Ejemplo n.º 1
0
        public string getAutoNum()
        {
            string str = "";

            try
            {
                this.dboperator_0 = this.connectionConfig_0.getDBOperator();
                this.dboperator_0.Open();
                IDbCommand myComm = this.dboperator_0.Connection.CreateCommand();
                myComm.Connection = (this.dboperator_0.Connection);
                str = this.getAutoNum(myComm);
                myComm.Dispose();
                this.dboperator_0.Close();
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                try
                {
                    this.dboperator_0.Close();
                }
                catch (Exception)
                {
                }
            }
            return(str);
        }
Ejemplo n.º 2
0
        public static string Load(HttpRequest Request, DBOperator oDb, string sFileName)
        {
            string str = "";

            try
            {
                string strSql = "select sText from fc_reportfile where sName='" + sFileName + "'";
                oDb.Open();
                IDataReader reader = oDb.exeSql(strSql);
                if (reader.Read())
                {
                    str = reader.GetString(0);
                }
                reader.Close();
            }
            catch (Exception exception)
            {
                str = exception.Message;
            }
            finally
            {
                try
                {
                    oDb.Close();
                }
                catch (Exception)
                {
                }
            }
            return(str);
        }
Ejemplo n.º 3
0
 public void readImage(HttpResponse Response)
 {
     try
     {
         string strSql = "select " + this.string_1 + " from " + this.string_0 + " where " + this.string_2 + "='" + this.string_3 + "'";
         this.dboperator_0 = this.connectionConfig_0.getDBOperator();
         this.dboperator_0.Open();
         Logger.debug("dbimg的读SQL语句:" + strSql);
         IDataReader reader = this.dboperator_0.exeSql(strSql);
         if (reader.Read())
         {
             byte[] buffer = (byte[])reader[(this.string_1)];
             if (buffer != null)
             {
                 Response.BinaryWrite(buffer);
             }
         }
         reader.Close();
         this.dboperator_0.Close();
     }
     catch (Exception exception)
     {
         throw exception;
     }
     finally
     {
         try
         {
             this.dboperator_0.Close();
         }
         catch (Exception)
         {
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 初始化一个应用系统用户
        /// </summary>
        public static ResultOfInitBasicLogin InitBasicLogin(DBOperator dbOperator, int userID)
        {
            ResultOfInitBasicLogin myResult = new ResultOfInitBasicLogin();

            Bigdesk2010.Business.UserRightManager.IUserRightInfo ur = new Bigdesk2010.Business.UserRightManager.UserRightInfo(dbOperator, userID);
            if (ur.CountOfUserMatched < 1)
            {
                myResult.ResultCode = ResultCodeOfInitBasicLogin.用户不存在;
                myResult.Message    = "用户不存在!";
                return(myResult);
            }
            else if (ur.CountOfUserMatched > 1)
            {
                myResult.ResultCode = ResultCodeOfInitBasicLogin.用户重复;
                myResult.Message    = "用户重复,请与系统管理员联系!";
                return(myResult);
            }
            myResult.ResultCode = ResultCodeOfInitBasicLogin.唯一用户;

            BasicLoginInfo workUser = new BasicLoginInfo();

            workUser.UserID      = ur.UserID;
            workUser.LoginName   = ur.LoginName;
            workUser.UserName    = ur.UserName;
            workUser.UserType    = ur.UserType;
            workUser.OrgUnitName = ur.OrgUnitName;

            myResult.WorkUser = workUser;
            return(myResult);
        }
Ejemplo n.º 5
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string rep       = comboBox1.SelectedValue.ToString();
            string month     = DateTime.Now.AddMonths(-1).ToString("MMMM, yyyy");
            string condition = "";

            if (rep != "All")
            {
                condition = " Rep = '" + rep + "' and ";
            }
            string             sql   = @"select Accountno as 'ID', Customer as 'Company', Contact, Phone, AltPhone, BalanceTotal as 'Balance', SalesTax, SalesTaxNum, 
                                  LiquorTax_Phila as 'LiquorTax', U_OTax from ClientDetail 
                            where " + condition + @"  (JobStatus='pending' 
                                  or (SalesTax in ('Monthly','Monthly(w/ Prepay)','Monthly(Sugar)') and JobStatus='current') 
                                  or (JobStatus<>'closed' and (LiquorTax_Phila='Yes' or U_OTax like 'Yes%')) )
                            order by JobStatus, Accountno";
            DataTable          dt    = DBOperator.QuerySql(sql);
            List <SalesTaxRep> items = DBOperator.getListFromTable <SalesTaxRep>(dt);
            int total = dt.Rows.Count;

            reportViewer1.LocalReport.DataSources.Clear();
            ReportParameter repTitle = new ReportParameter("repTitle", "Monthly Query - " + rep);
            ReportParameter repMonth = new ReportParameter("repMonth", month);
            ReportParameter totalPar = new ReportParameter("totalNum", "Total #: " + total.ToString());

            reportViewer1.LocalReport.SetParameters(new ReportParameter[] { repTitle, repMonth, totalPar });
            ReportDataSource rds = new ReportDataSource("dsMonthlySalesTax", items);

            reportViewer1.LocalReport.DataSources.Add(rds);

            reportViewer1.RefreshReport();
        }
Ejemplo n.º 6
0
        public string readClob()
        {
            string str = "";

            try
            {
                this.dboperator_0 = this.connectionConfig_0.getDBOperator();
                this.dboperator_0.Open();
                IDbCommand command = this.dboperator_0.Connection.CreateCommand();
                command.Connection  = (this.dboperator_0.Connection);
                command.CommandText = ("select " + this.string_1 + " from " + this.string_0 + " where " + this.string_2 + "='" + this.string_3 + "'");
                str = command.ExecuteScalar().ToString();
                command.Dispose();
                this.dboperator_0.Close();
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                try
                {
                    this.dboperator_0.Close();
                }
                catch (Exception)
                {
                }
            }
            return(str);
        }
Ejemplo n.º 7
0
        private void importData(string filePath, string tableName, Label tMessage)
        {
            Label.CheckForIllegalCrossThreadCalls = false;
            tMessage.Text = "Reading data from excel";
            DataTable dt    = ReadExcelToDataTable(filePath, tableName);
            int       total = dt.Rows.Count;

            tMessage.Text = "Data has been read, there are " + total + " records.";
            string sql = "";

            sql = "delete " + tableName + "; ";
            DBOperator.ExecuteSql(sql);
            sql = "insert into " + tableName + " values";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                sql += "(";
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    sql += "'" + dt.Rows[i][j].ToString().Replace("'", "''") + "',";
                }
                sql = sql.Substring(0, sql.Length - 1) + "), ";
                if (i % 10 == 0)
                {
                    sql = sql.Substring(0, sql.Length - 2);
                    DBOperator.ExecuteSql(sql);
                    sql           = "insert into " + tableName + " values";
                    tMessage.Text = i + " records has been imported, " + (total - i) + " left.";
                }
            }
            if (sql.Length > 40)
            {
                sql = sql.Substring(0, sql.Length - 2);
                DBOperator.ExecuteSql(sql);
            }
            tMessage.Text = "begin to update ClientPayroll with new data of ClientDetail.";
            if (tableName == "ClientDetail")
            {
                sql = @"update ClientPayroll set EIN=cd.EIN, AccRep=cd.Rep, Entity=cd.Customer, TradeName=cd.Company, BusAdd1=cd.BusAdd1, 
                                                 CkRep=cd.PaycheckRep, PayRep=cd.PayrollRep,
						                         BusAdd2=cd.BusAdd2, BusCity=cd.BusAdd3, BusSt=cd.BusAdd4 , BusZip=cd.BusAdd5, Fax=cd.Fax
                        from ClientDetail cd, ClientPayroll where AccNum=cd.AccountNo";
                DBOperator.ExecuteSql(sql);
                sql = @"select AccountNo, EIN, Rep, Customer, Company, BusAdd1, PaycheckRep, PayrollRep, BusAdd2, BusAdd3, BusAdd4, BusAdd5, Fax
                        from ClientDetail where AccountNo not in (select AccNum from ClientPayroll)";
                dt  = DBOperator.QuerySql(sql);
                sql = "";
                foreach (DataRow dr in dt.Rows)
                {
                    sql += @" insert into ClientPayroll(AccNum, EIN, AccRep, Entity, TradeName, BusAdd1, CkRep, PayRep, BusAdd2, BusCity, BusSt, BusZip, Fax) 
                              values('" + dr[0].ToString() + "', '" + dr[1].ToString() + "', '" + dr[2].ToString() + "', '" + dr[3].ToString().Replace("'", "''") + @"', 
                                     '" + dr[4].ToString().Replace("'", "''") + "', '" + dr[5].ToString().Replace("'", "''") + "', '" + dr[6].ToString() + "', '" + dr[7].ToString() + @"', 
                                     '" + dr[8].ToString() + "', '" + dr[9].ToString() + "', '" + dr[10].ToString() + "', '" + dr[11].ToString() + "', " +
                           "'" + dr[12].ToString() + "'); ";
                }
                if (sql != "")
                {
                    DBOperator.ExecuteSql(sql);
                }
            }
        }
Ejemplo n.º 8
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string    sql = @"select AccountNo, Contact, Customer, Company, Mailto1, Mailto2, Mailto3, Fee, 
                                  YearEnd, Phone, AltPhone,Fax, EIN, SalesTaxNum, StartDate, '2016' as 'corpNum' 
                           from ClientDetail where AccountNo='" + comboBox1.Text + "'";
            DataTable dt  = DBOperator.QuerySql(sql);

            reportViewer1.LocalReport.DataSources.Clear();
            ReportParameter accountNo  = new ReportParameter("accountNo", dt.Rows[0][0].ToString());
            ReportParameter contact    = new ReportParameter("contact", dt.Rows[0][1].ToString());
            ReportParameter customer   = new ReportParameter("customer", dt.Rows[0][2].ToString());
            ReportParameter company    = new ReportParameter("company", "DBA:" + dt.Rows[0][3].ToString());
            ReportParameter mailto1    = new ReportParameter("mailto1", dt.Rows[0][4].ToString());
            ReportParameter mailto2    = new ReportParameter("mailto2", dt.Rows[0][5].ToString());
            ReportParameter mailto3    = new ReportParameter("mailto3", dt.Rows[0][6].ToString());
            ReportParameter fee        = new ReportParameter("fee", dt.Rows[0][7].ToString());
            ReportParameter yearEnd    = new ReportParameter("yearEnd", dt.Rows[0][8].ToString());
            ReportParameter phone      = new ReportParameter("phone", dt.Rows[0][9].ToString());
            ReportParameter altphone   = new ReportParameter("altphone", dt.Rows[0][10].ToString());
            ReportParameter fax        = new ReportParameter("fax", dt.Rows[0][11].ToString());
            ReportParameter ein        = new ReportParameter("ein", dt.Rows[0][12].ToString());
            ReportParameter saleTaxNum = new ReportParameter("saleTaxNum", dt.Rows[0][13].ToString());
            ReportParameter startDate  = new ReportParameter("startDate", dt.Rows[0][14].ToString());
            ReportParameter corpNum    = new ReportParameter("corpNum", dt.Rows[0][15].ToString());
            ReportParameter rep        = new ReportParameter("rep", comboBox1.Text);

            reportViewer1.LocalReport.SetParameters(
                new ReportParameter[] {
                accountNo, contact, customer, company, mailto1, mailto2, mailto3, fee, yearEnd, phone, altphone, fax, ein, saleTaxNum, startDate, corpNum, rep
            });
            this.reportViewer1.RefreshReport();
        }
