コード例 #1
0
        public ActionResult ChangePassword(string pass)
        {
            ShiftManager inputShiftManager = (ShiftManager)TempData["inputShiftManager"];

            if (inputShiftManager != null)
            {
                TempData["inputShiftManager"] = inputShiftManager;
            }
            else
            {
                return(RedirectToAction("Index", "ShiftManager"));
            }
            if (String.IsNullOrEmpty(pass))
            {
                return(RedirectToAction("Index", "ShiftManager"));
            }
            if (pass.Length > 30)
            {
                return(RedirectToAction("Index", "ShiftManager"));
            }
            Dictionary <string, object> Parameters = new Dictionary <string, object>();

            Parameters.Add("@username", inputShiftManager.username);
            Parameters.Add("@password", pass);
            if (dbm.ExecuteNonQuery_proc("changePassword", Parameters) != 0)
            {
                TempData["passSuccess"] = true;
            }
            return(RedirectToAction("Index", "ShiftManager"));
        }
コード例 #2
0
        public void Setup()
        {
            var options = new DbContextOptionsBuilder <ShiftContext>()
                          .UseInMemoryDatabase(databaseName: "ShifttDatabase")
                          .Options;

            // Insert seed data into the database using one instance of the context
            shiftContext = new ShiftContext(options);
            shiftContext.Shifts.Add(new Shift {
                id = 1, employeeSlots = 6, shiftDate = DateTime.Now, workingEmployees = new List <User>()
                {
                    new User(1, "Dave", 1), new User(2, "Steve", 1)
                }
            });
            shiftContext.Shifts.Add(new Shift {
                id = 2, employeeSlots = 6, shiftDate = DateTime.Now, workingEmployees = new List <User>()
                {
                    new User(1, "Dave", 2), new User(2, "Steve", 2), new User(3, "Lisa", 2)
                }
            });
            shiftContext.Shifts.Add(new Shift {
                id = 3, employeeSlots = 6, shiftDate = DateTime.Now, workingEmployees = new List <User>()
            });
            shiftContext.SaveChanges();

            shiftManager = new ShiftManager(shiftContext);

            shiftController = new ShiftController(shiftManager);
        }
コード例 #3
0
        public ActionResult AddShiftManager(ShiftManager mgr)
        {
            Hospital inputHospital = (Hospital)TempData["inputHospital"];

            if (inputHospital != null)
            {
                TempData["inputHospital"] = inputHospital;
            }
            else
            {
                return(RedirectToAction("SignIn", "Hospitals"));
            }


            Dictionary <string, object> Parameters1 = new Dictionary <string, object>();

            Parameters1.Add("@username", mgr.username);
            Parameters1.Add("@user_pass", mgr.password);
            Parameters1.Add("@name", mgr.name);
            Parameters1.Add("@hospital_id", inputHospital.hospital_id);

            ViewBag.added = (dbm.ExecuteNonQuery_proc("insert_shift_manager", Parameters1) != 0);

            return(View());
        }
コード例 #4
0
 public void TestRetrieveShiftDetailsWithInvalidShiftID()
 {
     //Arrange
     int           shiftID       = 0;
     IShiftManager _shiftManager = new ShiftManager(_shiftAccessor);
     //Act
     ShiftDetailsVM actualResult = _shiftManager.RetrieveShfitDetailsByID(shiftID);
 }
コード例 #5
0
        public void TestRetrieveShiftDetailsWithInvalidUserID()
        {
            //Arrange
            int           userID        = 0;
            IShiftManager _shiftManager = new ShiftManager(_shiftAccessor);
            //Act
            var actualResult = _shiftManager.RetrieveShfitDetailsByUserID(userID);

            Assert.AreEqual(null, actualResult);
        }
