Beispiel #1
0
        public List <CommContracts.WorkPlanToSignalSource> GetAllWorkPlan111(int DepartmentID, DateTime startDate, DateTime endDate)
        {
            List <CommContracts.WorkPlanToSignalSource> list = new List <CommContracts.WorkPlanToSignalSource>();

            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                //var query = from a in ctx.WorkPlans
                //            from b in ctx.SignalTypes
                //            where
                //            (DepartmentID <= 0 || a.DepartmentID == DepartmentID) &&
                //            a.WorkTypeID == b.WorkTypeID &&
                //            a.WorkPlanDate.Value <= endDate &&
                //            a.WorkPlanDate.Value >= startDate &&
                //            (a.WorkPlanStatus == DAL.WorkPlanStatus.eIsOk || a.WorkPlanStatus == DAL.WorkPlanStatus.eIsTempStop)
                //            select a;

                var query = from w in ctx.WorkPlans
                            from s in ctx.SignalTypes
                            from j in ctx.EmployeeJobHistorys
                            where w.DepartmentID == DepartmentID &&
                            w.WorkPlanDate.Value <= endDate &&
                            w.WorkPlanDate.Value >= startDate &&
                            w.WorkPlanStatus == DAL.WorkPlanStatus.eIsOk &&
                            s.WorkTypeID == w.WorkTypeID &&
                            w.Employee.ID == j.EmployeeID &&
                            !j.EndDate.HasValue &&
                            j.JobID == s.JobID


                            select new { w, s };

                int n = query.Count();


                foreach (var temp in query)
                {
                    var config = new MapperConfiguration(cfg =>
                    {
                        cfg.CreateMap <DAL.WorkPlan, CommContracts.WorkPlan>();
                    });
                    var mapper = config.CreateMapper();

                    CommContracts.WorkPlan w = mapper.Map <CommContracts.WorkPlan>(temp.w);

                    var config1 = new MapperConfiguration(cfg =>
                    {
                        cfg.CreateMap <DAL.SignalType, CommContracts.SignalType>();
                    });
                    var mapper1 = config1.CreateMapper();

                    CommContracts.SignalType s = mapper1.Map <CommContracts.SignalType>(temp.s);

                    CommContracts.WorkPlanToSignalSource ws = new CommContracts.WorkPlanToSignalSource();
                    ws.WorkPlan   = w;
                    ws.SignalType = s;
                    list.Add(ws);
                }
            }
            return(list);
        }
Beispiel #2
0
        public List <CommContracts.WorkPlan> GetWorkPlanList(int DepartmentID, int EmployeeID, DateTime startDate, DateTime endDate, int ClinicVistTimeID)
        {
            List <CommContracts.WorkPlan> list = new List <CommContracts.WorkPlan>();

            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                var query = from a in ctx.WorkPlans
                            from b in ctx.SignalTypes
                            where
                            (DepartmentID <= 0 || a.DepartmentID == DepartmentID) &&
                            (EmployeeID <= 0 || a.EmployeeID == EmployeeID) &&
                            (ClinicVistTimeID <= 0 || a.ShiftID == ClinicVistTimeID) &&
                            a.WorkTypeID == b.WorkTypeID &&
                            a.WorkPlanDate.Value <= endDate &&
                            a.WorkPlanDate.Value >= startDate &&
                            (a.WorkPlanStatus == DAL.WorkPlanStatus.eIsOk || a.WorkPlanStatus == DAL.WorkPlanStatus.eIsTempStop)
                            select a;
                foreach (DAL.WorkPlan ass in query)
                {
                    var config = new MapperConfiguration(cfg =>
                    {
                        cfg.CreateMap <DAL.WorkPlan, CommContracts.WorkPlan>();
                    });
                    var mapper = config.CreateMapper();

                    CommContracts.WorkPlan temp = mapper.Map <CommContracts.WorkPlan>(ass);

                    list.Add(temp);
                }
            }
            return(list);
        }
