Exemplo n.º 1
0
        public string createAuditLogContentPageAction(ContentPage contentPage, string action, List <string> modified_fields = null)
        {
            var _contentPage = ContentPageDbContext.getInstance().findArticleByIDNoTracking(contentPage.ArticleID);

            if (_contentPage == null)
            {
                return(null);
            }

            var account = SessionPersister.account;

            if (account == null)
            {
                return(null);
            }

            var notificationAction = EmailNotificationHelper.ParseAction(action);

            EmailNotificationHelper.NotifyAllOnActionOfBaseArticle("Content Page", contentPage, notificationAction);

            AuditLog item = new AuditLog();

            item.accountID     = account.AccountID;
            item.account       = account.Username;
            item.contentPageID = _contentPage.ArticleID;
            item.contentPage   = _contentPage.Name;
            item.categoryID    = _contentPage.categoryID;
            item.category      = _contentPage.category != null?_contentPage.category.GetName() : null;

            item.action = action;

            manipulateRemarks(item, modified_fields);

            return(createAuditLog(item));
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            EmailNotificationModel  emailNotificationModel = new EmailNotificationModel();
            EmailNotificationHelper _Helper = new EmailNotificationHelper();

            emailNotificationModel = _Helper.GetEmailNotificationDetails(emailNotificationModel);
            return(View(emailNotificationModel));
        }
Exemplo n.º 3
0
        private EditionMailTemplate GetEmailTemplateForEditionCreation(EditionEntity edition)
        {
            var recipients        = WebConfigHelper.NewEventNotificationRecipients;
            var recipientFullName = "";
            var notificationAttr  = NotificationType.EditionCreated.GetAttribute <NotificationAttribute>();
            var buttonUrl         = _editionHelper.GetEditionUrl(edition, notificationAttr.Fragment);
            var unsubscriptionUrl = notificationAttr.Unsubscribable ? EmailNotificationHelper.GetUnsubscriptionUrl(edition) : string.Empty;
            var emailTemplate     = new EditionMailTemplate
            {
                Recipients        = recipients,
                RecipientFullName = recipientFullName,
                ButtonUrl         = buttonUrl,
                UnsubscriptionUrl = unsubscriptionUrl
            };

            return(emailTemplate);
        }
Exemplo n.º 4
0
        private EditionMailTemplate GetEmailTemplateForEditionUpdateNotification(EditionEntity edition)
        {
            var recipients        = _eventDirectorServices.GetRecipientEmails(edition);
            var recipientFullName = _editionHelper.GetEventDirectorFullName(edition);
            var notificationAttr  = NotificationType.EditionLocationUpdated.GetAttribute <NotificationAttribute>();
            var buttonUrl         = _editionHelper.GetEditionUrl(edition, notificationAttr.Fragment);
            var unsubscriptionUrl = notificationAttr.Unsubscribable ? EmailNotificationHelper.GetUnsubscriptionUrl(edition) : string.Empty;
            var emailTemplate     = new EditionMailTemplate
            {
                Recipients        = recipients,
                RecipientFullName = recipientFullName,
                ButtonUrl         = buttonUrl,
                UnsubscriptionUrl = unsubscriptionUrl
            };

            return(emailTemplate);
        }
Exemplo n.º 5
0
 public ActionResult Index(EmailNotificationModel emailNotificationModel)
 {
     if (ModelState.IsValid)
     {
         EmailNotificationHelper _Helper = new EmailNotificationHelper();
         int result = _Helper.UpdateEmailNotificationSetting(emailNotificationModel);
         if (result >= 1)
         {
             TempData["CommonMessage"] = AppLogic.setMessage(0, "Record updated successfully.");
             return(RedirectToAction("Index"));
         }
         else
         {
             TempData["CommonMessage"] = AppLogic.setMessage(result, "Error: Please try again.");
             return(RedirectToAction("Index"));
         }
     }
     return(View(emailNotificationModel));
 }
        /* NOTIFICATION - COMMON */
        protected void PushEditionUpdateNotifications(EditionEntity edition, string updatedFields)
        {
            if (WebConfigHelper.TrackEditionUpdate && !string.IsNullOrWhiteSpace(updatedFields))
            {
                var subscribers = GetSubscriberEmails(edition.EditionId);
                var inAppNotificationRecipients = subscribers;
                var emailRecipients             = WebConfigHelper.TrackEditionUpdateUseMockRecipients
                    ? WebConfigHelper.AdminEmails
                    : subscribers;

                var body = $"Field(s) updated by {CurrentCedUser.CurrentUser.FullName} on {edition.UpdateTime}:<br/><br/>";
                body += updatedFields;

                const NotificationType notificationType = NotificationType.EditionUpdated;
                var notifAttr         = notificationType.GetAttribute <NotificationAttribute>();
                var buttonUrl         = _editionHelper.GetEditionUrl(edition);
                var unsubscriptionUrl = notifAttr.Unsubscribable ? EmailNotificationHelper.GetUnsubscriptionUrl(edition) : string.Empty;

                CreateInAppNotification(edition, notificationType, inAppNotificationRecipients, CurrentCedUser.CurrentUser.Email);

                PushRealTimeInAppNotification(edition, notificationType, inAppNotificationRecipients, CurrentCedUser.CurrentUser.Email);

                var emailResult = SendEmailNotification(edition, notificationType, emailRecipients, CurrentCedUser.CurrentUser, body,
                                                        buttonUrl, unsubscriptionUrl);

                // STEP 5: LOG EMAIL
                if (emailResult.Sent)
                {
                    LogEmail(edition.EditionId, inAppNotificationRecipients, body, CurrentCedUser.CurrentUser.Email, notificationType.ToString());
                }
                else
                {
                    LogEmail(edition.EditionId, WebConfigHelper.AdminEmails, emailResult.ErrorMessage, null, notificationType.ToString());
                }
            }
        }
