Exemplo n.º 1
0
 public static DataTable XmlToDataTable(string parentnode, SchemaInfo info, XmlNode node)
 {
     try
     {
         if (node == null || !node.HasChildNodes)
         {
             return(null);
         }
         if (!string.IsNullOrEmpty(info.CData))
         {
             string strresult = GetNodeTextValue(info.CData, node);
             node = XmlHelper.RemoveNameSpace(strresult, info.RemoveNs);
         }
         DataTable dt     = info.ToDt();
         string[]  pnodes = parentnode.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
         ForeachToTable(0, pnodes, node, dt, info);
         Tools.RemoveEmpty(dt);
         return(dt);
     }
     catch (Exception ex)
     {
         Log4netUtil.Error(ex.Message, ex);
         return(null);
     }
 }
Exemplo n.º 2
0
        public override void SetTmpTableSchema()
        {
            DataTable dt = new DataTable();

            if (this.sourcetype == 0)
            {
                if (this.nodelx == 0)
                {
                    dt = ((RunInterface)this.TaskStarter.CreateInstance(this)).GetTmpTable();
                    Tools.FlushMemory();
                }
                else if (this.nodelx == 1)
                {
                    SchemaInfo info = JsonConvert.DeserializeObject <SchemaInfo>(this.xmlconfig);
                    if (info == null)
                    {
                        return;
                    }
                    dt = info.ToDt();
                }
            }
            else if (this.sourcetype == 1)
            {
                dt = GlobalInstanceManager <GlobalSqlManager> .Intance.GetDataTable(this.sourcedbtype, this.sourcedbstring, this.sourcesql);
            }
            if (dt != null)
            {
                string strtmp = "create table " + this.tmpname + Environment.NewLine + "(" + Environment.NewLine;
                foreach (DataColumn dc in dt.Columns)
                {
                    strtmp += "   " + dc.ColumnName + "   varchar(256) null," + Environment.NewLine;
                }
                strtmp         = strtmp.Remove(strtmp.LastIndexOf(','), 1);
                strtmp        += ")";
                this.createtmp = strtmp;
            }
        }