Beispiel #1
0
        public static ContactInformationDataContext ContactDataContext()
        {
            ConnectionStringSettings      connectionSettings = ConfigurationManager.ConnectionStrings["dao.owens.sql.connectionstring"];
            ContactInformationDataContext contactRepository  = new  ContactInformationDataContext(connectionSettings.ConnectionString);

            return(contactRepository);
        }
Beispiel #2
0
        private static IList <ContactForm> GetAllContactFormsFromRepository(ContactInformationDataContext repository)
        {
            IList <ContactForm> contacts = (from contact in repository.oc_contactlists
                                            select BuildContactForm(contact)).ToList();

            return(contacts);
        }
Beispiel #3
0
 private static int InsertItem(ContactForm form)
 {
     ValidateForm(form);
     using (ContactInformationDataContext repository = ContactDataSource.ContactDataContext())
     {
         oc_contactlist contact = new oc_contactlist
         {
             business_area    = form.BusinessArea,
             source_form_name = form.SourceFormName,
             source_form_path = form.SourcePath,
             external_key     = form.ExternalKey,
             external_date    = form.ExternalDate,
             contact_type     = form.ContactTypes,
             contact_fullname = form.Name,
             contact_email    = form.Email,
             contact_phone    = form.Phone,
             company_name     = form.Company,
             language         = form.Language,
             xml_form_data    = form.FormData,
             date_created     = DateTime.Now
         };
         repository.oc_contactlists.InsertOnSubmit(contact);
         repository.SubmitChanges();
         return(contact.pk_id);
     }
 }
Beispiel #4
0
 public static IList <ContactForm> GetAllContacts()
 {
     using (ContactInformationDataContext repository = ContactDataSource.ContactDataContext())
     {
         IList <ContactForm> contacts = GetAllContactFormsFromRepository(repository);
         return(contacts);
     }
 }
Beispiel #5
0
 public static ContactForm GetContactFormById(int formId)
 {
     using (ContactInformationDataContext repository = ContactDataSource.ContactDataContext())
     {
         ContactForm form = (from contact in repository.oc_contactlists
                             where contact.pk_id == formId
                             select BuildContactForm(contact)).FirstOrDefault();
         return(form);
     }
 }
Beispiel #6
0
 public static IList <ContactForm> GetLast100Contacts()
 {
     // Just for convinience lets show last 100 contacts
     using (ContactInformationDataContext repository = ContactDataSource.ContactDataContext())
     {
         //
         IList <ContactForm> contacts = (from contact in repository.oc_contactlists
                                         orderby contact.date_created descending
                                         select BuildContactForm(contact, repository.GetDmaXmlFromFormData(contact.xml_form_data))).Take(100).ToList();
         return(contacts);
     }
 }
Beispiel #7
0
 public static IList <ContactForm> GetContactsByCriteria(string formName, DateTime startDate, DateTime endDate)
 {
     // Just for convinience lets show last 100 contacts
     using (ContactInformationDataContext repository = ContactDataSource.ContactDataContext())
     {
         var contactForms = (from contact in repository.oc_contactlists
                             where (String.IsNullOrEmpty(formName) || contact.source_form_name == formName)
                             &&
                             (DateTime.MinValue == startDate || contact.date_created >= startDate) &&
                             (DateTime.MaxValue == endDate || contact.date_created <= endDate)
                             orderby contact.date_created descending
                             select BuildContactForm(contact, repository.GetDmaXmlFromFormData(contact.xml_form_data)));
         return(contactForms.ToList());
     }
 }
Beispiel #8
0
 public static IList <ContactFormType> GetContactFormTypes()
 {
     using (ContactInformationDataContext repository = ContactDataSource.ContactDataContext())
     {
         var formTypes = (from contact in repository.oc_contactlists
                          select contact.source_form_name).Distinct();
         List <ContactFormType> formTypeList = new List <ContactFormType>();
         foreach (var formType in formTypes)
         {
             formTypeList.Add(new ContactFormType {
                 SourceFormName = formType
             });
         }
         return(formTypeList);
     }
 }
Beispiel #9
0
 public static ContactFormType GetContactFormType(string sourceFormName)
 {
     using (ContactInformationDataContext repository = ContactDataSource.ContactDataContext())
     {
         var formTypes = (from mapping in repository.ContactListNameMaps
                          where string.Equals(mapping.SourceFormName, sourceFormName)
                          select new ContactFormType()
         {
             Active = mapping.Active,
             SourceFormName = mapping.SourceFormName,
             Name = mapping.Name,
             ColumnMap = mapping.ColumnMap,
             BusinessName = mapping.BusinessName
         });
         return(formTypes.SingleOrDefault());
     }
 }
Beispiel #10
0
 public static IList <ContactForm> GetContactsByCriteria(string businessArea, IEnumerable <string> formNames, DateTime startDate, DateTime endDate)
 {
     // Just for convinience lets show last 100 contacts
     using (ContactInformationDataContext repository = ContactDataSource.ContactDataContext())
     {
         var contactForms = (from contact in repository.oc_contactlists
                             join map in repository.ContactListNameMaps
                             on contact.source_form_name equals map.SourceFormName
                             where (formNames.Where(x => x != string.Empty).Count() == 0 || formNames.Contains(map.Name)) &&
                             (businessArea == null || businessArea == string.Empty || businessArea == map.BusinessName)
                             &&
                             (DateTime.MinValue == startDate || contact.date_created >= startDate) &&
                             (DateTime.MaxValue == endDate || contact.date_created <= endDate)
                             orderby contact.date_created descending
                             select BuildContactForm(contact, repository.GetDmaXmlFromFormData(contact.xml_form_data)));
         return(contactForms.ToList());
     }
 }
Beispiel #11
0
        internal static IList <ContactFormBusinessArea> GetContactFormBusinessAreas()
        {
            using (ContactInformationDataContext repository = ContactDataSource.ContactDataContext())
            {
                var businessAreas = (from mapping in repository.ContactListNameMaps
                                     where mapping.BusinessName != string.Empty
                                     select mapping.BusinessName).Distinct();

                List <ContactFormBusinessArea> formBusinessAreaList = new List <ContactFormBusinessArea>();
                foreach (var businessArea in businessAreas)
                {
                    formBusinessAreaList.Add(new ContactFormBusinessArea {
                        BusinessArea = businessArea
                    });
                }

                return(formBusinessAreaList);
            }
        }
Beispiel #12
0
 public static IList <ContactFormType> GetContactFormTypes(string businessArea)
 {
     using (ContactInformationDataContext repository = ContactDataSource.ContactDataContext())
     {
         var formTypes = (from contact in repository.oc_contactlists
                          join map in repository.ContactListNameMaps
                          on contact.source_form_name equals map.SourceFormName into tempMappings
                          from mapping in tempMappings.DefaultIfEmpty()            // allow nulls in the join. . .
                          where string.IsNullOrEmpty(businessArea) ? true :        // Only obtain items from the business area, if one is present.
                          mapping != null ? mapping.BusinessName == businessArea : // Attempt to check from the business name first. . .
                          contact.business_area == businessArea
                          select new ContactFormType()
         {
             Active = mapping != null ? mapping.Active : false,
             SourceFormName = mapping == null ? contact.source_form_name : mapping.Name,
             Name = mapping.Name,
             ColumnMap = mapping.ColumnMap,
             BusinessName = mapping.BusinessName
         }).Distinct().OrderByDescending(x => x.Active);
         return(formTypes.ToList());
     }
 }