void IDL.updateTester(int id, Tester updatedTester, bool[,] updatedSchedule) { XElement testerElement = (from item in TesterRoot.Elements() where int.Parse(item.Element("ID").Value) == id select item).FirstOrDefault(); if (testerElement == null) { throw new TestersIdNotFoundException(id); } testerElement.Remove(); TesterRoot.Add(updatedTester.ToXmlTester()); TesterRoot.Save(TesterPath); XElement scheduleXelement = ScheduleRoot.Elements() .Where(item => item.Element("ID").Value == id.ToString()) .FirstOrDefault(); if (scheduleXelement != null) { scheduleXelement.Remove(); } XElement testersId = new XElement("ID", id.ToString()); ScheduleRoot.Add(new XElement("TesterSchedule", testersId, updatedSchedule.ToXmlSchedule())); ScheduleRoot.Save(SchedulePath); }
public string GetSubject(ScheduleRoot schedule, string label) { string leadName = GetFieldValue(schedule, "Last Name", ZohoLead.Filter); string dtIni = GetFieldValue(schedule, "Start DateTime", FilterEntity); string dtFim = GetFieldValue(schedule, "End DateTime", FilterEntity); return(string.Format(label, leadName, dtIni, dtFim)); }
public bool Execute(ScheduleRoot schedule, List <MappingFields> mapping) { EventRoot eventRoot = new EventRoot { Schedule = schedule.Schedule, Authentication = schedule.Authentication, MappingFields = mapping }; return(Execute(eventRoot, mapping.Where(w => FilterEntity(w.Entity)).ToList())); }
private AccountRoot GetAccount(ScheduleRoot value) { AccountRoot company = new AccountRoot { Authentication = value.Authentication, MappingFields = value.MappingFields.Where(w => FilterEntity(w.Entity)).ToList() }; string accountSite = GetFieldValue(value, "City", ZohoLead.Filter) + " / " + GetFieldValue(value, "State", ZohoLead.Filter) + " - " + GetFieldValue(value, "Country", ZohoLead.Filter); company.MappingFields.Add(new MappingFields { Entity = ENTITY, Field = "Account Site", Value = accountSite }); return(company); }
bool[,] IDL.getSchedule(int testerID) { //if (!ScheduleRoot.Element("schedules").HasElements) // throw new Exception("No Schedule in the dataSource"); XElement schedule = ScheduleRoot.Elements() .Where(item => item.Element("ID").Value == testerID.ToString()) .FirstOrDefault(); if (schedule == null) { throw new ScheduleWasNotInsertedException("the tester's schedule was not inserted yet"); } return(schedule.Element("Schedule").XmlToDOSchedule()); }
public bool ReSchedule(ScheduleRoot value) { bool result = ExecuteAccount(value); if (result) { int index = 0; value.Contacts.ForEach(c => result &= ExecuteContact(value, c, index++)); result &= ExecuteLead(value); result &= ExecuteEvent(value); if (!result) { AccountDelete(value.Account.Id, value.Authentication); } } return(result); }
void IDL.addTester(Tester tester, bool[,] schedule) { int id = (from item in TesterRoot.Elements() where (int.Parse(item.Element("ID").Value) == tester.ID) select(int.Parse(item.Element("ID").Value))).FirstOrDefault(); if (id != 0) { throw new TestersIdAlreadyExistsException(tester.ID, tester.FirstName + " " + tester.LastName); } TesterRoot.Add(tester.ToXmlTester()); TesterRoot.Save(TesterPath); XElement testersId = new XElement("ID", tester.ID.ToString()); ScheduleRoot.Add(new XElement("TesterSchedule", testersId, schedule.ToXmlSchedule())); ScheduleRoot.Save(SchedulePath); }
public bool Execute(ScheduleRoot schedule, List <MappingFields> mapping) { Predicate <MappingFields> filterName = m => m.Field.Equals(FIELD_NAME); var potentialName = mapping.Where(w => filterName(w)).First().Value; LeadRoot lead = new LeadRoot { Lead = schedule.Lead, Authentication = schedule.Authentication, MappingFields = mapping }; SendRequestSearch(lead, GetEntityName(), FIELD_SELECT, FIELD_SEARCH, potentialName, GetResponseSearch); if (Execute(lead, mapping.Where(w => FilterEntity(w.Entity)).ToList())) { if (!schedule.MappingFields.Exists(e => ZohoEvent.Filter(e.Entity) && e.Field.Equals("SEMODULE"))) { lead.MappingFields.Where(w => ZohoEvent.Filter(w.Entity)).ToList().ForEach(f => { schedule.MappingFields.Add(f); }); } return(true); } return(false); }
public bool Execute(ScheduleRoot schedule, List <MappingFields> mapping) { if (base.Execute(schedule)) { AccountRoot account = GetAccount(schedule); if (!string.IsNullOrEmpty(schedule.Lead.Id)) { SendRequestGetRecord(account, ZohoPotential.ENTITY_NAME, schedule.Lead.Id, GetIdByRecord); } if (Execute(account, account.MappingFields.Where(w => FilterEntity(w.Entity)).ToList())) { schedule.Account = new Account { Id = account.Id }; account.MappingFields.Where(w => ZohoEvent.Filter(w.Entity)).ToList().ForEach(f => { schedule.MappingFields.Add(f); }); account.MappingFields.Where(w => ZohoPotential.Filter(w.Entity)).ToList().ForEach(f => { schedule.MappingFields.Add(f); }); return(true); } } return(false); }
private bool ExecuteEvent(ScheduleRoot value) { var mapping = value.MappingFields.Where(v => filterEvent(v.Entity)).ToList(); var subject = mapping.Where(x => x.Field == "Subject").FirstOrDefault(); if (subject == null) { value.MappingFields.Add(new MappingFields() { Id = 0, Entity = "Event", Field = "Subject", Value = GetSubjectEvent(value) }); } else if (string.IsNullOrEmpty(subject.Value)) { subject.Value = GetSubjectEvent(value); } return(OnExecuteEvent(value, mapping)); }
public bool Execute(ScheduleRoot schedule, Contact contact, List <MappingFields> mapping, int index = 0) { Predicate <MappingFields> filterEmail = m => m.Field.Equals(FIELD_EMAIL) && m.Id == index; var email = mapping.Where(w => filterEmail(w)).First().Value; if (schedule.MappingFields.Exists(e => ZohoPotential.Filter(e.Entity) && e.Field.Equals(ACCOUNT_ID))) { string accountId = schedule.MappingFields.Where(w => ZohoPotential.Filter(w.Entity) && w.Field.Equals(ACCOUNT_ID)).First().Value; mapping.Add(new MappingFields { Entity = ENTITY, Field = ACCOUNT_ID, Id = index, Value = accountId }); } ContactRoot contactRoot = new ContactRoot { Authentication = schedule.Authentication, Contact = contact, MappingFields = schedule.MappingFields }; SendRequestSearch(contactRoot, GetEntityName(), FIELD_SELECT, FIELD_SEARCH, email, GetResponseSearch); if (Execute(contactRoot, mapping, index)) { Predicate <string> filter = s => ZohoEvent.Filter(s) || ZohoPotential.Filter(s) || ZohoAccount.Filter(s); if (!schedule.MappingFields.Exists(e => filter(e.Entity) && e.Field.Equals("CONTACTID"))) { contactRoot.MappingFields.Where(e => filter(e.Entity) && e.Field.Equals("CONTACTID")).ToList().ForEach(f => schedule.MappingFields.Add(f)); } if (!schedule.MappingFields.Exists(e => ZohoEvent.Filter(e.Entity) && e.Field.Equals("Participants"))) { contactRoot.MappingFields.Where(e => ZohoEvent.Filter(e.Entity) && e.Field.Equals("Participants")).ToList().ForEach(f => schedule.MappingFields.Add(f)); } return(true); } return(false); }
protected override bool OnExecuteEvent(ScheduleRoot value, List <MappingFields> list) => EventController.Execute(value, list);
protected override bool OnExecuteContact(ScheduleRoot value, Contact contact, List <MappingFields> list, int index = 0) { return(ContactController.Execute(value, contact, list, index)); }
protected override bool OnExecuteLead(ScheduleRoot value, List <MappingFields> list) { return(OnExecutePotential(value, value.MappingFields.Where(v => filterPotential(v.Entity)).ToList())); }
protected override string GetSubjectEvent(ScheduleRoot value) { return(EventController.GetSubject(value, labelEvent)); }
protected bool OnExecutePotential(ScheduleRoot value, List <MappingFields> list) { return(PotentialController.Execute(value, list.Where(w => filterPotential(w.Entity)).ToList())); }
protected override bool OnExecuteAccount(ScheduleRoot value, List <MappingFields> list) { return(AccountController.Execute(value, list.Where(w => filterAccount(w.Entity)).ToList())); }
public bool Schedule(ScheduleRoot value) { value.Schedule.Id = string.Empty; return(ReSchedule(value)); }
private bool ExecuteAccount(ScheduleRoot value) { return(OnExecuteAccount(value, value.MappingFields.Where(v => filterAccount(v.Entity)).ToList())); }
private bool ExecuteContact(ScheduleRoot value, Contact contact, int index) { return(OnExecuteContact(value, contact, value.MappingFields.Where(v => filterContact(v.Entity)).ToList(), index)); }
protected abstract bool OnExecuteContact(ScheduleRoot value, Contact contact, List <MappingFields> list, int index = 0);
protected abstract string GetSubjectEvent(ScheduleRoot value);
public bool ReSchedule(ScheduleRoot value) => Execute(value, (c, v) => c.ReSchedule((ScheduleRoot)v));
protected abstract bool OnExecuteAccount(ScheduleRoot value, List <MappingFields> list);