static async Task Main(string[] args) { string strFilePath = @"C:\Users\Lenovo\Documents\emailvalidation_Processed.csv"; DateTime lastModified = System.IO.File.GetLastWriteTime(strFilePath).ToUniversalTime(); DownloadFileFromInformatica(); process p = new process(); Program pobject = new Program(); await pobject.GetReferencing(); p.cosmosClient = pobject.cosmosClient; p.database = pobject.database; p.containermain = pobject.containermain; p.containerretry = pobject.containerretry; List <getmainmail> responses = File.ReadAllLines(@"C:\Users\Lenovo\Documents\emailvalidation_Processed.csv").Skip(1).Select(v => FromCsv(v)).ToList(); 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"); foreach (var value in responses) { value.id = value.VerifyEmailResponse.VerifyEmailResult.ServiceResult.Email.Complete; if (value.VerifyEmailResponse.VerifyEmailResult.ServiceStatus.StatusNbr != 220 && value.VerifyEmailResponse.VerifyEmailResult.ServiceStatus.StatusNbr != 270) { signal SignalObject = new signal(); Key keyobject = new Key(); List <Key> keyslist = new List <Key>(); keyobject.value = value.id; keyslist.Add(keyobject); SignalObject.keys = keyslist; List <Attribute> attributelist = new List <Attribute>(); Attribute attributeobjectnew = new Attribute(); Attribute attributeobjectold = new Attribute(); Guid g = Guid.NewGuid(); SignalObject.correlationId = g.ToString(); attributeobjectnew.key = "EmailMatchType.new"; attributeobjectnew.value = dict[value.VerifyEmailResponse.VerifyEmailResult.ServiceStatus.StatusNbr.ToString()]; attributeobjectold.key = "EmailMatchType.old"; attributeobjectold.value = dict["220"]; attributelist.Add(attributeobjectnew); attributelist.Add(attributeobjectold); SignalObject.attributes = attributelist; SignalObject.originatingSystemDate = lastModified; SignalObject.internalProcessingDate = DateTime.UtcNow; value.partitionKey = value.id.Substring(0, 2); await SendSignalviaHttpAsync(SignalObject); await p.AddingAndDeleting(value); } } }
public static async Task SendSignalviaHttpAsync(signal signalObject) { var token = new AzureServiceTokenProvider("RunAs=App;AppId=aa0c3919-10cc-41aa-b236-35329c72ce95;TenantId=72f988bf-86f1-41af-91ab-2d7cd011db47;CertificateThumbprint=624225424959582dc202a153b69aa7f85c90c57b;CertificateStoreLocation=CurrentUser"); var requiredtoken = await token.GetAccessTokenAsync("https://activitystore-ppe.trafficmanager.net"); HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", requiredtoken); var json = JsonConvert.SerializeObject(signalObject); var data = new StringContent(json, Encoding.UTF8, "application/json"); var signalurl = "https://activitystore-ppe.trafficmanager.net/signalacquisition-dev/api/v1/signal"; var response = await client.PostAsync(signalurl, data); string result = await response.Content.ReadAsStringAsync(); Console.WriteLine(result); }