예제 #1
0
파일: CommonDAL.cs 프로젝트: sky-tc/U8
        /// <summary>
        /// 功能:RF登录
        /// </summary>
        /// <param name="dBString">登入字符串</param>
        /// <returns></returns>
        public static int PrintU8Login(out string dBString)
        {
            int result = 11;

            dBString = "";
            UFSoft.U8.Framework.Login.UI.clsLogin g_NetLogin = new UFSoft.U8.Framework.Login.UI.clsLogin();

            if (g_NetLogin.login("DP"))
            {
                //dBString = g_NetLogin.
                //UFSoft.U8.Framework.Login.UI.

                UFSoft.U8.Framework.LoginContext.UserData userData = g_NetLogin.GetLoginInfo();

                string sqlUser, sqlPassword, dataSource, catalog;

                SplitUserID(userData.ConnString, out sqlUser, out sqlPassword, out dataSource, out catalog);//解析返回数据串



                char[] a = new char[1];
                a[0]        = '\"';
                sqlUser     = sqlUser.Trim(a);
                sqlPassword = sqlPassword.Trim(a);
                dataSource  = dataSource.Trim(a);
                catalog     = catalog.Trim(a);


                dBString = "user id=" + sqlUser + ";password="******";data source=" + dataSource
                           + ";persist security info=True;initial catalog=" + catalog;
                return(0);
            }

            return(result);
        }
예제 #2
0
        private void reloginMenuItem_Click(object sender, EventArgs e)
        {
            //显示U8门户登陆界面,处理用户登陆信息
            UFSoft.U8.Framework.Login.UI.clsLogin u8LoginUI = new UFSoft.U8.Framework.Login.UI.clsLogin();
            if (!u8LoginUI.login("DP"))
            {
                MessageBox.Show("登陆失败,原因:" + u8LoginUI.ErrDescript);
                u8LoginUI.ShutDown();
                return;
            }

            //从这个类里可以获取登陆信息、数据库连接信息等等
            UFSoft.U8.Framework.LoginContext.UserData u8userdata = new UFSoft.U8.Framework.LoginContext.UserData();
            u8userdata = u8LoginUI.GetLoginInfo();

            Pubvar.gu8LoginUI      = u8LoginUI;
            Pubvar.gu8userdata     = u8userdata;
            Pubvar.gdataimporttype = "";

            //填写状态栏信息
            toolStripStatusLabel.Text             = "已登陆";
            toolStripStatususeridtext.Text        = Pubvar.gu8userdata.UserId;
            toolStripStatuscompanytext.Text       = "[" + Pubvar.gu8userdata.AccID + "]" + Pubvar.gu8userdata.AccName;
            toolStripStatusoperationdatetext.Text = Pubvar.gu8userdata.operDate;

            //隐藏tab control 及标签页
            U8tabCtl.Visible           = false;
            U8dataimporttabPage.Parent = null;
        }
예제 #3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //显示U8门户登陆界面,处理用户登陆信息
            UFSoft.U8.Framework.Login.UI.clsLogin u8LoginUI = new UFSoft.U8.Framework.Login.UI.clsLogin();
            if (!u8LoginUI.login("DP"))
            {
                MessageBox.Show("登陆失败,原因:" + u8LoginUI.ErrDescript);
                u8LoginUI.ShutDown();
                return;
            }

            //从这个类里可以获取登陆信息、数据库连接信息等等
            UFSoft.U8.Framework.LoginContext.UserData u8userdata = new UFSoft.U8.Framework.LoginContext.UserData();
            u8userdata = u8LoginUI.GetLoginInfo();

            Pubvar.gu8LoginUI      = u8LoginUI;
            Pubvar.gu8userdata     = u8userdata;
            Pubvar.gdataimporttype = "";
            Application.Run(new MainForm());
        }