コード例 #6
0
ファイル: DLManager.cs プロジェクト: thachgiasoft/ue96
        public void AddItemRelated(int sysno, int freightUserSysNo, DLItemInfo dlItem, int DLItemType, int updateUser)
        {
            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                Hashtable ht = new Hashtable();
                ht.Add("SysNo", sysno);
                ht.Add("FreightUserSysNo", freightUserSysNo);
                ht.Add("SetDeliveryManTime", DateTime.Now);
                ht.Add("DLSysNo", dlItem.DLSysNo);


                if (DLItemType == (int)AppEnum.DLItemType.SaleOrder)
                {
                    SaleManager.GetInstance().UpdateSOMaster(ht);
                }
                else if (DLItemType == (int)AppEnum.DLItemType.RMARequest)
                {
                    RMARequestManager.GetInstance().SetDeliveryMen(ht);
                }
                else if (DLItemType == (int)AppEnum.DLItemType.RMARevert)
                {
                    RMARevertManager.GetInstance().SetDeliveryMen(ht);
                }
                else if (DLItemType == (int)AppEnum.DLItemType.RMAOutbound)
                {
                    RMAOutBoundManager.GetInstance().SetDeliveryMen(ht);
                }
                else if (DLItemType == (int)AppEnum.DLItemType.RMASendAccessory)
                {
                    RMASendAccessoryManager.GetInstance().SetDeliveryMen(ht);
                }
                else if (DLItemType == (int)AppEnum.DLItemType.StShift)
                {
                    ShiftManager.GetInstance().UpdateShiftMaster(ht);
                }

                DeliveryManSetListInfo oInfo = new DeliveryManSetListInfo();
                oInfo.ItemID           = dlItem.ItemID;
                oInfo.SetUserSysNo     = updateUser;
                oInfo.FreightUserSysNo = freightUserSysNo;
                oInfo.CreateTime       = DateTime.Now;
                oInfo.DLSysNo          = dlItem.DLSysNo;
                DeliveryManager.GetInstance().InsertDeliveryMenSetList(oInfo);


                DLManager.GetInstance().AddNewDLItem(dlItem);

                scope.Complete();
            }
        }
コード例 #7
0
        public void TestSelectShiftsByScheduleAndInvalidDepartmentID()
        {
            //Arrange
            string        departmentID  = "Fake4";
            int           scheduleID    = 1;
            IShiftManager _shiftManager = new ShiftManager(_shiftAccessor);
            //Act
            List <ShiftUserVM> actualResult = _shiftManager.RetrieveShiftsByScheduleAndDepartmentID(scheduleID, departmentID);

            Assert.AreEqual(null, actualResult);
        }
コード例 #8
0
        public void TestRetrieveShiftDetailsByUSerIDSuccess()
        {
            //Arrange
            int           userID        = 1;
            IShiftManager _shiftManager = new ShiftManager(_shiftAccessor);

            //Act
            var actualResult = _shiftManager.RetrieveShfitDetailsByUserID(userID);

            //Assert
            Assert.AreEqual(1, actualResult.Count);
        }
コード例 #9
0
        public void TestSelectShiftsByScheduleAndInvalidScheduleID()
        {
            //Arrange
            int           expectedResult = 0;
            string        departmentID   = "Test1";
            int           scheduleID     = 8;
            IShiftManager _shiftManager  = new ShiftManager(_shiftAccessor);
            //Act
            List <ShiftUserVM> actualResult = _shiftManager.RetrieveShiftsByScheduleAndDepartmentID(scheduleID, departmentID);

            Assert.AreEqual(expectedResult, actualResult.Count);
        }
コード例 #10
0
        public void TestSelectShiftsByScheduleAndInvalidDepartmentDate()
        {
            //Arrange
            DateTime      Date          = DateTime.Today;
            string        departmentID  = "Fake01";
            int           scheduleID    = 1;
            IShiftManager _shiftManager = new ShiftManager(_shiftAccessor);
            //Act
            List <ShiftUserVM> actualResult = _shiftManager.RetrieveShiftsByScheduleAndDepartmentIDWithDate(scheduleID, departmentID, Date);

            Assert.AreEqual(null, actualResult);
        }
