public AddEditCoefficientModel(CommonUtils.Operation operation, int itemId)
        {
            CompositionInitializer.SatisfyImports(this);

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanExecuteOkButtonHandler);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true);

            if (operation == CommonUtils.Operation.Add)
            {
                var groupId = itemId;
                mCoefficient = new CalculatedRatingCoefficient();
                //mCoefficient.CoefficientGroupId = groupId;
            }
            else if (operation == CommonUtils.Operation.Update)
            {
                var CoefficientId = itemId;
                CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

                cmsWebServiceClient.GetCalculatedRatingCoefficientCompleted += (s1, e1) =>
                {
                    mCoefficient = e1.Result;
                    if (DataLoaded != null)
                    {
                        mCoefficient = e1.Result;
                        DataLoaded();
                    }
                };
                cmsWebServiceClient.GetCalculatedRatingCoefficientAsync(CoefficientId);
            }
        }
        public void SetContext(CommonUtils.TabId tabId, bool filterIsOn)
        {
            mModel = new SearchFilterControlModel(tabId, filterIsOn) { View = this };

            mModel.SetControlValuesFromSearchFilterListRequested += (filterList) =>
            {
                if (SetControlValuesFromSearchFilterListRequested != null)
                {
                    SetControlValuesFromSearchFilterListRequested(filterList);
                }
            };

            mModel.LoadRequested += (filterList) =>
            {
                if (LoadRequested != null)
                {
                    LoadRequested(filterList);
                }
            };

            mModel.BuildSearchFilterFromControlsRequested += (searchFilterList) =>
            {
                if (BuildFiltersRequested != null)
                {
                    BuildFiltersRequested(searchFilterList);
                }
            };

            this.DataContext = mModel;
        }
        public AddEditPropertyListNameViewModel(AddEditPropertyListNameDialog view, PropertyListName propertyListName, CommonUtils.Operation operation)
        {
            View = view;
            mPropertyListName = propertyListName;

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanModifyConfig);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true);

            if (operation == CommonUtils.Operation.Update)
            {
                CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

                cmsWebServiceClient.GetPropertyListNameCompleted +=
                    (s1, e1) =>
                    {
                        mPropertyListName = e1.Result;
                        LoadPropertyListNames(mPropertyListName.PropertyListId);
                        mExistingPropertyListNamesLoaded = true;
                        FireLoaded();
                    };
                cmsWebServiceClient.GetPropertyListNameAsync(mPropertyListName.Id);
            }
            else
            {
                LoadPropertyListNames(mPropertyListName.PropertyListId);
            }
        }
        public AddEditIssueFinancialVarianceCodeModel(CommonUtils.Operation operation, int itemId)
        {
            CompositionInitializer.SatisfyImports(this);

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanExecuteOkButtonHandler);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true);

            if (operation == CommonUtils.Operation.Add)
            {
                mIssueFinancialVarianceCode = new IssueFinancialVarianceCode();
            }
            else if (operation == CommonUtils.Operation.Update)
            {
                var varianceId = itemId;
                CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

                cmsWebServiceClient.GetIssueFinancialVarianceCodeCompleted += (s1, e1) =>
                {
                    mIssueFinancialVarianceCode = e1.Result;
                    if (DataLoaded != null)
                    {
                        mIssueFinancialVarianceCode = e1.Result;
                        DataLoaded();
                    }
                };
                cmsWebServiceClient.GetIssueFinancialVarianceCodeAsync(varianceId);
            }
        }
