예제 #1
0
        public void SetUp()
        {
            var contactGroupOwner = new ContactGroupOwner();

            session.Save(contactGroupOwner);
            _contactGroup = new ContactGroup(ContactGroupType.Reports, "testGroup")
            {
                ContactGroupOwner = contactGroupOwner
            };
            session.Save(_contactGroup);
            var contact = new Contact(ContactType.Email, "*****@*****.**")
            {
                ContactOwner = _contactGroup
            };

            _contactGroup.Contacts.Add(contact);
            var payer = new Payer("testPayer");

            session.Save(payer);
            var contactPayer = new Contact(ContactType.Email, "*****@*****.**")
            {
                ContactOwner = _contactGroup
            };

            _contactGroup.Contacts.Add(contactPayer);
            session.Save(_contactGroup);
            session.Save(payer);
            var payerOwner = new PayerOwnerContact {
                Payer = payer, Contact = contactPayer
            };

            session.Save(payerOwner);
        }
예제 #2
0
        public virtual List <PhoneCommented> GetPhonesForSendingSms()
        {
            var result = new List <PhoneCommented>();
            ContactGroupOwner owner = null;
            var groups = new ContactGroupType[0];

            if (RootService is Client)
            {
                groups = new[] { ContactGroupType.OrderManagers };
                owner  = ((Client)RootService).ContactGroupOwner;
            }
            else if (RootService is Supplier)
            {
                groups = new[] { ContactGroupType.OrderManagers, ContactGroupType.ClientManagers };
                owner  = ((Supplier)RootService).ContactGroupOwner;
            }

            if (owner != null)
            {
                result = owner.GetPhones(groups).ToList();
                if (result.Count == 0)
                {
                    result = owner.GetPhones(ContactGroupType.General).ToList();
                }
            }
            return(result);
        }
예제 #3
0
        public virtual string GetAddressForSendingClientCard()
        {
            ContactGroupOwner owner = null;
            var groups = new ContactGroupType[0];

            if (RootService is Client)
            {
                groups = new[] { ContactGroupType.OrderManagers };
                owner  = ((Client)RootService).ContactGroupOwner;
            }
            else if (RootService is Supplier)
            {
                groups = new[] { ContactGroupType.OrderManagers, ContactGroupType.ClientManagers };
                owner  = ((Supplier)RootService).ContactGroupOwner;
            }

            if (owner == null)
            {
                return("");
            }

            var emails = owner.GetEmails(groups);

            if (emails.Any())
            {
                return(emails.Implode());
            }

            return(owner.GetEmails(ContactGroupType.General).Implode());
        }
        public void Show()
        {
            var privateGroup = new ContactGroup(_contactGroupOwner, ContactGroupType.Reports)
            {
                Name = "Приватная рассылка"
            };

            session.Save(privateGroup);
            var publicGroup = new ContactGroup(_contactGroupOwner, ContactGroupType.ReportSubscribers)
            {
                Name = "Публичная рассылка"
            };

            session.Save(publicGroup);
            _report.ContactGroup        = privateGroup;
            _report.PublicSubscriptions = publicGroup;
            session.Save(_report);
            var privateContact = new Contact(ContactType.Email, "*****@*****.**")
            {
                ContactOwner = privateGroup
            };

            session.Save(privateContact);
            var publicContact = new Contact(ContactType.Email, "*****@*****.**")
            {
                ContactOwner = publicGroup
            };

            session.Save(publicContact);
            var contactGroupOwner = new ContactGroupOwner();

            session.Save(contactGroupOwner);
            var payerContactOwner = new ContactGroup(contactGroupOwner, ContactGroupType.ReportSubscribers);

            session.Save(payerContactOwner);
            var payer = new Payer("Тестовый плательщик")
            {
                ContactGroupOwner = contactGroupOwner
            };

            session.Save(payer);
            var payercontact = new Contact(payerContactOwner)
            {
                ContactText = "*****@*****.**"
            };

            session.Save(payercontact);
            var reportSub = new ReportSubscriptionContact(payercontact, publicContact);

            session.Save(reportSub);

            Open($"/Contacts/Show?reportId={_report.Id}");

            AssertText("*****@*****.**");
            AssertText("*****@*****.**");
            AssertText("Тестовый плательщик");
            AssertText("Приватная рассылка");
        }
        public void SetUp()
        {
            _report = new GeneralReport()
            {
                EMailSubject = "Тестовый отчет"
            };
            var ownerId = uint.Parse(ConfigurationManager.AppSettings["ReportsContactGroupOwnerId"]);

            _contactGroupOwner = session.Get <ContactGroupOwner>(ownerId);
            session.Save(_report);
        }