コード例 #11
0
        public void TestRetrieveShiftsByUser()
        {
            //arrange
            List <ShiftVM> shiftVMs;
            IShiftManager  shiftManager = new ShiftManager(_shiftAccessor);

            //act
            shiftVMs = shiftManager.RetrieveShiftsByUser(100001);

            //assert
            Assert.AreEqual(3, shiftVMs.Count);
        }
コード例 #12
0
 private void GrdShift_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (shiftWindow is null)
     {
         shiftWindow = new ShiftManager()
         {
             Owner = this
         }
     }
     ;
     lblContents.Content = shiftWindow.Content;
     Title = "Shift Management Window";
 }
コード例 #13
0
        public void TestSelectShiftsByScheduleAndScheduleIInvalidDDate()
        {
            //Arrange
            DateTime      Date           = DateTime.Today.AddYears(10).AddDays(10);
            int           expectedResult = 0;
            string        departmentID   = "Test1";
            int           scheduleID     = 1;
            IShiftManager _shiftManager  = new ShiftManager(_shiftAccessor);
            //Act
            List <ShiftUserVM> actualResult = _shiftManager.RetrieveShiftsByScheduleAndDepartmentIDWithDate(scheduleID, departmentID, Date);

            Assert.AreEqual(expectedResult, actualResult.Count);
        }
コード例 #14
0
        public ActionResult SignIn()/*Empty function --> redirects the user to Sign In page*/
        {
            ShiftManager inputShiftManager = (ShiftManager)TempData["inputShiftManager"];

            if (inputShiftManager != null)
            {
                TempData["inputShiftManager"] = inputShiftManager;
                return(RedirectToAction("Index", "ShiftManager"));
            }
            else
            {
                return(View());
            }
        }
コード例 #15
0
        public void TestRetrieveShiftDetailsWithDifferentExpectedResult()
        {
            //Arrange
            int            shiftID       = 1;
            IShiftManager  _shiftManager = new ShiftManager(_shiftAccessor);
            ShiftDetailsVM expectResult  = new ShiftDetailsVM()
            {
                ShiftID = 2, ShiftDate = DateTime.Now, RoleID = "Role1", ScheduleID = 1, ShiftTimeID = 1, EmployeeID = 1
            };
            //Act
            ShiftDetailsVM actualResult = _shiftManager.RetrieveShfitDetailsByID(shiftID);

            //Assert
            Assert.AreNotEqual(actualResult.ShiftID, expectResult.ShiftID);
        }
コード例 #16
0
        // GET: ShiftManager
        public ActionResult Index()
        {
            ShiftManager inputShiftManager = (ShiftManager)TempData["inputShiftManager"];

            if (inputShiftManager == null)
            {
                return(RedirectToAction("SignIn", "ShiftManager"));
            }
            else
            {
                TempData["inputShiftManager"] = inputShiftManager;
                ViewBag.passSuccess           = Convert.ToBoolean(TempData["passSuccess"]);
                return(View());
            }
        }
コード例 #17
0
        public void TestEditShiftUserWorking()
        {
            //Arrange
            IShiftManager shiftManager   = new ShiftManager(_shiftAccessor);
            int           shiftToChange  = 1000002;
            int           newUserWorking = 100000;
            int           oldUserWorking = 100001;


            //Act
            bool oneShiftModified = shiftManager.EditShiftUserWorking(shiftToChange, newUserWorking, oldUserWorking);

            //Assert
            Assert.IsTrue(oneShiftModified);
        }
コード例 #18
0
        public void TestEditEmployeeHoursWorkedNegative()
        {
            //Arrange
            IShiftManager shiftManager = new ShiftManager(_shiftAccessor);
            int           userID       = 1000001;
            int           scheduleID   = 1000001;
            int           weekNumber   = 2;
            double        changeAmount = -4.2;


            //Act
            bool oneScheduleModified = shiftManager.EditEmployeeHoursWorked(userID, scheduleID, weekNumber, changeAmount);

            //Assert
            Assert.IsTrue(oneScheduleModified);
        }
