コード例 #1
0
        public async Task <ActionResult> Save(ScheduleDetailViewModel model)
        {
            using (ScheduleDetailServiceClient client = new ScheduleDetailServiceClient())
            {
                ScheduleDetail obj = new ScheduleDetail()
                {
                    Key = new ScheduleDetailKey()
                    {
                        ScheduleName = model.ScheduleName,
                        ShiftName    = model.ShiftName
                    },
                    Editor     = User.Identity.Name,
                    EditTime   = DateTime.Now,
                    CreateTime = DateTime.Now,
                    Creator    = User.Identity.Name
                };
                MethodReturnResult rst = await client.AddAsync(obj);

                if (rst.Code == 0)
                {
                    rst.Message = string.Format(FMMResources.StringResource.ScheduleDetail_Save_Success
                                                , obj.Key);
                }
                return(Json(rst));
            }
        }
コード例 #2
0
        public async Task <ActionResult> Delete(string scheduleName, string shiftName)
        {
            MethodReturnResult result = new MethodReturnResult();

            using (ScheduleDetailServiceClient client = new ScheduleDetailServiceClient())
            {
                result = await client.DeleteAsync(new ScheduleDetailKey()
                {
                    ScheduleName = scheduleName,
                    ShiftName    = shiftName
                });

                if (result.Code == 0)
                {
                    result.Message = string.Format(FMMResources.StringResource.ScheduleDetail_Delete_Success
                                                   , shiftName);
                }
                return(Json(result));
            }
        }
コード例 #3
0
        public async Task <ActionResult> Query(ScheduleDetailQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (ScheduleDetailServiceClient client = new ScheduleDetailServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            where.AppendFormat(" {0} Key.ScheduleName = '{1}'"
                                               , where.Length > 0 ? "AND" : string.Empty
                                               , model.ScheduleName);

                            if (!string.IsNullOrEmpty(model.ShiftName))
                            {
                                where.AppendFormat(" {0} Key.ShiftName LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.ShiftName);
                            }
                        }
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "Key",
                            Where   = where.ToString()
                        };
                        MethodReturnResult <IList <ScheduleDetail> > result = client.Get(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
コード例 #4
0
        public async Task <ActionResult> PagingQuery(string where, string orderBy, int?currentPageNo, int?currentPageSize)
        {
            if (ModelState.IsValid)
            {
                int pageNo   = currentPageNo ?? 0;
                int pageSize = currentPageSize ?? 20;
                if (Request["PageNo"] != null)
                {
                    pageNo = Convert.ToInt32(Request["PageNo"]);
                }
                if (Request["PageSize"] != null)
                {
                    pageSize = Convert.ToInt32(Request["PageSize"]);
                }

                using (ScheduleDetailServiceClient client = new ScheduleDetailServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <ScheduleDetail> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
コード例 #5
0
        //
        // GET: /FMM/ScheduleDetail/
        public async Task <ActionResult> Index(string scheduleName)
        {
            using (ScheduleServiceClient client = new ScheduleServiceClient())
            {
                MethodReturnResult <Schedule> result = await client.GetAsync(scheduleName ?? string.Empty);

                if (result.Code > 0 || result.Data == null)
                {
                    return(RedirectToAction("Index", "Schedule"));
                }
                ViewBag.Schedule = result.Data;
            }

            using (ScheduleDetailServiceClient client = new ScheduleDetailServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        Where = string.Format(" Key.ScheduleName = '{0}'"
                                              , scheduleName)
                    };
                    MethodReturnResult <IList <ScheduleDetail> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            return(View(new ScheduleDetailQueryViewModel()
            {
                ScheduleName = scheduleName
            }));
        }
コード例 #6
0
        //
        // GET: /FMM/ScheduleDay/
        public async Task <ActionResult> Index(string locationName, string routeOperationName, string year, string month)
        {
            string   sStartDate = string.Format("{0}-{1}-01", year, month);
            DateTime startDate  = DateTime.Now;

            if (!DateTime.TryParse(sStartDate, out startDate))
            {
                return(RedirectToAction("Index", "ScheduleMonth"));
            }
            string scheduleName = string.Empty;

            //获取月排班计划。
            using (ScheduleMonthServiceClient client = new ScheduleMonthServiceClient())
            {
                MethodReturnResult <ScheduleMonth> result = await client.GetAsync(new ScheduleMonthKey
                {
                    LocationName       = locationName,
                    RouteOperationName = routeOperationName,
                    Year  = year,
                    Month = month
                });

                if (result.Code > 0 || result.Data == null)
                {
                    return(RedirectToAction("Index", "ScheduleMonth"));
                }
                scheduleName          = result.Data.ScheduleName;
                ViewBag.ScheduleMonth = result.Data;
            }
            //获取排班计划明细。
            using (ScheduleDetailServiceClient client = new ScheduleDetailServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false,
                    Where    = string.Format(@"Key.ScheduleName='{0}'", scheduleName)
                };
                MethodReturnResult <IList <ScheduleDetail> > result = client.Get(ref cfg);

                if (result.Code == 0)
                {
                    ViewBag.ScheduleDetailList = result.Data;
                }
            }
            //获取日排班计划。
            using (ScheduleDayServiceClient client = new ScheduleDayServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        IsPaging = false,
                        Where    = string.Format(@"Key.LocationName='{0}' 
                                                AND Key.RouteOperationName='{1}' 
                                                AND Key.Day>='{2}' 
                                                AND Key.Day<='{3}'",
                                                 locationName,
                                                 routeOperationName,
                                                 startDate.ToString("yyyy-MM-dd"),
                                                 startDate.AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd"))
                    };
                    MethodReturnResult <IList <ScheduleDay> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.ScheduleDayList = result.Data;
                    }
                });
            }
            return(View());
        }