Пример #1
0
        public InterlockRiskResult(
            CmsEquipmentDatabase.CmsWebService.ControlSystem controlSystem,
            InterlockType interlockType,
            InterlockRiskCategory riskCategory,
            InterlockRiskConsequence consequence,
            InterlockRiskLikelihood likelihood,
            InterlockRiskMatrix riskMatrix,
            Action action = Action.Insert)
        {
            ControlSystemName = controlSystem.Name;
            InterlockTypeCode = interlockType.Code;
            CategoryName = riskCategory.Name;

            if (consequence != null)
            {
                ConsequenceName = consequence.Name;
            }
            if (likelihood != null)
            {
                LikelihoodName = likelihood.Name;
            }
            if (riskMatrix != null)
            {
                RiskRatingNumber = riskMatrix.RiskRatingNumber;

                if (riskMatrix.InterlockRiskRating != null)
                {
                    RiskRatingName = riskMatrix.InterlockRiskRating.Name;
                }
            }

            Action = action;
        }
 public AddEditInterlockTypeDialog()
 {
     InitializeComponent();
     mInterlockType = new InterlockType();
     mViewModel = new AddEditInterlockTypeViewModel(mInterlockType) { View = this };
     DataContext = mViewModel;
     Utils.ResetOriginalValues(this);
 }
        public AddEditExistingInterlockPropertyDialog(InterlockType interlockType)
        {
            InitializeComponent();

            AddEditExistingInterlockPropertyViewModel model =
                new AddEditExistingInterlockPropertyViewModel(interlockType);
            model.Loaded +=
                () =>
                {
                    model.View = this;
                    DataContext = model;
                    Utils.ResetOriginalValues(this);
                };
        }
        public AddEditExistingInterlockPropertyViewModel(InterlockType interlockType)
        {
            mInterlockTypeId = interlockType.Id;
            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanModify);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true);

            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            Properties = new List<InterlockProperty>();

            //Load Interlock types
            EventHandler<GetAllInterlockPropertiesCompletedEventArgs> fetchCompleted = (s, eventArgs) =>
                                              {
                                                  cmsWebServiceClient.GetInterlockPropertiesCompleted +=
                                                      (s1, e1)
                                                      =>
                                                          {
                                                              List<int> listOfAssignedPropertyIds = new List<int>();
                                                              e1.Result.ForEach(x => listOfAssignedPropertyIds.Add(x.Id));

                                                              foreach (var interlockProperty in eventArgs.Result)
                                                              {
                                                                  if (!listOfAssignedPropertyIds.Contains(interlockProperty.Id))
                                                                  {
                                                                      Properties.Add(interlockProperty);
                                                                  }
                                                              }

                                                              if (Properties.Count > 0)
                                                              {
                                                                  SelectedProperty = Properties[0];
                                                              }
                                                              Loaded();
                                                          };

                                                  cmsWebServiceClient.GetInterlockPropertiesAsync(interlockType.Id);
                                              };
            cmsWebServiceClient.GetAllInterlockPropertiesCompleted += fetchCompleted;
            cmsWebServiceClient.GetAllInterlockPropertiesAsync();
        }
Пример #5
0
        private void InsertRevisionHistory(InterlockType interLockType, int interlockNumber, ControlSystem controlSystem)
        {
            var revision = new decimal(1.000);

            string comment = string.Empty;

            if (MetaData.ImportType == CommonUtils.ImportType.CreateInterlocks)
            {
                if (!string.IsNullOrEmpty(MetaData.RevisionHistoryComment))
                {
                    comment = BuildRevisionHistoryInsertComment(string.Format("Added Interlock Type '{0}' Number '{1}' to Control '{2}'. {3}",
                        interLockType.Name, interlockNumber, controlSystem.Name, MetaData.RevisionHistoryComment));
                }
                else
                {
                    comment = BuildRevisionHistoryInsertComment(string.Format("Added Interlock Type '{0}' Number '{1}' to Control '{2}'.",
                        interLockType.Name, interlockNumber, controlSystem.Name));
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(MetaData.RevisionHistoryComment))
                {
                    comment = BuildRevisionHistoryUpdateComment(string.Format("Updated Interlock Type '{0}' Number '{1}' on Control '{2}'. {3}",
                        interLockType.Name, interlockNumber, controlSystem.Name, MetaData.RevisionHistoryComment));
                }
                else
                {
                    comment = BuildRevisionHistoryUpdateComment(string.Format("Updated Interlock Type '{0}'  Number '{1}' on Control '{2}'.",
                        interLockType.Name, interlockNumber, controlSystem.Name));
                }
            }

            var rvh = new ControlSystemRevisionHistory
            {
                Date = DateTime.Now,
                UserId = MetaData.UserId,
                Description = comment,
                Revision = revision,
                IsSystemMessage = true
            };

            controlSystem.ControlSystemRevisionHistories.Add(rvh);
        }