コード例 #19
0
        private const int MaxIterationCount = 24 * 60 * 365 * 4; // 4 years of minutes
        protected IEnumerable <IScheduledJob> Solve(
            List <IShift> shifts,
            List <IWorker> workers,
            List <ITool> tools,
            IEnumerable <IZone> zones,
            IEnumerable <IJob> jobs,
            GreedyActivityStrategy strategy,
            ShiftManager shiftManager)
        {
            _shiftManager        = shiftManager;
            _strategy            = strategy;
            _jobPriorityFunction = new SlackTimeRemainingJobPriorityFunction();

            if (shifts.Count > 0)
            {
                _shifts = shifts.ToArray();
                SetupWorkers(shifts, workers);
                SetupTools(shifts, tools);
            }

            SetupZones(zones);

            SetupJobs(jobs);

            _timepoints   = new Dictionary <int, List <InWorkEvent> >();
            _inWorkEvents = new List <InWorkEvent>();

            int iteration = InitializeNextIteration(_shifts[0]);

            while (_jobs.Any() && iteration < MaxIterationCount)
            {
                // check to see if we have any events expiring
                ProcessCompletingJobs(iteration);

                // check to see if we have any new jobs we can work on
                ProcessJobs(iteration);

                // increment iteration counter
                iteration++;
            }

            // we're done!
            return(BuildSchedule());
        }
コード例 #20
0
        public SolverDataManager(ProjectDataSet model, ConstraintSolverResult data)
        {
            _model        = model;
            _solverResult = data;

            var jobFactory    = new JobFactory();
            var skillFactory  = new SkillFactory();
            var workerFactory = new WorkerFactory();
            var toolFactory   = new ToolFactory();
            var zoneFactory   = new ZoneFactory();
            var shiftFactory  = new ShiftFactory();

            var shiftConverter = new ShiftConverter(shiftFactory);
            var skillConverter = new SkillConverter(skillFactory);
            var toolConverter  = new ToolConverter(toolFactory, shiftConverter);
            var zoneConverter  = new ZoneConverter(zoneFactory);
            var laborConverter = new LaborConverter(workerFactory, shiftConverter, skillConverter);
            var jobConverter   = new JobConverter(jobFactory, skillConverter, toolConverter, zoneConverter);

            _shiftManager = new ShiftManager(shiftConverter, skillConverter, laborConverter, toolConverter);
            _jobManager   = new JobManager(jobConverter);
            _zoneManager  = new ZoneManager(zoneConverter);
        }
コード例 #21
0
        public async Task <ConstraintSolverResult> InitializeDataAsync()
        {
            _activitiesMap = new ConcurrentDictionary <int, IActivity>();
            _scheduledJobs = new ConcurrentDictionary <Guid, IActivitySchedule>();

            await Task.Run(() =>
            {
                var cp = new CriticalPathHelper();
                cp.OrderActivitySchedule(_model, _solverResult);

                foreach (var scheduledItem in _solverResult.Schedule)
                {
                    var activity = scheduledItem.ScheduledItem;
                    _scheduledJobs.GetOrAdd(activity.UID, scheduledItem);
                }
            });

            ShiftManager.ProcessModel(_model, _solverResult.Constraints);
            JobManager.ProcessModelActivities(_solverResult.Schedule);
            ZoneManager.ProcessZones(_model.GetZoneResources());

            return(_solverResult);
        }
