Beispiel #1
0
        public override IEnumerable <AbsSynchroDataInfo> GetK3Datas(IEnumerable <string> billNos = null, bool flag = true)
        {
            List <OnTheWay>      ways   = null;
            OnTheWay             way    = null;
            List <OnTheWayEntry> entrys = null;
            OnTheWayEntry        entry  = null;

            DynamicObjectCollection coll = SQLUtils.GetObjects(this.K3CloudContext, GetSQL());
            var group = from g in coll
                        orderby SQLUtils.GetFieldValue(g, "FMaterialId"), Convert.ToDateTime(SQLUtils.GetFieldValue(g, "FDeliveryDate"))
            group g by SQLUtils.GetFieldValue(g, "FMaterialId")
            into c
            select c;

            if (group != null && group.Count() > 0)
            {
                ways = new List <OnTheWay>();

                foreach (var item in group)
                {
                    if (item != null)
                    {
                        way    = new OnTheWay();
                        entrys = new List <OnTheWayEntry>();

                        way.FMaterialId = SQLUtils.GetFieldValue(item.ElementAt(0), "FMaterialId");
                        way.SrcNo       = way.FMaterialId;

                        if (item != null && item.Count() > 0)
                        {
                            foreach (var obj in item)
                            {
                                if (obj != null)
                                {
                                    entry = new OnTheWayEntry();

                                    entry.FStockId      = SQLUtils.GetFieldValue(obj, "FStockId");
                                    entry.FDeliveryDate = Convert.ToDateTime(SQLUtils.GetFieldValue(obj, "FDeliveryDate")).ToString();
                                    entry.FQty          = Convert.ToDecimal(SQLUtils.GetFieldValue(obj, "FQTY"));

                                    entrys.Add(entry);
                                }
                            }

                            way.Entry = entrys;
                            ways.Add(way);
                        }
                    }
                }
                DateTime now = DateTime.Now;
                SynchroDataLog.Add(now, ways.Select(w => w.SrcNo));
                BeforeSynchroOperate(now);
            }

            return(ways);
        }
Beispiel #2
0
        public override void UpdateAmounts()
        {
            List <Vesicle> dump = new List <Vesicle>();

            for (int i = 0; i < OnTheWay.Count; i++)
            {
                OnTheWay[i].DecreaseDist();
                if (OnTheWay[i].GetDist() < 1)
                {
                    AddResource(OnTheWay[i].GetAmount(), OnTheWay[i].GetRes());
                    dump.Add(OnTheWay[i]);
                    if (contents[(int)OnTheWay[i].GetRes()] > parent.MAX)
                    //in case of overflow discards excess
                    {
                        contents[(int)OnTheWay[i].GetRes()] = parent.MAX;
                    }
                }
            }
            foreach (Vesicle vesicle in dump)
            {
                OnTheWay.Remove(vesicle);
            }
            dump = new List <Vesicle>();
        }