Esempio n. 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Code"></param>
        /// <param name="Pwd"></param>
        /// <returns></returns>
        internal Business.Agent AdminLogin(string Code, string Pwd,string ipAddress)
        {
            Business.Agent agent = new Agent();
            Business.Investor investor = new Investor();
            investor = investor.LoginAgent(Code, Pwd);
            if (investor != null)
            {
                agent = agent.GetAgentByInvestorID(investor.InvestorID);
                if (agent != null)
                {
                    bool checkIp = agent.CheckValidRangeIpAddress(ipAddress);
                    if (checkIp == false)
                    {
                        string content = "'" + Code + "': admin blocked by IP";
                        string comment = "[login admin]";
                        TradingServer.Facade.FacadeAddNewSystemLog(4, content, comment, ipAddress, code);
                        return null;
                    }
                    for (int i = Business.Market.AdminList.Count - 1; i >= 0; i--)
                    {
                        if (Business.Market.AdminList[i].AgentID == agent.AgentID)
                        {
                            if (Business.Market.AdminList[i].IsAdmin && !Business.Market.AdminList[i].IsDisable)
                            {
                                Business.Market.AdminList[i].TimeSync = DateTime.Now;
                                Business.Market.AdminList[i].Ip = ipAddress;
                                return Business.Market.AdminList[i];
                            }
                            else return null;
                        }
                    }
                    agent.Code = Code;
                    agent.TimeSync = DateTime.Now;
                    agent.Ip = ipAddress;
                    agent.IsOnline = true;
                    agent.IAgentGroup = new List<Business.IAgentGroup>();
                    agent.IAgentGroup = Facade.FacadeGetIAgentGroupByAgentID(agent.AgentID);
                    agent.IAgentSecurity = new List<Business.IAgentSecurity>();
                    agent.IAgentSecurity = Facade.FacadeGetIAgentSecurityByAgentID(agent.AgentID);
                    List<Business.Permit> listPermit = new List<Business.Permit>();
                    listPermit = Facade.FacadeGetPermitByAgentID(agent.AgentID);
                    for (int i = listPermit.Count - 1; i >= 0; i--)
                    {
                        #region Enable Role
                        switch (listPermit[i].Role.Code)
                        {
                            case "R01":
                                agent.IsManager = true;
                                break;
                            case "R02":
                                agent.IsSuperviseTrades = true;
                                break;
                            case "R03":
                                agent.IsAdmin = true;
                                break;
                            case "R04":
                                agent.IsAccountant = true;
                                break;
                            case "R05":
                                agent.IsReports = true;
                                break;
                            case "R06":
                                agent.IsRiskManager = true;
                                break;
                            case "R07":
                                agent.IsInternalMail = true;
                                break;
                            case "R08":
                                agent.IsJournals = true;
                                break;
                            case "R09":
                                agent.IsSendNews = true;
                                break;
                            case "R10":
                                agent.IsMarketWatch = true;
                                break;
                            case "R11":
                                agent.IsConections = true;
                                break;
                            case "R12":
                                agent.IsPersonalDetails = true;
                                break;
                            case "R13":
                                agent.IsConfigServerPlugins = true;
                                break;
                            case "R14":
                                agent.IsAutomaticServerReports = true;
                                break;
                            case "R15":
                                agent.IsDealer = true;
                                break;
                            case "R16":
                                agent.IsEditDealer = true;
                                break;
                            case "R17":
                                agent.IsDownloadStatements = true;
                                break;
                        }

                        #endregion
                    }
                    if (agent.IsAdmin && !agent.IsDisable)
                    {
                        agent.AlertQueue = new List<PriceAlert>();
                        agent = this.GetAlertByAgent(agent);
                        Business.Market.AdminList.Add(agent);
                    }
                    else return null;
                }
            }
            return agent;
        }
Esempio n. 2
0
 internal bool ManagerChangePass(int investorID, string code, string oldPass, string newPass)
 {
     bool result = false;
     Business.Investor investor = new Investor();
     investor = investor.LoginAgent(code, oldPass);
     if (investor != null)
     {
         result = TradingServer.Facade.FacadeUpdatePasswordByCode(code, newPass);
     }
     return result;
 }