コード例 #1
0
        public static void InitData()
        {
            try
            {
                ClearLists();

                string query = "select table_name, user_name, start_time from import_user.semaphore";

                List <DbRecord> recList = new List <DbRecord>();

                OracleDataReader reader = _con.GetReader(query);
                while (reader.Read())
                {
                    DbRecord rec = new DbRecord();
                    rec.TableName = reader[0].ToString();
                    rec.UserName  = reader[1].ToString();
                    rec.StartTime = reader[2].ToString();

                    if (rec.UserName.Length < 1)
                    {
                        Mediator.EmptyList.Add(rec);
                    }
                    else
                    {
                        Mediator.BusyList.Add(rec);
                    }
                    Mediator.TableList.Add(rec);
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception from Semaphore.Infrastructure.Manager.InitData()" + ex.Message);
            }
        }
コード例 #2
0
        public static int CheckUpdatePriority(string priorityValue)
        {
            int count = -1;

            try
            {
                string query = "select count(p.id) " +
                               "from SUVD.SCHEDULED_TODO_ITEMS s, " +
                               "suvd.projects p, " +
                               "suvd.contacts c, " +
                               "suvd.creditor_dogovors d, " +
                               "suvd.creditors cr " +
                               "where p.id = s.project_id " +
                               "and cr.id = p.creditor_id " +
                               "and c.id = p.debtor_contact_id " +
                               "and d.id = p.dogovor_id " +
                               "and s.project_id in (select p.id " +
                               "from IMP_PRIOR t, suvd.projects p " +
                               "where p.business_n = t.deal_id) " +
                               "and s.priority_value " + (priorityValue == "0"? ">" : "<") + priorityValue;
                OracleDataReader reader = _con.GetReader(query);
                while (reader.Read())
                {
                    count = Convert.ToInt32(reader[0]);
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка соединения с базой данных, попробуйте повторить попытку.", "Приоритеты", MessageBoxButtons.OK, MessageBoxIcon.Error);
                PriorityLoger.AddRecordToLog("Ошибка соединения с базой данных. " + ex.Message);
            }
            return(count);
        }
コード例 #3
0
        private int GetCount(string query)
        {
            int i = -1;

            try
            {
                OracleDataReader reader = _con.GetReader(query);

                while (reader.Read())
                {
                    i = Convert.ToInt32(reader[0]);
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                Loger.AddRecordToLog(ex.Message);
            }
            return(i);
        }
コード例 #4
0
        static string DbReader(OracleConnect connnect, string queryName)
        {
            string           str    = "";
            string           query  = "select t.query_block from LETTER_BLDR t where t.name = '" + queryName + "'";
            OracleDataReader reader = connnect.GetReader(query);

            while (reader.Read())
            {
                str = reader[0].ToString();
            }
            reader.Close();
            return(str);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: fil-dv/XmlParser
        static void ReadDataToList(OracleConnect con)
        {
            try
            {
                string query = "select x.id, x.project_id, x.data " +
                               "from SUVD.PROJECTS t, suvd.creditor_dogovors d, suvd.project_xml x " +
                               "where d.id = t.dogovor_id " +
                               "and t.archive_flag = 0" +
                               "and nvl(d.stop_date, sysdate) >= sysdate " +
                               "and x.project_id = t.id " +
                               "and x.data is not null";
                OracleDataReader reader = con.GetReader(query);

                DateTime startDate = DateTime.Now;
                DateTime lastDate  = DateTime.Now;
                Console.WriteLine("Старт. " + startDate);
                int count    = 0;
                int bitStart = 0;
                while (reader.Read() && count < 100)
                {
                    count++;
                    //if (count < 77888) continue;
                    XmlData xmlData = new XmlData();
                    xmlData.Id        = Convert.ToDecimal(reader[0].ToString());
                    xmlData.ProjectId = Convert.ToDecimal(reader[1].ToString());
                    xmlData.Data      = reader[2].ToString();
                    Parser(xmlData, con, count);
                    if (count % 25000 == 0)
                    {
                        double tmp = (DateTime.Now - lastDate).TotalMinutes;
                        Console.WriteLine("c " + bitStart.ToString() + " по " + count.ToString() + " залилось за " + tmp.ToString() + " минут.");
                        bitStart = count;
                        lastDate = DateTime.Now;
                        Console.WriteLine();
                    }
                    //Console.WriteLine(count.ToString());
                    FileHandler.WriteToFile(count.ToString());
                }
                reader.Close();
                DateTime endDate = DateTime.Now;
                double   dif     = (endDate - startDate).TotalMinutes;
                Console.WriteLine("Закончено за " + dif + " минут." + Environment.NewLine + "Распарсено  " + count + " записей.");
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.TargetSite + "\n" + ex.Message);
                FileHandler.WriteToFile(ex.TargetSite + "\n" + ex.Message);
            }
        }
コード例 #6
0
        void InitData()
        {
            try
            {
                _con = new OracleConnect("User ID=IMPORT_USER;password=sT7hk9Lm;Data Source=CD_WORK");
                _con.OpenConnect();

                string query = File.ReadAllText(@"sql\CleanDubles.sql", Encoding.Default);

                SplitAndExecSubQueries(query);
                query = File.ReadAllText(@"sql\AddrToSplit.sql", Encoding.Default);
                OracleDataReader reader = _con.GetReader(query);
                _list = new List <string>();
                while (reader.Read())
                {
                    string str = reader[0].ToString() + " ; " + reader[1].ToString().Replace(";", ",");
                    _list.Add(str);
                }
                reader.Close();
                Cleaner();
                FillData();
                SetThreadCount();
                SetNumericUpDownValue();
                if (Mediator.IsIncomParam)
                {
                    button_path.Enabled           = false;
                    button_start.Enabled          = false;
                    numericUpDown_threads.Enabled = false;
                    SetThreadCount();
                    StartSplit();
                }
            }
            catch (Exception ex)
            {
                Loger.AddRecordToLog(ex.Message);
            }
        }
コード例 #7
0
        static string GetQuery(int id)
        {
            string res = "empty";

            try
            {
                string           query  = "select t.query from report.let_queries t where t.id = " + id;
                OracleDataReader reader = _con.GetReader(query);
                while (reader.Read())
                {
                    res = reader[0].ToString();
                }
                reader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception from MyLetterManager.LetterManager.GetQuery()" + ex.Message);
            }
            return(res);
        }