public static XLMain.Client GetClientFromIndex(string fileID) { try { FileInfo info = FileIndex(fileID); string clientStr = ""; foreach (IndexPair pair in info.Indexes) { if (pair.index == "INDEX02") { clientStr = pair.value; //once we have found what we want we need not look at other indexes break; } } clientStr = clientStr.Substring(0, clientStr.IndexOf("-")); XLMain.Client client = new XLMain.Client(); client = XLMain.Client.FetchClientFromCode(clientStr.TrimEnd()); return(client); } catch (Exception ex) { XLtools.LogException("XLVC-ClientInfofromIndex", ex.ToString()); return(null); } }
public MergeClient(XLMain.Client client) { Manager = client.manager.name; ManagerRole = XLMain.Staff.GetJobTitle(client.manager); ManagerEmail = client.manager.emails.Where(x => x.primary).FirstOrDefault().email; Partner = client.partner.name; PartnerRole = XLMain.Staff.GetJobTitle(client.partner); PartnerEmail = client.partner.emails.Where(x => x.primary).FirstOrDefault().email; ManagerImage = client.manager.GetImageLocation(); PartnerImage = client.partner.GetImageLocation(); name = client.name; clientcode = client.clientcode; crmID = client.crmID; relationship = client.relationship; type = client.type; status = client.status; isLive = client.isLive; wip = client.wip; debtor = client.debtor; department = client.department; office = client.office; IsIndividual = client.IsIndividual; if (client.salutations.Where(x => x.primary).Count() > 0) { Addressee = client.salutations.Where(x => x.primary).FirstOrDefault().addressee; Salutation = client.salutations.Where(x => x.primary).FirstOrDefault().salutation; } if (client.salutations.Count > 0) { Addressee = client.salutations.FirstOrDefault().addressee; Salutation = client.salutations.FirstOrDefault().salutation; } else { Addressee = ""; Salutation = "Sirs"; } if (client.addresses.Where(x => x.primary).Count() > 0) { Address = client.addresses.Where(x => x.primary).FirstOrDefault().addressBlock; } else if (client.addresses.Count > 0) { Address = client.addresses.FirstOrDefault().addressBlock; } else { Address = ""; } if (Addressee != name) { AddresseeBlock = Addressee + Environment.NewLine + name; } else { AddresseeBlock = name; } }
public static List <XLMain.EntityCouplet> StaffList(XLMain.Staff user, XLMain.Client client, Boolean incSec, Boolean incML = false, List <XLMain.EntityCouplet> userList = null) { //create list List <XLMain.EntityCouplet> users = new List <XLMain.EntityCouplet>(); //check whether we have been given a list if (userList == null) { //populate it with everyone userList = XLMain.Staff.AllStaff(); } users = userList; //assign list to temporary list for further adjustment int i = 0; //place current and connected users at the top of the list if (user != null) { users.Insert(i, new XLMain.EntityCouplet(user.crmID, user.name)); i++; } if (client != null) { if (client.partner != null) { users.Insert(i, new XLMain.EntityCouplet(client.partner.crmID, client.partner.name)); i++; } if (client.manager != null) { users.Insert(i, new XLMain.EntityCouplet(client.manager.crmID, client.manager.name)); i++; } List <XLMain.Staff> conStaff = XLMain.Staff.connectedStaff(client.crmID); if (conStaff != null) { foreach (XLMain.Staff staff in conStaff) { users.Insert(i, new XLMain.EntityCouplet(staff.crmID, staff.name)); i++; } } //add secretarial if (incSec) { XLMain.EntityCouplet secretarial = new XLMain.EntityCouplet(); secretarial.name = "Secretarial - " + client.manager.office; users.Insert(i, secretarial); i++; } } //add ML if (incML) { XLMain.EntityCouplet mL = new XLMain.EntityCouplet(); mL.name = "Milsted Langdon LLP"; users.Insert(i, mL); i++; } List <XLMain.EntityCouplet> dedupedList = users.GroupBy(p => p.crmID).Select(g => g.First()).ToList(); return(dedupedList); }