Beispiel #1
0
 public Disposal(IShift shift, ISellableItem item)
 {
     ShiftID  = shift.ID;
     ItemID   = item.ID;
     Basis    = string.Empty;
     Quantity = 0;
 }
Beispiel #2
0
        private bool CanPost(IPostable receipt, IShift shift, decimal money, out string message)
        {
            foreach (var item in receipt.Items)
            {
                if (!item.IsEnough(out float diff))
                {
                    message = $"Товара \"{item.ItemName}\" не хватает на складе ({diff} шт.)";
                    return(false);
                }
            }

            if ((money >= receipt.TotalPrice) && (receipt.GetItemsCount() > 0) && ((money - receipt.TotalPrice) <= shift.Balance))
            {
                message = $"Сдача: {money - receipt.TotalPrice} руб.";
                return(true);
            }
            else if (money < receipt.TotalPrice)
            {
                message = $"к оплате предоставлено недостаточно средств ({receipt.TotalPrice - money})";
                return(false);
            }
            else if (receipt.GetItemsCount() < 1)
            {
                message = $"список товаров пуст";
                return(false);
            }
            else
            {
                message = $"недостаточно средств для выдачи сдачи " +
                          $"({(money - receipt.TotalPrice) - shift.Balance}).\n" +
                          $"(В кассе: {shift.Balance} руб)";
                return(false);
            }
        }
Beispiel #3
0
        public bool CanWork(IShift shift)
        {
            if (_rules == null)
            {
                throw new ArgumentNullException("IBusinessRules", "Business Rules object must be set before CanWork can be called");
            }

            if (ShiftDuration >= MaxShiftDuration)
            {
                return(false);
            }

            if (!_rules.AllowConsecutiveDays)
            {
                if (Shifts.Any(s => s.Day == shift.Day - 1))
                {
                    return(false);
                }
            }

            if (Shifts.Count(s => s.Day == shift.Day) >= _rules.MaxShiftsPerDay)
            {
                return(false);
            }

            return(true);
        }
        public override IEnumerable <ITool> Convert(AvailableToolLink input)
        {
            if (!InstancesMap.ContainsKey(input))
            {
                var tool = input.Tool;

                if (!_shiftConverter.NamedInstances.ContainsKey(input.Shift.Name))
                {
                    _shiftConverter.Convert(input.Shift);
                }
                IShift shift = _shiftConverter.InstancesMap[input.Shift];

                var tools     = new HashSet <ITool>();
                var converted = Factory.Create(tool.Name, shift);
                tools.Add(converted);
                var instances = new Dictionary <int, IToolInstance>();
                ToolTypes.Add(converted, instances);
                for (int i = 0; i < input.AvailableQuantity; i++)
                {
                    var instance = _toolInstanceFactory.Create(converted);
                    instances.Add(instance.ID, instance);
                }

                InstancesMap.GetOrAdd(input, tools);
                // TODO: this should be a toolInstance converter and a toolDefinition converter
                // TODO: we have skillConverter which is the definition part, and laborConverter which is the instance part
                NamedInstances.GetOrAdd(tool.Name, tools.First());
            }

            return(InstancesMap[input]);
        }
        public ShiftsViewModel()
        {
            _repo               = new ContextRepository <InSQL.Shift>();
            _selectedShift      = new Shift();
            UpdateBtnVisibility = StateService.StoreType == StoreType.InMemory ? "Hidden" : "Visible";

            LoadData();
        }
Beispiel #6
0
 public bool Equals(IShift <T> other)
 {
     if (other == null)
     {
         return(false);
     }
     return((TargetStateIndex == other.TargetStateIndex) && (Input.Equals(other.Input)));
 }
        /// <summary>
        /// Creates a shift async
        /// </summary>
        /// <param name="user">The parent of the shift</param>
        /// <param name="shift">The shift wanting to be created</param>
        /// <returns></returns>
        public async Task CreateShiftAsync(IUser user, IShift shift)
        {
            SQLiteCommand command = new SQLiteCommand("INSERT INTO Shifts (UserId, Name) VALUES(@UserId, @Name)", sqliteConnection);
            command.Parameters.AddWithValue("UserId", user.Id);
            command.Parameters.AddWithValue("Name", cryptoService.EncryptString(shift.Name));

            await command.ExecuteNonQueryAsync();
        }
