Example #1
0
        public SpecificObjectStructure(XmlElement xml, string objtype)
            : base(xml)
        {
            this.LoadPropertiesCore(xml);
            ObjectType   = objtype;
            SpecificData = XmlTool.LoadParameters(xml);
            ObjectName   = NameWithSchema.LoadFromXml(xml);
            RelatedTable = NameWithSchema.LoadFromXml(xml, "relschema", "reltable");
            var deps = xml.FindElement("DependsOn");

            if (deps != null)
            {
                DependsOn = new List <DependencyItem>();
                foreach (XmlElement child in deps)
                {
                    var repr = SpecificRepresentationAddonType.Instance.FindByElement(child.Name);
                    DependsOn.Add(new DependencyItem {
                        Name = NameWithSchema.LoadFromXml(child), ObjectType = repr.ObjectType
                    });
                }
            }
        }
Example #2
0
 public DbDriverManager()
 {
     try
     {
         m_customDrivers = (DbDriverSet)XmlTool.DeserializeObject(Path.Combine(Core.ConfigDirectory, "drivers.xml"));
     }
     catch (Exception)
     {
         m_customDrivers = new DbDriverSet();
     }
     try
     {
         m_systemDrivers = (DbDriverSet)XmlTool.DeserializeObject(Path.Combine(Core.LibDirectory, "drivers.xml"));
     }
     catch (Exception)
     {
         m_systemDrivers = new DbDriverSet();
     }
     foreach (DbDriverDefinition drv in m_systemDrivers.Drivers)
     {
         drv.IsSystem = true;
     }
 }
Example #3
0
 private void SaveToXml(XmlElement xml, bool oldStyle)
 {
     SaveBase(xml);
     if (FullName != null)
     {
         FullName.SaveToXml(xml);
     }
     foreach (ColumnStructure col in Columns)
     {
         XmlElement cx = XmlTool.AddChild(xml, "Column");
         col.Save(cx);
     }
     if (oldStyle)
     {
         foreach (DatAdmin.Constraint cnt in Constraints)
         {
             cnt.Save(xml);
         }
     }
     else
     {
         foreach (DatAdmin.Constraint cnt in Constraints)
         {
             XmlElement cx = XmlTool.AddChild(xml, "Constraint");
             cnt.SaveToXml(cx);
         }
     }
     XmlTool.SaveParameters(xml, SpecificData);
     if (!String.IsNullOrEmpty(Comment))
     {
         xml.AddChild("Comment").InnerText = Comment;
     }
     if (FixedData != null)
     {
         FixedData.SaveToXml(xml.AddChild("FixedData"));
     }
 }
Example #4
0
 public override string ToString()
 {
     return(XmlTool.GetRegisterAttr(this).Title);
 }
Example #5
0
 public virtual string GetPersistString()
 {
     return(XmlTool.GetRegisterAttr(this).Name);
 }
Example #6
0
 public void SaveCustom()
 {
     XmlTool.SerializeObject(Path.Combine(Core.ConfigDirectory, "drivers.xml"), m_customDrivers);
 }
Example #7
0
 public void Clear()
 {
     m_doc = XmlTool.CreateDocument("Design");
 }
Example #8
0
 public ColumnReference(XmlElement xml)
 {
     this.LoadPropertiesCore(xml);
     SpecificData = XmlTool.LoadParameters(xml);
 }
Example #9
0
 public CollationStructure(XmlElement xml)
     : base(xml)
 {
     this.LoadPropertiesCore(xml);
     SpecificData = XmlTool.LoadParameters(xml);
 }
Example #10
0
 public override void SaveToXml(XmlElement xml)
 {
     base.SaveToXml(xml);
     xml.SetAttribute("type", XmlTool.GetRegisterType(this));
 }
