//初始化数据库
        private void InitDb()
        {
            //数据库连接方式取值方法一:固定链接串
            //string connectionString=@"ConnectType=SqlClient;Server=10.0.16.168\upty;Database=NG0054;User ID=sa;Password=123456";
            //string connectionString = "ConnectType=SqlClient;Server=10.0.18.21;Database=NG0008;User ID=sa;Password="******"ConnectType=SqlClient;Server=10.0.17.118;Database=NG0004;User ID=sa;Password=psoft";

            //二:从web.config取值
            //string connectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();

            //三:从config目录下文件DataBases.xml中取值
            DBConnectionStringBuilder dbbuilder = new DBConnectionStringBuilder();
            //var userConn = dbbuilder.GetDefaultConnString(); //主帐套连接串

            var result   = string.Empty;
            var dbname   = dbbuilder.DefaultDB;
            var pubConn  = dbbuilder.GetMainConnStringElement(0, out result, false);          //获取主数据库连接串 NGSoft
            var userConn = dbbuilder.GetAccConnstringElement(0, dbname, pubConn, out result); //获取默认数据库连接串 NG0001

            ConnectionInfoService.SetSessionConnectString(userConn);

            I6WebAppInfo appInfo = new I6WebAppInfo();

            appInfo.PubConnectString  = pubConn;
            appInfo.UserConnectString = userConn;
            appInfo.LoginID           = "xyp";
            appInfo.UserName          = "******";
            appInfo.OCode             = "001";
            appInfo.UCode             = dbname.Substring(2);
            appInfo.DbName            = dbname;
            //appInfo.UserID = 2;
            //appInfo.OrgID = 1;

            string uid = DbHelper.GetString(userConn, string.Format("select phid from fg3_user where userno='{0}'", appInfo.LoginID));
            string oid = DbHelper.GetString(userConn, string.Format("select phid from fg_orglist where ocode='{0}'", appInfo.OCode));

            if (!string.IsNullOrWhiteSpace(uid))
            {
                appInfo.UserID = Convert.ToInt64(uid);
            }
            else
            {
                appInfo.UserID = 1;
            }

            if (!string.IsNullOrWhiteSpace(oid))
            {
                appInfo.OrgID = Convert.ToInt64(oid);
            }
            else
            {
                appInfo.OrgID = 1;
            }

            System.Web.HttpContext.Current.Session["NGWebAppInfo"] = appInfo;
        }
Exemple #2
0
        private string WebCheck(out string msg, out bool loginflag, string svrName, string database, string logid, string pwd, string isOnlineCheck = "")
        {
            var appInfo  = new I6WebAppInfo();
            var userConn = proxy.WebCheck(out msg, out loginflag, svrName, database, logid, pwd, appInfo, isOnlineCheck);

            if (!string.IsNullOrEmpty(userConn))
            {
                if (msg == "UserNoHaveOrg")
                {
                    System.Web.HttpContext.Current.Session[WebNGWebAppInfo] = appInfo;
                    SimulateWebLogin(appInfo.UCode.Replace("NG", ""), appInfo.OCode, appInfo.LoginID, appInfo);

                    string guid = string.Empty;
                    if (appInfo.UserType != UserType.System)
                    {
                        if (!proxy.SetLoginUsers("", ref guid, ref msg))//注册在线用户
                        {
                            loginflag = false;
                        }
                    }
                    else
                    {
                        guid = Guid.NewGuid().ToString();
                    }
                    System.Web.HttpContext.Current.Session[LoginMark] = guid;
                }
                else if (string.IsNullOrEmpty(msg))
                {
                    System.Web.HttpContext.Current.Session[UPAppInfoNameInSession] = appInfo;
                    System.Web.HttpContext.Current.Session[WebNGWebAppInfo]        = appInfo;
                    ConnectionInfoService.SetSessionConnectString(userConn);//初始化2.0的dbhelper
                    SimulateWebLogin(appInfo.UCode.Replace("NG", ""), appInfo.OCode, appInfo.LoginID, appInfo);

                    string guid = string.Empty;
                    if (appInfo.UserType != UserType.System)
                    {
                        if (!proxy.SetLoginUsers("", ref guid, ref msg))//注册在线用户
                        {
                            loginflag = false;
                        }
                    }
                    else
                    {
                        guid = Guid.NewGuid().ToString();
                    }
                    System.Web.HttpContext.Current.Session[LoginMark] = guid;
                }
            }
            return(userConn);
        }