예제 #4
0
파일: CommonDAL.cs 프로젝트: sky-tc/U8
        /// <summary>

        /// 时间:2010-09-01
        /// </summary>
        /// <param name="userCode">用户编码</param>
        /// <param name="password">密码</param>
        /// <param name="accid">帐套号</param>
        /// <param name="year">帐套年度</param>
        /// <param name="msgID"></param>
        /// <param name="loginTime">登入时间</param>
        /// <param name="inf"></param>
        /// <param name="loginString">登入字符串</param>
        /// <param name="dBString">数据库字符串</param>
        /// <param name="taskId">任务ID</param>
        /// <param name="errMsg">错误信息</param>
        /// <param name="loginUser">登入人</param>
        /// <param name="netLogin"></param>
        /// <param name="systemDate">系统时间</param>
        /// <param name="isTaskExc">上下岗时间权限</param>
        /// <param name="isPFReport">工序流转卡权限</param>
        /// <returns></returns>
        public static int RFLogin(string userCode, string password, string accid, string year, string msgID, DateTime loginTime, Info inf,
                                  out string loginString, out string dBString, out string taskId, out string errMsg,
                                  out string loginUser, ref UFSoft.U8.Framework.Login.UI.clsLogin netLogin
                                  , out DateTime systemDate, out bool isTaskExc, out bool isPFReport)
        {
            loginString = "";
            taskId      = "";
            loginUser   = "";
            dBString    = "";
            errMsg      = "";
            isTaskExc   = false;     //记录当前登录人员是否有修改上下岗时间的权限

            isPFReport = false;      //记录当前登录人员是否有工序流转卡完工单权限

            string ERPService  = ""; //ERP服务器地址
            string DBService   = "";
            bool   result      = false;
            string sqlUser     = "";
            string sqlPassword = "";

            systemDate = loginTime;

            string serID = msgID + "@0";     //创建加密序列号


            //string serID = "{" + Guid.NewGuid() + "}" + msgID + "@0";


            string pDate = loginTime.ToString("yyyy-MM-dd");

            try
            {
                ERPService = inf.ERPService;
                DBService  = inf.DBService;
            }
            catch (Exception ex)
            {
                errMsg = "配置文件错误" + ex.Message;
                return(-1);
            }
            U8Login.clsLoginClass login;    //创建登录对象
            netLogin = new UFSoft.U8.Framework.Login.UI.clsLogin();


            try
            {
                result = netLogin.login("DP", userCode, password, inf.ERPService, pDate, accid, serID, false); //先登录平台

                if (result)
                {
                    netLogin.WorkStationName = userCode + ":" + msgID;//ADD BY HQ 设置工作站名称

                    //netLogin.SubLogin("CJ");                              //加密服务登录用户站点 + 1

                    UFSoft.U8.Framework.LoginContext.ProductContext pcT = new UFSoft.U8.Framework.LoginContext.ProductContext();
                    pcT = netLogin.SubLogin(inf.subID);                        //加密服务登录用户站点 + 1

                    if (pcT == null)
                    {
                        errMsg = "【" + _productName + "】登录错误:" + netLogin.ErrDescript;
                        return(1);
                    }
                    taskId = netLogin.GetTaskID(inf.BarSubID);              //获得任务号
                }
                else
                {
                    errMsg = "【" + _productName + "】登录错误:" + netLogin.ErrDescript;
                    return(1);
                }

                login = new U8Login.clsLoginClass();                    //生成登录对象

                result = login.ConstructLogin(netLogin.userToken);
                result = login.Login(ref inf.BarSubID, ref accid, ref year, ref userCode, ref password, ref pDate, ref inf.ERPService, ref serID);
                if (result)
                {
                    object bDemo = false;

                    //bDemo = true; //正式版
                    //bDemo = False;    演示版


                    login.GetAccInfo(10000, ref bDemo);//判断产品是否演示版


                    isTaskExc  = true; //= login.TaskExec("FZ102013", 1, 1);             //获得上下岗时间修改权限 by zhaobo
                    isPFReport = true; // = login.TaskExec("FC06006N", 1, 1);             //获得工序流转卡权限  By zhaobo


                    if (taskId == "")
                    {
                        errMsg = "";
                    }
                    //不是演示版


                    loginUser   = login.cUserName.ToString();
                    loginString = netLogin.userToken.ToString();


                    string dataSource, catalog;
                    SplitUserID(login.UfDbName, out sqlUser, out sqlPassword, out dataSource, out catalog);//解析返回数据串


                    char[] a = new char[1];
                    a[0]        = '\"';
                    sqlUser     = sqlUser.Trim(a);
                    sqlPassword = sqlPassword.Trim(a);
                    dataSource  = dataSource.Trim(a);
                    catalog     = catalog.Trim(a);


                    dBString = "user id=" + sqlUser + ";password="******";data source=" + dataSource
                               + ";persist security info=True;initial catalog=" + catalog;

                    string tempdBstring = "user id=" + sqlUser + ";password="******";data source=" + dataSource
                                          + ";persist security info=True;initial catalog=UFSystem";
                    dBString = dBString + "|" + login.UfDbName;

                    IniU8Message(tempdBstring);

                    if (!Convert.ToBoolean(bDemo))
                    {
                        if (isDemoOver(dBString))
                        {
                            errMsg = "请购买用友U8【" + _productName + "】";
                            return(5);
                        }
                    }


                    return(0);
                }
                else
                {
                    errMsg = "错误:" + login.ShareString;
                    //
                    return(2);
                }
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
                return(-2);
            }

            // return 0;
        }
