Beispiel #1
0
        private void BuildFieldList(XmlNode record, DataTable metaTable)
        {
            XmlAttribute fieldLabelAttribute = xDoc.CreateAttribute("fieldLabel");
            XmlNodeList  listOfFields        = GetTableFields(record);

            foreach (XmlNode fieldNode in listOfFields)
            {
                string       fieldName      = fieldNode.Name;
                string       fieldMetaName  = CICHelper.GetFieldAttributeValue(metaTable, fieldName, "FieldLabel");
                XmlAttribute fieldAttribute = fieldLabelAttribute.Clone() as XmlAttribute;
                fieldAttribute.Value = fieldMetaName;
                fieldNode.Attributes.Append(fieldAttribute);
            }
        }
Beispiel #2
0
        private void FleshOutProxy(XmlNode currentNode, XmlDocument dom)
        {
            string  sTarget = XmlUtils.GetAttributeValue(currentNode, "target");
            XmlNode xn      = dom.SelectSingleNode("//item[@id='" + sTarget + "']");

            if (xn != null)
            {
                XmlAttribute idAttr = dom.CreateAttribute("id");
                idAttr.Value = sTarget;
                idAttr.Value = sTarget;
                currentNode.Attributes.Append(idAttr);
                var guidAttr = (XmlAttribute)xn.SelectSingleNode("@guid");
                Debug.Assert(guidAttr != null, "guid is a required attribute for items with ids");
                currentNode.Attributes.Append((XmlAttribute)guidAttr.Clone());
                XmlAttribute typeAttr = (XmlAttribute)xn.SelectSingleNode("@type");
                if (typeAttr != null)
                {
                    currentNode.Attributes.Append((XmlAttribute)typeAttr.Clone());
                }
                // replace any abbrev, term or def items from target and add any citations in target
                string[] asNodes = new string[3] {
                    "abbrev", "term", "def"
                };
                for (int i = 0; i < 3; i++)
                {
                    XmlNode newTempNode = xn.SelectSingleNode(asNodes[i]);
                    XmlNode oldNode     = currentNode.SelectSingleNode(asNodes[i]);
                    if (newTempNode != null)
                    {
                        if (oldNode != null)
                        {
                            currentNode.ReplaceChild(newTempNode.Clone(), oldNode);
                        }
                        else
                        {
                            currentNode.AppendChild(newTempNode.Clone());
                        }
                    }
                }
                XmlNodeList citationNodes = xn.SelectNodes("citation");
                foreach (XmlNode citation in citationNodes)
                {
                    currentNode.AppendChild(citation.Clone());
                }
            }
        }
Beispiel #3
0
        private void RecursivelyFillTables(XmlNode parentNode, XmlNodeList distinctTableNodes)
        {
            // Look through each distinct table names
            foreach (XmlNode table in distinctTableNodes)
            {
                // db/xml table name
                string tableName = table.Name;
                // meta data table name/label
                string metaDataTableName = GetTableLabelByTableName(tableName);

                // Get mata data table for Table's fields
                DataTable fieldsMetaTable = da.GetFieldMetadataByTableName(tableName);

                // Get a complete list of tables named by tableName
                XmlNodeList listOfTableRecords = parentNode.SelectNodes(tableName);

                // Create Table Label Attribute
                XmlAttribute tableLabelAttribute = xDoc.CreateAttribute("tableLabel");
                tableLabelAttribute.Value = string.Empty;

                bool tableNameSet = false;
                foreach (XmlNode record in listOfTableRecords)
                {
                    // Check if a table has data (i.e., if any field has data)
                    // If table contains fields with data, then the table has data
                    if (TableHasFieldsWithData(record))
                    {
                        // Set TableLable attribute for this record, as it has data
                        XmlAttribute clonedTableLabelAttribute = tableLabelAttribute.Clone() as XmlAttribute;
                        if (!tableNameSet)
                        {
                            clonedTableLabelAttribute.Value = metaDataTableName;
                            tableNameSet = true;
                        }
                        record.Attributes.Append(clonedTableLabelAttribute);

                        // Get a list of Fields for a Table
                        XmlNodeList tableFields = GetTableFields(record);

                        XmlAttribute hasDataAttribute = xDoc.CreateAttribute("hasData");
                        hasDataAttribute.Value = Boolean.TrueString.ToLower();
                        record.Attributes.Append(hasDataAttribute);


                        this.BuildFieldList(record, fieldsMetaTable);

                        XmlNodeList distinctChildTables = GetDistinctChildTables(record);
                        if (distinctChildTables.Count > 0)
                        {
                            RecursivelyFillTables(record, distinctChildTables);
                        }
                    }
                    else
                    {
                        if (!tablesWithoutRecords.Contains(tableName))
                        {
                            tablesWithoutRecords.Add(tableName);
                            XmlAttribute a = xDoc.CreateAttribute("noData");
                            a.Value = string.Empty;
                            record.Attributes.Append(a);
                        }
                    }
                }
            }
        }
