public static string GetInspectionText(ExportField export, Type type, object oRef, EFieldSerializationType serType, SerializedProperty inspectedElement)
 {
     if (serType == EFieldSerializationType.ToArray)
     {
         object elementObj = null;
         var    id         = inspectedElement.intValue;
         if (oRef is IHashedSOCollection hcol)
         {
             elementObj = hcol.GetElementBase(id);
         }
         else if (oRef is System.Collections.IList list)
         {
             elementObj = list[id];
         }
         else if (oRef is System.Array array)
         {
             elementObj = array.GetValue(id);
         }
         if (elementObj != null)
         {
             var SB = export.SB;
             SB.Clear();
             SB.Append($"{export.FieldName}[{id}]: ");
             export.AppendFields(elementObj, export.CheckIfIsDirectValue());
             var str = SB.ToString().FormatAsJson("    ");
             SB.Clear();
             return(str);
         }
         return("null");
     }
     return(ExportFieldUtility.GetFieldDefinition(oRef, type, export).FormatAsJson("    "));
 }
Beispiel #2
0
 public void SetData(ExportField f)
 {
     _definition = f;
 }
Beispiel #3
0
        public static int UpdateDB(List <ExportObject> Rows, String cRootDir)
        {
            List <String> sqls = new List <string>();
            StringBuilder sql  = new StringBuilder();

            for (int i = 0; i < Rows.Count; i++)
            {
                ExportObject       vo          = Rows[i];
                String             cTABLE_ID   = vo.TABLE_ID;
                String             cTableName  = DbManager.GetStrValue("SELECT TABLE_NAME FROM S_ETL_TABLE WHERE TABLE_ID='" + cTABLE_ID + "'");
                DataTable          dtFieldList = DbManager.QueryData("SELECT FIELD_NAME,ISKEY FROM S_ETL_FIELD WHERE TABLE_ID='" + cTABLE_ID + "'");
                String             cSYS_ID     = vo.SYS_ID;
                List <ExportField> FieldList   = vo.rows.FieldList;
                List <ExportFile>  FileList    = vo.rows.FileList;
                sql.Clear();

                List <String> KeyField   = new List <string>();
                String        cWhereParm = null;
                String        cFieldList = null;
                String        cValueList = null;

                for (int j = 0; j < FieldList.Count; j++)
                {
                    ExportField vf          = FieldList[j];
                    String      cFieldName  = vf.FieldName;
                    String      cFieldValue = vf.FieldValue;
                    if (cFieldValue.Length > 0)
                    {
                        cFieldValue = Base64.Base64ToStr(cFieldValue);
                    }
                    DataRow[] drs = dtFieldList.Select("FIELD_NAME='" + cFieldName + "'");
                    if (String.IsNullOrEmpty(cFieldValue))
                    {
                        cFieldValue = "null";
                    }
                    else
                    {
                        cFieldValue = "'" + cFieldValue + "'";
                    }
                    if (cFieldList == null)
                    {
                        cFieldList = cFieldName;
                        cValueList = cFieldValue;
                    }
                    else
                    {
                        cFieldList = cFieldList + "," + cFieldName;
                        cValueList = cValueList + "," + cFieldValue;
                    }

                    if ((drs != null) && (drs.Length > 0))
                    {
                        int isKey = StringEx.getInt(drs[0]["iskey"]);
                        if (isKey > 0)
                        {
                            KeyField.Add(cFieldName);
                            if (cWhereParm == null)
                            {
                                cWhereParm = " (" + cFieldName + "=" + cFieldValue + ")";
                            }
                            else
                            {
                                cWhereParm = cWhereParm + " AND (" + cFieldName + "=" + cFieldValue + "') ";
                            }
                        }
                    }
                }
                sqls.Add(" DELETE FROM " + cTableName + " WHERE " + cWhereParm);
                sql.Append(" INSERT INTO " + cTableName + "(" + cFieldList + ") VALUES(" + cValueList + ")");

                for (int j = 0; j < FileList.Count; j++)
                {
                    sql.Clear();
                    ExportFile vf        = FileList[j];
                    String     cFileName = cRootDir + vf.Url.Replace("/", "\\");
                    bool       isSaved   = Base64.SaveBase64File(cFileName, vf.Data);
                    if (isSaved)
                    {
                        sqls.Add("DELETE FROM S_UPLOAD WHERE ID='" + vf.ID + "'");
                        sqls.Add(" INSERT INTO S_UPLOAD(ID,TEX,URL) VALUES('" + vf.ID + "','" + vf.Text + "','" + vf.Url + "')");
                    }
                }

                sqls.Add(sql.ToString());
            }
            return(DbManager.ExecSQL(sqls));
        }
