Пример #1
0
        public void FillData(WMSBusinessObject entity)
        {
            var obj = entity as CargoOWB;

            if (obj == null)
            {
                return;
            }

            obj.Vehicle   = null;
            obj.WorkerFIO = null;
            if (obj.InternalTrafficID == null)
            {
                return;
            }

            InternalTraffic it;

            using (var mgr = GetManager <InternalTraffic>())
                it = mgr.Get(obj.InternalTrafficID, GetModeEnum.Partial);

            if (it.ExternalTrafficID == null)
            {
                return;
            }

            ExternalTraffic et = null;

            using (var mgrET = GetManager <ExternalTraffic>())
                et = mgrET.Get(it.ExternalTrafficID);
            if (et == null)
            {
                return;
            }

            if (et.VVehicleRN != null)
            {
                obj.Vehicle = et.VVehicleRN;
            }

            if (et.Driver == null)
            {
                return;
            }

            Worker worker = null;

            using (var mgrWorker = GetManager <Worker>())
                worker = mgrWorker.Get(et.Driver);

            if (worker == null)
            {
                return;
            }

            if (worker.WorkerFIO != null)
            {
                obj.WorkerFIO = worker.WorkerFIO;
            }
        }
Пример #2
0
        public bool FillMandant(InternalTraffic internalTraffic)
        {
            if (internalTraffic.ExternalTrafficID == null)
            {
                return(false);
            }

            ExternalTraffic ext = null;

            using (var mgrExtTraffic = GetManager <ExternalTraffic>())
                ext = mgrExtTraffic.Get(internalTraffic.ExternalTrafficID);
            if (ext == null)
            {
                if (internalTraffic.MandantID == null)
                {
                    return(false);
                }
                internalTraffic.MandantID = null;
                return(false);
            }

            var list = ext.InternalTrafficList;

            if (list == null)
            {
                if (internalTraffic.MandantID == null)
                {
                    return(false);
                }
                internalTraffic.MandantID = null;
                return(false);
            }

            IEnumerable <InternalTraffic> result = list.OrderBy(x => x.DateIns).ThenBy(x => x.DateUpd);
            var mandant = result.Last().MandantID;

            if (mandant == internalTraffic.MandantID)
            {
                return(false);
            }

            internalTraffic.MandantID = mandant;
            return(true);
        }