Пример #1
0
        protected void Application_Start(Object sender, EventArgs e)
        {
            try
            {
                AppDebug.LogEvent("DealingConsole", "Application_Start", EventLogEntryType.Information);

                //Used for kickout--Michael
                this.Context.Application["SessionIDs"] = new Hashtable();

                this.Context.Application["IsRegistered"] = false;
                this.Context.Application["Commands"]     = new Commands(new TimeSpan(0, 10, 0).TotalMilliseconds);
                this.Context.Application["Tokens"]       = new Hashtable();

                StateServerService stateServer = new StateServerService();
                this.StateServerReadyCheck(stateServer);
                this.Context.Application["StateServer"] = stateServer;

                ParticipantServices.ParticipantServices participantServices = new ParticipantServices.ParticipantServices();
                Application["ParticipantServices"] = participantServices;
                SecurityServices.SecurityServices securityServices = new SecurityServices.SecurityServices();
                Application["SecurityServices"] = securityServices;


                //			this.Context.Application["IsRegistered"]=false;
                //			this.Context.Application["Commands"]=null;
                //			this.Context.Application["Tokens"]=new Hashtable();
                ////			this.Context.Application["Sessions"]=new Hashtable();
                //
                //			StateServer.Service stateServer=new StateServer.Service();
                //			this.Context.Application["StateServer"]=stateServer;
                //
                int     commandSequence;
                Token   token   = new Token(Guid.Empty, UserType.System, AppType.DealingConsoleServer);
                DataSet dataSet = stateServer.GetInitData(token, null, out commandSequence);

                string connectionString = ConfigurationSettings.AppSettings["ConnectionString"];
                DealingConsoleServer dealingConsoleServer = new DealingConsoleServer(connectionString);
                dealingConsoleServer.Init(dataSet);
                this.Context.Application["DealingConsoleServer"] = dealingConsoleServer;

                AppDebug.LogEvent("DealingConsole", "DealingConsole started", EventLogEntryType.SuccessAudit);
            }
            catch (Exception exception)
            {
                AppDebug.LogEvent("DealingConsole", exception.ToString(), EventLogEntryType.Error);
            }
            //
            //
            //#if (PERMISSION)
            //			ParticipantServices.ParticipantServices  participantServices = new ParticipantServices.ParticipantServices();
            //			Application["ParticipantServices"] = participantServices;
            //			SecurityServices.SecurityServices securityServices = new SecurityServices.SecurityServices();
            //			Application["SecurityServices"] = securityServices;
            //#endif
        }
        private bool InnerLoginAndAuthenticate(string userName, string password, ExchangeSystem exchangeSystem, bool authenticateOnly, out Guid userID, out string errorMsg)
        {
            try
            {
                ParticipantServices.ParticipantServices participantServices = (ParticipantServices.ParticipantServices)Application["ParticipantServices"];
                userID = participantServices.Login(userName, password);
                if (userID == Guid.Empty)
                {
                    errorMsg = "User name not exists or password is invalid.";
                    return(false);
                }

                SecurityServices.SecurityServices securityServices = (SecurityServices.SecurityServices)Application["SecurityServices"];
                Guid programID    = new Guid(ConfigurationSettings.AppSettings["DealingConsole"]);
                Guid permissionID = new Guid(ConfigurationSettings.AppSettings["Run"]);
                bool isAuthrized  = securityServices.CheckPermission(userID, programID, permissionID, "", "", userID, out errorMsg);
                if (isAuthrized == false)
                {
                    userID = Guid.Empty;
                    return(false);
                }

                Token token = new Token(userID, UserType.System, AppType.DealingConsole);
                token.SessionID       = this.Context.Session.SessionID;
                token.ExchangeSystem  = exchangeSystem;
                this.Session["Token"] = token;
                bool success = this.StateServer.Login(token);
                if (success == false)
                {
                    userID   = Guid.Empty;
                    errorMsg = "Login to stateServer failure.";
                    return(false);
                }

                if (!authenticateOnly)
                {
                    FormsAuthentication.SetAuthCookie(userID.ToString(), false);

                    //Prevent be kickout
                    Hashtable sessionIDs = (Hashtable)this.Context.Application["SessionIDs"];
                    sessionIDs         = Hashtable.Synchronized(sessionIDs);
                    sessionIDs[userID] = this.Context.Session.SessionID;
                }

                return(true);
            }
            catch (Exception exception)
            {
                AppDebug.LogEvent("DealingConsole", exception.ToString(), EventLogEntryType.Error);
                throw;
            }
        }
Пример #3
0
        public bool UpdatePassword(string loginId, string oldPassword, string newPassword, out string message)
        {
            message = "";
            ParticipantServices.ParticipantServices ParticipantServices = (ParticipantServices.ParticipantServices)Application["ParticipantServices"];
            Guid userId = ParticipantServices.Login(loginId, oldPassword);

            if (userId != Guid.Empty)
            {
                Token token = (Token)Session["Token"];
                return(ParticipantServices.UpdatePassword(userId, newPassword, userId, out message));
            }
            return(false);
        }
Пример #4
0
        protected void Application_Start(Object sender, EventArgs e)
        {
            try
            {
                AppDebug.LogEvent("DealingConsole", "Application_Start", EventLogEntryType.Information);

                //Used for kickout--Michael
                this.Context.Application["SessionIDs"] = new Hashtable();

                this.Context.Application["IsRegistered"] = false;
                this.Context.Application["Commands"] = new Commands(new TimeSpan(0, 10, 0).TotalMilliseconds);
                this.Context.Application["Tokens"] = new Hashtable();

                StateServerService stateServer = new StateServerService();
                this.StateServerReadyCheck(stateServer);
                this.Context.Application["StateServer"] = stateServer;

                ParticipantServices.ParticipantServices participantServices = new ParticipantServices.ParticipantServices();
                Application["ParticipantServices"] = participantServices;
                SecurityServices.SecurityServices securityServices = new SecurityServices.SecurityServices();
                Application["SecurityServices"] = securityServices;

                //			this.Context.Application["IsRegistered"]=false;
                //			this.Context.Application["Commands"]=null;
                //			this.Context.Application["Tokens"]=new Hashtable();
                ////			this.Context.Application["Sessions"]=new Hashtable();
                //
                //			StateServer.Service stateServer=new StateServer.Service();
                //			this.Context.Application["StateServer"]=stateServer;
                //
                int commandSequence;
                Token token = new Token(Guid.Empty, UserType.System, AppType.DealingConsoleServer);
                DataSet dataSet = stateServer.GetInitData(token, null, out commandSequence);

                string connectionString = ConfigurationSettings.AppSettings["ConnectionString"];
                DealingConsoleServer dealingConsoleServer = new DealingConsoleServer(connectionString);
                dealingConsoleServer.Init(dataSet);
                this.Context.Application["DealingConsoleServer"] = dealingConsoleServer;

                AppDebug.LogEvent("DealingConsole", "DealingConsole started", EventLogEntryType.SuccessAudit);
            }
            catch (Exception exception)
            {
                AppDebug.LogEvent("DealingConsole", exception.ToString(), EventLogEntryType.Error);
            }
            //
            //
            //#if (PERMISSION)
            //			ParticipantServices.ParticipantServices  participantServices = new ParticipantServices.ParticipantServices();
            //			Application["ParticipantServices"] = participantServices;
            //			SecurityServices.SecurityServices securityServices = new SecurityServices.SecurityServices();
            //			Application["SecurityServices"] = securityServices;
            //#endif
        }