Ejemplo n.º 9
0
        public string SqlToField(string strsql)
        {
            string str = "";

            try
            {
                this.dboperator_0 = this.connectionConfig_0.getDBOperator();
                this.dboperator_0.Open();
                IDataReader rs = this.dboperator_0.exeSql(strsql);
                if (rs.Read())
                {
                    str = SQLTool.getStr(rs, 0, this.string_0);
                }
                rs.Close();
                this.dboperator_0.Close();
            }
            catch (Exception exception)
            {
                throw new SqlRunException(strsql, exception.Message);
            }
            finally
            {
                try
                {
                    this.dboperator_0.Close();
                }
                catch (Exception)
                {
                }
            }
            return(str);
        }
Ejemplo n.º 10
0
        public static bool  GeneratedCode(string sql, EnvDTE.Project pjt, string classname)
        {
            bool ok = Kit.CheckDataBase();

            if (ok)
            {
                DBOperator <Keel.DB.Common> obc = new DBOperator <Keel.DB.Common>();
                DataTable dt = obc.ExecuteFillDataTable(sql);
                ok = false;
                if (classname == null || classname == "")
                {
                    classname = dt.TableName;
                }
                if (classname != null && classname != "")
                {
                    ViewGenerator mg = new ViewGenerator((string)pjt.Properties.Item("RootNamespace").Value, classname, sql);
                    for (int i = 0; i < dt.Columns.Count; i++)
                    {
                        DataColumn dc = dt.Columns[i];
                        mg.AddProperty(dc.ColumnName, dc.DataType, null);
                    }
                    cfLangType cl       = Kit.GetProjectLangType(pjt);
                    string     filename = mg.Save(pjt.FileName, cl);
                    pjt.ProjectItems.AddFromFile(filename);
                    ok = true;
                }
            }
            return(ok);
        }
