public List <CurveEntity> GetAllCurves() { List <CurveEntity> results = new List <CurveEntity>(); string selectAllQuery = " SELECT CurveId, CurveName, DataChange_CreateTime, DataChange_LastTime FROM curve "; // open connection if (this.OpenConnection() == true) { MySqlCommand mysqlCmd = new MySqlCommand(selectAllQuery, connection); MySqlDataReader dataReader = mysqlCmd.ExecuteReader(); while (dataReader.Read()) { CurveEntity curveItem = new CurveEntity() { CurveId = dataReader.GetInt64(0), CurveName = dataReader.GetString(1), DataChange_CreateTime = dataReader.GetDateTime(2), DataChange_LastTime = dataReader.GetDateTime(3) }; results.Add(curveItem); } // close connection this.CloseConnection(); } return(results); }
public CurveEntity GetCurveByName(string curveName) { CurveEntity result = null; if (String.IsNullOrWhiteSpace(curveName)) { return(result); } StringBuilder buildSQL = new StringBuilder(200); buildSQL.Append(" SELECT CurveId, CurveName, DataChange_CreateTime, DataChange_LastTime FROM curve WHERE 1=1 "); buildSQL.AppendFormat(" AND CurveName = '{0}' ", curveName); // open connection if (this.OpenConnection() == true) { MySqlCommand mysqlCmd = new MySqlCommand(buildSQL.ToString(), connection); MySqlDataReader dataReader = mysqlCmd.ExecuteReader(); while (dataReader.Read()) { result = new CurveEntity() { CurveId = dataReader.GetInt64(0), CurveName = dataReader.GetString(1), DataChange_CreateTime = dataReader.GetDateTime(2), DataChange_LastTime = dataReader.GetDateTime(3) }; } // close connection this.CloseConnection(); } return(result); }
public void Update(CurveEntity curveData) { if (curveData == null) { LogHelper.Warn(typeof(CurveDaoMySQLImpl), "Empty update operation"); } StringBuilder buildSQL = new StringBuilder(200); buildSQL.Append(" UPDATE curve "); buildSQL.AppendFormat(" SET CurveName='{0}' ", curveData.CurveName); buildSQL.AppendFormat(" WHERE CurveId = {0} ", curveData.CurveId); // open connection if (this.OpenConnection() == true) { MySqlCommand mysqlCmd = new MySqlCommand() { CommandText = buildSQL.ToString(), Connection = connection }; mysqlCmd.ExecuteNonQuery(); // close connection this.CloseConnection(); } }
/// <summary> /// 获取收率曲线中各个ECP对应的TWY的值 /// </summary> /// <param name="itemCode"></param> /// <returns></returns> public static Dictionary <float, float> getECP_TWYDatasfromYIELD(OilInfoBEntity oilInfoB) //ECP-TWY { Dictionary <float, float> ECP_TWYDIC = new Dictionary <float, float>(); //存储终切点数据。 #region "ECP-TWY判断" CurveEntity ECP_TWYCurve = oilInfoB.curves.Where(o => o.propertyX == "ECP" && o.propertyY == "TWY").FirstOrDefault(); if (ECP_TWYCurve == null) { //MessageBox.Show(this._oilB.crudeName + "的收率曲线不存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return(ECP_TWYDIC); } if (ECP_TWYCurve.curveDatas.Count <= 0) { //MessageBox.Show(this._oilB.crudeName + "的收率曲线数据不存在!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return(ECP_TWYDIC); } #endregion var ECP_TWYDatas = ECP_TWYCurve.curveDatas.OrderBy(o => o.xValue);//升序 List <CurveDataEntity> ECP_TWYCurveDatas = ECP_TWYDatas.ToList(); #region "存储终切点数据" for (int index = 0; index < ECP_TWYCurveDatas.Count; index++) { if (!ECP_TWYDIC.Keys.Contains(ECP_TWYCurveDatas[index].xValue)) { ECP_TWYDIC.Add(ECP_TWYCurveDatas[index].xValue, ECP_TWYCurveDatas[index].yValue);//ECP-TWY } } #endregion return(ECP_TWYDIC); }
public void DoFitCalculation(string stockName, string fitMethod) { CurveEntity curveInfo = this._iCurveDao.GetCurveByName(stockName); if (curveInfo == null) { LogHelper.Warn(typeof(ValueComplementBusinessImpl), "Cannot find certain stock information"); return; } List <CurveDataEntity> curveDataList = this._iCurveDataDao.GetCurveDataByCurveId(curveInfo.CurveId); if (ListHelper.IsNullOrEmpty(curveDataList)) { LogHelper.Warn(typeof(ValueComplementBusinessImpl), "Stock " + curveInfo.CurveName + " doesnot have any data"); return; } int missIdx = FindMissingValueIdx(curveDataList); CurveDataEntity missingCurveDataEntity = curveDataList[missIdx]; List <PointDto> modelPoints = ConvertValueItemsToPoints(curveDataList); if (missIdx != -1 && !ListHelper.IsNullOrEmpty(modelPoints)) { IFitStrategy fitStrategy = StrategyFactory.GetStrategyByName(fitMethod); PointDto fitResultPoint = fitStrategy.FitCalculation(modelPoints, missIdx); missingCurveDataEntity.Value = System.Convert.ToDecimal(fitResultPoint.Y); //更新至db this._iCurveDataDao.Update(missingCurveDataEntity); } }
/// <summary> /// 够造函数 /// </summary> /// <param name="_curve">一条性质曲线</param> public FrmCurveB(CurveEntity curve) { InitializeComponent(); this.zedGraphControl1.ZedExpand.ZoomChoose = false; // 放大为false this.zedGraphControl1.ZedExpand.IsMoving = true; //移动为true this.zedGraphControl1.ZedExpand.IsopenB = true; //打开B库 init(curve); //初始化函数 }
/// <summary> /// 够造函数 /// </summary> /// <param name="_curve">一条性质曲线</param> public FrmCurve(CurveEntity curve) { InitializeComponent(); this._curve = curve; this.propertyGraph1.DrawCurve(this._curve); RIPP.OilDB.UI.GridOil.myStyle.setToolStripStyle(this.toolStrip); InitStyle(); _setColHeader(); _setCellValues(); }
/// <summary> /// 选择曲线下拉列表 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmbCurve_SelectedIndexChanged(object sender, EventArgs e) { if (this.cmbType.SelectedValue == null || this.cmbCurve.SelectedValue == null) { this._curve = null; } else { int curveTypeID = Convert.ToInt32(this.cmbType.SelectedValue.ToString()); int curveID = Convert.ToInt32(this.cmbCurve.SelectedValue.ToString()); this._curve = _oilB.curves.Where(o => o.ID == curveID && o.curveTypeID == curveTypeID).FirstOrDefault(); } this.propertyGraph1.DrawCurve(this._curve); }
/// <summary> /// 根据曲线类别初始化 /// </summary> /// <param name="typeCode"></param> public void init(CurveEntity curve) { this._curve = curve; //获得一条曲线 //initTable(); InitStyle(); //表格样式 _setColHeader(); //表格表头 _setRowValues(); //设置行的头和值 RIPP.OilDB.UI.GridOil.myStyle.setToolStripStyle(this.toolStrip); drawCurve(); //画出曲线 this.dataGridView.CellEndEdit += new DataGridViewCellEventHandler(dataGridView_CellEndEdit); //单元格编辑结束事件 //this.zedGraph1.MouseDown += new MouseEventHandler(zedGraph1_MouseDown); this.zedGraphControl1.MouseMove += new MouseEventHandler(zedGraphControl1_MouseMove); //鼠标移动绑定事件 this.zedGraphControl1.MouseClick += new MouseEventHandler(zedGraphControl1_MouseClick); //鼠标单击绑定事件 }
/// <summary> /// 绘制一条性质曲线 /// </summary> /// <param name="curve">一条性质曲线</param> public void DrawCurve(CurveEntity curve = null) { this._curve = curve; if (curve == null) { this.zedGraph1.GraphPane.CurveList.Clear(); this.setTitle(); this.zedGraph1.AxisChange(); this.zedGraph1.Refresh(); } else { //this._curve = curve; if (this._curve.X == null) { this.zedGraph1.GraphPane.CurveList.Clear(); this.setTitle(); this.zedGraph1.AxisChange(); this.zedGraph1.Refresh(); } //去掉Y值为Float.MaxValue的点 PointPairList list = new PointPairList(); for (int i = 0; i < _curve.Y.Count(); i++) { if (float.MaxValue != _curve.Y[i]) { list.Add(_curve.X[i], _curve.Y[i]); } } //this.zedGraph1.GraphPane.AddCurve(this._curve.descript, this._curve.X.ToArray(), this._curve.Y.ToArray(), this._curve.Color, SymbolType.None); this.zedGraph1.GraphPane.CurveList.Clear(); this.zedGraph1.GraphPane.AddCurve(this._curve.descript, list, this._curve.Color, SymbolType.None); this.setTitle(); this.zedGraph1.AxisChange(); this.zedGraph1.Refresh(); } }
public FrmCurveB(CurveEntity curve) : base(curve) { InitializeComponent(); }
/// <summary> /// GC计算 /// </summary> /// <param name="GCLevelDataList">GC标准表的数据集合</param> /// <param name="ECP_TWYCurve">已经存在的ECP—TWY绘图曲线</param> /// <param name="B_X">馏分曲线中的已知的18个点数据集合</param> /// <param name="itemCode">判断哪个物性进行GC内插计算</param> /// <returns>表格中需要填充的数据,和B_X数据对应</returns> public static Dictionary <float, float> getGCInterpolationDIC(List <OilDataEntity> GCLevelDataList, CurveEntity ECP_TWYCurve, List <float> B_X, string itemCode) { Dictionary <float, float> DIC = new Dictionary <float, float>();//GC字典 #region "输入处理" if (GCLevelDataList.Count <= 0) { return(DIC); } if (ECP_TWYCurve == null) { return(DIC); } if (ECP_TWYCurve.curveDatas.Count <= 0) { return(DIC); } if (B_X.Count <= 0) { return(DIC); } OilDataEntity ICPEntity = GCLevelDataList.Where(o => o.OilTableRow.itemCode == "ICP").FirstOrDefault(); OilDataEntity ECPEntity = GCLevelDataList.Where(o => o.OilTableRow.itemCode == "ECP").FirstOrDefault(); if (ICPEntity == null || ECPEntity == null) { return(DIC); } if (ICPEntity.calData == string.Empty || ECPEntity.calData == string.Empty) { return(DIC); } float TotalICP = 0, TotalECP = 0; if (!(float.TryParse(ICPEntity.calData, out TotalICP) && float.TryParse(ECPEntity.calData, out TotalECP))) { return(DIC); } #endregion List <float> XList = B_X.Where(o => o >= TotalICP && o <= TotalECP).ToList(); if (XList.Count <= 0) { return(DIC); } if (XList.Count == 1) { float CUTICP = TotalICP; float CUTECP = XList[0]; } else if (XList.Count > 1) { for (int i = 1; i < XList.Count; i++) { float CUTICP = XList[i - 1]; float CUTECP = XList[i]; CurveDataEntity ICPData = ECP_TWYCurve.curveDatas.Where(o => o.xValue == CUTICP).FirstOrDefault(); CurveDataEntity ECPData = ECP_TWYCurve.curveDatas.Where(o => o.xValue == CUTECP).FirstOrDefault(); if (ICPData == null || ECPData == null) { continue; } if (ICPData.yValue.Equals(float.NaN) || ECPData.yValue.Equals(float.NaN)) { continue; } float WY = ECPData.yValue - ICPData.yValue; Dictionary <string, float> gcDIC = OilApplyBll.getGCInterpolationDIC(GCLevelDataList, CUTICP, CUTECP, WY); List <float> tempList = gcDIC.Values.ToList(); float sum = 0; foreach (string key in gcDIC.Keys) { sum += gcDIC[key]; } float?result = null; switch (itemCode) { case "D20": result = OilApplySupplement.getGC_D20Value(gcDIC, WY); break; case "MW": result = OilApplySupplement.getGC_MWValue(gcDIC, WY); break; case "RNC": result = OilApplySupplement.getGC_RNCValue(gcDIC, WY); break; case "PAN": result = OilApplySupplement.getGC_PANValue(gcDIC, WY); break; case "PAO": result = OilApplySupplement.getGC_PAOValue(gcDIC, WY); break; case "NAH": result = OilApplySupplement.getGC_NAHValue(gcDIC, WY); break; case "MON": result = OilApplySupplement.getGC_MONValue(gcDIC, WY); break; case "ARM": result = OilApplySupplement.getGC_ARMValue(gcDIC, WY); break; case "ARP": result = OilApplySupplement.getGC_ARPValue(gcDIC, WY); break; case "RVP": // result = OilApplySupplement.getGC_RVPValue(gcDIC, WY); break; } if (!DIC.Keys.Contains(CUTECP) && result != null) { DIC.Add(CUTECP, result.Value); } } } return(DIC); }
/// <summary> /// 从应用库中取出曲线 /// </summary> /// <param name="oilInfoBID"></param> /// <param name="DataBaseBDIC"></param> /// <param name="typeCode"></param> /// <param name="CurveXParmType"></param> /// <param name="CurveYParmType"></param> /// <returns></returns> public static CurveEntity getCurrentCurveFromDataBaseB(int oilInfoBID, Dictionary <float, float> DataBaseBDIC, CurveTypeCode typeCode, CurveParmTypeEntity CurveXParmType, CurveParmTypeEntity CurveYParmType) { if (DataBaseBDIC == null || CurveXParmType == null || CurveYParmType == null) { return(null); } if (DataBaseBDIC.Count <= 0) { return(null); } if (typeCode == CurveTypeCode.YIELD) { if (CurveXParmType.ItemCode != PartCurveItemCode.ECP.ToString())//只有X轴为ECP的曲线才保存 { return(null); } } else if (typeCode == CurveTypeCode.DISTILLATE) { if (CurveXParmType.ItemCode != PartCurveItemCode.ECP.ToString())//只有X轴为ECP的曲线才保存 { return(null); } } else if (typeCode == CurveTypeCode.RESIDUE) { if (CurveXParmType.ItemCode != PartCurveItemCode.WY.ToString()) { return(null); } } Dictionary <float, float> tempDiC = DataBaseBDIC; #region "曲线的数据点集合赋值" List <CurveDataEntity> curveDatas = new List <CurveDataEntity>(); foreach (float Key in tempDiC.Keys) { CurveDataEntity curveDataEntity = new CurveDataEntity(); curveDataEntity.cutPointCP = Key; curveDataEntity.xValue = Key; curveDataEntity.yValue = tempDiC[Key]; curveDataEntity.XItemCode = CurveXParmType.ItemCode; curveDataEntity.YItemCode = CurveYParmType.ItemCode; curveDatas.Add(curveDataEntity); } #endregion #region "向原油中添加曲线" if (curveDatas.Count > 0) { //CurveEntity currentCurve = oilInfoB.curves.Where(o => o.propertyX == CurveXParmType.ItemCode && o.propertyY == CurveYParmType.ItemCode).FirstOrDefault(); OilTableRowEntity tempRowY = OilTableRowBll._OilTableRow.Where(o => o.itemCode == CurveYParmType.ItemCode).FirstOrDefault(); //注意此处的曲线没有ID CurveEntity curve = new CurveEntity(); curve.curveTypeID = (int)typeCode; curve.oilInfoID = oilInfoBID; curve.propertyX = CurveXParmType.ItemCode; curve.propertyY = CurveYParmType.ItemCode; curve.unit = tempRowY.itemUnit; curve.descript = tempRowY.itemName; curve.decNumber = tempRowY.decNumber == null ? tempRowY.valDigital : tempRowY.decNumber.Value; curve.curveDatas.AddRange(curveDatas); return(curve); } #endregion return(null); }
/// <summary> /// 从当前的DataGridView中获取数据添加到原油的曲线集合中 /// </summary> /// <param name="oilInfoB">当前原油的曲线集合</param> /// <param name="dataGridView">从此表格中获取数据填到原油的曲线数据集合</param> /// <param name="typeCode">YIELD收率曲线,DISTILLATE性质曲线,RESIDUE渣油曲线</param> /// <param name="CurveXParmType">判断当前原油曲线的X轴参数</param> /// <param name="CurveYParmType">判断当前原油曲线的Y轴参数</param> public static void getCurrentCurveFromDataGridViewDataBaseB(ref OilInfoBEntity oilInfoB, DataGridView dataGridView, CurveTypeCode typeCode, CurveParmTypeEntity CurveXParmType, CurveParmTypeEntity CurveYParmType) { if (oilInfoB == null || dataGridView == null || CurveXParmType == null || CurveYParmType == null) { return; } if (dataGridView.Rows.Count < 5) { return; } if (typeCode == CurveTypeCode.YIELD) { if (CurveXParmType.ItemCode != PartCurveItemCode.ECP.ToString())//只有X轴为ECP的曲线才保存 { return; } } else if (typeCode == CurveTypeCode.DISTILLATE) { if (CurveXParmType.ItemCode != PartCurveItemCode.ECP.ToString())//只有X轴为MCP的曲线才保存 { return; } } else if (typeCode == CurveTypeCode.RESIDUE) { if (CurveXParmType.ItemCode != PartCurveItemCode.WY.ToString()) { return; } } Dictionary <float, float> tempDiC = getDataBaseBfromDataGridView(dataGridView); if (tempDiC.Count <= 0) { return; } OilTableRowEntity tempRowY = OilTableRowBll._OilTableRow.Where(o => o.itemCode == CurveYParmType.ItemCode).FirstOrDefault(); #region "曲线的数据点集合赋值" List <CurveDataEntity> curveDatas = new List <CurveDataEntity>(); foreach (float Key in tempDiC.Keys) { CurveDataEntity curveDataEntity = new CurveDataEntity(); curveDataEntity.cutPointCP = Key; curveDataEntity.xValue = Key; curveDataEntity.yValue = tempDiC[Key]; curveDataEntity.XItemCode = CurveXParmType.ItemCode; curveDataEntity.YItemCode = CurveYParmType.ItemCode; curveDatas.Add(curveDataEntity); } #endregion #region "向原油中添加曲线" if (curveDatas.Count > 0) { CurveEntity currentCurve = oilInfoB.curves.Where(o => o.propertyX == CurveXParmType.ItemCode && o.propertyY == CurveYParmType.ItemCode).FirstOrDefault(); if (currentCurve != null) //从内存中找到曲线、删除。 { oilInfoB.curves.Remove(currentCurve); //此处要考虑从B库取出的数据 currentCurve.curveDatas.Clear(); currentCurve.curveDatas.AddRange(curveDatas); oilInfoB.curves.Add(currentCurve); } else { //注意此处的曲线没有ID CurveEntity curve = new CurveEntity(); curve.curveTypeID = (int)typeCode; curve.oilInfoID = oilInfoB.ID; curve.propertyX = CurveXParmType.ItemCode; curve.propertyY = CurveYParmType.ItemCode; curve.unit = tempRowY.itemUnit; curve.descript = tempRowY.itemName; curve.decNumber = tempRowY.decNumber == null ? tempRowY.valDigital : tempRowY.decNumber.Value; //curve.decNumber = tempRowY.decNumber; curve.curveDatas.AddRange(curveDatas); oilInfoB.curves.Add(curve); } } #endregion }
//更新股票信息 public void Update(CurveEntity curveData) { }