Beispiel #4
0
        private List <ExportField> GetFields(XmlElement element, string currentDisplay, string currentXPath, string requestName, int currentRecordIndex)
        {
            List <ExportField> fields       = new List <ExportField>();
            string             m_name       = element.GetAttribute("Name");
            string             m_display    = element.GetAttribute("DisplayText");
            string             appendString = "";

            if (!currentDisplay.EndsWith(":") && currentDisplay != "")
            {
                appendString = ":";
            }

            m_display = currentDisplay + appendString + m_display;
            if (element.SelectNodes("Field").Count == 0)
            {
                int i = 1;
                foreach (XmlElement childElement in element.SelectNodes("Element"))
                {
                    List <ExportField> childFields = GetFields(childElement, m_display, currentXPath + "/" + m_name + "[" + currentRecordIndex + "]", requestName, i);
                    foreach (ExportField cf in childFields)
                    {
                        fields.Add(cf);
                    }
                }
            }


            foreach (XmlElement fieldNode in element.SelectNodes("Field"))
            {
                XmlElement  fieldElement = (XmlElement)fieldNode;
                ExportField field        = new ExportField();

                string fieldDisplay = fieldElement.GetAttribute("DisplayText");
                string converter    = fieldElement.GetAttribute("Converter");
                string dataType     = fieldElement.GetAttribute("DataType");

                string astring = "";
                if (!m_display.EndsWith(":") && m_display != "")
                {
                    astring = ":";
                }

                string display = m_display + astring + fieldDisplay;
                field.DisplayText = display;

                string fieldName      = fieldElement.GetAttribute("Name");
                int    fieldNameCount = 1;
                foreach (ExportField f in fields)
                {
                    if (f.FieldName == fieldName)
                    {
                        fieldNameCount++;
                    }
                }
                string xpath = currentXPath + "/" + m_name + "[" + currentRecordIndex + "]/" + fieldName + "[" + fieldNameCount + "]";
                field.XPath = xpath;

                field.FieldName   = fieldName;
                field.RequestName = requestName;
                field.Converter   = converter;
                field.DataType    = dataType;

                fields.Add(field);
            }
            return(fields);
        }
Beispiel #5
0
        public ExportFieldCollection Format(XmlElement source)
        {
            ExportFieldCollection _collection = new ExportFieldCollection();

            foreach (XmlNode node in source.ChildNodes)
            {
                if (node.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                XmlElement element = (XmlElement)node;
                if (element.Name == "Field")
                {
                    string name        = element.GetAttribute("Name");
                    string displaytext = element.GetAttribute("DisplayText");
                    string converter   = element.GetAttribute("Converter");
                    string dataType    = element.GetAttribute("DataType");

                    ExportField field = new ExportField();
                    field.FieldName   = name;
                    field.DisplayText = displaytext;
                    field.XPath       = name;
                    field.RequestName = name;
                    field.Converter   = converter;
                    field.DataType    = dataType;

                    _collection.Add(field);
                }
                else if (element.Name == "XmlField")
                {
                    XmlNode baseNode = element.SelectSingleNode("Element");
                    if (baseNode == null)
                    {
                        continue;
                    }

                    string name = element.GetAttribute("Name");
                    //string displaytext = element.GetAttribute("DisplayText");

                    //ExportField field = new ExportField();
                    //field.FieldName = name;
                    //field.DisplayText = displaytext;
                    XmlElement         baseElement = (XmlElement)baseNode;
                    List <ExportField> fields      = GetFields(baseElement, "", name, name, 1);
                    foreach (ExportField f in fields)
                    {
                        _collection.Add(f);
                    }
                    //foreach (XmlNode recNode in baseElement.SelectNodes("Element"))
                    //{
                    //    XmlElement recElement = (XmlElement)recNode;

                    //    int recIndex = 1;
                    //    foreach (XmlElement fieldNode in recElement.SelectNodes("Field"))
                    //    {
                    //        XmlElement fieldElement = (XmlElement)fieldNode;
                    //        ExportField field = new ExportField();
                    //        string baseDisplay = baseElement.GetAttribute("DisplayText");
                    //        string recDisplay = recElement.GetAttribute("DisplayText");
                    //        string fieldDisplay = fieldElement.GetAttribute("DisplayText");
                    //        string display = baseDisplay + ":" + recDisplay + (string.IsNullOrEmpty(recDisplay) ? "" : ":") + fieldDisplay;
                    //        field.DisplayText = display;

                    //        string baseName = baseElement.GetAttribute("Name");
                    //        string recName = recElement.GetAttribute("Name");
                    //        string fieldName = fieldElement.GetAttribute("Name");
                    //        string xpath = baseName + "/" + recName + "[" + recIndex + "]/" + fieldName;
                    //        field.XPath = xpath;

                    //        field.FieldName = element.GetAttribute("Name");
                    //        recIndex++;
                    //    }
                    //}
                }
            }
            return(_collection);
        }