예제 #6
0
        public Payer(string name, string fullname)
            : this()
        {
            Name              = name;
            JuridicalName     = fullname;
            Customer          = fullname;
            ContactGroupOwner = new ContactGroupOwner();
            JuridicalOrganizations.Add(new LegalEntity(this));
            Comment = "";

            Init(SecurityContext.Administrator);
        }
        private void AddContacts(ContactGroupOwner owner, Contact[] clientContacts)
        {
            var generalGroup = owner.AddContactGroup(ContactGroupType.General);

            foreach (var contact in clientContacts)
            {
                if (contact.ContactText != null)
                {
                    generalGroup.AddContact(contact);
                }
            }
            DbSession.Save(owner);
        }
예제 #8
0
        public virtual void Init(Administrator admin)
        {
            Registration = new RegistrationInfo(admin);

            if (ContactGroupOwner == null)
            {
                ContactGroupOwner = new ContactGroupOwner();
            }

            if (!ContactGroupOwner.HaveGroup(ContactGroupType.Billing))
            {
                ContactGroupOwner.AddContactGroup(ContactGroupType.Billing);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(Request["TemporaryId"]))
            {
                Response.Redirect("base.aspx");
            }
            else
            {
                uint contactOwnerId;
                if (uint.TryParse(ConfigurationManager.AppSettings["ReportsContactGroupOwnerId"], out contactOwnerId))
                {
                    try {
                        _reportsContactGroupOwner = ContactGroupOwner.Find(contactOwnerId);
                    }
                    catch (NotFoundException exp) {
                        throw new ReportTunerException("В файле Web.Config параметр ReportsContactGroupOwnerId указывает на несуществующую запись.", exp);
                    }
                }
                else
                {
                    throw new ReportTunerException("В файле Web.Config параметр ReportsContactGroupOwnerId не существует или настроен некорректно.");
                }

                _generalReport = GeneralReport.Find(Convert.ToUInt64(Request["TemporaryId"]));
                _taskService   = ScheduleHelper.GetService();
                _currentTask   = ScheduleHelper.GetTaskOrCreate(
                    _taskService,
                    ScheduleHelper.GetReportsFolder(_taskService),
                    _generalReport.Id,
                    "Временный отчет, созданный " + _generalReport.TemporaryCreationDate.Value.ToString(), "GR");

                btnRun.Enabled = _currentTask.Enabled && (_currentTask.State != TaskState.Running);
                btnRun.Text    = (_currentTask.State == TaskState.Running) ? StatusNotRunning : StatusRunning;

                if ((_generalReport.ContactGroup == null) && btnRun.Enabled)
                {
                    btnRun.Enabled = false;
                }

                if (!IsPostBack)
                {
                    ClearSearch();
                    if (_generalReport.ContactGroup != null)
                    {
                        lContactGroupName.Text = _generalReport.ContactGroup.Name;
                    }
                }
            }
        }
예제 #10
0
        public virtual void MergePerson(ContactGroupType type, Person person)
        {
            var group = ContactGroupOwner.ContactGroups.FirstOrDefault(g => g.Type == type)
                        ?? ContactGroupOwner.AddContactGroup(type);

            var exists = group.Persons.FirstOrDefault(p => String.Equals(p.Name, person.Name, StringComparison.CurrentCultureIgnoreCase));

            if (exists == null)
            {
                group.Persons.Add(person);
                group.Adopt();
            }
            else
            {
                foreach (var contact in person.Contacts)
                {
                    if (!exists.Contacts.Any(c => c.Type == contact.Type && String.Equals(contact.ContactText, c.ContactText, StringComparison.CurrentCultureIgnoreCase)))
                    {
                        exists.AddContact(new Contact(contact.Type, contact.ContactText, contact.Comment));
                    }
                }
            }
        }
예제 #11
0
 public virtual string GetEmailsForBilling()
 {
     return(ContactGroupOwner
            .GetEmails(ContactGroupType.Billing)
            .Implode());
 }