Пример #1
0
        /// <summary>
        /// 更新用戶信息
        /// </summary>
        public void UpdateInformation(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow();

            MESDataObject.Module.T_c_user   GetInformation = new MESDataObject.Module.T_c_user(SFCDB, DB_TYPE_ENUM.Oracle);
            MESDataObject.Module.Row_c_user InformationRow = (MESDataObject.Module.Row_c_user)GetInformation.NewRow();

            string EMP_NO       = Data["EMP_NO"].ToString();
            string EMP_PASSWORD = Data["EMP_PASSWORD"].ToString();

            InformationRow = (MESDataObject.Module.Row_c_user)GetInformation.getC_Userbyempno(EMP_NO, SFCDB, DB_TYPE_ENUM.Oracle);


            if (InformationRow != null)
            {
                InformationRow.EMP_PASSWORD = Data["EMP_PASSWORD"].ToString();
                string strRet = SFCDB.ExecSQL(InformationRow.GetUpdateString(DB_TYPE_ENUM.Oracle));
                StationReturn.Status  = StationReturnStatusValue.Pass;
                StationReturn.Message = "成功更新用戶信息!";
                StationReturn.Data    = "";
            }
            else
            {
                StationReturn.Status  = StationReturnStatusValue.Fail;
                StationReturn.Message = "無此用戶信息!";
            }
            this.DBPools["SFCDB"].Return(SFCDB);
        }
Пример #2
0
        /// <summary>
        /// 查詢用戶信息
        /// </summary>
        public void SelectInformation(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow();

            MESDataObject.Module.T_c_user   GetInformation = new MESDataObject.Module.T_c_user(SFCDB, DB_TYPE_ENUM.Oracle);
            MESDataObject.Module.Row_c_user InformationRow = (MESDataObject.Module.Row_c_user)GetInformation.NewRow();

            string    EMP_NO = Data["EMP_NO"].ToString();
            DataTable dt     = GetInformation.SelectC_Userbyempno(EMP_NO, SFCDB, DB_TYPE_ENUM.Oracle);
            Dictionary <string, string> dic = new Dictionary <string, string>();

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Columns.Count; i++)
                {
                    dic.Add(dt.Columns[i].ColumnName, dt.Rows[0][i].ToString());
                }

                StationReturn.Status  = StationReturnStatusValue.Pass;
                StationReturn.Message = "成功取到用戶信息!";
                StationReturn.Data    = dic;
            }
            else
            {
                StationReturn.Status  = StationReturnStatusValue.Fail;
                StationReturn.Message = "無此用戶信息!";
            }

            this.DBPools["SFCDB"].Return(SFCDB);
        }
Пример #3
0
        /// <summary>
        /// 刪除用戶信息
        /// </summary>
        public void DeleteInformation(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow();

            MESDataObject.Module.T_c_user   GetInformation = new MESDataObject.Module.T_c_user(SFCDB, DB_TYPE_ENUM.Oracle);
            MESDataObject.Module.Row_c_user InformationRow = (MESDataObject.Module.Row_c_user)GetInformation.NewRow();

            string        EMP_NO = "";
            List <string> list   = new List <string>();

            for (int i = 0; i < Data["EMP_NO"].Count(s => s != null); i++)
            {
                list.Add(Data["EMP_NO"][i].ToString());
                EMP_NO += "'" + Data["EMP_NO"][i].ToString() + "',";
            }
            EMP_NO         = EMP_NO.TrimEnd(',');
            InformationRow = (MESDataObject.Module.Row_c_user)GetInformation.getC_Userbyempno(EMP_NO, SFCDB, DB_TYPE_ENUM.Oracle);


            if (InformationRow != null)
            {
                string strRet = SFCDB.ExecSQL(InformationRow.GetDeleteString(DB_TYPE_ENUM.Oracle));

                StationReturn.Status  = StationReturnStatusValue.Pass;
                StationReturn.Message = "成功刪除用戶信息!";
                StationReturn.Data    = "";
            }
            else
            {
                StationReturn.Status  = StationReturnStatusValue.Fail;
                StationReturn.Message = "無此用戶信息!";
            }

            this.DBPools["SFCDB"].Return(SFCDB);
        }
Пример #4
0
        /// <summary>
        /// 取回用戶密碼
        /// </summary>
        public void GetPassword(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow();

            MESDataObject.Module.T_c_user   GetPassword = new MESDataObject.Module.T_c_user(SFCDB, DB_TYPE_ENUM.Oracle);
            MESDataObject.Module.Row_c_user Resetrow    = (MESDataObject.Module.Row_c_user)GetPassword.NewRow();

            string EMP_NO = Data["EMP_NO"].ToString();
            Dictionary <string, string> dic = new Dictionary <string, string>();

            Resetrow = GetPassword.getC_Userbyempno(EMP_NO, SFCDB, DB_TYPE_ENUM.Oracle);

            if (Resetrow != null)
            {
                ///缺發送EMAIL 或者短信功能
                dic.Add("EMP_PASSWORD", Resetrow.EMP_PASSWORD.ToString());
                StationReturn.Status  = StationReturnStatusValue.Pass;
                StationReturn.Message = "取回成功,密碼已發送至郵箱!";
                StationReturn.Data    = dic;
            }
            else
            {
                StationReturn.Status  = StationReturnStatusValue.Fail;
                StationReturn.Message = "無此用戶!";
            }

            this.DBPools["SFCDB"].Return(SFCDB);
        }
