Beispiel #1
0
 public static ComponentSetup ToComponentSetup(this DAL.GENERAL_EQ_UNIT geu)
 {
     return(new ComponentSetup
     {
         Brand = geu.make_auto.HasValue ? ((int)geu.make_auto).ToMake() : 0.ToMake(),
         BudgetLife = geu.track_budget_life ?? 0,
         EquipmentSMU = geu.eq_smu_at_install.LongNullableToInt(),
         Grouser = new IdTitleV {
             Id = geu.ShoeGrouserNo ?? 0, Title = geu.ShoeGrouserNo.HasValue ? ((int)geu.ShoeGrouserNo).ToGrouser() : ""
         },
         HoursAtInstall = geu.cmu.LongNullableToInt(),
         Id = geu.equnit_auto.LongNullableToInt(),
         InstallCost = geu.cost ?? 0,
         InstallDate = (geu.date_installed ?? DateTime.MinValue).ToLocalTime().Date,
         listPosition = 0,
         Note = geu.compart_note,
         Points = 1,
         Pos = geu.pos ?? 0,
         Result = new ResultMessage {
             Id = 0, OperationSucceed = true, LastMessage = "", ActionLog = ""
         },
         ShoeSize = new ShoeSizeV {
             Id = geu.ShoeSizeId ?? 0, Size = geu.SHOE_SIZE != null ? geu.SHOE_SIZE.Size : 0, Title = geu.SHOE_SIZE != null ? geu.SHOE_SIZE.Title : ""
         },
         SystemId = geu.module_ucsub_auto.LongNullableToInt(),
         Validity = false,
         Compart = new CompartV
         {
             Id = geu.compartid_auto,
             CompartStr = geu.compartsn,
             CompartTitle = geu.LU_COMPART.compart,
             MeasurementPointsNo = 1,
             CompartType = new CompartTypeV {
                 Id = geu.LU_COMPART.LU_COMPART_TYPE.comparttype_auto, Title = geu.LU_COMPART.LU_COMPART_TYPE.comparttype, Order = geu.LU_COMPART.LU_COMPART_TYPE.sorder ?? 1
             },
             Model = geu.equnit_auto.LongNullableToInt().ToModel()
         }
     });
 }
Beispiel #2
0
        public bool RecordAcrion(InventoryActionParam Param)
        {
            BLL.Core.Domain.Component LogicalComponent = new Component(_context, Param.ComponentId);
            if (LogicalComponent.Id == 0)
            {
                _message = "Component Not Found!";
                return(false);
            }
            var user = new BLL.Core.Domain.TTDevUser(new DAL.SharedContext(), Param.userId).getUCUser();

            if (user == null)
            {
                _message = "User Not Found!";
                return(false);
            }
            _actionLog += "Repalce childs first" + Environment.NewLine;
            if (!LogicalComponent.isAChildBasedOnCompart() && ReplaceChildsFirst(new InventoryActionParam {
                ActionDate = Param.ActionDate,
                BudgetLife = Param.BudgetLife,
                CMU = Param.CMU,
                Comment = Param.Comment,
                ComponentId = Param.ComponentId,
                Cost = Param.Cost,
                NewCompartId = Param.NewCompartId,
                userId = Param.userId
            }))
            {
                _actionLog += "Repalce childs returned true" + Environment.NewLine;
            }
            else
            {
                _actionLog += "Warning!! Repalce childs returned false!" + Environment.NewLine;
            }

            _actionLog += "Adding New Component ..." + Environment.NewLine;
            var LogicalCompart = new BLL.Core.Domain.Compart(_context, Param.NewCompartId);
            int systemId       = LogicalComponent.DALComponent.module_ucsub_auto.LongNullableToInt();

            DAL.GENERAL_EQ_UNIT geuNew = new DAL.GENERAL_EQ_UNIT
            {
                equipmentid_auto  = null,
                module_ucsub_auto = systemId,
                date_installed    = Param.ActionDate,
                created_user      = user.userName,
                compartid_auto    = Param.NewCompartId,
                compartsn         = LogicalCompart.GetCompartSerialNumber(),
                created_date      = Param.ActionDate,
                comp_status       = 0,
                pos  = LogicalComponent.DALComponent.pos,
                side = LogicalComponent.DALComponent.side,
                eq_ltd_at_install = 0,
                track_0_worn      = 0,
                track_100_worn    = 0,
                track_120_worn    = 0,
                track_budget_life = Param.BudgetLife,
                cmu  = Param.CMU,
                cost = Param.Cost,
                eq_smu_at_install       = 0,
                smu_at_install          = 0,
                system_LTD_at_install   = 0,
                component_current_value = 0,
                variable_comp           = false,
                insp_uom = 0
            };

            DAL.ACTION_TAKEN_HISTORY record = new DAL.ACTION_TAKEN_HISTORY
            {
                action_type_auto = (int)ActionType.TurnPinsAndBushingsLink,
                comment          = Param.Comment,
                compartid_auto   = LogicalComponent.DALComponent.compartid_auto,
                cost             = (long)Param.Cost,
                event_date       = Param.ActionDate,
                entry_date       = DateTime.Now,
                entry_user_auto  = Param.userId,
                equnit_auto      = Param.ComponentId,
                recordStatus     = 0,
                system_auto_id   = LogicalComponent.DALComponent.module_ucsub_auto
            };
            LogicalComponent.DALComponent.module_ucsub_auto     = null;
            _context.Entry(LogicalComponent.DALComponent).State = EntityState.Modified;
            _context.ACTION_TAKEN_HISTORY.Add(record);
            _context.GENERAL_EQ_UNIT.Add(geuNew);
            try
            {
                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                _message    = "Recording Action Failed! Please check Log for details";
                _actionLog += ex.Message;
                if (ex.InnerException != null)
                {
                    _actionLog += ex.InnerException.Message;
                }
                return(false);
            }
            _actionLog += "Creating a new life for the new component!" + Environment.NewLine;
            _context.COMPONENT_LIFE.Add(new DAL.ComponentLife {
                ActionDate  = Param.ActionDate,
                ActionId    = record.history_id,
                ActualLife  = Param.CMU,
                ComponentId = geuNew.equnit_auto,
                UserId      = Param.userId,
                Title       = "Installed on the system in inventory"
            });
            try
            {
                _context.SaveChanges();
                _message = "Action recorded sucessfully!";
                return(true);
            }
            catch (Exception ex)
            {
                _message    = "Action recorded with 1 warning! please check log";
                _actionLog += ex.Message;
                if (ex.InnerException != null)
                {
                    _actionLog += ex.InnerException.Message;
                }
                return(false);
            }
        }