Example #1
0
        public SessionInfo LogOn(string username, string userIP)
        {
            MA_USER       user;
            SessionInfo   sessioninfo    = new SessionInfo();
            AuditBusiness _auditBusiness = new AuditBusiness();

            LoggingHelper.Debug("Begin Logon by " + username);
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                sessioninfo.ConnectionString = (string)ConfigurationManager.AppSettings[AppSettingName.CONNECTION_STRING];
                sessioninfo.Local            = "Localhost";
                sessioninfo.StartSession     = DateTime.Now;
                LoggingHelper.Debug("Begin get user data");
                user = unitOfWork.MA_USERRepository.GetByUserCode(username);
                if (user == null)
                {
                    LoggingHelper.Debug(username + " error: " + Messages.USER_NOT_UNAVAILABLE);
                    throw this.CreateException(new Exception(), Messages.USER_NOT_UNAVAILABLE);
                }
                sessioninfo.ID            = Guid.NewGuid();
                sessioninfo.CurrentUserId = user.ID;
                sessioninfo.UserFullName  = user.NAME;
                sessioninfo.UserLogon     = username;
                sessioninfo.IsActive      = user.ISACTIVE.Value;
                sessioninfo.IsLocked      = user.ISLOCKED.Value;
                sessioninfo.ProfileId     = user.USER_PROFILE_ID;
                sessioninfo.ProfileName   = user.MA_USER_PROFILE.LABEL;
                sessioninfo.IPAddress     = userIP;
                LoggingHelper.Debug("End get user data");

                //Get from MA_PROCESS_DATE
                //LoggingHelper.Debug("Begin get processing date from OPICS");
                //OpicsBusiness _opicsBusiness = new OpicsBusiness();
                //PROCDateModel prcDate = _opicsBusiness.GetDateProcessing(DateTime.Today);
                //sessioninfo.Process.CurrentDate = prcDate.CURRDATE;
                //sessioninfo.Process.PreviousDate = prcDate.PREVDATE;
                //sessioninfo.Process.NextDate = prcDate.NEXTDATE;
                //LoggingHelper.Debug("End get processing date from OPICS");

                LoggingHelper.Debug("Begin get processing date from MA_PROCESS_DATE");
                MA_PROCESS_DATE PROC = unitOfWork.MA_PROCESS_DATERepository.All().FirstOrDefault();
                sessioninfo.Process.CurrentDate  = PROC != null ? PROC.PROC_DATE : DateTime.Today;
                sessioninfo.Process.PreviousDate = PROC != null ? PROC.PREV_PROC_DATE : DateTime.Today.AddDays(-1);
                sessioninfo.Process.NextDate     = PROC != null ? PROC.NEXT_PROC_DATE : DateTime.Today.AddDays(1);
                LoggingHelper.Debug("End get processing date from MA_PROCESS_DATE");

                //AUDIT USER TRANSACTION
                LoggingHelper.Debug("Begin Trace Audit User " + user.NAME);
                _auditBusiness.TraceAuditLoginUser(sessioninfo);
                LoggingHelper.Debug("End Trace Audit User " + user.NAME);
            }

            return(sessioninfo);
        }
        public MA_PROCESS_DATE Get()
        {
            try
            {
                MA_PROCESS_DATE prcDate = null;

                using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
                {
                    prcDate = unitOfWork.MA_PROCESS_DATERepository.All().First();
                }

                return(prcDate);
            }
            catch (DataServicesException ex)
            {
                throw this.CreateException(ex, null);
            }
        }
        public MA_PROCESS_DATE Update(SessionInfo sessioninfo, MA_PROCESS_DATE processdate)
        {
            using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
            {
                var found = unitOfWork.MA_PROCESS_DATERepository.All().First();
                if (found == null)
                {
                    throw this.CreateException(new Exception(), "Data not found!");
                }
                else
                {
                    found.NEXT_PROC_DATE     = processdate.NEXT_PROC_DATE;
                    found.PREV_PROC_DATE     = processdate.PREV_PROC_DATE;
                    found.PROC_DATE          = processdate.PROC_DATE;
                    found.FLAG_RECONCILE     = processdate.FLAG_RECONCILE;
                    found.LOG.MODIFYBYUSERID = processdate.LOG.MODIFYBYUSERID;
                    found.LOG.MODIFYDATE     = processdate.LOG.MODIFYDATE;
                    found.FLAG_RECONCILE     = processdate.FLAG_RECONCILE;
                    unitOfWork.Commit();
                }
            }

            return(processdate);
        }