Ejemplo n.º 1
0
        public bool IsValidLogin(string employeeNo, string password)
        {
            try
            {
                List <tbm_Employee> user = base.GetEmployeeByEmpNo(employeeNo);
                if (user.Count < 1)
                {
                    return(false);
                }

                tbm_Employee    loginUser = user.First();
                PasswordHandler handle    = new PasswordHandler();
                if (loginUser.Status == PasswordHandler.STATUS_ACCOUNT_LOCK)
                {
                    return(false);
                }

                if (loginUser.Password == handle.GeneratePasswordHash(password))
                {
                    handle.PasswordWrongCountReset(loginUser.EmpNo);
                    return(true);
                }
                else
                {
                    handle.PasswordWrongCountUp(loginUser.EmpNo);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        private List <tbm_Employee> SaveEmployee(dsEmployeeBelonging employeeInfo, IEmployeeMasterHandler hand)
        {
            List <tbm_Employee> result = null;

            doTransactionLog.eTransactionType?TransactionType = null;
            MAS070_ScreenParameter            MAS070Param     = GetScreenObject <MAS070_ScreenParameter>();
            PasswordHandler handler = new PasswordHandler();

            using (TransactionScope scope = new TransactionScope())
            {
                if (employeeInfo.employee.ModifyMode.Equals("ADD"))
                {
                    employeeInfo.employee.CreateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;
                    employeeInfo.employee.CreateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                    employeeInfo.employee.UpdateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;
                    employeeInfo.employee.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                    employeeInfo.employee.Password   = handler.GeneratePasswordHash(employeeInfo.employee.Password);
                    List <tbm_Employee> insertList = new List <tbm_Employee>();
                    insertList.Add(employeeInfo.employee);
                    string xml = CommonUtil.ConvertToXml_Store(insertList);
                    result          = hand.InsertEmployee(xml);
                    TransactionType = doTransactionLog.eTransactionType.Insert;
                }
                else
                {
                    if (employeeInfo.employee.ChangePasswordFlag)
                    {
                        employeeInfo.employee.Password = handler.GeneratePasswordHash(employeeInfo.employee.Password);
                        employeeInfo.employee.PasswordLastUpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                        employeeInfo.employee.PasswordWrongCount     = 0;
                        employeeInfo.employee.Status = null;
                    }
                    result          = hand.UpdateEmployee(employeeInfo.employee);
                    TransactionType = doTransactionLog.eTransactionType.Update;
                }

                if (result.Count == 0)
                {
                    return(null);
                }
                else
                {
                    doTransactionLog logData = new doTransactionLog()
                    {
                        TransactionType = TransactionType,
                        TableName       = TableName.C_TBL_NAME_EMPLOYEE,
                        TableData       = CommonUtil.ConvertToXml(result)
                    };
                    ILogHandler loghand = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                    loghand.WriteTransactionLog(logData);
                }

                List <tbm_Belonging>      insertBelList      = new List <tbm_Belonging>();
                List <View_tbm_Belonging> checkUpdateBelList = new List <View_tbm_Belonging>();
                List <View_tbm_Belonging> updateBelList      = new List <View_tbm_Belonging>();

                foreach (var item in employeeInfo.belongingList)
                {
                    if (item.ModifyMode.Equals("NONE"))
                    {
                        continue;
                    }

                    if (item.ModifyMode.Equals("ADD"))
                    {
                        item.CreateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;
                        item.CreateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                        item.UpdateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;
                        item.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                        insertBelList.Add(item);
                    }
                    else if (item.ModifyMode.Equals("EDIT"))
                    {
                        if (MAS070Param.belongingList != null)
                        {
                            var updateDate = from g in MAS070Param.belongingList
                                             where g.BelongingID == item.BelongingID
                                             select g.UpdateDate;

                            foreach (var date in updateDate)
                            {
                                item.UpdateDate = date;
                            }
                        }

                        if (item.UpdateDate != null)
                        {
                            checkUpdateBelList.Add(item);
                            updateBelList.Add(item);
                        }
                        else
                        {
                            item.CreateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;
                            item.CreateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                            item.UpdateBy   = CommonUtil.dsTransData.dtUserData.EmpNo;
                            item.UpdateDate = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;
                            insertBelList.Add(item);
                        }
                    }
                }


                if (employeeInfo.delBelList != null && employeeInfo.delBelList.Count != 0)
                {
                    foreach (var item in employeeInfo.delBelList)
                    {
                        var updateDate = from g in MAS070Param.belongingList
                                         where g.BelongingID == item.BelongingID
                                         select g.UpdateDate;

                        foreach (var date in updateDate)
                        {
                            item.UpdateDate = date;
                        }
                    }

                    checkUpdateBelList.AddRange(employeeInfo.delBelList);
                }

                if (checkUpdateBelList.Count != 0)
                {
                    hand.checkBelongingUpdateDate(checkUpdateBelList);
                }

                if (insertBelList.Count != 0)
                {
                    string xml = CommonUtil.ConvertToXml_Store(insertBelList);
                    List <tbm_Belonging> insertedList = hand.InsertBelonging(xml);
                    if (insertedList.Count == 0)
                    {
                        return(null);
                    }
                    else
                    {
                        doTransactionLog logData = new doTransactionLog()
                        {
                            TransactionType = doTransactionLog.eTransactionType.Insert,
                            TableName       = TableName.C_TBL_NAME_BELONGING,
                            TableData       = CommonUtil.ConvertToXml(insertedList)
                        };
                        ILogHandler loghand = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                        loghand.WriteTransactionLog(logData);
                    }
                }

                foreach (var item in updateBelList)
                {
                    List <tbm_Belonging> updateList = new List <tbm_Belonging>();
                    updateList.Add(item);
                    string xml = CommonUtil.ConvertToXml_Store(updateList);
                    List <tbm_Belonging> updatedList = hand.UpdateBelonging(xml, item.BelongingID);
                    if (updatedList.Count == 0)
                    {
                        return(null);
                    }
                    else
                    {
                        doTransactionLog logData = new doTransactionLog()
                        {
                            TransactionType = doTransactionLog.eTransactionType.Update,
                            TableName       = TableName.C_TBL_NAME_BELONGING,
                            TableData       = CommonUtil.ConvertToXml(updatedList)
                        };
                        ILogHandler loghand = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                        loghand.WriteTransactionLog(logData);
                    }
                }

                if (employeeInfo.delBelList != null && employeeInfo.delBelList.Count != 0)
                {
                    foreach (var item in employeeInfo.delBelList)
                    {
                        List <tbm_Belonging> deletedList = hand.DeleteBelonging(item.BelongingID);
                        if (deletedList.Count == 0)
                        {
                            return(null);
                        }
                        else
                        {
                            doTransactionLog logData = new doTransactionLog()
                            {
                                TransactionType = doTransactionLog.eTransactionType.Delete,
                                TableName       = TableName.C_TBL_NAME_BELONGING,
                                TableData       = CommonUtil.ConvertToXml(deletedList)
                            };
                            ILogHandler loghand = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                            loghand.WriteTransactionLog(logData);
                        }
                    }
                }

                scope.Complete();
            }

            return(result);
        }