コード例 #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtSearchScheme.Text != "" && lblScheme.Text == txtSearchScheme.Text)
                {
                    mfTransactionVo.CustomerId = customerVo.CustomerId;
                    //mfTransactionVo.AccountId = "acc1";
                    mfTransactionVo.AccountId       = int.Parse(ddlFolioNum.SelectedItem.Value.ToString());
                    mfTransactionVo.MFCode          = int.Parse(txtSchemeCode.Value);
                    mfTransactionVo.FinancialFlag   = 1;
                    mfTransactionVo.TransactionDate = DateTime.Parse(txtTransactionDate.Text);//ddlTransactionDateDay.SelectedItem.Value + "/" + ddlTransactionDateMonth.SelectedItem.Value + "/" + ddlTransactionDateYear.SelectedItem.Value
                    mfTransactionVo.Source          = "WP";
                    mfTransactionVo.IsSourceManual  = 1;


                    if (ddlTransactionType.SelectedItem.Value == "Buy")
                    {
                        mfTransactionVo.NAV    = float.Parse(txtNAV.Text.ToString());
                        mfTransactionVo.Price  = float.Parse(txtPrice.Text.ToString());
                        mfTransactionVo.Amount = float.Parse(txtAmount.Text.ToString());
                        mfTransactionVo.Units  = float.Parse(txtUnits.Text.ToString());
                        mfTransactionVo.TransactionClassificationCode = "BUY";
                        mfTransactionVo.BuySell = "B";

                        if (customerTransactionBo.AddMFTransaction(mfTransactionVo, customerVo.UserId) != 0)
                        {
                            customerPortfolioBo.UpdateAdviserDailyEODLogRevaluateForTransaction(advisorVo.advisorId, "MF", mfTransactionVo.TransactionDate);
                        }
                    }

                    if (ddlTransactionType.SelectedItem.Value == "Holdings")
                    {
                        mfTransactionVo.NAV    = float.Parse(txtNAV.Text.ToString());
                        mfTransactionVo.Price  = float.Parse(txtPrice.Text.ToString());
                        mfTransactionVo.Amount = float.Parse(txtAmount.Text.ToString());
                        mfTransactionVo.Units  = float.Parse(txtUnits.Text.ToString());
                        mfTransactionVo.TransactionClassificationCode = "HLD";
                        mfTransactionVo.BuySell = "B";

                        if (customerTransactionBo.AddMFTransaction(mfTransactionVo, customerVo.UserId) != 0)
                        {
                            customerPortfolioBo.UpdateAdviserDailyEODLogRevaluateForTransaction(advisorVo.advisorId, "MF", mfTransactionVo.TransactionDate);
                        }
                    }
                    if (ddlTransactionType.SelectedItem.Value == "Sell")
                    {
                        mfTransactionVo.NAV    = float.Parse(txtNAV.Text.ToString());
                        mfTransactionVo.Price  = float.Parse(txtPrice.Text.ToString());
                        mfTransactionVo.Amount = float.Parse(txtAmount.Text.ToString());
                        mfTransactionVo.Units  = float.Parse(txtUnits.Text.ToString());
                        mfTransactionVo.STT    = float.Parse(txtSTT.Text.ToString());
                        mfTransactionVo.TransactionClassificationCode = "SEL";
                        mfTransactionVo.BuySell = "S";

                        if (customerTransactionBo.AddMFTransaction(mfTransactionVo, customerVo.UserId) != 0)
                        {
                            customerPortfolioBo.UpdateAdviserDailyEODLogRevaluateForTransaction(advisorVo.advisorId, "MF", mfTransactionVo.TransactionDate);
                        }
                    }
                    if (ddlTransactionType.SelectedItem.Value == "Dividend Reinvestment")
                    {
                        if (txtDividentRate.Text != string.Empty || txtDividentRate.Text != "")
                        {
                            mfTransactionVo.DividendRate = float.Parse(txtDividentRate.Text.ToString());
                        }
                        mfTransactionVo.NAV    = float.Parse(txtNAV.Text.ToString());
                        mfTransactionVo.Price  = float.Parse(txtPrice.Text.ToString());
                        mfTransactionVo.Amount = float.Parse(txtAmount.Text.ToString());
                        mfTransactionVo.Units  = float.Parse(txtUnits.Text.ToString());
                        mfTransactionVo.TransactionClassificationCode = "DVR";

                        mfTransactionVo.BuySell = "B";

                        if (customerTransactionBo.AddMFTransaction(mfTransactionVo, customerVo.UserId) != 0)
                        {
                            customerPortfolioBo.UpdateAdviserDailyEODLogRevaluateForTransaction(advisorVo.advisorId, "MF", mfTransactionVo.TransactionDate);
                        }
                    }
                    if (ddlTransactionType.SelectedItem.Value == "SIP")
                    {
                        //mfTransactionVo.DividendRate = float.Parse(txtDividentRate.Text.ToString());
                        mfTransactionVo.NAV    = float.Parse(txtNAV.Text.ToString());
                        mfTransactionVo.Price  = float.Parse(txtPrice.Text.ToString());
                        mfTransactionVo.Amount = float.Parse(txtAmount.Text.ToString());
                        mfTransactionVo.Units  = float.Parse(txtUnits.Text.ToString());
                        mfTransactionVo.TransactionClassificationCode = "SIP";
                        mfTransactionVo.BuySell = "B";

                        if (customerTransactionBo.AddMFTransaction(mfTransactionVo, customerVo.UserId) != 0)
                        {
                            customerPortfolioBo.UpdateAdviserDailyEODLogRevaluateForTransaction(advisorVo.advisorId, "MF", mfTransactionVo.TransactionDate);
                        }
                    }
                    if (ddlTransactionType.SelectedItem.Value == "SWP")
                    {
                        //mfTransactionVo.DividendRate = float.Parse(txtDividentRate.Text.ToString());
                        mfTransactionVo.NAV    = float.Parse(txtNAV.Text.ToString());
                        mfTransactionVo.Price  = float.Parse(txtPrice.Text.ToString());
                        mfTransactionVo.Amount = float.Parse(txtAmount.Text.ToString());
                        mfTransactionVo.Units  = float.Parse(txtUnits.Text.ToString());
                        mfTransactionVo.STT    = float.Parse(txtSTT.Text.ToString());
                        mfTransactionVo.TransactionClassificationCode = "SWP";
                        mfTransactionVo.BuySell = "S";

                        if (customerTransactionBo.AddMFTransaction(mfTransactionVo, customerVo.UserId) != 0)
                        {
                            customerPortfolioBo.UpdateAdviserDailyEODLogRevaluateForTransaction(advisorVo.advisorId, "MF", mfTransactionVo.TransactionDate);
                        }
                    }
                    if (ddlTransactionType.SelectedItem.Value == "STP")
                    {
                        mfTransactionVo.NAV    = float.Parse(txtNAV.Text.ToString());
                        mfTransactionVo.Price  = float.Parse(txtPrice.Text.ToString());
                        mfTransactionVo.Amount = float.Parse(txtAmount.Text.ToString());
                        mfTransactionVo.Units  = float.Parse(txtUnits.Text.ToString());
                        mfTransactionVo.STT    = float.Parse(txtSTT.Text.ToString());
                        mfTransactionVo.TransactionClassificationCode = "STS";
                        mfTransactionVo.BuySell = "S";

                        if ((transactionId = customerTransactionBo.AddMFTransaction(mfTransactionVo, customerVo.UserId)) != 0)
                        {
                            customerPortfolioBo.UpdateAdviserDailyEODLogRevaluateForTransaction(advisorVo.advisorId, "MF", mfTransactionVo.TransactionDate);
                        }

                        mfTransactionVo.MFCode = int.Parse(txtSwitchSchemeCode.Value);
                        mfTransactionVo.NAV    = float.Parse(txtNAVPurchased.Text.ToString());
                        mfTransactionVo.Price  = float.Parse(txtPricePurchased.Text.ToString());
                        mfTransactionVo.Amount = float.Parse(txtAmtPurchased.Text.ToString());
                        mfTransactionVo.Units  = float.Parse(txtUnitsAlloted.Text.ToString());
                        mfTransactionVo.TransactionClassificationCode = "STB";
                        mfTransactionVo.SwitchSourceTrxId             = transactionId;
                        //mfTransactionVo.TransactionId = customerBo.GenerateId();
                        mfTransactionVo.BuySell = "B";

                        if (customerTransactionBo.AddMFTransaction(mfTransactionVo, customerVo.UserId) != 0)
                        {
                            customerPortfolioBo.UpdateAdviserDailyEODLogRevaluateForTransaction(advisorVo.advisorId, "MF", mfTransactionVo.TransactionDate);
                        }
                    }
                    if (ddlTransactionType.SelectedItem.Value == "Dividend Payout")
                    {
                        if (txtDividentRate.Text != string.Empty || txtDividentRate.Text != "")
                        {
                            mfTransactionVo.DividendRate = float.Parse(txtDividentRate.Text.ToString());
                        }
                        mfTransactionVo.NAV = float.Parse(txtNAV.Text.ToString());
                        //mfTransactionVo.Price = float.Parse(txtPrice.Text.ToString());
                        mfTransactionVo.Price  = 0;
                        mfTransactionVo.Amount = float.Parse(txtAmount.Text.ToString());
                        mfTransactionVo.TransactionClassificationCode = "DVP";
                        mfTransactionVo.BuySell = "S";

                        if (customerTransactionBo.AddMFTransaction(mfTransactionVo, customerVo.UserId) != 0)
                        {
                            customerPortfolioBo.UpdateAdviserDailyEODLogRevaluateForTransaction(advisorVo.advisorId, "MF", mfTransactionVo.TransactionDate);
                        }
                    }
                    if (ddlTransactionType.SelectedItem.Value == "Switch")
                    {
                        mfTransactionVo.NAV    = float.Parse(txtNAV.Text.ToString());
                        mfTransactionVo.Price  = float.Parse(txtPrice.Text.ToString());
                        mfTransactionVo.Amount = float.Parse(txtAmount.Text.ToString());
                        mfTransactionVo.Units  = float.Parse(txtUnits.Text.ToString());
                        mfTransactionVo.STT    = float.Parse(txtSTT.Text.ToString());
                        mfTransactionVo.TransactionClassificationCode = "SWS";
                        mfTransactionVo.BuySell = "S";

                        if ((transactionId = customerTransactionBo.AddMFTransaction(mfTransactionVo, customerVo.UserId)) != 0)
                        {
                            customerPortfolioBo.UpdateAdviserDailyEODLogRevaluateForTransaction(advisorVo.advisorId, "MF", mfTransactionVo.TransactionDate);
                        }

                        //  transactionId = customerTransactionBo.AddMFTransaction(mfTransactionVo, customerVo.UserId);

                        mfTransactionVo.MFCode = int.Parse(txtSwitchSchemeCode.Value);
                        mfTransactionVo.NAV    = float.Parse(txtNAVPurchased.Text.ToString());
                        mfTransactionVo.Price  = float.Parse(txtPricePurchased.Text.ToString());
                        mfTransactionVo.Amount = float.Parse(txtAmtPurchased.Text.ToString());
                        mfTransactionVo.Units  = float.Parse(txtUnitsAlloted.Text.ToString());
                        mfTransactionVo.TransactionClassificationCode = "SWB";
                        mfTransactionVo.SwitchSourceTrxId             = transactionId;
                        //mfTransactionVo.TransactionId = customerBo.GenerateId();
                        mfTransactionVo.BuySell = "B";
                        if (customerTransactionBo.AddMFTransaction(mfTransactionVo, customerVo.UserId) != 0)
                        {
                            customerPortfolioBo.UpdateAdviserDailyEODLogRevaluateForTransaction(advisorVo.advisorId, "MF", mfTransactionVo.TransactionDate);
                        }
                    }
                    List <MFPortfolioVo>          mfPortfolioVoList = new List <MFPortfolioVo>();
                    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["MFDate"].ToString());
                    }
                    if (tradeDate == DateTime.MinValue)
                    {
                        tradeDate = DateTime.Today;
                    }
                    mfPortfolioVoList = customerPortfolioBo.GetCustomerMFPortfolio(customerVo.CustomerId, portfolioId, tradeDate, lblScheme.Text, ddlFolioNum.SelectedItem.Text, "");
                    if (mfPortfolioVoList != null && mfPortfolioVoList.Count > 0)
                    {
                        customerPortfolioBo.DeleteMutualFundNetPosition(mfPortfolioVoList[0].MFCode, mfPortfolioVoList[0].AccountId, tradeDate);
                        customerPortfolioBo.AddMutualFundNetPosition(mfPortfolioVoList[0], userVo.UserId);
                    }

                    //ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "leftpane", "loadcontrol('TransactionsView','none');", true);

                    //Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "leftpane", "loadcontrol('TransactionsView','none');", true);
                    msgRecordStatus.Visible = true;
                    cleanAllFields();



                    //Response.Redirect("ControlHost.aspx?pageid=TransactionsView", false);
                }
                else
                {
                    //msgRecordStatus.InnerText = "Adding records is not successfull";
                    //msgRecordStatus.Style.Add("background", "Red");
                    RequiredFieldValidator3.ErrorMessage = "Please Select Proper Scheme Name";
                    RequiredFieldValidator3.IsValid      = false;
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }

            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "MFManualSingleTran.ascx:btnSubmit_Click()");
                object[] objects = new object[2];
                objects[0]   = mfTransactionVo;
                objects[1]   = customerVo;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
コード例 #2
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;
            }
        }
コード例 #3
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);
            }
        }
コード例 #4
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);
        }