Ejemplo n.º 1
0
        public async Task <ActionResult> Query(ScheduleQueryViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (ScheduleServiceClient client = new ScheduleServiceClient())
                {
                    await Task.Run(() =>
                    {
                        StringBuilder where = new StringBuilder();
                        if (model != null)
                        {
                            if (!string.IsNullOrEmpty(model.Name))
                            {
                                where.AppendFormat(" {0} Key LIKE '{1}%'"
                                                   , where.Length > 0 ? "AND" : string.Empty
                                                   , model.Name);
                            }
                        }
                        PagingConfig cfg = new PagingConfig()
                        {
                            OrderBy = "Key",
                            Where   = where.ToString()
                        };
                        MethodReturnResult <IList <Schedule> > result = client.Get(ref cfg);

                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
Ejemplo n.º 2
0
        //
        // GET: /FMM/Schedule/Detail
        public async Task <ActionResult> Detail(string key)
        {
            using (ScheduleServiceClient client = new ScheduleServiceClient())
            {
                MethodReturnResult <Schedule> result = await client.GetAsync(key);

                if (result.Code == 0)
                {
                    ScheduleViewModel viewModel = new ScheduleViewModel()
                    {
                        Name        = result.Data.Key,
                        CreateTime  = result.Data.CreateTime,
                        Creator     = result.Data.Creator,
                        Description = result.Data.Description,
                        Editor      = result.Data.Editor,
                        EditTime    = result.Data.EditTime
                    };
                    return(PartialView("_InfoPartial", viewModel));
                }
                else
                {
                    ModelState.AddModelError("", result.Message);
                }
            }
            return(PartialView("_InfoPartial"));
        }
Ejemplo n.º 3
0
        public void Step2_API_MakeFlights()
        {
            Simulate  simulate = new Simulate();
            WebClient client   = new WebClient();

            // make flights
            ScheduleServiceClient scheduleService = new ScheduleServiceClient();

            scheduleService.MakeFlightsFromScheduleAll(DefaultUserId);
        }
Ejemplo n.º 4
0
        // GET: Schedule
        public ActionResult MakeFlightsFromSchedule(Guid flightScheduleId)
        {
            var schedule = new ScheduleServiceClient();

            schedule.MakeFlightsFromSchedule(
                flightScheduleId,
                DefaultUserId
                );

            return(RedirectToAction("FlightsForPeriodIndex", "FlightsForPeriodLive"));
        }
Ejemplo n.º 5
0
        public void GetSchedulesByDepartmentIdAndDateTest()
        {
            ScheduleServiceClient client = new ScheduleServiceClient();

            Schedule schedule = client.GetScheduleByDepartmentIdAndDate(1, new DateTime(2017, 11, 15));

            Assert.IsNotNull(schedule);
            Assert.AreEqual(new DateTime(2017, 11, 01), schedule.StartDate);
            Assert.AreNotEqual(0, schedule.Shifts.Count);
            Assert.AreEqual("Kolonial", schedule.Department.Name);
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> Delete(string key)
        {
            MethodReturnResult result = new MethodReturnResult();

            using (ScheduleServiceClient client = new ScheduleServiceClient())
            {
                result = await client.DeleteAsync(key);

                if (result.Code == 0)
                {
                    result.Message = string.Format(FMMResources.StringResource.Schedule_Delete_Success
                                                   , key);
                }
                return(Json(result));
            }
        }
Ejemplo n.º 7
0
        public ActionResult ScheduleEdit(System.Guid flightScheduleId)
        {
            ScheduleContract scheduleContract =
                new ScheduleServiceClient().GetSchedule(
                    flightScheduleId,
                    DefaultUserId
                    );

            ViewBag.AirlineId =
                new SelectList(new CrudeAirlineServiceClient().FetchAll(),
                               "AirlineId",
                               "AirlineName",
                               scheduleContract.FlightSchedule.AirlineId
                               );

            // items, string dataValueField, string dataTextField, string dataGroupField, object selectedValue
            ViewBag.AircraftTypeRcd =
                new SelectList(items: new CrudeAircraftTypeRefServiceClient().FetchAll(),
                               dataValueField: "AircraftTypeRcd",
                               dataTextField: "AircraftTypeName",
                               selectedValue: scheduleContract.FlightSchedule.AircraftTypeRcd
                               );

            ViewBag.DepartureAirportId =
                new SelectList(new CrudeAirportServiceClient().FetchAll(),
                               "AirportId",
                               "AirportName",
                               scheduleContract.FlightSchedule.DepartureAirportId
                               );

            ViewBag.ArrivalAirportId =
                new SelectList(new CrudeAirportServiceClient().FetchAll(),
                               "AirportId",
                               "AirportName",
                               scheduleContract.FlightSchedule.ArrivalAirportId
                               );

            ViewBag.DefaultUserName =
                new CrudeDefaultUserServiceClient().FetchByDefaultUserId(
                    scheduleContract.FlightSchedule.UserId
                    ).DefaultUserName;

            return(View(
                       MVCHelper.Resolve(Request, "Schedule", "ScheduleEdit"),
                       scheduleContract
                       ));
        }
Ejemplo n.º 8
0
        public void Step3_API_CheckFlightAndMakeBookings()
        {
            Simulate  simulate = new Simulate();
            WebClient client   = new WebClient();

            ScheduleServiceClient scheduleService = new ScheduleServiceClient();

            // flight status
            for (int i = 0; i < 10; i++)
            {
                simulate.CheckFlightStatuses();
            }

            // bookings
            for (int i = 0; i < 10; i++)
            {
                simulate.SimulateBookings();
            }
        }
Ejemplo n.º 9
0
        //
        // GET: /FMM/Schedule/
        public async Task <ActionResult> Index()
        {
            using (ScheduleServiceClient client = new ScheduleServiceClient())
            {
                await Task.Run(() =>
                {
                    PagingConfig cfg = new PagingConfig()
                    {
                        OrderBy = "Key"
                    };
                    MethodReturnResult <IList <Schedule> > result = client.Get(ref cfg);

                    if (result.Code == 0)
                    {
                        ViewBag.PagingConfig = cfg;
                        ViewBag.List         = result.Data;
                    }
                });
            }
            return(View(new ScheduleQueryViewModel()));
        }
Ejemplo n.º 10
0
        public IEnumerable <SelectListItem> GetScheduleName()
        {
            using (ScheduleServiceClient client = new ScheduleServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    IsPaging = false
                };

                MethodReturnResult <IList <Schedule> > result = client.Get(ref cfg);
                if (result.Code <= 0)
                {
                    IEnumerable <SelectListItem> lst = from item in result.Data
                                                       select new SelectListItem()
                    {
                        Text  = item.Key,
                        Value = item.Key
                    };
                    return(lst);
                }
            }
            return(new List <SelectListItem>());
        }
Ejemplo n.º 11
0
        public async Task <ActionResult> SaveModify(ScheduleViewModel model)
        {
            using (ScheduleServiceClient client = new ScheduleServiceClient())
            {
                MethodReturnResult <Schedule> result = await client.GetAsync(model.Name);

                if (result.Code == 0)
                {
                    result.Data.Description = model.Description;
                    result.Data.Editor      = User.Identity.Name;
                    result.Data.EditTime    = DateTime.Now;
                    MethodReturnResult rst = await client.ModifyAsync(result.Data);

                    if (rst.Code == 0)
                    {
                        rst.Message = string.Format(FMMResources.StringResource.Schedule_SaveModify_Success
                                                    , model.Name);
                    }
                    return(Json(rst));
                }
                return(Json(result));
            }
        }
Ejemplo n.º 12
0
        public async Task <ActionResult> Save(ScheduleViewModel model)
        {
            using (ScheduleServiceClient client = new ScheduleServiceClient())
            {
                Schedule obj = new Schedule()
                {
                    Key         = model.Name,
                    Description = model.Description,
                    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.Schedule_Save_Success
                                                , model.Name);
                }
                return(Json(rst));
            }
        }
Ejemplo n.º 13
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 (ScheduleServiceClient client = new ScheduleServiceClient())
                {
                    await Task.Run(() =>
                    {
                        PagingConfig cfg = new PagingConfig()
                        {
                            PageNo   = pageNo,
                            PageSize = pageSize,
                            Where    = where ?? string.Empty,
                            OrderBy  = orderBy ?? string.Empty
                        };
                        MethodReturnResult <IList <Schedule> > result = client.Get(ref cfg);
                        if (result.Code == 0)
                        {
                            ViewBag.PagingConfig = cfg;
                            ViewBag.List         = result.Data;
                        }
                    });
                }
            }
            return(PartialView("_ListPartial"));
        }
Ejemplo n.º 14
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
            }));
        }