Example #11
0
        public static DataTable ReadXmlToQueue(XmlReader reader, IDataQueue queue, string tableTagName)
        {
            try
            {
                reader.MoveToContent();
                reader.Read();
                reader.MoveToContent();

                DataTable structTable = null;
                if (reader.LocalName != tableTagName)
                {
                    structTable = new DataTable();
                    structTable.ReadXmlSchema(reader);
                }

                Dictionary <string, int> colPos = new Dictionary <string, int>();
                ITableStructure          rowFormat;
                if (structTable != null)
                {
                    foreach (DataColumn col in structTable.Columns)
                    {
                        colPos[XmlTool.NormalizeIdentifier(col.ColumnName)] = col.Ordinal;
                    }
                    rowFormat = structTable.Columns.GetTableStructure(null);
                }
                else
                {
                    rowFormat = queue.PutRowFormat;
                    int index = 0;
                    foreach (var col in rowFormat.Columns)
                    {
                        colPos[XmlTool.NormalizeIdentifier(col.ColumnName)] = index;
                        index++;
                    }
                }
                while (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.LocalName != tableTagName)
                    {
                        throw new XmlFormatError(String.Format("DAE-00301 Bad xml, expected tag {0}, found {1}", tableTagName, reader.LocalName));
                    }
                    reader.Read();
                    reader.MoveToContent();
                    object[] values = new object[rowFormat.Columns.Count];
                    for (int i = 0; i < values.Length; i++)
                    {
                        values[i] = DBNull.Value;
                    }
                    while (reader.NodeType == XmlNodeType.Element)
                    {
                        string colname = reader.LocalName;
                        int    pos     = colPos[colname];
                        bool   wasdata = false;

                        Type dataType = structTable != null ? structTable.Columns[pos].DataType : rowFormat.Columns[pos].DataType.DotNetType;
                        reader.Read();
                        if (reader.NodeType == XmlNodeType.Text)
                        {
                            string data = reader.Value;
                            values[pos] = XmlTool.StringToObject_DataXml(dataType, data);
                            reader.Read();
                            wasdata = true;
                        }
                        if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == colname)
                        { // skip end of element
                            reader.Read();
                        }
                        else
                        {
                            // error, do not throw, it is error if .NET parser
                        }
                        //if (reader.NodeType != XmlNodeType.EndElement) throw new XmlFormatError("Bad XML, expected end of tag");
                        //if (reader.LocalName != colname) throw new XmlFormatError(String.Format("Bad xml, expected tag {0}, found {1}", colname, reader.LocalName));
                        //reader.Read();

                        if (!wasdata)
                        {
                            values[pos] = XmlTool.StringToObject_DataXml(dataType, "");
                        }
                    }
                    queue.PutRecord(new ArrayDataRecord(rowFormat, values));
                    if (reader.NodeType == XmlNodeType.EndElement)
                    {
                        reader.Read();
                    }
                }
                return(structTable);
            }
            finally
            {
                queue.PutEof();
            }
        }
Example #12
0
 protected virtual void LoadFromXml(XmlElement xml)
 {
     XmlTool.LoadProperties(this, xml);
     XmlTool.LoadSpecificAttributes(SpecificData, "typespec.", xml);
     //if (xml.HasAttribute("array")) ArraySpec = new ArrayDimensions(xml.GetAttribute("array"));
 }
Example #13
0
        protected override void DoRead(IDataQueue queue)
        {
            try
            {
                TableStructure s = CreateStructure();

                Dictionary <string, int> colPos = new Dictionary <string, int>();
                for (int i = 0; i < m_columnNames.Count; i++)
                {
                    colPos[m_columnNames[i]] = i;
                    colPos[XmlTool.NormalizeIdentifier(m_columnNames[i])] = i;
                }

                using (XmlReader xr = new XmlTextReader(GetWorkingFileName()))
                {
                    xr.MoveToContent();
                    if (xr.Name != m_rootElementName)
                    {
                        Logging.Warning("Root element has different name");
                    }
                    xr.Read();
                    while (xr.NodeType == XmlNodeType.Element)
                    {
                        // process one row

                        object[] values = new object[m_columnNames.Count];
                        for (int i = 0; i < values.Length; i++)
                        {
                            values[i] = DBNull.Value;
                        }


                        if (xr.Name == m_rowElementName)
                        {
                            switch (m_storageType)
                            {
                            case XmlDataStorageType.Attribute:
                                for (int i = 0; i < xr.AttributeCount; i++)
                                {
                                    xr.MoveToAttribute(i);
                                    string name = xr.Name;
                                    if (colPos.ContainsKey(name))
                                    {
                                        values[colPos[name]] = xr.Value;
                                    }
                                }
                                xr.MoveToElement();
                                xr.Read();
                                break;

                            case XmlDataStorageType.ColumnNamedElement:
                                xr.Read();
                                xr.MoveToContent();
                                while (xr.NodeType == XmlNodeType.Element)
                                {
                                    string name  = xr.Name;
                                    string value = xr.ReadElementContentAs(typeof(string), null).ToString();
                                    if (colPos.ContainsKey(name))
                                    {
                                        values[colPos[name]] = value;
                                    }
                                }
                                xr.MoveToContent();
                                if (xr.NodeType == XmlNodeType.EndElement)
                                {
                                    xr.Read();
                                }
                                break;

                            case XmlDataStorageType.InvariantNamedElement:
                                xr.Read();
                                xr.MoveToContent();
                                while (xr.NodeType == XmlNodeType.Element)
                                {
                                    string name  = xr.GetAttribute(m_columnAttributeName);
                                    string value = xr.ReadElementContentAs(typeof(string), null).ToString();
                                    if (colPos.ContainsKey(name))
                                    {
                                        values[colPos[name]] = value;
                                    }
                                }
                                xr.MoveToContent();
                                if (xr.NodeType == XmlNodeType.EndElement)
                                {
                                    xr.Read();
                                }
                                break;
                            }
                        }
                        else
                        {
                            xr.Skip();
                        }

                        queue.PutRecord(new ArrayDataRecord(s, values));
                    }
                }
            }
            finally
            {
                queue.PutEof();
            }
            FinalizeBulkCopy();
        }
