Пример #1
0
        public CommandResult DROP_SCHEMA(IConnectToDB _Connect, string SchemaName)
        {
            CommandResult _result  = new CommandResult();
            ER_Tools      er_tools = new ER_Tools();
            ER_Query      er_query = new ER_Query();
            ER_DML        er_dml   = new ER_DML();

            StringBuilder SQLBuffer = new StringBuilder();

            string _Schema = ER_DB.GetSchema(_Connect);

            SQLBuffer.Append("DROP SCHEMA " + SchemaName);

            string SuccessMessage = "Success " + SchemaName + " has been dropped.";

            _result._Response   = er_query.RUN_NON_QUERY(_Connect, SQLBuffer.ToString(), SuccessMessage).ToString();
            _result._Successful = _result._Response.IndexOf(SuccessMessage) > -1 ? true : false;
            _result._EndTime    = DateTime.Now;

            if (_result._Successful)
            {
                er_dml.DROP_Dictionary_View(_Connect, SchemaName);
            }

            return(_result);
        }
Пример #2
0
 public byte[] GetBytes(string str)
 {
     try
     {
         byte[] bytes = new byte[str.Length * sizeof(char)];
         System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
         return(bytes);
     }
     catch (Exception ex)
     {
         ER_Tools._WriteEventLog(string.Format("Caught exception: {0} \r\n Stack Trace: {1}", ex.Message, ex.StackTrace), EventLogType.exception);
         throw;
     }
 }
Пример #3
0
        public string GetString(byte[] bytes)
        {
            try
            {
                int arraylength = bytes.Length % 2 != 0 ? bytes.Length + 1 : bytes.Length;

                char[] chars = new char[arraylength / sizeof(char)];
                System.Buffer.BlockCopy(bytes, 0, chars, 0, bytes.Length);
                return(new string(chars));
            }
            catch (Exception ex)
            {
                ER_Tools._WriteEventLog(string.Format("Caught exception: {0} \r\n Stack Trace: {1}", ex.Message, ex.StackTrace), EventLogType.error);
                return("Error getting string bytes. " + ex.ToString());;
            }
        }
Пример #4
0
        public CommandResult ADD_MSSQL_ROLE(IConnectToDB _Connect, string Name)
        {
            CommandResult _result = new CommandResult();

            ER_Tools er_tools = new ER_Tools();
            ER_Query er_query = new ER_Query();

            string tempstringNAME = er_tools.MaxNameLength(Name, 125) + "_RL";

            string SuccessMessage = "Role " + Name + " Created";

            _result._Response   = er_query.RUN_NON_QUERY(_Connect, "Create Role " + tempstringNAME, SuccessMessage);
            _result._Successful = _result._Response.IndexOf(SuccessMessage) > -1 ? true : false;
            _result._EndTime    = DateTime.Now;

            return(_result);
        }
Пример #5
0
        public static List <CommandResult> CREATE_OBJECT_FROM_FILE(IConnectToDB _NewConnect, sqlCreateObject thisModel, List <CommandResult> _Results)
        {
            string _objectName = thisModel.objectName;
            string _Schema     = _NewConnect.Schema;
            string SQLFilePath = thisModel.SqlFilePath;
            string ServerPath  = SQLFilePath;

            ER_DB _dbio = new ER_DB();

            StringBuilder _sqlIn  = new StringBuilder();
            CommandResult _Result = new CommandResult();

            if (!thisModel.registerObjectToDictionary || !ER_Tools.checkIfTableExist(_NewConnect, _NewConnect.Schema, _objectName))
            {
                _sqlIn = new StringBuilder();

                _Result = RUN_SQL_FILE(_NewConnect, ServerPath, "Success - " + _objectName + " SQL Ran.", _sqlIn);
                _Results.Add(_Result);

                //TODO: FIx this to make insert into DB. Might need type of object as well.
                //_CSAInputProcedures CSA_IPH = new _CSAInputProcedures();

                //if (thisModel.registerObjectToDictionary)
                //{
                //    VDbModel this_InstallModel = CSA_IPH.InitVApp(_Schema, thisModel.DBOBJTypeID, _objectName, "Y", "N", thisModel._selectedTemplateID);
                //    _Results.AddRange(CSA_IPH.InsertInstallation(_NewConnect, this_InstallModel));
                //}
            }
            else
            {
                _Result             = new CommandResult();
                _Result._StartTime  = DateTime.Now;
                _Result._Response   = "Warning - " + _objectName + " Object already exists.";
                _Result._Successful = _Result._Response.IndexOf("Warning") != -1 ? true : false;
                _Result._EndTime    = DateTime.Now;
                _Results.Add(_Result);
            }

            return(_Results);
        }
Пример #6
0
        public static ArrayList _GetObjectListFromDataTable(ArrayList list, DataTable DT)
        {
            ER_Tools _tools = new ER_Tools();

            return(_tools.GetObjectListFromDataTable(list, DT));
        }
