Example #1
0
        public XsdDataBase.TBL_ObjectRow LoadAndRestoreStoredProcedure(XsdDataBase.TBL_ObjectRow nOriginalStoredProcedure, StringBuilder nLog)
        {
            CMData.Manager.DBManager DBM = null;

            try
            {
                if (Connection != null)
                {
                    if (Connection.IsConnection_TypeNull())
                    {
                        DBM = new CMData.Manager.DBManager(Connection.Connection_String);
                    }
                    else
                    {
                        var dbType = (CMData.DataBase.DataBaseType)(Enum.Parse(typeof(CMData.DataBase.DataBaseType), Connection.Connection_Type));
                        DBM = new CMData.Manager.DBManager(dbType, Connection.Connection_String);
                    }

                    DBM.Connection_Open();

                    var newDataBase = new XsdDataBase();
                    var newObject = newDataBase.TBL_Object.NewTBL_ObjectRow();

                    newObject.Generic_Type = nOriginalStoredProcedure.Generic_Type;
                    newObject.Object_Type = nOriginalStoredProcedure.Object_Type;
                    newObject.Catalog_Name = nOriginalStoredProcedure.Catalog_Name;
                    newObject.Schema_Name = nOriginalStoredProcedure.Schema_Name;
                    newObject.Object_Name = nOriginalStoredProcedure.Object_Name;

                    newDataBase.TBL_Object.AddTBL_ObjectRow(newObject);

                    DBM.DataBase.FillDataBaseParameters(newDataBase.TBL_Field, newObject);

                    try { newObject.Selected = nOriginalStoredProcedure.Selected; }
                    catch { }
                    newObject.Mapped = true;

                    try
                    {
                        var originalSpReturn = nOriginalStoredProcedure.GetTBL_SP_ReturnRows()[0];
                        var newSpReturn = newDataBase.TBL_SP_Return.NewTBL_SP_ReturnRow();

                        newSpReturn.fk_Object = newObject.id_Object;
                        newSpReturn.Return_Type = originalSpReturn.Return_Type;
                        newSpReturn.Data_Type_Returned = originalSpReturn.Data_Type_Returned;
                        newSpReturn.Schema_Name_Returned = originalSpReturn.Schema_Name_Returned;
                        newSpReturn.Object_Name_Returned = originalSpReturn.Object_Name_Returned;

                        newDataBase.TBL_SP_Return.AddTBL_SP_ReturnRow(newSpReturn);
                    }
                    catch { }

                    DBM.Connection_Close();

                    return newObject;
                }

                throw new Exception("Se debe seleccionar una conexión");
            }
            catch (Exception ex)
            {
                if (DBM != null) DBM.Connection_Close();
                throw new Exception(ex.Message);
            }
        }