コード例 #1
0
        public async Task <ActionResult> Save(ScheduleMonthViewModel model)
        {
            using (ScheduleMonthServiceClient client = new ScheduleMonthServiceClient())
            {
                ScheduleMonth obj = new ScheduleMonth()
                {
                    Key = new ScheduleMonthKey()
                    {
                        LocationName       = model.LocationName,
                        RouteOperationName = model.RouteOperationName,
                        Year  = model.Year,
                        Month = model.Month
                    },
                    ScheduleName = model.ScheduleName,
                    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.ScheduleMonth_Save_Success
                                                , obj.Key);
                }
                return(Json(rst));
            }
        }
コード例 #2
0
        public async Task <ActionResult> Query(ScheduleMonthQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (ScheduleMonthServiceClient client = new ScheduleMonthServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            if (!string.IsNullOrEmpty(model.LocationName))
                            {
                                where.AppendFormat(" {0} Key.LocationName LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.LocationName);
                            }
                            if (!string.IsNullOrEmpty(model.RouteOperationName))
                            {
                                where.AppendFormat(" {0} Key.RouteOperationName LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.RouteOperationName);
                            }
                            if (!string.IsNullOrEmpty(model.Year))
                            {
                                where.AppendFormat(" {0} Key.Year LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.Year);
                            }
                            if (!string.IsNullOrEmpty(model.Month))
                            {
                                where.AppendFormat(" {0} Key.Month LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.Month);
                            }
                        }
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "Key",
                            Where   = where.ToString()
                        };
                        MethodReturnResult <IList <ScheduleMonth> > result = client.Get(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
コード例 #3
0
        //
        // GET: /FMM/ScheduleMonth/
        public async Task <ActionResult> Index()
        {
            using (ScheduleMonthServiceClient client = new ScheduleMonthServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "Key"
                    };
                    MethodReturnResult <IList <ScheduleMonth> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            return(View(new ScheduleMonthQueryViewModel()));
        }
コード例 #4
0
        public async Task <ActionResult> Delete(string locationName, string routeOperationName, string year, string month)
        {
            MethodReturnResult result = new MethodReturnResult();

            using (ScheduleMonthServiceClient client = new ScheduleMonthServiceClient())
            {
                ScheduleMonthKey key = new ScheduleMonthKey()
                {
                    LocationName       = locationName,
                    RouteOperationName = routeOperationName,
                    Year  = year,
                    Month = month
                };
                result = await client.DeleteAsync(key);

                if (result.Code == 0)
                {
                    result.Message = string.Format(FMMResources.StringResource.ScheduleMonth_Delete_Success
                                                   , key);
                }
                return(Json(result));
            }
        }
コード例 #5
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 (ScheduleMonthServiceClient client = new ScheduleMonthServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <ScheduleMonth> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
コード例 #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());
        }