示例#1
0
    /// <summary>
    /// 添加日程信息
    /// </summary>
    /// <param name="user"></param>
    private void AddSchedule(User user)
    {
        Schedule schedule = GiveSchedule(user);

        int i = ScheduleManager.AddSchedule(schedule);

        if (i != 0)
        {
            if (this.lbUserName.Items.Count > 0)
            {
                foreach (ListItem li in lbUserName.Items)
                {
                    PreContract preContract = new PreContract();
                    preContract.Schedule.ScheduleId = i;
                    preContract.UserId = li.Value;
                    int count = PreContractManager.AddPreContract(preContract);
                    if (count == 0)
                    {
                        ScriptManager.RegisterStartupScript(this, GetType(), "key", "alert('添加失败!')", true);
                        break;
                    }
                }

                Response.Redirect("PersonSchedule.aspx");
            }
            else
            {
                Response.Redirect("PersonSchedule.aspx");
            }
        }
        else
        {
            ScriptManager.RegisterStartupScript(this, GetType(), "key", "alert('添加失败!')", true);
        }
    }
示例#2
0
        /// <summary>
        /// Initializes <see cref="AdapterBase"/>.
        /// </summary>
        public override void Initialize()
        {
            ConnectionStringParser <ConnectionStringParameterAttribute> parser = new ConnectionStringParser <ConnectionStringParameterAttribute>();

            parser.ParseConnectionString(ConnectionString, this);
            base.Initialize();
            m_scheduleManager.AddSchedule(ScheduleName, ImportSchedule, true);
        }
示例#3
0
        public void ScheduleShouldBeInsertedWhenAdded()
        {
            var manager = new ScheduleManager(_unitOfWork.Object, _dateTimeManager.Object, _personManager.Object);

            _unitOfWork.Setup(u => u.ScheduleRepository.GetList()).Returns(new List <Schedule>().AsQueryable());

            manager.AddSchedule(null, new DateTime(), new DateTime());

            _unitOfWork.Verify(u => u.ScheduleRepository.Insert(It.IsAny <Schedule>()), Times.Once);
        }
示例#4
0
        public void ScheduleShouldBeInsertedWithGoodInfos()
        {
            var manager     = new ScheduleManager(_unitOfWork.Object, _dateTimeManager.Object, _personManager.Object);
            var responsible = new Person();
            var startDate   = new DateTime(2016, 12, 26, 8, 0, 0);
            var endDate     = new DateTime(2017, 1, 1, 7, 59, 0);

            _unitOfWork.Setup(u => u.ScheduleRepository.GetList()).Returns(new List <Schedule>().AsQueryable());

            manager.AddSchedule(responsible, startDate, endDate);

            _unitOfWork.Verify(u => u.ScheduleRepository.Insert(It.Is <Schedule>(s => s.Responsible == responsible && s.StartAt == startDate && s.EndAt == endDate)), Times.Once);
        }
示例#5
0
        public void TestGenerateScheduleCountTooHigh()
        {
            IScheduleManager scheduleManager = new ScheduleManager(_scheduleAccessor, _shiftTimeAccessor);

            // To ensure the list is at capacity.
            List <ScheduleVM> scheduleVMs = new List <ScheduleVM>
            {
                new ScheduleVM()
                {
                    ScheduleID     = 1000003,
                    CreatingUserID = 100000,
                    StartDate      = DateTime.Now.AddDays(15),
                    EndDate        = DateTime.Now.AddDays(29),
                    Active         = true,
                    CreatorName    = "Last, First",
                    ScheduleLines  = new List <ShiftUserVM>()
                },
                new ScheduleVM()
                {
                    ScheduleID     = 1000004,
                    CreatingUserID = 100000,
                    StartDate      = DateTime.Now.AddDays(30),
                    EndDate        = DateTime.Now.AddDays(44),
                    Active         = true,
                    CreatorName    = "Last, First",
                    ScheduleLines  = new List <ShiftUserVM>()
                }
            };

            foreach (var item in scheduleVMs)
            {
                scheduleManager.AddSchedule(item);
            }
            List <BaseScheduleLine> lines = new List <BaseScheduleLine>
            {
                new BaseScheduleLine
                {
                    BaseScheduleID = 1000000,
                    DepartmentID   = "Management",
                    ShiftTimeID    = 100002,
                    ERoleID        = "Manager",
                    Count          = 1
                }
            };

            DateTime date = DateTime.Now;

            ScheduleVM scheduleVM = scheduleManager.GenerateSchedule(date, lines);
        }
示例#6
0
        /// <summary>
        /// Initializes <see cref="CsvExportAdapter"/>.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            ConnectionStringParser <ConnectionStringParameterAttribute> parser = new ConnectionStringParser <ConnectionStringParameterAttribute>();

            parser.ParseConnectionString(ConnectionString, this);

            if (string.IsNullOrWhiteSpace(ExportPath))
            {
                ExportPath = Path.Combine("CSVExports", Name);
            }

            m_scheduleManager.AddSchedule(ScheduleName, RolloverSchedule, true);
            InternalProcessQueue.SynchronizedOperationType = GSF.Threading.SynchronizedOperationType.Long;
        }