Beispiel #8
0
 public Supply(IShift shift, ISellableItem item)
 {
     this.ShiftID  = shift.ID;
     this.ItemID   = item.ID;
     this.Basis    = string.Empty;
     this.Quantity = 0;
     this.Price    = 0;
     this.SupplyDT = default;
 }
 private Worker(int id, ISkill skill, IShift shift) : this()
 {
     if (id == -1)
     {
         id = this.NextId();
     }
     ID = id;
     Skill = skill;
     Shift = shift;
 }
Beispiel #10
0
 private Worker(int id, ISkill skill, IShift shift) : this()
 {
     if (id == -1)
     {
         id = this.NextId();
     }
     ID    = id;
     Skill = skill;
     Shift = shift;
 }
Beispiel #11
0
 public bool TryPost(IPostable receipt, IShift shift, out string message, decimal money = 0)
 {
     if ((receipt as Receipt != null) && (shift as Shift != null))
     {
         if (this.CanPost(receipt, shift, out string innerMessage))
         {
             using (CashRegisterContext ctx = new CashRegisterContext())
             {
                 using (var transaction = ctx.Database.BeginTransaction())
                 {
                     try
                     {
                         receipt.AssignShiftAndDate(shift);
                         shift.ChangeReturnsStats(receipt.TotalPrice);
                         var s = shift as Shift;
                         var r = receipt as Receipt;
                         s.Receipts.Clear();
                         s.Receipts.Add(r);
                         foreach (var i in s.Receipts[s.Receipts.Count - 1].Items)
                         {
                             i.Receipt        = null;
                             i.Item.Quantity += i.Quantity;
                             ctx.Update(i);
                         }
                         ctx.Shifts.Update(shift as Shift);
                         ctx.SaveChanges();
                         transaction.Commit();
                         foreach (var i in s.Receipts[s.Receipts.Count - 1].Items)
                         {
                             i.Item = null;
                         }
                         message = innerMessage;
                         return(true);
                     }
                     catch (Exception ex)
                     {
                         transaction.Rollback();
                         message = ex.Message;
                         return(false);
                     }
                 }
             }
         }
         else
         {
             message = innerMessage;
             return(false);
         }
     }
     else
     {
         message = "не удалось получить ссылку на экземпляр смены, либо чека";
         return(false);
     }
 }
Beispiel #12
0
 private void AddShift(IShift shift)
 {
     if (!ShiftWorkerManager.ContainsKey(shift))
     {
         ShiftWorkerManager.Add(shift, new WorkerManager(shift, _laborConverter));
     }
     if (!ShiftToolManager.ContainsKey(shift))
     {
         ShiftToolManager.Add(shift, new ToolManager(shift, _toolConverter));
     }
 }
Beispiel #13
0
 private Tool(int id, string toolType, IShift shift) : this()
 {
     if (id == -1)
     {
         id = this.NextId();
     }
     ID = id;
     ToolType = toolType;
     Shift = shift;
     ToolInstanceKeys = new Dictionary<int, IToolInstance>();
 }
Beispiel #14
0
        /// <summary>
        /// Encrypts the data based on the key
        /// </summary>
        /// <param name="Data">Data to encrypt</param>
        /// <param name="Key">Key to use</param>
        /// <returns>The encrypted data</returns>
        public byte[] Encrypt(byte[] Data, byte[] Key)
        {
            Contract.Requires <NullReferenceException>(ShiftAlgorithms != null, "ShiftAlgorithms");
            IShift Found = ShiftAlgorithms.FirstOrDefault();

            if (Found == null)
            {
                throw new ArgumentException("No shift based encryption algorithm found");
            }
            return(Found.Encrypt(Data, Key));
        }
Beispiel #15
0
 private Tool(int id, string toolType, IShift shift) : this()
 {
     if (id == -1)
     {
         id = this.NextId();
     }
     ID               = id;
     ToolType         = toolType;
     Shift            = shift;
     ToolInstanceKeys = new Dictionary <int, IToolInstance>();
 }
