Exemplo n.º 1
0
        public void loadSQL(string name, string path)
        {
            string        sConn   = @"server=" + this.strServer + "; database=" + this.strDataBase + ";user id=" + this.strUsername + ";password="******";";
            SqlConnection objConn = new SqlConnection(sConn);

            objConn.Open();

            ///BizagiInfo.xml
            ///Catalog__Indexes.xml
            ///Catalog__IndexObjects.xml
            ///Catalog__Localization.xml
            ///Catalog__Objects.xml
            ///Catalog__References.xml
            ///Options.xml
            ///PackageInfo.xml
            ///Relational.xml
            ///
            if (name.ToLower() == "packageinfo.xml")
            {
                //var xmlCO = File.ReadAllText(path);
                //XmlSerializer serializer = new XmlSerializer(typeof(PackageContentInformation));
                //StringReader rdr = new StringReader(xmlCO);
                //PackageContentInformation packageContentInformation = (PackageContentInformation)serializer.Deserialize(rdr);
                //this.PackageContentInformation = packageContentInformation;

                //propertyGrid1.SelectedObject = packageContentInformation;
                //txtContent.Text = xmlCO;
            }
            if (name.ToLower() == "relational.xml")
            {
                string     sTSQL  = "SELECT * from BADPLYCONFIG";
                SqlCommand objCmd = new SqlCommand(sTSQL, objConn);
                objCmd.CommandType = CommandType.Text;
                SqlDataReader dr = objCmd.ExecuteReader();
                dr.Read();
                var dFile = dr["baDplyConfigFile"];
                var m_oDefaultEncodingForXML = new UTF8Encoding(false, true);
                //var texto = Encoding.Unicode.GetString((byte[])dFile);
                var texto          = Compression.DecompressString((byte[])dFile, m_oDefaultEncodingForXML);
                var textoFormatado = "";
                if (texto.StartsWith("<?xml") || texto.Contains("xmlns="))
                {
                    textoFormatado = texto;
                }
                else
                {
                    textoFormatado = Newtonsoft.Json.Linq.JToken.Parse(texto).ToString();
                }

                NewDataSet bADPLYCONFIG = new NewDataSet();
                bADPLYCONFIG.BADPLYCONFIG = new List <BADPLYCONFIG>();

                BADPLYCONFIG bi = new BADPLYCONFIG();

                bi.BaDplyConfigFile = textoFormatado;
                bi.DcFileVersion    = ((byte)dr["dcFileVersion"]).ToString();
                bi.DcMapType        = ((byte)dr["dcMapType"]).ToString();
                bi.DplyBADplyConfig = ((byte)dr["dplyBADplyConfig"]).ToString();
                bi.GuidBADplyConfig = ((System.Guid)dr["guidBADplyConfig"]).ToString();
                bi.IdBaDplyConfig   = ((int)dr["idBaDplyConfig"]).ToString();

                bADPLYCONFIG.BADPLYCONFIG.Add(bi);

                this.BADPLYConfig = bADPLYCONFIG;
                var jdata = Newtonsoft.Json.JsonConvert.SerializeObject(bADPLYCONFIG);
                txtContent.Text = Newtonsoft.Json.Linq.JToken.Parse(jdata).ToString();
            }

            if (name.ToLower() == "options.xml")
            {
                //var xmlCO = File.ReadAllText(path);
                //XmlSerializer serializer = new XmlSerializer(typeof(AdvancedOptions));
                //StringReader rdr = new StringReader(xmlCO);
                //AdvancedOptions advancedOptions = (AdvancedOptions)serializer.Deserialize(rdr);
                //this.AdvancedOptions = advancedOptions;
                //var dic = new Dictionary<string, string>();
                //var option = advancedOptions.AdvancedOption.FirstOrDefault();
                //if (option != null)
                //    propertyGrid1.SelectedObject = option;
                //txtContent.Text = xmlCO;
            }
            if (name.ToLower() == "bizagiinfo.xml")
            {
                //select * from BIZAGIINFO
                string     sTSQL  = "SELECT * from BIZAGIINFO";
                SqlCommand objCmd = new SqlCommand(sTSQL, objConn);
                objCmd.CommandType = CommandType.Text;
                SqlDataReader dr         = objCmd.ExecuteReader();
                NewDataSet    bizagiInfo = new NewDataSet();
                bizagiInfo.BIZAGIINFO = new List <BIZAGIINFO>();
                while (dr.Read())
                {
                    BIZAGIINFO bi = new BIZAGIINFO
                    {
                        BAInfo  = (string)dr["BAInfo"],
                        BAValue = (string)dr["BAValue"]
                    };
                    bizagiInfo.BIZAGIINFO.Add(bi);
                }
                this.BizagiInfo = bizagiInfo;
                var dic = new Dictionary <string, string>();
                foreach (var b in bizagiInfo.BIZAGIINFO)
                {
                    dic.Add(b.BAInfo, b.BAValue);
                }
                propertyGrid1.SelectedObject = new DictionaryPropertyGridAdapter(dic);
                txtContent.Text = "";
            }
            if (name.ToLower() == "catalog__references.xml")
            {
                // var xmlCO = File.ReadAllText(path);
                string     sTSQL  = "SELECT * from BACATALOGREFERENCE";
                SqlCommand objCmd = new SqlCommand(sTSQL, objConn);
                objCmd.CommandType = CommandType.Text;
                SqlDataReader dr = objCmd.ExecuteReader();

                ArrayOfReference catalogReferences = new ArrayOfReference();
                CatalogReferences.Reference = new List <Reference>();
                while (dr.Read())
                {
                    Reference bi = new Reference();
                    bi.Deleted  = ((byte)dr["Deleted"]).ToString();
                    bi.Pointer  = ((System.Guid)dr["guidPointer"]).ToString();
                    bi.Referrer = ((System.Guid)dr["guidObjectRef"]).ToString();
                    bi.Root     = ((System.Guid)dr["rootObject"]).ToString();
                    bi.Target   = ((System.Guid)dr["guidObjectTarget"]).ToString();

                    CatalogReferences.Reference.Add(bi);
                }

                this.CatalogReferences = catalogReferences;

                FilterReferences(catalogReferences.Reference);

                //txtContent.Text = xmlCO;
            }
            if (name.ToLower() == "catalog__objects.xml")
            {
                //string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);

                string     sTSQL  = "SELECT * from vwBA_Catalog_BABIZAGICATALOG";
                SqlCommand objCmd = new SqlCommand(sTSQL, objConn);
                objCmd.CommandType = CommandType.Text;
                SqlDataReader dr = objCmd.ExecuteReader();


                CatalogObject catOb = new CatalogObject();

                ArrayOfCatalogObject resultingMessage = new ArrayOfCatalogObject();
                resultingMessage.CatalogObject = new List <CatalogObject>();
                while (dr.Read())
                {
                    CatalogObject bi = new CatalogObject();
                    //bi.CatalogReferences = ((byte)dr["Deleted"]).ToString();
                    bi.ChangeSetId = dr["changeSetId"] == DBNull.Value ? "" : ((int)dr["changeSetId"]).ToString();
                    bi.Type        = dr["objTypeName"] == DBNull.Value ? "" : ((string)dr["objTypeName"]);
                    var byCont = (byte[])dr["objContent"];
                    bi.Content = Convert.ToBase64String(byCont, 0, byCont.Length);
                    try
                    {
                        var texto          = Encoding.Unicode.GetString(byCont);
                        var textoFormatado = "";
                        if (texto.StartsWith("<?xml"))
                        {
                            textoFormatado = texto;
                        }
                        else
                        {
                            textoFormatado = Newtonsoft.Json.Linq.JToken.Parse(texto).ToString();
                        }
                        bi.Content = textoFormatado;
                    }
                    catch (Exception)
                    {
                        //   throw;
                    }


                    bi.ParentId       = dr["guidObjectParent"] == DBNull.Value ? "" : ((System.Guid)dr["guidObjectParent"]).ToString();
                    bi.DeployOnParent = dr["DeployOnParent"] == DBNull.Value ? "false" : ((bool)dr["DeployOnParent"]).ToString();// ((byte)dr["DeployOnParent"]).ToString();
                    bi.HasOverride    = dr["isOverride"] == DBNull.Value ? "false" : ((string)dr["isOverride"]);
                    bi.ContentFormat  = ((byte)dr["contentFormat"]).ToString();
                    bi.Deleted        = dr["Deleted"] == DBNull.Value ? "false" : ((bool)dr["Deleted"]).ToString();
                    bi.DeployOnParent = dr["deployOnParent"] == DBNull.Value ? "false" : ((bool)dr["deployOnParent"]).ToString();; // ((byte)dr["deployOnParent"]).ToString();
                    bi.Dicionario     = new Dictionary <string, object>();
                    bi.Id             = ((System.Guid)dr["guidObject"]).ToString();
                    bi.Indexes        = new Indexes();
                    bi.ModifiedByUser = (string)dr["modifiedByUser"];
                    bi.Name           = (string)dr["objName"];
                    bi.ParentId       = dr["guidObjectParent"] == DBNull.Value ? "":((System.Guid)dr["guidObjectParent"]).ToString();
                    bi.References     = new References();
                    bi.Root           = dr["rootObject"] == DBNull.Value ? "" : ((System.Guid)dr["rootObject"]).ToString();
                    bi.Tags           = new Tags();


                    bi.Version = ((int)dr["mtdVersion"]).ToString();
                    resultingMessage.CatalogObject.Add(bi);
                }

                this.DataCatalog = resultingMessage;
                propertyGrid1.SelectedObjects = resultingMessage.CatalogObject.ToArray();
                this.Tabelas = new List <CatalogObject>();
                this.Types   = new List <TipoObjeto>();
                this.Types   = FillTypes(resultingMessage.CatalogObject).OrderBy(d => d.Tipo).ToList();
                cmbType.Items.Clear();
                foreach (var tb in this.Types)
                {
                    cmbType.Items.Add(new ComboIten {
                        Name = tb.Tipo, Value = tb.Tipo, Catalogos = tb.Objetos
                    });
                }
                this.Tabelas = FillTabelas(resultingMessage.CatalogObject);

                Filter(resultingMessage.CatalogObject);
            }
            if (name.ToLower() == "catalog__indexes.xml")
            {
                string     sTSQL  = "SELECT * from BATAGVALUE";
                SqlCommand objCmd = new SqlCommand(sTSQL, objConn);
                objCmd.CommandType = CommandType.Text;
                SqlDataReader dr = objCmd.ExecuteReader();

                ArrayOfIndexValue cIndex = new ArrayOfIndexValue();
                cIndex.IndexValueIn = new List <IndexValue>();
                while (dr.Read())
                {
                    IndexValue bi = new IndexValue();
                    bi.Deleted   = dr["Deleted"] == DBNull.Value?"false": ((bool)dr["Deleted"]).ToString();
                    bi.IndexName = ((string)dr["tagName"]);
                    bi.ObjectId  = ((System.Guid)dr["taggedObject"]).ToString();
                    bi.Root      = ((System.Guid)dr["rootObject"]).ToString();
                    bi.TagType   = ((System.Guid)dr["tagType"]).ToString();
                    bi.Value     = (string)dr["value"];
                    cIndex.IndexValueIn.Add(bi);
                }

                this.DataCatalogIndex = cIndex;
            }
            objConn.Close();
        }
