Esempio n. 1
0
        private void LoadXML()
        {
            if (m_xmlDoc != null)
            {
                return;
            }

            XmlDocument xmlDoc = new XmlDocument();
            IsxDocument doc = new sxDocument(m_document);
            xmlDoc.LoadXml(doc.StringContent);

            m_xmlDoc = new XmlDocument();
            m_xmlDoc.LoadXml(xmlDoc.FirstChild.OuterXml.Replace("xmlns", "sxns"));
 
            // Get the instructions
            XmlNode instructionList = m_xmlDoc.SelectSingleNode("//instructions");

            foreach (XmlNode instruction in instructionList.SelectNodes("instruction"))
            {
                string name = instruction.SelectSingleNode("name").InnerText;
                string value = instruction.SelectSingleNode("value").InnerText;

                switch (name.ToLower())
                {
                    case "selectfolder":
                        m_browse = (value == "1");
                        break;
                    case "setproperties":
                        m_displayProps = (value == "1");
                        break;
                    case "constrainfolder":
                        m_constrainFolder = (value == "1");
                        break;
                    case "useforcheckin":
                        m_useForCheckin = (value == "1");
                        break;
                }
            }

            // Get the major/minor version
            XmlNode versionNode = m_xmlDoc.SelectSingleNode("//version");
            m_majorVersion = (versionNode.SelectSingleNode("value").InnerText == "0");
            m_versionReadOnly = (versionNode.SelectSingleNode("isreadonly").InnerText == "1");


            // Get the folder if it exists
            XmlNode xmlFolder = m_xmlDoc.SelectSingleNode("//folder");
            if (xmlFolder == null)
            {
                m_folder = null;
            }
            else
            {
                string fldID = xmlFolder.SelectSingleNode("id").InnerText;

                if (fldID == "")
                {
                    m_folder = null;
                }
                else
                {
                    IFolder fld = Factory.Folder.FetchInstance(sxAPI.ObjectStore, new Id(fldID), null);
                    m_folder = new sxFolder(fld);
                }
            }

            // Get the Class Desc if it exists
            XmlNode xmlDocClass = m_xmlDoc.SelectSingleNode("//classdesc");
            if (xmlDocClass == null)
            {
                m_docClass = null;
            }
            else
            {
                string dcID = xmlDocClass.SelectSingleNode("id").InnerText;

                IClassDefinition cd = Factory.ClassDefinition.FetchInstance(sxAPI.ObjectStore, dcID, null);
                m_docClass = new sxDocClass(cd);
            }

            // Get the property Descriptions
            m_props = new Dictionary<string, IsxProperty>();

            XmlNode propList = m_xmlDoc.SelectSingleNode("//propdescs");

            foreach (XmlNode xmlProp in propList.SelectNodes("propdesc"))
            {
                IsxProperty prop = new sxProperty(m_docClass, xmlProp);


                if (prop.PropertyDefinition != null)
                {
                    m_props.Add(prop.Name, prop);
                }
            }
        }
Esempio n. 2
0
        private void LoadJSON()
        {
            if (m_jsonDoc != null)
            {
                return;
            }

            IsxDocument doc = new sxDocument(m_document);
            m_jsonDoc = JObject.Parse(doc.StringContent);

            m_browse = false;
            m_constrainFolder = (bool)((JValue)m_jsonDoc["restrictToSelectedFolderOrDescendant"]).Value;
            m_displayProps = (bool)((JValue)m_jsonDoc["allowUserSetPropertyValues"]).Value;
            m_useForCheckin = true;
            m_majorVersion = true;
            m_versionReadOnly = false;
    
            // Get the folder if it exists
            JValue jsonFolder = (JValue)m_jsonDoc["folder"];
            if (jsonFolder == null)
            {
                m_folder = null;
            }
            else
            {
                string fldID = jsonFolder.Value.ToString().Split(",".ToCharArray())[2];
                if (fldID == "")
                {
                    m_folder = null;
                }
                else
                {
                    IFolder fld = Factory.Folder.FetchInstance(sxAPI.ObjectStore, new Id(fldID), null);
                    m_folder = new sxFolder(fld);
                }
            }

            // Get the Class Desc if it exists
            JValue jsonDocClass = (JValue)m_jsonDoc["addClassName"];
            if (jsonDocClass == null)
            {
                m_docClass = null;
            }
            else
            {
                string dcID = jsonDocClass.Value.ToString();

                IClassDefinition cd = Factory.ClassDefinition.FetchInstance(sxAPI.ObjectStore, dcID, null);
                m_docClass = new sxDocClass(cd);
            }

            // Get the property Descriptions
            m_props = new Dictionary<string, IsxProperty>();
            JArray propList = (JArray)m_jsonDoc["propertiesOptions"];

            foreach (JObject jo in propList)
            {
                string symName = ((JValue)jo["id"]).Value.ToString();
                IsxProperty prop = new sxProperty(m_docClass, symName);

                if (prop.PropertyDefinition != null)
                {
                    m_props.Add(prop.Name, prop);
                }
            }
        }