private string getLookupValue(DataRow drField)
        {
            WebSvcCustomFields.CustomFieldDataSet.CustomFieldsRow[] dr = (WebSvcCustomFields.CustomFieldDataSet.CustomFieldsRow[])cfDs.CustomFields.Select("MD_PROP_ID=" + drField["MD_PROP_ID"].ToString());

            if (dr.Length > 0)
            {
                string tableuid = dr[0]["MD_LOOKUP_TABLE_UID"].ToString();

                WebSvcLookupTables.LookupTableDataSet dsLt = psiLookupTable.ReadLookupTablesByUids(new Guid[1] {
                    new Guid(tableuid)
                }, false, 0);

                WebSvcLookupTables.LookupTableDataSet.LookupTableTreesRow[] tr = (WebSvcLookupTables.LookupTableDataSet.LookupTableTreesRow[])dsLt.LookupTableTrees.Select("LT_STRUCT_UID = '" + drField["CODE_VALUE"] + "'");

                switch ((PSLibrary.PSDataType)dr[0].MD_PROP_TYPE_ENUM)
                {
                case PSLibrary.PSDataType.STRING:
                    return(tr[0].LT_VALUE_TEXT);

                case PSLibrary.PSDataType.COST:
                    return((tr[0].LT_VALUE_NUM / 100).ToString());

                case PSLibrary.PSDataType.NUMBER:
                    return(tr[0].LT_VALUE_NUM.ToString());
                }
            }

            return("");
        }
Exemple #2
0
        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);
            }
        }