Exemplo n.º 2
0
        public void loadXml(string name, string path)
        {
            ///BizagiInfo.xml
            ///Catalog__Indexes.xml
            ///Catalog__IndexObjects.xml
            ///Catalog__Localization.xml
            ///Catalog__Objects.xml
            ///Catalog__References.xml
            ///Options.xml
            ///PackageInfo.xml
            ///Relational.xml
            ///
            if (name.ToLower() == "packageinfo.xml")
            {
                var                       xmlCO      = File.ReadAllText(path);
                XmlSerializer             serializer = new XmlSerializer(typeof(PackageContentInformation));
                StringReader              rdr        = new StringReader(xmlCO);
                PackageContentInformation packageContentInformation = (PackageContentInformation)serializer.Deserialize(rdr);
                this.PackageContentInformation = packageContentInformation;

                propertyGrid1.SelectedObject = packageContentInformation;
                txtContent.Text = xmlCO;
            }
            if (name.ToLower() == "relational.xml")
            {
                var           xmlCO        = File.ReadAllText(path);
                XmlSerializer serializer   = new XmlSerializer(typeof(NewDataSet));
                StringReader  rdr          = new StringReader(xmlCO);
                NewDataSet    bADPLYCONFIG = (NewDataSet)serializer.Deserialize(rdr);
                this.BADPLYConfig = bADPLYCONFIG;
                //var dic = new Dictionary<string, string>();
                //foreach (var b in bADPLYCONFIG.BADPLYCONFIG)
                //{
                //    dic.Add(b., b.BAValue);
                //}
                // propertyGrid1.SelectedObject = new DictionaryPropertyGridAdapter(dic);
                txtContent.Text = xmlCO;
            }

            if (name.ToLower() == "options.xml")
            {
                var             xmlCO           = File.ReadAllText(path);
                XmlSerializer   serializer      = new XmlSerializer(typeof(AdvancedOptions));
                StringReader    rdr             = new StringReader(xmlCO);
                AdvancedOptions advancedOptions = (AdvancedOptions)serializer.Deserialize(rdr);
                this.AdvancedOptions = advancedOptions;
                var dic    = new Dictionary <string, string>();
                var option = advancedOptions.AdvancedOption.FirstOrDefault();
                if (option != null)
                {
                    propertyGrid1.SelectedObject = option;
                }
                txtContent.Text = xmlCO;
            }
            if (name.ToLower() == "bizagiinfo.xml")
            {
                var           xmlCO      = File.ReadAllText(path);
                XmlSerializer serializer = new XmlSerializer(typeof(NewDataSet));
                StringReader  rdr        = new StringReader(xmlCO);
                NewDataSet    bizagiInfo = (NewDataSet)serializer.Deserialize(rdr);
                this.BizagiInfo = bizagiInfo;
                var dic = new Dictionary <string, string>();
                foreach (var b in bizagiInfo.BIZAGIINFO)
                {
                    dic.Add(b.BAInfo, b.BAValue);
                }
                propertyGrid1.SelectedObject = new DictionaryPropertyGridAdapter(dic);
                txtContent.Text = xmlCO;
            }
            if (name.ToLower() == "catalog__references.xml")
            {
                var              xmlCO             = File.ReadAllText(path);
                XmlSerializer    serializer        = new XmlSerializer(typeof(ArrayOfReference));
                StringReader     rdr               = new StringReader(xmlCO);
                ArrayOfReference catalogReferences = (ArrayOfReference)serializer.Deserialize(rdr);
                this.CatalogReferences = catalogReferences;

                FilterReferences(catalogReferences.Reference);

                txtContent.Text = xmlCO;
            }
            if (name.ToLower() == "catalog__objects.xml")
            {
                var                  xmlCO            = File.ReadAllText(path);
                CatalogObject        catOb            = new CatalogObject();
                XmlSerializer        serializer       = new XmlSerializer(typeof(ArrayOfCatalogObject));
                StringReader         rdr              = new StringReader(xmlCO);
                ArrayOfCatalogObject resultingMessage = (ArrayOfCatalogObject)serializer.Deserialize(rdr);
                this.DataCatalog = resultingMessage;
                propertyGrid1.SelectedObjects = resultingMessage.CatalogObject.ToArray();
                this.Tabelas = new List <CatalogObject>();
                this.Types   = new List <TipoObjeto>();
                this.Types   = FillTypes(resultingMessage.CatalogObject).OrderBy(d => d.Tipo).ToList();
                cmbType.Items.Clear();
                foreach (var tb in this.Types)
                {
                    cmbType.Items.Add(new ComboIten {
                        Name = tb.Tipo, Value = tb.Tipo, Catalogos = tb.Objetos
                    });
                }
                this.Tabelas = FillTabelas(resultingMessage.CatalogObject);

                //Filter(resultingMessage.CatalogObject);
            }
            if (name.ToLower() == "catalog__indexes.xml")
            {
                var xmlCO = File.ReadAllText(path);
                ArrayOfIndexValue cIndex     = new ArrayOfIndexValue();
                XmlSerializer     serializer = new XmlSerializer(typeof(ArrayOfIndexValue));
                StringReader      rdr        = new StringReader(xmlCO);
                cIndex = (ArrayOfIndexValue)serializer.Deserialize(rdr);
                this.DataCatalogIndex = cIndex;
            }
        }