Пример #5
0
        public void Login(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            string  EMP_NO  = Data["EMP_NO"].ToString();
            string  PWD     = Data["Password"].ToString();
            string  BU_NAME = Data["BU_NAME"].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   GetLoginUser = new MESDataObject.Module.T_c_user(SFCDB, this.DBTYPE);
            MESDataObject.Module.Row_c_user rcu          = (Row_c_user)GetLoginUser.NewRow();
            rcu = GetLoginUser.getC_Userbyempno(EMP_NO, SFCDB, this.DBTYPE);
            if (rcu == null)
            {
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000010";
                _DBPools["SFCDB"].Return(SFCDB);
                return;
            }
            c_user_info user_info = new c_user_info();

            user_info = GetLoginUser.GetLoginUser(EMP_NO, SFCDB);

            LogicObject.User lu = new LogicObject.User();
            if (PWD == rcu.EMP_PASSWORD)
            {
                lu.ID        = user_info.ID;
                lu.FACTORY   = user_info.FACTORY;
                lu.BU        = user_info.BU_NAME;
                lu.EMP_NO    = user_info.EMP_NO;
                lu.EMP_LEVEL = user_info.EMP_LEVEL;
                lu.DPT_NAME  = user_info.DPT_NAME;
                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.MessageCode = "MES00000009";
                LoginUser = lu;
                //lr = new LoginReturn() { Token = TokenBas64, User_ID = user.EMP_NO};
                lr = new LoginReturn()
                {
                    Token = TokenBas64, User_ID = LoginUser.EMP_NO, UserInfo = user_info
                };
            }
            else
            {
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000010";
            }
            StationReturn.Data = lr;
            _DBPools["SFCDB"].Return(SFCDB);
        }
Пример #6
0
        /// <summary>
        /// 創建新用戶
        /// </summary>
        /// <param name="requestValue"></param>
        /// <param name="Data"></param>
        /// <param name="StationReturn"></param>
        public void CreateNewUser(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow();

            MESDataObject.Module.T_c_user USER = new MESDataObject.Module.T_c_user(SFCDB, DB_TYPE_ENUM.Oracle);

            MESDataObject.Module.Row_c_user UserRow = (MESDataObject.Module.Row_c_user)USER.NewRow();

            UserRow.ID                   = USER.GetNewID(BU, SFCDB);
            UserRow.FACTORY              = Data["FACTORY"].ToString();
            UserRow.BU_NAME              = Data["BU_NAME"].ToString();
            UserRow.EMP_NO               = Data["EMP_NO"].ToString();
            UserRow.EMP_PASSWORD         = Data["EMP_PASSWORD"].ToString();
            UserRow.EMP_NAME             = Data["EMP_NAME"].ToString();
            UserRow.EMP_LEVEL            = Data["EMP_LEVEL"].ToString();
            UserRow.DPT_NAME             = Data["DPT_NAME"].ToString();
            UserRow.POSITION_NAME        = Data["POSITION_NAME"].ToString();
            UserRow.MAIL_ADDRESS         = Data["MAIL_ADDRESS"].ToString();
            UserRow.PHONE_NUMBER         = Data["PHONE_NUMBER"].ToString();
            UserRow.LOCATION             = Data["LOCATION"].ToString();
            UserRow.LOCK_FLAG            = "N";
            UserRow.AGENT_EMP_NO         = Data["AGENT_EMP_NO"].ToString();
            UserRow.CHANGE_PASSWORD_TIME = DateTime.Now;
            UserRow.EMP_DESC             = Data["EMP_DESC"].ToString();
            UserRow.EDIT_TIME            = DateTime.Now;
            UserRow.EDIT_EMP             = Data["EDIT_EMP"].ToString();
            UserRow.EMP_EN_NAME          = Data["EMP_EN_NAME"].ToString();

            DataTable userstr = new DataTable();

            userstr = USER.SelectC_Userbyempno(UserRow.EMP_NO, SFCDB, DB_TYPE_ENUM.Oracle);
            if (userstr.Rows.Count != 0)
            {
                StationReturn.Status  = StationReturnStatusValue.Fail;
                StationReturn.Message = "註冊失敗,已存在該用戶";
            }
            else
            {
                string strRet = SFCDB.ExecSQL(UserRow.GetInsertString(DB_TYPE_ENUM.Oracle));

                if (strRet == "1")
                {
                    StationReturn.Status  = StationReturnStatusValue.Pass;
                    StationReturn.Message = "註冊成功!";
                }
                else
                {
                    StationReturn.Status  = StationReturnStatusValue.Fail;
                    StationReturn.Message = "註冊失敗!";
                }
            }

            this.DBPools["SFCDB"].Return(SFCDB);
        }