Exemplo n.º 7
0
        public async Task <ServiceResponse> UserRegistration(UserRegistrationRequestDto request)
        {
            var response = new ServiceResponse {
                ErrorList = new List <ErrorMessage>()
            };

            request.FirstName = request.FirstName?.TitleCase();
            request.LastName  = request.LastName?.TitleCase();
            request.UserName  = request.UserName?.LowerCase();
            request.Password  = _encryptData.EncryptPassword(request.Password);
            request.UserEmail = request.UserEmail?.LowerCase();
            request.Remarks   = request.Remarks?.TitleCase();
            request.Active    = true;
            var user = _mapper.Map <IM_USERS>(request);

            // to fix an issue related to claims generation during login
            if (string.IsNullOrEmpty(user.LASTNAME))
            {
                user.LASTNAME = "";
            }

            user.CreatedBy   = "SYSTEM";
            user.CreatedDate = DateTime.Now;
            user.ID          = Guid.NewGuid().ToString();

            _transactionalUnitOfWork.SetIsActive(false);

            await _transactionalUnitOfWork.CommitAsync();

            _userRepository.Add(user);

            var contributorGroup = await _groupsRepository.GetReadOnlyAsync(x => x.NAME == "CONTRIBUTORS");

            if (contributorGroup == null)
            {
                throw new BadRequestException("Unable to assign access to user");
            }

            var addUserGroup = new IM_USERS_GROUPS
            {
                ID          = Guid.NewGuid().ToString(),
                CreatedBy   = "ADMIN",
                CreatedDate = DateTime.Now,
                GROUP_ID    = contributorGroup.ID,
                ACTIVE      = true,
                USER_NAME   = user.USERNAME
            };

            _transactionalUnitOfWork.SetIsActive(true);

            _usersGroupsRepository.Add(addUserGroup);

            var committedRows = await _transactionalUnitOfWork.CommitAsync();

            if (committedRows > 0)
            {
                response.Success = true;
                response.Msg     = "User registered successfully";
            }
            else
            {
                response.Success = false;
                response.Msg     = "Failed to register user";
            }

            var recipients = new List <EmailRecipientDto>
            {
                new EmailRecipientDto
                {
                    RecipientName         = $"{user.FIRSTNAME} {user.LASTNAME}",
                    RecipientEmailAddress = user.USEREMAIL
                }
            };

            var newUserRegistrationEmailTemplate =
                await _templateSettingRepository.GetReadOnlyAsync(x => x.KEY == "NEW_USER_TEMPLATE");

            if (newUserRegistrationEmailTemplate != null)
            {
                var emailTemplateString = newUserRegistrationEmailTemplate.VALUE;

                if (!string.IsNullOrEmpty(emailTemplateString))
                {
                    var emailHtmlBody = emailTemplateString.Replace("{username}", $"{user.FIRSTNAME} {user.LASTNAME}")
                                        // TODO: get application ui url from appsettings
                                        .Replace("{link}", "https://www.google.com");

                    await EmailNotificationHelper.SendEmailNotification(_configuration.GetSection("SendGridAPIKey").Value,
                                                                        newUserRegistrationEmailTemplate.NAME, emailHtmlBody, "", recipients);
                }
            }



            return(await Task.Run(() => response));
        }