Ejemplo n.º 11
0
        private void LabelFolderReport_Load(object sender, EventArgs e)
        {
            DBOperator.SetComboxRepData(comboBox1);
            string sql       = "select AccountNo from ClientDetail ";
            string condition = "";

            if (Main.cUser.UserLevel >= Setting.ReporterLevel)
            {
                comboBox1.Enabled       = true;
                comboBox1.SelectedIndex = 0;
            }
            else
            {
                comboBox1.Enabled = false;
                comboBox1.Text    = Main.cUser.Rep;
                condition         = " where Rep='" + Main.cUser.Rep + "'";
            }
            sql += condition;
            DataTable dt = DBOperator.QuerySql(sql);

            comboBox1.DataSource                 = dt;
            comboBox1.DisplayMember              = "AccountNo";
            this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);
            comboBox1.SelectedIndex              = 0;
            WindowState = FormWindowState.Maximized;
        }
Ejemplo n.º 12
0
        private void CkRepFrm_Load(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;
            DBOperator.SetComboxRepData(cmbRep);
            cmbRep.SelectedIndex   = DateTime.Now.Month - 1;
            comMonth.SelectedIndex = 0;
            int year = DateTime.Now.Year;

            for (int i = 0; i < 5; i++)
            {
                comYear.Items.Add(year--);
            }
            comYear.SelectedIndex = 0;
            if (Main.cUser.UserLevel >= Setting.ReporterLevel)
            {
                cmbRep.Enabled       = true;
                cmbRep.SelectedIndex = 0;
            }
            else
            {
                cmbRep.Enabled       = false;
                cmbRep.Text          = Main.cUser.FirstName + " " + Main.cUser.LastName;
                cmbRep.SelectedValue = Main.cUser.Rep;
            }
        }
