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");
        }
Ejemplo n.º 4
0
        public DocumentAuthor SaveDocumentAuthor(DocumentAuthor documentAuthor)
        {
            using (CmsEntities cee = new CmsEntities())
            {
                DocumentAuthor original = (from x in cee.DocumentAuthors where x.Id == documentAuthor.Id select x).FirstOrDefault();

                if (original == null)
                {
                    cee.DocumentAuthors.Add(documentAuthor);
                }
                else
                {
                    original.Name = documentAuthor.Name;
                    original.Description = documentAuthor.Description;
                    original.Ordinal = documentAuthor.Ordinal;
                }

                cee.SaveChanges();
            }

            return documentAuthor;
        }
Ejemplo n.º 5
0
        void cmsWebServiceClient_GetDocumentsAndRelatedObjectsCompleted(object sender, GetDocumentsAndRelatedObjectsCompletedEventArgs e)
        {
            var documnetRelatedObjects = e.Result;

            mAreas = documnetRelatedObjects.Areas;
            mAreas.Insert(0, new Area { Id = -1, Name = "All" });
            mSelectedArea = mAreas[0];

            mInOutStatuses = new List<string>();
            mInOutStatuses.Add("All");
            mInOutStatuses.Add("Checked In");
            mInOutStatuses.Add("Checked Out");
            mSelectedInOutStatus = mInOutStatuses[0];

            mDocumentAuthors = documnetRelatedObjects.Authors;
            mDocumentAuthors.Insert(0, new DocumentAuthor { Id = -1, Name = "All" });
            mSelectedDocumentAuthor = mDocumentAuthors[0];

            mDocumentTypes = documnetRelatedObjects.DocumentTypes;
            mDocumentTypes.Insert(0, new DocumentType { Id = -1, Name = "All" });
            mSelectedDocumentType = mDocumentTypes[0];

            mFileTypes = new List<string>();
            mFileTypes.Add("All");
            mFileTypes.Add("PDF");
            mFileTypes.Add("Native");
            mSelectedFileType = mFileTypes[0];

            mDocumentStatuses = new List<string>();
            mDocumentStatuses.Add("All");
            mDocumentStatuses.Add("Active");
            mDocumentStatuses.Add("Disabled");
            mSelectedDocumentStatus = mDocumentStatuses[0];

            List<DocumentAuthor> versions = new List<DocumentAuthor>();

            versions.Add(new DocumentAuthor { Id = (int)CommonUtils.DocumentVersionFilter.All, Name = "All" });
            versions.Add(new DocumentAuthor { Id = (int)CommonUtils.DocumentVersionFilter.Latest, Name = "Latest" });
            versions.Add(new DocumentAuthor { Id = (int)CommonUtils.DocumentVersionFilter.RequireDrafting, Name = "Requires Drafting" });
            versions.Add(new DocumentAuthor { Id = (int)CommonUtils.DocumentVersionFilter.NoVersions, Name = "No Versions Exist" });
            versions.Add(new DocumentAuthor { Id = (int)CommonUtils.DocumentVersionFilter.NoNativeExist, Name = "No Native Exist" });
            versions.Add(new DocumentAuthor { Id = (int)CommonUtils.DocumentVersionFilter.NoPdfExist, Name = "No PDF Exist" });

            mFilterDocumentVersions = versions;
            mSelectedFilterDocumentVersion = versions[0];

            View.KeywordTextBox.KeyUp += (s1, e1) => ProcessSearchFilter();
            RelatedObjectLoaded = true;
            RaiseLoaded();
        }
Ejemplo n.º 6
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();
                });
            });
        }