Example #1
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();
                }
            }
        }
 /// <summary>
 /// Adds the association for matter.
 /// </summary>
 /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
 /// <param name="association">The association.</param>
 /// <returns></returns>
 public ReturnValue AddAssociationForMatter(HostSecurityToken oHostSecurityToken, AssociationForMatter association)
 {
     ReturnValue returnValue = null;
     if (Functions.ValidateIWSToken(oHostSecurityToken))
     {
         oContactService = new ContactService();
         returnValue = oContactService.AddAssociationForMatter(Functions.GetLogonIdFromToken(oHostSecurityToken),
             association);
     }
     else
     {
         returnValue = new ReturnValue();
         returnValue.Success = false;
         returnValue.Message = "Invalid Token";
     }
     return returnValue;
 }
        /// <summary>
        /// Gets the control data.
        /// </summary>
        /// <returns></returns>
        private AssociationForMatter GetControlData()
        {
            try
            {
                AssociationForMatter association = new AssociationForMatter();
                association.ApplicationId = 1;//PMS
                association.ProjectId = (Guid)Session[SessionName.ProjectId];
                association.RoleId = Convert.ToInt32(_ddlRole.SelectedValue);
                association.MemberId = new Guid(_hdnMemberId.Value);
                association.OrganisationId = new Guid(_hdnOrganisationId.Value);
                association.Description = _txtDescription.Text.Trim();
                if (_ccDateFrom.DateText.Length > 0)
                {
                    association.DateFrom = Convert.ToDateTime(_ccDateFrom.DateText);
                }
                else
                {
                    association.DateFrom = DataConstants.BlankDate;
                }

                if (_ccDateTo.DateText.Length > 0)
                {
                    association.DateTo = Convert.ToDateTime(_ccDateTo.DateText);
                }
                else
                {
                    association.DateTo = DataConstants.BlankDate;
                }
                association.Reference = _txtReference.Text.Trim();
                association.LetterHead = _txtLetterHeading.Text.Trim();
                association.Comment = _txtCommenting.Text.Trim();
                association.LinkedProjectId = new Guid(_hdnLinkedProjectId.Value);

                //Get extended info from the grid
                List<RoleExtendedInfo> extendedInfo = new List<RoleExtendedInfo>();
                foreach (GridViewRow row in _grdAdditionalAssociationInfo.Rows)
                {
                    string text = string.Empty;
                    decimal number = decimal.Zero;
                    DateTime date = DataConstants.BlankDate;
                    bool hasValue = false;

                    string dataType = ((HiddenField)row.FindControl("_hdnDataType")).Value.ToString().Trim();
                    int typeId = Convert.ToInt32(((HiddenField)row.FindControl("_hdnTypeId")).Value);

                    TextBox notes = (TextBox)row.Cells[2].FindControl("_txtNotes");

                    switch (dataType)
                    {
                        case "Date":
                            CalendarControl calendarControl = (CalendarControl)row.Cells[1].FindControl("_cc");
                            string dateText = calendarControl.DateText.Trim();
                            if (dateText != string.Empty)
                            {
                                date = Convert.ToDateTime(dateText);
                                hasValue = true;
                            }
                            break;

                        case "Number":
                            TextBox numericTextBox = (TextBox)row.FindControl("_txt");
                            number = Convert.ToDecimal(numericTextBox.Text);
                            hasValue = (number != decimal.Zero);
                            break;

                        case "Text":
                            TextBox textBox = (TextBox)row.FindControl("_txt");
                            text = textBox.Text.Trim();
                            hasValue = (text != string.Empty);
                            break;

                        case "Bool":
                            CheckBox checkBox = (CheckBox)row.FindControl("_chk");
                            text = Convert.ToInt32(checkBox.Checked).ToString();
                            hasValue = (text != "0");
                            break;

                        case "List":
                            DropDownList dropDownList = (DropDownList)row.FindControl("_ddl");
                            text = dropDownList.SelectedValue.Trim();
                            hasValue = (text != string.Empty);
                            break;
                    }

                    //Add extended info item if a value was entered
                    if (notes.Text.Trim().Length > 0 || hasValue)
                    {
                        RoleExtendedInfo info = new RoleExtendedInfo();
                        info.TypeId = typeId;
                        info.Text = text;
                        info.Date = date;
                        info.Number = number;
                        info.Comment = notes.Text.Trim();
                        extendedInfo.Add(info);
                    }
                }

                if (extendedInfo.Count > 0)
                {
                    association.RoleExtendedInfoDetails = extendedInfo.ToArray();
                }

                return association;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #4
0
        /// <summary>
        /// Gets the control data.
        /// </summary>
        /// <returns></returns>
        private AssociationForMatter GetControlData()
        {
            try
            {
                AssociationForMatter association = new AssociationForMatter();
                association.ApplicationId  = 1;//PMS
                association.ProjectId      = (Guid)Session[SessionName.ProjectId];
                association.RoleId         = Convert.ToInt32(_ddlRole.SelectedValue);
                association.MemberId       = new Guid(_hdnMemberId.Value);
                association.OrganisationId = new Guid(_hdnOrganisationId.Value);
                association.Description    = _txtDescription.Text.Trim();
                if (_ccDateFrom.DateText.Length > 0)
                {
                    association.DateFrom = Convert.ToDateTime(_ccDateFrom.DateText);
                }
                else
                {
                    association.DateFrom = DataConstants.BlankDate;
                }

                if (_ccDateTo.DateText.Length > 0)
                {
                    association.DateTo = Convert.ToDateTime(_ccDateTo.DateText);
                }
                else
                {
                    association.DateTo = DataConstants.BlankDate;
                }
                association.Reference       = _txtReference.Text.Trim();
                association.LetterHead      = _txtLetterHeading.Text.Trim();
                association.Comment         = _txtCommenting.Text.Trim();
                association.LinkedProjectId = new Guid(_hdnLinkedProjectId.Value);

                //Get extended info from the grid
                List <RoleExtendedInfo> extendedInfo = new List <RoleExtendedInfo>();
                foreach (GridViewRow row in _grdAdditionalAssociationInfo.Rows)
                {
                    string   text     = string.Empty;
                    decimal  number   = decimal.Zero;
                    DateTime date     = DataConstants.BlankDate;
                    bool     hasValue = false;

                    string dataType = ((HiddenField)row.FindControl("_hdnDataType")).Value.ToString().Trim();
                    int    typeId   = Convert.ToInt32(((HiddenField)row.FindControl("_hdnTypeId")).Value);

                    TextBox notes = (TextBox)row.Cells[2].FindControl("_txtNotes");

                    switch (dataType)
                    {
                    case "Date":
                        CalendarControl calendarControl = (CalendarControl)row.Cells[1].FindControl("_cc");
                        string          dateText        = calendarControl.DateText.Trim();
                        if (dateText != string.Empty)
                        {
                            date     = Convert.ToDateTime(dateText);
                            hasValue = true;
                        }
                        break;

                    case "Number":
                        TextBox numericTextBox = (TextBox)row.FindControl("_txt");
                        number   = Convert.ToDecimal(numericTextBox.Text);
                        hasValue = (number != decimal.Zero);
                        break;

                    case "Text":
                        TextBox textBox = (TextBox)row.FindControl("_txt");
                        text     = textBox.Text.Trim();
                        hasValue = (text != string.Empty);
                        break;

                    case "Bool":
                        CheckBox checkBox = (CheckBox)row.FindControl("_chk");
                        text     = Convert.ToInt32(checkBox.Checked).ToString();
                        hasValue = (text != "0");
                        break;

                    case "List":
                        DropDownList dropDownList = (DropDownList)row.FindControl("_ddl");
                        text     = dropDownList.SelectedValue.Trim();
                        hasValue = (text != string.Empty);
                        break;
                    }

                    //Add extended info item if a value was entered
                    if (notes.Text.Trim().Length > 0 || hasValue)
                    {
                        RoleExtendedInfo info = new RoleExtendedInfo();
                        info.TypeId  = typeId;
                        info.Text    = text;
                        info.Date    = date;
                        info.Number  = number;
                        info.Comment = notes.Text.Trim();
                        extendedInfo.Add(info);
                    }
                }

                if (extendedInfo.Count > 0)
                {
                    association.RoleExtendedInfoDetails = extendedInfo.ToArray();
                }

                return(association);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Adds the association for matter.
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service.</param>
        /// <param name="association">The association.</param>
        /// <returns></returns>
        public ReturnValue AddAssociationForMatter(Guid logonId, AssociationForMatter association)
        {
            ReturnValue returnValue = new ReturnValue();

            try
            {
                // Get the logged on user from the current logons and add their
                // ApplicationSettings the list of concurrent sessions.
                Host.LoadLoggedOnUser(logonId);
                Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid);
                switch (UserInformation.Instance.UserType)
                {
                    case DataConstants.UserType.Staff:
                        // Can do everything
                        break;
                    case DataConstants.UserType.Client:
                    case DataConstants.UserType.ThirdParty:
                        throw new Exception("Access denied");
                    default:
                        throw new Exception("Access denied");
                }

                SrvAssociationForMatter _srvAssociationForMatter = new SrvAssociationForMatter();
                _srvAssociationForMatter.ApplicationId = association.ApplicationId;
                _srvAssociationForMatter.ProjectId = association.ProjectId;
                _srvAssociationForMatter.RoleId = association.RoleId;
                _srvAssociationForMatter.OrganisationId = association.OrganisationId;
                _srvAssociationForMatter.MemberId = association.MemberId;
                _srvAssociationForMatter.Description = association.Description;
                _srvAssociationForMatter.DateFrom = association.DateFrom;
                _srvAssociationForMatter.DateTo = association.DateTo;
                _srvAssociationForMatter.Reference = association.Reference;
                _srvAssociationForMatter.LetterHead = association.LetterHead;
                _srvAssociationForMatter.Comment = association.Comment;
                _srvAssociationForMatter.LinkedProjectId = association.LinkedProjectId;

                //Code from MsRoleExtendedInfo.cs
                // fill out some default values for personal reps
                if (association.RoleId == 61)
                {
                    //Static method call to the service layer..
                    DsMatterAssociations dmatAssoc = SrvAssociationLookup.GetMatterAssociations(association.ProjectId, "Personal Representative");

                    SrvRoleExtendedInfo roleExtendedInfo = new SrvRoleExtendedInfo();
                    roleExtendedInfo.RoleExtendedInfoTypeId = 128;
                    roleExtendedInfo.RoleExtendedInfoNumber = decimal.Zero;
                    roleExtendedInfo.RoleExtendedInfoDate = DataConstants.BlankDate;
                    roleExtendedInfo.RoleExtendedInfoComment = string.Empty;
                    if (dmatAssoc == null || dmatAssoc.uvw_ProjectAssociations.Count == 0)
                    {
                        roleExtendedInfo.RoleExtendedInfoText = "1";
                    }
                    else
                    {
                        roleExtendedInfo.RoleExtendedInfoText = "0";
                    }
                    _srvAssociationForMatter.RoleExtendedInfoDetails.Add(roleExtendedInfo);
                }

                if (association.RoleExtendedInfoDetails != null)
                {
                    //Get role info
                    foreach (RoleExtendedInfo info in association.RoleExtendedInfoDetails)
                    {
                        SrvRoleExtendedInfo roleExtendedInfo = new SrvRoleExtendedInfo();
                        roleExtendedInfo.RoleExtendedInfoTypeId = info.TypeId;
                        roleExtendedInfo.RoleExtendedInfoText = info.Text;
                        roleExtendedInfo.RoleExtendedInfoNumber = info.Number;
                        roleExtendedInfo.RoleExtendedInfoDate = info.Date;
                        roleExtendedInfo.RoleExtendedInfoComment = info.Comment;
                        _srvAssociationForMatter.RoleExtendedInfoDetails.Add(roleExtendedInfo);
                    }
                }

                string errorMessage;

                returnValue.Success = _srvAssociationForMatter.Save(out errorMessage);
                returnValue.Message = errorMessage;
            }
            catch (System.Data.SqlClient.SqlException)
            {
                returnValue.Success = false;
                returnValue.Message = Functions.SQLErrorMessage;
            }
            catch (Exception Ex)
            {
                returnValue.Success = false;
                returnValue.Message = Ex.Message;
            }
            finally
            {
                // Remove the logged on user's ApplicationSettings from the
                // list of concurrent sessions
                Host.UnloadLoggedOnUser();
            }

            return returnValue;
        }
Example #6
0
        /// <summary>
        /// Adds the association for matter.
        /// </summary>
        /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
        /// <param name="association">The association.</param>
        /// <returns></returns>
        public ReturnValue AddAssociationForMatter(HostSecurityToken oHostSecurityToken, AssociationForMatter association)
        {
            ReturnValue returnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oContactService = new ContactService();
                returnValue     = oContactService.AddAssociationForMatter(Functions.GetLogonIdFromToken(oHostSecurityToken),
                                                                          association);
            }
            else
            {
                returnValue         = new ReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return(returnValue);
        }