예제 #5
0
파일: APIOp.cs 프로젝트: sky-tc/U8
        /// <summary>
        /// 获取 vb login 和 .net login
        /// 可绕过login验证
        /// </summary>
        /// <param name="bd"></param>
        /// <param name="oSysLogin"></param>
        /// <param name="u8Login"></param>
        /// <returns></returns>
        private Model.DealResult GetU8LoginNew(Model.APIData bd, UFSoft.U8.Framework.Login.UI.clsLogin oSysLogin, U8Login.clsLogin u8Login)
        {
            Model.DealResult dr = new Model.DealResult();

            System.Diagnostics.Trace.WriteLine("  before  GetU8Login 判断格式 ");
            #region 判断格式  登录
            string strErr = ",请在[账套档案注册]模块中更新!";
            if (string.IsNullOrEmpty(bd.ConnectInfo.UserId))
            {
                dr.ResultMsg = "默认操作员不能为空" + strErr;
                dr.ResultNum = -1;
                Marshal.FinalReleaseComObject(u8Login);
                throw new Exception(dr.ResultMsg);
            }
            if (string.IsNullOrEmpty(bd.ConnectInfo.Source))
            {
                dr.ResultMsg = "数据源不能为空" + strErr;
                dr.ResultNum = -1;
                Marshal.FinalReleaseComObject(u8Login);
                throw new Exception(dr.ResultMsg);
            }
            if (string.IsNullOrEmpty(bd.ConnectInfo.AccId))
            {
                dr.ResultMsg = "账套号不能为空" + strErr;
                dr.ResultNum = -1;
                Marshal.FinalReleaseComObject(u8Login);
                throw new Exception(dr.ResultMsg);
            }
            if (string.IsNullOrEmpty(bd.ConnectInfo.Srv))
            {
                dr.ResultMsg = "服务器地址不能为空" + strErr;
                dr.ResultNum = -1;
                Marshal.FinalReleaseComObject(u8Login);
                throw new Exception(dr.ResultMsg);
            }
            if (string.IsNullOrEmpty(bd.ConnectInfo.YearId))
            {
                dr.ResultMsg = "登陆年度不能为空" + strErr;
                dr.ResultNum = -1;
                Marshal.FinalReleaseComObject(u8Login);
                throw new Exception(dr.ResultMsg);
            }
            else
            {
                try { int.Parse(bd.ConnectInfo.YearId); }
                catch
                {
                    dr.ResultMsg = "登陆年度格式错误:" + bd.ConnectInfo.YearId + strErr;
                    dr.ResultNum = -1;
                    Marshal.FinalReleaseComObject(u8Login);
                    throw new Exception(dr.ResultMsg);
                }
            }
            DbHelperSQLP dsp    = new DbHelperSQLP(bd.ConnectInfo.Constring);
            string       strSql = "SELECT 1 FROM UFSystem.dbo.UA_AccountDatabase A JOIN UFSystem.dbo.UA_Account B ON A.cAcc_Id=B.cAcc_Id WHERE A.cAcc_Id='" + bd.ConnectInfo.AccId + "' ";
            if (!dsp.Exists(strSql))
            {
                dr.ResultMsg = "登陆失败,原因:账套 " + bd.ConnectInfo.AccId + " 在 " + bd.ConnectInfo.Srv + " 上不存在";
                dr.ResultNum = -1;
                Marshal.FinalReleaseComObject(u8Login);
                throw new Exception(dr.ResultMsg);
            }
            #endregion

            System.Diagnostics.Trace.WriteLine("  after  GetU8Login 判断格式 ");


            bool   bLogined;
            string beginDate;

            oSysLogin = new UFSoft.U8.Framework.Login.UI.clsLogin();

            beginDate            = "";      //GetMonthBegindate(acc_ID, iYear, "12")  //用12期间构造login,12期间必有
            oSysLogin.LanguageID = "zh-CN"; // GetAccountLoginLocaleID(modUtility.GetDbName(acc_ID, iYear))

            string subId    = U8.Interface.Bus.SysInfo.subId;
            string userId   = bd.ConnectInfo.UserId;
            string accId    = bd.ConnectInfo.Source + "@" + bd.ConnectInfo.AccId;
            string yearId   = bd.ConnectInfo.YearId;
            string password = bd.ConnectInfo.Password;
            string date     = bd.ConnectInfo.Date;
            string srv      = bd.ConnectInfo.sSrv;
            string serial   = bd.ConnectInfo.Serial;

            bLogined = oSysLogin.login(subId, userId, password, srv, date, accId, serial);

            if (!bLogined)
            {
                strErr = oSysLogin.ErrDescript; //& g_fmtr.GetString("String.U8.AA.Admin.4671", g_args)
                //'strErr = oSysLogin.ErrDescript & "内置用户密码不正确!"
                //'Call WriteTransferLog(g_ologin.cAcc_ID, g_ologin.cAccName, g_ologin.cIyear, "", "准备年结环境时出现错误,错误描述:" & oSyslogin.ErrDescript & "内置用户密码不正确!")
                dr.ResultMsg = "登陆失败,原因:" + strErr;
                dr.ResultNum = -1;
                Marshal.FinalReleaseComObject(u8Login);
                throw new Exception(dr.ResultMsg);
            }

            UFSoft.U8.Framework.LoginContext.ProductContext oLoginContext;
            oLoginContext = new UFSoft.U8.Framework.LoginContext.ProductContext();
            oLoginContext = oSysLogin.SubLogin(U8.Interface.Bus.SysInfo.subId);

            if (null == oLoginContext)
            {
                strErr = oSysLogin.ErrDescript;
                //'MsgBox oSyslogin.ErrDescript
                //'Call WriteTransferLog(g_ologin.cAcc_ID, g_ologin.cAccName, g_ologin.cIyear, "", "准备年结环境时出现错误,错误描述:" & oSyslogin.ErrDescript)
                dr.ResultMsg = "登陆失败,原因:" + strErr;
                dr.ResultNum = -1;
                Marshal.FinalReleaseComObject(u8Login);
                throw new Exception(dr.ResultMsg);
            }

            //u8Login = new U8Login.clsLogin();

            if (!u8Login.ConstructLogin(oSysLogin.userToken))
            {
                strErr = u8Login.ShareString;
                //'Call WriteTransferLog(g_ologin.cAcc_ID, g_ologin.cAccName, g_ologin.cIyear, "", "准备年结环境时出现错误,错误描述:" & oLogin.ShareString)
                dr.ResultMsg = "登陆失败,原因:" + strErr;
                dr.ResultNum = -1;
                Marshal.FinalReleaseComObject(u8Login);
                throw new Exception(dr.ResultMsg);
            }

            if (!u8Login.Login(ref subId, ref accId, ref yearId, ref userId, ref password, ref date, ref srv, ref serial))
            {
                System.Diagnostics.Trace.WriteLine("    GetU8Login  failed  ");
                dr.ResultMsg = "登陆失败,原因:" + u8Login.ShareString;
                if (u8Login.ShareString.IndexOf("年度") > 0 || u8Login.ShareString.IndexOf("日期") > 0)
                {
                    dr.ResultMsg += " - " + date;
                }
                dr.ResultNum = -1;
                Marshal.FinalReleaseComObject(u8Login);
                throw new Exception(dr.ResultMsg);
            }


            return(dr);
        }