Example #5
0
        public AddEditUnitViewUnit(AddEditUnitDialog view, Unit unit, CommonUtils.Operation operation)
        {
            View = view;
            mUnit = unit;
            LoadUnits();

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanModifyConfig);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true);

            if (operation == CommonUtils.Operation.Update)
            {
                CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

                cmsWebServiceClient.GetUnitCompleted +=
                    (s1, e1) =>
                    {
                        mUnit = e1.Result;
                        FireLoaded();
                    };
                cmsWebServiceClient.GetUnitAsync(mUnit.Id);
            }
            else
            {
                FireLoaded();
            }
        }
        public AddEditIssueFinancialVarianceCodeDialog(CommonUtils.Operation operation, int itemId)
        {
            InitializeComponent();

            if (operation == CommonUtils.Operation.Add)
            {
                var groupId = itemId;
                AddEditIssueFinancialVarianceCodeModel viewModel = new AddEditIssueFinancialVarianceCodeModel(operation, groupId);
                viewModel.View = this;
                DataContext = viewModel;
                Title = "Add Financtial Variance Code";
            }
            else if (operation == CommonUtils.Operation.Update)
            {
                var varianceId = itemId;
                AddEditIssueFinancialVarianceCodeModel viewModel = new AddEditIssueFinancialVarianceCodeModel(operation, varianceId);
                viewModel.View = this;
                Title = "Edit Financial Variance Code";
                viewModel.DataLoaded += () =>
                {
                    DataContext = viewModel;
                   // Utils.ResetOriginalValues(this);
                };
            }
        }
        public ElectricalDataAdapter(OleDbDataReader dr, string workSheetName, int rowNumber, CommonUtils.ImportType importType)
        {
            RowNumber = rowNumber;
            WorkSheetName = workSheetName;

            Tag = dr.SafeString((int) EquipmentColumn.Tag).Trim();
            EquipmentType = dr.SafeString((int) EquipmentColumn.Type).Trim();
            Description = dr.SafeString((int) EquipmentColumn.Description).Trim();
            Notes = dr.SafeString((int) EquipmentColumn.Notes);
            AreaNumber = dr.SafeString((int)EquipmentColumn.Area).Trim();
            Specification = dr.SafeString((int)EquipmentColumn.Spec).Trim();
            PandID = dr.SafeString((int)EquipmentColumn.PID).Trim();
            MaintSysId = dr.SafeString((int)EquipmentColumn.MaintSysId);

            string classifiedString = dr.SafeString((int)EquipmentColumn.Classified);
            bool classified;
            if (bool.TryParse(classifiedString, out classified))
            {
                Classified = classified;
            }

            string isActiveString = dr.SafeString((int)EquipmentColumn.IsActive);
            bool isActive;
            if (bool.TryParse(isActiveString, out isActive))
            {
                IsActive = isActive;
            }

            Validate(importType==CommonUtils.ImportType.CreateElectrical);
        }
 public AddEditManufacturerDialog(int manufacturerId, CommonUtils.EquipmentTypeCode equipmentType)
 {
     InitializeComponent();
     Title = "Edit Manufacturer";
     model = new AddEditManufacturerViewModel(manufacturerId, (int)equipmentType);
     model.View = this;
 }
        public AddEditPromptDialog(CommonUtils.Operation operation, int itemId)
        {
            InitializeComponent();

            if (operation == CommonUtils.Operation.Add)
            {
                var groupId = itemId;
                AddEditPromptModel viewModel = new AddEditPromptModel(operation, groupId);
                viewModel.View = this;
                DataContext = viewModel;
                Title = "Add New Prompt";
            }
            else if (operation == CommonUtils.Operation.Update)
            {
                var promptId = itemId;
                AddEditPromptModel viewModel = new AddEditPromptModel(operation, promptId);
                viewModel.View = this;
                Title = "Edit Prompt";
                viewModel.DataLoaded += () =>
                {
                    DataContext = viewModel;
                    Utils.ResetOriginalValues(this);
                };
            }
        }
 public void ClearRevisionHistory(CommonUtils.TabId tabId, int equipmentId)
 {
     if (mViewModel != null)
     {
         mViewModel.RevisionHistories.Clear();
         mViewModel.RaisePropertyChanged("RevisionHistories");
     }
 }
        public PreferredEquipmetListView(CommonUtils.EquipmentTypeCode equipmentTypeCode)
        {
            InitializeComponent();

            CompositionInitializer.SatisfyImports(this);
            mViewModel = new PreferredEquipmentListViewModel(equipmentTypeCode);
            DataContext = mViewModel;
        }
