public void CreateEQNetpositionForAllAdviser()
        {
            int adviserId  = 0;
            int customerId = 0;

            CheckForTradeDate(DateTime.Today.AddDays(-1));
            if (isValuationDateTradeDate)
            {
                adviserVoList = adviserMaintenanceBo.GetAdviserList();
                for (int i = 0; i < adviserVoList.Count; i++)
                {
                    adviserId = adviserVoList[i].advisorId;
                    int logId = 0;
                    logId = CreateAdviserEODLog("EQ", DateTime.Today.AddDays(-1), adviserId);
                    try
                    {
                        customerList = customerPortfolioBo.GetAdviserCustomerList_EQ(adviserId);

                        if (customerList != null && customerList.Count > 0)
                        {
                            for (int j = 0; j < customerList.Count; j++)
                            {
                                customerId = customerList[j];
                                try
                                {
                                    customerPortfolioList = portfolioBo.GetCustomerPortfolios(customerId);
                                    customerPortfolioBo.DeleteEquityNetPosition(customerId, DateTime.Today.AddDays(-1));
                                    if (customerPortfolioList != null)
                                    {
                                        for (int k = 0; k < customerPortfolioList.Count; k++)
                                        {
                                            eqPortfolioList = customerPortfolioBo.GetCustomerEquityPortfolio(customerId, customerPortfolioList[k].PortfolioId, DateTime.Today.AddDays(-1), string.Empty, string.Empty);
                                            if (eqPortfolioList != null)
                                            {
                                                customerPortfolioBo.AddEquityNetPosition(eqPortfolioList, 1000);
                                            }
                                        }
                                    }
                                }
                                catch (BaseApplicationException Ex)
                                {
                                    throw Ex;
                                }
                                catch (Exception Ex)
                                {
                                    BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                                    NameValueCollection      FunctionInfo = new NameValueCollection();
                                    FunctionInfo.Add("Method", "EquityNetpositionProcessBo:CreateEQNetpositionForAllAdviser()");
                                    object[] objects = new object[2];
                                    objects[0]   = "EQ";
                                    objects[1]   = customerId;
                                    FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                                    exBase.AdditionalInformation = FunctionInfo;
                                    ExceptionManager.Publish(exBase);
                                    throw exBase;
                                }
                            }
                            UpdateAdviserEODLog("EQ", 1, logId);
                        }
                    }
                    catch (BaseApplicationException Ex)
                    {
                        throw Ex;
                    }
                    catch (Exception Ex)
                    {
                        BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                        NameValueCollection      FunctionInfo = new NameValueCollection();
                        FunctionInfo.Add("Method", "EquityNetpositionProcessBo:CreateEQNetpositionForAllAdviser()");
                        object[] objects = new object[2];
                        objects[0]   = "EQ";
                        objects[1]   = adviserId;
                        FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                        exBase.AdditionalInformation = FunctionInfo;
                        ExceptionManager.Publish(exBase);
                        throw exBase;
                    }
                }
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            List <AdvisorVo>           adviserVoList         = new List <AdvisorVo>();
            AdviserMaintenanceBo       adviserMaintenanceBo  = new AdviserMaintenanceBo();
            CustomerPortfolioBo        customerPortfolioBo   = new CustomerPortfolioBo();
            PortfolioBo                portfolioBo           = new PortfolioBo();
            List <CustomerPortfolioVo> customerPortfolioList = new List <CustomerPortfolioVo>();
            List <MFPortfolioVo>       mfPortfolioList       = new List <MFPortfolioVo>();
            List <EQPortfolioVo>       eqPortfolioList       = new List <EQPortfolioVo>();
            List <int> customerList_MF   = new List <int>();
            List <int> customerList_EQ   = new List <int>();
            DataSet    dsMFValuationDate = new DataSet();
            DataSet    dsEQValuationDate = new DataSet();
            DateTime   tradeDate         = new DateTime();
            int        LogId             = 0;
            int        year  = int.Parse(ConfigurationSettings.AppSettings["YEAR"].ToString());
            int        month = int.Parse(ConfigurationSettings.AppSettings["MONTH"].ToString());
            int        day   = int.Parse(ConfigurationSettings.AppSettings["FROMDAY"].ToString());

            tradeDate = new DateTime(year, month, 01);
            while (tradeDate.Year == year && tradeDate.Month == month)
            {
                //if (DateTime.Now.TimeOfDay.Hours < 1)
                //    tradeDate = DateTime.Today.AddDays(-1);
                //else

                Console.WriteLine("Starting for the Year:" + tradeDate.Year.ToString() + "Month:" + tradeDate.Month.ToString());
                DateTime MFValuationDate;
                DateTime EQValuationDate;
                try
                {
                    adviserVoList = adviserMaintenanceBo.GetAdviserList();
                    Console.WriteLine("Starting Valuation Process for " + adviserVoList.Count.ToString() + " Advisers");
                    for (int i = 0; i < adviserVoList.Count; i++)
                    {
                        dsMFValuationDate = customerPortfolioBo.GetAdviserValuationDate(adviserVoList[i].advisorId, "MF", tradeDate.Month, tradeDate.Year);
                        dsEQValuationDate = customerPortfolioBo.GetAdviserValuationDate(adviserVoList[i].advisorId, "EQ", tradeDate.Month, tradeDate.Year);
                        customerList_MF   = customerPortfolioBo.GetAdviserCustomerList_MF(adviserVoList[i].advisorId);
                        customerList_EQ   = customerPortfolioBo.GetAdviserCustomerList_EQ(adviserVoList[i].advisorId);
                        Console.WriteLine("Starting MF Valuation Process for Adviser: " + adviserVoList[i].OrganizationName.ToString());

                        foreach (DataRow drMF in dsMFValuationDate.Tables[0].Rows)
                        {
                            if (DateTime.Parse(drMF["WTD_Date"].ToString()).Day != DateTime.Now.Day && DateTime.Parse(drMF["WTD_Date"].ToString()).Day > day)
                            {
                                MFValuationDate = DateTime.Parse(drMF["WTD_Date"].ToString());
                                if (drMF["STAT"].ToString() == "Pending. Changes Found")
                                {
                                    customerPortfolioBo.DeleteAdviserEODLog(adviserVoList[i].advisorId, "MF", MFValuationDate, 0);
                                }
                                if (drMF["STAT"].ToString() != "Completed")
                                {
                                    if (DateTime.Compare(MFValuationDate, DateTime.Today) <= 0)
                                    {
                                        if (customerList_MF != null && customerList_MF.Count != 0)
                                        {
                                            LogId = CreateAdviserEODLog("MF", MFValuationDate, adviserVoList[i].advisorId);
                                            for (int j = 0; j < customerList_MF.Count; j++)
                                            {
                                                customerPortfolioList = portfolioBo.GetCustomerPortfolios(customerList_MF[j]);
                                                customerPortfolioBo.DeleteMutualFundNetPosition(customerList_MF[j], MFValuationDate);
                                                if (customerPortfolioList != null && customerPortfolioList.Count != 0)
                                                {
                                                    for (int k = 0; k < customerPortfolioList.Count; k++)
                                                    {
                                                        Console.WriteLine("Starting MF Valuation Process for Customer:" + j.ToString() + " Portfolio:" + k.ToString() + " Date:" + MFValuationDate.ToShortDateString());
                                                        try
                                                        {
                                                            mfPortfolioList = customerPortfolioBo.GetCustomerMFPortfolio(customerList_MF[j], customerPortfolioList[k].PortfolioId, MFValuationDate, "", "", "");
                                                        }
                                                        catch (Exception ex)
                                                        {
                                                            Console.WriteLine("Exception: " + ex.ToString());
                                                        }
                                                        if (mfPortfolioList != null && mfPortfolioList.Count != 0)
                                                        {
                                                            try
                                                            {
                                                                customerPortfolioBo.AddMutualFundNetPosition(mfPortfolioList, adviserVoList[i].UserId);
                                                            }
                                                            catch (Exception Ex)
                                                            {
                                                                Console.WriteLine("Exception: " + Ex.ToString());
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            UpdateAdviserEODLog("MF", 1, LogId);
                                        }
                                    }
                                }
                            }
                        }
                        #region Equity Valuation
                        Console.WriteLine("Starting EQ Valuation Process for Adviser " + i.ToString());

                        foreach (DataRow drEQ in dsEQValuationDate.Tables[0].Rows)
                        {
                            EQValuationDate = DateTime.Parse(drEQ["WTD_Date"].ToString());
                            if (drEQ["STAT"].ToString() == "Pending. Changes Found")
                            {
                                customerPortfolioBo.DeleteAdviserEODLog(adviserVoList[i].advisorId, "EQ", EQValuationDate, 0);
                            }
                            if (drEQ["STAT"].ToString() != "Completed")
                            {
                                if (DateTime.Compare(EQValuationDate, DateTime.Today) <= 0)
                                {
                                    if (customerList_EQ != null && customerList_EQ.Count != 0)
                                    {
                                        LogId = CreateAdviserEODLog("EQ", EQValuationDate, adviserVoList[i].advisorId);
                                        for (int j = 0; j < customerList_EQ.Count; j++)
                                        {
                                            customerPortfolioList = portfolioBo.GetCustomerPortfolios(customerList_EQ[j]);
                                            customerPortfolioBo.DeleteEquityNetPosition(customerList_EQ[j], EQValuationDate);
                                            if (customerPortfolioList != null && customerPortfolioList.Count != 0)
                                            {
                                                for (int k = 0; k < customerPortfolioList.Count; k++)
                                                {
                                                    Console.WriteLine("Starting EQ Valuation Process for Customer:" + j.ToString() + " Portfolio:" + k.ToString() + " Date:" + EQValuationDate.ToShortDateString());
                                                    try
                                                    {
                                                        eqPortfolioList = customerPortfolioBo.GetCustomerEquityPortfolio(customerList_EQ[j], customerPortfolioList[k].PortfolioId, EQValuationDate, string.Empty, string.Empty);
                                                    }
                                                    catch (Exception Ex)
                                                    {
                                                        Console.WriteLine("Exception: " + Ex.ToString());
                                                    }
                                                    if (eqPortfolioList != null && eqPortfolioList.Count != 0)
                                                    {
                                                        try
                                                        {
                                                            customerPortfolioBo.AddEquityNetPosition(eqPortfolioList, adviserVoList[i].UserId);
                                                        }
                                                        catch (Exception Ex)
                                                        {
                                                            Console.WriteLine("Exception: " + Ex.ToString());
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        UpdateAdviserEODLog("EQ", 1, LogId);
                                    }
                                }
                            }
                        }
                        #endregion Equity Valuation
                    }
                }
                catch (BaseApplicationException Ex)
                {
                    throw Ex;
                }
                catch (Exception Ex)
                {
                    BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                    NameValueCollection      FunctionInfo = new NameValueCollection();
                    FunctionInfo.Add("Method", "DailyValuation.ascx.cs:CreateAdviserEODLog()");
                    object[] objects = new object[2];
                    objects[0]   = 0;
                    objects[1]   = tradeDate;
                    FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                    exBase.AdditionalInformation = FunctionInfo;
                    ExceptionManager.Publish(exBase);
                    throw exBase;
                }
                tradeDate = tradeDate.AddMonths(1);
            }
        }
コード例 #3
0
        public void UpdateLOG(string value, string assetgroup)
        {
            int        cnt          = 0;
            int        LogId        = 0;
            int        notNullcnt   = 0;
            List <int> customerList = new List <int>();
            List <CustomerPortfolioVo> customerPortfolioList = new List <CustomerPortfolioVo>();
            List <EQPortfolioVo>       eqPortfolioList       = null;
            List <MFPortfolioVo>       mfPortfolioList       = null;
            string status = string.Empty;

            try
            {
                if (value == "1" && assetgroup == "EQ")
                {
                    if (rbtnEquity.Checked)
                    {
                        if (ddTradeMonth.SelectedValue != "" && ddTradeYear.SelectedValue != "")
                        {
                            for (int i = 0; i < dsAdviserValuationDate.Tables[0].Rows.Count; i++)
                            {
                                GridViewRow gvr = gvValuationDate.Rows[i];
                                if (gvValuationDate.Rows[i].RowType == DataControlRowType.DataRow)
                                {
                                    CheckBox checkBox = (CheckBox)gvr.FindControl("chkBx");
                                    status = gvr.Cells[2].Text.ToString();
                                    if (checkBox.Checked)
                                    {
                                        dt = DateTime.Parse(dsAdviserValuationDate.Tables[0].Rows[i][0].ToString());
                                        if (status == "Pending. Changes Found" || status == "Completed")
                                        {
                                            customerPortfolioBo.DeleteAdviserEODLog(advisorVo.advisorId, "EQ", dt, 0);
                                        }



                                        if (DateTime.Compare(dt, DateTime.Today) <= 0)
                                        {
                                            customerList = customerPortfolioBo.GetAdviserCustomerList_EQ(advisorVo.advisorId);

                                            if (customerList != null)
                                            {
                                                notNullcnt = notNullcnt + 1;
                                                LogId      = CreateAdviserEODLog("EQ", dt);
                                                if (LogId != 0)
                                                {
                                                    cnt = 0;
                                                    for (int j = 0; j < customerList.Count; j++)
                                                    {
                                                        customerPortfolioList = portfolioBo.GetCustomerPortfolios(customerList[j]);
                                                        customerPortfolioBo.DeleteEquityNetPosition(customerList[j], dt);
                                                        if (customerPortfolioList != null)
                                                        {
                                                            for (int k = 0; k < customerPortfolioList.Count; k++)
                                                            {
                                                                eqPortfolioList = customerPortfolioBo.GetCustomerEquityPortfolio(customerList[j], customerPortfolioList[k].PortfolioId, dt, string.Empty, string.Empty);
                                                                if (eqPortfolioList != null)
                                                                {
                                                                    customerPortfolioBo.AddEquityNetPosition(eqPortfolioList, userVo.UserId);
                                                                }
                                                            }
                                                        }

                                                        cnt = cnt + 1;
                                                    }
                                                }

                                                if (cnt == customerList.Count)
                                                {
                                                    UpdateAdviserEODLog("EQ", 1, LogId);
                                                    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "pageloadscript", "alert('Equity Valuation done...!');", true);
                                                }
                                                else
                                                {
                                                    UpdateAdviserEODLog("EQ", 0, LogId);
                                                    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "pageloadscript", "alert('Equity Valuation not done...!');", true);
                                                }

                                                //
                                            }
                                            else
                                            {
                                                break;
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    continue;
                                }
                            }
                            if (notNullcnt == 0)
                            {
                                ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "pageloadscript", "alert('No Customers With Equity Transactions....');", true);
                            }
                        }
                    }
                }
                else if (value == "1" && assetgroup == "MF")
                {
                    if (ddTradeMFMonth.SelectedValue != "" && ddTradeMFYear.SelectedValue != "")
                    {
                        for (int i = 0; i < dsAdviserValuationDate.Tables[0].Rows.Count; i++)
                        {
                            GridViewRow gvr = gvValuationDate.Rows[i];
                            if (gvValuationDate.Rows[i].RowType == DataControlRowType.DataRow)
                            {
                                CheckBox checkBox = (CheckBox)gvr.FindControl("chkBx");
                                status = gvr.Cells[2].Text.ToString();
                                if (checkBox.Checked)
                                {
                                    dt = DateTime.Parse(dsAdviserValuationDate.Tables[0].Rows[i][0].ToString());
                                    if (status == "Pending. Changes Found" || status == "Completed")
                                    {
                                        customerPortfolioBo.DeleteAdviserEODLog(advisorVo.advisorId, "MF", dt, 0);
                                    }

                                    if (DateTime.Compare(dt, DateTime.Today) <= 0)
                                    {
                                        customerList = customerPortfolioBo.GetAdviserCustomerList_MF(advisorVo.advisorId);
                                        if (customerList != null)
                                        {
                                            notNullcnt = notNullcnt + 1;
                                            LogId      = CreateAdviserEODLog("MF", dt);
                                            if (LogId != 0)
                                            {
                                                cnt = 0;
                                                for (int j = 0; j < customerList.Count; j++)
                                                {
                                                    customerPortfolioList = portfolioBo.GetCustomerPortfolios(customerList[j]);
                                                    customerPortfolioBo.DeleteMutualFundNetPosition(customerList[j], dt);
                                                    if (customerPortfolioList != null)
                                                    {
                                                        for (int k = 0; k < customerPortfolioList.Count; k++)
                                                        {
                                                            mfPortfolioList = customerPortfolioBo.GetCustomerMFPortfolio(customerList[j], customerPortfolioList[k].PortfolioId, dt, "", "", "");


                                                            if (mfPortfolioList != null)
                                                            {
                                                                customerPortfolioBo.AddMutualFundNetPosition(mfPortfolioList, userVo.UserId);
                                                            }
                                                        }
                                                    }


                                                    cnt = cnt + 1;
                                                }
                                            }
                                            if (cnt == customerList.Count)
                                            {
                                                UpdateAdviserEODLog("MF", 1, LogId);
                                                ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "pageloadscript", "alert('MF Valuation done...!');", true);
                                            }
                                            else
                                            {
                                                UpdateAdviserEODLog("MF", 0, LogId);
                                                ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "pageloadscript", "alert('MF Valuation not done...!');", true);
                                            }

                                            //  GetTradeDate();
                                        }
                                    }
                                }
                                else
                                {
                                    continue;
                                }
                            }
                        }
                        if (notNullcnt == 0)
                        {
                            ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "pageloadscript", "alert('No Customers With MF Transactions....');", true);
                        }
                    }
                }
                GetTradeDate();
            }

            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "DailyValuation.ascx.cs:UpdateLOG()");
                object[] objects = new object[2];
                objects[0]   = value;
                objects[1]   = assetgroup;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
コード例 #4
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            decimal     temp;
            DataTable   dt;
            CultureInfo ci = new CultureInfo("en-GB");

            try
            {
                dt = productEquityBo.GetBrokerCode(portfolioId, ddlTradeAcc.SelectedItem.Text.ToString());

                eqTransactionVo.IsSourceManual = 1;
                if (txtBrokerage.Text != "")
                {
                    eqTransactionVo.Brokerage = float.Parse(txtBrokerage.Text);
                }
                eqTransactionVo.BrokerCode = dt.Rows[0]["XB_BrokerCode"].ToString();
                if (ddlTransactionType.SelectedItem.Text.ToString() == "Purchase")
                {
                    eqTransactionVo.BuySell         = "B";
                    eqTransactionVo.TransactionCode = 1;
                }
                if (ddlTransactionType.SelectedItem.Text.ToString() == "Sell")
                {
                    eqTransactionVo.BuySell         = "S";
                    eqTransactionVo.TransactionCode = 2;
                }
                if (ddlTransactionType.SelectedItem.Text.ToString() == "Holdings")
                {
                    eqTransactionVo.BuySell         = "B";
                    eqTransactionVo.TransactionCode = 13;
                }


                eqTransactionVo.CustomerId   = customerVo.CustomerId;
                eqTransactionVo.IsCorpAction = 0;
                if (rbtnDelivery.Checked)
                {
                    eqTransactionVo.IsSpeculative = 0;
                }
                if (rbtnSpeculation.Checked)
                {
                    eqTransactionVo.IsSpeculative = 1;
                }

                eqTransactionVo.EducationCess = (float)tempEducation;
                eqTransactionVo.ScripCode     = scripCode;
                if (ddlExchange.SelectedItem.Value.ToString() != "Select an Exchange")
                {
                    eqTransactionVo.Exchange = ddlExchange.SelectedItem.Value.ToString();
                }
                else
                {
                    eqTransactionVo.Exchange = "NSE";
                }
                if (txtOtherCharge.Text != "")
                {
                    eqTransactionVo.OtherCharges = float.Parse(txtOtherCharge.Text);
                }
                eqTransactionVo.Quantity      = float.Parse(txtNumShares.Text);
                eqTransactionVo.IsSpeculative = 0;
                eqTransactionVo.TradeType     = "D";



                eqTransactionVo.AccountId         = int.Parse(ddlTradeAcc.SelectedItem.Value.ToString());
                eqTransactionVo.Rate              = float.Parse(txtRate.Text);
                eqTransactionVo.RateInclBrokerage = float.Parse(txtRateIncBrokerage.Text);
                temp = decimal.Round(Convert.ToDecimal(tempService), 3);
                if (txtTax.Text != "")
                {
                    eqTransactionVo.ServiceTax = float.Parse(txtTax.Text);
                }
                if (txtSTT.Text != "")
                {
                    eqTransactionVo.STT = float.Parse(txtSTT.Text);
                }

                eqTransactionVo.TradeDate  = Convert.ToDateTime(txtTradeDate.Text.Trim(), ci);// DateTime.Parse(txtTradeDate.Text);//ddlDay.SelectedItem.Text.ToString() + "/" + ddlMonth.SelectedItem.Value.ToString() + "/" + ddlYear.SelectedItem.Value.ToString()
                eqTransactionVo.TradeTotal = float.Parse(txtTotal.Text);
                eqTransactionVo.TradeNum   = 0;

                if (customerTransactionBo.AddEquityTransaction(eqTransactionVo, customerVo.UserId))
                {
                    customerPortfolioBo.UpdateAdviserDailyEODLogRevaluateForTransaction(advisorVo.advisorId, "EQ", eqTransactionVo.TradeDate);
                }

                List <EQPortfolioVo>          eqPortfolioVoList = new List <EQPortfolioVo>();
                Dictionary <string, DateTime> genDict           = new Dictionary <string, DateTime>();
                DateTime tradeDate = new DateTime();
                if (Session["ValuationDate"] != null)
                {
                    genDict   = (Dictionary <string, DateTime>)Session["ValuationDate"];
                    tradeDate = DateTime.Parse(genDict["EQDate"].ToString());
                }
                if (tradeDate == DateTime.MinValue)
                {
                    tradeDate = DateTime.Today;
                }
                eqPortfolioVoList = customerPortfolioBo.GetCustomerEquityPortfolio(customerVo.CustomerId, portfolioId, tradeDate, txtScrip.Text, ddlTradeAcc.SelectedItem.Value.ToString());
                if (eqPortfolioVoList != null && eqPortfolioVoList.Count > 0)
                {
                    customerPortfolioBo.DeleteEquityNetPosition(eqPortfolioVoList[0].EQCode, eqPortfolioVoList[0].AccountId, tradeDate);
                    customerPortfolioBo.AddEquityNetPosition(eqPortfolioVoList[0], userVo.UserId);
                }

                btnSubmit.Enabled = false;
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "leftpane", "loadcontrol('EquityTransactionsView','none');", true);
            }

            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }

            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "EquityManualSingleTransaction.ascx:btnSubmit_Click()");
                object[] objects = new object[3];
                objects[0]   = portfolioId;;
                objects[1]   = eqTransactionVo;
                objects[2]   = customerVo;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
コード例 #5
0
        public override JobStatus Start(JobParams JP, out string ErrorMsg)
        {
            List <AdvisorVo>           adviserVoList         = new List <AdvisorVo>();
            AdviserMaintenanceBo       adviserMaintenanceBo  = new AdviserMaintenanceBo();
            CustomerPortfolioBo        customerPortfolioBo   = new CustomerPortfolioBo();
            PortfolioBo                portfolioBo           = new PortfolioBo();
            List <CustomerPortfolioVo> customerPortfolioList = new List <CustomerPortfolioVo>();
            List <MFPortfolioVo>       mfPortfolioList       = new List <MFPortfolioVo>();
            List <EQPortfolioVo>       eqPortfolioList       = new List <EQPortfolioVo>();
            List <int> customerList_MF   = new List <int>();
            List <int> customerList_EQ   = new List <int>();
            DataSet    dsMFValuationDate = new DataSet();
            DataSet    dsEQValuationDate = new DataSet();
            DateTime   tradeDate         = new DateTime();
            int        LogId             = 0;

            // if (DateTime.Now.TimeOfDay.Hours < 1)
            tradeDate = DateTime.Today;
            // else
            //  tradeDate = DateTime.Today;

            DateTime MFValuationDate;
            DateTime EQValuationDate;

            adviserVoList = adviserMaintenanceBo.GetAdviserList();

            for (int i = 0; i < adviserVoList.Count; i++)
            {
                dsMFValuationDate = customerPortfolioBo.GetAdviserValuationDate(adviserVoList[i].advisorId, "MF", tradeDate.Month, tradeDate.Year);
                dsEQValuationDate = customerPortfolioBo.GetAdviserValuationDate(adviserVoList[i].advisorId, "EQ", tradeDate.Month, tradeDate.Year);
                customerList_MF   = customerPortfolioBo.GetAdviserCustomerList_MF(adviserVoList[i].advisorId);
                customerList_EQ   = customerPortfolioBo.GetAdviserCustomerList_EQ(adviserVoList[i].advisorId);
                foreach (DataRow drMF in dsMFValuationDate.Tables[0].Rows)
                {
                    MFValuationDate = DateTime.Parse(drMF["WTD_Date"].ToString());
                    if (MFValuationDate != DateTime.Today || DateTime.Today.Hour > 23)
                    {
                        if (drMF["STAT"].ToString() == "Pending. Changes Found")
                        {
                            customerPortfolioBo.DeleteAdviserEODLog(adviserVoList[i].advisorId, "MF", MFValuationDate, 0);
                        }
                        if (drMF["STAT"].ToString() != "Completed")
                        {
                            if (DateTime.Compare(MFValuationDate, DateTime.Today) <= 0)
                            {
                                if (customerList_MF != null && customerList_MF.Count != 0)
                                {
                                    LogId = CreateAdviserEODLog("MF", MFValuationDate, adviserVoList[i].advisorId);
                                    for (int j = 0; j < customerList_MF.Count; j++)
                                    {
                                        customerPortfolioList = portfolioBo.GetCustomerPortfolios(customerList_MF[j]);
                                        customerPortfolioBo.DeleteMutualFundNetPosition(customerList_MF[j], MFValuationDate);
                                        if (customerPortfolioList != null && customerPortfolioList.Count != 0)
                                        {
                                            for (int k = 0; k < customerPortfolioList.Count; k++)
                                            {
                                                try
                                                {
                                                    mfPortfolioList = customerPortfolioBo.GetCustomerMFPortfolio(customerList_MF[j], customerPortfolioList[k].PortfolioId, MFValuationDate, "", "", "");
                                                }
                                                catch (Exception ex)
                                                {
                                                    Console.WriteLine("Exception: " + ex.ToString());
                                                }
                                                if (mfPortfolioList != null && mfPortfolioList.Count != 0)
                                                {
                                                    try
                                                    {
                                                        customerPortfolioBo.AddMutualFundNetPosition(mfPortfolioList, adviserVoList[i].UserId);
                                                    }
                                                    catch (Exception Ex)
                                                    {
                                                        Console.WriteLine("Exception: " + Ex.ToString());
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    UpdateAdviserEODLog("MF", 1, LogId);
                                }
                            }
                        }
                    }
                }

                foreach (DataRow drEQ in dsEQValuationDate.Tables[0].Rows)
                {
                    EQValuationDate = DateTime.Parse(drEQ["WTD_Date"].ToString());
                    if (EQValuationDate != DateTime.Today || DateTime.Today.Hour > 23)
                    {
                        if (drEQ["STAT"].ToString() == "Pending. Changes Found")
                        {
                            customerPortfolioBo.DeleteAdviserEODLog(adviserVoList[i].advisorId, "EQ", EQValuationDate, 0);
                        }
                        if (drEQ["STAT"].ToString() != "Completed")
                        {
                            if (DateTime.Compare(EQValuationDate, DateTime.Today) <= 0)
                            {
                                if (customerList_EQ != null && customerList_EQ.Count != 0)
                                {
                                    LogId = CreateAdviserEODLog("EQ", EQValuationDate, adviserVoList[i].advisorId);
                                    for (int j = 0; j < customerList_EQ.Count; j++)
                                    {
                                        customerPortfolioList = portfolioBo.GetCustomerPortfolios(customerList_EQ[j]);
                                        customerPortfolioBo.DeleteEquityNetPosition(customerList_EQ[j], EQValuationDate);
                                        if (customerPortfolioList != null && customerPortfolioList.Count != 0)
                                        {
                                            for (int k = 0; k < customerPortfolioList.Count; k++)
                                            {
                                                try
                                                {
                                                    eqPortfolioList = customerPortfolioBo.GetCustomerEquityPortfolio(customerList_EQ[j], customerPortfolioList[k].PortfolioId, EQValuationDate, string.Empty, string.Empty);
                                                }
                                                catch (Exception Ex)
                                                {
                                                    Console.WriteLine("Exception: " + Ex.ToString());
                                                }
                                                if (eqPortfolioList != null && eqPortfolioList.Count != 0)
                                                {
                                                    try
                                                    {
                                                        customerPortfolioBo.AddEquityNetPosition(eqPortfolioList, adviserVoList[i].UserId);
                                                    }
                                                    catch (Exception Ex)
                                                    {
                                                        Console.WriteLine("Exception: " + Ex.ToString());
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    UpdateAdviserEODLog("EQ", 1, LogId);
                                }
                            }
                        }
                    }
                }
            }

            ErrorMsg = "";
            return(JobStatus.SuccessFull);
        }
コード例 #6
0
        public void UpdateLOG(string value, string assetGroup, int adviserId, DateTime valuationDate)
        {
            int        cnt          = 0;
            int        LogId        = 0;
            int        notNullcnt   = 0;
            List <int> customerList = new List <int>();
            List <CustomerPortfolioVo> customerPortfolioList = new List <CustomerPortfolioVo>();
            List <EQPortfolioVo>       eqPortfolioList       = null;
            List <MFPortfolioVo>       mfPortfolioList       = null;
            string status = string.Empty;

            try
            {
                if (value == "1" && assetGroup == "EQ")
                {
                    if (rbtnEquity.Checked)
                    {
                        if (ddTradeMonth.SelectedValue != "" && ddTradeYear.SelectedValue != "")
                        {
                            customerPortfolioBo.DeleteAdviserEODLog(adviserId, "EQ", valuationDate, 0);

                            if (DateTime.Compare(valuationDate, DateTime.Today) <= 1)
                            {
                                customerList = customerPortfolioBo.GetAdviserCustomerList_EQ(adviserId);

                                if (customerList != null)
                                {
                                    notNullcnt = notNullcnt + 1;
                                    LogId      = CreateAdviserEODLog("EQ", valuationDate, adviserId);
                                    if (LogId != 0)
                                    {
                                        cnt = 0;
                                        for (int j = 0; j < customerList.Count; j++)
                                        {
                                            customerPortfolioList = portfolioBo.GetCustomerPortfolios(customerList[j]);
                                            customerPortfolioBo.DeleteEquityNetPosition(customerList[j], valuationDate);
                                            if (customerPortfolioList != null)
                                            {
                                                for (int k = 0; k < customerPortfolioList.Count; k++)
                                                {
                                                    eqPortfolioList = customerPortfolioBo.GetCustomerEquityPortfolio(customerList[j], customerPortfolioList[k].PortfolioId, valuationDate, string.Empty, string.Empty);
                                                    if (eqPortfolioList != null)
                                                    {
                                                        customerPortfolioBo.AddEquityNetPosition(eqPortfolioList, userVo.UserId);
                                                    }
                                                }
                                            }

                                            cnt = cnt + 1;
                                        }
                                    }

                                    if (cnt == customerList.Count)
                                    {
                                        UpdateAdviserEODLog("EQ", 1, LogId);
                                        if (Cache[adviserId.ToString()] != null && valuationDate == DateTime.Today)
                                        {
                                            Cache.Remove(adviserId.ToString());
                                        }
                                        ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "pageloadscript", "alert('Equity Valuation done...!');", true);
                                    }
                                    else
                                    {
                                        UpdateAdviserEODLog("EQ", 0, LogId);
                                        ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "pageloadscript", "alert('Equity Valuation not done...!');", true);
                                    }

                                    //
                                    BindAdviserGrid("EQ", valuationDate);
                                }
                            }

                            if (notNullcnt == 0)
                            {
                                ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "pageloadscript", "alert('No Customers With Equity Transactions....');", true);
                            }
                        }
                    }
                }
                else if (value == "1" && assetGroup == "MF")
                {
                    customerPortfolioBo.DeleteAdviserEODLog(adviserId, "MF", valuationDate, 0);
                    if (DateTime.Compare(valuationDate, DateTime.Today) <= 1)
                    {
                        MFEngineBo mfEngineBo = new MFEngineBo();
                        //mfEngineBo.MFBalanceCreation(adviserId, 0, valuationFor);

                        advisorBo.InsertHistoricalValuationInQueue(valuationDate, adviserId, userVo.UserId, int.Parse(hfIsCurrentValuation.Value));
                        ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "pageloadscript", "alert('Request successfully sent !!...Please wait for another 30 mints');", true);

                        BindAdviserGrid("MF", valuationDate);
                    }
                }

                //if (notNullcnt == 0)
                //{
                //    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "pageloadscript", "alert('No Customers With MF Transactions....');", true);

                //}

                //GetTradeDate();
                btnRunValuation.Visible = true;
            }

            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "DailyValuation.ascx.cs:UpdateLOG()");
                object[] objects = new object[2];
                objects[0]   = value;
                objects[1]   = assetGroup;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }