Exemplo n.º 1
0
 public GETFlagIgnoredAction(DbContext context, IEquipmentActionRecord actionRecord, GETFlagIgnoredParams Parameters)
     : base((GETContext)context)
 {
     Params        = Parameters;
     _actionRecord = actionRecord;
     Status        = ActionStatus.Close;
 }
Exemplo n.º 2
0
 public ChangeMeterUnitAction(DbContext context, IEquipmentActionRecord actionRecord, ChangeMeterUnitParams Paramteres)
     : base(context)
 {
     Params        = Paramteres;
     _actionRecord = actionRecord;
     Status        = ActionStatus.Close;
 }
Exemplo n.º 3
0
 public UpdateEquipmentSetupAction(System.Data.Entity.DbContext context, IEquipmentActionRecord actionRecord, GETEquipmentSetupParams Paramteres)
     : base(context)
 {
     Params   = Paramteres;
     _status  = ActionStatus.Close;
     _current = actionRecord;
 }
Exemplo n.º 4
0
 public GETInspectionAction(DbContext context, IEquipmentActionRecord actionRecord, GETInspectionParams Parameters)
     : base((GETContext)context, new UndercarriageContext())
 {
     Params        = Parameters;
     _actionRecord = actionRecord;
     Status        = ActionStatus.Close;
 }
Exemplo n.º 5
0
 public MoveImplementToInventoryAction(DbContext context, DbContext gContext, IEquipmentActionRecord actionRecord, MoveImplementToInventoryParams Parameters)
     : base((GETContext)gContext, (UndercarriageContext)context)
 {
     Params        = Parameters;
     _actionRecord = actionRecord;
     Status        = ActionStatus.Close;
 }
Exemplo n.º 6
0
 public ReplaceSystemAction(DbContext context, IEquipmentActionRecord actionRecord, ReplaceSystemParams Parameters)
     : base(context)
 {
     Params        = Parameters;
     _actionRecord = actionRecord;
     Status        = ActionStatus.Close;
 }
Exemplo n.º 7
0
 public AttachImplementToEquipmentAction(DbContext context, DbContext gContext, IEquipmentActionRecord actionRecord, AttachImplementToEquipmentParams Parameters)
     : base((GETContext)gContext, (UndercarriageContext)context)
 {
     Params        = Parameters;
     _actionRecord = actionRecord;
     Status        = ActionStatus.Close;
 }
Exemplo n.º 8
0
 public UpdateInspectionGeneralAction(System.Data.Entity.DbContext context, IEquipmentActionRecord actionRecord, IGeneralInspectionModel Paramteres)
     : base(context)
 {
     Params   = Paramteres;
     _status  = ActionStatus.Close;
     _current = actionRecord;
 }
Exemplo n.º 9
0
 public GETEquipmentSetupAction(DbContext context, DbContext gContext, IEquipmentActionRecord actionRecord, GETEquipmentSetupParams Parameters)
     : base((GETContext)gContext, (UndercarriageContext)context)
 {
     Params        = Parameters;
     _actionRecord = actionRecord;
     Status        = ActionStatus.Close;
 }
Exemplo n.º 10
0
 public InstallComponentOnSystemAction(DbContext context, IEquipmentActionRecord actionRecord, InstallComponentOnSystemParams Parameters)
     : base(context)
 {
     Params        = Parameters;
     _actionRecord = actionRecord;
     Status        = ActionStatus.Close;
 }
Exemplo n.º 11
0
 public UpdateUndercarriageSetupAction(System.Data.Entity.DbContext context, IEquipmentActionRecord actionRecord, SetupViewModel Paramteres)
     : base(context)
 {
     Params   = Paramteres;
     Status   = ActionStatus.Close;
     _current = actionRecord;
 }
Exemplo n.º 12
0
 public InsertInspectionAction(DbContext context, IEquipmentActionRecord actionRecord, InsertInspectionParams Paramteres)
     : base(context)
 {
     Params        = Paramteres;
     _actionRecord = actionRecord;
     Status        = ActionStatus.Close;
 }
Exemplo n.º 13
0
 public GETComponentReplacementAction(DbContext context, IEquipmentActionRecord actionRecord, GETComponentReplacementParams Parameters)
     : base((GETContext)context)
 {
     Params        = Parameters;
     _actionRecord = actionRecord;
     Status        = ActionStatus.Close;
 }
Exemplo n.º 14
0
Arquivo: Action.cs Projeto: hari81/BLL
 public Action(DbContext context, IEquipmentActionRecord actionRecord, IGeneralInspectionModel Parameters)
 {
     _context = (UndercarriageContext)context;
     _current = actionRecord;
     if (Parameters.Id == 0)
     {
         Operation = new InsertInspectionGeneralAction(context, actionRecord, Parameters);
     }
     else
     {
         Operation = new UpdateInspectionGeneralAction(context, actionRecord, Parameters);
     }
 }
Exemplo n.º 15
0
Arquivo: Action.cs Projeto: hari81/BLL
 public Action(DbContext context, DbContext gContext, IEquipmentActionRecord actionRecord, GETEquipmentSetupParams Parameters)
 {
     _context  = (UndercarriageContext)context;
     _gContext = (GETContext)gContext;
     if (Parameters.IsUpdating)
     {
         Operation = new BLL.Core.Actions.UpdateEquipmentSetupAction(context, actionRecord, Parameters);
     }
     else
     {
         Operation = new BLL.GETCore.Repositories.GETEquipmentSetupAction(context, gContext, actionRecord, Parameters);
     }
 }
Exemplo n.º 16
0
Arquivo: Action.cs Projeto: hari81/BLL
        protected bool UpdateGETByAction(IEquipmentActionRecord actionRecord, ref string OperationResult)
        {
            bool result = false;

            var getEventsByUC = _gContext.GET_EVENTS.Where(m => m.UCActionHistoryId == actionRecord.Id);

            if (getEventsByUC.Count() > 0) //Means update
            {
                var getEventTobeUpdated = getEventsByUC.First();
                //All the logic for the lifes to be updated based on getEventTobeUpdated
            }
            else
            { //Insert
                GET_EVENTS GetEvents = new GET_EVENTS
                {
                    user_auto     = actionRecord.ActionUser.Id,
                    action_auto   = (int)GETActionType.UndercarriageAction,
                    event_date    = actionRecord.ActionDate,
                    comment       = actionRecord.Comment,
                    cost          = actionRecord.Cost,
                    recorded_date = actionRecord.ActionDate
                };

                GET_EVENTS_EQUIPMENT GetEventsEquipment = new GET_EVENTS_EQUIPMENT
                {
                    equipment_auto = actionRecord.EquipmentId,
                    smu            = actionRecord.ReadSmuNumber,
                    ltd            = 0, // Check this.
                    events_auto    = 0  // Check this.
                };

                //GET_EVENTS_IMPLEMENT GetEventsImplement = new GET_EVENTS_IMPLEMENT
                //{

                //};

                //GET_EVENTS_COMPONENT GetEventsComponent = new GET_EVENTS_COMPONENT
                //{

                //};
            }
            return(result);
        }
Exemplo n.º 17
0
Arquivo: Action.cs Projeto: hari81/BLL
        /// <summary>
        /// This method validates current action based on the current recorded history.
        /// Must be called before any operations! Otherwise will be incorrect!
        /// Not suitable for update an action because updating action won't be neglected and
        /// validation may be invalid!
        /// Not available for inventory actions
        /// </summary>
        /// <returns></returns>
        public ActionPreValidationResult PreValidate(IEquipmentActionRecord actionRecord)
        {
            var result = new ActionPreValidationResult
            {
                Id           = actionRecord.Id,
                EquipmentId  = actionRecord.EquipmentId,
                IsValid      = true,
                Status       = ActionValidationStatus.Valid,
                ProvidedDate = actionRecord.ActionDate,
                ProvidedSMU  = actionRecord.ReadSmuNumber,
                EarliestValidDateForProvidedSMU = DateTime.MinValue,
                SmallestValidSmuForProvidedDate = 0
            };
            Equipment LogicalEquipment = new Equipment(_context, actionRecord.EquipmentId);

            if (actionRecord.EquipmentId == 0 || LogicalEquipment.Id == 0)
            {
                result.Status  = ActionValidationStatus.InvalidEquipment;
                result.IsValid = false;
                return(result);
            }

            result.SmallestValidSmuForProvidedDate = LogicalEquipment.GetSerialMeterUnit(actionRecord.ActionDate);
            int NextSMU = GetNextEquipmentSerialMeterUnit(LogicalEquipment.Id, actionRecord.ActionDate);

            result.EarliestValidDateForProvidedSMU = LogicalEquipment.DALEquipment.purchase_date ?? DateTime.MinValue;

            var lives = LogicalEquipment.GetEquipmentAvailableLives().Where(m => m.SerialMeterReading <= actionRecord.ReadSmuNumber).OrderByDescending(m => m.ActionDate);

            if (lives.Count() > 0)
            {
                result.EarliestValidDateForProvidedSMU = lives.FirstOrDefault().ActionDate;
            }

            if (actionRecord.ReadSmuNumber < result.SmallestValidSmuForProvidedDate || actionRecord.ReadSmuNumber > NextSMU)
            {
                result.IsValid = false;
                result.Status  = ActionValidationStatus.InvalidSMU;
            }
            return(result);
        }
Exemplo n.º 18
0
Arquivo: Action.cs Projeto: hari81/BLL
 public Action(DbContext context, IEquipmentActionRecord actionRecord, ReplaceComponentParams Parameters)
 {
     _context  = (UndercarriageContext)context;
     Operation = new ReplaceComponentAction(context, actionRecord, Parameters);
 }
Exemplo n.º 19
0
Arquivo: Action.cs Projeto: hari81/BLL
 public Action(DbContext context, IEquipmentActionRecord actionRecord, GETUndoComponentReplacementParams Parameters)
 {
     _gContext = (GETContext)context;
     Operation = new BLL.GETCore.Repositories.GETUndoComponentReplacementAction(context, actionRecord, Parameters);
 }
Exemplo n.º 20
0
Arquivo: Action.cs Projeto: hari81/BLL
 public Action(DbContext context, IEquipmentActionRecord actionRecord, GETFlagIgnoredParams Parameters)
 {
     _gContext = (GETContext)context;
     Operation = new BLL.GETCore.Repositories.GETFlagIgnoredAction(context, actionRecord, Parameters);
 }
Exemplo n.º 21
0
Arquivo: Action.cs Projeto: hari81/BLL
 public Action(DbContext context, DbContext gContext, IEquipmentActionRecord actionRecord, MoveImplementToInventoryParams Parameters)
 {
     _context  = (UndercarriageContext)context;
     _gContext = (GETContext)gContext;
     Operation = new BLL.GETCore.Repositories.MoveImplementToInventoryAction(context, gContext, actionRecord, Parameters);
 }
Exemplo n.º 22
0
 public SMUReadingAction(DbContext context, IEquipmentActionRecord actionRecord)
     : base(context)
 {
     _actionRecord = actionRecord;
     Status        = ActionStatus.Close;
 }