Beispiel #16
0
        private static void logObjectState(string carObjName, ICar carObj)
        {
            log.AppendLine(IDENTATION_LEVEL, $"\t{carObjName}: {carObj.GetType().Name}");

            IEngine engine            = carObj.GetEngine();
            string  engineDescription = engine.GetDescription();

            IShift shift            = carObj.GetShift();
            string shiftDescription = shift.GetDescription();


            log.AppendLine(IDENTATION_LEVEL, $"\t\tEngine = {engineDescription}");
            log.AppendLine(IDENTATION_LEVEL, $"\t\tShift  = {shiftDescription}");
        }
        public override ITool Create(params object[] args)
        {
            var    defaultToolType = ToolTypes.Autoclave;
            IShift shift           = null;

            if (args.Length == 1)
            {
                defaultToolType = (string)args[0];
            }
            else if (args.Length == 2)
            {
                defaultToolType = (string)args[0];
                shift           = (IShift)args[1];
            }

            return(new Tool(defaultToolType, shift));
        }
Beispiel #18
0
        public override IWorker Create(params object[] args)
        {
            ISkill skill = null;
            IShift shift = null;

            if (args.Length == 1)
            {
                skill = (ISkill)args[0];
            }
            else if (args.Length == 2)
            {
                skill = (ISkill)args[0];
                shift = (IShift)args[1];
            }

            return(new Worker(skill, shift));
        }
Beispiel #19
0
 public ToolManager(IShift shift, ToolConverter converter)
 {
     _shift                  = shift;
     _converter              = converter;
     _inProcessJobs          = new Dictionary <IToolInstance, IJob>();
     _inProcessTools         = new Dictionary <IJob, HashSet <IToolInstance> >();
     _inProcessToolSchedules = new Dictionary <IJob, HashSet <IScheduledTool> >();
     _processedJobs          = new Dictionary <IJob, Tuple <int, int> >();
     _toolAvailableStates    = new Dictionary <ITool, Dictionary <int, bool> >();
     foreach (var tool in _converter.ToolTypes)
     {
         _toolAvailableStates.Add(tool.Key, new Dictionary <int, bool>());
         foreach (var ti in tool.Value)
         {
             _toolAvailableStates[tool.Key].Add(ti.Key, true);
         }
     }
 }
 public ToolManager(IShift shift, ToolConverter converter)
 {
     _shift = shift;
     _converter = converter;
     _inProcessJobs = new Dictionary<IToolInstance, IJob>();
     _inProcessTools = new Dictionary<IJob, HashSet<IToolInstance>>();
     _inProcessToolSchedules = new Dictionary<IJob, HashSet<IScheduledTool>>();
     _processedJobs = new Dictionary<IJob, Tuple<int, int>>();
     _toolAvailableStates = new Dictionary<ITool, Dictionary<int, bool>>();
     foreach (var tool in _converter.ToolTypes)
     {
         _toolAvailableStates.Add(tool.Key, new Dictionary<int, bool>());
         foreach (var ti in tool.Value)
         {
             _toolAvailableStates[tool.Key].Add(ti.Key, true);
         }
     }
 }
 public WorkerManager(IShift shift, LaborConverter converter)
 {
     _shift = shift;
     _converter = converter;
     _inProcessJobs = new Dictionary<IWorker, IJob>();
     _inProcessWorkers = new Dictionary<IJob, HashSet<IWorker>>();
     _inProcessWorkerSchedules = new Dictionary<IJob, HashSet<IScheduledWorker>>();
     _processedJobs = new Dictionary<IJob, Tuple<int, int>>();
     _workerAvailableStates = new Dictionary<ISkill, Dictionary<int, bool>>();
     foreach (var item in _converter.WorkerTypes)
     {
         _workerAvailableStates.Add(item.Key, new Dictionary<int, bool>());
         foreach (var worker in item.Value)
         {
             _workerAvailableStates[item.Key].Add(worker.Key, true);
         }
     }
 }
 public WorkerManager(IShift shift, LaborConverter converter)
 {
     _shift                    = shift;
     _converter                = converter;
     _inProcessJobs            = new Dictionary <IWorker, IJob>();
     _inProcessWorkers         = new Dictionary <IJob, HashSet <IWorker> >();
     _inProcessWorkerSchedules = new Dictionary <IJob, HashSet <IScheduledWorker> >();
     _processedJobs            = new Dictionary <IJob, Tuple <int, int> >();
     _workerAvailableStates    = new Dictionary <ISkill, Dictionary <int, bool> >();
     foreach (var item in _converter.WorkerTypes)
     {
         _workerAvailableStates.Add(item.Key, new Dictionary <int, bool>());
         foreach (var worker in item.Value)
         {
             _workerAvailableStates[item.Key].Add(worker.Key, true);
         }
     }
 }
