コード例 #1
0
        public ProcessResult CreateSendListOnEuroMessage(string listName, string AuthenticationServiceKey)
        {
            try
            {
                SendList         sendList = new SendList();
                EmSendListResult emResult = sendList.CreateSendList(AuthenticationServiceKey, "CRM", listName);

                if (emResult.Code == "00")
                {
                    return(new ProcessResult(true, "", ""));
                }
                else
                {
                    return(new ProcessResult(false, "", emResult.Code));
                }
            }
            catch (Exception ex)
            {
                return(new ProcessResult(false, "", ex.Message));
            }
        }
コード例 #2
0
        public ProcessResult AddToSendLists(Guid campaignActivityId, string AuthenticationServiceKey, string listName, IOrganizationService service)
        {
            try
            {
                bool sonuc = false;

                #region |   Query Contact   |

                string queryList = @"SELECT
	                                    C.FirstName [FirstName],
	                                    C.LastName [LastName],
	                                    C.emailaddress1 [EmailAddress],
	                                    C.ContactId [ContactId]
                                    FROM
	                                    Contact C WITH(NOLOCK)
                                    WHERE
	                                    C.StateCode = 0
                                    AND
	                                    C.birthdate IS NOT NULL
                                    AND
	                                    LEFT((RIGHT(CONVERT(VARCHAR(10), dbo.fn_UTCToTzSpecificLocalTime(C.birthdate,-120,-60,0,3,5,3,0,0,0,1,0,0,1,5,4,0,0,0,0), 103), 10)), 5) = LEFT((RIGHT(CONVERT(VARCHAR(10), GETDATE(), 103), 10)), 5)
                                    AND
	                                    C.donotemail = 0
                                    AND
	                                    C.donotbulkemail = 0
                                    AND
	                                    C.emailaddress1 IS NOT NULL
                                    AND
	                                    C.new_email = 0"    ;
                sda.openConnection(Globals.ConnectionString);
                DataTable dt = sda.getDataTable(queryList, new SqlParameter("@campaignActivityId", campaignActivityId));
                sda.closeConnection();

                #endregion |   Query Contact   |

                List <sendlist.live.EmKeyValue[]> demographicDatas = new List <sendlist.live.EmKeyValue[]>();

                int counter = 0;

                foreach (DataRow dr in dt.Rows)
                {
                    Console.WriteLine("Sayaç:" + counter.ToString());

                    string firstName           = dr["FirstName"] != DBNull.Value ? dr["FirstName"].ToString() : "";
                    string lastName            = dr["LastName"] != DBNull.Value ? dr["LastName"].ToString() : "";
                    string customermailaddress = dr["EmailAddress"] != DBNull.Value ? dr["EmailAddress"].ToString() : "";
                    string customerId          = dr["ContactId"] != DBNull.Value ? dr["ContactId"].ToString() : "";

                    //Eğer Contact üzerindeki tüm EPosta alanları boş ise..
                    if (customermailaddress == "-1")
                    {
                        continue;
                    }

                    sendlist.live.EmKeyValue[] demographicData =
                    {
                        new sendlist.live.EmKeyValue()
                        {
                            Key = "EMAIL", Value = customermailaddress
                        },
                        new sendlist.live.EmKeyValue()
                        {
                            Key = "Adınız", Value = firstName
                        },
                        new sendlist.live.EmKeyValue()
                        {
                            Key = "Soyadınız", Value = lastName
                        },
                        new sendlist.live.EmKeyValue()
                        {
                            Key = "CustomerId", Value = customerId
                        }
                    };

                    demographicDatas.Add(demographicData);
                    Console.WriteLine(demographicDatas[counter][0].Value);

                    counter++;
                }

                int packetCount = 0;
                Console.WriteLine("Kişi Sayısı:" + demographicDatas.Count + " bir tuşa basınız");

                if (demographicDatas.Count > 0)
                {
                    packetCount = demographicDatas.Count / 2000;
                }

                Console.WriteLine("Paket Sayısı:" + packetCount.ToString() + " Devam etmek için tuşa basınız");

                List <BulkDetailedResult> resultList = new List <BulkDetailedResult>();

                for (int i = 0; i <= packetCount; i++)
                {
                    Console.WriteLine("Paket Sayısı:" + demographicDatas.Skip(2000 * i).Take(2000).ToArray().Length.ToString());
                    BulkDetailedResult[] results;
                    SendList             sendListService = new SendList();
                    sendListService.Timeout = 10000000;
                    Console.WriteLine("Toplu gönderim yapılacak.Bir tuşa basınız.");

                    EmSendListResult result = sendListService.AddBulk(AuthenticationServiceKey, "CRM", listName, "EMAIL", demographicDatas.Skip(2000 * i).Take(2000).ToArray(), true, out results);

                    if (result.Code == "00")
                    {
                        resultList.AddRange(results);
                        Console.WriteLine(i.ToString() + ". Paket Gönderildi.Bir Tuşa Basınız.");
                    }
                    else
                    {
                        Console.WriteLine("Hata:" + result.DetailedMessage);
                    }
                }

                if (resultList.Count > 0)
                {
                    sonuc = true;
                    Console.WriteLine("Kampanya Gönderildi. Adet:" + resultList.Count.ToString());
                }
                else
                {
                    return(new ProcessResult(false, "Hata", "Liste EuroMsg tarafına iletilemedi."));
                }

                if (sonuc == true)
                {
                    return(new ProcessResult(true, "", "00"));
                }
                else
                {
                    return(new ProcessResult(false, "", "99"));
                }
            }
            catch (Exception ex)
            {
                return(new ProcessResult(false, "", ex.StackTrace));
            }
        }