Beispiel #1
0
        //public void GetMenu(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        //{
        //    string User_Name = Data["EMP_NO"].ToString();
        //    MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow();
        //    try
        //    {
        //        LogicObject.Privilege lu = new LogicObject.Privilege();
        //        List<Privileges> pi= lu.GetMenu(User_Name, SFCDB);
        //        StationReturn.Status = StationReturnStatusValue.Pass;
        //        StationReturn.Message = "获取权限列表成功!!!";
        //        StationReturn.Data = pi;
        //    }
        //    catch(Exception ex)
        //    {
        //        StationReturn.Status = StationReturnStatusValue.Fail;
        //        StationReturn.Message = "获取权限列表失败!!!该用户可能没有任何权限!!!";
        //        StationReturn.Data = ex.Message;
        //    }
        //    finally
        //    {
        //        this.DBPools["SFCDB"].Return(SFCDB);
        //    }
        //}


        public void CreatMenuId(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow();
            LogicObject.User    lu    = new LogicObject.User();

            lu.CreatMenuId(Data, SFCDB, StationReturn);
            this.DBPools["SFCDB"].Return(SFCDB);
        }
Beispiel #2
0
        /// <summary>
        /// 登錄API
        /// </summary>
        /// <param name="requestValue"></param>
        /// <param name="Data"></param>
        /// <param name="StationReturn"></param>
        public void Login(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            string  User_Name = Data["User_Name"].ToString();/// EMP_NAME  IS EMP_NO
            string  PWD       = Data["Password"].ToString();
            DataSet res       = new DataSet();

            Language = Data["Language"].ToString();
            MESReturnMessage.Language = Language;
            LoginReturn lr = new LoginReturn();

            MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow();

            MESDataObject.Module.T_c_user GetLoginInformation = new MESDataObject.Module.T_c_user(SFCDB, this.DBTYPE);
            //   string strSql = $@" select * from C_USER where EMP_NO='{User_Name}' and EMP_PASSWORD='******' ";
            //MESDataObject.Module.Row_c_user user = GetPassword.getC_Userbyempno("TEST",SFCDB,this.DBTYPE);

            DataTable           dt   = GetLoginInformation.SelectC_Userbyempno(User_Name, SFCDB, this.DBTYPE);
            List <c_user_model> lsit = new List <c_user_model>();

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow item in dt.Rows)
                {
                    lsit.Add(new c_user_model
                    {
                        ID            = item["ID"].ToString(),
                        FACTORY       = item["FACTORY"].ToString(),
                        BU_NAME       = item["BU_NAME"].ToString(),
                        EMP_NO        = item["EMP_NO"].ToString(),
                        EMP_NAME      = item["EMP_NAME"].ToString(),
                        EMP_PASSWORD  = item["EMP_PASSWORD"].ToString(),
                        EMP_LEVEL     = item["EMP_LEVEL"].ToString(),
                        DPT_NAME      = item["DPT_NAME"].ToString(),
                        POSITION_NAME = item["POSITION_NAME"].ToString(),
                        MAIL_ADDRESS  = item["MAIL_ADDRESS"].ToString(),
                        PHONE_NUMBER  = item["PHONE_NUMBER"].ToString(),
                        LOCATION      = item["LOCATION"].ToString(),
                        LOCK_FLAG     = item["LOCK_FLAG"].ToString(),
                        AGENT_EMP_NO  = item["AGENT_EMP_NO"].ToString(),
                        EMP_DESC      = item["EMP_DESC"].ToString(),
                        EDIT_EMP      = item["EDIT_EMP"].ToString(),
                        EMP_EN_NAME   = item["EMP_EN_NAME"].ToString()
                    }
                             );
                }
            }

            LogicObject.User lu = new LogicObject.User();
            //if (user.EMP_PASSWORD == user.EMP_PASSWORD)
            if (true)
            {
                string token1     = DateTime.Now.ToString("yyyyMMddHHmmss");
                string token2     = rand.Next(100, 999).ToString();
                char[] TokenChars = (token1 + token2).ToArray();
                byte[] TokenBytes = Encoding.Default.GetBytes(TokenChars);
                string TokenBas64 = Convert.ToBase64String(TokenBytes);
                StationReturn.Status  = StationReturnStatusValue.Pass;
                StationReturn.Message = "登錄成功";
                LoginUser             = lu;
                //lr = new LoginReturn() { Token = TokenBas64, User_ID = user.EMP_NO};
                lr = new LoginReturn()
                {
                    Token = TokenBas64, User_ID = LoginUser.EMP_NO
                };
            }
            else
            {
                StationReturn.Status  = StationReturnStatusValue.Fail;
                StationReturn.Message = "登錄失敗!密碼錯誤或用戶名不存在!!";
            }
            StationReturn.Data = lr;
            _DBPools["SFCDB"].Return(SFCDB);
        }