Esempio n. 1
0
        protected void Application_Start(object sender, EventArgs e)
        {
            if (!SrvSecurityCommon.Logon(IlbCommon.ILBWebServiceSecretLogonUserName, IlbCommon.ILBWebServiceSecretLogonPassword))
            {
                throw new Exception(string.Format("Invalid {0} web service secret logon details", Solicitors.Branding.Strings.ProductName));
            }

            Host.AddSpecialLoggedOnUser(IlbCommon.IlbWebServiceSecretLogonId);

            // Tell the ApplicationSettings we are running as a web service so that ApplicationSettings.Instance works for multiple sessions
            ApplicationSettings.IsWebServices = true;
        }
Esempio n. 2
0
        /// <summary>
        /// Log on to the services
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public LogonReturnValue Logon(string userName, string password)
        {
            LogonReturnValue returnValue = new LogonReturnValue();

            try
            {
                // Create a new instance of ApplicationSettings and add it to
                // the list of concurrent sessions.
                // ApplicationSettings.Instance can now be used to get the
                // ApplicationSettings for this session.
                ApplicationSettings.NewSession();

                try
                {
                    // If OS has default culture settings other than culture defined in the config, then set it to config culture
                    if (System.Configuration.ConfigurationManager.AppSettings["CultureInfo"] != null)
                    {
                        if (System.Threading.Thread.CurrentThread.CurrentCulture.Name != System.Configuration.ConfigurationManager.AppSettings["CultureInfo"])
                        {
                            string Lang = System.Configuration.ConfigurationManager.AppSettings["CultureInfo"];
                            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(Lang);
                        }
                    }

                    // TODO: The query for this does not use a stored procedure so need to protect against SQL injection.
                    // This is due to change in the next release anyway so will probably become a stored procedure.

                    if (bool.Parse(ConfigurationManager.AppSettings["MaintenenceMode"]))
                    {
                        throw new Exception("Request failed, site is undergoing maintenence. Please try again later.");
                    }


                    if (!SrvSecurityCommon.Logon(userName, password))
                    {
                        throw new Exception("Invalid logon details");
                    }

                    //ApplicationSettings.Instance.UserType = DataConstants.UserType.ThirdParty;
                    returnValue.LogonId = Host.AddLoggedOnUser();


                    returnValue.UserType = (int)UserInformation.Instance.UserType;
                    //"dbUid = -1" is used for Rekoop integration and doesn't need licence.
                    if (returnValue.UserType == 1)
                    {
                        if (UserInformation.Instance.DbUid != -1 && !UserSecuritySettings.IsUserLicenced(DataConstants.Application.PMS, true))
                        {
                            throw new Exception("The number of licenses has been exceeded");
                        }
                    }

                    //returnValue.UserType = 3;
                    // Soon the following two new fields will need their values setting from info stored against the user in ILB
                    // TODO : Comment it, Hardcoded for testing custom styling
                    returnValue.WebMaster              = UserSecuritySettings.GetUserSecuitySettings(246); // 245 = Web Master
                    returnValue.WebStyleSheet          = UserInformation.Instance.Stylesheet;
                    returnValue.OrganisationId         = UserInformation.Instance.UserOrgId;
                    returnValue.MemberId               = UserInformation.Instance.UserMemberId;
                    returnValue.IsMember               = UserInformation.Instance.UserMemberId != DataConstants.DummyGuid;
                    returnValue.UserDefaultPartner     = UserInformation.Instance.UserDefaultPartner;
                    returnValue.UserDefaultBranch      = UserInformation.Instance.UserDefaultBranch;
                    returnValue.UserDefaultDepartment  = UserInformation.Instance.UserDefaultDepartment;
                    returnValue.UserDefaultWorkType    = UserInformation.Instance.UserDefaultWorkType;
                    returnValue.UserDefaultFeeMemberId = UserInformation.Instance.UserDefaultFeeMemberId;
                    returnValue.DbUid                   = UserInformation.Instance.DbUid;
                    returnValue.DatabaseRole            = UserInformation.Instance.UserDbRole;
                    returnValue.IsPostCodeLookupEnabled = SrvSystemParameterCommon.IsPostCodeLookupEnabled();
                    returnValue.TimeUnits               = ApplicationSettings.Instance.TimeUnits;
                    returnValue.AutomaticVersioning     = ApplicationSettings.Instance.AutomaticVersioning;
                    if (!ApplicationSettings.Instance.ConflictCheckRoles.ToLower().Equals("client/client other side"))
                    {
                        returnValue.ConflictCheckRoles = true;
                    }
                    else
                    {
                        returnValue.ConflictCheckRoles = false;
                    }
                    // TODO : Hardcoded 154 -> PmsCommon.CommonServices.UserSecurityTypes.PmsSettings.LockUnlockDocuments
                    // Since enum PmsSettings is inside PmsCommon and which cannot be refactored
                    returnValue.CanUserLockDocument = IRIS.Law.PmsCommonServices.CommonServices.UserSecuritySettings.GetUserSecuitySettings(154);
                    // TODO : Hardcoded 169 -> PmsCommon.CommonServices.UserSecurityTypes.PmsSettings.EditArchivedMatters
                    // Since enum PmsSettings is inside PmsCommon and which cannot be refactored
                    returnValue.CanUserEditArchivedMatter = IRIS.Law.PmsCommonServices.CommonServices.UserSecuritySettings.GetUserSecuitySettings(169);

                    if (ApplicationSettings.Instance.DiaryProviderDllPath == "IRIS.Law.DiaryProviders.MSDiaryProvider.dll")
                    {
                        returnValue.IsUsingILBDiary = true;
                    }
                    else
                    {
                        returnValue.IsUsingILBDiary = false;
                    }



                    returnValue.IsFirstTimeLoggedIn = false;

                    if (UserInformation.Instance.UserLoggedIn == DataConstants.BlankDate)
                    {
                        returnValue.IsFirstTimeLoggedIn = true;
                    }
                }
                finally
                {
                    // Remove the current ApplicationSettings from the list of concurrent sessions.
                    // ApplicationSettings.RemoveSession();
                }
            }
            catch (System.Data.SqlClient.SqlException)
            {
                returnValue.Success = false;
                returnValue.Message = Functions.SQLErrorMessage;
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Message = ex.Message;
            }

            return(returnValue);
        }