Beispiel #4
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            // 01/11/2006 Paul.  Only a developer/administrator should see this.
            if (!SplendidCRM.Security.IS_ADMIN || Request.ServerVariables["SERVER_NAME"] != "localhost")
            {
                return;
            }
            Response.Buffer          = false;
            Response.ExpiresAbsolute = new DateTime(1980, 1, 1, 0, 0, 0, 0);
            Response.Write("<html><body><pre>\r\n");

            using (SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["SplendidSQLServer"]))
            {
                string strSpecifiedLang = Request["Lang"];
                con.Open();
                using (SqlCommand cmd = new SqlCommand("select distinct Lang from TERMINOLOGY order by Lang", con))
                {
                    using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                    {
                        using (DataTable dt = new DataTable())
                        {
                            da.Fill(dt);
                            for (int i = 0; i < dt.Rows.Count && Response.IsClientConnected; i++)
                            {
                                string sLANG = Sql.ToString(dt.Rows[i]["Lang"]);
                                Response.Write(sLANG + "\r\n");

                                /* the following language packs have errors.
                                 * cn-ZH
                                 * dk
                                 * ge-CH
                                 * ge-GE
                                 * se
                                 * sp-CO
                                 * sp-VE
                                 * tw-ZH
                                 */
                                if (strSpecifiedLang == null || sLANG == strSpecifiedLang)
                                {
                                    string sSQL;
                                    sSQL = "select *                     " + ControlChars.CrLf
                                           + "  from TERMINOLOGY           " + ControlChars.CrLf
                                           + " where LANG = '" + sLANG + "'" + ControlChars.CrLf
                                           + "   and LIST_NAME is null     " + ControlChars.CrLf
                                           + " order by NAME               " + ControlChars.CrLf;
                                    cmd.CommandText = sSQL;
                                    using (DataTable dtLang = new DataTable())
                                    {
                                        da.Fill(dtLang);
                                        XmlDocument docClean = new XmlDocument();

                                        docClean.Load(Server.MapPath(".") + "\\Resources\\Resource-clean.resx");
                                        for (int j = 0; j < dtLang.Rows.Count && Response.IsClientConnected; j++)
                                        {
                                            //Response.Write(dtLang.Rows[j]["LANG"].ToString() + " " + dtLang.Rows[j]["NAME"].ToString() + "\r\n");
                                            XmlElement   elmData = docClean.CreateElement("data");
                                            XmlAttribute attName = (XmlAttribute)docClean.CreateNode(XmlNodeType.Attribute, "name", "");
                                            attName.Value = dtLang.Rows[j]["NAME"].ToString();
                                            elmData.Attributes.Append(attName);
                                            XmlElement   elmValue    = docClean.CreateElement("value");
                                            XmlElement   elmComment  = docClean.CreateElement("comment");
                                            XmlAttribute attPreserve = (XmlAttribute)docClean.CreateNode(XmlNodeType.Attribute, "space", "xml");
                                            attPreserve.Value = "preserve";
                                            elmValue.Attributes.Append(attPreserve);
                                            elmComment.Attributes.Append((XmlAttribute)attPreserve.Clone());
                                            docClean.DocumentElement.AppendChild(elmData);
                                            elmData.AppendChild(elmValue);
                                            elmData.AppendChild(elmComment);
                                            elmValue.InnerText   = dtLang.Rows[j]["DISPLAY_NAME"].ToString();
                                            elmComment.InnerText = dtLang.Rows[j]["MODULE_NAME"].ToString();
                                        }
                                        if (dt.Rows[i]["Lang"].ToString() == "en-US")
                                        {
                                            docClean.Save(Server.MapPath(".") + "\\Resources\\Resource.resx");
                                        }
                                        else
                                        {
                                            docClean.Save(Server.MapPath(".") + "\\Resources\\Resource." + dt.Rows[i]["Lang"].ToString() + ".resx");
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            Response.Write("</pre></body></html>\r\n");
        }