public void GetContactExportParametersTest() { AllClientsAccount account = new AllClientsAccount { AccountId = 1000, APIKey = "123456789" }; AllClientsWebform webform = new AllClientsWebform { Account = account, FormKey = "123", FormName = "TestForm", WebformType = Types.Enumerations.WebformType.ActiveCustomer }; AllClientsContactExport export = new AllClientsContactExport(); export.AllClientsWebform = webform; export.Account = account; export.Contact = CommonService.FromXml(typeof(AllClientsContact), GetWellKnownContactElement().ToString()) as AllClientsContact; Dictionary<string, string> actual; actual = AllClientsService.GetContactExportParameters(export); Assert.IsTrue(actual.ContainsKey("accountid")); Assert.IsTrue(actual.ContainsKey("apikey")); Assert.IsTrue(actual.ContainsKey("birthday_month")); Assert.IsTrue(actual.ContainsKey("birthday_day")); Assert.IsTrue(actual.ContainsKey("birthday_year")); }
public static List<AllClientsWebform> GetSampleWebforms() { List<AllClientsWebform> result = new List<AllClientsWebform>(); XElement webforms = XElement.Load(String.Format("{0}\\Resources\\AllClientsWebforms.xml", AppDomain.CurrentDomain.BaseDirectory)); //standard form names string leadToCustomerFormName = "5. sys_action_import_lead to customer"; string customerFormName = "4. sys_action_import_customer"; string customerInactiveFormName = "2. sys_action_import_customer_inactive"; string leadFormName = "3. sys_action_import_lead"; string newCustomerFormName = "1. sys_action_import_customer_new"; //webforms from All Clients as Elements XElement leadToCustomerForm = webforms.Descendants("webform").Where(n => n.Element("name").Value == leadToCustomerFormName).First(); XElement customerForm = webforms.Descendants("webform").Where(n => n.Element("name").Value == customerFormName).First(); XElement customerInactiveForm = webforms.Descendants("webform").Where(n => n.Element("name").Value == customerInactiveFormName).First(); XElement leadForm = webforms.Descendants("webform").Where(n => n.Element("name").Value == leadFormName).First(); XElement newCustomerForm = webforms.Descendants("webform").Where(n => n.Element("name").Value == newCustomerFormName).First(); //Assign new forms with FormKeys AllClientsWebform leadToCustomerWebForm = new AllClientsWebform(); leadToCustomerWebForm.WebformType = Enumerations.WebformType.LeadToCustomer; leadToCustomerWebForm.FormKey = leadToCustomerForm.Element("formkey").Value; AllClientsWebform customerWebform = new AllClientsWebform(); customerWebform.WebformType = Enumerations.WebformType.ActiveCustomer; customerWebform.FormKey = customerForm.Element("formkey").Value; AllClientsWebform customerInactiveWebform = new AllClientsWebform(); customerInactiveWebform.WebformType = Enumerations.WebformType.InactiveCustomer; customerInactiveWebform.FormKey = customerInactiveForm.Element("formkey").Value; AllClientsWebform customerLeadWebform = new AllClientsWebform(); customerLeadWebform.WebformType = Enumerations.WebformType.Lead; customerLeadWebform.FormKey = leadForm.Element("formkey").Value; AllClientsWebform newCustomerWebform = new AllClientsWebform(); newCustomerWebform.WebformType = Enumerations.WebformType.NewCustomer; newCustomerWebform.FormKey = leadForm.Element("formkey").Value; //Assign Accounts //Assign FormName leadToCustomerWebForm.FormName = leadToCustomerFormName; customerWebform.FormName = customerFormName; customerInactiveWebform.FormName = customerInactiveFormName; customerLeadWebform.FormName = leadFormName; newCustomerWebform.FormName = newCustomerFormName; result.Add(leadToCustomerWebForm); result.Add(customerWebform); result.Add(customerInactiveWebform); result.Add(customerLeadWebform); result.Add(newCustomerWebform); return result; }
public static List<AllClientsWebform> GetAllClientsWebforms(AllClientsAccount account) { List<AllClientsWebform> result = new List<AllClientsWebform>(); try { XElement webforms = CommonService.AllClientsRequest("GetWebforms.aspx", account.AccountId, account.APIKey); //standard form names string appointmentReminderFormName = "6. sys_action_assign_appt_reminder"; string leadToCustomerFormName = "5. sys_action_import_lead to customer"; string customerFormName = "4. sys_action_import_customer"; string customerInactiveFormName = "2. sys_action_import_customer_inactive"; string leadFormName = "3. sys_action_import_lead"; string newCustomerFormName = "1. sys_action_import_customer_new"; string aimsAutoNotificationFormName = "AIMS Auto Notification"; //webforms from All Clients as Elements XElement leadToCustomerForm = webforms.Descendants("webform").Where(n => n.Element("name").Value == leadToCustomerFormName).First(); XElement customerForm = webforms.Descendants("webform").Where(n => n.Element("name").Value == customerFormName).First(); XElement customerInactiveForm = webforms.Descendants("webform").Where(n => n.Element("name").Value == customerInactiveFormName).First(); XElement leadForm = webforms.Descendants("webform").Where(n => n.Element("name").Value == leadFormName).First(); XElement newCustomerForm = webforms.Descendants("webform").Where(n => n.Element("name").Value == newCustomerFormName).First(); XElement aimsAutoNotificationForm = webforms.Descendants("webform").Where(n => n.Element("name").Value == aimsAutoNotificationFormName).FirstOrDefault(); XElement appointmentReminderForm = webforms.Descendants("webform").Where(n => n.Element("name").Value == appointmentReminderFormName).FirstOrDefault(); //Assign new forms with FormKeys AllClientsWebform leadToCustomerWebForm = new AllClientsWebform(); leadToCustomerWebForm.WebformType = Enumerations.WebformType.LeadToCustomer; leadToCustomerWebForm.FormKey = leadToCustomerForm.Element("formkey").Value; AllClientsWebform customerWebform = new AllClientsWebform(); customerWebform.WebformType = Enumerations.WebformType.ActiveCustomer; customerWebform.FormKey = customerForm.Element("formkey").Value; AllClientsWebform customerInactiveWebform = new AllClientsWebform(); customerInactiveWebform.WebformType = Enumerations.WebformType.InactiveCustomer; customerInactiveWebform.FormKey = customerInactiveForm.Element("formkey").Value; AllClientsWebform customerLeadWebform = new AllClientsWebform(); customerLeadWebform.WebformType = Enumerations.WebformType.Lead; customerLeadWebform.FormKey = leadForm.Element("formkey").Value; AllClientsWebform newCustomerWebform = new AllClientsWebform(); newCustomerWebform.WebformType = Enumerations.WebformType.NewCustomer; newCustomerWebform.FormKey = newCustomerForm.Element("formkey").Value; if (aimsAutoNotificationForm != null) { AllClientsWebform aimsAutoNotificationWebform = new AllClientsWebform(); aimsAutoNotificationWebform.WebformType = Enumerations.WebformType.AutoNotification; aimsAutoNotificationWebform.FormKey = aimsAutoNotificationForm.Element("formkey").Value; aimsAutoNotificationWebform.Account = account; result.Add(aimsAutoNotificationWebform); } if (appointmentReminderForm != null) { AllClientsWebform appointmentReminderWebForm = new AllClientsWebform(); appointmentReminderWebForm.WebformType = Enumerations.WebformType.AppointmentReminder; appointmentReminderWebForm.FormKey = appointmentReminderForm.Element("formkey").Value; appointmentReminderWebForm.Account = account; result.Add(appointmentReminderWebForm); } //Assign Accounts leadToCustomerWebForm.Account = account; customerWebform.Account = account; customerInactiveWebform.Account = account; customerLeadWebform.Account = account; newCustomerWebform.Account = account; //Assign FormName leadToCustomerWebForm.FormName = leadToCustomerFormName; customerWebform.FormName = customerFormName; customerInactiveWebform.FormName = customerInactiveFormName; customerLeadWebform.FormName = leadFormName; newCustomerWebform.FormName = newCustomerFormName; result.Add(leadToCustomerWebForm); result.Add(customerWebform); result.Add(customerInactiveWebform); result.Add(customerLeadWebform); result.Add(newCustomerWebform); return result; } catch (System.Exception ex) { throw new AccountSetupException(String.Format("Could not retrieve expected webforms for client: {0}", account.ClientName), ex); } }