Beispiel #23
0
 private bool CanPost(IPostable receipt, IShift shift, out string message)
 {
     if ((receipt.GetItemsCount() > 0) && (receipt.TotalPrice <= shift.Balance))
     {
         message = $"К возврату: {receipt.TotalPrice} руб";
         return(true);
     }
     else if (receipt.GetItemsCount() < 1)
     {
         message = $"список товаров пуст";
         return(false);
     }
     else
     {
         message = $"недостаточно средств в кассе для выдачи сдачи " +
                   $"({receipt.TotalPrice - shift.Balance}).\n " +
                   $"В кассе: {shift.Balance} руб)";
         return(false);
     }
 }
Beispiel #24
0
 /// <summary>
 /// Adds the given element to the collection
 /// </summary>
 /// <param name="item">The item to add</param>
 public override void Add(IModelElement item)
 {
     if ((this._parent.Line == null))
     {
         ILineDetail lineCasted = item.As<ILineDetail>();
         if ((lineCasted != null))
         {
             this._parent.Line = lineCasted;
             return;
         }
     }
     if ((this._parent.Shift == null))
     {
         IShift shiftCasted = item.As<IShift>();
         if ((shiftCasted != null))
         {
             this._parent.Shift = shiftCasted;
             return;
         }
     }
 }
        public override IEnumerable <IWorker> Convert(AvailableLaborLink input)
        {
            if (!InstancesMap.ContainsKey(input))
            {
                var labor = input.Labor;
                if (!_skillConverter.NamedInstances.ContainsKey(labor.Name))
                {
                    _skillConverter.Convert(labor);
                }
                ISkill skill = _skillConverter.InstancesMap[labor];

                if (!WorkerTypes.ContainsKey(skill))
                {
                    WorkerTypes.Add(skill, new Dictionary <int, IWorker>());
                }

                if (!_shiftConverter.NamedInstances.ContainsKey(input.Shift.Name))
                {
                    _shiftConverter.Convert(input.Shift);
                }
                IShift shift = _shiftConverter.InstancesMap[input.Shift];

                var workers = new HashSet <IWorker>();
                for (int i = 0; i < input.AvailableQuantity; i++)
                {
                    var worker = Factory.Create(skill, shift);
                    workers.Add(worker);
                    WorkerTypes[skill].Add(worker.ID, worker);
                }

                InstancesMap.GetOrAdd(input, workers);
            }
            else
            {
                string test = "do we really already have it?";
            }

            return(InstancesMap[input]);
        }
        public void ScheduleJob(IShift shift, IJob job)
        {
            ShiftWorkerManager[shift].ScheduleJob(job);
            ShiftToolManager[shift].ScheduleJob(job);

        }
Beispiel #27
0
 public Tool(string toolType, IShift shift) : this(-1, toolType, shift)
 {
 }
Beispiel #28
0
 private int GetRemainingIterationShiftTime(IShift shift, int iteration)
 {
     return shift.EndTime - GetIterationShiftTime(iteration);
 }
Beispiel #29
0
 private int InitializeNextIteration(IShift shift)
 {
     _currentShift = shift;
     return _currentShift.NextStart();
 }
 public bool AreToolsAvailable(IShift currentShift, IJob job)
 {
     return ShiftToolManager[currentShift].CanProcess(job);
 }
 public bool AreWorkersAvailable(IShift currentShift, IJob job)
 {
     return ShiftWorkerManager[currentShift].CanWork(job);
 }
Beispiel #32
0
 public Tool(string toolType, IShift shift): this(-1, toolType, shift)
 {
 }
Beispiel #33
0
 public void AddShift(IShift shift)
 {
     throw new NotImplementedException();
 }
