Beispiel #1
0
        public HoneywellPBFile LoadFile(string fileName, string plant, DateTime currentDay)
        {
            Filename = fileName;
            HoneywellPBFile pf = new HoneywellPBFile(fileName, plant);

            pf.IsCurrentDay(currentDay);
            string fileText = File.ReadAllText(fileName);

            if (string.IsNullOrEmpty(fileText))
            {
                throw new Exception("File is empty");
            }
            fileText = fileText.Replace("\r", "");  // only care about \n
            Contents fileContents    = GetTagContents(fileText, "<<NP UPLOAD FILE>>");
            Contents defaultContents = GetTagContents(fileContents.TagContents, "<<DEFAULTS>>");

            pf.SetDefaults(ParseCSVContents(defaultContents.TagContents));
            pf.SetValues(ParseCSVContents(defaultContents.OuterContents));

            Contents balanceContents = GetTagContents(fileContents.TagContents, "<<START BALANCE REC>>");

            pf.BalanceRecords = GetBalanceRecords(defaultContents.OuterContents, pf);


            foreach (var item in pf.ProductionRecords())
            {
                item.TagBalance(currentDay);
            }

            return(pf);
        }
        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);
        }
Beispiel #3
0
        private List <BalanceRecord> GetBalanceRecords(string contents, HoneywellPBFile pf)
        {
            List <BalanceRecord> bals = new List <BalanceRecord>();

            while (true)
            {
                ContentTag tag = GetNextFileTag(contents);
                if (tag == null)
                {
                    break;
                }
                if (tag.Name != "BALANCE REC")
                {
                    throw new Exception("Tag does not match BALANCE REC:" + tag.Name);
                }
                BalanceRecord br = new BalanceRecord();
                br.SetValues(ParseCSVContents(tag.InnerContents));
                br.ProductionRecords = GetProductionRecords(tag.InnerContents, pf);
                contents             = contents.Substring(tag.End);
                bals.Add(br);
            }
            return(bals);
        }
Beispiel #4
0
        private List <HoneywellPBProductionRecord> GetProductionRecords(string contents, HoneywellPBFile pf)
        {
            List <HoneywellPBProductionRecord> recs = new List <HoneywellPBProductionRecord>();

            while (true)
            {
                ContentTag tag = GetNextFileTag(contents);
                if (tag == null)
                {
                    break;
                }
                if (tag.Name != "PRODUCT REC")
                {
                    throw new Exception("Tag does not match PRODUCT REC:" + tag.Name);
                }

                HoneywellPBProductionRecord pr = new HoneywellPBProductionRecord(ParseCSVContents(tag.InnerContents), pf);
                recs.Add(pr);
                contents = contents.Substring(tag.End);
            }
            return(recs);
        }
 public decimal GetDecimalValue(string v)
 {
     return(HoneywellPBFile.ParseDecimal(Values[v]));
 }
 public HoneywellPBProductionRecord(Dictionary <string, string> values, HoneywellPBFile pf)
 {
     ProductionFile = pf;
     Values         = values;
 }