Exemplo n.º 23
0
Arquivo: Action.cs Projeto: hari81/BLL
        protected IEquipmentActionRecord UpdateEquipmentByAction(IEquipmentActionRecord actionRecord, ref string OperationResult)
        {
            //Steps in this method:
            //1- Create a record in ACTION_TAKEN_HISTORY Table with no data in EquipmentSMU and EquipmentLTD
            //2- Update Equipment, Systems and Components life
            //3- Update ACTION_TAKEN_HISTORY Table with New EquipmentSMU and EquipmentLTD
            //4- Return an IEquipmentActionRecord to use in the occuring action

            actionLifeUpdate = new ActionLifeUpdate();
            DALEquipment     = _context.EQUIPMENTs.Find(actionRecord.EquipmentId);
            if (DALEquipment == null)
            {
                return(null);
            }
            //Step1
            int aType = 0;

            try
            {
                aType = (int)actionRecord.TypeOfAction;
            }
            catch { aType = (int)ActionType.NoActionTakenYet; }

            OperationResult += "Start insert into ACTION_TAKEN_HISTORY" + System.Environment.NewLine;
            var k = new ACTION_TAKEN_HISTORY
            {
                action_type_auto = aType,
                cmu                = 0,
                event_date         = actionRecord.ActionDate,
                entry_date         = DateTime.Now,
                entry_user_auto    = actionRecord.ActionUser.Id,
                equipmentid_auto   = actionRecord.EquipmentId,
                cost               = (long)actionRecord.Cost,
                equipment_ltd      = 0, //Will be updated in Step3
                equipment_smu      = 0, //Will be updated in Step3
                comment            = actionRecord.Comment,
                GETActionHistoryId = actionRecord.GETHistoryId,
                recordStatus       = (int)RecordStatus.MiddleOfAction
            };

            _context.ACTION_TAKEN_HISTORY.Add(k);
            try
            {
                _context.SaveChanges();
                OperationResult += "Succeded" + System.Environment.NewLine;
                DALRecord        = k;
            }
            catch (Exception ex)
            {
                OperationResult += "Error :" + ex.Message + System.Environment.NewLine;
                Message          = "Saving action history failed!";
                return(null);
            }

            if (longNullableToint(k.history_id) == 0)
            {
                OperationResult += "Error: Returned Id is not valid" + System.Environment.NewLine;
                Message          = "Action history has not been saved successfully";
                return(null);
            }
            actionLifeUpdate.ActionTakenHistory = k;
            int EquipmentActualLife = actionRecord.EquipmentActualLife;
            int EquipmentCurrentSMU = actionRecord.ReadSmuNumber;

            //End of Step 1
            if (k.action_type_auto != (int)ActionType.UpdateSetupEquipment)
            {
                //Step2
                OperationResult += "Updating Equipment, Systems and Components life " + System.Environment.NewLine;
                if (!UpdateEquipmentLife(actionRecord.EquipmentId, actionRecord.ReadSmuNumber, actionRecord.ActionUser.Id, longNullableToint(k.history_id), actionRecord.ActionDate, ref OperationResult))
                {
                    return(null);
                }
                EquipmentActualLife = GetEquipmentLife(actionRecord.EquipmentId, actionRecord.ActionDate, true);
                EquipmentCurrentSMU = GetEquipmentSerialMeterUnit(actionRecord.EquipmentId, actionRecord.ActionDate, true);

                if (EquipmentActualLife < 0 || EquipmentCurrentSMU < 0)
                {
                    OperationResult += "Equipment Actual Life OR Equipment Current SMU is invalid" + System.Environment.NewLine;
                    Message          = "Stored Life or SMU of the equipment is less than zero and not correct!";
                    return(null);
                }
            }

            //Step3
            k.equipment_ltd         = EquipmentActualLife;
            k.equipment_smu         = EquipmentCurrentSMU;
            _context.Entry(k).State = System.Data.Entity.EntityState.Modified;

            try
            {
                OperationResult += "Updating Action Taken History..." + Environment.NewLine;
                _context.SaveChanges();
                OperationResult += "Succeded" + Environment.NewLine;
            }
            catch (Exception ex)
            {
                OperationResult += "Error :" + ex.Message + Environment.NewLine;
                Message          = "Updating action history failed!";
                return(null);
            }

            //Step4
            actionRecord.Id = (int)k.history_id;
            actionRecord.EquipmentActualLife = EquipmentActualLife;
            return(actionRecord);
        }
Exemplo n.º 24
0
Arquivo: Action.cs Projeto: hari81/BLL
 public Action(DbContext context, IEquipmentActionRecord actionRecord, ChangeMeterUnitParams Parameters)
 {
     _context  = (UndercarriageContext)context;
     Operation = new ChangeMeterUnitAction(context, actionRecord, Parameters);
 }
Exemplo n.º 25
0
Arquivo: Action.cs Projeto: hari81/BLL
 public Action(DbContext context, IEquipmentActionRecord actionRecord, InstallSystemParams Parameters)
 {
     _context  = (UndercarriageContext)context;
     Operation = new InstallSystemAction(context, actionRecord, Parameters);
 }