Ejemplo n.º 13
0
        static async Task Main(string[] args)
        {
            Timer.Reset();

            IPreprocessable preprocessor = new TFPreprocessor();
            // IPreprocessable preprocessor = new HistogramPreprocessor();
            // preprocessor.ProcessFolders(Directory.GetDirectories("assets"));
            var single = preprocessor.PreprocessSingle("assets/007.bat/007_0001.jpg");

            preprocessor.TotalList.Add(single);
            preprocessor.AfterAdd();
            var dbOperator = new DBOperator(VectorType.TF);

            if (await dbOperator.CheckExists())
            {
                await dbOperator.CreateCollection();
            }

            // await dbOperator.InsertVectors(preprocessor.TotalList);

            var res = await dbOperator.Search(preprocessor.TotalList[0], 10);

            Console.WriteLine($"Test Image: {single.Name}\n\nAnswer:");

            foreach (var item in res)
            {
                Console.WriteLine($"{item.path}\t{item.distance}");
            }

            Console.Write("Time used:   ");
            Console.WriteLine(Timer.Stop());
        }
Ejemplo n.º 14
0
 private void prepareDataSource(string[] sources, Env env)
 {
     if ((sources != null) && (sources.Length > 0))
     {
         string[]         strArray = sources;
         ConnectionConfig config   = null;
         for (int i = 0; i < strArray.Length; i++)
         {
             string dsName = strArray[i];
             if ((dsName != null) && (dsName.Trim().Length != 0))
             {
                 config = new ConnectionConfig(dsName);
                 DBOperator @operator = config.getDBOperator();
                 @operator.Open();
                 env.setConnection(dsName, @operator.Connection, config.getDbCharset(), config.getDbType(), config.getSqlEncoding(), config.getEncoding());
             }
             else
             {
                 config = new ConnectionConfig();
                 DBOperator operator2 = config.getDBOperator();
                 operator2.Open();
                 env.setConnection(operator2.Connection);
                 env.setDBCharset(config.getDbCharset());
                 env.setDBType(config.getDbType());
                 env.setNeedTransSQLcode(config.getSqlEncoding());
                 env.setIsEncoding(config.getEncoding());
             }
         }
     }
 }
