Пример #1
0
 private void LoginCheck(object sender, DoWorkEventArgs e)
 {
     try
     {
         _loginInfo.AccessLevel = _cargoHostEndPoint.Login(_loginInfo.Username, _loginInfo.Password);
     }
     catch (Exception ex)
     {
         _loginInfo.ErrorMessage = ex.Message;
     }
     finally
     {
         _loginInfo.ClearPassword();
     }
 }
Пример #2
0
        public override LoginResponse Login(WorkstationInfo wsInfo)
        {
            try
            {
                AuthenticationLevel authLvl = AuthenticationLevel.None;

                authLvl = (AuthenticationLevel)m_CargoHostEndPoint.Login(wsInfo.userInfo.UserName, wsInfo.userInfo.Password);

                Profile profile;

                try
                {
                    XmlSerializer mySerializer = new XmlSerializer(typeof(Profile));

                    string profileFile = m_ProfilesFolder + "\\" + wsInfo.userInfo.UserName + ".xml";
                    if (!File.Exists(profileFile))
                    {
                        File.Copy(m_ProfilesFolder + "\\default.xml", profileFile);
                    }

                    using (FileStream fileStream = new FileStream(profileFile, FileMode.Open))
                    {
                        profile = (Profile)mySerializer.Deserialize(fileStream);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ErrorMessages.NO_USER_PROFILE, ex.InnerException);
                }

                SystemConfiguration sysConfig =
                    new SystemConfiguration(m_Alias, m_CargoHostEndPoint.GetMaxManifestPerCase());

                Database db = new Database();
                sysConfig.ContainerDBConnectString      = db.GetConnectionStringByDBName(ConfigurationManager.AppSettings["ContainerDBName"]);
                sysConfig.ContainerRefreshPeriodSeconds = int.Parse(ConfigurationManager.AppSettings["ContainerRefreshPeriodSeconds"]);

                return(new LoginResponse(authLvl, sysConfig, profile));
            }
            catch (Exception ex)
            {
                throw new FaultException(new FaultReason(ex.Message));
            }
        }