/// <summary>
        /// Servers the message recieved.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The e.</param>
        private void Server_MessageRecieved(object sender, string e)
        {
            if (string.IsNullOrEmpty(e))
            {
                return;
            }

            var splitted = e.Split('$');

            if (splitted.Length != 2)
            {
                this.log.Error("Data Format is not correct. The length must be 2 with splitter $!");
                return;
            }

            string ShiftPrimaryKey = splitted.FirstOrDefault();

            if (string.IsNullOrWhiteSpace(ShiftPrimaryKey))
            {
                this.log.Error("Shift Primary key cannot be whitespace or null!");
                return;
            }

            dynamic shiftRepository = null;
            Shift   existingShift   = shiftRepository.GetById(ShiftPrimaryKey);

            if (existingShift == null)
            {
                this.log.Error("Data not exist in the Database!");
                return;
            }

            string shiftStateAsStringInteger = splitted.LastOrDefault();

            if (string.IsNullOrWhiteSpace(shiftStateAsStringInteger))
            {
                this.log.Error("Shift state cannot be whitespace or null!");
                return;
            }

            int shiftStateAsInteger = 0;

            if (!int.TryParse(shiftStateAsStringInteger, out shiftStateAsInteger))
            {
                this.log.Error("Shift state can only be integer value between 0 to 4!");
                return;
            }


            ShiftStateType shiftCurrentState = ShiftStateType.Finished;

            if (!Enum.TryParse <ShiftStateType>(shiftStateAsStringInteger, out shiftCurrentState))
            {
                this.log.Error("Shift state value must be between 0 to 4!");
                return;
            }

            existingShift.StateType = shiftCurrentState;

            dynamic unitOfwork = null;

            var erpOperationResult = erpClient.PushShiftState(ShiftPrimaryKey, shiftCurrentState);

            if (erpOperationResult)
            {
                unitOfwork.Commit();
            }
        }
Beispiel #2
0
 /// <summary>
 /// Pushes the state of the shift.
 /// </summary>
 /// <param name="shiftId">The shift identifier.</param>
 /// <param name="stateType">Type of the state.</param>
 /// <returns></returns>
 public bool PushShiftState(string shiftId, ShiftStateType stateType)
 {
     return(true);
 }