Exemple #3
0
        public static void MyClassInitialize(TestContext testContext)
        {
            HttpSimulator hs = new HttpSimulator("/", @"E:\Enterprise\Enterprise3\Enterprise3.Test\Enterprise3.NHORM.Test");

            hs.SimulateRequest();

            I6WebAppInfo appInfo = new I6WebAppInfo
            {
                UserType          = UserType.OrgUser,
                PubConnectString  = ConfigHelper.GetString("PubConnectString"),
                UserConnectString = ConfigHelper.GetString("UserConnectString"),
                LoginID           = "007",
                UserName          = "******",
                OCode             = "001",
                OrgName           = "001组织",
                UCode             = "NG0003" //Northwind
            };

            //MockHttpContext.Init();

            System.Web.HttpContext.Current.Session["NGWebAppInfo"] = appInfo;
            ConnectionInfoService.SetSessionConnectString(ConfigHelper.GetString("UserConnectString"));
        }
Exemple #4
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="requestContext">请求上下文</param>
        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            var isSso = System.Web.HttpContext.Current.Request.Params["issso"] == null ? "" : System.Web.HttpContext.Current.Request.Params["issso"].ToString();

            if (isSso == "1")
            {
                var logId   = System.Web.HttpContext.Current.Request.Params["logno"] == null ? "" : System.Web.HttpContext.Current.Request.Params["logno"].ToString();
                var logName = System.Web.HttpContext.Current.Request.Params["logname"] == null ? "" : System.Web.HttpContext.Current.Request.Params["logname"].ToString();
                var oCode   = System.Web.HttpContext.Current.Request.Params["ocode"] == null ? "" : System.Web.HttpContext.Current.Request.Params["ocode"].ToString();
                var uCode   = System.Web.HttpContext.Current.Request.Params["ucode"] == null ? "" : System.Web.HttpContext.Current.Request.Params["ucode"].ToString();

                //comment by ljy 2018.01.17 特变要求预览能跟正式发布单据一样操作
                //ViewBag.IsSso = "true";
                ViewBag.IsSso = "false";

                try
                {
                    //设置NG3的i6WebInfoBase对象
                    var dbbuilder = new DBConnectionStringBuilder();
                    var dbName    = string.Empty;

                    //没有传帐套号过来
                    if (string.IsNullOrWhiteSpace(uCode))
                    {
                        dbName = dbbuilder.DefaultDB;  //如NG0001
                        uCode  = dbName.Substring(2);  //如0001
                    }
                    else
                    {
                        dbName = "NG" + uCode;
                    }

                    var result   = string.Empty;
                    var pubConn  = dbbuilder.GetMainConnStringElement(0, out result, false);          //获取主数据库连接串 NGSoft
                    var userConn = dbbuilder.GetAccConnstringElement(0, dbName, pubConn, out result); //获取默认数据库连接串 NG0001

                    var i6AppInfo = new I6WebAppInfo()
                    {
                        UserType          = UserType.OrgUser,
                        PubConnectString  = pubConn,
                        UserConnectString = userConn,
                        LoginID           = logId,
                        UserName          = logName,
                        OCode             = oCode,
                        UCode             = uCode,
                        DbName            = dbName,
                        UserID            = Convert.ToInt64(DbHelper.GetString(userConn, string.Format("select phid from fg3_user where userno='{0}'", logId))),
                        OrgID             = Convert.ToInt64(DbHelper.GetString(userConn, string.Format("select phid from fg_orglist where ocode='{0}'", oCode)))
                    };

                    System.Web.HttpContext.Current.Session["NGWebAppInfo"] = i6AppInfo;
                    ConnectionInfoService.SetSessionConnectString(i6AppInfo.UserConnectString);
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message); //应该加入日志,设置i6WebAppInfo异常。
                }
            }

            base.Initialize(requestContext);

            //调老丰AFCommonController的InitialAF(),里面含WorkFlowHandling()
            string dbnameStr = NG3.AppInfoBase.DbName;

            if (string.IsNullOrWhiteSpace(dbnameStr))
            {
                dbnameStr = base.NGPreCompileHandling();
            }
            base.InitialAF(dbnameStr);
        }