/// <summary>
        /// This method credits or debits balance of platform accounts
        /// </summary>
        /// <param name="login">login</param>
        /// <param name="amount">amount</param>
        /// <param name="comment">comment</param>
        /// <returns></returns>
        public bool DoPlatformTransaction(int login, double amount, string comment)
        {
            try
            {
                var newTransac = new TradeTransInfoNET();
                newTransac.cmd      = (short)TradeCommands.OP_BALANCE;
                newTransac.comment  = comment;
                newTransac.orderby  = login;
                newTransac.price    = amount;
                newTransac.type     = (short)TradeTransTypes.TT_BR_BALANCE;
                newTransac.reserved = 0;

                var manager = new MetaTraderWrapperManager("mtdem01.primexm.com:443", 900, "!FQS123!!");
                if (manager.IsConnected() == 1)
                {
                    if (manager.TradeTransaction(newTransac) == 0)
                    {
                        return(true);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                return(false);
            }
        }
        /// <summary>
        /// This Function will check if there
        /// is any alert or not and updates the variable
        /// </summary>
        public void StartMonitoringAlerts()
        {
            try
            {
                var boMAMAlertBO = new BOMAMAlertBO();

                while (true)
                {
                    if (boMAMAlertBO.CheckAlerts())
                    {
                        //Update the alerts to true
                        boMAMAlertBO.UpdateAlerts(false);

                        //Mark Initiated as false
                        isInitiated = false;
                        isStop      = true;

                        Thread.Sleep(5000);
                    }
                }
            }
            catch (Exception exceptionMessage)
            {
                //Log Error
                CurrentDeskLog.Error("Monitoring Alert Issue :" + exceptionMessage);
            }
        }
        /// <summary>
        ///
        /// </summary>
        public void StartBOMAMClosedTrades()
        {
            var lastProcessedID = 0;
            var tradeHistoryBO  = new TradesHistoryBO();
            var bobMAMTradeBO   = new BOMAMTradeBO();

            while (true)
            {
                if (isInitiated)
                {
                    try
                    {
                        if (assetManagerDict.Keys.Count > 0)
                        {
                            //If The LastProcessID is 0 get it from database
                            if (lastProcessedID == 0)
                            {
                                //Get The Last ClosedTradeProcessedID
                                lastProcessedID = bobMAMTradeBO.GetLastClosedTradeProcessedID();
                            }

                            //Updates to Get Last ProcessedID
                            lastProcessedID = bobMAMTradeBO.UpdateBOMAMOpenToCloseTrade(assetManagerDict, lastProcessedID);
                        }
                    }
                    catch (Exception exceptionMessage)
                    {
                        //Log Error
                        CurrentDeskLog.Error("Monitoring Closed Trades :" + exceptionMessage);
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// This action creates new landing account for user as per currency id
        /// </summary>
        /// <param name="currencyID">currencyID</param>
        /// <returns></returns>
        public ActionResult CreateNewLandingAccount(string currencyID)
        {
            try
            {
                if (SessionManagement.UserInfo != null)
                {
                    LoginInformation loginInfo = SessionManagement.UserInfo;
                    var currLookupValue        = accountCurrencyBO.GetCurrencyLookUpID(Convert.ToInt32(currencyID));

                    var accCreationResult = clientAccBo.CreateNewLandingAccount(loginInfo.LogAccountType, loginInfo.UserID, currLookupValue, (int)SessionManagement.OrganizationID);

                    if (accCreationResult)
                    {
                        //Logs new account creation in db
                        InsertAccountActivityDetails(currLookupValue, "Landing", null);
                        InsertAccountActivityDetails(currLookupValue, "Rebate", null);

                        return(Json(true));
                    }
                    return(Json(false));
                }
                else
                {
                    return(Json(false));
                }
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                throw;
            }
        }
        /// <summary>
        /// This action returns list of market news from
        /// forexfactory xml file
        /// </summary>
        /// <returns></returns>
        public List <MarketNewsDataModel> GetMarketNews()
        {
            var lstMarketNews = new List <MarketNewsDataModel>();

            try
            {
                var xmlDoc = new XmlDocument();
                xmlDoc.Load("http://www.forexfactory.com/ffcal_week_this.xml");
                XmlElement  root  = xmlDoc.DocumentElement;
                XmlNodeList nodes = root.SelectNodes("event");

                //Iterate through each news event
                //and if news date >= todays date then add to list
                foreach (XmlNode node in nodes)
                {
                    if (node["date"].InnerText.DateTimeTryParse() >= DateTime.Now.Date)
                    {
                        var marketNewsData = new MarketNewsDataModel();
                        marketNewsData.NewsDateTime = node["date"].InnerText + " " + node["time"].InnerText;
                        marketNewsData.Currency     = node["country"].InnerText;
                        marketNewsData.Title        = node["title"].InnerText;
                        marketNewsData.Impact       = node["impact"].InnerText;
                        lstMarketNews.Add(marketNewsData);
                    }
                }

                //Return list of market news
                return(lstMarketNews);
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                return(lstMarketNews);
            }
        }
        /// <summary>
        /// This action calculates if margin restriction and returns true
        /// if balance after transfer is greater than margin restriction
        /// </summary>
        /// <param name="loginId">loginId</param>
        /// <param name="amount">amount</param>
        /// <param name="balance">balance</param>
        /// <param name="marginRestriction">marginRestriction</param>
        /// <returns></returns>
        public bool IsMarginRestrictionSatisfied(int loginId, decimal amount, decimal balance, double marginRestriction)
        {
            try
            {
                var marginCache = new DataCache("MarginCache");

                //Get margin object for the login
                object objMargin = marginCache.Get(loginId.StringTryParse());

                if (objMargin != null)
                {
                    var margin = (Margin)objMargin;

                    //Add margin restriction percent to accountMargin
                    var accountMargin = (decimal)margin.Margin1;
                    accountMargin += ((accountMargin * (decimal)marginRestriction) / 100);

                    return(((balance - amount) >= accountMargin) ? true : false);
                }

                return(false);
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                return(false);
            }
        }
        /// <summary>
        /// This action returns Dashboard view with view-model
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            try
            {
                if (SessionManagement.UserInfo != null)
                {
                    var model = new DashboardModel();
                    LoginInformation loginInfo = SessionManagement.UserInfo;
                    var userAccInfo            = clientAccBO.GetDashboardAccounts(loginInfo.LogAccountType, loginInfo.UserID);

                    //Group all accounts by currency
                    var pairedAccInfo = userAccInfo.GroupBy(o => o.FK_CurrencyID);
                    var tradeList     = new List <UserAccountGrouped>();

                    //Iterate through each currency grouped accounts and add them to model
                    foreach (var item in pairedAccInfo)
                    {
                        var groupedTradingAccount = new UserAccountGrouped();
                        groupedTradingAccount.AccountCurrency = lCurrValueBO.GetCurrencySymbolFromID((int)item.Key);
                        var list = new List <Client_Account>();
                        foreach (var groupedItem in item)
                        {
                            list.Add(groupedItem);
                        }
                        groupedTradingAccount.UserAccountList = list;
                        tradeList.Add(groupedTradingAccount);
                    }
                    model.UserAccInformation = tradeList;

                    //Get market news
                    model.MarketNews = GetMarketNews();

                    //Get IB userID under which client is present
                    int ibUserID = clientBO.GetIntroducingBrokerIDOfClient(loginInfo.UserID);
                    model.BrokerPromoImgName = String.Empty;

                    //If client is under any IB
                    if (ibUserID != 0)
                    {
                        var imgDetail = userImgBO.GetActiveImageOfIB(ibUserID);
                        if (imgDetail != null)
                        {
                            var imgExt = imgDetail.ImageName.Substring(imgDetail.ImageName.LastIndexOf('.'));
                            model.BrokerPromoImgName = imgDetail.PK_UserImageID + imgExt;
                        }
                    }

                    return(View(model));
                }
                else
                {
                    return(RedirectToAction("Login", "Account"));
                }
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                return(View("ErrorMessage"));
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Get Equity from cache
        /// </summary>
        /// <param name="loginid"></param>
        /// <returns></returns>
        public JsonResult GetEquity(int loginid)
        {
            try
            {
                var    marginCache = new DataCache("MarginCache");
                object objMargin   = marginCache.Get(loginid.StringTryParse());
                if (objMargin != null)
                {
                    var margin = (Margin)objMargin;

                    var marginDetails = new MarginDetails();

                    marginDetails.Equ = margin.Equity.CurrencyFormat();
                    marginDetails.Bal = margin.Balance.CurrencyFormat();

                    var equity = margin.Equity ?? 0;
                    var bal    = margin.Balance ?? 0;
                    var pnl    = equity - bal;

                    marginDetails.Pnl = pnl.CurrencyFormat();

                    return(Json(marginDetails, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
            }

            return(Json(string.Empty, JsonRequestBehavior.AllowGet));
        }
Esempio n. 9
0
        /// <summary>
        /// This method sends document to be
        /// downloaded as attachment for saving in browser
        /// </summary>
        /// <param name="docID">docID</param>
        public void DownloadDocument(int docID)
        {
            try
            {
                if (SessionManagement.UserInfo != null)
                {
                    LoginInformation loginInfo = SessionManagement.UserInfo;

                    //Get file name from database
                    var fileName = userDocumentBO.GetUploadedDocumentName(loginInfo.UserID, docID);

                    if (fileName != String.Empty)
                    {
                        //Get file extension
                        var fileExt = fileName.Substring(fileName.LastIndexOf('.'));

                        var file = new FileInfo(Server.MapPath("~/UserDocuments/" + loginInfo.UserID + "-" + docID + fileExt));

                        Response.Clear();
                        Response.ClearHeaders();
                        Response.ClearContent();
                        Response.AppendHeader("Content-Disposition", "attachment; filename = " + fileName);
                        Response.AppendHeader("Content-Length", file.Length.ToString());
                        Response.ContentType = GetContentType(file.Name);
                        Response.WriteFile(file.FullName);
                        Response.Flush();
                        Response.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// This actions returns FundSourceManagement view
        /// with required data
        /// </summary>
        /// <returns></returns>
        public ActionResult FundingSourceManagement()
        {
            try
            {
                if (SessionManagement.UserInfo != null)
                {
                    var model = new FundingSourceModel();
                    ViewData["ReceivingBankInfo"] = new SelectList(receivingBankInfoBO.GetReceivingBankInfo((int)SessionManagement.OrganizationID), "PK_RecievingBankID", "RecievingBankName");
                    ViewData["Country"]           = new SelectList(countryBO.GetCountries(), "PK_CountryID", "CountryName");
                    ViewData["Currency"]          = new SelectList(currencyBO.GetCurrencies(), "PK_CurrencyValueID", "CurrencyValue");
                    ViewData["SourceType"]        = new SelectList(ExtensionUtility.GetAllSourceTypes(), "ID", "Value");

                    return(View(model));
                }
                else
                {
                    return(RedirectToAction("Login", "Account", new { Area = "" }));
                }
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                return(View("ErrorMessage"));
            }
        }
Esempio n. 11
0
        /// <summary>
        /// This action method deletes IB document from
        /// file system and makes IsDeleted = true entry in db
        /// </summary>
        /// <param name="docID">docID</param>
        /// <returns></returns>
        public ActionResult ClearDocument(int docID)
        {
            try
            {
                if (SessionManagement.UserInfo != null)
                {
                    LoginInformation loginInfo = SessionManagement.UserInfo;
                    var fileName = userDocumentBO.ClearUserDocument(loginInfo.UserID, docID);
                    var fileExt  = fileName.Substring(fileName.LastIndexOf('.'));

                    if (fileName != String.Empty)
                    {
                        //Delete document file from file system
                        System.IO.File.Delete(Directory.EnumerateFileSystemEntries(System.Web.HttpContext.Current.Server.MapPath("~/UserDocuments"), loginInfo.UserID + "-" + docID + fileExt).First());
                        return(Json(true));
                    }
                }

                return(Json(false));
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                return(Json(false));
            }
        }
Esempio n. 12
0
        /// <summary>
        /// This method creates new user account in meta trader
        /// </summary>
        /// <param name="newUser"></param>
        /// <returns></returns>
        public static bool CreateMetaTraderAccountForUser(int pkClientAccID, int?fkPlatformID, User newUser, LoginAccountType accType)
        {
            try
            {
                var user = new MT4ManLibraryNETv03.UserRecordNET();
                user.group    = "FQ-IB-One";
                user.name     = newUser.UserEmailID;
                user.password = "******";

                var manager = new MetaTraderWrapperManager("mtdem01.primexm.com:443", 900, "!FQS123!!");
                if (manager.IsConnected() == 1)
                {
                    var accStatus = manager.CreateNewUser(user);

                    //If success
                    if (accStatus == 0)
                    {
                        var clientAccBO = new Client_AccountBO();
                        clientAccBO.InsertPlatformLoginForTradingAccount(pkClientAccID, fkPlatformID, user.password, user.login);
                        return(true);
                    }
                    else
                    {
                        var error = manager.ErrorDescription(accStatus);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                throw;
            }
        }
        /// <summary>
        /// This action returns AgentDetails view
        /// with required data passed as model
        /// </summary>
        /// <returns></returns>
        public ActionResult AgentDetails(int agentID)
        {
            try
            {
                if (SessionManagement.UserInfo != null)
                {
                    LoginInformation      loginInfo = SessionManagement.UserInfo;
                    AccountNumberRuleInfo ruleInfo  = SessionManagement.AccountRuleInfo;

                    var agentDetail = agentBO.GetAgentDetails(agentID, loginInfo.UserID);
                    var model       = new AgentDetailsModel();

                    if (agentDetail != null)
                    {
                        model.FirstName         = agentDetail.FirstName;
                        model.LastName          = agentDetail.LastName;
                        model.BirthDate         = Convert.ToDateTime(agentDetail.BirthDate).ToString("dd/MM/yyyy");
                        model.PhoneNumber       = agentDetail.PhoneNumber;
                        model.EmailAddress      = agentDetail.EmailAddress;
                        model.PhoneID           = agentDetail.PhoneID;
                        model.Password          = agentDetail.Password;
                        model.AgentAddress      = agentDetail.AgentAddress;
                        model.AgentCity         = agentDetail.City;
                        model.AgentCountry      = countryBO.GetSelectedCountry((int)agentDetail.FK_CountryID);
                        model.AgentPostalCode   = agentDetail.PostalCode;
                        model.BankName          = agentDetail.BankName;
                        model.AccountNumber     = agentDetail.AccountNumber;
                        model.BicOrSwiftCode    = agentDetail.BicOrSwiftCode;
                        model.ReceivingBankInfo = agentDetail.FK_ReceivingBankInfoID != null?receivingBankInfoBO.GetSelectedRecievingBankInfo((int)agentDetail.FK_ReceivingBankInfoID) : null;

                        model.ReceivingBankInfoDetail = agentDetail.ReceivingBankInfo;
                        model.BankAddress             = agentDetail.BankAddress;
                        model.BankCity    = agentDetail.BankCity;
                        model.BankCountry = agentDetail.FK_BankCountryID != null?countryBO.GetSelectedCountry((int)agentDetail.FK_BankCountryID) : null;

                        model.BankPostalCode = agentDetail.BankPostalCode;
                        model.AgentID        = (int)agentDetail.AgentIntroducingBrokerCode;
                    }

                    //For referral links
                    ViewData["CustomizedLink"] = introducingBrokerBO.GetCustomizedLinkOfIB(loginInfo.UserID);
                    ViewData["AccountNumber"]  = clientAccBO.GetAccountNumberOfUser(loginInfo.LogAccountType, loginInfo.UserID).Split('-')[ruleInfo.AccountNumberPosition - 1];

                    return(View(model));
                }
                else
                {
                    return(RedirectToAction("Login", "Account", new { Area = "" }));
                }
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                return(View("ErrorMessage"));
            }
        }
        /// <summary>
        /// This action returns WithdrawFunds view with required
        /// data passed as model
        /// </summary>
        /// <param name="accountNumber">accountNumber</param>
        /// <returns></returns>
        public ActionResult WithdrawFunds(string accountNumber)
        {
            try
            {
                if (SessionManagement.UserInfo != null)
                {
                    LoginInformation      loginInfo = SessionManagement.UserInfo;
                    AccountNumberRuleInfo ruleInfo  = SessionManagement.AccountRuleInfo;

                    ViewData["Country"]           = new SelectList(countryBO.GetCountries(), "PK_CountryID", "CountryName");
                    ViewData["ReceivingBankInfo"] = new SelectList(receivingBankInfoBO.GetReceivingBankInfo((int)SessionManagement.OrganizationID), "PK_RecievingBankID", "RecievingBankName");

                    var model = new TransfersModel();
                    model.BankInformation       = new List <BankInformation>();
                    model.LandingAccInformation = new List <LandingAccInformation>();
                    model.AccountNumber         = accountNumber;

                    //Get all bank accounts
                    var userBankInfos = bankBO.GetAllBankInfosForUser(loginInfo.LogAccountType, loginInfo.UserID);
                    foreach (var bank in userBankInfos)
                    {
                        var bankInfo = new BankInformation();
                        bankInfo.BankID        = bank.PK_BankAccountInformationID;
                        bankInfo.BankName      = bank.BankName;
                        bankInfo.BankAccNumber = bank.AccountNumber;
                        model.BankInformation.Add(bankInfo);
                    }

                    //Get all landing accounts
                    var landingAccs = clientAccBo.GetAllLandingAccountForUser(loginInfo.LogAccountType, loginInfo.UserID);
                    foreach (var lAcc in landingAccs)
                    {
                        var lAccInfo = new LandingAccInformation();
                        lAccInfo.LCurrencyName = lCurrValueBO.GetCurrencySymbolFromCurrencyAccountCode(lAcc.LandingAccount.Split('-')[ruleInfo.CurrencyPosition - 1]);
                        lAccInfo.LAccNumber    = lAcc.LandingAccount;

                        lAccInfo.LAccBalance = Utility.FormatCurrencyValue((decimal)lAcc.CurrentBalance, "");

                        model.LandingAccInformation.Add(lAccInfo);
                    }

                    return(View("WithdrawFunds", model));
                }
                else
                {
                    return(RedirectToAction("Login", "Account", new { Area = "" }));
                }
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                return(View("ErrorMessage"));
            }
        }
 /// <summary>
 /// This action sets IsRead value of a msg to true
 /// </summary>
 /// <param name="msgID">msgID</param>
 public void SetMessageIsReadTrue(int msgID)
 {
     try
     {
         intUsrMsgBO.SetMessageIsReadTrue(msgID);
     }
     catch (Exception ex)
     {
         CurrentDeskLog.Error(ex.Message, ex);
         throw;
     }
 }
 /// <summary>
 /// This method updates LastTradingDate in Client_Account
 /// table for all passed logins
 /// </summary>
 /// <param name="logins"></param>
 public void UpdateClientTradeDate(List <int> logins)
 {
     try
     {
         clientAccBO.UpdateClientTradeDate(logins);
     }
     catch (Exception ex)
     {
         CurrentDeskLog.Error(ex.Message, ex);
         throw;
     }
 }
 /// <summary>
 /// This method gets all logins for which trading
 /// has been done on particular day
 /// </summary>
 /// <param name="checkDate">checkDate</param>
 /// <returns></returns>
 public List <int> GetAllLoginsTradedToday(DateTime checkDate)
 {
     try
     {
         return(tradeBO.GetAllLoginsTradedToday(checkDate));
     }
     catch (Exception ex)
     {
         CurrentDeskLog.Error(ex.Message, ex);
         throw;
     }
 }
Esempio n. 18
0
        /// <summary>
        /// This action returns list of document details related to user
        /// </summary>
        /// <returns></returns>
        public ActionResult GetDocumentDetails()
        {
            try
            {
                if (SessionManagement.UserInfo != null)
                {
                    LoginInformation loginInfo = SessionManagement.UserInfo;

                    var lstDocument = new List <ClientDocumentModel>();

                    //Get docs required for that account type
                    var reqDocs = r_UserDocumentBO.GetAllDocumentsOfAccountType(loginInfo.AccountType);

                    //Iterate through each doc type
                    foreach (var doc in reqDocs)
                    {
                        var document = new ClientDocumentModel();
                        document.DocumentName = doc.Document.DocumentName;
                        document.DocumentID   = (int)doc.FK_DocumentID;

                        //Get user document details if exists from db
                        var docDetails = userDocumentBO.GetUserDocumentDetails(loginInfo.UserID, (int)doc.FK_DocumentID);
                        if (docDetails != null)
                        {
                            document.Status = docDetails.Status;
                        }
                        else
                        {
                            document.Status = "Missing Documents";
                        }
                        lstDocument.Add(document);
                    }

                    return(Json(new
                    {
                        total = 1,
                        page = 1,
                        records = lstDocument.Count,
                        rows = lstDocument
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(RedirectToAction("Login", "Account"));
                }
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                return(View("ErrorMessage"));
            }
        }
Esempio n. 19
0
        /// <summary>
        /// This actions updates funding source data
        /// </summary>
        /// <param name="fundSource">fundSource</param>
        /// <returns></returns>
        public ActionResult UpdateFundingSource(FundingSourceDetail fundSource)
        {
            int?fkInterBankCountryID = null;

            try
            {
                if (SessionManagement.UserInfo != null)
                {
                    var source = new FundingSource();
                    source.PK_FundingSourceID         = fundSource.PK_FundingSourceID;
                    source.SourceType                 = Convert.ToInt32(fundSource.SourceType);
                    source.SourceName                 = fundSource.SourceName;
                    source.BankName                   = fundSource.BankName;
                    source.BicOrSwiftCode             = fundSource.BicOrSwiftCode;
                    source.AccountNumber              = fundSource.AccountNumber;
                    source.FK_ReceivingBankInfoID     = fundSource.FK_ReceivingBankInfoID;
                    source.ReceivingBankInfo          = fundSource.ReceivingBankInfo;
                    source.BankAddress                = fundSource.BankAddress;
                    source.BankCity                   = fundSource.BankCity;
                    source.FK_BankCountryID           = fundSource.FK_BankCountryID;
                    source.BankPostalCode             = fundSource.BankPostalCode;
                    source.InterBankName              = fundSource.InterBankName;
                    source.FK_InterBankCountryID      = fundSource.FK_InterBankCountryID != 0 ? fundSource.FK_InterBankCountryID : fkInterBankCountryID;
                    source.InterBicOrSwiftCode        = fundSource.InterBicOrSwiftCode;
                    source.IncomingWireFeeAmount      = fundSource.IncomingWireFeeAmount;
                    source.OutgoingWireFeeAmount      = fundSource.OutgoingWireFeeAmount;
                    source.FK_IncomingWireFeeCurrency = fundSource.FK_IncomingWireFeeCurr;
                    source.FK_OutgoingWireFeeCurrency = fundSource.FK_OutgoingWireFeeCurr;
                    source.IsEnabled                  = false;
                    source.IsDeleted                  = false;

                    //Call BO method to update
                    if (fundSourceBO.UpdateFundingSource(source))
                    {
                        return(Json(fundSoureAcceptedCurrBO.UpdateFundingSourceAcceptedCurrency(fundSource.PK_FundingSourceID, fundSource.AcceptedCurr)));
                    }
                    else
                    {
                        return(Json(false));
                    }
                }
                else
                {
                    return(RedirectToAction("Login", "Account", new { Area = "" }));
                }
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                return(Json(false));
            }
        }
Esempio n. 20
0
        /// <summary>
        /// This method returns list of all funding sources
        /// </summary>
        /// <returns></returns>
        public ActionResult GetAllFundingSources()
        {
            try
            {
                if (SessionManagement.UserInfo != null)
                {
                    var lstFundingSources = new List <FundingSourceDetail>();

                    //Get all funding sources
                    var allFundSources = fundSourceBO.GetAllFundSources((int)SessionManagement.OrganizationID);

                    //Iterate through each source
                    foreach (var source in allFundSources)
                    {
                        var fundSource = new FundingSourceDetail();
                        fundSource.PK_FundingSourceID = source.PK_FundingSourceID;
                        fundSource.SourceType         = GetSourceTypeValueFromID((int)source.SourceType);
                        fundSource.SourceName         = source.SourceName;
                        fundSource.AccountNumber      = source.AccountNumber;
                        fundSource.AcceptedCurr       = fundSoureAcceptedCurrBO.GetAllAcceptedCurrenciesofSource(source.PK_FundingSourceID);
                        if ((bool)source.IsEnabled)
                        {
                            fundSource.Action = "<input class='icon active tip' title='Disable' type='button' value='Disable' onclick='disableFundingSource(" + source.PK_FundingSourceID + ")'><input type='button' class='icon view-edit tip' data-modal='modalUpdateSource' title='View/Edit' onclick='showUpdateFundSource(" + source.PK_FundingSourceID + ")'><input class='icon delete tip' title='Delete' type='button' value='Delete' onclick='deleteFundingSource(" + source.PK_FundingSourceID + ")'>";
                        }
                        else
                        {
                            fundSource.Action = "<input class='icon inactive tip' title='Enable' type='button' value='Disable' onclick='enableFundingSource(" + source.PK_FundingSourceID + ")'><input type='button' class='icon view-edit tip' data-modal='modalUpdateSource' title='View/Edit' onclick='showUpdateFundSource(" + source.PK_FundingSourceID + ")'><input class='icon delete tip' title='Delete' type='button' value='Delete' onclick='deleteFundingSource(" + source.PK_FundingSourceID + ")'>";
                        }

                        lstFundingSources.Add(fundSource);
                    }

                    //Return list
                    return(Json(new
                    {
                        total = 1,
                        page = 1,
                        records = lstFundingSources.Count,
                        rows = lstFundingSources
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(RedirectToAction("Login", "Account", new { Area = "" }));
                }
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                throw;
            }
        }
Esempio n. 21
0
        /// <summary>
        /// This action inserts new fund source info into database
        /// </summary>
        /// <param name="newFundSource">newFundSource</param>
        /// <returns></returns>
        public ActionResult AddNewFundingSource(FundingSourceDetail newFundSource)
        {
            int?fkInterBankCountryID = null;

            try
            {
                if (SessionManagement.UserInfo != null)
                {
                    var source = new FundingSource();
                    source.SourceType                 = Convert.ToInt32(newFundSource.SourceType);
                    source.SourceName                 = newFundSource.SourceName;
                    source.BankName                   = newFundSource.BankName;
                    source.BicOrSwiftCode             = newFundSource.BicOrSwiftCode;
                    source.AccountNumber              = newFundSource.AccountNumber;
                    source.FK_ReceivingBankInfoID     = newFundSource.FK_ReceivingBankInfoID;
                    source.ReceivingBankInfo          = newFundSource.ReceivingBankInfo;
                    source.BankAddress                = newFundSource.BankAddress;
                    source.BankCity                   = newFundSource.BankCity;
                    source.FK_BankCountryID           = newFundSource.FK_BankCountryID;
                    source.BankPostalCode             = newFundSource.BankPostalCode;
                    source.InterBankName              = newFundSource.InterBankName;
                    source.FK_InterBankCountryID      = newFundSource.FK_InterBankCountryID != 0 ? newFundSource.FK_InterBankCountryID : fkInterBankCountryID;
                    source.InterBicOrSwiftCode        = newFundSource.InterBicOrSwiftCode;
                    source.IncomingWireFeeAmount      = newFundSource.IncomingWireFeeAmount;
                    source.OutgoingWireFeeAmount      = newFundSource.OutgoingWireFeeAmount;
                    source.FK_IncomingWireFeeCurrency = newFundSource.FK_IncomingWireFeeCurr;
                    source.FK_OutgoingWireFeeCurrency = newFundSource.FK_OutgoingWireFeeCurr;
                    source.FK_OrganizationID          = (int)SessionManagement.OrganizationID;
                    source.IsEnabled                  = false;
                    source.IsDeleted                  = false;

                    //Add accepted currencies if funding source inserted successfully
                    if (fundSourceBO.AddNewFundingSource(source))
                    {
                        return(Json(fundSoureAcceptedCurrBO.AddFundingSourceAcceptedCurrency(source.PK_FundingSourceID, newFundSource.AcceptedCurr)));
                    }
                    else
                    {
                        return(Json(false));
                    }
                }
                else
                {
                    return(RedirectToAction("Login", "Account", new { Area = "" }));
                }
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                return(Json(false));
            }
        }
Esempio n. 22
0
 public string GetAllCurrencyAccountsForUser()
 {
     try
     {
         LoginInformation loginInfo = SessionManagement.UserInfo;
         return(clientAccBo.GetDifferentCurrencyAccountOfUser(loginInfo.LogAccountType, loginInfo.UserID));
     }
     catch (Exception ex)
     {
         CurrentDeskLog.Error(ex.Message, ex);
         throw;
     }
 }
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            try
            {
                var organizationID = OrganizationUtility.GetOrganizationID(Request.Url.AbsoluteUri);

                if (ModelState.IsValid && organizationID != null)
                {
                    if (LoginVerification.ValidateUser(model.UserName, model.Password, (int)organizationID))
                    {
                        FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                        if (SessionManagement.UserInfo.LogAccountType == LoginAccountType.LiveAccount)
                        {
                            return(RedirectToAction("Index", "Dashboard"));
                        }
                        //If Introducing Broker
                        else if (SessionManagement.UserInfo.AccountCode == Constants.K_ACCTCODE_IB)
                        {
                            return(RedirectToAction("Index", "Dashboard", new { Area = "IntroducingBroker" }));
                        }
                        //If Asset Manager
                        else if (SessionManagement.UserInfo.AccountCode == Constants.K_ACCTCODE_AM)
                        {
                            return(RedirectToAction("Index", "Profile", new { Area = "AssetManager" }));
                        }
                        //If Super Admin
                        else if (SessionManagement.UserInfo.AccountCode == Constants.K_ACCTCODE_SUPERADMIN)
                        {
                            return(RedirectToAction("Index", "Dashboard", new { Area = "SuperAdmin" }));
                        }
                        else
                        {
                            ModelState.AddModelError("", "Some error occurred!");
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", "The user name or password provided is incorrect.");
                    }
                }


                return(View(model));
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                throw;
            }
        }
        /// <summary>
        /// This action returns all conversion transactions of clients
        /// </summary>
        /// <returns></returns>
        public ActionResult GetAllConversionTransactions()
        {
            try
            {
                if (SessionManagement.UserInfo != null)
                {
                    //Get all conversion transactions
                    var conversionTransactions =
                        adminTransactionBO.GetAllTransactionsOfParticularType((int)AdminTransactionType.ConversionsRequests, (int)SessionManagement.OrganizationID);

                    var lstConversionTransfers = new List <DashboardTransactionModel>();

                    //Iterating through each conversion transaction
                    foreach (var transaction in conversionTransactions)
                    {
                        var convTran = new DashboardTransactionModel();
                        convTran.TransactionDate =
                            Convert.ToDateTime(transaction.TransactionDate).ToString("dd/MM/yyyy hh:mm:ss tt");
                        convTran.AccountNumber   = transaction.AccountNumber;
                        convTran.ClientName      = transaction.ClientName;
                        convTran.ToAccount       = transaction.ToAccountNumber;
                        convTran.ToClientName    = transaction.ToClientName;
                        convTran.Amount          = Utility.FormatCurrencyValue((decimal)transaction.TransactionAmount, "");
                        convTran.ExchangeRate    = (double)transaction.ExchangeRate;
                        convTran.ExchangedAmount = Utility.FormatCurrencyValue(Math.Round((decimal)(transaction.TransactionAmount * (decimal)transaction.ExchangeRate), 2), "");
                        convTran.Status          = (bool)transaction.IsApproved ? "Approved" : "Pending";

                        lstConversionTransfers.Add(convTran);
                    }

                    return(Json(new
                    {
                        total = 1,
                        page = 1,
                        records = lstConversionTransfers.Count,
                        rows = lstConversionTransfers
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(RedirectToAction("Login", "Account", new { Area = "" }));
                }
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                throw;
            }
        }
        /// <summary>
        /// This action returns list of user messages as per status
        /// </summary>
        /// <param name="status">status</param>
        /// <returns></returns>
        public ActionResult GetUserMessages(string status)
        {
            try
            {
                if (SessionManagement.UserInfo != null)
                {
                    var lstMessages            = new List <InboxModel>();
                    LoginInformation loginInfo = SessionManagement.UserInfo;

                    var sortColName = System.Web.HttpContext.Current.Request["sidx"];
                    var sortOrder   = System.Web.HttpContext.Current.Request["sord"];

                    //Get all messages of user as per status
                    var userMsgs = intUsrMsgBO.GetUserMessages(loginInfo.UserID, status, sortColName, sortOrder);

                    foreach (var msg in userMsgs)
                    {
                        var userMsg = new InboxModel();
                        userMsg.PK_MessageID   = msg.PK_MessageID;
                        userMsg.MessageSubject = msg.MessageSubject;
                        userMsg.MessageBody    = msg.MessageContent;
                        userMsg.Timestamp      = Convert.ToDateTime(msg.Timestamp).ToString("dd/MM/yyyy HH:mm:ss tt");
                        userMsg.FromUserName   = msg.FromUserName;
                        userMsg.IsRead         = (bool)msg.IsRead;
                        userMsg.LongDateString = Convert.ToDateTime(msg.Timestamp).ToLongDateString() + " " + Convert.ToDateTime(msg.Timestamp).ToLongTimeString();
                        userMsg.MessageTime    = (DateTime)msg.Timestamp;

                        lstMessages.Add(userMsg);
                    }

                    return(Json(new
                    {
                        total = 1,
                        page = 1,
                        records = lstMessages.Count,
                        rows = lstMessages
                    }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(RedirectToAction("Login", "Account"));
                }
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                return(View("ErrorMessage"));
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Get Equity,Balance and Pnl from Cache
        /// </summary>
        /// <param name="lstLogin"></param>
        /// <returns></returns>
        public JsonResult GetEquityList(string strLogin)
        {
            var lstMarginDetails = new List <MarginDetails>();
            var lstLogin         = new List <int>();

            try
            {
                //Convert platform login to List<int>
                string[] lstStrLogins = strLogin.Split(new[] { ',' });
                foreach (var pl in lstStrLogins)
                {
                    lstLogin.Add(pl.Int32TryParse());
                }

                //Get Data from cache
                var           marginCache = new DataCache("MarginCache");
                List <string> lstStrLogin = lstLogin.Select(s => s.StringTryParse()).ToList();
                IEnumerable <KeyValuePair <string, object> > lstMarginsObj = marginCache.BulkGet(lstStrLogin);

                //Create a Json Data
                var lstMargins = lstMarginsObj.Select(s => (Margin)s.Value).ToList();
                foreach (var margin in lstMargins)
                {
                    var ed = new MarginDetails();
                    if (margin != null)
                    {
                        ed.Pl  = margin.Login ?? 0;
                        ed.Equ = margin.Equity.CurrencyFormat();
                        ed.Bal = margin.Balance.CurrencyFormat();

                        var equity = margin.Equity ?? 0;
                        var bal    = margin.Balance ?? 0;

                        var pnl = equity - bal;
                        ed.Pnl = pnl.CurrencyFormat();
                        lstMarginDetails.Add(ed);
                    }
                }

                return(Json(lstMarginDetails, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
            }

            return(Json(string.Empty, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Login(string returnUrl)
        {
            try
            {
                //Check Whether User is already Authenticated
                if (SessionManagement.IsLoginAuthenticated)
                {
                    if (SessionManagement.UserInfo.LogAccountType == LoginAccountType.LiveAccount)
                    {
                        return(RedirectToAction("Index", "Dashboard"));
                    }
                    //If Introducing Broker
                    else if (SessionManagement.UserInfo.AccountCode == Constants.K_ACCTCODE_IB)
                    {
                        return(RedirectToAction("Index", "Dashboard", new { Area = "IntroducingBroker" }));
                    }
                    //If Asset Manager
                    else if (SessionManagement.UserInfo.AccountCode == Constants.K_ACCTCODE_AM)
                    {
                        return(RedirectToAction("Index", "Profile", new { Area = "AssetManager" }));
                    }
                    //If Super Admin
                    else if (SessionManagement.UserInfo.AccountCode == Constants.K_ACCTCODE_SUPERADMIN)
                    {
                        return(RedirectToAction("Index", "Dashboard", new { Area = "SuperAdmin" }));
                    }
                }

                //Check for the existing organization from the URL
                var organizationID = OrganizationUtility.GetOrganizationID(Request.Url.AbsoluteUri);
                if (organizationID != null)
                {
                    SessionManagement.OrganizationID = organizationID;
                    ViewBag.ReturnUrl = returnUrl;
                    return(View());
                }
                else
                {
                    //Redirect it to page not found.
                    return(RedirectToAction("PageNotFound", "Error"));
                }
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                throw;
            }
        }
 /// <summary>
 /// This Function will abort the BOMAMOpenTrades
 /// </summary>
 public void StopBOMAMOpenTrade()
 {
     try
     {
         //Check if thread exist or alive
         if (boMAMOpenTradeThread != null && boMAMOpenTradeThread.IsAlive)
         {
             boMAMOpenTradeThread.Abort();
         }
     }
     catch (Exception exceptionMessage)
     {
         //Log Error
         CurrentDeskLog.Error("Stopping Open Trades :" + exceptionMessage);
     }
 }
 /// <summary>
 /// This Function will Abort the thread
 /// </summary>
 public void StopBOMAM()
 {
     try
     {
         //Check whether Thread is null or alive
         if (boMAMAssetMangerThread != null && boMAMAssetMangerThread.IsAlive)
         {
             boMAMAssetMangerThread.Abort();
         }
     }
     catch (Exception exceptionMessage)
     {
         //Log Error
         CurrentDeskLog.Error("Stopping Asset manager :" + exceptionMessage);
     }
 }
Esempio n. 30
0
        /// <summary>
        /// This action returns AccountDetails view with
        /// required data to be displayed passed as model
        /// </summary>
        /// <param name="accountNumber">accountNumber</param>
        /// <returns></returns>
        public ActionResult ShowAccountDetails(string accountNumber)
        {
            try
            {
                if (SessionManagement.UserInfo != null)
                {
                    var organizationID = (int)SessionManagement.OrganizationID;

                    var model = new AccountDetailsModel();
                    model.TransferLogDetails = new List <TransferLogDetails>();

                    //Get account details and latest transactions
                    var accountDetails     = clientAccBo.GetAccountDetails(accountNumber, organizationID);
                    var latestTransactions = transferLogBO.GetLatestTransactionsForAccount(accountNumber, organizationID);

                    //Iterate through all transactions
                    foreach (var tran in latestTransactions)
                    {
                        var log = new TransferLogDetails();
                        log.TransactionDate   = Convert.ToDateTime(tran.TransactionDateTime).ToString("dd/MM/yyyy HH:mm:ss tt");
                        log.TransactionType   = tran.TransactionType;
                        log.TransactionAmount = Utility.FormatCurrencyValue((decimal)tran.Amount, "");
                        model.TransferLogDetails.Add(log);
                    }

                    model.AccountNumber = accountNumber;

                    model.Balance = Utility.FormatCurrencyValue((decimal)accountDetails.CurrentBalance, "");

                    model.AccountName      = accountDetails.AccountName;
                    model.IsTradingAcc     = accountDetails.IsTradingAccount;
                    model.PlatformLogin    = accountDetails.PlatformLogin.ToString();
                    model.PlatformPassword = accountDetails.PlatformPassword;

                    return(View("AccountDetails", model));
                }
                else
                {
                    return(RedirectToAction("Login", "Account", new { Area = "" }));
                }
            }
            catch (Exception ex)
            {
                CurrentDeskLog.Error(ex.Message, ex);
                return(View("ErrorMessage"));
            }
        }