Beispiel #1
0
        public void GetAssistence(Quote q, string path)
        {
            q        = GetById(q.ID);
            q.Status = QuoteStatus.AssistenceRequired;

            IList <UserMember>   umlst = MembershipManager.GetAdministrators();
            MembershipHelperUser user  = MembershipHelper.GetUser();

            IList <Note> lst = ControllerManager.Note.ListByType(q.GetType(), q.ID, 1);

            foreach (UserMember userMember in umlst)
            {
                //PermissionManager.AddEntityPermision(q.GetType(), q.ID.ToString(), userMember.UserName);
                WebMailing w    = new WebMailing();
                string     body = File.ReadAllText(Path.Combine(HttpContext.Current.Server.MapPath(Config.MailTemplatePath), "quote.htm"));
                body = body.Replace("[QUOTE_CONTACT]", MembershipHelper.GetUser(userMember.ID).FullName);
                body = body.Replace("[QUOTE_BODY]", path);
                body = body.Replace("[QUOTE_OBSERVATION]", lst[0].Description);
                body = body.Replace("[USUARIO]", user.FullName);
                body = body.Replace("[EMAIL]", user.Email);

                w.SendMail(userMember.Email, "", "Se ha solicitado asistencia en la cotización " + q.Number, body, false);
            }

            Save(q);
        }
Beispiel #2
0
        public void Send(Quote q, byte[] filecontent)
        {
            string body = File.ReadAllText(
                Path.Combine(HttpContext.Current.Server.MapPath(Config.MailTemplatePath), "quote.htm"));

            string email = q.Email;

            if (string.IsNullOrEmpty(email))
            {
                email = q.Distributor.Email;
            }
            if (string.IsNullOrEmpty(email))
            {
                email = q.Distributor.AlternativeEmail;
            }
            q.Status = QuoteStatus.Sent;
            Save(q);
            this.CommitChanges();

            MembershipHelperUser mhu = MembershipHelper.GetUser(q.TimeStamp.CreatedBy);

            body = body.Replace("[QUOTE_BODY]", Resource.Business.GetString("QuoteBody"));
            body = body.Replace("[QUOTE_OBSERVATION]", q.Observations);
            body = body.Replace("[USUARIO]", mhu.FullName);
            body = body.Replace("[EMAIL]", mhu.Email);

            string title    = "Cotizaciones";
            string subject  = "Cotización para " + q.Distributor.Name;
            string fileName = "Cotizacion" + q.Number + ".pdf";

            IList <string> lstMails = new List <string>();

            lstMails.Add(email);
            if (mhu != null)
            {
                lstMails.Add(mhu.Email);
            }

            if (ControllerManager.Lookup.List(LookupType.AdministratorReceiveMail)[0].Description == "True")
            {
                IList <UserMember> umlst = MembershipManager.GetAdministrators();
                foreach (UserMember um in umlst)
                {
                    lstMails.Add(um.Email);
                }
            }

            WebMailing w = new WebMailing();

            foreach (string currentEmail in lstMails)
            {
                w.SendMail(currentEmail, title, subject, body, false, false, mhu.Email, mhu.FullName, fileName, filecontent);
            }
        }