Ejemplo n.º 15
0
        public void GetClientsByManager_Valide()
        {
            DBOperator.ConnectionString = ConnectionString;

            DBOperator.DirectQuery("insert into MANAGERS values('Something', 'test_test')", false);
            int manager_ID = Convert.ToInt32(DBOperator.DirectQueryR("SELECT IDENT_CURRENT('ManagerS');", false)[0].Split("||".ToCharArray())[2]);

            DBOperator.DirectQuery("insert into CLIENTS values('Someone',0,'test_test')", false);
            int client_ID1 = Convert.ToInt32(DBOperator.DirectQueryR("SELECT IDENT_CURRENT('CLIENTS');", false)[0].Split("||".ToCharArray())[2]);

            DBOperator.DirectQuery("insert into CLIENTS values('Someone',0,'test_test')", false);
            int client_ID2 = Convert.ToInt32(DBOperator.DirectQueryR("SELECT IDENT_CURRENT('CLIENTS');", false)[0].Split("||".ToCharArray())[2]);


            DBOperator.DirectQuery($"insert into CLIENTS_MANAGERS_LINK values ({manager_ID},{client_ID1}), ({manager_ID},{client_ID2})", false);

            List <Client> checkListManagers = DBOperator.GetClientsByManager(manager_ID);

            DBOperator.DirectQuery($"delete from CLIENTS_MANAGERS_LINK where MANAGER_ID = {manager_ID} and CLIENT_ID in ({client_ID1}, {client_ID2}); " +
                                   $"delete from MANAGERS where ID = {manager_ID}; " +
                                   $"delete from CLIENTS where ID in ({client_ID1}, {client_ID2}); ",
                                   false);

            Assert.AreEqual(2, checkListManagers.Count);
        }
Ejemplo n.º 16
0
        public Hashtable sqlToHashtable(string strsql)
        {
            Hashtable hashtable = new Hashtable();

            try
            {
                this.dboperator_0 = this.connectionConfig_0.getDBOperator();
                this.dboperator_0.Open();
                Logger.debug("数据集中读出时转换SQL语句:" + strsql);
                IDataReader rs = this.runProc(this.dboperator_0, strsql);
                while (rs.Read())
                {
                    hashtable.Add(SQLTool.getStr(rs, 0, this.string_0).Trim(), SQLTool.getStr(rs, 1, this.string_0));
                }
                rs.Close();
            }
            catch (Exception exception)
            {
                throw new SqlRunException(strsql, exception.Message);
            }
            finally
            {
                try
                {
                    this.dboperator_0.Close();
                }
                catch (Exception)
                {
                }
            }
            return(hashtable);
        }
Ejemplo n.º 17
0
        public void GetClientsByProduct_Valide()
        {
            DBOperator.ConnectionString = ConnectionString;

            DBOperator.DirectQuery("insert into PRODUCTS values('Something_test', 1, 0, NULL)", false);
            int Product_ID = Convert.ToInt32(DBOperator.DirectQueryR("SELECT IDENT_CURRENT('PRODUCTS');", false)[0].Split("||".ToCharArray())[2]);

            DBOperator.DirectQuery("insert into CLIENTS values('Someone',0,'test_test')", false);
            int client_ID1 = Convert.ToInt32(DBOperator.DirectQueryR("SELECT IDENT_CURRENT('CLIENTS');", false)[0].Split("||".ToCharArray())[2]);

            DBOperator.DirectQuery("insert into CLIENTS values('Someone',0,'test_test')", false);
            int client_ID2 = Convert.ToInt32(DBOperator.DirectQueryR("SELECT IDENT_CURRENT('CLIENTS');", false)[0].Split("||".ToCharArray())[2]);


            DBOperator.DirectQuery($"insert into CLIENTS_PRODUCTS_LINK values ({client_ID1},{Product_ID}), ({client_ID2},{Product_ID})", false);

            List <Client> checkListProducts = DBOperator.GetClientsByProduct(Product_ID);

            DBOperator.DirectQuery($"delete from CLIENTS_PRODUCTS_LINK where PRODUCT_ID = {Product_ID} and CLIENT_ID in ({client_ID1}, {client_ID2}); " +
                                   $"delete from PRODUCTS where ID = {Product_ID}; " +
                                   $"delete from CLIENTS where ID in ({client_ID1}, {client_ID2}); ",
                                   false);

            Assert.AreEqual(2, checkListProducts.Count);
        }