Exemplo n.º 8
0
    public static Boolean workflowCheckerPayroll(ISession session, Transaction trx, ILog log)
    {
        //get trxpayrolls object
        XmlDocument   doc = new XmlDocument();
        XmlSerializer ser = new XmlSerializer(typeof(TrxPayroll));

        doc.LoadXml(trx.TObject);
        XmlNodeReader reader = new XmlNodeReader(doc.DocumentElement);
        object        obj    = ser.Deserialize(reader);

        TrxPayroll ObjPayroll = (TrxPayroll)obj;
        TrxPayroll payroll    = session.Load <TrxPayroll>(ObjPayroll.Id);

        bool   result         = true;
        string HeaderErrorMsg = "||" + DateTime.Now.ToString("dd-MM-yyyy hh:mm:ss") + " ";

        //invalid authority setting status
        string StatusInvalidAuth = "";

        try
        {
            int    user_id  = 0;
            string clientID = trx.ClientId.ToString();

            //sayedzul add - 20161108
            #region cek rek debet notpool or not
            string debAcc             = payroll.DebitAccount.Trim().PadLeft(15, '0');
            NotionalPoolingMember npm = session.CreateCriteria(typeof(NotionalPoolingMember))
                                        .Add(Expression.Eq("AccountNumber", debAcc))
                                        .Add(Expression.Eq("Status", "A"))
                                        .UniqueResult <NotionalPoolingMember>();
            if (npm != null)
            {
                String[] desc = payroll.Description.Split(new String[] { "||" }, StringSplitOptions.None);
                payroll.Status            = ParameterHelper.TRXSTATUS_REJECT;
                payroll.StatusEmail       = ParameterHelper.PAYROLL_NEEDEMAIL;
                payroll.Description       = ParameterHelper.TRXDESCRIPTION_REJECT + " - Notional pooling account not permitted for payroll transaction||" + desc[1];
                payroll.ErrorDescription += HeaderErrorMsg + "Notional pooling account not permitted for payroll transaction";

                session.Update(payroll);

                //reject child
                string outRejectChild = "";
                if (rejectAllChild(session, payroll, out outRejectChild, log))
                {
                    log.Info("Success Update All Child.");
                    payroll.ErrorDescription += HeaderErrorMsg + " Success reject child";
                    //delete transactions
                    session.Delete(trx);
                }
                else
                {
                    payroll.Status           = ParameterHelper.PAYROLL_EXCEPTION;
                    payroll.ErrorDescription = HeaderErrorMsg + outRejectChild;
                }

                session.Update(payroll);
                session.Flush();
                return(true);
            }
            #endregion
            //end sayedzul

            #region get usermaps/user_id
            UserMap umap = null;
            try
            {
                if (!string.IsNullOrEmpty(trx.Approver))
                {
                    String[] tempmaker = trx.Approver.Split(new String[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (String makinfo in tempmaker)
                    {
                        String[] detmake = makinfo.Split(new String[] { " - " }, StringSplitOptions.RemoveEmptyEntries);
                        umap = session.CreateCriteria(typeof(UserMap))
                               .Add(Expression.Like("UserHandle", detmake[0].Trim()))
                               .Add(Expression.Like("ClientEntity", int.Parse(clientID)))
                               .UniqueResult <UserMap>();
                        user_id = umap.UserEntity;
                    }
                }
                else if (!string.IsNullOrEmpty(trx.Checker))
                {
                    String[] tempmaker = trx.Checker.Split(new String[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (String makinfo in tempmaker)
                    {
                        String[] detmake = makinfo.Split(new String[] { " - " }, StringSplitOptions.RemoveEmptyEntries);
                        umap = session.CreateCriteria(typeof(UserMap))
                               .Add(Expression.Like("UserHandle", detmake[0].Trim()))
                               .Add(Expression.Like("ClientEntity", int.Parse(clientID)))
                               .UniqueResult <UserMap>();
                        user_id = umap.UserEntity;
                    }
                }
                else//maker
                {
                    String[] tempmaker = trx.Maker.Split(new String[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (String makinfo in tempmaker)
                    {
                        String[] detmake = makinfo.Split(new String[] { " - " }, StringSplitOptions.RemoveEmptyEntries);
                        umap = session.CreateCriteria(typeof(UserMap))
                               .Add(Expression.Like("UserHandle", detmake[0].Trim()))
                               .Add(Expression.Like("ClientEntity", int.Parse(clientID)))
                               .UniqueResult <UserMap>();
                        user_id = umap.UserEntity;
                    }
                }
            }
            catch (Exception ex)
            {
                payroll.ErrorDescription = "Exception on Scheduller Payroll Get Auth :: " + ex.Message + " => " + ex.StackTrace + " => " + ex.InnerException;
                payroll.Status           = ParameterHelper.PAYROLL_EXCEPTION;
                session.Update(payroll);
                session.Flush();

                log.Error("Exception on Scheduller Payroll Get Auth :: " + ex.Message + " => " + ex.StackTrace + " => " + ex.InnerException);
                //EvtLogger.Write("Exception on Scheduller Payroll Get Auth :: " + ex.Message + " => " + ex.StackTrace, System.Diagnostics.EventLogEntryType.Error);
                result = false;
            }
            log.Info("User Id : " + user_id);
            #endregion

            //get total TRX
            //|susccess|fail|total| ==> |1:200|:|2:300|
            //string[] total = payroll.TotalTrx.Split(new String[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
            //string[] pecahan = total[2].Split(':');
            //string counttrx = pecahan[0];
            //string totalamount = pecahan[1];

            //trx.TotalTrx = "|" + feeIFT + "|" + reject + "|" + totalTrx + "|" + feeRTG + "|" + feeLLG + "|";
            if (payroll.TotalTrx.Equals("|0:0|0:0|0:0|0:0|0:0|"))
            {
                //countift : sumift| countrejectAll : sumrejectAll | countAll : sumAll | countRTG : sumRTG | countLLG : sumLLG|
                //ga dipake pun, ga usah lah

                int    _countSuccess = payroll.TrxPayrollDetail.Where(x => x.Status != ParameterHelper.TRXSTATUS_REJECT).Count();
                double _sumSuccess   = payroll.TrxPayrollDetail.Where(x => x.Status != ParameterHelper.TRXSTATUS_REJECT).Sum(x => x.Amount / 100);
                int    _countInvalid = payroll.TrxPayrollDetail.Where(x => x.Status == ParameterHelper.TRXSTATUS_REJECT).Count();
                double _sumInvalid   = payroll.TrxPayrollDetail.Where(x => x.Status == ParameterHelper.TRXSTATUS_REJECT).Sum(x => x.Amount / 100);
                int    _countTotal   = payroll.TrxPayrollDetail.Count();
                double _sumTotal     = payroll.TrxPayrollDetail.Sum(x => x.Amount / 100);
                payroll.TotalTrx = "|" + _countSuccess.ToString() + ":" + _sumSuccess.ToString() + "|" + _countInvalid.ToString() + ":" + _sumInvalid.ToString() + "|" + _countTotal.ToString() + ":" + _sumTotal.ToString() + "|";
                //log.Info("Trx Id = " + payroll.Id + ", Total Trx : " + payroll.TotalTrx);
                //session.Update(trx);
                //session.Flush();


                //Denny coba
                //string TotalTrxNew = "|0:0|0:0|0:0|0:0|0:0|";
                //TotalTrxNew = "|" + _countSuccess.ToString() + ":" + _sumSuccess.ToString() + "|" + _countInvalid.ToString() + ":" + _sumInvalid.ToString() + "|" + _countTotal.ToString() + ":" + _sumTotal.ToString() + "|";

                #region Native update Parent payroll
                //string temp_query2 = "";
                //string msg2 = "";
                //int count2 = 0;
                //string dbResult2 = "";
                //temp_query2 = @"update trxpayrolls set totaltrx = '" + TotalTrxNew + "' where id = '" + payroll.Id + "';";

                //if (!PayrollHelper.ExecuteQueryValue(session, temp_query2, out dbResult2, out msg2))
                //{
                //    log.Error("(TrxID " + payroll.Id + ") Failed Query: " + temp_query2 + " " + msg2);

                //}
                #endregion native update
            }
            string counttrx    = payroll.TrxPayrollDetail.Where(x => x.Status != ParameterHelper.TRXSTATUS_REJECT).Count().ToString();
            double totalamount = payroll.TrxPayrollDetail.Where(x => x.Status != ParameterHelper.TRXSTATUS_REJECT).Sum(x => x.Amount / 100);

            //get debit acc
            string[]      debAccArr  = payroll.Description.Split(new String[] { "||" }, StringSplitOptions.RemoveEmptyEntries);
            string        debitAccId = debAccArr[1];
            ClientAccount ClientAcc  = session.Load <ClientAccount>(int.Parse(debitAccId));
            string        debitAcc   = ClientAcc.Number;

            string valueDate = payroll.ProcessTime.ToString("yyMMdd");
            if (valueDate.Equals("010101"))
            {
                valueDate = "991231";
            }

            #region cek limit-limit
            if (trx.CheckWork == 0 && trx.ApproveWork == 0)
            {
                string outMsgAuthorityError = "";
                if (CekAuthority(session, 100, umap, "PAYROLL", valueDate, totalamount, "IDR", out outMsgAuthorityError))
                {
                    if (!outMsgAuthorityError.Equals(""))
                    {
                        StatusInvalidAuth = "[LIMIT]" + outMsgAuthorityError;
                    }
                }
                else
                {
                    StatusInvalidAuth = "[EXCEPTION]" + outMsgAuthorityError;
                }
            }
            #endregion


            #region cek Authority Setting
            //Pengecekkan bypass transaksi di Settingan LIsence - Denny
            bool isWithAuthority    = true;
            IList <ClientMatrix> cm = session.CreateCriteria(typeof(ClientMatrix))
                                      .Add(Expression.Eq("Id", trx.ClientId))
                                      .List <ClientMatrix>();
            foreach (ClientMatrix cm1 in cm)
            {
                AuthorityHelper ah = null;
                ah = new AuthorityHelper(cm1.Matrix);
                isWithAuthority = ah.isDirectTransaction(100);

                //Kondisi menggunakan Direct Transactions
                if (trx.CheckTotal == 0 && trx.ApproveTotal == 0 && isWithAuthority)
                {
                    StatusInvalidAuth = "";
                }

                if (trx.CheckWork == 0 && trx.ApproveWork == 0 && isWithAuthority == false)
                {
                    log.Error("debit Account : " + debitAcc);
                    log.Error("total Account : " + totalamount);
                    log.Error("umap Client Entity : " + umap.ClientEntity);
                    //string nextProcessor = UserGroupHelper.getNextAppTemp(session, 100, umap, trx.Approver, "Payroll", debitAcc, "IDR", double.Parse(totalamount));


                    string nextProcessorChecker  = "GAK PAKE CHECKER";
                    string nextProcessorApprover = "GAK PAKE APPROVER";
                    if (trx.CheckTotal != 0)
                    {
                        nextProcessorChecker = UserGroupHelper.getNextCheTemp(session, 100, umap, "", "Payroll", debitAcc, "IDR", totalamount);
                    }
                    if (trx.ApproveTotal != 0)
                    {
                        nextProcessorApprover = UserGroupHelper.getNextAppTemp(session, 100, umap, "", "Payroll", debitAcc, "IDR", totalamount);
                    }

                    log.Error("Checker : " + nextProcessorChecker);
                    log.Error("Approver : " + nextProcessorApprover);

                    nextProcessorChecker  = nextProcessorChecker.Replace("|", "");
                    nextProcessorApprover = nextProcessorApprover.Replace("|", "");

                    if (string.IsNullOrEmpty(nextProcessorChecker))
                    {
                        StatusInvalidAuth += "CHECKER";
                    }
                    if (string.IsNullOrEmpty(nextProcessorApprover))
                    {
                        StatusInvalidAuth += " and APPROVER";
                    }
                }
            }

            #endregion


            if (StatusInvalidAuth.Equals(""))//authority valid
            {
                //transaction complete
                if (trx.CheckWork >= trx.CheckTotal)
                {
                    if (trx.ApproveWork >= trx.ApproveTotal)//FINAL, transactions ready to process
                    {
                        //update trxpayroll
                        String[] des = payroll.Description.Split(new String[] { "||" }, StringSplitOptions.None);
                        if (payroll.ProcessTime.ToString("yyyy-MM-dd").Equals("0001-01-01"))
                        {
                            payroll.ProcessTime = DateTime.Now;
                        }

                        //20170423 sayedzul add handler payroll processtime
                        if (payroll.IsPayrollBankLain == 1)
                        {
                            payroll.ProcessTime = PayrollHelper.GetRealProcessTime(session, payroll.ProcessTime);
                        }

                        payroll.Maker       = trx.Maker;
                        payroll.Checker     = trx.Checker;
                        payroll.Approver    = trx.Approver;
                        payroll.Status      = ParameterHelper.TRXSTATUS_RUNNING_AFTERCHECKACCOUNT;//19
                        payroll.Description = "PROCESSED" + "||" + des[1];
                        session.Update(payroll);
                        session.Flush();

                        //delete transactions
                        session.Delete(trx);
                        session.Flush();

                        log.Info("Finish. Data deleteled from table transactions");
                    }
                    else
                    {
                        //Masih Butuh Approval
                        log.Info("Total Amount" + totalamount);
                        string nextProcessor = UserGroupHelper.getNextAppTemp(session, 100, umap, trx.Approver, "Payroll", debitAcc, "IDR", totalamount);

                        trx.NextProcessor = nextProcessor;
                        trx.Status        = short.Parse(ParameterHelper.TRXSTATUS_APPROVE.ToString());
                        session.Update(trx);
                        log.Info("Masih Butuh Approver");

                        session.Flush();

                        #region Send Notification
                        if (!nextProcessor.Trim().Replace("|", "").Equals(""))
                        {
                            String[] uid_np = nextProcessor.Split(new String[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                            foreach (String idnp in uid_np)
                            {
                                UserMatrix      umx = session.Load <UserMatrix>(int.Parse(idnp));
                                AuthorityHelper ahe = new AuthorityHelper(umx.Matrix);
                                if (ahe.isNeedPendingEmail(100))
                                {
                                    User uid = session.Load <User>(int.Parse(idnp));
                                    //state=0->inProcess verify; state=1->inProc Approve; state=2->Succed; state=3->reject
                                    EmailNotificationHelper.MassNotification(session, uid.Email, trx.ClientId, trx.Id, "Payroll", 1, payroll.FileDescription, counttrx, totalamount.ToString(), payroll.CreatedTime, trx.Maker, payroll.ProcessTime, "Need Approve");
                                }
                            }
                        }
                        #endregion
                    }
                }
                else
                {
                    //Masih Butuh Checker
                    Console.Write("===User Handle : " + umap.UserHandle);

                    string nextProcessor = UserGroupHelper.getNextCheTemp(session, 100, umap, trx.Checker, "Payroll", debitAcc, "IDR", totalamount);

                    trx.NextProcessor = nextProcessor;
                    trx.Status        = short.Parse(ParameterHelper.TRXSTATUS_VERIFY.ToString());
                    session.Update(trx);

                    session.Flush();
                    log.Info("Next Processor : " + nextProcessor);
                    log.Info("Masih Butuh Checker");

                    #region Send Notification
                    if (!nextProcessor.Trim().Replace("|", "").Equals(""))
                    {
                        String[] uid_np = nextProcessor.Split(new String[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (String idnp in uid_np)
                        {
                            UserMatrix      umx = session.Load <UserMatrix>(int.Parse(idnp));
                            AuthorityHelper ahe = new AuthorityHelper(umx.Matrix);
                            if (ahe.isNeedPendingEmail(100))
                            {
                                User uid = session.Load <User>(int.Parse(idnp));
                                //state=0->inProcess verify; state=1->inProc Approve; state=2->Succed; state=3->reject
                                EmailNotificationHelper.MassNotification(session, uid.Email, trx.ClientId, trx.Id, "Payroll", 0, payroll.FileDescription, counttrx, totalamount.ToString(), payroll.CreatedTime, trx.Maker, payroll.ProcessTime, "Need Verify");
                            }
                        }
                    }
                    #endregion
                }
            }
            else//invalid authority setting
            {
                string invalidMsg = "";
                if (StatusInvalidAuth.Equals(" and APPROVER"))
                {
                    invalidMsg = "APPROVER";
                }
                else
                {
                    invalidMsg = StatusInvalidAuth;
                }

                String[] desc = payroll.Description.Split(new String[] { "||" }, StringSplitOptions.None);
                payroll.Status      = ParameterHelper.TRXSTATUS_REJECT;
                payroll.StatusEmail = ParameterHelper.PAYROLL_NEEDEMAIL;
                if (invalidMsg.Contains("[LIMIT]"))
                {
                    payroll.Description       = ParameterHelper.TRXDESCRIPTION_REJECT + " - " + invalidMsg.Replace("[LIMIT]", "") + "||" + desc[1];
                    payroll.ErrorDescription += HeaderErrorMsg + "Invalid Authority Settting on " + invalidMsg;
                }
                else if (invalidMsg.Contains("[EXCEPTION]"))
                {
                    payroll.Status           = ParameterHelper.PAYROLL_EXCEPTION;
                    payroll.ErrorDescription = HeaderErrorMsg + invalidMsg.Replace("[EXCEPTION]", "");
                }
                else
                {
                    payroll.Description       = ParameterHelper.TRXDESCRIPTION_REJECT + " - Invalid Authority Setting on " + invalidMsg + "||" + desc[1];
                    payroll.ErrorDescription += HeaderErrorMsg + "Invalid Authority Settting on " + invalidMsg;
                }
                session.Update(payroll);

                //reject child
                string outRejectChild = "";
                if (rejectAllChild(session, payroll, out outRejectChild, log))
                {
                    log.Info("Success Update All Child.");
                    payroll.ErrorDescription += HeaderErrorMsg + " Success reject child";
                    //delete transactions
                    session.Delete(trx);
                }
                else
                {
                    payroll.Status           = ParameterHelper.PAYROLL_EXCEPTION;
                    payroll.ErrorDescription = HeaderErrorMsg + outRejectChild;
                }
            }


            session.Update(payroll);
            session.Flush();



            result = true;
        }
        catch (Exception ex)
        {
            log.Error("Exception on Scheduller Workflow Check Payroll :: " + ex.Message + " => " + ex.StackTrace + " => " + ex.InnerException);
            //EvtLogger.Write("Exception on Scheduller FT Workflow Check :: " + ex.Message + " => " + ex.StackTrace, System.Diagnostics.EventLogEntryType.Error);
            payroll.ErrorDescription += HeaderErrorMsg + "|Exception on Scheduller Workflow Check Payroll :: " + ex.Message + " => " + ex.StackTrace + " => " + ex.InnerException;
            payroll.Status            = ParameterHelper.PAYROLL_EXCEPTION;
            session.Update(payroll);
            session.Flush();
            result = false;
        }
        return(result);
    }
Exemplo n.º 9
0
        private void Commitjob_transaction(ILog log)
        {
            try
            {
                IList <TrxPayroll> trxList = session.CreateCriteria(typeof(TrxPayroll))
                                             .Add(Expression.Eq("StatusEmail", ParameterHelper.PAYROLL_NEEDEMAIL))
                                             .Add(Expression.Or(Expression.Eq("Status", ParameterHelper.TRXSTATUS_COMPLETE), Expression.Eq("Status", ParameterHelper.TRXSTATUS_REJECT)))
                                             .AddOrder(Order.Asc("CreatedTime"))
                                             .List <TrxPayroll>();
                log.Info("Jumlah transaksi butuh email : " + trxList.Count);
                //we've found some data
                foreach (TrxPayroll trx in trxList)
                {
                    try
                    {
                        //update status running
                        trx.StatusEmail = ParameterHelper.PAYROLL_PROCESSEMAIL;
                        session.Update(trx);
                        session.Flush();


                        string user_id  = "";
                        int    clientID = trx.ClientID;

                        #region get user id
                        UserMap umap = null;
                        if (!string.IsNullOrEmpty(trx.Approver))
                        {
                            String[] tempmaker = trx.Approver.Split(new String[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                            foreach (String makinfo in tempmaker)
                            {
                                String[] detmake = makinfo.Split(new String[] { " - " }, StringSplitOptions.RemoveEmptyEntries);
                                umap = session.CreateCriteria(typeof(UserMap))
                                       .Add(Expression.Like("UserHandle", detmake[0].Trim()))
                                       .Add(Expression.Like("ClientEntity", clientID))
                                       .UniqueResult <UserMap>();
                                user_id = umap.UserEntity.ToString();
                            }
                        }

                        if (!string.IsNullOrEmpty(trx.Checker))
                        {
                            String[] tempmaker = trx.Checker.Split(new String[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                            foreach (String makinfo in tempmaker)
                            {
                                String[] detmake = makinfo.Split(new String[] { " - " }, StringSplitOptions.RemoveEmptyEntries);
                                umap = session.CreateCriteria(typeof(UserMap))
                                       .Add(Expression.Like("UserHandle", detmake[0].Trim()))
                                       .Add(Expression.Like("ClientEntity", clientID))
                                       .UniqueResult <UserMap>();
                                user_id += "|" + umap.UserEntity.ToString();
                            }
                        }

                        if (!string.IsNullOrEmpty(trx.Maker))
                        {
                            String[] tempmaker = trx.Maker.Split(new String[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                            foreach (String makinfo in tempmaker)
                            {
                                String[] detmake = makinfo.Split(new String[] { " - " }, StringSplitOptions.RemoveEmptyEntries);
                                umap = session.CreateCriteria(typeof(UserMap))
                                       .Add(Expression.Like("UserHandle", detmake[0].Trim()))
                                       .Add(Expression.Like("ClientEntity", clientID))
                                       .UniqueResult <UserMap>();
                                user_id += "|" + umap.UserEntity.ToString();
                            }
                        }
                        log.Info("User ID will send email = " + user_id);
                        #endregion


                        #region counttrx
                        ////trx.TrxPayrollDetail.
                        string _theTotalTrx = "";
                        IList <TrxPayrollDetail> ListSuccess = trx.TrxPayrollDetail;
                        int    countSuccess = 0;
                        int    countFail    = 0;
                        int    countTotal   = ListSuccess.Count;
                        double sumSuccess   = 0;
                        double sumFail      = 0;
                        double sumTotal     = 0;
                        foreach (TrxPayrollDetail a in ListSuccess)
                        {
                            if (a.Status == ParameterHelper.TRXSTATUS_SUCCESS)
                            {
                                countSuccess++;
                                sumSuccess += a.Amount;
                            }
                            else if (a.Status == ParameterHelper.TRXSTATUS_REJECT)
                            {
                                countFail++;
                                sumFail += a.Amount;
                            }
                            sumTotal += a.Amount;
                        }

                        //real amount
                        sumSuccess = sumSuccess / 100;
                        sumFail    = sumFail / 100;
                        sumTotal   = sumTotal / 100;
                        string _countSuccess = countSuccess.ToString();
                        string _sumSuccess   = sumSuccess.ToString();
                        string _countFail    = countFail.ToString();
                        string _sumFail      = sumFail.ToString();
                        string _countTotal   = countTotal.ToString();
                        string _sumTotal     = sumTotal.ToString();
                        //|berhasil|gagal|total|
                        //|17:56000|:|3:25612541|
                        trx.LastUpdate = DateTime.Now;
                        trx.TotalTrx   = "|" + _countSuccess + ":" + _sumSuccess + "|" + _countFail + ":" + _sumFail + "|" + _countTotal + ":" + _sumTotal + "|";
                        _theTotalTrx   = "|" + _countSuccess + ":" + _sumSuccess + "|" + _countFail + ":" + _sumFail + "|" + _countTotal + ":" + _sumTotal + "|";
                        log.Info("Trx Id = " + trx.Id + ", Total Trx : " + trx.TotalTrx);
                        session.Update(trx);
                        session.Flush();
                        #endregion



                        #region send email
                        String[] uid_np = user_id.Split(new String[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                        foreach (String idnp in uid_np)
                        {
                            UserMatrix      umx = session.Load <UserMatrix>(int.Parse(idnp));
                            AuthorityHelper ahe = new AuthorityHelper(umx.Matrix);
                            if (ahe.isNeedPendingEmail(100))
                            {
                                User uid = session.Load <User>(int.Parse(idnp));
                                //state=0->inProcess verify; state=1->inProc Approve; state=2->Succed; state=3->reject
                                if (trx.Status == ParameterHelper.TRXSTATUS_COMPLETE)
                                {
                                    EmailNotificationHelper.MassNotification(session, uid.Email, clientID, trx.SeqNumber, "Payroll", 2, trx.FileDescription, _theTotalTrx, "", trx.CreatedTime, trx.Maker, trx.ProcessTime, "Done");
                                }
                                else if (trx.Status == ParameterHelper.TRXSTATUS_REJECT)
                                {
                                    string rejectDesc = "";
                                    if (!string.IsNullOrEmpty(trx.Rejecter))
                                    {
                                        rejectDesc = "Rejected by " + trx.Rejecter;
                                    }
                                    else
                                    {
                                        string[] desc = trx.Description.Split(new String[] { "||" }, StringSplitOptions.RemoveEmptyEntries);
                                        rejectDesc = desc[0];
                                    }
                                    EmailNotificationHelper.MassNotification(session, uid.Email, clientID, trx.SeqNumber, "Payroll", 3, trx.FileDescription, _countTotal, _sumTotal, trx.CreatedTime, trx.Maker, trx.ProcessTime, "Reject (" + rejectDesc + ")");
                                }
                            }
                        }
                        log.Info("Email Send Successfully");
                        trx.StatusEmail = ParameterHelper.PAYROLL_DONEMAIL;
                        session.Update(trx);
                        session.Flush();



                        //if (trx.Status == ParameterHelper.TRXSTATUS_COMPLETE)
                        //{
                        //    String[] uid_np = nextProcessor.Split(new String[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
                        //    foreach (String idnp in uid_np)
                        //    {
                        //        UserMatrix umx = session.Load<UserMatrix>(int.Parse(idnp));
                        //        AuthorityHelper ahe = new AuthorityHelper(umx.Matrix);
                        //        if (ahe.isNeedPendingEmail(3600))
                        //        {
                        //            User uid = session.Load<User>(int.Parse(idnp));
                        //            //state=0->inProcess verify; state=1->inProc Approve; state=2->Succed; state=3->reject
                        //            EmailNotificationHelper.MassNotification(session, uid.Email, o.ClientId, massSWIFfile.Id, "Mass SWIFT", 0, massSWIFfile.FileDescription, counttrx, totalamount, massSWIFfile.CreatedTime, massSWIFfile.Maker, massSWIFfile.Valuedate, "Need Verify");
                        //        }
                        //    }

                        //}
                        //else if(trx.Status == ParameterHelper.TRXSTATUS_REJECT)
                        //{

                        //}
                        #endregion
                    }
                    catch (Exception e)
                    {
                        log.Error("Exception >>" + e.Message + ">>" + e.InnerException + ">>" + e.StackTrace);
                        trx.ErrorDescription = "Send Email Exception >>" + e.Message + ">>" + e.InnerException + ">>" + e.StackTrace;
                        trx.StatusEmail      = ParameterHelper.PAYROLL_EXCEPTIONEMAIL;
                        session.Update(trx);
                        session.Flush();
                    }
                }
            }
            catch (Exception e)
            {
                log.Error("Exception Send Email >>" + e.Message + ">>" + e.InnerException + ">>" + e.StackTrace);
            }
        }
Exemplo n.º 10
0
        public void emailNotification()
        {
            string[] username = null;
            string[] password = null;

            var oXMLData = new XMLParse();

            oXMLData.LoadXML("../../Config/ApplicationSettings.xml");

            username = oXMLData.getData("settings/Credentials", "username");
            password = oXMLData.getData("settings/Credentials", "password");

            //Initializing the objects
            var loginHelper             = new LoginHelper(GetWebDriver());
            var clientHelper            = new ClientsHelper(GetWebDriver());
            var emailNotificationHelper = new EmailNotificationHelper(GetWebDriver());

            // Variable
            var name = "Test" + RandomNumber(1, 99);


            //Login with valid username and password
            Login(username[0], password[0]);
            Console.WriteLine("Logged in as: " + username[0] + " / " + password[0]);

            //Verify Page title
            VerifyTitle("Dashboard");
            Console.WriteLine("Redirected at Dashboard screen.");

            //Click On  Admin
            emailNotificationHelper.RedirectToAdmin();


            //Redirect To URL
            emailNotificationHelper.RedirectToPage();

            //verify title
            VerifyTitle("E-Mail Notifications");


//########  CREATED

            //Click on When A Ticket Created
            emailNotificationHelper.ClickElement("WhenATicketCreated");

            //Click on Created Assigned To
            emailNotificationHelper.ClickElement("CreatedAssignedTo");

            //Click on Created Assigned Depatment
            emailNotificationHelper.ClickElement("CreatedAssignedDepatment");

            //Enter Email
            emailNotificationHelper.TypeText("EmailCreated", "*****@*****.**");

//#####  UPDATE

            //Click on When Ticket Update
            emailNotificationHelper.ClickElement("WhneTicketUpdate");


            //Click on Assigned To Update
            emailNotificationHelper.ClickElement("AssignedToUpdate");

            //Click on Assigned Manager Update
            emailNotificationHelper.ClickElement("AssignedManagerUpdate");

            //Enter Email
            emailNotificationHelper.TypeText("EmailUpdate", "*****@*****.**");

//#########  POSTED

            //Click on When Comment Posted
            emailNotificationHelper.ClickElement("WhenCommentPosted");

            //Click on Assigned To Posted
            emailNotificationHelper.ClickElement("AssignedToPosted");

            //Click on Assigned Department Posted
            emailNotificationHelper.ClickElement("AssignedDepartmentPosted");

            //Enter Email
            emailNotificationHelper.TypeText("EmailPosetd", "*****@*****.**");

            //Click on Save
            emailNotificationHelper.ClickElement("SaveBtn");

            //wait for text
            emailNotificationHelper.WaitForText("Alerts Saved Successfully.", 30);
        }