コード例 #22
0
        public ActionResult SignIn(loginViewModel sm)
        {
            Dictionary <string, object> Parameters = new Dictionary <string, object>();

            Parameters.Add("@username", sm.username);
            Parameters.Add("@password", sm.password);
            if (ModelState.IsValid)
            {
                DataTable    inputSMTable = dbm.ExecuteReader_proc("checkShiftManager", Parameters);
                ShiftManager inputShiftManager;
                if (inputSMTable == null)
                {
                    return(View(sm));
                }
                else
                {
                    string username    = Convert.ToString(inputSMTable.Rows[0]["username"]);
                    string password    = Convert.ToString(inputSMTable.Rows[0]["user_pass"].GetHashCode());
                    string name        = Convert.ToString(inputSMTable.Rows[0]["name"]);
                    int    hospital_id = Convert.ToInt32(inputSMTable.Rows[0]["hospital_id"]);
                    inputShiftManager = new ShiftManager()
                    {
                        username    = username,
                        password    = password,
                        name        = name,
                        hospital_id = hospital_id
                    };
                    TempData["inputShiftManager"] = inputShiftManager;

                    return(RedirectToAction("Index", "ShiftManager"));
                }
            }
            else
            {
                return(View(sm));
            }
        }
コード例 #23
0
ファイル: Program.cs プロジェクト: artiomnichifor/IPP
        static void Main(string[] args)
        {
            Group groupA = new HighPriorityGroup("A", "HPG");
            Group groupB = new ModeratePriorityGroup("B", "MPG");
            Group groupC = new LowPriorityGroup("C", "LPG");

            //ChainOfResponsibilities
            groupA.SetSuccessor(groupB);
            groupB.SetSuccessor(groupC);

            Requestor requestor = new Requestor();

            requestor.Name         = "req1";
            requestor.Priority     = 111;
            requestor.TypeOfFlight = "internal";

            Console.WriteLine("Assign customer to a group");
            groupA.HandleRequest(requestor);
            Console.WriteLine($"Customer was assigned to group {requestor.Group.Name}");
            //Console.Write(groupC.requestors.First().Name);
            //Console.Write(requestor.Group.Name);
            Console.ReadKey();


            //State
            Console.WriteLine("First call");
            requestor.Call();
            Console.ReadKey();
            Console.WriteLine("Second call");
            requestor.Call();
            Console.ReadKey();
            Console.WriteLine("Third call");
            requestor.Call();
            Console.ReadKey();
            Console.WriteLine("Customer support call");
            requestor.Call();
            Console.ReadKey();

            //Command
            Employee empl1 = groupC.employees.Find(x => x.Position == "FlightBuilder");

            Flight flight1 = new Flight();

            flight1.Start       = "S1";
            flight1.Destination = "D1";
            flight1.Price       = 10;
            Flight flight2 = new Flight();

            flight2.Start       = "S2";
            flight2.Destination = "D2";
            flight2.Price       = 20;
            Flight flight3 = new Flight();

            flight3.Start       = "S3";
            flight3.Destination = "D3";
            flight3.Price       = 30;
            Flight flight4 = new Flight();

            flight4.Start       = "S4";
            flight4.Destination = "D4";
            flight4.Price       = 40;


            empl1.AddFlight(requestor, flight1);
            empl1.AddFlight(requestor, flight2);
            empl1.AddFlight(requestor, flight3);
            empl1.Undo(requestor);
            empl1.AddFlight(requestor, flight4);

            //requestor.Route.ShowFlights();
            Console.ReadKey();

            //Strategy
            requestor.Route.SetCalculationStrategy(new CalculatePrimeMethod());
            Console.WriteLine($"Total route price is {requestor.Route.CalculatePrice()}");
            Console.ReadKey();

            //Observer
            ShiftManager shiftManager = new ShiftManager();

            foreach (Employee empl in groupA.employees)
            {
                shiftManager.Attach(empl);
            }

            Shift nightShift = new Shift("night", "17:00", "23:00");

            shiftManager.SetNewShift(nightShift);

            Console.ReadKey();
        }
コード例 #24
0
 public WeightApiController()
 {
     IncidentManager = new IncidentManager();
     SensorManager   = new SensorManager();
     ShiftManager    = new ShiftManager();
 }
コード例 #25
0
 public ShiftController()
 {
     ShiftManager = new ShiftManager();
 }