private void ddListSelectionMade() { switch (cbNameList.SelectedValue.ToString()) { case "Search": IsSearch = true; pnlContact.Closed = false; pnlFileContact.Closed = true; pnlOwner.Closed = true; pnlLists.Closed = true; contactBindingSource.DataSource = null; contactBindingSource.DataMember = ""; tbSearchName.Focus(); this.AcceptButton = btnSearch; break; case "MyAddressBook": case "CurrentFileContacts": IsSearch = false; pnlFileContact.Closed = false; pnlContact.Closed = true; pnlOwner.Closed = true; pnlLists.Closed = true; string activeFilter3 = ""; if (ActiveOnly) { activeFilter3 = "Active=1"; } if (PartiesOnly) { if (ActiveOnly) { activeFilter3 += " and "; } activeFilter3 += "ContactClass='P'"; } DataView dvFC; if (cbNameList.SelectedValue.ToString() == "CurrentFileContacts") { //fmCurrent.GetFileContact().LoadByFileId(fmCurrent.CurrentFile.FileId); dvFC = new DataView(fmCurrent.DB.FileContact, activeFilter3, "", DataViewRowState.CurrentRows); } else //Address Book { FileManager fm = fmCurrent.AtMng.GetFile(fmCurrent.AtMng.WorkingAsOfficer.MyFileId); //fm.GetFileContact().LoadByFileId(fm.CurrentFile.FileId); dvFC = new DataView(fm.DB.FileContact, activeFilter3, "", DataViewRowState.CurrentRows); } fileContactBindingSource.DataSource = dvFC; fileContactBindingSource.DataMember = ""; fileContactGridEX.SetDataBinding(fileContactBindingSource, null); fileContactGridEX.Focus(); this.AcceptButton = null; break; case "LawMateDistributionList": IsSearch = false; pnlFileContact.Closed = true; pnlContact.Closed = true; pnlOwner.Closed = true; pnlLists.Closed = false; fmCurrent.AtMng.GetList().Load(); listBindingSource.DataSource = fmCurrent.AtMng.DB; listBindingSource.DataMember = fmCurrent.AtMng.DB.List.TableName; listBindingSource.Filter = "SyncExchange=True"; listGridEX.SetDataBinding(listBindingSource, null); listGridEX.Focus(); this.AcceptButton = null; break; case "OwnerOffice": case "LeadOffice": case "MyOffice": case "AllOffices": IsSearch = false; pnlFileContact.Closed = true; pnlContact.Closed = true; pnlOwner.Closed = false; pnlLists.Closed = true; string activeFilter = "", activeFilter1 = ""; if (ActiveOnly) { activeFilter = "CurrentEmployee=1"; activeFilter1 = "CurrentEmployee=1 and "; } switch (cbNameList.SelectedValue.ToString()) { case "AllOffices": if (!AllOfficesLoaded) { fmCurrent.AtMng.OfficeMng.GetOfficer().Load(); dvAllOffices = new DataView(fmCurrent.AtMng.OfficeMng.DB.Officer, activeFilter, "", DataViewRowState.CurrentRows); AllOfficesLoaded = true; } officerBindingSource.DataSource = dvAllOffices; break; case "OwnerOffice": if (!OwnerLoaded) { fmCurrent.AtMng.OfficeMng.GetOfficer().LoadByOfficeId(fmCurrent.CurrentFile.OwnerOfficeId); dvOwner = new DataView(fmCurrent.AtMng.OfficeMng.DB.Officer, activeFilter1 + "OfficeId=" + fmCurrent.CurrentFile.OwnerOfficeId.ToString(), "", DataViewRowState.CurrentRows); OwnerLoaded = true; } officerBindingSource.DataSource = dvOwner; break; case "LeadOffice": if (!LeadLoaded) { fmCurrent.AtMng.OfficeMng.GetOfficer().LoadByOfficeId(fmCurrent.CurrentFile.LeadOfficeId); dvLead = new DataView(fmCurrent.AtMng.OfficeMng.DB.Officer, activeFilter1 + "OfficeId=" + fmCurrent.CurrentFile.LeadOfficeId.ToString(), "", DataViewRowState.CurrentRows); LeadLoaded = true; } officerBindingSource.DataSource = dvLead; break; case "MyOffice": if (!MyOfficeLoaded) { fmCurrent.AtMng.OfficeMng.GetOfficer().LoadByOfficeId(fmCurrent.AtMng.OfficeLoggedOn.OfficeId); dvMyOffice = new DataView(fmCurrent.AtMng.OfficeMng.DB.Officer, activeFilter1 + "OfficeId=" + fmCurrent.AtMng.OfficeLoggedOn.OfficeId.ToString(), "", DataViewRowState.CurrentRows); MyOfficeLoaded = true; } officerBindingSource.DataSource = dvMyOffice; break; } OwnerGridEx.Focus(); this.AcceptButton = null; break; case "Outlook": IsSearch = false; Redemption.MAPIUtils mapiUtil = DocumentBE.MAPIUtils(); try { Redemption.SafeRecipients recips = mapiUtil.AddressBook(missing, missing, 3, true, missing, missing, missing, missing, missing); if (recips != null) { for (int i = 1; i <= recips.Count; i++) { Redemption.SafeRecipient recip = recips.Item(i); if (recip.Type == 1) { ucRecipientTextBoxTo.Add(recip.AddressEntry.SMTPAddress, recip.Name); } else if (recip.Type == 2) { ucRecipientTextBoxCc.Add(recip.AddressEntry.SMTPAddress, recip.Name); } } } } catch (Exception x) { UIHelper.HandleUIException(x); } mapiUtil.Cleanup(); break; } lblTypeName.Visible = IsSearch; tbSearchName.Visible = IsSearch; btnSearch.Visible = IsSearch; }
public void Resolve(string userInput, string display, docDB.RecipientRow newR, bool showDialog) { officeDB.OfficerRow or = null; //TODO:resolve from autocomplete first! userInput = userInput.Replace("'", "''"); //not sure why auto-complete was taking precedence //this will prevent look up from resolving officer before they were created or = myA.AtMng.OfficeMng.GetOfficer().LoadByEmail(userInput); if (or != null && or.CurrentEmployee) { Resolve(or, newR); return; } //JL: old email addresses with 'INET[' fail on line below: Address='" + userInput +" //data clean up required? //userInput = userInput.Replace("INET[", ""); //userInput = userInput.Replace("]", ""); DataRow[] drAuto = myA.AtMng.RecipientGetRecentSent().Select("Address='" + userInput + "'"); if (drAuto.Length > 0) { //add recipient row if (drAuto[0].IsNull("OfficerId")) { newR.Address = drAuto[0]["email"].ToString(); newR.Name = drAuto[0]["Name"].ToString(); if (!drAuto[0].IsNull("ListId")) { newR.ListId = (int)drAuto[0]["ListId"]; } } else { or = myA.AtMng.OfficeMng.GetOfficer().FindLoad((int)drAuto[0]["OfficerId"]); if (or != null) { Resolve(or, newR); } else { newR.OfficerId = (int)drAuto[0]["OfficerId"]; newR.Address = drAuto[0]["email"].ToString(); newR.Name = drAuto[0]["Name"].ToString(); } } return; } ////resolve by officecode //try //{ // officeDB.OfficeRow off = myA.AtMng.GetOffice(userInput).CurrentOffice; // Resolve(off, newR); // return; //} //catch (Exception xo) //{ // //do nothing it just means the office didn't exist //} //resolve by list appDB.ListRow[] lr = (appDB.ListRow[])myA.AtMng.DB.List.Select("ListNameEng like '" + userInput + "%'"); if (lr.Length > 0) { Resolve(lr[0], newR); return; } //resolve by role on file atriumDB.FileContactRow fcr = myA.FM.GetFileContact().GetByRole(userInput); if (fcr != null && fcr.Active) { //if it is not an officer then get the contact record if (fcr.IsOfficeIdNull()) { atriumDB.ContactRow cr = fcr.ContactRow; if (cr == null) { myA.FM.GetPerson().Load(fcr.ContactId); } Resolve(cr, newR); return; } else { or = myA.AtMng.OfficeMng.GetOfficer().FindLoad(fcr.ContactId); } } if (or == null) { //resolve by officer code first or = myA.AtMng.OfficeMng.GetOfficer().LoadByOfficerCode(userInput); if (or != null && !or.CurrentEmployee) { or = null; } } if (or != null) { Resolve(or, newR); return; } //or = myA.AtMng.OfficeMng.GetOfficer().LoadByEmail(userInput); //if (or != null && or.CurrentEmployee ) //{ // Resolve(or, newR); // return; //} if (!newR.DocumentRow.isLawmail) { //this is good for non-comm documents newR.Address = userInput; newR.Name = display; newR.AddressType = "NONE"; } else { string addrType = "SMTP"; try { Redemption.MAPIUtils mapiUtil = DocumentBE.MAPIUtils(); Redemption.SafeRecipient rdoRecip = mapiUtil.CreateRecipient(userInput, showDialog, 0); addrType = "SMTP";//always get the SMTP address rdoRecip.AddressEntry.Type; //resolution of distrib lists gets done on acbf now //if (addrType == "SMTP") // userInput = rdoRecip.AddressEntry.SMTPAddress; //else if (addrType == "MAPIPDL") //{ // //go thorugh all entries in list // Redemption.AddressEntry ade = rdoRecip.AddressEntry; // Redemption.AddressEntries mbrs = (Redemption.AddressEntries)ade.Members; // foreach (Redemption.AddressEntry addr in mbrs) // { // if (addr.Type == "EX") // Add(addr.Address, addr.Name); // else // Add(addr.SMTPAddress, addr.Name); // } // return; //} //else userInput = rdoRecip.AddressEntry.SMTPAddress; if (userInput == null || userInput == "") { addrType = "X400"; userInput = rdoRecip.Address; } display = rdoRecip.Name; } catch (System.NullReferenceException xnull) { // myA.AtMng.LogError(xnull); //address not found in address book or cancel hit throw new AtriumException("Cancel of address pick"); } catch (Exception x) { myA.AtMng.LogError(x); //address not found in address book or cancel hit throw x; } if (userInput == null) //personal\outlook distribution lists cause this { userInput = display; } or = myA.AtMng.OfficeMng.GetOfficer().LoadByEmail(userInput); if (or == null || !or.CurrentEmployee) { //add recipient row newR.Address = userInput; newR.Name = display; newR.AddressType = addrType; return; } else { Resolve(or, newR); } } }