예제 #1
0
        /// <summary>
        /// 取回用戶密碼
        /// </summary>
        public void GetPassword(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn)
        {
            OleExec  sfcdb = null;
            T_c_user GetPassword;
            string   EMP_NO = Data["EMP_NO"].ToString();
            Dictionary <string, string> dic = new Dictionary <string, string>();

            try
            {
                sfcdb       = this.DBPools["SFCDB"].Borrow();
                GetPassword = new T_c_user(sfcdb, DBTYPE);
                Row_c_user row = (Row_c_user)GetPassword.NewRow();
                row = GetPassword.getC_Userbyempno(EMP_NO, sfcdb, this.DBTYPE);

                if (row != null)
                {
                    ///缺發送EMAIL 或者短信功能
                    dic.Add("EMP_PASSWORD", row.EMP_PASSWORD.ToString());
                    StationReturn.MessageCode = "MES00000015";
                    StationReturn.Data        = dic;
                }
                StationReturn.Status = StationReturnStatusValue.Pass;
                this.DBPools["SFCDB"].Return(sfcdb);
            }
            catch (Exception e)
            {
                this.DBPools["SFCDB"].Return(sfcdb);
                throw e;
            }
        }
예제 #2
0
        /// <summary>
        /// 根據工號檢查密碼是否正確
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void EmpPasswordChecker(MESPubLab.MESStation.MESStationBase Station, MESPubLab.MESStation.MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            if (Paras.Count != 2)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000050"));
            }
            MESStationSession sessionEmp = Station.StationSession.Find(t => t.MESDataType == Paras[0].SESSION_TYPE && t.SessionKey == Paras[0].SESSION_KEY);

            if (sessionEmp == null || sessionEmp.Value == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE }));
            }
            MESStationSession sessionPwd = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (sessionPwd == null || sessionPwd.Value == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE }));
            }
            T_c_user   t_c_user = new T_c_user(Station.SFCDB, Station.DBType);
            Row_c_user rowUser  = t_c_user.getC_Userbyempno(sessionEmp.Value.ToString(), Station.SFCDB, Station.DBType);

            if (rowUser == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180620163103", new string[] { sessionEmp.Value.ToString() }));
            }
            if (!rowUser.EMP_PASSWORD.Equals(sessionPwd.Value.ToString()))
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180813154717", new string[] { sessionEmp.Value.ToString() }));
            }
        }
예제 #3
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  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();
            OleExec     SFCDB = _DBPools["SFCDB"].Borrow();

            T_c_user   GetLoginUser = new T_c_user(SFCDB, this.DBTYPE);
            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);

            MESPubLab.MESStation.LogicObject.User lu = new MESPubLab.MESStation.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 = LoginUser.EMP_NO, UserInfo = user_info
                };
            }
            else
            {
                StationReturn.Status      = StationReturnStatusValue.Fail;
                StationReturn.MessageCode = "MES00000010";
            }
            StationReturn.Data = lr;
            _DBPools["SFCDB"].Return(SFCDB);
        }
예제 #4
0
        /// <summary>
        /// REPAIR_CHECK_OUT權限檢查
        /// </summary>
        /// <param name="Station"></param>
        /// <param name="Input"></param>
        /// <param name="Paras"></param>
        public static void RepairOutEmpChecker(MESStationBase Station, MESStationInput Input, List <R_Station_Action_Para> Paras)
        {
            if (Paras.Count != 2)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000050"));
            }
            string type = Paras[0].VALUE.ToString().ToUpper();

            if (type == "")
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[0].SESSION_TYPE }));
            }
            MESStationSession sessionEmp = Station.StationSession.Find(t => t.MESDataType == Paras[1].SESSION_TYPE && t.SessionKey == Paras[1].SESSION_KEY);

            if (sessionEmp == null || sessionEmp.Value == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MES00000052", new string[] { Paras[1].SESSION_TYPE }));
            }
            //Vertiv SE&RE黃克喜要求只有指定人員才能掃入和接收REPAIR_CHECK_IN
            T_c_user    t_c_uer     = new T_c_user(Station.SFCDB, Station.DBType);
            Row_c_user  rowUser     = t_c_uer.getC_Userbyempno(sessionEmp.Value.ToString(), Station.SFCDB, Station.DBType);
            T_C_CONTROL t_c_control = new T_C_CONTROL(Station.SFCDB, Station.DBType);

            string[]      inEmp       = t_c_control.GetControlByName("REPAIR_CHECK_OUT_SEND", Station.SFCDB).CONTROL_VALUE.Split(',');
            string[]      receiveEmp  = t_c_control.GetControlByName("REPAIR_CHECK_OUT_RECEIVE", Station.SFCDB).CONTROL_VALUE.Split(',');
            List <string> inEmpList   = new List <string>(inEmp);
            List <string> receiveList = new List <string>(receiveEmp);

            if (rowUser == null)
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180620163103", new string[] { sessionEmp.Value.ToString() }));
            }
            if (type == "SEND")
            {
                if (inEmpList.Find(s => s == rowUser.EMP_NO) == null)
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180619155133", new string[] { rowUser.EMP_NO }));
                }
            }
            else if (type == "RECEIVE")
            {
                if (receiveList.Find(s => s == rowUser.EMP_NO) == null)
                {
                    throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180619154947", new string[] { rowUser.EMP_NO }));
                }
            }
            else
            {
                throw new MESReturnMessage(MESReturnMessage.GetMESReturnMessage("MSGCODE20180607163531", new string[] { "Input" }));
            }
        }