Пример #7
0
        /// <summary>
        /// 查詢用戶信息
        /// </summary>
        public void SelectInformation(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow();

            MESDataObject.Module.T_c_user   GetInformation = new MESDataObject.Module.T_c_user(SFCDB, this.DBTYPE);
            MESDataObject.Module.Row_c_user InformationRow = (MESDataObject.Module.Row_c_user)GetInformation.NewRow();
            try
            {
                string EMP_NO = Data["EMP_NO"].ToString();
                List <c_user_model> LoadUsetInfolsit = new List <c_user_model>();
                LoadUsetInfolsit     = GetInformation.SelectUserInfomation(EMP_NO, SFCDB);
                StationReturn.Status = StationReturnStatusValue.Pass;
                StationReturn.Data   = LoadUsetInfolsit;
                this.DBPools["SFCDB"].Return(SFCDB);
            }
            catch (Exception e)
            {
                this.DBPools["SFCDB"].Return(SFCDB);
                throw e;
            }
        }
Пример #8
0
        /// <summary>
        /// 查詢用戶角色權限
        /// </summary>
        public void SelectUserRolePrivilege(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow();

            MESDataObject.Module.T_c_user   User    = new MESDataObject.Module.T_c_user(SFCDB, DB_TYPE_ENUM.Oracle);
            MESDataObject.Module.Row_c_user UserRow = (MESDataObject.Module.Row_c_user)User.NewRow();

            string LoginUserEmp = Data["LoginUserEmp"].ToString();
            string EditEmp      = Data["LoginUserEmp"].ToString();


            DataTable StrRes = new DataTable();
            //  StrRes = UserRow.getC_Rolebyrolename(Role_Name, SFCDB, DB_TYPE_ENUM.Oracle);
            List <c_role> rolelist = new List <c_role>();

            if (StrRes.Rows.Count > 0)
            {
                foreach (DataRow item in StrRes.Rows)
                {
                    rolelist.Add(new c_role
                    {
                        ID          = item["ID"].ToString(),
                        SYSTEM_NAME = item["SYSTEM_NAME"].ToString(),
                        ROLE_NAME   = item["ROLE_NAME"].ToString(),
                        ROLE_DESC   = item["ROLE_DESC"].ToString(),
                        EDIT_EMP    = item["EDIT_EMP"].ToString()
                    });
                }
                StationReturn.Status  = StationReturnStatusValue.Pass;
                StationReturn.Message = "角色信息";
                StationReturn.Data    = rolelist;
            }
            else
            {
                StationReturn.Status  = StationReturnStatusValue.Fail;
                StationReturn.Message = "無任何角色信息!";
            }

            this.DBPools["SFCDB"].Return(SFCDB);
        }
Пример #9
0
        /// <summary>
        /// 加載所有用戶列表
        /// </summary>
        public void LoadInformation(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow();

            MESDataObject.Module.T_c_user   GetInformation = new MESDataObject.Module.T_c_user(SFCDB, DB_TYPE_ENUM.Oracle);
            MESDataObject.Module.Row_c_user InformationRow = (MESDataObject.Module.Row_c_user)GetInformation.NewRow();
            string r         = Data["PageRow"].ToString() == "" ? "10" : Data["PageRow"].ToString();
            string i         = Data["PageCount"].ToString() == "" ? "1" : Data["PageCount"].ToString();
            int    PageRow   = Convert.ToInt32(r == "0" ? "10" : r);
            int    PageCount = Convert.ToInt32(i == "0" ? "1" : i);
            string emp_no    = Data["emp_no"].ToString();

            string strSql = $@"select * from c_user order by  edit_time  ";

            System.Data.DataSet res = SFCDB.ExecSelect(strSql);

            int MaxPage = res.Tables[0].Rows.Count / PageRow + 1;

            if (MaxPage >= PageCount)
            {
                DataTable dt = GetInformation.SelectC_User(PageRow, PageCount, emp_no, SFCDB, DB_TYPE_ENUM.Oracle);

                if (dt.Rows.Count > 0)
                {
                    List <c_user_model> lsit = new List <c_user_model>();
                    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()
                        });
                    }
                    StationReturn.Status  = StationReturnStatusValue.Pass;
                    StationReturn.Message = "成功取到用戶信息!";
                    StationReturn.Data    = lsit;
                }
                else
                {
                    StationReturn.Status  = StationReturnStatusValue.Fail;
                    StationReturn.Message = "無此用戶信息!";
                }
            }
            else
            {
                StationReturn.Status  = StationReturnStatusValue.Fail;
                StationReturn.Message = "所需分頁數(" + PageCount + ")大於最大分頁(" + MaxPage + ")";
            }

            this.DBPools["SFCDB"].Return(SFCDB);
        }
Пример #10
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);
        }