예제 #1
0
        public Hashtable GetAllUser()
        {
            Hashtable retData = new Hashtable();
            string query = "SELECT ID, Password FROM [User] ";
            DataSet dataSet = DataAccess.ExecuteQuery(query);

            if ((dataSet != null) && (dataSet.Tables.Count > 0) && (dataSet.Tables[0].Rows.Count > 0))
            {
                for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
                {
                    BrokerManager.DataObjects.UserDTO user = new BrokerManager.DataObjects.UserDTO();
                    user.Id = dataSet.Tables[0].Rows[i][0].ToString();
                    user.Password = dataSet.Tables[0].Rows[i][1].ToString();
                    if (!retData.Contains(user.Id))
                    {
                        retData.Add(user.Id, user);
                    }
                    else
                    {
                        retData[user.Id] = user;
                    }
                }
            }

            return retData;
        }
예제 #2
0
        public static UserDTO Authenticate(UserDTO user, out string errorMessage)
        {
            
            errorMessage = null;
            UserDTO systemUser = null;
            if (user != null)
            {
                if (user.Id != null)
                {
                    systemUser = (UserDTO)UserDTO.HashAllUser[user.Id];
                    if (systemUser != null)
                    {
                        if (systemUser.Password.Equals(user.Password))
                        {
                            return systemUser;
                        }
                        else
                        {
                            string authenticationDomain = ConfigurationManager.AppSettings[Constants.CONF_ID_AUTHENTICATION_DOMAIN];
                            if (Utils.AuthenticateLDAP(user.Id, user.Password, authenticationDomain))
                            {
                                return systemUser;
                            }
                            else
                            {
                                errorMessage = "Incorrect username/password or domain authentication fails";
                                return null;
                            }
                        }
                    }
                    else
                    {
                        errorMessage = "User not found";
                    }
                }
            }

            return systemUser;
        }
        public void Calculate(string calculPeriodId, DateTime calculPeriod, UserDTO byUser) 
        {
            _logger.Info("Calculate - ENTER");

            // Load all master data();
            BrokerCommissionModal brokerDataModal = new BrokerCommissionModal();
            brokerDataModal.LoadData();

            //Get average 3 months commision
            //Hashtable hash3MonthAvgResult = GetAvgNetRevenue(calculPeriod);
            //_logger.Info("3 Month AvgNetRevenue data load completed. Count=" + hash3MonthAvgResult.Count);

            List<ClientTradeData> listClientTradeData = ClientTradeDataAccess.GetAllClientTradeData(calculPeriodId);
            _logger.Info("ClientTradeData data load completed. Count=" + listClientTradeData.Count);

            // Link client trade data and their brokers together
            for (int i = 0; i < listClientTradeData.Count; i++)
            {
                ClientTradeData clientTradeData = listClientTradeData[i];

                if (clientTradeData.BrokerId != null)
                {
                    if (brokerDataModal.HashBroker[clientTradeData.BrokerId] != null)
                    {
                        Broker brk = (Broker)brokerDataModal.HashBroker[clientTradeData.BrokerId];
                        brk.ClientTradeData.Add(clientTradeData);
                    }
                }
            }


            foreach (string brkID in brokerDataModal.HashBroker.Keys)
            {
                Broker broker = (Broker)brokerDataModal.HashBroker[brkID];
                // Create the ResultData object to hold calculation data for the broker (brk)
                BrokerCalculationResult result = new BrokerCalculationResult();
                result.BrokerId = broker.Id;
                result.PeriodId = calculPeriodId;
                result.CalculatePeriod = calculPeriod;
                broker.PaymentResult = result;

                //// check the last 3 month commmision average to identify if this broker have allowance or not
                //if (hash3MonthAvgResult[broker.Id] != null)
                //{
                //    result.AverageNetRevenue = (decimal)hash3MonthAvgResult[broker.Id]; ;
                //}
                //else
                //{
                //    // Mark this to know that there is NO DATA about Average Net Revenue
                //    result.AverageNetRevenue = -1;
                //}
                
                CalculateAE(broker, calculPeriodId, brokerDataModal);
            }
            //Supervisor
            foreach (string brkID in brokerDataModal.HashBroker.Keys)
            {
                Broker broker = (Broker)brokerDataModal.HashBroker[brkID];
                if (broker.IsSupervisor())
                {
                    CalculateSupervisor(broker, brokerDataModal);
                }
            }
            //Supporter
            foreach (string brkID in brokerDataModal.HashBroker.Keys)
            {
                Broker broker = (Broker)brokerDataModal.HashBroker[brkID];
                if (broker.IsSupporter())
                {
                    CalculateSupporter(broker, brokerDataModal);
                }
            }

            AccumulateOfficeRevenue(brokerDataModal, calculPeriodId, calculPeriod);

            foreach (string brkID in brokerDataModal.HashBroker.Keys)
            {
                Broker brk = (Broker)brokerDataModal.HashBroker[brkID];
                if (brk.IsManager()) 
                {
                    CalculateManager(brk,brokerDataModal);
                } 
            }

            StoreCalculationData(brokerDataModal,calculPeriodId);
            _logger.Info("Calculate - LEAVE");
        }
 public void CalculateCommission(string calculPeriodId, DateTime calculPeriod, UserDTO byUser) 
 {
     CalculationService.Calculate(calculPeriodId, calculPeriod, byUser);
 }