Example #14
0
 public virtual string GetPersistString()
 {
     return(XmlTool.GetRegisterType(this));
 }
Example #15
0
 internal void LoadLayoutFromPanel(DockPanelContentFrame frame)
 {
     m_layout = XmlTool.CreateDocument("Layout");
     frame.SaveLayout(m_layout.DocumentElement);
 }
Example #16
0
 public void Save(XmlElement xml)
 {
     this.SavePropertiesCore(xml);
     XmlTool.SaveParameters(xml, SpecificData);
 }
Example #17
0
        private static void DoSendError(Exception error, List <LogMessageRecord> logHistory, Bitmap screenshot)
        {
            try
            {
                var            desc = ApiDescriptor.GetInstance();
                HttpWebRequest req  = (HttpWebRequest)WebRequest.Create(desc.SendError);
                req.ContentType = "application/x-www-form-urlencoded; charset=utf-8";
                req.Method      = "POST";

                XmlDocument doc = XmlTool.CreateDocument("Error");
                XmlElement  xml = doc.DocumentElement;

                xml.SetAttribute("version", VersionInfo.VERSION);
                xml.AddChild("Message").InnerText    = error.Message;
                xml.AddChild("Type").InnerText       = error.GetType().FullName;
                xml.AddChild("StackTrace").InnerText = error.StackTrace;
                //xml.AddChild("DataTree").InnerText = GetDataTree();
                Exception se = error;
                while (se != null)
                {
                    XmlTool.SaveParameters(xml, se.Data);
                    se = se.InnerException;
                }

                xml.AddChild("Text").InnerText = error.ToString();

                //if (logHistory != null && CheckAutoUpdate.SendErrorLogs) Logging.SaveLogs(logHistory, xml.AddChild("LogHistory"));

                Dictionary <string, string> pars = new Dictionary <string, string>();
                StringWriter sw = new StringWriter();
                doc.Save(sw);
                pars["DATA"] = sw.ToString();
                //if (screenshot != null && CheckAutoUpdate.SendErrorScreenshots) pars["SCREENSHOT"] = SerializeScreenshot(screenshot);
                //if (CheckAutoUpdate.UpdateID != null) pars["PROGRAMUPDATE"] = CheckAutoUpdate.UpdateID.ToString();
                FeedbackTool.FillStdParams(pars, true);

                string pars_enc = StringTool.UrlEncode(pars, Encoding.UTF8);
                byte[] data     = Encoding.UTF8.GetBytes(pars_enc);
                req.ContentLength = data.Length;

                using (Stream fw = req.GetRequestStream())
                {
                    fw.Write(data, 0, data.Length);
                }
                using (var resp = req.GetResponse())
                {
                    using (Stream fr = resp.GetResponseStream())
                    {
                        using (StreamReader reader = new StreamReader(fr))
                        {
                            string line = reader.ReadToEnd();
                            Logging.Debug("Read result from datadmin feedback:" + line);
                        }
                    }
                }
            }
            catch (Exception err)
            {
                Errors.ReportSilent(err, false);
            }
        }
Example #18
0
 public SchemaStructure(XmlElement xml)
     : base(xml)
 {
     //this.LoadProperties(xml);
     SpecificData = XmlTool.LoadParameters(xml);
 }