Пример #1
0
        public AddRoleModel()
        {
            mRole = new Role();

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

            cmsWebServiceClient.GetIssueCategoriesCompleted += cmsWebServiceClient_GetIssueCategoriesCompleted;
            cmsWebServiceClient.GetIssueCategoriesAsync();

            OkButtonCommand = new DelegateCommand<object>(OkButtonHander, CanExecuteOkButtonHandler);
            CancelButtonCommand = new DelegateCommand<object>(CancelButtonHander, CanExecuteOkButtonHandler);
        }
Пример #2
0
        public static Task LoadIssueCategoriesCache()
        {
            var task = new TaskCompletionSource<bool>();

            if (CMS.Cache.IssueCategories == null)
            {
                CMS.Cache.IssueCategories = new CmsObservableCollection<IssueCategory>();
                var cee = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

                DateTime now = DateTime.Now;
                System.Diagnostics.Debug.WriteLine("LoadIssueCategoriesCache First {0}", now.ToString("G"));

                //IssueCategories
                cee.GetIssueCategoriesCompleted += (s4, e4) =>
                {
                    CMS.Cache.IssueCategories = new ObservableCollection<IssueCategory>(e4.Result.OrderBy(x => x.Ordinal));
                    var elapsed = DateTime.Now - now;
                    System.Diagnostics.Debug.WriteLine("LoadIssueCategoriesCache: {0}      {1}", elapsed.TotalSeconds, DateTime.Now);
                    task.SetResult(true);
                };
                cee.GetIssueCategoriesAsync();
            }
            else
            {
                task.SetResult(true);
                return task.Task; //Already loaded
            }
            return task.Task;
        }
Пример #3
0
        private void LoadIssueCategories(NodeView expandedNode)
        {
            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            EventHandler<GetIssueCategoriesCompletedEventArgs> fetchCompleted = null;
            fetchCompleted = (s, eventArgs) =>
                                 {
                                     List<IssueCategory> issueCategories = eventArgs.Result;
                                     foreach (IssueCategory issueCategory in issueCategories)
                                     {
                                         NodeView issueCategoryNode = new NodeView(expandedNode)
                                                                          {
                                                                              Id = issueCategory.Id,
                                                                              Name = issueCategory.Name,
                                                                              Description = issueCategory.Description,
                                                                              IsActive = issueCategory.IsActive,
                                                                              Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png",
                                                                              Type = NodeType.IssueCategoryNode,
                                                                              HasChildren = true,
                                                                              SortField = issueCategory.Ordinal.ToString(),
                                                                          };

                                         expandedNode.Children.Add(issueCategoryNode);
                                         cmsWebServiceClient.GetIssueCategoriesCompleted -= fetchCompleted;
                                     }
                                     expandedNode.Sort();
                                     Utils.HideSpinner(expandedNode);
                                 };
            cmsWebServiceClient.GetIssueCategoriesCompleted += fetchCompleted;
            cmsWebServiceClient.GetIssueCategoriesAsync();
        }