public void BindContactTitle(DropDownList _ddlContactTitles)
        {
            ContactServiceClient contactService = null;
            try
            {
                contactService = new ContactServiceClient();
                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.StartRow = 0;

                TitleSearchCriteria titleCriteria = new TitleSearchCriteria();
                TitleSearchReturnValue titleReturnValue = contactService.TitleSearch(_logonSettings.LogonId, collectionRequest, titleCriteria);
                if (titleReturnValue.Title != null)
                {
                    _ddlContactTitles.DataSource = titleReturnValue.Title.Rows;
                    _ddlContactTitles.DataTextField = "TitleId";
                    _ddlContactTitles.DataValueField = "TitleId";
                    _ddlContactTitles.DataBind();
                }
                AddDefaultToDropDownList(_ddlContactTitles);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        contactService.Close();
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Reads the full list of contacts from the online storage
        /// </summary>
        /// <param name="clientFolderName">represents a path to the data</param>
        /// <param name="result">the list that will be filled with the contacts</param>
        /// <returns>the list of contacts that has been read from the online storage</returns>
        protected override List <SyncBase.DetailData.StdElement> ReadFullList(string clientFolderName, List <SyncBase.DetailData.StdElement> result)
        {
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }

            var client    = new ContactServiceClient();
            var formatter = new BinaryFormatter();

            using (var stream = new MemoryStream())
            {
                var all = client.GetAll(clientFolderName);
                all.CopyTo(stream);
                stream.Position = 0;

                var stdContacts = formatter.Deserialize(stream) as List <StdElement>;

                if (stdContacts != null)
                {
                    result.AddRange(stdContacts);
                }
            }

            return(result);
        }
Beispiel #3
0
        /// <summary>
        /// Binds title dropdownlist control
        /// </summary>
        private void BindTitleDropDown()
        {
            ContactServiceClient contactService = null;

            try
            {
                contactService = new ContactServiceClient();
                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.StartRow = 0;

                TitleSearchCriteria    titleCriteria    = new TitleSearchCriteria();
                TitleSearchReturnValue titleReturnValue = contactService.TitleSearch(_logonSettings.LogonId, collectionRequest, titleCriteria);
                if (titleReturnValue.Title != null)
                {
                    _ddlTitle.DataSource     = titleReturnValue.Title.Rows;
                    _ddlTitle.DataTextField  = "TitleId";
                    _ddlTitle.DataValueField = "TitleId";
                    _ddlTitle.DataBind();
                }

                // Adds "Select" at zero index of dropdownlist control.
                AddDefaultToDropDownList(_ddlTitle);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                {
                    contactService.Close();
                }
            }
        }
Beispiel #4
0
        private void SaveContact()
        {
            ContactServiceClient contactService = null;

            try
            {
                AssociationForMatter association = GetControlData();
                contactService = new ContactServiceClient();
                ReturnValue returnValue = contactService.AddAssociationForMatter(_logonSettings.LogonId, association);
                if (returnValue.Success)
                {
                    Response.Redirect("~/Pages/Matter/EditMatter.aspx");
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                {
                    contactService.Close();
                }
            }
        }
        public ContactSearchItem[] SearchContact(int startRow, int pageSize, string sortBy, string contactName, string organisation,
                                                 string houseNo, string POBox, string postCode, string town,
                                                 bool forceRefresh)
        {
            ContactServiceClient contactService = null;

            ContactSearchItem[] contacts = null;
            try
            {
                if (HttpContext.Current.Session[SessionName.LogonSettings] != null)
                {
                    Guid _logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId;

                    CollectionRequest collectionRequest = new CollectionRequest();
                    collectionRequest.ForceRefresh = forceRefresh;
                    collectionRequest.StartRow     = startRow;
                    collectionRequest.RowCount     = pageSize;

                    ContactSearchCriteria criteria = new ContactSearchCriteria();
                    criteria.ContactName  = contactName;
                    criteria.HouseNumber  = houseNo;
                    criteria.Organisation = organisation;
                    criteria.POBox        = POBox;
                    criteria.PostCode     = postCode;
                    criteria.Town         = town;
                    criteria.OrderBy      = sortBy;

                    contactService = new ContactServiceClient();

                    ContactSearchReturnValue returnValue =
                        contactService.ContactSearch(_logonId,
                                                     collectionRequest,
                                                     criteria);
                    if (returnValue.Success)
                    {
                        contacts = returnValue.Contacts.Rows;
                        _contactSearchRowCount = returnValue.Contacts.TotalRowCount;
                    }
                    else
                    {
                        ErrorEventArgs e = new ErrorEventArgs();
                        e.Message = returnValue.Message;
                        OnError(e);
                    }
                }
                return(contacts);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                {
                    contactService.Close();
                }
            }
        }
 public ActionResult AddContact()
 {
     IList<State> states = null;
     using (ContactServiceReference.ContactServiceClient client = new ContactServiceClient()) {
         states = client.GetAllStates();
     }
     return View(new AddContactPageModel(states));
 }
        public ActionResult AddContact(Contact contact)
        {
            using (ContactServiceReference.ContactServiceClient client = new ContactServiceClient()) {
                Contact result = client.AddContact(contact);
            }

            return(RedirectToAction("ViewContacts", "Contacts"));
        }
 public ActionResult ViewContact(long id)
 {
     Contact contact = null;
     using (ContactServiceClient client = new ContactServiceClient()) {
         contact = client.GetContactById(id);
     }
     return ViewContact(contact);
 }
        public ActionResult AddContact(Contact contact)
        {
            using (ContactServiceReference.ContactServiceClient client = new ContactServiceClient()) {
                Contact result = client.AddContact(contact);
            }

            return RedirectToAction("ViewContacts", "Contacts");
        }
        public ActionResult ViewContacts()
        {
            List<Contact> contacts = null;
            using (ContactServiceReference.ContactServiceClient client = new ContactServiceClient()) {
                contacts = client.GetAllContacts().ToList();
            }

            return View(contacts);
        }
        public ActionResult AddContact()
        {
            IList <State> states = null;

            using (ContactServiceReference.ContactServiceClient client = new ContactServiceClient()) {
                states = client.GetAllStates();
            }
            return(View(new AddContactPageModel(states)));
        }
Beispiel #12
0
        /// <summary>
        /// Gets the industries.
        /// </summary>
        private void BindIndustries()
        {
            ContactServiceClient contactService = null;

            try
            {
                contactService = new ContactServiceClient();
                CollectionRequest         collectionRequest = new CollectionRequest();
                IndustrySearchCriteria    searchCriteria    = new IndustrySearchCriteria();
                IndustrySearchReturnValue returnValue       = contactService.IndustrySearch(_logonSettings.LogonId,
                                                                                            collectionRequest, searchCriteria);
                if (returnValue.Success)
                {
                    //Add a blank item
                    AppFunctions.AddDefaultToDropDownList(_ddlIndustry);

                    //Generate the items to be displayed in the Industry drop down list
                    //Get the main items
                    string industryText = string.Empty;
                    foreach (IndustrySearchItem industry in returnValue.Industries.Rows)
                    {
                        if (industry.ParentId == 0)
                        {
                            industryText = industry.Name;
                            _ddlIndustry.Items.Add(new ListItem(industryText, industry.Id.ToString()));

                            // Call method to get the sub items
                            GetIndustrySubItems(returnValue.Industries.Rows, industryText, industry.Id);
                        }
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblError.Text     = DataConstants.WSEndPointErrorMessage;
                _lblError.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblError.Text     = ex.Message;
                _lblError.CssClass = "errorMessage";
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        contactService.Close();
                    }
                }
            }
        }
        public ActionResult ViewContact(long id)
        {
            Contact contact = null;

            using (ContactServiceClient client = new ContactServiceClient()) {
                contact = client.GetContactById(id);
            }
            return(ViewContact(contact));
        }
        public ActionResult ViewContacts()
        {
            List <Contact> contacts = null;

            using (ContactServiceReference.ContactServiceClient client = new ContactServiceClient()) {
                contacts = client.GetAllContacts().ToList();
            }

            return(View(contacts));
        }
Beispiel #15
0
        /// <summary>
        /// Create Service contract
        /// </summary>
        private void CreateServiceContact(string conflictNoteSummary, string conflictNoteContent)
        {
            ContactServiceClient contactService = null;

            try
            {
                ServiceContact serviceContactInfo = new ServiceContact();

                serviceContactInfo.ServiceId   = new Guid(Convert.ToString(ViewState["ServiceId"]));
                serviceContactInfo.ServiceName = Convert.ToString(ViewState["ServiceName"]);
                serviceContactInfo.SurName     = _cdContactDetails.SurName;
                serviceContactInfo.ForeName    = _cdContactDetails.ForeName;
                serviceContactInfo.Title       = _cdContactDetails.Title;
                if (_cdContactDetails.Sex != string.Empty)
                {
                    serviceContactInfo.Sex = int.Parse(_cdContactDetails.Sex);
                }
                serviceContactInfo.Position = _cdContactDetails.Position;

                //Get the address details
                Address address = new Address();
                address = _addressDetails.Address;

                contactService = new ContactServiceClient();

                ReturnValue returnValue = contactService.SaveServiceContact(_logonSettings.LogonId, address, _aadContactInfo.AdditionalDetails, serviceContactInfo, conflictNoteSummary, conflictNoteContent);

                if (returnValue.Success)
                {
                    _wizardContact.Visible   = true;
                    Session["SuccessMesage"] = "Service Contact saved successfully";

                    ResetControls();
                }
                else
                {
                    _lblError.CssClass = "errorMessage";
                    _lblError.Text     = returnValue.Message;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        contactService.Close();
                    }
                }
            }
        }
Beispiel #16
0
        /// <summary>
        /// Gets the supplimentary details for the role
        /// </summary>
        private void GetRoleExtendedInfo()
        {
            ContactServiceClient contactService = null;

            try
            {
                CollectionRequest collectionRequest     = new CollectionRequest();
                RoleExtendedInfoSearchCriteria criteria = new RoleExtendedInfoSearchCriteria();
                criteria.AssociationRoleId = Convert.ToInt32(_ddlRole.SelectedValue);

                contactService = new ContactServiceClient();
                RoleExtendedInfoReturnValue returnValue = contactService.RoleExtendedInfoSearch(_logonSettings.LogonId,
                                                                                                criteria, collectionRequest);

                if (returnValue.Success)
                {
                    //Set to false so that the info is not fetched again from the service if the user
                    //navigates back and does not change the role
                    _hdnRefreshRoleExtInfo.Value = "false";

                    if (returnValue.RoleExtendedInfo.Rows.Length > 0)
                    {
                        _grdAdditionalAssociationInfo.DataSource = returnValue.RoleExtendedInfo.Rows;
                        _grdAdditionalAssociationInfo.DataBind();
                    }
                    else
                    {
                        _grdAdditionalAssociationInfo.DataSource = null;
                        _grdAdditionalAssociationInfo.DataBind();

                        _wizardAddAssociationsForMatter.WizardSteps.Remove(_wizardStepAdditionalAssociationInfo2);
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        contactService.Close();
                    }
                }
            }
        }
Beispiel #17
0
        /// <summary>
        /// Gets the industries.
        /// </summary>
        private void GetIndustries()
        {
            ContactServiceClient contactService = null;

            try
            {
                contactService = new ContactServiceClient();
                CollectionRequest         collectionRequest = new CollectionRequest();
                IndustrySearchCriteria    searchCriteria    = new IndustrySearchCriteria();
                IndustrySearchReturnValue returnValue       = contactService.IndustrySearch(_logonId,
                                                                                            collectionRequest, searchCriteria);
                if (returnValue.Success)
                {
                    //Add a blank item
                    _ddlIndustry.Items.Add(new ListItem("", "0"));

                    //Generate the items to be displayed in the Industry drop down list
                    //Get the main items
                    string industryText = string.Empty;
                    foreach (IndustrySearchItem industry in returnValue.Industries.Rows)
                    {
                        if (industry.ParentId == 0)
                        {
                            industryText = industry.Name;
                            _ddlIndustry.Items.Add(new ListItem(industryText, industry.Id.ToString()));

                            // Call method to get the sub items
                            GetIndustrySubItems(returnValue.Industries.Rows, industryText, industry.Id);
                        }
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        contactService.Close();
                    }
                }
            }
        }
        public void ContactPublish()
        {
            ContactServiceClient client = new ContactServiceClient();

            client.Publish(new Toyota.Tsusho.CRM.API.MessageContracts.ContactPublishRequestMessage()
            {
                Contact = new Toyota.Tsusho.CRM.API.Contact()
                {
                    FirstName = "Test",
                    LastName = "Testing"
                }
            }
            );
        }
Beispiel #19
0
 private void GetGeneralContactDetails()
 {
     if (_memId == DataConstants.DummyGuid && _orgId == DataConstants.DummyGuid)
     {
         throw new Exception("Member/Organisation Id not set");
     }
     else
     {
         ContactServiceClient contactService = null;
         try
         {
             contactService = new ContactServiceClient();
             GeneralContactReturnValue returnValue = contactService.GetGeneralContact(_logonId, _memId, _orgId);
             if (returnValue.Success)
             {
                 if (_orgId == DataConstants.DummyGuid)
                 {
                     DisplayIndividualDetails(returnValue.Person);
                     SelectDropDownListValue(_ddlSourceCampaign, returnValue.CampaignId.ToString());
                     _chkReceivesMarketing.Checked = returnValue.IsReceivingMarketingStatus;
                 }
                 else
                 {
                     DisplayOrganisationDetails(returnValue.Organisation);
                     SelectDropDownListValue(_ddlSourceCampaignOrg, returnValue.CampaignId.ToString());
                     _chkReceivesMarketingOrg.Checked = returnValue.IsReceivingMarketingStatus;
                 }
             }
             else
             {
                 throw new Exception(returnValue.Message);
             }
         }
         catch (Exception ex)
         {
             throw ex;
         }
         finally
         {
             if (contactService != null)
             {
                 if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                 {
                     contactService.Close();
                 }
             }
         }
     }
 }
Beispiel #20
0
        /// <summary>
        /// Writes the elements to the sample online store.
        /// </summary>
        /// <param name="elements"> The elements to be written. </param>
        /// <param name="clientFolderName"> represents a path to the data </param>
        /// <param name="skipIfExisting"> If this parameter is true, existing elements will not be altered. </param>
        protected override void WriteFullList(List <StdElement> elements, string clientFolderName, bool skipIfExisting)
        {
            var formatter = new BinaryFormatter();

            using (var memStream = new MemoryStream())
            {
                using (var zip = new DeflateStream(memStream, CompressionMode.Compress, true))
                {
                    formatter.Serialize(zip, (from x in elements select Tools.SetPropertyValue(x, "PictureData", string.Empty, true)).ToList());
                }

                var client = new ContactServiceClient();
                memStream.Position = 0;
                client.WriteFullList(memStream);
            }
        }
Beispiel #21
0
        /// <summary>
        /// Binds association roles
        /// </summary>
        private void BindAssociationRoles()
        {
            ContactServiceClient contactService = new ContactServiceClient();

            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();

                AssociationRoleSearchCriteria associationRoleCriteria = new AssociationRoleSearchCriteria();
                //PMS
                associationRoleCriteria.ApplicationId = 1;

                AssociationRoleSearchReturnValue associationRoleReturnValue =
                    contactService.AssociationRoleForApplicationSearch(_logonSettings.LogonId,
                                                                       collectionRequest,
                                                                       associationRoleCriteria);
                if (associationRoleReturnValue.Success)
                {
                    if (associationRoleReturnValue.AssociationRole != null)
                    {
                        //Sort based on AssociationRoleDescription
                        IEnumerable <AssociationRoleSearchItem> assocRolesSorted =
                            associationRoleReturnValue.AssociationRole.Rows.OrderBy(role => role.AssociationRoleDescription);

                        _ddlRole.DataSource     = assocRolesSorted;
                        _ddlRole.DataTextField  = "AssociationRoleDescription";
                        _ddlRole.DataValueField = "AssociationRoleID";
                        _ddlRole.DataBind();
                    }
                }
                else
                {
                    throw new Exception(associationRoleReturnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                {
                    contactService.Close();
                }
            }
        }
Beispiel #22
0
        /// <summary>
        /// Method to display the available address types.
        /// </summary>
        private void GetAddressTypes()
        {
            ContactServiceClient contactService = null;

            try
            {
                CollectionRequest         collectionRequest = new CollectionRequest();
                AddressTypeSearchCriteria searchCriteria    = new AddressTypeSearchCriteria();
                searchCriteria.MemberId       = _memId;
                searchCriteria.OrganisationId = _orgId;

                contactService = new ContactServiceClient();
                AddressTypeReturnValue returnValue = contactService.GetAddressTypes(_logonId, collectionRequest, searchCriteria);

                if (returnValue.Success)
                {
                    _ddlAddressType.DataSource     = returnValue.AddressTypes.Rows;
                    _ddlAddressType.DataTextField  = "Description";
                    _ddlAddressType.DataValueField = "Id";
                    _ddlAddressType.DataBind();
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        contactService.Close();
                    }
                }
            }
        }
Beispiel #23
0
        /// <summary>
        /// Gets the industry for the association role
        /// </summary>
        /// <param name="associationRoleId">The association role id.</param>
        private int GetIndustryForAssociationRole(int associationRoleId)
        {
            int industryId = -1;

            if (_hdnIsSpecialisedSearch.Value == "true")
            {
                ContactServiceClient contactService = null;
                try
                {
                    contactService = new ContactServiceClient();
                    IndustrySearchCriteria searchCriteria = new IndustrySearchCriteria();
                    searchCriteria.AssociationRoleId = associationRoleId;
                    IndustryForAssociationRoleReturnValue returnValue = contactService.GetIndustryForAssociationRole(_logonSettings.LogonId,
                                                                                                                     searchCriteria);
                    if (returnValue.Success)
                    {
                        industryId = returnValue.IndustryId;
                    }
                    else
                    {
                        throw new Exception(returnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (contactService != null)
                    {
                        if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        {
                            contactService.Close();
                        }
                    }
                }
            }
            return(industryId);
        }
Beispiel #24
0
        private void GetCampaigns(DropDownList dropDownList)
        {
            ContactServiceClient contactService = null;

            try
            {
                contactService = new ContactServiceClient();
                CollectionRequest         collectionRequest = new CollectionRequest();
                CampaignSearchCriteria    searchCriteria    = new CampaignSearchCriteria();
                CampaignSearchReturnValue returnValue       = contactService.CampaignSearch(_logonId, collectionRequest,
                                                                                            searchCriteria);

                if (returnValue.Success)
                {
                    dropDownList.DataSource     = returnValue.Campaigns.Rows;
                    dropDownList.DataTextField  = "Description";
                    dropDownList.DataValueField = "CampaignId";
                    dropDownList.DataBind();
                    dropDownList.Items.Insert(0, "");
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        contactService.Close();
                    }
                }
            }
        }
Beispiel #25
0
        /// <summary>
        /// Gets the name of the person to perform the conflict check.
        /// </summary>
        /// <returns></returns>
        private string GetPersonName(Guid memberId)
        {
            string name = string.Empty;
            ContactServiceClient contactService = null;

            try
            {
                contactService = new ContactServiceClient();
                PersonReturnValue returnValue = contactService.GetPerson(_logonSettings.LogonId, memberId);

                if (returnValue.Success)
                {
                    if (returnValue.Person != null)
                    {
                        name = returnValue.Person.Surname;
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        contactService.Close();
                    }
                }
            }

            return(name);
        }
Beispiel #26
0
        /// <summary>
        /// Gets the sex values for the drop down list.
        /// </summary>
        private void GetSex()
        {
            ContactServiceClient contactService = null;

            try
            {
                contactService = new ContactServiceClient();
                CollectionRequest collectionRequest = new CollectionRequest();
                SexSearchCriteria searchCriteria    = new SexSearchCriteria();
                searchCriteria.IncludeArchived = false;
                SexSearchReturnValue returnValue = contactService.SexSearch(_logonId,
                                                                            collectionRequest, searchCriteria);
                if (returnValue.Success)
                {
                    _ddlSex.DataSource     = returnValue.Sex.Rows;
                    _ddlSex.DataTextField  = "Description";
                    _ddlSex.DataValueField = "Id";
                    _ddlSex.DataBind();
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        contactService.Close();
                    }
                }
            }
        }
Beispiel #27
0
        public void BindSex()
        {
            ContactServiceClient contactService = null;

            try
            {
                contactService = new ContactServiceClient();
                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.StartRow = 0;

                SexSearchCriteria    sexCriteria    = new SexSearchCriteria();
                SexSearchReturnValue sexReturnValue = contactService.SexSearch(_logonSettings.LogonId, collectionRequest, sexCriteria);
                if (sexReturnValue.Sex != null)
                {
                    _ddlContactSex.DataSource     = sexReturnValue.Sex.Rows;
                    _ddlContactSex.DataTextField  = "Description";
                    _ddlContactSex.DataValueField = "Id";
                    _ddlContactSex.DataBind();
                }
                AddDefaultToDropDownList(_ddlContactSex);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        contactService.Close();
                    }
                }
            }
        }
