Exemple #1
0
        /// <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;
        }