Beispiel #3
0
        public bool Execute()
        {
            try
            {
                IList <UserMember> lstUsers = MembershipManager.GetAdministrators();
                if (lstUsers.Count > 0)
                {
                    IInterceptor interceptor = new SessionInterceptor(new UserContext(lstUsers[0].ID, lstUsers[0].UserName, DateTime.Now));
                    NHibernateSessionManager.Instance.RegisterInterceptorOn(Config.GrundfosFactoryConfigPath, interceptor);
                }
                else
                {
                    throw new Exception("Could not retrieve Administrator user from Membership database.");
                }

                #region Check if needs to be executed

                if (DateTime.Now.Hour >= Convert.ToInt32(ConfigurationManager.AppSettings["ExecuteHour"]))
                {
                    if (ControllerManager.Log.IsExecuting(Name, ExecutionStatus.Start))
                    {
                        return(true);
                    }
                    else
                    {
                        ControllerManager.Log.Add(Name, ExecutionStatus.Start, string.Empty);
                    }
                }
                else
                {
                    return(true);
                }

                #endregion

                Utils.GetLogger().Info("[[SCALA UPDATE]] Distributors Update Starting ");
                ControllerManager.Distributor.ScalaUpdate();

                Utils.GetLogger().Info("[[SCALA UPDATE]] Providers Update Starting ");
                ControllerManager.Provider.ScalaUpdate();

                ControllerManager.CurrentSession.Flush();

                //Utils.GetLogger().Info("[[CURRENCY UPDATE]] Currency Update Starting");
                //ControllerManager.CurrencyRate.Synchronize();

                //Utils.GetLogger().Info("[[CURRENCY UPDATE]] Currency Update Finished");
                //ControllerManager.CurrentSession.Flush();


                ControllerManager.Log.Add(Name, ExecutionStatus.Finished, "Sync process finished successfully");
            }
            catch (Exception e)
            {
                Utils.GetLogger().Error(e);
                ControllerManager.Log.Add(Name, ExecutionStatus.Running, e.ToString());
                return(false);
            }

            return(true);
        }
Beispiel #4
0
        public void Send(Quote q, byte[] filecontent)
        {
            MembershipHelperUser mhu      = MembershipHelper.GetUser(q.TimeStamp.CreatedBy);
            IList <string[]>     lstMails = new List <string[]>();

            if (q.QuoteNotifications.Count > 0)
            {
                foreach (IQuoteNotification quoteNotification in q.QuoteNotifications)
                {
                    string[] _contact = new string[2];
                    _contact[0] = quoteNotification.Name;
                    _contact[1] = quoteNotification.Email;
                    lstMails.Add(_contact);
                }
            }
            else
            {
                string name  = q.Distributor.Contact;
                string email = q.Distributor.Email;
                if (string.IsNullOrEmpty(email))
                {
                    email = q.Distributor.AlternativeEmail;
                }

                string[] _contact = new string[2];
                _contact[0] = name;
                _contact[1] = email;
                lstMails.Add(_contact);
            }


            if (mhu != null)
            {
                string[] _contact = new string[2];
                _contact[0] = mhu.FullName;
                _contact[1] = mhu.Email;
                lstMails.Add(_contact);
            }

            if (ControllerManager.Lookup.List(LookupType.AdministratorReceiveMail)[0].Description == "True")
            {
                IList <UserMember> umlst = MembershipManager.GetAdministrators();
                foreach (UserMember um in umlst)
                {
                    string[] _contact = new string[2];
                    _contact[0] = um.UserName;
                    _contact[1] = um.Email;
                    lstMails.Add(_contact);
                }
            }

            string title    = "Cotizaciones";
            string subject  = "Cotización para " + q.Distributor.Name;
            string fileName = "Cotizacion" + q.Number + ".pdf";

            WebMailing w = new WebMailing();

            foreach (string[] currentEmail in lstMails)
            {
                string body = File.ReadAllText(Path.Combine(HttpContext.Current.Server.MapPath(Config.MailTemplatePath), "quote.htm"));
                body = body.Replace("[QUOTE_CONTACT]", currentEmail[0]);
                body = body.Replace("[QUOTE_BODY]", Resource.Business.GetString("QuoteBody"));
                body = body.Replace("[QUOTE_OBSERVATION]", q.Observations);
                body = body.Replace("[USUARIO]", mhu.FullName);
                body = body.Replace("[EMAIL]", mhu.Email);

                w.SendMail(currentEmail[1], title, subject, body, false, false, mhu.Email, mhu.FullName, fileName, filecontent);
            }

            q.Status = QuoteStatus.Sent;
            if (q.SentDate == null)
            {
                q.SentDate = DateTime.Now;
            }
            repository.Save(q);
            repository.CommitChange();
        }