Beispiel #28
0
        /// <summary>
        /// Show/hide the search that can be performed based on the selected association role id
        /// </summary>
        private void ShowHideAssociationSearch()
        {
            if (_ddlRole.Items.Count > 0)
            {
                CheckForClientOnSpecialMatters();

                //Create a json object that will be used to show/hide the available searches.
                string jsonStr = "{";

                ContactServiceClient contactService = null;

                try
                {
                    CollectionRequest             collectionRequest       = new CollectionRequest();
                    AssociationRoleSearchCriteria associationRoleCriteria = new AssociationRoleSearchCriteria();
                    associationRoleCriteria.RoleId = Convert.ToInt32(_ddlRole.SelectedValue);
                    contactService = new ContactServiceClient();
                    AssociationRoleSearchReturnValue associationRoleReturnValue =
                        contactService.AssociationRoleForRoleIdSearch(_logonSettings.LogonId,
                                                                      collectionRequest,
                                                                      associationRoleCriteria);
                    if (associationRoleReturnValue.Success)
                    {
                        if (associationRoleReturnValue.AssociationRole != null)
                        {
                            // Decide which rows to Show/Hide based on the selected role.
                            // Build a json object which will be used to show/hide the options using js
                            if (associationRoleReturnValue.AssociationRole.Rows.Length > 0)
                            {
                                // Client & Matter.
                                if ((associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchClient) &&
                                    (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchMatter))
                                {
                                    _lblClientSearch.Text = "Client/Matter";
                                    jsonStr += "\"ClientSearch\":\"true\"";
                                    _clientSearch.DisplayMattersForClientGridview = true;
                                }
                                // Client.
                                else if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchClient)
                                {
                                    _lblClientSearch.Text = "Client";
                                    jsonStr += "\"ClientSearch\":\"true\"";
                                    _clientSearch.DisplayMattersForClientGridview = false;
                                }
                                // Matter.
                                else if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchMatter)
                                {
                                    _lblClientSearch.Text = "Matter";
                                    jsonStr += "\"ClientSearch\":\"true\"";
                                    _clientSearch.DisplayMattersForClientGridview = true;
                                }
                                else
                                {
                                    jsonStr += "\"ClientSearch\":\"false\"";
                                }

                                // General Contact.
                                if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchGeneral)
                                {
                                    jsonStr += ",\"ContactSearch\":\"true\"";
                                }
                                else
                                {
                                    jsonStr += ",\"ContactSearch\":\"false\"";
                                }

                                // Service Contact.
                                if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchService)
                                {
                                    jsonStr += ",\"ServiceSearch\":\"true\"";
                                }
                                else
                                {
                                    jsonStr += ",\"ServiceSearch\":\"false\"";
                                }

                                // Search for Fee Earner
                                if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchFeeEarner)
                                {
                                    jsonStr += ",\"FeeEarnerSearch\":\"true\"";
                                }
                                else
                                {
                                    jsonStr += ",\"FeeEarnerSearch\":\"false\"";
                                }

                                jsonStr += "}";

                                _hdnSearchDisplay.Value = jsonStr;

                                // Determine whether the selected Association Role requires a specialised search.
                                if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSpecialisedSearch)
                                {
                                    _hdnIsSpecialisedSearch.Value = "true";
                                }
                                else
                                {
                                    _hdnIsSpecialisedSearch.Value = "false";
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new Exception(associationRoleReturnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (contactService != null)
                    {
                        if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        {
                            contactService.Close();
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Gets the industries.
        /// </summary>
        private void BindIndustries()
        {
            ContactServiceClient contactService = null;
            try
            {
                contactService = new ContactServiceClient();
                CollectionRequest collectionRequest = new CollectionRequest();
                IndustrySearchCriteria searchCriteria = new IndustrySearchCriteria();
                IndustrySearchReturnValue returnValue = contactService.IndustrySearch(_logonSettings.LogonId,
                                                                collectionRequest, searchCriteria);
                if (returnValue.Success)
                {
                    //Add a blank item
                    AppFunctions.AddDefaultToDropDownList(_ddlIndustry);

                    //Generate the items to be displayed in the Industry drop down list
                    //Get the main items
                    string industryText = string.Empty;
                    foreach (IndustrySearchItem industry in returnValue.Industries.Rows)
                    {
                        if (industry.ParentId == 0)
                        {
                            industryText = industry.Name;
                            _ddlIndustry.Items.Add(new ListItem(industryText, industry.Id.ToString()));

                            // Call method to get the sub items
                            GetIndustrySubItems(returnValue.Industries.Rows, industryText, industry.Id);
                        }
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblMessage.Text = DataConstants.WSEndPointErrorMessage;
                _lblMessage.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {

                _lblMessage.Text = ex.Message;
                _lblMessage.CssClass = "errorMessage";
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        contactService.Close();
                }
            }
        }
Beispiel #30
0
        protected void _grdContactDetails_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            ContactServiceClient contactService = null;

            try
            {
                TextBox txtElementText = (TextBox)_grdContactDetails.Rows[e.RowIndex].FindControl("_txtElementText");
                contactService = new ContactServiceClient();
                AdditionalAddressElement element = new AdditionalAddressElement();

                Guid _memberId       = DataConstants.DummyGuid;
                Guid _organisationId = DataConstants.DummyGuid;

                if (Session[SessionName.MemberId] != null && Session[SessionName.OrganisationId] != null)
                {
                    _memberId       = (Guid)Session[SessionName.MemberId];
                    _organisationId = (Guid)Session[SessionName.OrganisationId];
                }

                if (_logonSettings.UserType == (int)DataConstants.UserType.ThirdParty && Request.QueryString["mydetails"] == "true")
                {
                    _memberId       = _logonSettings.MemberId;
                    _organisationId = _logonSettings.OrganisationId;
                }

                element.MemberId       = _memberId;
                element.OrganisationId = _organisationId;
                element.TypeId         = (int)_grdContactDetails.DataKeys[e.RowIndex].Values["TypeId"];
                element.ElementText    = txtElementText.Text.Trim();
                element.ElementComment = ((TextBox)_grdContactDetails.Rows[e.RowIndex].FindControl("_txtElementComment")).Text.Trim();
                element.AddressId      = (int)_grdContactDetails.DataKeys[e.RowIndex].Values["AddressId"];

                ReturnValue returnValue = contactService.SaveAdditionalAddressElement(((LogonReturnValue)Session[SessionName.LogonSettings]).LogonId, element);
                if (returnValue.Success)
                {
                    //update the modified additional info in the session
                    AdditionalAddressElement[] additionalAddressElements = (AdditionalAddressElement[])Session[SessionName.ContactDetails];
                    for (int i = 0; i < additionalAddressElements.Length; i++)
                    {
                        if (additionalAddressElements[i].TypeId == element.TypeId)
                        {
                            additionalAddressElements[i].ElementText    = element.ElementText;
                            additionalAddressElements[i].ElementComment = element.ElementComment;
                            break;
                        }
                    }

                    _messageCssClass = "successMessage";
                    _message         = "Edit successful";
                }
                else
                {
                    _messageCssClass = "errorMessage";
                    _message         = returnValue.Message;
                }

                _grdContactDetails.EditIndex = -1;
                DisplayContactDetails();
            }
            catch (Exception ex)
            {
                _messageCssClass = "errorMessage";
                _message         = ex.Message;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        contactService.Close();
                    }
                }

                if (ErrorOccured != null)
                {
                    OnErrorOccured(System.EventArgs.Empty);
                }
            }
        }
        /// <summary>
        /// Binds title dropdownlist control
        /// </summary>
        private void BindTitleDropDown()
        {
            ContactServiceClient contactService = null;
            try
            {
                contactService = new ContactServiceClient();
                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.StartRow = 0;

                TitleSearchCriteria titleCriteria = new TitleSearchCriteria();
                TitleSearchReturnValue titleReturnValue = contactService.TitleSearch(_logonSettings.LogonId, collectionRequest, titleCriteria);
                if (titleReturnValue.Title != null)
                {
                    _ddlTitle.DataSource = titleReturnValue.Title.Rows;
                    _ddlTitle.DataTextField = "TitleId";
                    _ddlTitle.DataValueField = "TitleId";
                    _ddlTitle.DataBind();
                }

                // Adds "Select" at zero index of dropdownlist control.
                AddDefaultToDropDownList(_ddlTitle);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                    contactService.Close();
            }
        }
        /// <summary>
        /// Loads the contact details.
        /// </summary>
        private void LoadContact()
        {
            ContactServiceClient serviceClient = null;

            try
            {
                serviceClient = new ContactServiceClient();
                //_contactReturnValue = serviceClient.GetGeneralContact(_logonSettings.LogonId, _memberId, _organisationId);
                if (_memberId != DataConstants.DummyGuid)
                {
                    _personReturnValue = serviceClient.GetPerson(_logonSettings.LogonId, _memberId);
                    if (_personReturnValue.Success)
                    {
                        DisplayContactData();
                    }
                    else
                    {
                        throw new Exception(_contactReturnValue.Message);
                    }
                }
                else if (_organisationId != DataConstants.DummyGuid)
                {
                    _organisationReturnValue = serviceClient.GetOrganisation(_logonSettings.LogonId, _organisationId);
                    if (_organisationReturnValue.Success)
                    {
                        DisplayContactData();
                    }
                    else
                    {
                        throw new Exception(_contactReturnValue.Message);
                    }
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (serviceClient != null)
                {
                    if (serviceClient.State != System.ServiceModel.CommunicationState.Faulted)
                        serviceClient.Close();
                }
            }
        }
        /// <summary>
        /// Create General contact for Individual and Organisation Contact Type 
        /// </summary>
        private void CreateGeneralContact(string conflictNoteSummary, string conflictNoteContent)
        {
            ContactServiceClient contactService = null;
            try
            {
                Person person = null;
                Organisation organisation = null;
                ContactType contactType = ContactType.Individual;

                if (_ddlContactType.Text == "Individual")
                {
                    person = new Person();
                    person.ForeName = _txtForename.Text;
                    person.Surname = _txtSurname.Text;
                    person.Title = _ddlTitle.Text;
                    contactType = ContactType.Individual;
                }

                if (_ddlContactType.Text == "Organisation")
                {
                    organisation = new Organisation();
                    organisation.Name = _txtOrgName.Text;
                    contactType = ContactType.Organisation;
                }

                // Gets the address details
                Address address = new Address();
                address = _addressDetails.Address;
                address.TypeId = 1;

                contactService = new ContactServiceClient();
                ReturnValue returnValue = contactService.SaveGeneralContact(_logonSettings.LogonId, address,
                                                            person, _aadContactInfo.AdditionalDetails,
                                                            contactType, organisation, conflictNoteSummary,
                                                            conflictNoteContent);

                if (returnValue.Success)
                {
                    _wizardContact.Visible = true;
                    Session["SuccessMesage"] = "General Contact saved successfully";

                    ResetControls();
                }
                else
                {
                    _lblError.CssClass = "errorMessage";
                    _lblError.Text = returnValue.Message;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        contactService.Close();
                }
            }
        }
        /// <summary>
        /// Gets the name of the person to perform the conflict check.
        /// </summary>
        /// <returns></returns>
        private string GetPersonName(Guid memberId)
        {
            string name = string.Empty;
            ContactServiceClient contactService = null;

            try
            {
                contactService = new ContactServiceClient();
                PersonReturnValue returnValue = contactService.GetPerson(_logonSettings.LogonId, memberId);

                if (returnValue.Success)
                {
                    if (returnValue.Person != null)
                    {
                        name = returnValue.Person.Surname;
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        contactService.Close();
                }
            }

            return name;
        }
        /// <summary>
        /// Binds association roles
        /// </summary>
        private void BindAssociationRoles()
        {
            ContactServiceClient contactService = new ContactServiceClient();

            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();

                AssociationRoleSearchCriteria associationRoleCriteria = new AssociationRoleSearchCriteria();
                //PMS
                associationRoleCriteria.ApplicationId = 1;

                AssociationRoleSearchReturnValue associationRoleReturnValue =
                                            contactService.AssociationRoleForApplicationSearch(_logonSettings.LogonId,
                                                                                 collectionRequest,
                                                                                 associationRoleCriteria);
                if (associationRoleReturnValue.Success)
                {
                    if (associationRoleReturnValue.AssociationRole != null)
                    {
                        //Sort based on AssociationRoleDescription
                        IEnumerable<AssociationRoleSearchItem> assocRolesSorted =
                            associationRoleReturnValue.AssociationRole.Rows.OrderBy(role => role.AssociationRoleDescription);

                        _ddlRole.DataSource = assocRolesSorted;
                        _ddlRole.DataTextField = "AssociationRoleDescription";
                        _ddlRole.DataValueField = "AssociationRoleID";
                        _ddlRole.DataBind();
                    }
                }
                else
                {
                    throw new Exception(associationRoleReturnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                    contactService.Close();
            }
        }
        /// <summary>
        /// Executes the plug-in.
        /// </summary>
        /// <param name="serviceProvider">The service provider.</param>
        /// <remarks>
        /// For improved performance, Microsoft Dynamics CRM caches plug-in instances. 
        /// The plug-in's Execute method should be written to be stateless as the constructor 
        /// is not called for every invocation of the plug-in. Also, multiple system threads 
        /// could execute the plug-in at the same time. All per invocation state information 
        /// is stored in the context. This means that you should not use global variables in plug-ins.
        /// </remarks>
        public void Execute(IServiceProvider serviceProvider)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }

            // Construct the Local plug-in context.
            LocalPluginContext localcontext = new LocalPluginContext(serviceProvider);

            localcontext.Trace(string.Format(CultureInfo.InvariantCulture, "Entered {0}.Execute()", this.ChildClassName));

            try
            {
                // Iterate over all of the expected registered events to ensure that the plugin
                // has been invoked by an expected event
                // For any given plug-in event at an instance in time, we would expect at most 1 result to match.
                Action<LocalPluginContext> entityAction =
                    (from a in this.RegisteredEvents
                     where (
                     a.Item1 == localcontext.PluginExecutionContext.Stage &&
                     a.Item2 == localcontext.PluginExecutionContext.MessageName &&
                     (string.IsNullOrWhiteSpace(a.Item3) ? true : a.Item3 == localcontext.PluginExecutionContext.PrimaryEntityName)
                     )
                     select a.Item4).FirstOrDefault();

                if (entityAction != null)
                {
                    localcontext.Trace(string.Format(
                        CultureInfo.InvariantCulture,
                        "{0} is firing for Entity: {1}, Message: {2}",
                        this.ChildClassName,
                        localcontext.PluginExecutionContext.PrimaryEntityName,
                        localcontext.PluginExecutionContext.MessageName));

                    entityAction.Invoke(localcontext);

                    ServiceContext context = new ServiceContext(localcontext.OrganizationService);

                    Contact contact = null;
                    ModificationEnumeration modification = ModificationEnumeration.Create;

                    // The InputParameters collection contains all the data passed in the message request.
                    if (localcontext.PluginExecutionContext.InputParameters.Contains("Target") &&
                        localcontext.PluginExecutionContext.InputParameters["Target"] is Entity)
                    {
                        // Obtain the target entity from the input parameters.
                        Entity entity = (Entity)localcontext.PluginExecutionContext.InputParameters["Target"];

                        contact = entity.ToEntity<Contact>();
                    }
                    else if (localcontext.PluginExecutionContext.InputParameters.Contains("Target") && localcontext.PluginExecutionContext.InputParameters["Target"] is EntityReference)
                    {
                        // Obtain the target entity from the input parameters.
                        EntityReference entity = (EntityReference)localcontext.PluginExecutionContext.InputParameters["Target"];

                        contact = (from c in context.ContactSet
                                   where c.Id == entity.Id
                                   select c).FirstOrDefault();

                        modification = ModificationEnumeration.Delete;
                    }

                    ContactServiceClient client = new ContactServiceClient();

                    client.Open();

                    try
                    {
                        client.Publish(new ContactPublishRequestMessage()
                        {
                            Contact = contact,
                            Modification = modification
                        });
                    }
                    catch
                    {
                        if(client.State == CommunicationState.Faulted)
                            client.Abort();

                        throw;
                    }
                    finally
                    {
                        if(client.State == CommunicationState.Opened)
                            client.Close();
                    }

                    // now exit - if the derived plug-in has incorrectly registered overlapping event registrations,
                    // guard against multiple executions.
                    return;
                }
            }
            catch (FaultException<OrganizationServiceFault> e)
            {
                localcontext.Trace(string.Format(CultureInfo.InvariantCulture, "Exception: {0}", e.ToString()));

                // Handle the exception.
                throw;
            }
            finally
            {
                localcontext.Trace(string.Format(CultureInfo.InvariantCulture, "Exiting {0}.Execute()", this.ChildClassName));
            }
        }
        public ContactSearchItem[] SearchContact(int startRow, int pageSize, string sortBy, string contactName, string organisation, 
                                                 string houseNo, string POBox, string postCode, string town, 
                                                 bool forceRefresh)
        {
            ContactServiceClient contactService = null;
            ContactSearchItem[] contacts = null;
            try
            {
                if (HttpContext.Current.Session[SessionName.LogonSettings] != null)
                {
                    Guid _logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId;

                    CollectionRequest collectionRequest = new CollectionRequest();
                    collectionRequest.ForceRefresh = forceRefresh;
                    collectionRequest.StartRow = startRow;
                    collectionRequest.RowCount = pageSize;

                    ContactSearchCriteria criteria = new ContactSearchCriteria();
                    criteria.ContactName = contactName;
                    criteria.HouseNumber = houseNo;
                    criteria.Organisation = organisation;
                    criteria.POBox = POBox;
                    criteria.PostCode = postCode;
                    criteria.Town = town;
                    criteria.OrderBy = sortBy;

                    contactService = new ContactServiceClient();

                    ContactSearchReturnValue returnValue =
                                                contactService.ContactSearch(_logonId,
                                                                             collectionRequest,
                                                                             criteria);
                    if (returnValue.Success)
                    {
                        contacts = returnValue.Contacts.Rows;
                        _contactSearchRowCount = returnValue.Contacts.TotalRowCount;
                    }
                    else
                    {
                        ErrorEventArgs e = new ErrorEventArgs();
                        e.Message = returnValue.Message;
                        OnError(e);
                    }
                }
                return contacts;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                    contactService.Close();
            }
        }
        /// <summary>
        /// Saves the addresses.
        /// </summary>
        private void SaveAddresses()
        {
            ContactServiceClient contactService = null;
            ClientServiceClient clientService = null;
            try
            {
                CheckForModifiedAddress();
                List<string> updatedAddresses = (List<string>)ViewState[UpdatedAddresses];
                //Check if any of the addresses have been modified
                if (updatedAddresses.Count > 0)
                {
                    contactService = new ContactServiceClient();
                    List<Address> clientAddresses = (List<Address>)Session[SessionName.ClientAddresses];
                    foreach (string addressType in updatedAddresses)
                    {
                        foreach (Address address in clientAddresses)
                        {
                            if (address.TypeId.ToString() == addressType)
                            {

                                if (_logonSettings.UserType == (int)DataConstants.UserType.ThirdParty && Request.QueryString["mydetails"] == "true")
                                {
                                    address.MemberId = _logonSettings.MemberId;
                                    address.OrganisationId = _logonSettings.OrganisationId;
                                }
                                else
                                {
                                    address.MemberId = (Guid)Session[SessionName.MemberId];
                                    address.OrganisationId = (Guid)Session[SessionName.OrganisationId];
                                }

                                AddressReturnValue returnValue = contactService.SaveAddress(_logonSettings.LogonId, address);
                                if (!returnValue.Success)
                                {
                                    _lblMessage.CssClass = "errorMessage";
                                    _lblMessage.Text = returnValue.Message;
                                }
                                break;
                            }
                        }
                    }
                    updatedAddresses.Clear();
                    //Reload the addresses
                    clientService = new ClientServiceClient();
                    AddressSearchCriteria searchCriteria = new AddressSearchCriteria();
                    searchCriteria.MemberId = _memberId;
                    searchCriteria.OrganisationId = _organisationId;
                    CollectionRequest collectionRequest = new CollectionRequest();
                    collectionRequest.ForceRefresh = true;

                    if (Request.QueryString["mydetails"] == "true" && _logonSettings.UserType == (int)DataConstants.UserType.ThirdParty)
                    {
                        AddressSearchReturnValue addressSearchReturnValue = new AddressSearchReturnValue();
                        ContactServiceClient serviceClient = new ContactServiceClient();
                        addressSearchReturnValue = serviceClient.GetContactAddresses(_logonSettings.LogonId, collectionRequest, searchCriteria);
                        clientAddresses.Clear();
                        //Store the addresses in a list so that we can add items if necessary
                        foreach (Address address in addressSearchReturnValue.Addresses.Rows)
                        {
                            clientAddresses.Add(address);
                        }

                    }
                    else
                    {
                        AddressSearchReturnValue addresses = clientService.GetClientAddresses(_logonSettings.LogonId,
                                                                                            collectionRequest,
                                                                                            searchCriteria);
                        clientAddresses.Clear();
                        //Store the addresses in a list so that we can add items if necessary
                        foreach (Address address in addresses.Addresses.Rows)
                        {
                            clientAddresses.Add(address);
                        }
                    }

                    if (Request.QueryString["mydetails"] == "true" && _logonSettings.UserType == (int)DataConstants.UserType.ThirdParty)
                    {
                        DisplayContactAddressDetails();
                    }
                    else
                    {
                        DisplayAddressDetails();
                    }
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblMessage.Text = DataConstants.WSEndPointErrorMessage;
                _lblMessage.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblMessage.CssClass = "errorMessage";
                _lblMessage.Text = ex.Message;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        contactService.Close();
                }

                if (clientService != null)
                {
                    if (clientService.State != System.ServiceModel.CommunicationState.Faulted)
                        clientService.Close();
                }
            }
        }
Beispiel #39
0
        /// <summary>
        /// Create Service
        /// </summary>
        private void CreateService(string conflictNoteSummary, string conflictNoteContent)
        {
            ContactServiceClient contactService = null;

            try
            {
                ServiceInfo serviceInfo = new ServiceInfo();
                serviceInfo.ServiceName = _txtServiceName.Text;
                serviceInfo.IndustryId  = Convert.ToInt32(_ddlIndustry.SelectedValue);

                //Get the address details
                Address serviceAddress = _addressDetails.Address;

                // Stores Service contact details entered by the user
                ServiceContact serviceContactInfo = new ServiceContact();
                serviceContactInfo.ServiceName = _ssService.ServiceText;
                serviceContactInfo.SurName     = _cdServiceContactDetails.SurName;
                serviceContactInfo.ForeName    = _cdServiceContactDetails.ForeName;
                serviceContactInfo.Title       = _cdServiceContactDetails.Title;
                serviceContactInfo.Sex         = Convert.ToInt32(false);
                serviceContactInfo.Position    = _cdServiceContactDetails.Position;
                serviceContactInfo.Description = _cdServiceContactDetails.Description;

                //Get the address details
                Address contactAddress = _addressServiceDetails.Address;

                contactService = new ContactServiceClient();
                ReturnValue returnValue = contactService.SaveService(_logonSettings.LogonId, serviceAddress,
                                                                     _aadServiceAddressInfo.AdditionalDetails, serviceInfo,
                                                                     serviceContactInfo, contactAddress,
                                                                     _aadContactInfo.AdditionalDetails, conflictNoteSummary,
                                                                     conflictNoteContent);

                if (returnValue.Success)
                {
                    _wizardContact.Visible   = true;
                    Session["SuccessMesage"] = "Service saved successfully";

                    ResetControls();
                }
                else
                {
                    _lblError.CssClass = "errorMessage";
                    _lblError.Text     = returnValue.Message;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        contactService.Close();
                    }
                }
            }
        }
        public void BindSex()
        {
            ContactServiceClient contactService = null;
            try
            {
                contactService = new ContactServiceClient();
                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.StartRow = 0;

                SexSearchCriteria sexCriteria = new SexSearchCriteria();
                SexSearchReturnValue sexReturnValue = contactService.SexSearch(_logonSettings.LogonId, collectionRequest, sexCriteria);
                if (sexReturnValue.Sex != null)
                {
                    _ddlContactSex.DataSource = sexReturnValue.Sex.Rows;
                    _ddlContactSex.DataTextField = "Description";
                    _ddlContactSex.DataValueField = "Id";
                    _ddlContactSex.DataBind();
                }
                AddDefaultToDropDownList(_ddlContactSex);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        contactService.Close();
                }
            }
        }
 private void SaveContact()
 {
     ContactServiceClient contactService = null;
     try
     {
         AssociationForMatter association = GetControlData();
         contactService = new ContactServiceClient();
         ReturnValue returnValue = contactService.AddAssociationForMatter(_logonSettings.LogonId, association);
         if (returnValue.Success)
         {
             Response.Redirect("~/Pages/Matter/EditMatter.aspx");
         }
         else
         {
             throw new Exception(returnValue.Message);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
             contactService.Close();
     }
 }
        protected void PostcodeLookup(string AmbiguityId, string SearchStatus)
        {
            try
            {
                ContactServiceClient      contactService    = new ContactServiceClient();
                PostcodeLookupReturnValue returnValue       = new PostcodeLookupReturnValue();
                CollectionRequest         collectionRequest = new CollectionRequest();
                collectionRequest.StartRow = 0;
                PostcodeLookupSearchCriteria criteria = new PostcodeLookupSearchCriteria();

                criteria.Address = new Address();
                criteria.Address.OrganisationName  = _txtOrganisation.Text;
                criteria.Address.PostBox           = _txtPOBox.Text;
                criteria.Address.SubBuilding       = _txtSubBuildingName.Text;
                criteria.Address.HouseName         = _txtHouseName.Text;
                criteria.Address.StreetNumber      = _txtHouseNumber.Text;
                criteria.Address.Line1             = _txtAddress1.Text;
                criteria.Address.Line2             = _txtAddress2.Text;
                criteria.Address.Line3             = _txtAddress3.Text;
                criteria.Address.DependantLocality = _txtDeptLoc.Text;
                criteria.Address.Town     = _txtTown.Text;
                criteria.Address.County   = _txtCounty.Text;
                criteria.Address.PostCode = _txtPostcode.Text;
                criteria.Address.Country  = _txtCountry.Text;
                criteria.Address.DXNumber = _txtDXAddress1.Text;
                criteria.Address.DXTown   = _txtDXAddress2.Text;
                criteria.AmbiguityId      = AmbiguityId;
                criteria.SearchStatus     = SearchStatus;
                returnValue = contactService.PostcodeLookupSearch(_logonId, criteria);

                if (returnValue != null)
                {
                    //Add each address
                    if (returnValue.PostcodeLookup != null)
                    {
                        _trServiceError.Style["display"]      = "none";
                        _trServiceErrorSpace.Style["display"] = "none";
                        _listAddress.Style["display"]         = "";

                        _listAddress.Items.Clear();

                        foreach (PostcodeLookupSearchItem cAddress in returnValue.PostcodeLookup)
                        {
                            this._listAddress.Items.Add(CreateListViewItem(cAddress));
                        }
                    }
                    else
                    {
                        string msg = string.Empty;

                        if (string.IsNullOrEmpty(returnValue.Message))
                        {
                            msg = "No matching or ambiguous addresses could be found for these details.";
                        }
                        else
                        {
                            msg = returnValue.Message;
                        }

                        _trServiceError.Style["display"]      = "";
                        _trServiceErrorSpace.Style["display"] = "";
                        _listAddress.Style["display"]         = "none";
                        _lblServiceError.Text = msg;
                    }
                }
                else
                {
                    _trServiceError.Style["display"]      = "";
                    _trServiceErrorSpace.Style["display"] = "";
                    _listAddress.Style["display"]         = "none";
                    _lblServiceError.Text = "No matching or ambiguous addresses could be found for these details.";
                }
            }
            catch (Exception ex)
            {
                //throw ex;
                _trServiceError.Style["display"]      = "";
                _trServiceErrorSpace.Style["display"] = "";
                _listAddress.Style["display"]         = "none";
                _lblServiceError.Text = ex.Message;
            }
            _mpePostcodeLookup.Show();
        }
        /// <summary>
        /// Show/hide the search that can be performed based on the selected association role id
        /// </summary>
        private void ShowHideAssociationSearch()
        {
            if (_ddlRole.Items.Count > 0)
            {
                CheckForClientOnSpecialMatters();

                //Create a json object that will be used to show/hide the available searches.
                string jsonStr = "{";

                ContactServiceClient contactService = null;

                try
                {
                    CollectionRequest collectionRequest = new CollectionRequest();
                    AssociationRoleSearchCriteria associationRoleCriteria = new AssociationRoleSearchCriteria();
                    associationRoleCriteria.RoleId = Convert.ToInt32(_ddlRole.SelectedValue);
                    contactService = new ContactServiceClient();
                    AssociationRoleSearchReturnValue associationRoleReturnValue =
                                                contactService.AssociationRoleForRoleIdSearch(_logonSettings.LogonId,
                                                                                     collectionRequest,
                                                                                     associationRoleCriteria);
                    if (associationRoleReturnValue.Success)
                    {
                        if (associationRoleReturnValue.AssociationRole != null)
                        {
                            // Decide which rows to Show/Hide based on the selected role.
                            // Build a json object which will be used to show/hide the options using js
                            if (associationRoleReturnValue.AssociationRole.Rows.Length > 0)
                            {
                                // Client & Matter.
                                if ((associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchClient) &&
                                    (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchMatter))
                                {
                                    _lblClientSearch.Text = "Client/Matter";
                                    jsonStr += "\"ClientSearch\":\"true\"";
                                    _clientSearch.DisplayMattersForClientGridview = true;
                                }
                                // Client.
                                else if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchClient)
                                {
                                    _lblClientSearch.Text = "Client";
                                    jsonStr += "\"ClientSearch\":\"true\"";
                                    _clientSearch.DisplayMattersForClientGridview = false;
                                }
                                // Matter.
                                else if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchMatter)
                                {
                                    _lblClientSearch.Text = "Matter";
                                    jsonStr += "\"ClientSearch\":\"true\"";
                                    _clientSearch.DisplayMattersForClientGridview = true;
                                }
                                else
                                {
                                    jsonStr += "\"ClientSearch\":\"false\"";
                                }

                                // General Contact.
                                if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchGeneral)
                                {
                                    jsonStr += ",\"ContactSearch\":\"true\"";
                                }
                                else
                                {
                                    jsonStr += ",\"ContactSearch\":\"false\"";
                                }

                                // Service Contact.
                                if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchService)
                                {
                                    jsonStr += ",\"ServiceSearch\":\"true\"";
                                }
                                else
                                {
                                    jsonStr += ",\"ServiceSearch\":\"false\"";
                                }

                                // Search for Fee Earner
                                if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchFeeEarner)
                                {
                                    jsonStr += ",\"FeeEarnerSearch\":\"true\"";
                                }
                                else
                                {
                                    jsonStr += ",\"FeeEarnerSearch\":\"false\"";
                                }

                                jsonStr += "}";

                                _hdnSearchDisplay.Value = jsonStr;

                                // Determine whether the selected Association Role requires a specialised search.
                                if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSpecialisedSearch)
                                {
                                    _hdnIsSpecialisedSearch.Value = "true";
                                }
                                else
                                {
                                    _hdnIsSpecialisedSearch.Value = "false";
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new Exception(associationRoleReturnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (contactService != null)
                    {
                        if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                            contactService.Close();
                    }
                }
            }
        }
        private void GetCampaigns(DropDownList dropDownList)
        {
            ContactServiceClient contactService = null;
            try
            {
                contactService = new ContactServiceClient();
                CollectionRequest collectionRequest = new CollectionRequest();
                CampaignSearchCriteria searchCriteria = new CampaignSearchCriteria();
                CampaignSearchReturnValue returnValue = contactService.CampaignSearch(_logonId, collectionRequest,
                                                                                       searchCriteria);

                if (returnValue.Success)
                {
                    dropDownList.DataSource = returnValue.Campaigns.Rows;
                    dropDownList.DataTextField = "Description";
                    dropDownList.DataValueField = "CampaignId";
                    dropDownList.DataBind();
                    dropDownList.Items.Insert(0, "");
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        contactService.Close();
                }
            }
        }
 /// <summary>
 /// Gets the industry for the association role
 /// </summary>
 /// <param name="associationRoleId">The association role id.</param>
 private int GetIndustryForAssociationRole(int associationRoleId)
 {
     int industryId = -1;
     if (_hdnIsSpecialisedSearch.Value == "true")
     {
         ContactServiceClient contactService = null;
         try
         {
             contactService = new ContactServiceClient();
             IndustrySearchCriteria searchCriteria = new IndustrySearchCriteria();
             searchCriteria.AssociationRoleId = associationRoleId;
             IndustryForAssociationRoleReturnValue returnValue = contactService.GetIndustryForAssociationRole(_logonSettings.LogonId,
                                                              searchCriteria);
             if (returnValue.Success)
             {
                 industryId = returnValue.IndustryId;
             }
             else
             {
                 throw new Exception(returnValue.Message);
             }
         }
         catch (Exception ex)
         {
             throw ex;
         }
         finally
         {
             if (contactService != null)
             {
                 if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                     contactService.Close();
             }
         }
     }
     return industryId;
 }
        /// <summary>
        /// Create Service 
        /// </summary>
        private void CreateService(string conflictNoteSummary, string conflictNoteContent)
        {
            ContactServiceClient contactService = null;
            try
            {
                ServiceInfo serviceInfo = new ServiceInfo();
                serviceInfo.ServiceName = _txtServiceName.Text;
                serviceInfo.IndustryId = Convert.ToInt32(_ddlIndustry.SelectedValue);

                //Get the address details
                Address serviceAddress = _addressDetails.Address;

                // Stores Service contact details entered by the user
                ServiceContact serviceContactInfo = new ServiceContact();
                serviceContactInfo.ServiceName = _ssService.ServiceText;
                serviceContactInfo.SurName = _cdServiceContactDetails.SurName;
                serviceContactInfo.ForeName = _cdServiceContactDetails.ForeName;
                serviceContactInfo.Title = _cdServiceContactDetails.Title;
                serviceContactInfo.Sex = Convert.ToInt32(false);
                serviceContactInfo.Position = _cdServiceContactDetails.Position;
                serviceContactInfo.Description = _cdServiceContactDetails.Description;

                //Get the address details
                Address contactAddress = _addressServiceDetails.Address;

                contactService = new ContactServiceClient();
                ReturnValue returnValue = contactService.SaveService(_logonSettings.LogonId, serviceAddress,
                                                                    _aadServiceAddressInfo.AdditionalDetails, serviceInfo,
                                                                    serviceContactInfo, contactAddress,
                                                                    _aadContactInfo.AdditionalDetails, conflictNoteSummary,
                                                                    conflictNoteContent);

                if (returnValue.Success)
                {
                    _wizardContact.Visible = true;
                    Session["SuccessMesage"] = "Service saved successfully";

                    ResetControls();
                }
                else
                {
                    _lblError.CssClass = "errorMessage";
                    _lblError.Text = returnValue.Message;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        contactService.Close();
                }
            }
        }
        /// <summary>
        /// Gets the supplimentary details for the role
        /// </summary>
        private void GetRoleExtendedInfo()
        {
            ContactServiceClient contactService = null;
            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();
                RoleExtendedInfoSearchCriteria criteria = new RoleExtendedInfoSearchCriteria();
                criteria.AssociationRoleId = Convert.ToInt32(_ddlRole.SelectedValue);

                contactService = new ContactServiceClient();
                RoleExtendedInfoReturnValue returnValue = contactService.RoleExtendedInfoSearch(_logonSettings.LogonId,
                                            criteria, collectionRequest);

                if (returnValue.Success)
                {
                    //Set to false so that the info is not fetched again from the service if the user
                    //navigates back and does not change the role
                    _hdnRefreshRoleExtInfo.Value = "false";

                    if (returnValue.RoleExtendedInfo.Rows.Length > 0)
                    {
                        _grdAdditionalAssociationInfo.DataSource = returnValue.RoleExtendedInfo.Rows;
                        _grdAdditionalAssociationInfo.DataBind();
                    }
                    else
                    {
                        _grdAdditionalAssociationInfo.DataSource = null;
                        _grdAdditionalAssociationInfo.DataBind();

                        _wizardAddAssociationsForMatter.WizardSteps.Remove(_wizardStepAdditionalAssociationInfo2);
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        contactService.Close();
                }
            }
        }
        /// <summary>
        /// Gets the industries.
        /// </summary>
        private void GetIndustries()
        {
            ContactServiceClient contactService = null;
            try
            {
                contactService = new ContactServiceClient();
                CollectionRequest collectionRequest = new CollectionRequest();
                IndustrySearchCriteria searchCriteria = new IndustrySearchCriteria();
                IndustrySearchReturnValue returnValue = contactService.IndustrySearch(_logonId,
                                                                collectionRequest, searchCriteria);
                if (returnValue.Success)
                {
                    //Add a blank item
                    _ddlIndustry.Items.Add(new ListItem("", "0"));

                    //Generate the items to be displayed in the Industry drop down list
                    //Get the main items
                    string industryText = string.Empty;
                    foreach (IndustrySearchItem industry in returnValue.Industries.Rows)
                    {
                        if (industry.ParentId == 0)
                        {
                            industryText = industry.Name;
                            _ddlIndustry.Items.Add(new ListItem(industryText, industry.Id.ToString()));

                            // Call method to get the sub items
                            GetIndustrySubItems(returnValue.Industries.Rows, industryText, industry.Id);
                        }
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        contactService.Close();
                }
            }
        }
        /// <summary>
        /// Method to display the available address types.
        /// </summary>
        private void GetAddressTypes()
        {
            ContactServiceClient contactService = null;
            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();
                AddressTypeSearchCriteria searchCriteria = new AddressTypeSearchCriteria();
                searchCriteria.MemberId = _memId;
                searchCriteria.OrganisationId = _orgId;

                contactService = new ContactServiceClient();
                AddressTypeReturnValue returnValue = contactService.GetAddressTypes(_logonId, collectionRequest, searchCriteria);

                if (returnValue.Success)
                {
                    _ddlAddressType.DataSource = returnValue.AddressTypes.Rows;
                    _ddlAddressType.DataTextField = "Description";
                    _ddlAddressType.DataValueField = "Id";
                    _ddlAddressType.DataBind();
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        contactService.Close();
                }
            }
        }
        /// <summary>
        /// Gets the title values for the drop down list..
        /// </summary>
        private void GetTitles()
        {
            ContactServiceClient contactService = null;
            try
            {
                contactService = new ContactServiceClient();
                CollectionRequest collectionRequest = new CollectionRequest();
                TitleSearchCriteria searchCriteria = new TitleSearchCriteria();
                TitleSearchReturnValue returnValue = contactService.TitleSearch(_logonId, collectionRequest, searchCriteria);

                if (returnValue.Success)
                {
                    _ddlTitle.DataSource = returnValue.Title.Rows;
                    _ddlTitle.DataTextField = "TitleId";
                    _ddlTitle.DataValueField = "TitleId";
                    _ddlTitle.DataBind();
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        contactService.Close();
                }
            }
        }
 /// <summary>
 /// Gets the disability values for the drop down list.
 /// </summary>
 private void GetDisability()
 {
     ContactServiceClient contactService = null;
     try
     {
         contactService = new ContactServiceClient();
         CollectionRequest collectionRequest = new CollectionRequest();
         DisabilitySearchCriteria searchCriteria = new DisabilitySearchCriteria();
         searchCriteria.IncludeArchived = false;
         DisabilitySearchReturnValue returnValue = contactService.DisabilitySearch(_logonId,
                                                         collectionRequest, searchCriteria);
         if (returnValue.Success)
         {
             _ddlDisability.DataSource = returnValue.Disabilities.Rows;
             _ddlDisability.DataTextField = "Description";
             _ddlDisability.DataValueField = "Id";
             _ddlDisability.DataBind();
         }
         else
         {
             throw new Exception(returnValue.Message);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         if (contactService != null)
         {
             if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                 contactService.Close();
         }
     }
 }
        /// <summary>
        /// Displays the address details for the selected address type.
        /// </summary>
        private void DisplayContactAddressDetails()
        {
            try
            {
                AddressSearchReturnValue addressSearchReturnValue = new AddressSearchReturnValue();
                CollectionRequest collectionRequest = new CollectionRequest();
                AddressSearchCriteria searchCriteria = new AddressSearchCriteria();
                searchCriteria.MemberId = _memberId;
                searchCriteria.OrganisationId = _organisationId;

                ContactServiceClient serviceClient = new ContactServiceClient();
                addressSearchReturnValue = serviceClient.GetContactAddresses(_logonSettings.LogonId, collectionRequest, searchCriteria);

                List<Address> contactAddresses = null;
                Address currentAddress = null;
                if (!IsPostBack)
                {
                    GetContactAddressTypes();
                    //Store the addresses in a list so that we can add items if necessary
                    contactAddresses = new List<Address>();
                    foreach (Address address in addressSearchReturnValue.Addresses.Rows)
                    {
                        contactAddresses.Add(address);
                    }
                    Session[SessionName.ClientAddresses] = contactAddresses;
                }
                else
                {
                    contactAddresses = (List<Address>)Session[SessionName.ClientAddresses];
                }

                //Get the current selected address type and display the address
                foreach (Address address in contactAddresses)
                {
                    if (address.TypeId == 1)
                    {
                        Session[SessionName.ContactDetails] = address.AdditionalAddressElements;
                    }

                    if (address.TypeId == Convert.ToInt32(_ddlAddressType.SelectedValue))
                    {
                        currentAddress = address;
                        break;
                    }
                }
                //If an address exists then display it..
                if (currentAddress != null)
                {
                    List<string> updatedAddresses = (List<string>)ViewState[UpdatedAddresses];
                    _ucAddress.Address = currentAddress;
                    _ucAddress.IsDataChanged = updatedAddresses.Contains(currentAddress.TypeId.ToString());
                    _ucAddress.DataBind();
                }
                else
                {
                    //No address exists for the current type, so create a new one
                    currentAddress = new Address();
                    currentAddress.LastVerified = DataConstants.BlankDate;
                    currentAddress.TypeId = Convert.ToInt32(_ddlAddressType.SelectedValue);
                    contactAddresses.Add(currentAddress);
                    _ucAddress.Address = currentAddress;
                    _ucAddress.IsDataChanged = false;
                    _ucAddress.DataBind();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 private void GetServiceContactDetails()
 {
     if (_memId == DataConstants.DummyGuid)
     {
         throw new Exception("Member Id not set");
     }
     else
     {
         ContactServiceClient contactService = null;
         try
         {
             contactService = new ContactServiceClient();
             ServiceContactReturnValue returnValue = contactService.GetServiceContact(_logonId, _memId);
             if (returnValue.Success)
             {
                 DisplayIndividualDetails(returnValue.ServiceContact);
                 SelectDropDownListValue(_ddlSourceCampaign, returnValue.CampaignId.ToString());
                 _chkReceivesMarketing.Checked = returnValue.IsReceivingMarketingStatus;
             }
             else
             {
                 throw new Exception(returnValue.Message);
             }
         }
         catch (Exception ex)
         {
             throw ex;
         }
         finally
         {
             if (contactService != null)
             {
                 if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                     contactService.Close();
             }
         }
     }
 }
Beispiel #54
0
        /// <summary>
        /// Create General contact for Individual and Organisation Contact Type
        /// </summary>
        private void CreateGeneralContact(string conflictNoteSummary, string conflictNoteContent)
        {
            ContactServiceClient contactService = null;

            try
            {
                Person       person       = null;
                Organisation organisation = null;
                ContactType  contactType  = ContactType.Individual;

                if (_ddlContactType.Text == "Individual")
                {
                    person          = new Person();
                    person.ForeName = _txtForename.Text;
                    person.Surname  = _txtSurname.Text;
                    person.Title    = _ddlTitle.Text;
                    contactType     = ContactType.Individual;
                }

                if (_ddlContactType.Text == "Organisation")
                {
                    organisation      = new Organisation();
                    organisation.Name = _txtOrgName.Text;
                    contactType       = ContactType.Organisation;
                }

                // Gets the address details
                Address address = new Address();
                address        = _addressDetails.Address;
                address.TypeId = 1;

                contactService = new ContactServiceClient();
                ReturnValue returnValue = contactService.SaveGeneralContact(_logonSettings.LogonId, address,
                                                                            person, _aadContactInfo.AdditionalDetails,
                                                                            contactType, organisation, conflictNoteSummary,
                                                                            conflictNoteContent);

                if (returnValue.Success)
                {
                    _wizardContact.Visible   = true;
                    Session["SuccessMesage"] = "General Contact saved successfully";

                    ResetControls();
                }
                else
                {
                    _lblError.CssClass = "errorMessage";
                    _lblError.Text     = returnValue.Message;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        contactService.Close();
                    }
                }
            }
        }
        /// <summary>
        /// Create Service contract
        /// </summary>
        private void CreateServiceContact(string conflictNoteSummary, string conflictNoteContent)
        {
            ContactServiceClient contactService = null;
            try
            {
                ServiceContact serviceContactInfo = new ServiceContact();

                serviceContactInfo.ServiceId = new Guid(Convert.ToString(ViewState["ServiceId"]));
                serviceContactInfo.ServiceName = Convert.ToString(ViewState["ServiceName"]);
                serviceContactInfo.SurName = _cdContactDetails.SurName;
                serviceContactInfo.ForeName = _cdContactDetails.ForeName;
                serviceContactInfo.Title = _cdContactDetails.Title;
                if (_cdContactDetails.Sex!=string.Empty)
                    serviceContactInfo.Sex = int.Parse(_cdContactDetails.Sex);
                serviceContactInfo.Position = _cdContactDetails.Position;

                //Get the address details
                Address address = new Address();
                address = _addressDetails.Address;

                contactService = new ContactServiceClient();

                ReturnValue returnValue = contactService.SaveServiceContact(_logonSettings.LogonId, address, _aadContactInfo.AdditionalDetails, serviceContactInfo, conflictNoteSummary, conflictNoteContent);

                if (returnValue.Success)
                {
                    _wizardContact.Visible = true;
                    Session["SuccessMesage"] = "Service Contact saved successfully";

                    ResetControls();
                }
                else
                {
                    _lblError.CssClass = "errorMessage";
                    _lblError.Text = returnValue.Message;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        contactService.Close();
                }
            }
        }
        /// <summary>
        /// Saves the contact details(user type 3).
        /// </summary>
        private void SaveContact()
        {
            ////Perform HO UCN field length validation as it is not checked in the service layer
            //if (_txtHOUCN.Text.Length > 0 && _txtHOUCN.Text.Length < 8)
            //{
            //    _lblMessage.CssClass = "errorMessage";
            //    _lblMessage.Text = "All characters have not been entered for the HO UCN";
            //    return;
            //}

            //ClientServiceClient clientService = null;
            ContactServiceClient contactService = null;
            try
            {
                ContactType contactType = ContactType.Individual;

                SaveAddresses();
                contactService = new ContactServiceClient();
                //clientService = new ClientServiceClient();
                //IRIS.Law.WebServiceInterfaces.Client.Client client = GetClientDetails();
                Person person = GetPersonDetails();
                Organisation organisation = GetOrganisationDetails();

                if (_memberId == DataConstants.DummyGuid)
                    contactType = ContactType.Organisation;

                //ReturnValue returnValue = clientService.UpdateClient(_logonSettings.LogonId, client, person, organisation);
                ReturnValue returnValue = contactService.UpdateGeneralContact(_logonSettings.LogonId, person, contactType, organisation);

                if (returnValue.Success)
                {
                    _lblMessage.CssClass = "successMessage";
                    _lblMessage.Text = "Edit successful";
                    //Generate client name label as the details may have changed
                    if (_memberId != DataConstants.DummyGuid)
                    {
                        _lblClientName.Text = CommonFunctions.MakeFullName(_ddlTitle.SelectedItem.Text.Trim(),
                                    _txtForenames.Text.Trim(), _txtSurname.Text.Trim());
                    }
                    else
                    {
                        _lblClientName.Text = _txtOrganisationName.Text.Trim();
                    }

                    // _imgClientArchieved.Visible = _chkArchiveClient.Checked;
                }
                else
                {
                    _lblMessage.CssClass = "errorMessage";
                    _lblMessage.Text = returnValue.Message;
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblMessage.Text = DataConstants.WSEndPointErrorMessage;
                _lblMessage.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblMessage.CssClass = "errorMessage";
                _lblMessage.Text = ex.Message;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        contactService.Close();
                }
            }
        }