예제 #1
0
        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;
        }