Пример #6
0
        private List<PropertyNameComponentNamePair> AddDynamicProperties(InterlockDataAdapter adapter, InterlockType interlockType, Interlock interlock, string controlSystemName, int i, out bool failed)
        {
            failed = false;
            var results = new List<PropertyNameComponentNamePair>();

            foreach (DynamicProperty dynamicProperty in adapter.DynamicProperties)
            {
                //InterlockProperty
                InterlockProperty matchProperty = (from x in Cee.InterlockProperties where string.Compare(x.Name, dynamicProperty.PropertyName, true, CultureInfo.CurrentCulture) == 0 select x).FirstOrDefault();

                if (matchProperty == null)
                {
                    RaiseMessage(CommonUtils.MessageType.Error, string.Format(BuildItemNotFoundInDatabaseMessage("InterlockProperty", dynamicProperty.PropertyName, i + 1)));
                    failed = true;
                    continue;
                }

                //InterlockTypeProperty
                InterlockTypeProperty matchTypeProperty = (from x in Cee.InterlockTypeProperties
                    where x.InterlockPropertyId == matchProperty.Id
                          && x.InterlockTypeId == interlockType.Id
                    select x).FirstOrDefault();

                if (matchTypeProperty == null)
                {
                    string message = string.Format("Missing a entry in Database for the Table 'InterlockTypeProperty' Where InterlockTypeId = '{0}'({1}) And InterlockPropertyId = '{2}' ({3}). Row {4}.",
                        interlockType.Id, interlockType.Name, matchProperty.Id, matchProperty.Name, i);
                    RaiseMessage(CommonUtils.MessageType.Error, message);
                    failed = true;
                    continue;
                }

                if (PropertyValueToPropertyTypeMismatched(matchProperty.PropertyListId, matchProperty.Type, dynamicProperty, i + 1))
                {
                    continue;
                }

                //NEW
                var propertyValue = new InterlockPropertyValue
                {
                    InterlockPropertyId = matchProperty.Id,
                    Value = dynamicProperty.PropertyValue,
                    VerifiedUserDate = string.Format("{0} by {1}", DateTime.Now.ToString(@"dd/MM/yyyy hh:mm"), mUser.FirstLastName)
                };

                //add to interlock
                interlock.InterlockPropertyValues.Add(propertyValue);

                var pair = new PropertyNameComponentNamePair
                {
                    ComponentName = string.Format("Control:{0}- Interlock:{1}", controlSystemName, interlockType.Name),
                    PropertyName = matchProperty.Name,
                    Value = dynamicProperty.PropertyValue
                };

                results.Add(pair);
            }

            return results;
        }
        public InterlockType AddInterlockType(InterlockType interlockType)
        {
            using (var cee = new CmsEntities())
            {
                //Check if this component type already exist
                var existingInterlockType = (from x in cee.InterlockTypes
                                             where x.Id == interlockType.Id
                                             select x).FirstOrDefault();

                if (existingInterlockType != null)
                {
                    //Edit the Component Type
                    existingInterlockType.Name = interlockType.Name;
                    existingInterlockType.Description = interlockType.Description;
                    existingInterlockType.Ordinal = interlockType.Ordinal;

                    cee.SaveChanges();
                }
                else
                {
                    //Add new Component Type
                    existingInterlockType = new InterlockType
                    {
                        Name = interlockType.Name,
                        Description = interlockType.Description,
                        Code = interlockType.Name.Replace(" ", ""),
                        IsActive = true
                    };
                    cee.InterlockTypes.Add(existingInterlockType);

                    cee.SaveChanges();
                }
                var newInterlockType = new InterlockType
                {
                    Id = existingInterlockType.Id,
                    Name = existingInterlockType.Name,
                    Description = existingInterlockType.Description,
                    Ordinal = existingInterlockType.Ordinal,
                    Code = existingInterlockType.Code
                };

                return newInterlockType;
            }
        }