Example #12
0
 public static string GetAppSettingValue(CommonUtils.AppSettingKey keyIn)
 {
     using (CmsEntities cee = new CmsEntities())
     {
         string keyInText = keyIn.ToString();
         return (from x in cee.AppSettings where string.Compare(keyInText, x.Key, StringComparison.OrdinalIgnoreCase) == 0 select x.Value).FirstOrDefault();
     }
 }
 public AddEditManufacturerDialog(CommonUtils.EquipmentTypeCode equipmentType)
 {
     InitializeComponent();
     Manufacturer = new Manufacturer();
     Manufacturer.EquipmentTypeId = (int) equipmentType;
     model = new AddEditManufacturerViewModel(Manufacturer, (int)equipmentType);
     model.View = this;
     Utils.ResetOriginalValues(this);
 }
Example #14
0
        public RiskReviewDialog(Issue issue, CommonUtils.RiskType riskType)
        {
            if (DesignerProperties.IsInDesignTool){return;}
            // Required to initialize variables
            InitializeComponent();

            RiskReviewDialogViewModel riskReviewDialogViewModel = new RiskReviewDialogViewModel(issue, riskType, this);
            DataContext = riskReviewDialogViewModel;
        }
        public AddEditSearchFilterListDialog(CommonUtils.TabId tabId, List<SearchFilterList> existingSearchFilterLists)
        {
            InitializeComponent();

            mModel = new AddEditSearchFilterListModel(tabId, existingSearchFilterLists) {View = this};
            DataContext = mModel;

            Title = "Add New Favourite Search Filter";
        }
        public AddEditKpiVarianceCodeViewModel(IssueKpi kpi, CommonUtils.KpiVarianceCode varianceCode, List<IssueKpiVarianceCode> issueKpiVarianceCodes)
        {
            IssueKpiVarianceCodes = issueKpiVarianceCodes;
            mKpi = kpi;
            mVarianceCode = varianceCode;

            OkButtonCommand = new DelegateCommand<object>(OkButtonHandler, CanExecuteOkButtonHandler);
            CancelButtonCommand = new DelegateCommand<object>(CanelButtonHandler, CanExecuteOkButtonHandler);
        }
        public AddEditVarianceCodeViewModel(IssueFinancial financial,CommonUtils.VarianceCode varianceCode, List<IssueFinancialVarianceCode> issueFinancialVarianceCodes)
        {
            IssueFinancialVarianceCodes = issueFinancialVarianceCodes;
            mFinancial = financial;
            mVarianceCode = varianceCode;

            OkButtonCommand = new DelegateCommand<object>(OkButtonHandler, CanExecuteOkButtonHandler);
            CancelButtonCommand = new DelegateCommand<object>(CanelButtonHandler, CanExecuteOkButtonHandler);
        }
        public PreferredEquipmentListViewModel(CommonUtils.EquipmentTypeCode equipmentTypeCode)
        {
            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            cmsWebServiceClient.GetPreferredEquipmentsCompleted += (s, e) =>
            {
                PreferredEquipments = e.Result;
            };
            cmsWebServiceClient.GetPreferredEquipmentsAsync(equipmentTypeCode);
        }
        //ADD
        public AddEditSearchFilterListModel(CommonUtils.TabId tabId, List<SearchFilterList> existingSearchFilterLists)
        {
            ExistingSearchFilters = existingSearchFilterLists;
            SearchFilterList = new SearchFilterList {UserId = CMS.User.Id, TabId = (int) tabId, Ordinal = 0, IsDefault = false};

            OkCommand = new DelegateCommand<object>(OkCommandHandler, CanExecuteOkCommand);
            CancelCommand = new DelegateCommand<object>(CancelCommandHandler, CanExecuteOkCommand);

            OnDataSourceLoaded();
        }
        public IssueSummaryListView(List<int> ints, CommonUtils.SummaryViewType summaryType, string filterName)
        {
            InitializeComponent();
            CompositionInitializer.SatisfyImports(this);

            RadContextMenu radContextMenu = removeFavouriteContextMenu.Parent as RadContextMenu;

            if (summaryType == CommonUtils.SummaryViewType.MyFavouriteIssues)
            {
                if (radContextMenu == null)
                {
                    return;
                }

                radContextMenu.Opened += (s, e) =>
                    {
                        RadContextMenu menu = (RadContextMenu) s;
                        menu.Items.Clear();
                        GridViewRow row = menu.GetClickedElement<GridViewRow>();

                        if (row != null)
                        {
                            row.IsSelected = row.IsCurrent = true;
                            GridViewCell cell = menu.GetClickedElement<GridViewCell>();
                            if (cell != null)
                            {
                                cell.IsCurrent = true;
                                var issueSummaryDto = row.DataContext as IssueSummaryDto;
                                if (issueSummaryDto != null)
                                {
                                    var quickIssue = new QuickIssue {Id = issueSummaryDto.Id, IsActive = issueSummaryDto.IsActive};

                                    RadMenuItem rmi = new RadMenuItem {Header = "Remove from Favourites", Icon = null};
                                    rmi.IsEnabled = (CMS.EffectivePrivileges.AdminTab.CanDelete || CMS.EffectivePrivileges.IssueTab.CanView) && quickIssue.IsActive;
                                    rmi.Click += (s3, args) => RemoveFromFavourites(quickIssue);
                                    menu.Items.Add(rmi);
                                }
                            }
                        }
                        else
                        {
                            menu.IsOpen = false;
                        }
                    };
            }
            else
            {
                radContextMenu.Visibility = Visibility.Collapsed;
            }

            mViewModel = new IssueSummaryListViewModel(ints, summaryType, filterName);
            FilterName = filterName;
            SummaryType = summaryType;
            DataContext = mViewModel;
        }
 public AddEditEquipmentPropertyDialog(CommonUtils.EquipmentPropertyType equipmentPropertyType, string descriptionRowHeight = "25")
 {
     InitializeComponent();
     Title = GetAddTitle(equipmentPropertyType);
     AddEditEquipmentPropertyViewModel viewModel = new AddEditEquipmentPropertyViewModel(equipmentPropertyType, descriptionRowHeight) { View = this };
     viewModel.DataLoaded += () =>
     {
         DataContext = viewModel;
         Utils.ResetOriginalValues(this);
     };
 }