Beispiel #3
0
        public bool UpdateWorkPlan(CommContracts.WorkPlan signalSource)
        {
            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                var temp = ctx.WorkPlans.FirstOrDefault(m => m.ID == signalSource.ID);
                if (temp != null)
                {
                    temp.WorkPlanDate   = signalSource.WorkPlanDate;
                    temp.WorkTypeID     = signalSource.WorkTypeID;
                    temp.EmployeeID     = signalSource.EmployeeID;
                    temp.DepartmentID   = signalSource.DepartmentID;
                    temp.ShiftID        = signalSource.ShiftID;
                    temp.WorkPlanStatus = (DAL.WorkPlanStatus)signalSource.WorkPlanStatus;
                    temp.MaxNum         = signalSource.MaxNum;
                }
                else
                {
                    return(false);
                }

                try
                {
                    ctx.SaveChanges();
                }
#pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过
                catch (Exception ex)
#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #4
0
        public bool SaveWorkPlan(CommContracts.WorkPlan signalSource)
        {
            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                var config = new MapperConfiguration(cfg =>
                {
                    cfg.CreateMap <CommContracts.WorkPlan, DAL.WorkPlan>();
                });
                var mapper = config.CreateMapper();

                DAL.WorkPlan temp = new DAL.WorkPlan();
                temp = mapper.Map <DAL.WorkPlan>(signalSource);

                ctx.WorkPlans.Add(temp);
                try
                {
                    ctx.SaveChanges();
                }
#pragma warning disable CS0168 // 声明了变量“ex”,但从未使用过
                catch (Exception ex)
#pragma warning restore CS0168 // 声明了变量“ex”,但从未使用过
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #5
0
        public List <CommContracts.WorkPlan> GetAllWorkPlan()
        {
            List <CommContracts.WorkPlan> list = new List <CommContracts.WorkPlan>();

            using (DAL.HisContext ctx = new DAL.HisContext())
            {
                var query = from a in ctx.WorkPlans
                            select a;
                foreach (DAL.WorkPlan ass in query)
                {
                    var config = new MapperConfiguration(cfg =>
                    {
                        cfg.CreateMap <DAL.WorkPlan, CommContracts.WorkPlan>();
                    });
                    var mapper = config.CreateMapper();

                    CommContracts.WorkPlan temp = mapper.Map <CommContracts.WorkPlan>(ass);
                    list.Add(temp);
                }
            }
            return(list);
        }
Beispiel #6
0
        /// <summary>
        /// 从界面中得到需要保存的排班记录列表
        /// 注意:界面上是从周一到周日分别对应的是0-6
        ///       然而,外国的一周是从周日开始的,所以枚举类型DayOfWeek是周日到周一对应0-6
        ///       会造成Bug
        /// </summary>
        /// <returns></returns>
        private List <CommContracts.WorkPlan> getSignalsFromView()
        {
            var vm = this.DataContext as HISGUIDoctorVM;

            CommClient.Employee employeeClient = new CommClient.Employee();

            var department = employeeClient.GetCurrentDepartment(vm.CurrentUser.ID);

            if (department == null)
            {
                return(null);
            }
            if (department.ID < 0)
            {
                return(null);
            }

            List <PaiBan> list = this.DateClinicMsgGrid.ItemsSource as List <PaiBan>;

            if (list == null)
            {
                return(null);
            }

            List <CommContracts.WorkPlan> sourceList = new List <CommContracts.WorkPlan>();

            for (int i = 0; i < list.Count; i++)
            {
                PaiBan paiBan = list.ElementAt(i);
                if (paiBan == null)
                {
                    continue;
                }

                if (paiBan.EmployeeID <= 0)
                {
                    continue;
                }

                for (int week = 0; week < 7; week++)
                {
                    if (paiBan.WorkPlanWorkTypeList[week] != null)
                    {
                        if (paiBan.WorkPlanWorkTypeList[week].ID == 0)
                        {
                            continue;
                        }

                        CommContracts.WorkPlan signalSource = new CommContracts.WorkPlan();
                        signalSource.ID           = paiBan.WorkPlanIDList[week];
                        signalSource.DepartmentID = department.ID;
                        signalSource.EmployeeID   = paiBan.EmployeeID;
                        signalSource.WorkTypeID   = paiBan.WorkPlanWorkTypeList[week].ID;
                        signalSource.ShiftID      = paiBan.ShiftID;
                        signalSource.MaxNum       = paiBan.MaxVistNum;


                        if (week == 0)
                        {
                            signalSource.WorkPlanDate = getMonday(currentManageDate).AddDays(6);
                        }
                        else
                        {
                            signalSource.WorkPlanDate = getMonday(currentManageDate).AddDays(week - 1);
                        }


                        if (signalSource.WorkPlanDate.Value.Date >= DateTime.Now.Date)
                        {
                            sourceList.Add(signalSource);
                        }
                    }
                }
            }
            return(sourceList);
        }