static getmainmail FromCsv(string csvLine) { string[] array = csvLine.Split(','); getmainmail getmainmailObj = new getmainmail(); VerifyEmailResponse verifyemailresponse = new VerifyEmailResponse(); VerifyEmailResult verifyemailres = new VerifyEmailResult(); verifyemailresponse.VerifyEmailResult = verifyemailres; ServiceResult servresult = new ServiceResult(); ServiceStatus servstatus = new ServiceStatus(); Hygiene hygieneobj = new Hygiene(); Email mailobject = new Email(); Reason Reasonobj = new Reason(); verifyemailres.ServiceStatus = servstatus; verifyemailres.ServiceResult = servresult; servresult.Reason = Reasonobj; servresult.Email = mailobject; servresult.Hygiene = hygieneobj; getmainmailObj.VerifyEmailResponse = verifyemailresponse; getmainmailObj.VerifyEmailResponse.VerifyEmailResult.ServiceResult.Email.Complete = array[0]; getmainmailObj.VerifyEmailResponse.VerifyEmailResult.ServiceStatus.StatusNbr = long.Parse(array[1]); getmainmailObj.VerifyEmailResponse.VerifyEmailResult.ServiceStatus.StatusDescription = array[2]; getmainmailObj.VerifyEmailResponse.VerifyEmailResult.ServiceResult.Reason.Code = long.Parse(array[3]); getmainmailObj.VerifyEmailResponse.VerifyEmailResult.ServiceResult.Reason.Description = array[4]; getmainmailObj.VerifyEmailResponse.VerifyEmailResult.ServiceResult.Hygiene.HygieneResult = array[5]; getmainmailObj.VerifyEmailResponse.VerifyEmailResult.ServiceResult.Hygiene.NetProtected = bool.Parse(array[6]); getmainmailObj.VerifyEmailResponse.VerifyEmailResult.ServiceResult.Hygiene.NetProtectedBy = array[7]; getmainmailObj.VerifyEmailResponse.VerifyEmailResult.ServiceResult.Email.LocalPart = array[11]; getmainmailObj.VerifyEmailResponse.VerifyEmailResult.ServiceResult.Email.DomainPart = array[12]; return(getmainmailObj); }
public static async Task AddItemstoMainContainer(getmainmail obj) { try { ItemResponse <getmainmail> Response = await azurecontainer.UpsertItemAsync <getmainmail>(obj); Console.WriteLine("updated item in database"); } catch (Exception e) { Console.WriteLine(e.Message); } }
public static async void processingmessage(BrokeredMessage message) { Dictionary <string, string> dict = new Dictionary <string, string>(); dict.Add("200", "EMAIL_VALID"); dict.Add("210", "DOMAIN_EXISTS"); dict.Add("220", "RETRY"); dict.Add("250", "EMAIL_EXISTS_BUT_SPAM"); dict.Add("260", "DOMAIN_EXISTS_BUT_SPAM"); dict.Add("270", "RETRY"); dict.Add("300", "EMAIL_NOT_VALID"); dict.Add("310", "DOMAIN_EXISTS_BUT_SPAM"); Stream stream = message.GetBody <Stream>(); StreamReader reader = new StreamReader(stream); string messagestring = reader.ReadToEnd(); Console.WriteLine(messagestring); JObject json = JObject.Parse(messagestring); string emailstatus = (string)json["activityType"]; string mailId = (string)json["mailid"]; string codeofstatus; getmainmail mainmail = new getmainmail(); if (emailstatus == "Open Email" || emailstatus == "Click Email" || emailstatus == "Email Delivered") { emailstatus = "Email Valid"; codeofstatus = "200"; mainmail = JsonConvert.DeserializeObject <getmainmail>(messagestring); VerifyEmailResponse verifyemailresponse = new VerifyEmailResponse(); VerifyEmailResult verifyemailres = new VerifyEmailResult(); verifyemailresponse.VerifyEmailResult = verifyemailres; ServiceResult servresult = new ServiceResult(); ServiceStatus servstatus = new ServiceStatus(); Hygiene hygieneobj = new Hygiene(); Email mailobject = new Email(); Reason Reasonobj = new Reason(); verifyemailres.ServiceStatus = servstatus; verifyemailres.ServiceResult = servresult; servresult.Reason = Reasonobj; servresult.Email = mailobject; servresult.Hygiene = hygieneobj; mainmail.VerifyEmailResponse = verifyemailresponse; mainmail.VerifyEmailResponse.VerifyEmailResult.ServiceResult.Email.Complete = mailId; mainmail.id = mainmail.VerifyEmailResponse.VerifyEmailResult.ServiceResult.Email.Complete; mainmail.partitionKey = mainmail.id.Substring(0, 2); var statusmail = await ReadItemsFromMainCollection(mainmail.id, new PartitionKey(mainmail.VerifyEmailResponse.VerifyEmailResult.ServiceResult.Email.Complete.Substring(0, 2))); mainmail.VerifyEmailResponse.VerifyEmailResult.ServiceStatus.StatusNbr = long.Parse(codeofstatus); mainmail.VerifyEmailResponse.VerifyEmailResult.ServiceStatus.StatusDescription = emailstatus; mainmail.VerifyEmailResponse.VerifyEmailResult.ServiceResult.Timestamp = DateTime.UtcNow; if (statusmail != codeofstatus && statusmail != "item not found") { signal SignalObject = new signal(); List <Attribute> attributelist = new List <Attribute>(); List <Key> keylist = new List <Key>(); Attribute attributeobjectnew = new Attribute(); Attribute attributeobjectold = new Attribute(); Guid g = Guid.NewGuid(); Key keyobject = new Key(); keyobject.value = mainmail.id; keylist.Add(keyobject); SignalObject.keys = keylist; SignalObject.correlationId = g.ToString(); SignalObject.originatingSystemDate = (DateTime)json["EventProcessedUtcTime"]; attributeobjectnew.key = "EmailMatchType.new"; attributeobjectnew.value = dict[codeofstatus]; attributeobjectold.key = "EmailMatchType.old"; attributeobjectold.value = dict[statusmail]; attributelist.Add(attributeobjectold); attributelist.Add(attributeobjectnew); SignalObject.attributes = attributelist; SignalObject.internalProcessingDate = DateTime.UtcNow; await SendSignalviaHttpAsync(SignalObject); } await AddItemstoMainContainer(mainmail); message.Complete(); Console.WriteLine("message deleted"); } else { mainmail = JsonConvert.DeserializeObject <getmainmail>(messagestring); VerifyEmailResponse verifyemailresponse = new VerifyEmailResponse(); VerifyEmailResult verifyemailres = new VerifyEmailResult(); verifyemailresponse.VerifyEmailResult = verifyemailres; ServiceResult servresult = new ServiceResult(); ServiceStatus servstatus = new ServiceStatus(); Hygiene hygieneobj = new Hygiene(); Email mailobject = new Email(); Reason Reasonobj = new Reason(); verifyemailres.ServiceStatus = servstatus; verifyemailres.ServiceResult = servresult; servresult.Reason = Reasonobj; servresult.Email = mailobject; servresult.Hygiene = hygieneobj; mainmail.VerifyEmailResponse = verifyemailresponse; // mainmail.VerifyEmailResponse.VerifyEmailResult.ServiceStatus.StatusDescription = emailstatus; mainmail.VerifyEmailResponse.VerifyEmailResult.ServiceResult.Email.Complete = mailId; mainmail.id = mailId; mainmail.partitionKey = mainmail.id.Substring(0, 2); var statusmail = await ReadItemsFromMainCollection(mainmail.id, new PartitionKey(mainmail.VerifyEmailResponse.VerifyEmailResult.ServiceResult.Email.Complete.Substring(0, 2))); if (statusmail == "item not found") { mainmail.BounceCount++; await AddItemstoMainContainer(mainmail); } else if (statusmail != "300" && statusmail != "item not found") { mainmail.VerifyEmailResponse.VerifyEmailResult.ServiceStatus.StatusNbr = long.Parse(statusmail); await getemailobject(mainmail.id); mainmail = emailist[0]; emailist[0].BounceCount++; await AddItemstoMainContainer(emailist[0]); Console.WriteLine(emailist[0].BounceCount); if (mainmail.BounceCount == 5) { emailstatus = "Email Not Valid"; codeofstatus = "300"; if (statusmail != codeofstatus && statusmail != "item not found" && statusmail != "300") { mainmail.VerifyEmailResponse.VerifyEmailResult.ServiceStatus.StatusDescription = emailstatus; mainmail.VerifyEmailResponse.VerifyEmailResult.ServiceStatus.StatusNbr = long.Parse(codeofstatus); mainmail.VerifyEmailResponse.VerifyEmailResult.ServiceResult.Timestamp = DateTime.UtcNow; if (statusmail != "0") { signal SignalObject = new signal(); List <Attribute> attributelist = new List <Attribute>(); Attribute attributeobjectnew = new Attribute(); Attribute attributeobjectold = new Attribute(); List <Key> keylist = new List <Key>(); Guid g = Guid.NewGuid(); Key keyobject = new Key(); keyobject.value = mainmail.id; keylist.Add(keyobject); SignalObject.keys = keylist; SignalObject.correlationId = g.ToString(); SignalObject.originatingSystemDate = (DateTime)json["EventProcessedUtcTime"]; attributeobjectnew.key = "EmailMatchType.new"; attributeobjectnew.value = dict[codeofstatus]; attributeobjectold.key = "EmailMatchType.old"; attributeobjectold.value = dict[statusmail]; attributelist.Add(attributeobjectold); attributelist.Add(attributeobjectnew); SignalObject.attributes = attributelist; SignalObject.internalProcessingDate = DateTime.UtcNow; await SendSignalviaHttpAsync(SignalObject); } await AddItemstoMainContainer(mainmail); } } } message.Complete(); Console.WriteLine("message deleted"); } }