private void LoadBindData()
        {
            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            Classifications = new List<IssueClassification>();

            //Load Component types
            EventHandler<GetIssueClassificationsCompletedEventArgs> fetchCompleted = (s, e) =>
            {
                Classifications = e.Result;

                cmsWebServiceClient.GetIssueTypeClassificationsCompleted += (s1, e1) =>
                {
                    var issueTypeClassifications = e1.Result;
                    var existingissueTypeClassification = (from x in issueTypeClassifications
                                                           where x.Id == mIssueTypeClassificationId
                                                           select x).FirstOrDefault();

                    foreach (var issueTypeClassification in issueTypeClassifications)
                    {
                        var existingClassification = (from x in Classifications
                                                      where x.Id == issueTypeClassification.IssueClassificationId
                                                      select x).FirstOrDefault();

                        if (mInEditMode)
                        {
                            //If we are in edit mode remove all existing classification excep the one we are editing
                            if (existingClassification.Id != existingissueTypeClassification.IssueClassificationId)
                            {
                                Classifications.Remove(existingClassification);
                            }
                        }
                        else
                        {
                            //If we are NOT in edit mode remove all existing classification
                            Classifications.Remove(existingClassification);
                        }
                    }

                    if (mInEditMode)
                    {

                        SelectedClassification = (from x in Classifications
                                                  where x.Id == existingissueTypeClassification.IssueClassificationId
                                                  select x).FirstOrDefault();

                        mOrdinal = existingissueTypeClassification.Ordinal;
                    }

                    DataLoaded();
                };

                cmsWebServiceClient.GetIssueTypeClassificationsAsync(mIssueTypeId);

            };
            cmsWebServiceClient.GetIssueClassificationsCompleted += fetchCompleted;
            cmsWebServiceClient.GetIssueClassificationsAsync();
        }
Esempio n. 2
0
 public static Task LoadIssueClassificationsCache()
 {
     var task = new TaskCompletionSource<bool>();
     if (CMS.Cache.IssueClassifications == null)
     {
         CMS.Cache.IssueClassifications = new ObservableCollection<IssueClassification>();
         var cee = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
         DateTime now = DateTime.Now;
         System.Diagnostics.Debug.WriteLine("LoadIssueClassificationsCache First {0}", now.ToString("G"));
         //IssueClassifications
         cee.GetIssueClassificationsCompleted += (s, e) =>
         {
             CMS.Cache.IssueClassifications = new ObservableCollection<IssueClassification>(e.Result.OrderBy(x => x.Ordinal));
             var elapsed = DateTime.Now - now;
             System.Diagnostics.Debug.WriteLine("LoadIssueClassificationsCache: {0}", elapsed.TotalSeconds);
             task.SetResult(true);
         };
         cee.GetIssueClassificationsAsync();
     }
     else
     {
         task.SetResult(true);
         return task.Task; //Already loaded
     }
     return task.Task;
 }
        private void LoadIssueClassifications(NodeView expandedNode)
        {
            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);

            EventHandler<GetIssueClassificationsCompletedEventArgs> fetchCompleted = null;
            fetchCompleted = (s, eventArgs) =>
            {
                List<IssueClassification> issueClassifications = eventArgs.Result;
                foreach (IssueClassification issueClassification in issueClassifications)
                {
                    NodeView child = new NodeView(expandedNode)
                    {
                        Id = issueClassification.Id,
                        Name = issueClassification.Name,
                        Description = issueClassification.Description,
                        IsActive = issueClassification.IsActive,
                        Icon = "/CmsEquipmentDatabase;component/Images/Configuration.png",
                        Type = NodeType.IssueClassificationNode,
                        HasChildren = false,
                        SortField = issueClassification.Ordinal.ToString(),
                    };
                    expandedNode.Children.Add(child);
                    cmsWebServiceClient.GetIssueClassificationsCompleted -= fetchCompleted;
                }
                Utils.HideSpinner(expandedNode);
                expandedNode.Sort();
            };
            cmsWebServiceClient.GetIssueClassificationsCompleted += fetchCompleted;
            cmsWebServiceClient.GetIssueClassificationsAsync();
        }