Beispiel #34
0
        /*Florin
         * open a widow for saving shift and saves data in the main matrix
         */
        public void MachingTheData(object sender, MouseButtonEventArgs e)
        {
            Assign_Shift myWindow    = new Assign_Shift();
            int          tempDateId  = -1;
            int          tempStaffId = -1;
            int          tempShiftId = -1;
            Assign_Shift shiftWindow = new Assign_Shift();

            shiftWindow.ShowDialog();
            var    getSelectedButton = (Button)sender;
            string str = getSelectedButton.Name;

            int tempRowNr1 = Convert.ToInt16(str[1] - 48);
            int tempRowNr2 = Convert.ToInt16(str[2] - 48);

            if (tempRowNr1 * 10 + tempRowNr2 < 27)
            {
                RowNumber    = tempRowNr1 * 10 + tempRowNr2;
                ColumnNumber = Convert.ToInt16(str[4] - 48);
            }
            else
            {
                RowNumber    = Convert.ToInt16(str[1] - 48);
                ColumnNumber = Convert.ToInt16(str[3] - 48);
            }
            //foreach (IShiftDate myShift in myController.ShiftIds)
            for (int i = 0; i <= myController.ShiftIds.Count; i++)
            {
                IShiftDate myShift = myController.ShiftIds[i];
                if (Matrix[1, ColumnNumber] == myShift.DateWorked.ToShortDateString())
                {
                    tempDateId = myShift.DateId;
                    i          = myController.ShiftIds.Count + 1;
                }
            }
            // foreach (IStaffMember myStaff in myController.StaffMembers)
            for (int i = 0; i <= myController.StaffMembers.Count; i++)
            {
                IStaffMember myStaff = myController.StaffMembers[i];
                if (Matrix[RowNumber, 0] == myStaff.StaffMemberName)
                {
                    tempStaffId = myStaff.StaffMemeberId;
                    i           = myController.StaffMembers.Count + 1;
                }
            }
            IShift cbShift  = (IShift)myWindow.lbShiftType.SelectedItem;
            IShift myshifts = (IShift)shiftWindow.lbShiftType.SelectedItem;

            myController.Selectedshift = myshifts;
            if (myController.Selectedshift != null)
            {
                tempShiftId = myController.Selectedshift.ShiftId;
            }
            if (tempShiftId != -1)
            {
                myController.AddNewShiftDateInDB(tempDateId, tempStaffId, tempShiftId);
            }

            myController.GetAllFromDB();
            DrawButtons();
        }
Beispiel #35
0
 public bool AreToolsAvailable(IShift currentShift, IJob job)
 {
     return(ShiftToolManager[currentShift].CanProcess(job));
 }
Beispiel #36
0
 public Worker(ISkill skill, IShift shift) : this(-1, skill, shift)
 {
 }
 public MathCellsShifter(IShift shiftWay, int delimiterIndex, GridForm ownerGrid)
 {
     _shiftWay       = shiftWay;
     _delimiterIndex = delimiterIndex;
     _ownerGrid      = ownerGrid;
 }
Beispiel #38
0
 public void AddEngineerToShift(IShift shift, IEngineer engineer)
 {
     shift.Engineer = engineer;
     engineer.Shifts.Add(shift);
 }
 public void CompleteJob(IShift shift, IScheduledJob job)
 {
     ShiftWorkerManager[shift].CompleteJob(job.Job);
     ShiftToolManager[shift].CompleteJob(job.Job);
 }
 private void AddShift(IShift shift)
 {
     if (!ShiftWorkerManager.ContainsKey(shift))
     {
         ShiftWorkerManager.Add(shift, new WorkerManager(shift, _laborConverter));
     }
     if (!ShiftToolManager.ContainsKey(shift))
     {
         ShiftToolManager.Add(shift, new ToolManager(shift, _toolConverter));
     }
 }
Beispiel #41
0
 private int InitializeNextIteration(IShift shift)
 {
     _currentShift = shift;
     return(_currentShift.NextStart());
 }
Beispiel #42
0
 private int GetRemainingIterationShiftTime(IShift shift, int iteration)
 {
     return(shift.EndTime - GetIterationShiftTime(iteration));
 }
Beispiel #43
0
 public Worker(ISkill skill, IShift shift) : this(-1, skill, shift)
 {
 }