Example #22
0
        public static bool ShowDownloadToolFile(HttpResponse httpResponse, NameValueCollection queryString, CommonUtils.AppSettingKey settingKey, out Exception message)
        {
            try
            {
                string fileName = queryString["DownloadToolFile"];

                if (string.IsNullOrEmpty(fileName))
                {
                    message = new Exception("Query string 'DownloadToolFile' missing from url.");
                    return false;
                }

                if (!File.Exists(fileName))
                {
                    message = new FileNotFoundException(string.Format(@"Failed to find file '{0}'.
                                                    Please ask your administrator to check whether the folder exists.", fileName));
                    return false;
                }

                httpResponse.Clear();
                httpResponse.ClearContent();

                //Response.OutputStream.f
                httpResponse.BufferOutput = true;
                httpResponse.ContentType = "application/unknown";
                httpResponse.AddHeader("Content-Disposition", string.Format("attachment; filename=\"{0}\"", Path.GetFileName(fileName)));
                byte[] fileContent = File.ReadAllBytes(fileName);

                BinaryWriter binaryWriter = new BinaryWriter(httpResponse.OutputStream);
                binaryWriter.Write(fileContent, 0, fileContent.Length);
                binaryWriter.Flush();
                binaryWriter.Close();

                var dirName = Path.GetDirectoryName(fileName);

                if (dirName != null)
                {
                    //Delete any files that are older than 1 hour
                    Directory.GetFiles(dirName)
                        .Select(f => new FileInfo(f))
                        .Where(f => f.CreationTime < DateTime.Now.AddHours(-1))
                        .ToList()
                        .ForEach(f => f.Delete());
                }
            }
            catch (Exception ex)
            {
                message = ex;
                return false;
            }

            message = null;
            return true;
        }
        public IssueSummaryListViewModel(List<int> issueIds, CommonUtils.SummaryViewType viewType, string filterName)
        {
            CompositionInitializer.SatisfyImports(this);
            mIssueIds = issueIds;
            mFilterName = filterName;
            mViewType = viewType;

            LoadData(mIssueIds, mViewType, mFilterName);

            GoToIssueLink = new DelegateCommand<object>(GoToIssueLinkLinkHandler, CanModifyHandler);
        }
        public SearchFilterControlModel(CommonUtils.TabId tabId, bool filterIsOn)
        {
            CompositionInitializer.SatisfyImports(this);

            mTabId = tabId;
            FilterIsOn = filterIsOn;
            OpenEditSearchFiltersDialogCommand = new DelegateCommand<object>(OpenDialogHandler, CanViewHandler);

            var model = new EditSearchFiltersModel(tabId);
            model.DataLoaded += searchFilterList => { BuildContextMenuItems(model.SearchFilterLists); };
        }
        public ExportEquipmentAttachmentsDialog(CommonUtils.AttachmentObject attachmentObject)
        {
            InitializeComponent();
            IsBusyIndicator.IsBusy = true;

            mModel = new ExportAttachmentsModel(attachmentObject) { View = this };
            mModel.ModelLoaded += () =>
            {
                DataContext = mModel;
                IsBusyIndicator.IsBusy = false;
            };
        }
 public void LoadRevisionHistory(CommonUtils.TabId tabId, int equipmentId)
 {
     if (mViewModel == null)
     {
         mViewModel = new RevisionHistoryViewModel(tabId, equipmentId);
         DataContext = mViewModel;
     }
     else
     {
         mViewModel.Load(tabId, equipmentId);
     }
 }
        public DocumentEquipmentDataAdapter(OleDbDataReader dr, int rowNumber, CommonUtils.ImportType importType)
        {
            DocumentName = string.Empty;
            EquipmentTypeName = string.Empty;

            RowNumber = rowNumber;
            mImportType = importType;
            DocumentName = dr.SafeString((int)DocumentEquipmentColumn.DocumentName).Trim();
            EquipmentTypeName = dr.SafeString((int)DocumentEquipmentColumn.EquipmentType).Trim();
            Tag = dr.SafeString((int)DocumentEquipmentColumn.Tag).Trim();
            this.Validate(rowNumber, importType == CommonUtils.ImportType.LinkRelatedEquipmentDocument);
        }
        public AddEditEquipmentPropertyViewModel(CommonUtils.EquipmentPropertyType equipmentPropertyType, string descriptionRowHeight)
        {
            DescriptionRowHeight = descriptionRowHeight;
            mEquipmentPropertyType = equipmentPropertyType;
            CreateComponentPropertyInstance();
            Types = GetPropertyTypes();
            Type = Types[0];
            IsEditable = true;
            IsVisible = true;

            LoadAllPropertyLists();
            LoadExistingProperties();

            InitialiseCommandButtons();
        }
        public AddEditKpiVarianceCodeDialog(IssueKpi kpi, CommonUtils.KpiVarianceCode varianceCode, List<IssueKpiVarianceCode> issueKpiVarianceCodes)
        {
            InitializeComponent();

            CompositionInitializer.SatisfyImports(this);

            Title = "Variance";

            if (varianceCode == CommonUtils.KpiVarianceCode.Kpi) Title = String.Format("Reason For KPI Variance ({0:MMM yy})", kpi.Date);
            if (varianceCode == CommonUtils.KpiVarianceCode.ValueGeneration) Title = String.Format("Reason For Value Generation Variance ({0:MMM yy})", kpi.Date);

            var viewModel = new AddEditKpiVarianceCodeViewModel(kpi, varianceCode, issueKpiVarianceCodes);
            viewModel.View = this;
            DataContext = viewModel;
        }
        public AddEditVarianceCodeDialog(IssueFinancial financial, CommonUtils.VarianceCode varianceCode,List<IssueFinancialVarianceCode> issueFinancialVarianceCodes)
        {
            InitializeComponent();

            CompositionInitializer.SatisfyImports(this);

            Title = "Variance";

            if (varianceCode == CommonUtils.VarianceCode.ActualVsBaseline) Title = String.Format("Reason For Actual vs Baseline Variance ({0:MMM yy})", financial.Date);
            if (varianceCode == CommonUtils.VarianceCode.ActualVsForecast) Title = String.Format("Reason For Actual vs Forecast Variance ({0:MMM yy})", financial.Date);

            var viewModel = new AddEditVarianceCodeViewModel(financial, varianceCode,issueFinancialVarianceCodes);
            viewModel.View = this;
            DataContext = viewModel;
        }