public bool ValidateSession() { LoginController objLoginController = new LoginController(); try { if (Session["LoggedInUser"] != null) { return(true); } else { return(false); } } catch (Exception ex) { UserMaster objUserMaster = new UserMaster(); objUserMaster = (UserMaster)Session["LoggedInUser"]; objLoginController.LogError(ex.Message, ex.StackTrace, "BlackscholesPricersController", "ValidateSession", objUserMaster.UserID); return(false); } }
public bool ValidateSession() { LoginController objLoginController = new LoginController(); try { if (Session["LoggedInUser"] != null) { return(true); } else { return(false); } } catch (Exception ex) { UserMaster objUserMaster = new UserMaster(); objUserMaster = (UserMaster)Session["LoggedInUser"]; objLoginController.LogError(ex.Message, ex.StackTrace, "MonitoringScreenController", "ValidateSession", -1); return(false); } }
public ActionResult ProductParameters(ProductParameter objProductParameter, string Command, FormCollection collection, HttpPostedFileBase file) { LoginController objLoginController = new LoginController(); List <UploadFileMaster> UploadFileMasterList = (List <UploadFileMaster>)Session["UploadFileMasterList"]; try { if (ValidateSession()) { return(View()); } else { return(RedirectToAction("Login", "Login")); } } catch (Exception ex) { UserMaster objUserMaster = new UserMaster(); objUserMaster = (UserMaster)Session["LoggedInUser"]; LogError(ex.Message, ex.StackTrace, "UnderlyingCreationController", "ProductParameters Post", objUserMaster.UserID); return(RedirectToAction("ErrorPage", "Login")); } }
public ActionResult ProductParameters(int?underlyingID) { LoginController objLoginController = new LoginController(); ProductParameter objProductParameter = new ProductParameter(); try { if (ValidateSession()) { ObjectResult <ProductParameterResult> objProductParameterResult = objSP_PRICINGEntities.FETCH_PRODUCT_PARAMETERS_DETAILS(Convert.ToInt32(underlyingID), -1, -1, 0); List <ProductParameterResult> ProductParameterResultList = objProductParameterResult.ToList(); if (ProductParameterResultList != null && ProductParameterResultList.Count == 1) { objProductParameter.ID = ProductParameterResultList[0].ID; objProductParameter.UnderlyingID = ProductParameterResultList[0].UnderlyingID; objProductParameter.IV = ProductParameterResultList[0].IV; objProductParameter.RFR = ProductParameterResultList[0].RFR; objProductParameter.BuiltInAdjustment = ProductParameterResultList[0].BuiltInAdjustment; } return(View(objProductParameter)); } else { return(RedirectToAction("Login", "Login")); } } catch (Exception ex) { UserMaster objUserMaster = new UserMaster(); objUserMaster = (UserMaster)Session["LoggedInUser"]; LogError(ex.Message, ex.StackTrace, "UnderlyingCreationController", "ProductParameters Get", objUserMaster.UserID); return(RedirectToAction("ErrorPage", "Login")); } }
public ActionResult PricingDeployment(PricingDeployment objPricingDeployment, string Command, FormCollection collection, HttpPostedFileBase file, HttpPostedFileBase file1) { LoginController objLoginController = new LoginController(); List <UploadFileMaster> UploadFileMasterList = (List <UploadFileMaster>)Session["UploadFileMasterList"]; string strEntityID = collection["EntityID"]; string strIsSecuredID = collection["IsSecuredID"]; Int32 intEntityID = Convert.ToInt32(strEntityID.Split(',')[0]); Int32 intIsSecuredID = Convert.ToInt32(strIsSecuredID.Split(',')[0]); try { if (ValidateSession()) { bool blnUploadStatus = false; bool blnUploadDataStatus = true; #region Price Deployment if (Command == "PDUpload") { if (file != null && file.ContentLength > 0) { UploadFileMaster objUploadFileMaster = UploadFileMasterList.Find(delegate(UploadFileMaster oUploadFileMaster) { return(oUploadFileMaster.UploadTypeCode == "PDR"); }); string strFilePath = System.Web.HttpContext.Current.Server.MapPath("~/Uploads/"); string strFileName = Path.GetFileNameWithoutExtension(file.FileName) + DateTime.Now.ToString("dd_mmm_yyyy_hh_mm"); string strExtension = Path.GetExtension(file.FileName); strFilePath += strFileName + strExtension; file.SaveAs(strFilePath); FileInfo newFile = new FileInfo(strFilePath); string strSourceColumn = objUploadFileMaster.SourceColumn; string[] arrSourceColumn = null; if (strSourceColumn != "") { arrSourceColumn = strSourceColumn.Split('|'); } DataTable dtData = new DataTable(); for (int i = 0; i < arrSourceColumn.Length; i++) { dtData.Columns.Add(arrSourceColumn[i]); } string strDestinationColumn = objUploadFileMaster.DestinationColumn; string[] arrDestinationColumn = null; if (strDestinationColumn != "") { arrDestinationColumn = strDestinationColumn.Split('|'); } string strTableName = objUploadFileMaster.TableName; using (ExcelPackage xlPackage = new ExcelPackage(newFile)) { ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets[objUploadFileMaster.SheetName]; string strVersion = worksheet.Cell(1, 2).Value.Trim(); if (strVersion == "") { strVersion = "0"; } DataRow drNew; for (int iRow = 4; iRow < 36; iRow++) { if (Convert.ToString(worksheet.Cell(iRow, 1).Value) != "") { drNew = dtData.NewRow(); var Days = worksheet.Cell(iRow, 1).Value.Split('-'); var MinDays = Days[0].Trim(); var MaxDays = Days[1].Trim(); drNew["VERSION"] = strVersion; drNew["ENTITY_ID"] = intEntityID; drNew["IS_SECURED_ID"] = intIsSecuredID; drNew["MIN_DAYS"] = MinDays;//worksheet.Cell(iRow, 1).Value; drNew["MAX_DAYS"] = MaxDays; drNew["DEPLOYMENT_RATE"] = worksheet.Cell(iRow, 2).Value; drNew["CREATED_DATE"] = DateTime.Now; drNew["CREATED_BY"] = 1; dtData.Rows.Add(drNew); } else { break; } } } string strMyConnection = Convert.ToString(System.Configuration.ConfigurationManager.ConnectionStrings["SP_PRICINGConnectionString"]); if (arrSourceColumn != null && arrDestinationColumn != null && arrSourceColumn.Length == arrDestinationColumn.Length) { using (SqlBulkCopy bulkCopy = new SqlBulkCopy(strMyConnection)) { bulkCopy.DestinationTableName = strTableName; for (int i = 0; i < arrSourceColumn.Length; i++) { bulkCopy.ColumnMappings.Add(arrSourceColumn[i], arrDestinationColumn[i]); } bulkCopy.WriteToServer(dtData); } blnUploadStatus = true; DataSet dsIV = new DataSet(); dsIV = General.ExecuteDataSet(objUploadFileMaster.ExtraProcedure); } else { blnUploadStatus = false; } if (blnUploadStatus) { ManageUploadFileInfo(0, file.FileName, strFilePath, blnUploadStatus, blnUploadDataStatus); ViewBag.Message = "Imported successfully"; } return(View(objPricingDeployment)); } } #endregion #region Actual Deployment else if (Command == "ADUpload") { if (file1 != null && file1.ContentLength > 0) { UploadFileMaster objUploadFileMaster = UploadFileMasterList.Find(delegate(UploadFileMaster oUploadFileMaster) { return(oUploadFileMaster.UploadTypeCode == "ADR"); }); string strFilePath = System.Web.HttpContext.Current.Server.MapPath("~/Uploads/"); string strFileName = Path.GetFileNameWithoutExtension(file1.FileName) + DateTime.Now.ToString("dd_mmm_yyyy_hh_mm"); string strExtension = Path.GetExtension(file1.FileName); strFilePath += strFileName + strExtension; file1.SaveAs(strFilePath); FileInfo newFile = new FileInfo(strFilePath); string strSourceColumn = objUploadFileMaster.SourceColumn; string[] arrSourceColumn = null; if (strSourceColumn != "") { arrSourceColumn = strSourceColumn.Split('|'); } DataTable dtData = new DataTable(); for (int i = 0; i < arrSourceColumn.Length; i++) { dtData.Columns.Add(arrSourceColumn[i]); } string strDestinationColumn = objUploadFileMaster.DestinationColumn; string[] arrDestinationColumn = null; if (strDestinationColumn != "") { arrDestinationColumn = strDestinationColumn.Split('|'); } string strTableName = objUploadFileMaster.TableName; using (ExcelPackage xlPackage = new ExcelPackage(newFile)) { ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets[objUploadFileMaster.SheetName]; string strVersion = worksheet.Cell(1, 2).Value.Trim(); if (strVersion == "") { strVersion = "0"; } DataRow drNew; for (int iRow = 4; iRow < 100; iRow++) { if (Convert.ToString(worksheet.Cell(iRow, 1).Value) != "") { drNew = dtData.NewRow(); var Days = worksheet.Cell(iRow, 1).Value.Split(' '); var MinDays = Days[0].Trim(); var MaxDays = Days[2].Trim(); drNew["VERSION"] = strVersion; drNew["MIN_DAYS"] = MinDays;//worksheet.Cell(iRow, 1).Value; drNew["MAX_DAYS"] = MaxDays; drNew["DEPLOYMENT_RATE"] = worksheet.Cell(iRow, 2).Value; drNew["CREATED_DATE"] = DateTime.Now; drNew["CREATED_BY"] = 1; dtData.Rows.Add(drNew); } else { break; } } } string strMyConnection = Convert.ToString(System.Configuration.ConfigurationManager.ConnectionStrings["SP_PRICINGConnectionString"]); if (arrSourceColumn != null && arrDestinationColumn != null && arrSourceColumn.Length == arrDestinationColumn.Length) { using (SqlBulkCopy bulkCopy = new SqlBulkCopy(strMyConnection)) { bulkCopy.DestinationTableName = strTableName; for (int i = 0; i < arrSourceColumn.Length; i++) { bulkCopy.ColumnMappings.Add(arrSourceColumn[i], arrDestinationColumn[i]); } bulkCopy.WriteToServer(dtData); } blnUploadStatus = true; DataSet dsIV = new DataSet(); dsIV = General.ExecuteDataSet(objUploadFileMaster.ExtraProcedure); } else { blnUploadStatus = false; } if (blnUploadStatus) { ManageUploadFileInfo(0, file1.FileName, strFilePath, blnUploadStatus, blnUploadDataStatus); ViewBag.Message = "Imported successfully"; } return(View(objPricingDeployment)); } } #endregion #region Pricing Deployment Download else if (Command == "PDDownload") { UploadFileMaster objUploadFileMaster = UploadFileMasterList.Find(delegate(UploadFileMaster oUploadFileMaster) { return(oUploadFileMaster.UploadTypeCode == "PDR"); }); string strFilePath = System.Web.HttpContext.Current.Server.MapPath(objUploadFileMaster.TemplateFileName); if (System.IO.File.Exists(strFilePath)) { FileInfo fileinfo = new FileInfo(strFilePath); Response.Clear(); Response.ClearHeaders(); Response.ClearContent(); Response.AddHeader("content-disposition", "attachment; filename=" + Path.GetFileName(strFilePath)); Response.AddHeader("Content-Type", "application/Excel"); Response.ContentType = "application/vnd.xls"; Response.AddHeader("Content-Length", fileinfo.Length.ToString()); Response.WriteFile(fileinfo.FullName); Response.End(); } return(View(objPricingDeployment)); } #endregion return(View()); } else { return(RedirectToAction("Login", "Login")); } } catch (Exception ex) { UserMaster objUserMaster = new UserMaster(); objUserMaster = (UserMaster)Session["LoggedInUser"]; LogError(ex.Message, ex.StackTrace, "UnderlyingCreationController", "PricingDeployment Post", objUserMaster.UserID); return(RedirectToAction("ErrorPage", "Login")); } }
public ActionResult LineOfQuoteMaster() { LoginController objLoginController = new LoginController(); try { if (ValidateSession()) { LineOfQuoteModel objLineOfQuoteModel = new LineOfQuoteModel(); #region Menu Access By on Role Int32 intResult = 0; // bool PPorNonPP = false; UserMaster objUserMaster = new UserMaster(); objUserMaster = (UserMaster)Session["LoggedInUser"]; var Result = objSP_PRICINGEntities.VALIDATE_MENU_BY_ROLE(objUserMaster.RoleID, "LOQM"); intResult = Convert.ToInt32(Result.SingleOrDefault()); if (intResult == 0) { return(RedirectToAction("UserNotAuthorize", "Login")); } #endregion #region Product Type List List <QuotronQuoteRequest> OptionTypeList = new List <QuotronQuoteRequest>(); ObjectResult <OptionTypeResult> objOptionTypeResult; List <OptionTypeResult> OptionTypeResultList = new List <OptionTypeResult>(); objOptionTypeResult = objSP_PRICINGEntities.SP_FETCH_OPTION_TYPES(); OptionTypeResultList = objOptionTypeResult.ToList(); foreach (OptionTypeResult oOptionTypeListResult in OptionTypeResultList) { QuotronQuoteRequest objOptionType = new QuotronQuoteRequest(); General.ReflectSingleData(objOptionType, oOptionTypeListResult); OptionTypeList.Add(objOptionType); } objLineOfQuoteModel.OptionTypeList = OptionTypeList; #endregion return(View(objLineOfQuoteModel)); } else { return(RedirectToAction("Login", "Login")); } } catch (Exception ex) { UserMaster objUserMaster = new UserMaster(); objUserMaster = (UserMaster)Session["LoggedInUser"]; LogError(ex.Message, ex.StackTrace, "MasterController", "LineOfQuoteMaster Get", objUserMaster.UserID); return(RedirectToAction("ErrorPage", "Login")); } }
public ActionResult Index(DashboardModel objDashboardModel) { LoginController objLoginController = new LoginController(); try { if (ValidateSession()) { #region Menu Access By on Role Int32 intResult = 0; // bool PPorNonPP = false; UserMaster objUserMaster = new UserMaster(); objUserMaster = (UserMaster)Session["LoggedInUser"]; var Result = objSP_PRICINGEntities.VALIDATE_MENU_BY_ROLE(objUserMaster.RoleID, "DI"); intResult = Convert.ToInt32(Result.SingleOrDefault()); if (intResult == 0) { return(RedirectToAction("UserNotAuthorize", "Login")); } #endregion objDashboardModel.IsPricerCountChart = true; objDashboardModel.IsPricerBarChart = true; #region Pie Chart For Blacksholes Pricers ObjectResult <PricerCountPieResult> objPricerCountPieResult = objSP_PRICINGEntities.FETCH_PRICE_COUNT_PIE_CHART(); List <PricerCountPieResult> PricerCountPieResultList = objPricerCountPieResult.ToList(); List <KeyValuePair <string, string> > pricerCounts = new List <KeyValuePair <string, string> >(); foreach (var a in PricerCountPieResultList) { pricerCounts.Add(new KeyValuePair <string, string>(a.PricerType.ToString(), a.Count.ToString())); } List <object> ChartValues1 = new List <object>(); foreach (var item in pricerCounts) { ChartValues1.Add(new object[] { item.Key, item.Value }); } //instanciate an object of the Highcharts type Highcharts pricerChart = new Highcharts("pricer") //define the type of chart .InitChart(new Chart { DefaultSeriesType = ChartTypes.Pie, PlotShadow = false }) //overall Title of the chart .SetTitle(new Title { Text = "Blackscholes Pricers " }) //small label below the main Title .SetSubtitle(new Subtitle { Text = "Count" }) .SetTooltip(new Tooltip { PointFormat = "{series.name}: <b>{point.percentage:.1f}%</b>", Enabled = true //Formatter = @"function() { return '<b>'+ this.series.name +'</b><br/>'+ this.x +': '+ this.y; }" }) .SetPlotOptions(new PlotOptions { Pie = new PlotOptionsPie { AllowPointSelect = true, DataLabels = new PlotOptionsPieDataLabels { Enabled = true }, EnableMouseTracking = true, //ShowInLegend = true } }) .SetSeries(new Series { //Type = ChartTypes.Line, Name = "Count", Data = new Data(ChartValues1.ToArray()) }); objDashboardModel.PricerCountChart = pricerChart; #endregion #region Pie Chart For Blacksholes Pricers DataSet dsResult = new DataSet(); dsResult = General.ExecuteDataSet("PRICER_STATUS_FOR_BAR_CHART"); //dsResult.DataSetName = "Test1"; List <KeyValuePair <string, string> > pricerCounts1 = new List <KeyValuePair <string, string> >(); for (int i = 0; i < dsResult.Tables[0].Rows.Count; i++) { pricerCounts1.Add(new KeyValuePair <string, string>(dsResult.Tables[0].Rows[i]["STATUS"].ToString(), dsResult.Tables[0].Rows[i]["COUNT"].ToString())); } List <object> Pending = new List <object>(); List <object> Confirmed = new List <object>(); List <object> Expired = new List <object>(); List <object> Cancel = new List <object>(); foreach (var item in pricerCounts1) { if (item.Key == "Pending For Approval") { Pending.Add(new object[] { item.Value }); } if (item.Key == "Confirmed") { Confirmed.Add(new object[] { item.Value }); } if (item.Key == "Cancelled") { Cancel.Add(new object[] { item.Value }); } if (item.Key == "Expired") { Expired.Add(new object[] { item.Value }); } } var transactionCounts = new List <Graph>(); if (dsResult != null && dsResult.Tables.Count > 0 && dsResult.Tables[1].Rows.Count > 0) { foreach (DataRow dr in dsResult.Tables[1].Rows) { transactionCounts.Add(new Graph() { PricerType = Convert.ToString(dr["PRICERTYPE"]) }); } } var xPricer = transactionCounts.Select(i => i.PricerType).ToArray(); //instanciate an object of the Highcharts type Highcharts BarChart = new Highcharts("pricerbar") //define the type of chart .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column }) //overall Title of the chart .SetTitle(new Title { Text = "Blackscholes Pricers " }) //small label below the main Title .SetSubtitle(new Subtitle { Text = "Count" }) .SetXAxis(new XAxis { Title = new XAxisTitle { Text = "Pricer Types" }, Categories = xPricer }) //.SetTooltip(new Tooltip //{ // HeaderFormat = "<span style=font-size:11px>{series.name}</span><br>", // ////PointFormat = "<span style=color:{point.color}>{point.name}</span>: <b>{point.y:.2f}</b> of total<br/>", // //PointFormat = "{series.name}: <b>{point.percentage:.1f}%</b>", // Enabled = true //}) .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { AllowPointSelect = true, DataLabels = new PlotOptionsColumnDataLabels { Enabled = false } // EnableMouseTracking = false, } }) .SetSeries(new[] { new Series { Name = "Pending For Approval", Color = System.Drawing.Color.Orange, Data = new Data(Pending.ToArray()) }, //you can add more y data to create a second line new Series { Name = "Confirmed", Color = System.Drawing.Color.Green, Data = new Data(Confirmed.ToArray()) }, new Series { Name = "Cancelled", Color = System.Drawing.Color.Red, Data = new Data(Cancel.ToArray()) }, new Series { Name = "Expired", Data = new Data(Expired.ToArray()) } }); objDashboardModel.PricerBarChart = BarChart; #endregion #region Fetch UnderlyingList List <Underlying> UnderlyingList = new List <Underlying>(); DataSet dsResult2 = new DataSet(); dsResult2 = General.ExecuteDataSet("FETCH_UNDERLYING_CREATION_TICKER"); if (dsResult2 != null && dsResult2.Tables.Count > 0 && dsResult2.Tables[0].Rows.Count > 0) { foreach (DataRow dr in dsResult2.Tables[0].Rows) { Underlying obj = new Underlying(); obj.UnderlyingName = Convert.ToString(dr["UnderlyingName"]); obj.UnderlyingType = Convert.ToString(dr["UnderlyingType"]); obj.PriceDiff = Convert.ToString(dr["PriceDiff"]); obj.PriceDiffInPercentage = Convert.ToString(dr["PriceDiffInPercentage"]); obj.NewDate = Convert.ToString(dr["NewDate"]); obj.NewPrice = Convert.ToString(dr["NewPrice"]); UnderlyingList.Add(obj); } } objDashboardModel.UnderlyingList = UnderlyingList; #endregion return(View(objDashboardModel)); } else { return(RedirectToAction("Login", "Login")); } } catch (Exception ex) { UserMaster objUserMaster = new UserMaster(); objUserMaster = (UserMaster)Session["LoggedInUser"]; LogError(ex.Message, ex.StackTrace, "BlackscholesPricersController", "Dashboard Index Get", objUserMaster.UserID); return(RedirectToAction("ErrorPage", "Login")); } }