コード例 #1
0
ファイル: ACSServer.cs プロジェクト: BdGL3/CXPortal
        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));
            }
        }
コード例 #2
0
ファイル: WSServer.cs プロジェクト: BdGL3/CXPortal
        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));
            }
        }