Пример #7
0
        public static List <object> _GetObjectListFromDataTable(List <object> list, DataTable DT)
        {
            ER_Tools _tools = new ER_Tools();

            return(_tools.GetObjectListFromDataTable(list, DT));
        }
Пример #8
0
        public static DataTable ConvertCSVtoDataTable(byte[] csv_File, string[] delimiter)
        {
            ER_Tools _tools = new ER_Tools();

            //Stream stream = File.OpenRead("C:\\Users\\jose\\Source\\Repos\\revamp\\ER\\Files\\Test.csv");

            Stream stream = new MemoryStream(csv_File);

            DataTable  table = new DataTable("ReturnData");
            DataColumn column;

            try
            {
                //using (TextFieldParser parser = new TextFieldParser("C:\\Users\\jose\\Source\\Repos\\revamp\\ER\\Files\\Test.csv"))
                //TODO: Verify .Net Core Port
                using (TextFieldParser parser = new TextFieldParser(stream))
                {
                    parser.TextFieldType = FieldType.Delimited;
                    parser.SetDelimiters(delimiter);

                    int count = 0;
                    while (!parser.EndOfData)
                    {
                        //Processing row
                        string[] fields      = parser.ReadFields();
                        int      fieldsCount = fields.Length;
                        if (count == 0)
                        {
                            // Create first column and add to the DataTable.
                            column                   = new DataColumn();
                            column.DataType          = System.Type.GetType("System.Int32");
                            column.ColumnName        = "CVS_ID";
                            column.AutoIncrement     = true;
                            column.AutoIncrementSeed = 0;
                            column.AutoIncrementStep = 1;
                            column.Caption           = "ID";
                            column.ReadOnly          = true;
                            column.Unique            = true;
                            table.Columns.Add(column);
                            count++;


                            for (int i = 0; i < fieldsCount; i++)
                            {
                                column               = new DataColumn();
                                column.DataType      = System.Type.GetType("System.String");
                                column.ColumnName    = fields[i];
                                column.AutoIncrement = false;
                                column.Caption       = fields[i];
                                column.ReadOnly      = false;
                                column.Unique        = false;
                                table.Columns.Add(column);
                                //TODO: Process field
                            }
                        }

                        DataRow _row = table.NewRow();

                        for (int i = 0; i < fieldsCount; i++)
                        {
                            _row[i + 1] = fields[i];
                            //TODO: Process field
                        }

                        table.Rows.Add(_row);
                    }
                }
            }
            catch (Exception e)
            {
                table = new DataTable("Error");
                // Create fourth column and add to the DataTable.
                column               = new DataColumn();
                column.DataType      = System.Type.GetType("System.String");
                column.ColumnName    = "Exception";
                column.AutoIncrement = false;
                column.Caption       = "Exception";
                column.ReadOnly      = false;
                column.Unique        = false;
                table.Columns.Add(column);


                DataRow row = table.NewRow();
                row["Exception"] = e;
                table.Rows.Add(row);
            }
            //stream = File.OpenRead("C:\\Users\\jose\\Source\\Repos\\revamp\\ER\\Files\\Test.csv");

            //using (StreamReader sr = new StreamReader("C:\\Users\\jose\\Source\\Repos\\revamp\\ER\\Files\\Test.csv"))
            //using (StreamReader sr = new StreamReader(stream))
            //{
            //    string currentLine;
            //    // currentLine will be null when the StreamReader reaches the end of file
            //    while ((currentLine = sr.ReadLine()) != null)
            //    {
            //        // Search, case insensitive, if the currentLine contains the searched keyword
            //        StringReader csv_reader = new StringReader(currentLine.ToString());

            //        TextFieldParser csv_parser = new TextFieldParser(csv_reader);
            //        csv_parser.SetDelimiters(delimiter);
            //        csv_parser.HasFieldsEnclosedInQuotes = true;
            //        string[] csv_array = csv_parser.ReadFields();

            //    }
            //}

            return(table);
        }
Пример #9
0
        public static List <string> _ConvertDataTableToArrayList(DataTable dtTable)
        {
            ER_Tools _tools = new ER_Tools();

            return(_tools.ConvertDataTableToArrayList(dtTable));
        }
Пример #10
0
        public static Boolean _WriteEventLog(string message, EventLogType eventlogtype, RevampCoreSettings appSettings = null)
        {
            ER_Tools _tools = new ER_Tools();

            return(_tools.WriteEventLog(message, eventlogtype, appSettings));
        }
Пример #11
0
        public static string ConvertObjectToString(byte[] bytes)
        {
            ER_Tools tools = new ER_Tools();

            return(tools.GetString(bytes));
        }
Пример #12
0
        public static byte[] _GetBytes(string str)
        {
            ER_Tools tools = new ER_Tools();

            return(tools.GetBytes(str));
        }