protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            CurrentUser = GetCurrentUser();
            Mails       = new EmailSender(DB, DB2, CurrentUser);
            Mails.IP    = Request.UserHostAddress;
            SecurityCheck(CurrentUser, TypeUsers.ProducerUser, filterContext);

            if (CurrentUser != null)
            {
                CurrentAdmin       = GetCurrentAdmin();
                CurrentUser.ID_LOG = CurrentAdmin?.Id ?? CurrentUser.Id;
                CurrentUser.IP     = Request.UserHostAddress;
                if (CurrentUser.AccountCompany.ProducerId != null)
                {
                    ViewBag.Producernames = DB.producernames.Single(x => x.ProducerId == CurrentUser.AccountCompany.ProducerId).ProducerName;
                }
                else
                {
                    ViewBag.Producernames = "Физическое лицо";
                }
                ViewBag.CurrentUser = CurrentUser;
                ViewBag.AdminUser   = CurrentAdmin;
            }
        }
Exemple #2
0
        public PromotionSnapshot(ProducerInterfaceCommon.ContextModels.Account author,
                                 Promotion promotion,
                                 producerinterface_Entities db,
                                 Context db2,
                                 string comment = null)
        {
            Author          = db2.Users.Find(author.Id);
            AuthorName      = Author.DisplayName;
            CreatedOn       = DateTime.Now;
            Promotion       = promotion;
            Name            = promotion.Name;
            SnapshotName    = "Изменена промоакция";
            SnapshotComment = comment;
            Annotation      = promotion.Annotation;
            Status          = promotion.GetStatus().DisplayName();
            Begin           = promotion.Begin;
            End             = promotion.End;
            File            = promotion.MediaFile;
            var ids      = promotion.PromotionToDrug.Select(x => x.DrugId).ToArray();
            var products = db.assortment.Where(x => ids.Contains(x.CatalogId)).Select(x => x.CatalogName).ToArray();

            ProductsJson = JsonConvert.SerializeObject(products);
            var regions = db.Regions((ulong)promotion.RegionMask).Select(x => x.Name).ToArray();

            RegionsJson = JsonConvert.SerializeObject(regions);
            ids         = promotion.PromotionsToSupplier.Select(x => x.SupplierId).ToArray();
            var suppliers = db.suppliernames.Where(x => ids.Contains(x.SupplierId)).Select(x => x.SupplierName).ToArray();

            SuppliersJson = JsonConvert.SerializeObject(suppliers);
        }
