private string getLookupDescription(string fieldName, string lv_id) { try { WebSvcCustomFields.CustomFieldDataSet ds = new WebSvcCustomFields.CustomFieldDataSet(); WebSvcLookupTables.LookupTableDataSet dsLt = new WebSvcLookupTables.LookupTableDataSet(); SPSecurity.RunWithElevatedPrivileges(delegate() { ds = pCf.ReadCustomFieldsByMdPropUids(new Guid[1] { new Guid(fieldName) }, false); dsLt = psiLookupTable.ReadLookupTablesByUids(new Guid[1] { ds.CustomFields[0].MD_LOOKUP_TABLE_UID }, false, 0); }); WebSvcLookupTables.LookupTableDataSet.LookupTableTreesRow[] tr = (WebSvcLookupTables.LookupTableDataSet.LookupTableTreesRow[])dsLt.LookupTableTrees.Select("LT_STRUCT_UID = '" + lv_id + "'"); return(tr[0].LT_VALUE_DESC); } catch (Exception ex) { myLog.WriteEntry("Error Reading Lookup Table for field (" + fieldName + "): " + ex.Message + ex.StackTrace, EventLogEntryType.Error, 330); } return(""); }
public ResourceSyncher(Guid siteId) { siteGuid = siteId; SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite(siteGuid)) { pCf = new WebSvcCustomFields.CustomFields(); pCf.Url = site.Url + "/_vti_bin/psi/customfields.asmx"; pCf.UseDefaultCredentials = true; cfDs = new WebSvcCustomFields.CustomFieldDataSet(); cfDs = pCf.ReadCustomFieldsByEntity(resEntity); psiLookupTable = new WebSvcLookupTables.LookupTable(); psiLookupTable.Url = site.Url + "/_vti_bin/psi/lookuptable.asmx"; psiLookupTable.UseDefaultCredentials = true; pResource = new WebSvcResource.Resource(); pResource.Url = site.Url + "/_vti_bin/psi/resource.asmx"; pResource.UseDefaultCredentials = true; //SPSecurity.RunWithElevatedPrivileges(delegate() //{ cn = new SqlConnection(EPMLiveCore.CoreFunctions.getConnectionString(site.WebApplication.Id)); cn.Open(); //}); } }); }
public bool isCalculated(WebSvcCustomFields.CustomFieldDataSet cfDs, string fieldName) { WebSvcCustomFields.CustomFieldDataSet.CustomFieldsRow[] drCf = (WebSvcCustomFields.CustomFieldDataSet.CustomFieldsRow[])cfDs.CustomFields.Select("MD_PROP_ID=" + fieldName); if (drCf.Length > 0) { if (!drCf[0].IsMD_PROP_FORMULANull() && drCf[0].MD_PROP_FORMULA != "") { return(true); } } return(false); }
private string getSchemaXml(SPField f, string fieldName) { try { XmlDocument doc = new XmlDocument(); doc.LoadXml(f.SchemaXml); //WebSvcCustomFields.CustomFieldDataSet ds = pCf.ReadCustomFieldsByMdPropUids(new Guid[1] { new Guid(fieldName) }, false); WebSvcCustomFields.CustomFieldDataSet dsFields = new WebSvcCustomFields.CustomFieldDataSet(); SPSecurity.RunWithElevatedPrivileges(delegate() { dsFields = pCf.ReadCustomFieldsByEntity(new Guid(PSLibrary.EntityCollection.Entities.TaskEntity.UniqueId)); }); WebSvcCustomFields.CustomFieldDataSet.CustomFieldsRow[] ds = (WebSvcCustomFields.CustomFieldDataSet.CustomFieldsRow[])dsFields.CustomFields.Select("MD_PROP_ID=" + fieldName); if (ds.Length <= 0) { SPSecurity.RunWithElevatedPrivileges(delegate() { dsFields = pCf.ReadCustomFieldsByEntity(new Guid(PSLibrary.EntityCollection.Entities.ProjectEntity.UniqueId)); }); ds = (WebSvcCustomFields.CustomFieldDataSet.CustomFieldsRow[])dsFields.CustomFields.Select("MD_PROP_ID=" + fieldName); } if (ds.Length > 0) { WebSvcLookupTables.LookupTableDataSet dsLt = new WebSvcLookupTables.LookupTableDataSet(); SPSecurity.RunWithElevatedPrivileges(delegate() { dsLt = psiLookupTable.ReadLookupTablesByUids(new Guid[1] { ds[0].MD_LOOKUP_TABLE_UID }, false, 0); }); StringBuilder sbChoices = new StringBuilder(); foreach (WebSvcLookupTables.LookupTableDataSet.LookupTableTreesRow tr in dsLt.LookupTableTrees) { switch ((PSLibrary.PSDataType)ds[0].MD_PROP_TYPE_ENUM) { case PSLibrary.PSDataType.STRING: sbChoices.Append("<CHOICE><![CDATA[" + tr.LT_VALUE_FULL + "]]></CHOICE>"); break; case PSLibrary.PSDataType.NUMBER: sbChoices.Append("<CHOICE>" + float.Parse(tr.LT_VALUE_NUM.ToString()).ToString() + "</CHOICE>"); break; } } string schema = f.SchemaXml; XmlNode ndChoices = doc.SelectSingleNode("//CHOICES"); if (ndChoices != null) { ndChoices.InnerXml = sbChoices.ToString(); } else { XmlNode nd = doc.CreateNode(XmlNodeType.Element, "CHOICES", doc.NamespaceURI); nd.InnerXml = sbChoices.ToString(); XmlElement root = doc.DocumentElement; root.AppendChild(nd); } } return(doc.OuterXml); } catch (Exception ex) { myLog.WriteEntry("Error Processing Lookup Table for field (" + f.Title + "): " + ex.Message + ex.StackTrace, EventLogEntryType.Error, 330); return(f.SchemaXml); } }
private void loadEnterpriseFields() { Guid siteGuid = SPContext.Current.Site.ID; SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = SPContext.Current.Site) { try { WebSvcCustomFields.CustomFields cf = new WebSvcCustomFields.CustomFields(); cf.Url = SPContext.Current.Site.Url + "/_vti_bin/PSI/customfields.asmx"; cf.UseDefaultCredentials = true; WebSvcCustomFields.CustomFieldDataSet dsF = cf.ReadCustomFieldsByEntity(new Guid(PSLibrary.EntityCollection.Entities.TaskEntity.UniqueId)); ddlAssignedToField.Items.Add(new ListItem("[Not Specified]", "")); ddlTimesheet.Items.Add(new ListItem("[Select Field]", "")); ddlTimesheetHours.Items.Add(new ListItem("[Select Field]", "")); foreach (DataRow dr in dsF.Tables[0].Select("MD_PROP_TYPE_ENUM = 21")) { ListItem li = new ListItem(dr["MD_PROP_NAME"].ToString(), dr["MD_PROP_UID"].ToString()); ddlAssignedToField.Items.Add(li); } foreach (DataRow dr in dsF.Tables[0].Select("MD_PROP_TYPE_ENUM = 15")) { ListItem li = new ListItem(dr["MD_PROP_NAME"].ToString(), dr["MD_PROP_ID"].ToString()); ddlTimesheetHours.Items.Add(li); } foreach (DataRow dr in dsF.Tables[0].Select("MD_PROP_TYPE_ENUM = 17")) { ListItem li = new ListItem(dr["MD_PROP_NAME"].ToString(), dr["MD_PROP_UID"].ToString()); ddlTimesheet.Items.Add(li); } ddlTimesheetHours.Items.Add(new ListItem("Actual Work", "251658250")); using (var connection = new SqlConnection(CoreFunctions.getConnectionString(site.WebApplication.Id))) { connection.Open(); using (var command = new SqlCommand("SELECT config_value FROM ECONFIG where config_name='AssignedToField'", connection)) using (var reader = command.ExecuteReader()) { if (reader.Read()) { ddlAssignedToField.SelectedValue = reader.GetString(0); } } using (var command = new SqlCommand("SELECT config_value FROM ECONFIG where config_name='TimesheetField'", connection)) using (var reader = command.ExecuteReader()) { if (reader.Read()) { ddlTimesheet.SelectedValue = reader.GetString(0); } } using (var command = new SqlCommand("SELECT config_value FROM ECONFIG where config_name='TimesheetHoursField'", connection)) using (var reader = command.ExecuteReader()) { if (reader.Read()) { ddlTimesheetHours.SelectedValue = reader.GetString(0); } } using (var command = new SqlCommand("SELECT config_value FROM ECONFIG where config_name='LockSynch'", connection)) using (var reader = command.ExecuteReader()) { if (reader.Read()) { chkLockSynch.Checked = bool.Parse(reader.GetString(0)); } } using (var command = new SqlCommand("SELECT config_value FROM ECONFIG where config_name='ForceWS'", connection)) using (var reader = command.ExecuteReader()) { if (reader.Read()) { chkForceWS.Checked = bool.Parse(reader.GetString(0)); } } using (var command = new SqlCommand("SELECT config_value FROM ECONFIG where config_name='ValidTemplates'", connection)) using (var reader = command.ExecuteReader()) { if (reader.Read()) { loadTemplates(reader.GetString(0)); } else { loadTemplates(string.Empty); } } using (var command = new SqlCommand("SELECT config_value FROM ECONFIG where config_name='CrossSite'", connection)) using (var reader = command.ExecuteReader()) { if (reader.Read()) { chkCrossSite.Checked = bool.Parse(reader.GetString(0)); } } using (var command = new SqlCommand("SELECT config_value FROM ECONFIG where config_name='DefaultURL'", connection)) using (var reader = command.ExecuteReader()) { if (reader.Read()) { txtDefaultURL.Text = reader.GetString(0); } } using (var command = new SqlCommand("SELECT config_value FROM ECONFIG where config_name='ConnectedURLs'", connection)) using (var reader = command.ExecuteReader()) { if (reader.Read()) { txtUrls.Text = reader.GetString(0); } } } lblError.Visible = false; WebSvcEvents.Events events = new EPMLiveEnterprise.WebSvcEvents.Events(); events.Url = SPContext.Current.Site.Url + "/_vti_bin/psi/events.asmx"; events.UseDefaultCredentials = true; WebSvcEvents.EventHandlersDataSet ds = events.ReadEventHandlerAssociations(); if (ds.EventHandlers.Select("EventId = 53 and name = 'EPMLivePublisher'").Length <= 0) { lblProjectPublished.Text = "Not Installed"; } else { lblProjectPublished.Text = "Installed"; } if (ds.EventHandlers.Select("EventId = 133 and name = 'EPMLiveStatusing'").Length <= 0) { lblStatusingApplied.Text = "Not Installed"; } else { lblStatusingApplied.Text = "Installed"; } if (ds.EventHandlers.Select("EventId = 95 and name = 'EPMLiveResUpdated'").Length <= 0) { lblResUpdated.Text = "Not Installed"; } else { lblResUpdated.Text = "Installed"; } if (ds.EventHandlers.Select("EventId = 89 and name = 'EPMLiveResCreated'").Length <= 0) { lblResCreated.Text = "Not Installed"; } else { lblResCreated.Text = "Installed"; } if (ds.EventHandlers.Select("EventId = 92 and name = 'EPMLiveResDeleting'").Length <= 0) { lblResDeleted.Text = "Not Installed"; } else { lblResDeleted.Text = "Installed"; } } catch (Exception ex) { if (ex.Message.Contains("401")) { lblError.Text = "Error: 401 Unauthorized<br>This usually means the service account that is current running your SharePoint Application Pool does not have access to the Project Server Site."; lblError.Visible = true; } else { Response.Write("Error: " + ex.Message + "<br>Current User: " + HttpContext.Current.User.Identity.Name); } } } }); }