Example #1
0
        private AuthenticationLevel LoginToIndividualSource (string sourceAlias, string username, string password)
        {
            AuthenticationLevel ret = AuthenticationLevel.None;

            try
            {
                string wsId = m_SysConfig.GetDefaultConfig().WorkstationAlias;
                UserInfo userInfo = new UserInfo(username, password);
                WorkstationInfo wsInfo = new WorkstationInfo(wsId, userInfo);

                LoginResponse loginResponse = m_DataSourceAccess.Login(sourceAlias, wsInfo);

                ret = loginResponse.UserAuthenticationLevel;

                if (!ret.Equals(AuthenticationLevel.None))
                {
                    SysConfiguration sysConfig = new SysConfiguration();
                    sysConfig.ID = sourceAlias;
                    sysConfig.ContainerDBConnectionString = loginResponse.systemConfiguration.ContainerDBConnectString;
                    sysConfig.ContainerRefreshPeriodmsecs = loginResponse.systemConfiguration.ContainerRefreshPeriodSeconds * 1000;

                    if (m_SysConfig.Contains(sourceAlias))
                    {
                        m_SysConfig.Delete(sourceAlias);
                    }

                    m_SysConfig.Add(sysConfig);

                    if (m_SysConfig.UserProfileManager.Profile == null)
                    {
                        ProfileObject profile = ProfileTranslator.Translate(loginResponse.UserProfile, 4);
                        profile.SourceAlias = sourceAlias;
                        profile.UserName = wsInfo.userInfo.UserName;
                        profile.Password = wsInfo.userInfo.Password;

                        m_SysConfig.UserProfileManager.Profile = profile;
                        m_SysConfig.UserProfileManager.Profile.ProfileUpdatedEvent += new ProfileUpdated(ProfileUpdated);
                    }

                    DataSet caselist = null;
                    m_DataSourceAccess.GetCaseList(sourceAlias, out caselist);

                    if (caselist != null)
                    {
                        CaseListDataSet caseListDataSet = (CaseListDataSet)caselist;
                        caseListDataSet.CaseListTable.CaseListTableRowChanged +=
                            new CaseListDataSet.CaseListTableRowChangeEventHandler(CaseListTable_CaseListTableRowChanged);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return ret;
        }
Example #2
0
        public override LoginResponse Login(WorkstationInfo awsInfo)
        {
            try
            {
                Profile profile;
                XmlSerializer mySerializer = new XmlSerializer(typeof(Profile));

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

                using (FileStream fileStream = new FileStream(profileFile, FileMode.Open))
                {
                    profile = (Profile)mySerializer.Deserialize(fileStream);
                }


                if (Boolean.Parse(ConfigurationManager.AppSettings["TrainingModeEnabled"]))
                {
                    SystemConfiguration sysConfig = new SystemConfiguration(String.Empty, 2);
                    Database db = new Database();
                    sysConfig.ContainerDBConnectString = db.GetConnectionStringByDBName(ConfigurationManager.AppSettings["ContainerDBName"]);
                    sysConfig.ContainerRefreshPeriodSeconds = int.Parse(ConfigurationManager.AppSettings["ContainerRefreshPeriodSeconds"]);

                    return new LoginResponse(L3.Cargo.Communications.Interfaces.AuthenticationLevel.Operator, sysConfig, profile);
                }
                else if (Boolean.Parse(ConfigurationManager.AppSettings["LoginRequired"]))
                {
                    L3.Cargo.Communications.Interfaces.AuthenticationLevel authenticationLevel =
                        L3.Cargo.Communications.Interfaces.AuthenticationLevel.None;

                    authenticationLevel =
                        (L3.Cargo.Communications.Interfaces.AuthenticationLevel)m_HostComm.Login(awsInfo.userInfo.UserName,
                                                                                                      awsInfo.userInfo.Password);

                    SystemConfiguration sysConfig = new SystemConfiguration(String.Empty, m_HostComm.GetMaxManifestPerCase());

                    return new LoginResponse(authenticationLevel, sysConfig, profile);
                }
                
                else
                {
                     SystemConfiguration sysConfig = new SystemConfiguration(String.Empty, 0);

                     return new LoginResponse(L3.Cargo.Communications.Interfaces.AuthenticationLevel.None, sysConfig, null);
                }
                
            }
            catch (CargoException cex)
            {
                throw new FaultException(new FaultReason(cex.error_msg));
            }
            catch (Exception ex)
            {
                throw new FaultException(new FaultReason(ex.Message));
            }
        }
Example #3
0
        private void Tab1Login_Click(object sender, RoutedEventArgs e)
        {
            WorkstationInfo awsInfo = new WorkstationInfo(m_AWSId);
            awsInfo.userInfo.UserName = Tab1UsernameTextBox.Text;
            awsInfo.userInfo.Password = Tab1PasswordTextBox.Text;

            try
            {
                LoginResponse response = m_AWSCommEndPoint1.Login(awsInfo);
                Tab1LogListBox.Items.Add("Result: Success | AuthLevel: "
                    + response.UserAuthenticationLevel.ToString());
            }
            catch (Exception ex)
            {
                Tab1LogListBox.Items.Add("Result: Failed | ErrorMessage: " + ex.Message
                    + " | AuthLevel: None");
            }
        }
Example #4
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));
            }
        }
Example #5
0
 public LoginResponse Login(String sourceAlias, WorkstationInfo awsInfo)
 {
     return m_CaseSourceManager.Login(sourceAlias, awsInfo);
 }