public AddEditDocumentLocationModel()
        {
            mDocumentLocation = new DocumentLocation();
            mDocumentLocation.IsActive = true;

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanExecuteOkButtonHandler);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, x => true);
        }
        public AddEditDocumentLocationModel(int documentLocationId)
        {
            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            cmsWebServiceClient.GetDocumentLocationAsync(documentLocationId);
            cmsWebServiceClient.GetDocumentLocationCompleted += (s1, e1) =>
                {
                    mDocumentLocation = e1.Result;
                    DataLoaded();
                };

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanExecuteOkButtonHandler);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, CanExecuteOkButtonHandler);
        }
        private void SetControlValuesFromSearchFilterList(SearchFilterList searchFilterList)
        {
            mSearchFilterControl.SetFilterIsOn(true);
            ClearControls();

            foreach (SearchFilter filter in searchFilterList.SearchFilters)
            {
                if (!string.IsNullOrEmpty(filter.Value))
                {
                    //KeyWords
                    if (filter.Name.Equals(CommonUtils.DocumentSearchFilterNames.KeyWord.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        mKeyword = filter.Value;
                        RaisePropertyChanged("Keyword");
                    }

                    //Area
                    if (filter.Name.Equals(CommonUtils.DocumentSearchFilterNames.Area.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            Area match = (from x in Areas where x.Id == result select x).FirstOrDefault();
                            mSelectedArea= match;
                            RaisePropertyChanged("SelectedArea");
                        }
                    }

                    //Author
                    if (filter.Name.Equals(CommonUtils.DocumentSearchFilterNames.Author.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            DocumentAuthor match = (from x in Authors where x.Id == result select x).FirstOrDefault();
                            mSelectedDocumentAuthor = match;
                            RaisePropertyChanged("SelectedDocumentAuthor");
                        }
                    }

                    //Discipline
                    if (filter.Name.Equals(CommonUtils.DocumentSearchFilterNames.Discipline.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            DocumentDiscipline match = (from x in DocumentDisciplines where x.Id == result select x).FirstOrDefault();
                            mSelectedDocumentDiscipline = match;
                            RaisePropertyChanged("SelectedDocumentDiscipline");
                        }
                    }

                    //DocumentStatus
                    if (filter.Name.Equals(CommonUtils.DocumentSearchFilterNames.DocumentStatus.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        //For compatibility as previously it was saved as ID
                        if (filter.Value == "-1") filter.Value = All;
                        if (filter.Value == "-2") filter.Value = "Active";
                        if (filter.Value == "-3") filter.Value = "Disabled";

                        var match = (from x in DocumentStatuses where x == filter.Value select x).FirstOrDefault();
                        mSelectedDocumentStatus = match;
                        RaisePropertyChanged("SelectedDocumentStatus");
                    }

                    //DocumentType
                    if (filter.Name.Equals(CommonUtils.DocumentSearchFilterNames.DocumentType.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            DocumentType match = (from x in DocumentTypes where x.Id == result select x).FirstOrDefault();
                            mSelectedDocumentType = match;
                            RaisePropertyChanged("SelectedDocumentType");
                        }
                    }

                    //Location
                    if (filter.Name.Equals(CommonUtils.DocumentSearchFilterNames.Location.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            DocumentLocation match = (from x in DocumentLocations where x.Id == result select x).FirstOrDefault();
                            mSelectedDocumentLocation = match;
                            RaisePropertyChanged("SelectedDocumentLocation");
                        }
                    }

                    //PurchaseOrder
                    if (filter.Name.Equals(CommonUtils.DocumentSearchFilterNames.PurchaseOrder.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            DocumentPurchaseOrder match = (from x in PurchaseOrders where x.Id == result select x).FirstOrDefault();
                            mSelectedPurchaseOrder = match;
                            RaisePropertyChanged("SelectedPurchaseOrder");
                        }
                    }

                    //CheckInOutStatus
                    if (filter.Name.Equals(CommonUtils.DocumentSearchFilterNames.CheckInOutStatus.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        //For compatibility as previously it was saved as Id
                        if (filter.Value == "-1") filter.Value = All;
                        if (filter.Value == "-2") filter.Value = "Checked Out";
                        if (filter.Value == "-3") filter.Value = "Checked In";

                        var match = (from x in InOutStatuses where x == filter.Value select x).FirstOrDefault();
                        mSelectedInOutStatus = match;
                        RaisePropertyChanged("SelectedInOutStatus");
                    }

                    //Version
                    if (filter.Name.Equals(CommonUtils.DocumentSearchFilterNames.Version.ToString(), StringComparison.CurrentCultureIgnoreCase))
                    {
                        int result;
                        if (int.TryParse(filter.Value, out result))
                        {
                            var match = (from x in DocumentVersionFilters where x.Id == result select x).FirstOrDefault();
                            mSelectedDocumentVersionFilter = match;
                            RaisePropertyChanged("SelectedDocumentVersionFilter");

                        }
                    }
                }
            }

            ProcessSearchFilter();
        }
        private void LoadedDocumentsReleatedData()
        {
            var documentDisciplinesTask = DatabaseLoader.GetDocumentDisciplines();
            var documentAuthorsTask = DatabaseLoader.GetDocumentAuthors();
            var documentLocationsTask = DatabaseLoader.GetDocumentLocations();
            var documentTypesTask = DatabaseLoader.GetDocumentTypes();
            var documentPurchaseOrdersTask = DatabaseLoader.GetDocumentPurchaseOrders();

            List<Task> tasks = new List<Task>();
            tasks.Add(documentDisciplinesTask);
            tasks.Add(documentAuthorsTask);
            tasks.Add(documentLocationsTask);
            tasks.Add(documentTypesTask);
            tasks.Add(documentPurchaseOrdersTask);

            Task.Factory.ContinueWhenAll(tasks.ToArray(), x =>
            {
                CMS.UiFactory.StartNew(() =>
                {
                    List<DocumentDiscipline> list = documentDisciplinesTask.Result;
                    list.Insert(0, new DocumentDiscipline {Id = -1, Name = "All"});
                    DocumentDisciplines = new ObservableCollection<DocumentDiscipline>(list);
                    mSelectedDocumentDiscipline = list[0];
                    RaisePropertyChanged("DocumentDisciplines");
                    RaisePropertyChanged("SelectedDocumentDiscipline");

                    var authors = documentAuthorsTask.Result;
                    authors.Insert(0, new DocumentAuthor {Id = -1, Name = "All"});
                    Authors = new ObservableCollection<DocumentAuthor>(authors);
                    mSelectedDocumentAuthor = Authors[0];
                    RaisePropertyChanged("Authors");
                    RaisePropertyChanged("SelectedDocumentAuthor");

                    var locations = documentLocationsTask.Result;
                    locations.Insert(0, new DocumentLocation {Id = -1, Name = "All"});
                    DocumentLocations = new ObservableCollection<DocumentLocation>(locations);
                    mSelectedDocumentLocation = DocumentLocations[0];
                    RaisePropertyChanged("DocumentLocations");
                    RaisePropertyChanged("SelectedDocumentLocation");

                    var types = documentTypesTask.Result;
                    types.Insert(0, new DocumentType {Id = -1, Name = "All"});
                    DocumentTypes = new ObservableCollection<DocumentType>(types);
                    mSelectedDocumentType = DocumentTypes[0];
                    RaisePropertyChanged("DocumentTypes");
                    RaisePropertyChanged("SelectedDocumentType");

                    PurchaseOrders = new ObservableCollection<DocumentPurchaseOrder>(documentPurchaseOrdersTask.Result);
                    PurchaseOrders.Insert(0, new DocumentPurchaseOrder {Id = 0, Name = All, Description = ""});
                    mSelectedPurchaseOrder = PurchaseOrders[0];
                    RaisePropertyChanged("PurchaseOrders");
                    RaisePropertyChanged("SelectedPurchaseOrder");

                    //SetUpFilteredLinkControl();
                    InitialiseSearchFilterControl(CommonUtils.TabId.Documents);

                });
            });
        }
        private void ClearControls()
        {
            mKeyword = string.Empty;
            RaisePropertyChanged("Keyword");

            mSelectedArea = Areas[0];
            RaisePropertyChanged("SelectedArea");

            mSelectedDocumentDiscipline = DocumentDisciplines[0];
            RaisePropertyChanged("SelectedDocumentDiscipline");

            mSelectedDocumentType = DocumentTypes[0];
            RaisePropertyChanged("SelectedDocumentType");

            mSelectedPurchaseOrder = PurchaseOrders[0];
            RaisePropertyChanged("SelectedPurchaseOrder");

            mSelectedDocumentAuthor = Authors[0];
            RaisePropertyChanged("SelectedDocumentAuthor");

            mSelectedDocumentVersionFilter = DocumentVersionFilters[0];
            RaisePropertyChanged("SelectedDocumentVersionFilter");

            mSelectedInOutStatus = InOutStatuses[0];
            RaisePropertyChanged("SelectedInOutStatus");

            mSelectedDocumentStatus = DocumentStatuses[0];
            RaisePropertyChanged("SelectedDocumentStatus");

            mSelectedDocumentLocation = DocumentLocations[0];
            RaisePropertyChanged("SelectedDocumentLocation");
        }
Exemplo n.º 6
0
        public DocumentLocation SaveDocumentLocation(DocumentLocation documentLocation)
        {
            using (CmsEntities cee = new CmsEntities())
            {
                DocumentLocation original = (from x in cee.DocumentLocations where x.Id == documentLocation.Id select x).FirstOrDefault();

                if (original == null)
                {
                    cee.DocumentLocations.Add(documentLocation);
                    cee.SaveChanges();
                    return documentLocation;
                }

                original.Name = documentLocation.Name;
                original.Description = documentLocation.Description;
                original.IsActive = documentLocation.IsActive;
                cee.SaveChanges();
                return original;
            }
        }
Exemplo n.º 7
0
        private void LoadedDocumentsReleatedData()
        {
            var documentDisciplinesTask = DatabaseLoader.GetDocumentDisciplines();
            var documentAuthorsTask = DatabaseLoader.GetDocumentAuthors();
            var documentLocationsTask = DatabaseLoader.GetDocumentLocations();
            var documentTypesTask = DatabaseLoader.GetDocumentTypes();
            var documentPurchaseOrdersTask = DatabaseLoader.GetDocumentPurchaseOrders();

            List<Task> tasks = new List<Task>();
            tasks.Add(documentDisciplinesTask);
            tasks.Add(documentAuthorsTask);
            tasks.Add(documentLocationsTask);
            tasks.Add(documentTypesTask);
            tasks.Add(documentPurchaseOrdersTask);

            Task.Factory.ContinueWhenAll(tasks.ToArray(), x =>
            {
                CMS.UiFactory.StartNew(() =>
                {
                    DocumentDisciplines = documentDisciplinesTask.Result;
                    DocumentDisciplines.Insert(0, new DocumentDiscipline {Id = -1, Name = "All"});
                    mSelectedDocumentDiscipline = DocumentDisciplines[0];
                    RaisePropertyChanged("DocumentDisciplines");
                    RaisePropertyChanged("SelectedDocumentDiscipline");

                    Authors = documentAuthorsTask.Result;
                    Authors.Insert(0, new DocumentAuthor {Id = -1, Name = "All"});
                    mSelectedDocumentAuthor = Authors[0];
                    RaisePropertyChanged("Authors");
                    RaisePropertyChanged("SelectedDocumentAuthor");

                    DocumentLocations = documentLocationsTask.Result;
                    DocumentLocations.Insert(0, new DocumentLocation { Id = -1, Name = "All" });
                    mSelectedDocumentLocation = DocumentLocations[0];
                    RaisePropertyChanged("DocumentLocations");
                    RaisePropertyChanged("SelectedDocumentLocation");

                    DocumentTypes = documentTypesTask.Result;
                    DocumentTypes.Insert(0, new DocumentType {Id = -1, Name = "All"});
                    mSelectedDocumentType = DocumentTypes[0];
                    RaisePropertyChanged("DocumentTypes");
                    RaisePropertyChanged("SelectedDocumentType");

                    PurchaseOrders = documentPurchaseOrdersTask.Result;
                    PurchaseOrders.Insert(0, new DocumentPurchaseOrder {Id = 0, Name = All, Description = ""});
                    mSelectedPurchaseOrder = PurchaseOrders[0];
                    RaisePropertyChanged("PurchaseOrders");
                    RaisePropertyChanged("SelectedPurchaseOrder");

                    ProcessSearchFilter();
                });
            });
        }