예제 #6
0
        public static U8LoginInfor DoLogin(string cAccId, string cYear, string appServer, string dataSource,
                                           string sdate, string userid, string pass, string curlangid)
        {
            bool   bmerp = false;
            string subid = "AS";

            if (userid.Trim().Length == 0)
            {
                userid = "ASUSER";
                pass   = "******";
            }
            else
            {
                bmerp = true;
            }
            string serial    = "";
            string accid     = dataSource + "@" + cAccId;
            string year      = cYear;
            string appserver = appServer;

            if (sdate.Trim().Length == 0)
            {
                sdate = DateTime.Now.ToString("yyyy-MM-dd");
            }
            var login = new UFSoft.U8.Framework.Login.UI.clsLogin();

            if (curlangid.Length > 0)
            {
                login.LanguageID = curlangid;
            }
            if (login.login(subid, userid, pass, appserver, sdate, accid, serial))
            {
                #region 将login缓存到MERP中
                var token       = "";
                var xmlDocument = new XmlDocument();
                xmlDocument.LoadXml(login.userToken);
                var doc       = xmlDocument.DocumentElement;
                var tokennode = doc.SelectSingleNode("/ufsoft/data/SignedToken");
                if (tokennode != null)
                {
                    token = tokennode.Attributes["id"].Value;
                }
                ContextObj context = new ContextObj();
                context.Login = login;
                ContextManager.SingletonInstance.Add(token, context);
                #endregion
                clsLogin _u8LoginCls = new clsLoginClass();
                _u8LoginCls.ConstructLogin(login.userToken);
                return(new U8LoginInfor(_u8LoginCls));
                //m_LoginCollection[hash] = login.userToken;
                //logger.Info(m_LoginCollection[hash].GetType().FullName);
                //_userdata = login.GetLoginInfo();
            }
            else
            {
                var sb = new StringBuilder();
                sb.AppendLine("登陆失败,错误信息:");
                sb.AppendLine("subid:" + subid);
                sb.AppendLine("accid:" + accid);
                sb.AppendLine("year:" + year);
                sb.AppendLine("userid:" + userid);
                sb.AppendLine("pass:"******"sdate:" + sdate);
                sb.AppendLine("appserver:" + appserver);
                sb.AppendLine("serial:" + serial);
                sb.AppendLine("login.ErrDescript:" + login.ErrDescript);
                throw new Exception(sb.ToString());
            }
        }