public static void LogSuccess(string fileName, SuncorProductionFile pf, int successCount, int failedCount) { string info = "File " + fileName + " successfully loaded " + successCount + " records loaded with " + failedCount + " records not loaded"; string msg = DateTime.Now.ToUniversalTime() + ":" + info; LogWriter(pf.Plant, msg); }
public void TagBalance(DateTime currentDay) { decimal quantity; string product = this.GetValue("PRODUCT_CODE"); DateTime balanceDate = this.ProductionFile.GetAccountDate(); try { quantity = this.GetAMMDTQuantity(); } catch (Exception ex) { SuncorProductionFile.Log(this.ProductionFile.Plant, "NET YIELD FAILED : " + ex.Message + " for " + balanceDate + "," + this.ProductionFile.Plant + "," + product); this.ProductionFile.FailedRecords.Add(new TagBalance() { Tag = product, BalanceDate = balanceDate }); this.ProductionFile.Warnings.Add(new WarningMessage(product, "NET YIELD FAILED : " + ex.Message + " for " + balanceDate + "," + this.ProductionFile.Plant + "," + product)); return; } this.ProductionFile.AddTagBalance(currentDay, "Honeywell PB", product, balanceDate, quantity); }
public void AddTagBalance(DateTime currentDay, string system, string productCode, DateTime day, decimal quantity) { TagBalance tb = new TagBalance(); tb.MovementType = "Production"; tb.System = system; tb.Tag = productCode; tb.Plant = this.Plant; tb.Created = DateTime.Now; tb.BalanceDate = day; tb.QuantityTimestamp = DateTime.Now; tb.CreatedBy = "STransform"; TagMap tm = AzureModel.LookupTag(tb.Tag, tb.Plant); if (tm == null) { SuncorProductionFile.Log(this.Plant, "no TagMapping found for " + tb.BalanceDate + "," + tb.Plant + "," + tb.Tag); Warnings.Add(new WarningMessage(tb.Tag, "No TagMapping")); this.FailedRecords.Add(tb); return; } tb.StandardUnit = tm.DefaultUnit; tb.Plant = tm.Plant; tb.ValType = tm.DefaultValuationType; tb.WorkCenter = tm.WorkCenter; tb.Material = tm.MaterialNumber; tb.Quantity = Math.Round(quantity, 3); tb.BatchId = this.BatchId.ToString(); if (!IsDayValid(day, currentDay)) { this.Warnings.Add(new WarningMessage(tb.Tag, "Invalid Date " + day.ToString("yyyy/MM/dd"))); this.FailedRecords.Add(tb); } else { this.Products.Add(tb); } return; }
public void RecordSuccess(string fileName) { AzureModel.RecordStats(this, fileName, Warnings); SuncorProductionFile.LogSuccess(fileName, this, SavedRecords.Count, FailedRecords.Count); }