示例#7
0
        public void AddScheduleTester()
        {
            IScheduleManager scheduleManager = new ScheduleManager(_scheduleAccessor,
                                                                   _shiftTimeAccessor);
            ScheduleVM scheduleVM = new ScheduleVM()
            {
                ScheduleID     = 1000001,
                CreatingUserID = 100000,
                StartDate      = DateTime.Now.AddDays(14),
                EndDate        = DateTime.Now.AddDays(28),
                Active         = false,
                CreatorName    = "Last, First",
                ScheduleLines  = new List <ShiftUserVM>()
                {
                    new ShiftUserVM()
                    {
                        ScheduleID  = 1000000,
                        ShiftID     = 1000000,
                        ShiftTimeID = 1000000,
                        ShiftDate   = DateTime.Now,
                        EmployeeID  = 1000000,
                        RoleID      = "Manager"
                    },
                    new ShiftUserVM()
                    {
                        ScheduleID  = 1000000,
                        ShiftID     = 1000001,
                        ShiftTimeID = 1000000,
                        ShiftDate   = DateTime.Now,
                        EmployeeID  = 1000001,
                        RoleID      = "Supervisor"
                    }
                }
            };

            int result = scheduleManager.AddSchedule(scheduleVM);
            int target = 1;

            Assert.AreEqual(target, result);
        }
示例#8
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            ScheduleManager obj = new ScheduleManager();

            Schedule schedule = new Schedule();

            Route route = new Route();


            City fromcity = new City();

            if (dpFromCity.SelectedItem.Value != "None" && dpFromCity.SelectedItem.Value != "none")
            {
                fromcity.CityId = long.Parse(dpFromCity.SelectedItem.Value);
            }
            fromcity.Name  = dpFromCity.SelectedItem.Text;
            route.FromCity = fromcity;

            City tocity = new City();

            if (dpToCity.SelectedItem.Value != "None" && dpToCity.SelectedItem.Value != "none")
            {
                tocity.CityId = long.Parse(dpToCity.SelectedItem.Value);
            }
            tocity.Name  = dpToCity.SelectedItem.Text;
            route.ToCity = tocity;

            schedule.RouteInfo = route;

            TimeSpan t1 = new TimeSpan(0, 0, 0);

            if (DropDownList4.SelectedItem.ToString() != "None" && DropDownList4.SelectedItem.ToString() != "none")
            {
                t1 = TimeSpan.Parse(DropDownList4.SelectedItem.ToString() + ":" + DropDownList5.SelectedItem.ToString());
            }

            TimeSpan t2 = new TimeSpan(0, 0, 0);

            if (DropDownList1.SelectedItem.ToString() != "None" && DropDownList1.SelectedItem.ToString() != "none")
            {
                TimeSpan.Parse(DropDownList1.SelectedItem.ToString() + ":" + DropDownList2.SelectedItem.ToString());
            }

            total            = int.Parse((t1 - t2).TotalMinutes.ToString());
            txtDuration.Text = total.ToString();

            Flight flight = new Flight();

            if (dpFlightName.SelectedItem != null && dpFlightName.SelectedItem.Text != "None")
            {
                flight.ID = long.Parse(dpFlightName.SelectedItem.Value);
            }
            if (dpFlightName.SelectedItem != null)
            {
                flight.Name = dpFlightName.SelectedItem.Text;
            }

            schedule.RouteInfo  = route;
            schedule.FlightInfo = flight;

            TimeSpan tempT1;

            TimeSpan.TryParse(DropDownList1.SelectedItem.ToString() + ":" + DropDownList2.SelectedItem.ToString(), out tempT1);
            schedule.DepartureTime = tempT1;

            TimeSpan.TryParse(DropDownList4.SelectedItem.ToString() + ":" + DropDownList5.SelectedItem.ToString(), out tempT1);
            schedule.ArrivalTime = tempT1;

            schedule.DurationInMins = total;
            schedule.IsActive       = chkStatus.Checked;

            foreach (RepeaterItem item in Repeater1.Items)
            {
                Label   lblclassname = (Label)item.FindControl("ClassName");
                TextBox txtcost      = (TextBox)item.FindControl("txtCostPerTicket");

                if (txtcost != null || lblclassname != null)
                {
                    string classname = lblclassname.Text;
                    string val       = txtcost.Text;

                    FlightCost fc = new FlightCost();
                    fc.Class         = (TravelClass)Enum.Parse(typeof(TravelClass), classname);
                    fc.CostPerTicket = decimal.Parse(txtcost.Text);

                    schedule.AddFlightCost(fc);
                }
            }

            try
            {
                if (obj.AddSchedule(schedule))
                {
                    lblError.Text = "Schedule Added Successfully";
                }
                else
                {
                    lblError.Text = "Unable to add schedule";
                }
            }
            catch (ScheduleManagerException ex)
            {
                lblError.Text = ex.Message;
            }
            catch (Exception ex)
            {
                lblError.Text = ex.Message;
            }
        }