Exemplo n.º 1
0
        private void Find()
        {
            var workingFilter   = string.Format("(workingfrom is null or workingfrom < '{0:yyyyMMdd HH:mm:ss}') and (workingtill is null or workingtill > '{1:yyyyMMdd HH:mm:ss}')", DateTill, DateFrom);
            var workFilter      = string.Format("workid in (select workid_r from wmsworking where {0})", workingFilter);
            var operationFilter = string.Format("operationcode in (select operationcode_r from wmswork where workid in (select workid_r from wmsworking where {0}))", workingFilter);
            var workerFilter    = string.Format("workerid in (select workerid_r from wmsworking where {0})", workingFilter);

            IEnumerable <Work> works;

            using (var mgr = IoC.Instance.Resolve <IBaseManager <Work> >())
                works = mgr.GetFiltered(workFilter);

            IEnumerable <Working> workings;

            using (var mgr = IoC.Instance.Resolve <IBaseManager <Working> >())
                workings = mgr.GetFiltered(workingFilter);

            IEnumerable <Worker> workers;

            using (var mgr = IoC.Instance.Resolve <IBaseManager <Worker> >())
                workers = mgr.GetFiltered(workerFilter);

            IEnumerable <BillOperation> operations;

            using (var mgr = IoC.Instance.Resolve <IBaseManager <BillOperation> >())
                operations = mgr.GetFiltered(operationFilter);

            // операции становятся
            Operations.Clear();
            foreach (var operation in operations)
            {
                var op = new OperationModel()
                {
                    Id = Operations.Count, Code = operation.OperationCode, Name = operation.OperationName, ClassCode = operation.OperationClassCode
                };
                Operations.Add(op);
            }

            // работники становятся ресурсами
            Resources.Clear();
            foreach (var worker in workers)
            {
                var res = new ResourceModel(worker);
                Resources.Add(res);
            }

            // выполнения становятся событиями
            Appointments.Clear();
            foreach (var working in workings)
            {
                var work      = works.First(i => i.GetKey <decimal>() == working.WORKID_R);
                var operation = Operations.First(i => i.Code == work.OPERATIONCODE_R);
                var worker    = Resources.First(i => i.Id == working.WORKERID_R);
                var label     = Labels.First(i => i.Code == operation.ClassCode);
                var a         = new AppointmentModel(working, operation, worker, label);
                Appointments.Add(a);
            }
        }
Exemplo n.º 2
0
        public AppointmentModel(Working working, OperationModel operationModel, ResourceModel resourceModel, LabelModel label)
        {
            Working     = working;
            StartTime   = working.WORKINGFROM.Value;
            WorkerId    = Convert.ToInt32(working.WORKERID_R);
            OperationId = operationModel.Id;
            ResourceId  = string.Format("<ResourceIds>\r\n<ResourceId Type=\"System.Int32\" Value=\"{0}\" />\r\n</ResourceIds>", WorkerId);

            if (working.WORKINGTILL.HasValue)
            {
                EndTime     = working.WORKINGTILL.Value;
                IsCompleted = true;
            }
            else
            {
                EndTime = DateTime.Now;
            }

            Status  = IsCompleted ? 1 : 0;
            Label   = label.Id;
            Subject = string.Format("{0} ({1})", operationModel.Name, EndTime - StartTime);
        }