Exemple #3
0
 public override void Init(ProducerInterfaceCommon.ContextModels.Account currentUser)
 {
     base.Init(currentUser);
     if (ProducerId == null)
     {
         Var = CatalogVar.AllAssortment;
     }
 }
 public EmailSender(producerinterface_Entities db, Context db2,
                    Account currentUser)
 {
     this.db          = db;
     this.db2         = db2;
     this.currentUser = currentUser;
     diagnostics      = new DiagnosticInformation(currentUser);
 }
        private void MessageForUser(MailType type, Account targetUser, object args)
        {
            var values = new Dictionary <string, object> {
                { "UserName", targetUser.Name },
                { "UserLogin", targetUser.Login },
            };

            MessageFromTemplate(type, targetUser.Login, Merge(values, ToMap(args)));
        }
        // Обратная связь, сотрудникам
        public static void SendFeedBackMessage(producerinterface_Entities cntx, Account user, string message, string Ip)
        {
            var siteName = ConfigurationManager.AppSettings["SiteName"];
            var mailInfo = ConfigurationManager.AppSettings["MailInfo"];
            var subject  = $"Сообщение пользователя с сайта {siteName}";

            var di = new DiagnosticInformation(user)
            {
                Body = message, ActionName = "Обратная связь"
            };

            EmailSender.SendEmail(mailInfo, subject, di.ToString(cntx), null, false);
        }
        // Именение МНН препарата, сотрудникам
        public static void SendMnnChangeMessage(producerinterface_Entities cntx, Account user, string catalogName, string before, string after)
        {
            var siteName = ConfigurationManager.AppSettings["SiteName"];
            var mailForm = cntx.mailformwithfooter.Single(x => x.Id == (int)MailType.CatalogMNN);
            var subject  = ReliableTokenizer(mailForm.Subject, new { SiteName = siteName });
            var body     = $"{ReliableTokenizer(mailForm.Body, new { CatalogName = catalogName, Before = before, After = after })}";

            var di = new DiagnosticInformation(user)
            {
                Body = body, ActionName = MailType.CatalogMNN.DisplayName()
            };
            var catalogChangeEmail = ConfigurationManager.AppSettings["CatalogChangeEmail"];

            EmailSender.SendEmail(catalogChangeEmail, subject, di.ToString(cntx), null, false);
        }
        // Запрос регистрации производителя, расширенное сотрудникам
        public static void ProducerRequestMessage(producerinterface_Entities cntx, Account user, string message, string contacts)
        {
            var siteName = ConfigurationManager.AppSettings["SiteName"];
            var mailForm = cntx.mailformwithfooter.Single(x => x.Id == (int)MailType.ProducerRequest);
            var subject  = ReliableTokenizer(mailForm.Subject, new { SiteName = siteName });
            var body     = $"{ReliableTokenizer(mailForm.Body, new { Message = message, Contacts = contacts })}";

            var di = new DiagnosticInformation(user)
            {
                Body = body, ActionName = MailType.ProducerRequest.DisplayName()
            };
            var mailInfo = ConfigurationManager.AppSettings["MailInfo"];

            EmailSender.SendEmail(mailInfo, subject, di.ToString(cntx), null, false);
        }
 public DiagnosticInformation(Account user)
 {
     User = user;
 }
        // Отклонение правки в каталог
        public static bool SendRejectCatalogChangeMessage(producerinterface_Entities cntx, Account user, string catalogName,
                                                          string fieldName, string before, string after, string comment)
        {
            //throw new NotImplementedException();
            bool mailSentToTheUser = false;
            var  siteName          = ConfigurationManager.AppSettings["SiteName"];
            var  mailForm          = cntx.mailformwithfooter.Single(x => x.Id == (int)MailType.RejectCatalogChange);
            var  subject           = ReliableTokenizer(mailForm.Subject, new { SiteName = siteName });
            var  header            = ReliableTokenizer(mailForm.Header, new { UserName = user.Name });
            var  body =
                $"{header}\r\n\r\n{ReliableTokenizer(mailForm.Body, new {FieldName = fieldName, CatalogName = catalogName, Before = before, After = after, Comment = comment})}\r\n\r\n{mailForm.Footer}";

            //var attachments = EmailSender.GetAttachments(cntx, MailType.RejectCatalogChange);

            if (!user.IsAdmin || user.IsAdmin && user.Login.IndexOf("@") != -1)
            {
                EmailSender.SendEmail(user.Login, subject, body, new List <string>(), false);
                mailSentToTheUser = true;
            }
            var di = new DiagnosticInformation(user)
            {
                Body = body, ActionName = MailType.RejectCatalogChange.DisplayName()
            };
            var mailInfo = ConfigurationManager.AppSettings["MailInfo"];

            EmailSender.SendEmail(mailInfo, subject, di.ToString(cntx), new List <string>(), false);
            return(mailSentToTheUser);
        }
 public void RegistrationReject(Account targetUser, string comment)
 {
     MessageForUser(MailType.RegistrationRejected, targetUser, new { Comment = comment });
 }
 // Подтверждение регистрации пользователя без производителя
 public void SendAccountVerificationMessage(Account targetUser, string password)
 {
     MessageForUser(MailType.AccountVerification, targetUser, new { Password = password });
 }
 // Восстановление пароля, пользователю и расширенное сотрудникам
 public void SendPasswordRecoveryMessage(Account targetUser, string password)
 {
     MessageForUser(MailType.PasswordRecovery, targetUser, new { Password = password });
 }
 // Смена пароля, пользователю и расширенное сотрудникам
 public void SendPasswordChangeMessage(Account targetUser, string password)
 {
     MessageForUser(MailType.PasswordChange, targetUser, new { Password = password, });
 }
 // Регистрация в системе, пользователю и расширенное сотрудникам
 public void SendRegistrationMessage(Account targetUser, string password)
 {
     MessageForUser(MailType.Registration, targetUser, new { Password = password, });
 }
 public virtual void Init(ProducerInterfaceCommon.ContextModels.Account currentUser)
 {
     ProducerId = currentUser.AccountCompany.ProducerId;
 }