Example #1
0
        //U8EnvContext envContext = new U8EnvContext();
        public override object CallFunction(string cMenuId, string cMenuName, string cAuthId, string cCmdLine)
        {
            //canshu.uLogin = LoginObject;

            //赋值给公共变量 constr
            canshu.userName = LoginObject.GetLoginInfo().UserName;
            //canshu.conStr = LoginObject.GetLoginInfo().ConnString;
            //canshu.conStr = canshu.conStr.Substring(canshu.conStr.IndexOf("data"), canshu.conStr.IndexOf(";Conn") + 2);
            string userToken = LoginObject.userToken;

            //string accid = LoginObject.GetLoginInfo().AccID;
            //string iyear = LoginObject.GetLoginInfo().iYear;
            //string ztdb = "//ZT" + accid + "//" + iyear;
            canshu.acc = LoginObject.GetLoginInfo().AccID;


            //U8Login.clsLogin u8Login = new U8Login.clsLogin();
            //String sSubId = "AS";
            //String sAccID = LoginObject.GetLoginInfo().AccID;
            //String sYear = LoginObject.GetLoginInfo().iYear;
            //String sUserID = LoginObject.GetLoginInfo().UserId;
            //String sPassword =LoginObject.GetLoginInfo().Password;
            //String sDate = LoginObject.GetLoginInfo().operDate;
            //String sServer = LoginObject.GetLoginInfo().AppServer;
            ////String sSerial = "";
            //if (!u8Login.Login(ref sSubId, ref sAccID, ref sYear, ref sUserID, ref sPassword, ref sDate, ref sServer))
            ////if (!uLogin.Login(ref sSubId, ref sAccID, ref sYear, ref sUserID, ref sPassword, ref sDate, ref sServer))
            //{
            //    MessageBox.Show("登陆失败,原因:" + u8Login.ShareString);
            //    Marshal.FinalReleaseComObject(u8Login);
            //    return "0";
            //}

            //canshu.conStr = u8Login.UFDataConnstringForNet;

            U8Login.clsLogin u8Login2 = new U8Login.clsLoginClass();
            u8Login2.ConstructLogin(LoginObject.userToken);
            canshu.conStr = u8Login2.UFDataConnstringForNet;
            //////u8Login.UfDbPath = ztdb;
            canshu.u8Login = u8Login2;
            //U8Login.clsLogin u8Login = new U8Login.clsLoginClass();
            //u8Login.ConstructLogin(userToken);
            ////u8Login.UfDbPath = ztdb;

            //canshu.u8Login = u8Login;


            //MessageBox.Show(canshu.conStr);
            INetUserControl mycontrol = new MyNetUserControl();

            mycontrol.Title = cMenuName;
            base.ShowEmbedControl(mycontrol, cMenuId, true);



            return(null);
        }
Example #2
0
        /// <summary>
        /// 登录帐套_得到连接
        /// </summary>
        private void Login_Uf()
        {
            SetString.SQLConn = null;
            DLL_Sql.log.Info("开始登录用友");
            m_Login = new U8Login.clsLoginClass();
            // m_Login.Login()
            String sSubId    = "WA";     //登陆总账
            String sAccID    = null;
            String sYear     = null;
            String sUserID   = null;
            String sPassword = null;
            String sDate     = null;
            String sServer   = null;
            String sSerial   = "";

            try
            {
                if (!m_Login.Login(ref sSubId, ref sAccID, ref sYear, ref sUserID, ref sPassword, ref sDate, ref sServer, ref sSerial))
                {
                    DLL_Sql.log.Info("登陆失败,原因:" + m_Login.ShareString);
                    MessageBox.Show("登陆失败,原因:" + m_Login.ShareString);
                    this.Close();
                    //Marshal.FinalReleaseComObject(m_Login);
                    return;
                }
            }
            catch (Exception ex)
            {
                DLL_Sql.log.Error("控件操作失败! 程序退出!", ex);
                MessageBox.Show("登录控件操作失败!!");
                this.Close();
                return;
                //throw;
            }

            DLL_Sql.log.Info("登录成功");
            //SysDataLog.jsonwriteobj(m_Login);
            //SysDataLog.jsonwriteobj(m_Login.UfSystemDb);
            //DLL_Sql.log.Info(m_Login.UfSystemDb);
            //SysDataLog.jsonwriteobj(m_Login.UfSystemDb);
            SetString.SQLConn = m_Login.UfDbName.Substring(17);
            HongHu.DBUtility.DbHelperSQL.connectionString = SetString.SQLConn;
            DLL_Sql.log.Info("SQLConn=" + SetString.SQLConn);
            //测试连接
            if (SqlHelper.TestConnStr(SetString.SQLConn) != null)
            {
                MessageBox.Show("连接数据库失败!");
                DLL_Sql.log.Info("连接数据库失败");
                this.Close();
                return;
            }
            Objectm_Login = m_Login;
        }
Example #3
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;
        }