Ejemplo n.º 18
0
        public bool FileUpload(Classes classes)
        {
            string     sql = string.Format("insert into [Classes] (Cname,Cpath) values ('{0}','{1}')", classes.Cname, classes.Cpath);
            DBOperator dbo = new DBOperator();

            return(dbo.ExecuteInsertOrUpdateSql(sql));
        }
Ejemplo n.º 19
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string rep       = comboBox1.SelectedValue.ToString();
            string condition = "";

            if (rep != "All")
            {
                condition = " Rep = '" + rep + "' and ";
            }
            string    month = DateTime.Now.AddMonths(-1).ToString("MMMMM, yyyy");
            string    year  = (DateTime.Now.Year - 1).ToString();
            string    sql   = @"select AccountNo as 'ID', Company, Contact, Phone, AltPhone
                            from ClientDetail
                            where " + condition + @"  (JobStatus in ('Current', 'Yearly','Pending') 
                                  or ((SalesTax in ('Closed(1Q/" + year + ")','Closed(2Q/" + year + ")','Closed(3Q/" + year + ")','Closed(4Q/" + year + @")') 
                                        or Payroll in ('Closed(1Q/" + year + ")','Closed(2Q/" + year + ")','Closed(3Q/" + year + ")','Closed(4Q/" + year + @")')) 
                                        and JobStatus = 'Closed' and EndDate between '1/1/" + year + "' and '12/31/" + year + @"'))
                            order by JobStatus, Accountno";
            DataTable dt    = DBOperator.QuerySql(sql);
            List <QuarterlyProfitLoss> items = DBOperator.getListFromTable <QuarterlyProfitLoss>(dt);

            reportViewer1.LocalReport.DataSources.Clear();
            ReportParameter repTitle = new ReportParameter("repTitle", "Profit and Loss - " + rep);
            ReportParameter repMonth = new ReportParameter("repMonth", "Month: " + month);

            reportViewer1.LocalReport.SetParameters(new ReportParameter[] { repTitle, repMonth });
            ReportDataSource rds = new ReportDataSource("QuarterlyProfitLoss", items);

            reportViewer1.LocalReport.DataSources.Add(rds);

            reportViewer1.RefreshReport();
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 初始化数据库信息
        /// </summary>
        /// <returns>结果</returns>
        public Result InitDatabaseInfo()
        {
            Result result = new Result();

            try
            {
                var conInfo = new BConString().GetConString(this.TaskInfo.BusinessKeyID);
                if (string.IsNullOrWhiteSpace(conInfo?.KeyID))
                {
                    result.Msg = "获取当前任务信息失败";
                    return(result);
                }

                IDBOperator op = new DBOperator();
                ////获取数据库连接
                SqlSugarClient client = null;
                ///根据链接获取此链接下所有数据库
                var dataBases = op.GetAllDataBase(conInfo.ConnectionString, ref client);
                ///根据数据库获取所有表
                if (dataBases == null || dataBases.Count == 0)
                {
                    result.Msg     = "当前链接没有数据库";
                    result.Success = true;
                    return(result);
                }

                Dictionary <string, List <Table> > dBAndTables = new Dictionary <string, List <Table> >();
                ////这里表多了会不会超时,待处理
                foreach (var item in dataBases)
                {
                    Thread.Sleep(100);
                    dBAndTables.Add(item, op.GetAllTables(item, client));
                }

                ///根据规则判断表的生成规则,并生成tables的表信息
                var tables = this.BuildTableModel(dBAndTables, conInfo);
                var res    = new BTable().AddTableBatch(tables);
                ////筛选需要定期建表的
                var           cycleTables = tables.FindAll(p => p.SplitType != SplitType.None && p.SplitType != SplitType.HASH);
                List <DBTask> tasks       = new List <DBTask>();
                cycleTables.ForEach(p => tasks.Add(new DBTask()
                {
                    BusinessKeyID = p.TabelKeyID, BusinessType = BusinessType.表建表
                }));
                var insertRes = new BTask().AddTasks(tasks);
                if (insertRes.Success)
                {
                    this.TaskInfo.NextExecuteTime = DateTime.Now.AddDays(1);
                }

                return(insertRes);
            }
            catch (Exception e)
            {
                NLog.LogManager.GetCurrentClassLogger().Error($"{e}");
                result.Msg = e.Message;
            }

            return(result);
        }
