public void SendBogusTagBalanceToMuleSoft() { MulesoftPush.SetConnection("https://api-rtfdev.sequt.com/azureiot-experience-api/api/v1/azureiot-experience-api/production-posting", "20da7837f9574f03adb6fca17301f75a", "63e0E42AaDbA4815bD6B002E70E9B321"); HoneywellPBFile pf = new HoneywellPBFile("filename", "CP04"); List <TagBalance> items = new List <TagBalance>(); var tb = new TagBalance(); tb.MovementType = "Production"; tb.System = "Honeywell PB"; tb.Tag = "asdf"; tb.Quantity = 44; tb.Created = DateTime.Now; tb.BalanceDate = DateTime.Now; tb.QuantityTimestamp = DateTime.Now; tb.CreatedBy = "cab"; tb.StandardUnit = "BBL"; tb.Plant = "cab"; tb.ValType = "cab"; tb.WorkCenter = "cab"; tb.Material = "123"; items.Add(tb); pf.SavedRecords = new List <TagBalance>(); pf.SavedRecords.Add(tb); var json = pf.ExportR2PJson(); Console.WriteLine(json); MulesoftPush.PostProduction(json); }
public void PostMulesoftTest() { MulesoftPush.SetConnection("https://api-rtfdev.sequt.com/azureiot-experience-api/api/v1/azureiot-experience-api/production-posting", "20da7837f9574f03adb6fca17301f75a", "63e0E42AaDbA4815bD6B002E70E9B321"); // good string jsonGood = "{\n \"BatchId\": \"76347512-0c9e-47f5-9123-b9266218404b\",\n \"Created\": \"2021-02-05T09:00:00\",\n \"CreatedBy\": \"R2P\",\n \"TagBalance\": [\n {\n \"Tag\": \"EP01_OIL-STORAGE-CORR-LD\",\n \"Material\": \"11234\",\n \"Plant\": \"EP01\",\n \"WorkCenter\": \"PRODEP01\",\n \"ValType\": \"RTFTest2\",\n \"BalanceDate\": \"2019-10-01T00:00:00\",\n \"Quantity\": \"7075\",\n \"Uom\": \"M3\"\n } ]\n}"; string jsonFailure = "{\"BatchId\":\"890703ed-45f0-4c60-89c8-4dce394d9e53\",\"Created\": \"2021-02-05T09:00:00\", \"CreatedBy\": \"R2P\", \"TagBalance\":[{\"Date\":\"2021-02-17T00:59:00\",\"Tag\":\"BCNRL\",\"System\":\"Honeywell PB\",\"MovementType\":\"Production\",\"Material\":\"10029\",\"Plant\":\"CP04\",\"WorkCenter\":\"PRODCP04\",\"ValType\":\"SUNCOR\",\"BalanceDate\":\"2021-02-17T00:59:00\",\"Quantity\":-1113075.000,\"StandardUnit\":\"M15\"},{\"Date\":\"2021-02-17T00:59:00\",\"Tag\":\"BSUNOSP\",\"System\":\"Honeywell PB\",\"MovementType\":\"Production\",\"Material\":\"10025\",\"Plant\":\"CP04\",\"WorkCenter\":\"PRODCP04\",\"ValType\":\"SUNCOR\",\"BalanceDate\":\"2021-02-17T00:59:00\",\"Quantity\":-5000.000,\"StandardUnit\":\"M15\"}]}"; string json = "{\"BatchId\":\"890703ed-45f0-4c60-89c8-4dce394d9e53\",\"Created\": \"2021-02-05T09:00:00\", \"CreatedBy\": \"R2P\",\"TagBalance\":[{\"Date\":\"2021-02-17T00:59:00\",\"Tag\":\"BCNRL\",\"System\":\"Honeywell PB\",\"MovementType\":\"Production\",\"Material\":\"10029\",\"Plant\":\"CP04\",\"WorkCenter\":\"PRODCP04\",\"ValType\":\"SUNCOR\",\"BalanceDate\":\"2021-02-17T00:59:00\",\"Quantity\":\"-1113075.000\",\"Uom\":\"M15\"}]}"; MulesoftPush.PostProduction(json); }
public void ProcessFile(ILogger log, string version) { SuncorProductionFile.SetLogFileWriter(LogHelper.WriteLogFile); this.ProducitionFile = null; DateTime day = GetCurrentDay(this.PlantName); if (this.IsHoneywellPB) { this.ProducitionFile = new HoneywellPBParser().LoadFile(this.TempFileName, this.PlantName, day); } if (this.IsMontrealSulphur) { this.ProducitionFile = new MontrealSulphurParser().LoadFile(this.TempFileName, this.PlantName, this.ProductCode, day); } if (this.IsDPS) { this.ProducitionFile = new DPSParser().LoadFile(this.TempFileName, this.PlantName, day); } if (this.IsDenver) { this.ProducitionFile = new SigmafineParser().LoadExcel(this.TempFileName, this.PlantName, day); } if (this.IsTerraNova) { this.ProducitionFile = new TerraNovaParser().LoadFile(this.TempFileName, this.PlantName, day); } if (this.IsSarnia) { } if (this.ProducitionFile != null) { this.ProducitionFile.SaveRecords(); this.SuccessfulRecords = this.ProducitionFile.SavedRecords.Count; this.FailedRecords = this.ProducitionFile.FailedRecords.Count; if (this.ProducitionFile.SavedRecords.Count > 0) { string json = this.ProducitionFile.ExportR2PJson(); if (!MulesoftPush.PostProduction(json)) { LogHelper.LogSystemError(log, version, "Json NOT sent to Mulesoft"); this.ProducitionFile.Warnings.Add(new WarningMessage("Json NOT sent to Mulesoft")); } AzureFileHelper.WriteFile(this.AzureFullPathName.Replace("immediateScan", "tempJsonOutput") + ".json", json, false); } } }
public static void SetConnection(ExecutionContext context, ILogger log) { IConfiguration iconfig = new ConfigurationBuilder() .AddEnvironmentVariables() // needed for the ConnectionString - comes from local.settings.json or Azure Function Configuration // .AddJsonFile("local.settings.json", true, true) .Build(); string cs = iconfig["ConnectionStrings:DataHub"]; string aw = Utilities.GetEnvironmentVariable("AzureWebJobsStorage"); // log.LogInformation($"Connection String:" + cs); //log.LogInformation($"AW Storage:" + aw); //AzureFileHelper.WriteFile("system/" + ".AzureDataHubProduction.SS.log", cs == null ? "empty - connection" : "cs:" + cs, true); //AzureFileHelper.WriteFile("system/" + ".AzureDataHubProduction.SS.log", aw == null ? "empty - storage" : "env:" + aw, true); DBContextWithConnectionString.SetConnectionString(cs); string Url = iconfig["MuleSoftUrl"]; string User = iconfig["MuleSoftUser"]; string PW = iconfig["MuleSoftPassword"]; string stop = iconfig["DoNotSendToMuleSoft"]; MulesoftPush.SetConnection(stop == "true" ? null : Url, User, PW); }