0

`

using (var s = webRequest.GetResponse().GetResponseStream())
            {
                using (var sr = new StreamReader(s))
                {
                    var entitydatafromMysql = sr.ReadToEnd();
                    string bsObj2 = string.Empty;
                    if (entitydatafromMysql.Contains("Success0:"))
                    {
                        DataContractJsonSerializer deserializer = new DataContractJsonSerializer(typeof(string));
                        using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(entitydatafromMysql)))
                        {
                            bsObj2 = (string)deserializer.ReadObject(ms);
                            bsObj2 = bsObj2.Remove(0, 9);
                            dtMySQLdata = (DataTable)JsonConvert.DeserializeObject(bsObj2, (typeof(DataTable)));

                            for (int i = 0; i < dtMySQLdata.Rows.Count; i++)
                            {
                                Entity entity = new Entity("efl_archivalemail");
                                entity["efl_archivalemailid"] = Convert.ToString(dtMySQLdata.Rows[i]["activityid"]);
                                entity.Id = new Guid(Convert.ToString(dtMySQLdata.Rows[i]["activityid"]));
                                entity["efl_name"] = Convert.ToString(dtMySQLdata.Rows[i]["sender"]);
                                entity["efl_description"] = Convert.ToString(dtMySQLdata.Rows[i]["description"]);
                                ec.Entities.Add(entity);
                            }
                        }
                    }
                    else
                    {
                        throw new InvalidPluginExecutionException(entitydatafromMysql);
                    }
                }
            }

`

This is a plugin code so I am using POST API to connect and get data FROM mysql database. I know I need to map CRM and Mysql entity attributes but I can only access CRM attributes by IserviceProviders execution context how can I do this?

Jdz777
  • 1
  • 1
  • Please revise the title and question body. It looks a part of question is included in the title – MD Zand Nov 28 '22 at 13:05

0 Answers0