Ejemplo n.º 21
0
        public bool deletecour(string str)
        {
            string     sql = string.Format("delete from [Classes] where Cpath=\'" + str + "\'");
            DBOperator dbo = new DBOperator();

            return(dbo.ExecuteInsertOrUpdateSql(sql));
        }
Ejemplo n.º 22
0
        public string loadClob()
        {
            this.dboperator_0 = this.connectionConfig_0.getDBOperator();
            this.dboperator_0.Open();
            string str  = this.xmlDocument_0.DocumentElement.ChildNodes.Item(0).InnerText;
            string str2 = this.xmlDocument_0.DocumentElement.ChildNodes.Item(1).InnerText;
            string str3 = "";

            try
            {
                IDbCommand command = this.dboperator_0.Connection.CreateCommand();
                command.Connection  = (this.dboperator_0.Connection);
                command.CommandText = ("select " + str + " from FC_BILLZL where djid=" + str2);
                str3 = command.ExecuteScalar().ToString();
                command.Dispose();
                this.dboperator_0.Close();
            }
            catch (Exception exception)
            {
                throw exception;
            }
            finally
            {
                try
                {
                    this.dboperator_0.Close();
                }
                catch (Exception)
                {
                }
            }
            return(str3);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 功能: 返回字段最大值加1
        /// </summary>
        /// <param name="QueryString"></param>
        /// <returns></returns>
        public static int GetMaxID(string FieldName, string TableName)
        {
            if (ConnectType == DBConnectType.SqlServer)
            {
                #region sql
                string strsql = "select max(" + FieldName + ")+1 from " + TableName;
                object obj    = GetSingle(strsql);
                if (obj == null)
                {
                    return(1);
                }
                else
                {
                    return(int.Parse(obj.ToString()));
                }
                #endregion
            }
            else
            {
                DBOperator db = DBOperatorFactory.GetDBOperator(ConStr, ConnectType);
                try
                {
                    db.Open();
                    int exec = Convert.ToInt32(db.getTableId(TableName, FieldName)) + 1;
                    db.Close();

                    return(exec);
                }
                catch (System.Data.SqlClient.SqlException e)
                {
                    db.Close();
                    throw new Exception(e.Message);
                }
            }
        }
Ejemplo n.º 24
0
        //public bool registerSys(string uname, string upass, string urole, string uphone, string uemail, string udepartment)
        //{
        //    //读取插入数据后的表格,所有变量首字母小写
        //    //string sql = string.Format("insert into [User] (Uname, Upassword, Urole, Uphone, Uemail, Udept) values ('{0}','{1}', {2}, '{3}', '{4}', '{5}')", uname, upass, urole, uphone, uemail, udepartment);
        //    //DBOperator dbo = new DBOperator();
        //    //return dbo.ExecuteInsertOrUpdateSql(sql);
        //}
        public bool register(User user)
        {
            string     sql = string.Format("insert into [User] (Uname, Upassword, Urole, Uphone, Uemail, Udept) values ('{0}','{1}', {2}, '{3}', '{4}', '{5}')", user.Uname, user.Upassword, user.Urole, user.Uphone, user.Uemail, user.Udept);
            DBOperator dbo = new DBOperator();

            return(dbo.ExecuteInsertOrUpdateSql(sql));
        }
Ejemplo n.º 25
0
        public static string Load(HttpRequest Request, string sConn, string sFileName)
        {
            DBOperator oDb = null;

            oDb = DBOperatorFactory.GetDBOperator(sConn);
            return(Load(Request, oDb, sFileName));
        }
Ejemplo n.º 26
0
        private void ClientDetail_Load(object sender, EventArgs e)
        {
            string sql;

            if (Main.cUser.UserLevel >= 10)
            {
                sql = "select * from ClientDetail";
            }
            else
            {
                sql = "select * from ClientDetail where Rep='" + Main.cUser.Rep + "' or PaycheckRep='" + Main.cUser.Rep + "' or PayrollRep='" + Main.cUser.Rep + "'";
            }
            DataTable dt = DBOperator.QuerySql(sql);

            details = DBOperator.getListFromTable <KYLDB.Model.ClientDetail>(dt);
            var accNum = from acc in details
                         select acc.AccountNo;

            AccNumList.DataSource = accNum.ToList();
            var company = from acc in details
                          select acc.Customer;

            comboBox2.DataSource             = company.ToList();
            AccNumList.SelectedIndex         = 0;
            comboBox2.SelectedIndex          = 0;
            AccNumList.SelectedIndexChanged += AccNumList_SelectedIndexChanged;
            comboBox2.SelectedIndexChanged  += ComboBox2_SelectedIndexChanged;
            enableTxt(true);
        }
Ejemplo n.º 27
0
        private string DealUploadedZTBFile(string shortFileName, string fullFileName, Dictionary <string, string> customParams)
        {
            string masterID = customParams["MasterID"];
            string fileName = shortFileName;
            string fileType = Path.GetExtension(shortFileName);

            byte[] fileContent = null;
            using (FileStream fs = File.Open(fullFileName, FileMode.Open))
            {
                using (BinaryReader reader = new BinaryReader(fs))
                {
                    fs.Seek(0L, SeekOrigin.Begin);
                    fileContent = reader.ReadBytes((int)fs.Length);
                }
            }

            ConnectionStringSettings connstr = ConfigurationManager.ConnectionStrings["SparkServiceDesk_SZZJFileManagerConnectionString"];
            DBOperator             db        = DBOperatorFactory.GetDBOperator(connstr);
            SqlParameterCollection spc       = db.CreateSqlParameterCollection();

            spc.Add("@masterID", masterID);
            string bh = db.ExeSqlForString("select b.bh from gc_wd a inner join gc_jbqk b on a.工程注册号=b.工程注册号 where a.bh=@masterID", spc);

            string sql = "insert into Dwgcfjb(bh,附件名称,附件流,可选择) values(@bh, @fileName, @fileContent,'{建设负责人}')";

            spc.Add("@bh", bh);
            spc.Add("@fileName", fileName);
            spc.Add("@fileContent", fileContent);
            db.ExecuteNonQuerySql(sql, spc);

            sql = "  select max(ID) from Dwgcfjb ";

            return(db.ExeSqlForObject(sql, null).ToString());
        }
Ejemplo n.º 28
0
        /// 上移
        /// </summary>
        /// <param name="id"></param>
        /// <param name="ln">LINENO</param>
        /// <param name="id1">类型/param>
        public static void sortUp(string id)
        {
            int    id2 = 0;
            int    ln2 = 0;
            string sql = " SELECT TOP 1 menu_id,Menu_Order FROM  system_menu WHERE Menu_Order<" + int.Parse(id.Split(',')[1]) + " AND Menu_Location='top' ORDER BY Menu_Order";

            SqlDataReader dr = null;

            try
            {
                dr = DBOperator.GetInstance().ReturnReader(sql) as SqlDataReader;
                while (dr.Read())
                {
                    id2 = Convert.ToInt32(dr["menu_id"]);
                    ln2 = Convert.ToInt32(dr["Menu_Order"]);
                }
                if (!id2.Equals(0) || !ln2.Equals(0))
                {
                    string sql1 = "UPDATE system_menu SET [Menu_Order]=" + ln2 + " WHERE menu_id=" + int.Parse(id.Split(',')[0]);
                    string sql2 = "UPDATE system_menu SET [Menu_Order]=" + int.Parse(id.Split(',')[1]) + " WHERE menu_id=" + id2;
                    DBOperator.GetInstance().ExeCmd(sql1); DBOperator.GetInstance().ExeCmd(sql2);
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }finally{
                dr.Close();
            }
        }
Ejemplo n.º 29
0
 public MaxNo(ConnectionConfig connConfig, XmlDocument xdoc)
 {
     this.connectionConfig_0 = null;
     this.dboperator_0       = null;
     this.connectionConfig_0 = connConfig;
     this.xmlDocument_0      = xdoc;
 }
Ejemplo n.º 30
0
 /// <summary>
 /// 带事务执行的构造函数
 /// </summary>
 /// <param name="dbconn">The dbconn.</param>
 public EmployeeRepository(DBOperator dbConn)
 {
     this.IsAddIntoCache = false;
     this.TableName      = "Employee";
     this.OrderbyFields  = "KID DESC";
     this.KeyField       = "KID";
     base.DbConn         = dbConn;
 }