Example #1
0
        public DocumentViewModel(Document document)
        {
            if (document == null) throw new ArgumentNullException("document");

            CompositionInitializer.SatisfyImports(this);

            mDocument = document;

            SaveButtonCommand = new DelegateCommand<object>(SaveButtonHandler, CanExecuteOkButtonHandler);
            RemoveButtonCommand = new DelegateCommand<object>(RemoveButtonHandler, CanExecuteDeleteButtonHandler);

            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            cmsWebServiceClient.GetDocumentTypesCompleted += cmsWebServiceClient_GetDocumentTypesCompleted;
            cmsWebServiceClient.GetDocumentTypesAsync();

            Areas = new ObservableCollection<Area>(from x in CMS.Cache.Areas where x.IsActive && x.SiteId == CMS.AppSetting.DefaultSiteId select x);

            cmsWebServiceClient.GetDocumentAuthorsCompleted += cmsWebServiceClient_GetDocumentAuthorsCompleted;
            cmsWebServiceClient.GetDocumentAuthorsAsync();

            cmsWebServiceClient.GetDocumentDisciplinesCompleted += (s, e) =>
                {
                    DocumentDisciplines = new ObservableCollection<DocumentDiscipline>(e.Result);
                    mDisciplinesLoaded = true;
                    OnDataSourceLoaded();
                };
            cmsWebServiceClient.GetDocumentDisciplinesAsync();

            cmsWebServiceClient.GetDocumentPurchaseOrdersCompleted += (s, e) =>
            {
                DocumentPurchaseOrders = new ObservableCollection<DocumentPurchaseOrder>(e.Result);
                DocumentPurchaseOrders.Insert(0, new DocumentPurchaseOrder { Name = BLANK, Id = -1 });
                mPurchaseOrdersLoaded = true;
                OnDataSourceLoaded();
            };
            cmsWebServiceClient.GetDocumentPurchaseOrdersAsync();

            if (mDocument.DocumentVersions != null && mDocument.DocumentVersions.Count > 0)
            {
                mSelectedVersion = Document.DocumentVersions[0];
            }
        }
Example #2
0
 public static Task<List<DocumentType>> GetDocumentTypes()
 {
     var task = new TaskCompletionSource<List<DocumentType>>();
     var cee = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
     cee.GetDocumentTypesCompleted += (s, e) => task.SetResult(e.Result);
     cee.GetDocumentTypesAsync();
     return task.Task;
 }
        private void LoadIssueDocumentTypes(NodeView expandedNode)
        {
            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            EventHandler<GetDocumentTypesCompletedEventArgs> fetchCompleted = null;
            fetchCompleted = (s, eventArgs) =>
            {
                List<DocumentType> docTypeList = eventArgs.Result;

                foreach (DocumentType docType in docTypeList)
                {
                    NodeView child = new NodeView(expandedNode)
                    {
                        Id = docType.Id,
                        Name = docType.Name,
                        Description = docType.Description,
                        Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png",
                        Type = NodeType.DocumentTypeNode,
                        SortField = docType.Ordinal.ToString(),
                        HasChildren = false
                    };
                    expandedNode.Children.Add(child);
                }
                Utils.HideSpinner(expandedNode);
                expandedNode.Sort();
                cmsWebServiceClient.GetDocumentTypesCompleted -= fetchCompleted;
            };

            cmsWebServiceClient.GetDocumentTypesCompleted += fetchCompleted;
            cmsWebServiceClient.GetDocumentTypesAsync(false);
        }