/// <sumary> /// </summary> private void actualizaCamposPersonalizados() { using (ProjectCont1) { Guid Id = new Guid("888c9a81-5fce-e911-b081-00155db8343c"); CustomFieldCollection customFields = ProjectCont1.CustomFields; EnterpriseResourceCollection resources = ProjectCont1.EnterpriseResources; ProjectCont1.Load(ProjectCont1.EnterpriseResources.GetByGuid(Id)); ProjectCont1.ExecuteQuery(); var cfInternalName = "Custom_aaf4156c7804e511943500155d569905"; foreach (EnterpriseResource res in resources) { string[] Newval = new string[] { "Entry_333982d27604e511943500155d569905" }; res[cfInternalName] = Newval; } ProjectCont1.EnterpriseResources.Update(); ProjectCont1.ExecuteQuery(); /* * CustomField cfPersonType; * String cfPersonTypeInternalName; * cfPersonType = customFields.First(c => c.Name == "Resource_HR_Person_Type"); * cfPersonTypeInternalName = cfPersonType.InternalName; */ } }
static void getEngagements() { string err = ""; string sql = "exec [MCG_RM_GetPendingUpdates_engagements]"; DataSet ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(sql, cn); da.Fill(ds); resources = projContext.EnterpriseResources; projContext.Load(resources); projContext.ExecuteQuery(); testEngagement(ds); int x = 0; if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow r in ds.Tables[0].Rows) { checkEngagement(r["projectuid"].ToString()); //if (x >= 17) { try { createPWAEngagement(r["projectuid"].ToString(), r["resourceuid"].ToString(), r["start_dt"].ToString(), r["end_dt"].ToString(), Convert.ToDouble(r["pct1"].ToString()), 0, "", ""); } catch (Exception ex) { err += r["projectuid"].ToString() + "|" + r["resourceuid"].ToString() + "|" + ex.Message + ";"; } } x = x + 1; } draftProj.CheckIn(false); QueueJob qJob = projContext.Projects.Update(); JobState jobState = projContext.WaitForQueue(qJob, timeoutSeconds); } //createPWAEngagement("ccb09aba-3b48-e611-80ca-00155d784803", "2faccbc2-7cc0-e511-80e2-00155da47821", "3/8/17", "4/1/17", .5, 0, "project", "_test6"); //mcg dev //createPWAEngagement("7b0d8c9a-1f51-e611-80db-00155dac312b", "897dacfa-afba-e511-80f6-00155da88b1b", "4/3/17", "4/5/17", 0, 0, "resplan", ""); //tina //createPWAEngagement("102c1cf8-15a1-e611-80ce-00155db08b21", "6C8D9F86-775A-E611-80C6-00155DB0931F", "10/1/16", "1/31/17", 0, 0, "resplan", "Team project forecast"); }
// This function shows how to list facts about the MS Project site public void ListContextData() { Console.WriteLine("\nListing context data...\n"); Console.WriteLine("---------------All Projects---------------"); context.Load(context.Projects); context.ExecuteQuery(); foreach (PublishedProject proj in context.Projects) { Console.WriteLine(proj.Name); } Console.WriteLine("---------------All Site Users---------------"); UserCollection siteUsers = context.Web.SiteUsers; context.Load(siteUsers); context.ExecuteQuery(); var peopleManager = new PeopleManager(context); foreach (var user in siteUsers) { try { PersonProperties userProfile = peopleManager.GetPropertiesFor(user.LoginName); context.Load(userProfile); context.ExecuteQuery(); Console.WriteLine(userProfile.DisplayName + " (" + userProfile.Email + ")"); } catch (Exception ex) { Console.WriteLine("Error loading user: "******" --> " + ex.Message); } } Console.WriteLine("---------------All Site User Resources---------------"); EnterpriseResourceCollection resources = context.EnterpriseResources; context.Load(resources); context.ExecuteQuery(); foreach (EnterpriseResource res in resources) { Console.WriteLine(res.Name + " {" + res.Id + "}"); } Console.WriteLine("---------------Custom Fields---------------"); CustomFieldCollection customFields = context.CustomFields; context.Load(customFields); context.ExecuteQuery(); foreach (CustomField cf in customFields) { Console.WriteLine(cf.Name + " {" + cf.Id + "}"); } Console.WriteLine("---------------Lookup Tables---------------"); LookupTableCollection lookupTables = context.LookupTables; context.Load(lookupTables); context.ExecuteQuery(); foreach (LookupTable lt in lookupTables) { Console.WriteLine(lt.Name + " {" + lt.Id + "}"); context.Load(lt.Entries); context.ExecuteQuery(); foreach (LookupEntry entry in lt.Entries) { Console.WriteLine(" " + entry.FullValue + " {" + entry.Id + "}"); } } }