Exemplo n.º 26
0
Arquivo: Action.cs Projeto: hari81/BLL
 public Action(UndercarriageContext context, IEquipmentActionRecord actionRecord, SetupViewModel Parameters)
 {
     _context  = context;
     Operation = new UpdateUndercarriageSetupAction(_context, actionRecord, Parameters);
 }
Exemplo n.º 27
0
Arquivo: Action.cs Projeto: hari81/BLL
 public Action(DbContext context, IEquipmentActionRecord actionRecord)
 {
     _context  = (UndercarriageContext)context;
     Operation = new SMUReadingAction(context, actionRecord);
 }
Exemplo n.º 28
0
        public IEquipmentActionRecord UpdateEquipmentByAction(IEquipmentActionRecord actionRecord, ref string OperationResult)
        {
            //Steps in this method:
            //1- Create a record in ACTION_TAKEN_HISTORY Table with no data in EquipmentSMU and EquipmentLTD
            //2- Update Equipment, Systems and Components life
            //3- Update ACTION_TAKEN_HISTORY Table with New EquipmentSMU and EquipmentLTD
            //4- Return an IEquipmentActionRecord to use in the happening action

            //Step1
            OperationResult += "Start insert into -> ACTION_TAKEN_HISTORY" + System.Environment.NewLine;
            var k = new ACTION_TAKEN_HISTORY
            {
                action_type_auto = (int)ActionType.NoActionTakenYet,
                cmu              = 0,
                event_date       = actionRecord.ActionDate,
                entry_date       = DateTime.Now,
                entry_user_auto  = actionRecord.ActionUser.Id,
                equipmentid_auto = actionRecord.EquipmentId,
                cost             = (long)actionRecord.Cost,
                equipment_ltd    = 0, //Will be updated in Step3
                equipment_smu    = 0, //Will be updated in Step3
                comment          = actionRecord.Comment
            };

            _context.ACTION_TAKEN_HISTORY.Add(k);
            try
            {
                _context.SaveChanges();
                OperationResult += "Succeded" + System.Environment.NewLine;
            }
            catch (Exception ex)
            {
                OperationResult += "Error :" + ex.Message + System.Environment.NewLine;
                return(null);
            }

            if (base.longNullableToint(k.history_id) == 0)
            {
                OperationResult += "Error: Returned Id is not valid" + System.Environment.NewLine;
                return(null);
            }

            //End of Step 1

            //Step2
            OperationResult += "Updating Equipment, Systems and Components life -> " + System.Environment.NewLine;
            if (!UpdateEquipmentLife(actionRecord.EquipmentId, actionRecord.ReadSmuNumber, actionRecord.ActionUser.Id, base.longNullableToint(k.history_id), actionRecord.ActionDate, ref OperationResult))
            {
                return(null);
            }

            int EquipmentActualLife = GetEquipmentLife(actionRecord.EquipmentId, actionRecord.ActionDate);
            int EquipmentCurrentSMU = GetEquipmentSerialMeterUnit(actionRecord.EquipmentId, actionRecord.ActionDate);

            if (EquipmentActualLife < 0 || EquipmentCurrentSMU < 0)
            {
                OperationResult += "Equipment Actual Life OR Equipment Current SMU is invalid" + System.Environment.NewLine;
                return(null);
            }


            //Step3
            k.equipment_ltd         = EquipmentActualLife;
            k.equipment_smu         = EquipmentCurrentSMU;
            _context.Entry(k).State = System.Data.Entity.EntityState.Modified;

            //Step4
            actionRecord.Id = (int)k.history_id;
            actionRecord.EquipmentActualLife = EquipmentActualLife;
            return(actionRecord);
        }
Exemplo n.º 29
0
Arquivo: Action.cs Projeto: hari81/BLL
 public Action(DbContext context, IEquipmentActionRecord actionRecord, UpdateInspectionParams Parameters)
 {
     _context  = (UndercarriageContext)context;
     Operation = new UpdateInspectionAction(context, actionRecord, Parameters);
 }
Exemplo n.º 30
0
Arquivo: Action.cs Projeto: hari81/BLL
 protected bool rollBackGETAction(IEquipmentActionRecord actionRecord, ref string OperationResult)
 {
     //throw new NotImplementedException();
     return(false);
 }