Example #1
0
        /// <summary>
        /// Get details about multiple organisations.
        /// </summary>
        /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
        /// <param name="projectId">The project id.</param>
        /// <returns></returns>
        public OrganisationSearchReturnValue GetMultipleOrganisationDetails(HostSecurityToken oHostSecurityToken, Guid[] OrganisationIds)
        {
            OrganisationSearchReturnValue returnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oContactService = new ContactService();
                returnValue     = oContactService.GetMultipleOrganisationDetails(Functions.GetLogonIdFromToken(oHostSecurityToken), OrganisationIds);
            }
            else
            {
                returnValue         = new OrganisationSearchReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return(returnValue);
        }
        /// <summary>
        /// Get details about multiple organisations.
        /// </summary>
        /// <param name="logonId">Logon id obtained when logging on to the logon service.</param>
        /// <param name="projectId">The project id.</param>
        /// <returns></returns>
        public OrganisationSearchReturnValue GetMultipleOrganisationDetails(Guid logonId, Guid[] OrganisationIds)
        {
            OrganisationSearchReturnValue returnValue = new OrganisationSearchReturnValue();

            try
            {
                // Get the logged on user from the current logons and add their
                // ApplicationSettings the list of concurrent sessions.
                Host.LoadLoggedOnUser(logonId);

                try
                {
                    Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid);
                    switch (UserInformation.Instance.UserType)
                    {
                        case DataConstants.UserType.Staff:
                            // Can do everything
                            break;
                        case DataConstants.UserType.Client:
                            // Can only access themself
                            if (OrganisationIds.Length != 1)
                                throw new Exception("Access denied");

                            if (!ApplicationSettings.Instance.IsUser(DataConstants.DummyGuid, OrganisationIds[0]))
                                throw new Exception("Access denied");
                            break;
                        case DataConstants.UserType.ThirdParty:
                            // Can only access themself
                            if (OrganisationIds.Length != 1)
                                throw new Exception("Access denied");

                            if (!ApplicationSettings.Instance.IsUser(DataConstants.DummyGuid, OrganisationIds[0]))
                                throw new Exception("Access denied");
                            break;
                        default:
                            throw new Exception("Access denied");
                    }

                    DataListCreator<OrganisationSearchItem> dataListCreator = new DataListCreator<OrganisationSearchItem>();

                    returnValue.Organisations = new DataList<OrganisationSearchItem>();

                    returnValue.Organisations.FirstRowNumber = 0;

                    foreach (IRIS.Law.PmsCommonData.DsOrganisations.OrganisationsRow Row in
                        SrvOrganisationlookup.GetMultipleOrganisations(OrganisationIds).Tables[0].Rows)
                    {
                        OrganisationSearchItem Item = new OrganisationSearchItem();

                        Item.OrganisationId = Row.OrgID;
                        Item.Name = Row.OrgName;

                        returnValue.Organisations.TotalRowCount++;
                        returnValue.Organisations.Rows.Add(Item);
                    }
                }
                finally
                {
                    // Remove the logged on user's ApplicationSettings from the
                    // list of concurrent sessions
                    Host.UnloadLoggedOnUser();
                }
            }
            catch (System.Data.SqlClient.SqlException)
            {
                returnValue.Success = false;
                returnValue.Message = Functions.SQLErrorMessage;
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Message = ex.Message;
            }

            return returnValue;
        }
 /// <summary>
 /// Get details about multiple organisations.
 /// </summary>
 /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
 /// <param name="projectId">The project id.</param>
 /// <returns></returns>
 public OrganisationSearchReturnValue GetMultipleOrganisationDetails(HostSecurityToken oHostSecurityToken, Guid[] OrganisationIds)
 {
     OrganisationSearchReturnValue returnValue = null;
     if (Functions.ValidateIWSToken(oHostSecurityToken))
     {
         oContactService = new ContactService();
         returnValue = oContactService.GetMultipleOrganisationDetails(Functions.GetLogonIdFromToken(oHostSecurityToken), OrganisationIds);
     }
     else
     {
         returnValue = new OrganisationSearchReturnValue();
         returnValue.Success = false;
         returnValue.Message = "Invalid Token";
     }
     return returnValue;
 }