Exemple #1
0
        public WorkItem DownloadWIfromSM(string Id)
        {
            EnterpriseManagementObject wiInSM = null;
            WorkItem wi = new WorkItem();

            EnterpriseManagementObjectCriteria criteria = new EnterpriseManagementObjectCriteria(String.Format("Name='{0}'", Id), wiClass);

            IObjectReader <EnterpriseManagementObject> reader = mg.EntityObjects.
                                                                GetObjectReader <EnterpriseManagementObject>(criteria, ObjectQueryOptions.Default);

            if (reader.Count == 1)
            {    // Found WI
                wiInSM = reader.GetRange(0, 1)[0];
            }
            else
            {
                Console.WriteLine("Can't find Work Item {0}", Id);
                Environment.Exit(2);
            }

            wi.Id                 = Convert.ToString(wiInSM[wiClass, "Id"].Value);
            wi.Title              = Convert.ToString(wiInSM[wiClass, "Title"].Value);
            wi.Description        = Convert.ToString(wiInSM[wiClass, "Description"].Value);
            wi.ContactMethod      = Convert.ToString(wiInSM[wiClass, "ContactMethod"].Value);
            wi.DisplayName        = Convert.ToString(wiInSM[wiClass, "DisplayName"].Value);
            wi.ScheduledStartDate = Convert.ToDateTime(wiInSM[wiClass, "ScheduledStartDate"].Value).ToLocalTime();
            wi.ScheduledEndDate   = Convert.ToDateTime(wiInSM[wiClass, "ScheduledEndDate"].Value).ToLocalTime();
            wi.ActualStartDate    = Convert.ToDateTime(wiInSM[wiClass, "ActualStartDate"].Value).ToLocalTime();
            wi.ActualEndDate      = Convert.ToDateTime(wiInSM[wiClass, "ActualEndDate"].Value).ToLocalTime();
            //            wi.LastModified     = Convert.ToDateTime(wiInSM[null, "LastModified"].Value).ToLocalTime();  // doesnt' work - this one is from System.Entity

            return(wi);
        }