示例#1
0
        ///// <summary>
        ///// 设置单元格最后两行,在第A库X轴填充值
        ///// </summary>
        ///// <param name="keys"></param>
        //public static void addDataToDataGridViewDataBaseB(ref OilInfoBEntity oilInfoB, ref DataGridView dataGridView, CurveTypeCode typeCode, CurveParmTypeEntity CurveXParmType, CurveParmTypeEntity CurveYParmType)
        //{
        //    if (dataGridView.Rows.Count < 5)
        //        return;

        //    if (typeCode == CurveTypeCode.YIELD || typeCode == CurveTypeCode.DISTILLATE)
        //    {
        //        #region "!RESIDUE"
        //        CurveEntity XCurve = oilInfoB.curves.Where(o => o.propertyX == "ECP" && o.propertyY == CurveXParmType.ItemCode).FirstOrDefault();
        //        CurveEntity YCurve = oilInfoB.curves.Where(o => o.propertyX == "ECP" && o.propertyY == CurveYParmType.ItemCode).FirstOrDefault();

        //        if (XCurve == null || YCurve == null)
        //            return;
        //        if (XCurve.curveDatas.Count <= 0 || YCurve.curveDatas.Count <= 0)
        //            return;

        //        Dictionary<float, List<float>> ECP_X_Y = new Dictionary<float, List<float>>();

        //        for (int index = 0; index < XCurve.curveDatas.Count; index++)
        //        {
        //            float ecp = XCurve.curveDatas[index].xValue;
        //            CurveDataEntity tempCurveData = YCurve.curveDatas.Where(o => o.xValue == ecp).FirstOrDefault();
        //            if (tempCurveData != null)
        //            {
        //                List<float> X_Y = new List<float>();
        //                X_Y.Add(XCurve.curveDatas[index].yValue);
        //                X_Y.Add(tempCurveData.yValue);
        //                ECP_X_Y.Add(ecp, X_Y);
        //            }
        //        }
        //        if (ECP_X_Y.Count <= 0)
        //            return;

        //        foreach (float ECP_Key in ECP_X_Y.Keys)
        //        {
        //            int colIndex = FindItemCodeValueColIndexfromSpecRow(dataGridView, ECP_Key, 2);
        //            if (colIndex != -1)
        //            {
        //                dataGridView.Rows[FrmCurveAGlobal._curveRowXIndex].Cells[colIndex].Value = ECP_X_Y[ECP_Key][0];
        //                dataGridView.Rows[FrmCurveAGlobal._curveRowYIndex].Cells[colIndex].Value = ECP_X_Y[ECP_Key][1];
        //            }
        //        }
        //        #endregion
        //    }
        //    else if (typeCode == CurveTypeCode.RESIDUE)
        //    {
        //        #region "RESIDUE"
        //        CurveEntity XCurve = oilInfoB.curves.Where(o => o.propertyX == "ECP" && o.propertyY == CurveXParmType.ItemCode).FirstOrDefault();
        //        CurveEntity YCurve = oilInfoB.curves.Where(o => o.propertyX == "WY" && o.propertyY == CurveYParmType.ItemCode).FirstOrDefault();

        //        if (XCurve == null || YCurve == null)
        //            return;
        //        if (XCurve.curveDatas.Count <= 0 || YCurve.curveDatas.Count <= 0)
        //            return;

        //        Dictionary<float, List<float>> ECP_X_Y = new Dictionary<float, List<float>>();

        //        for (int index = 0; index < XCurve.curveDatas.Count; index++)
        //        {
        //            //float ecp = XCurve.curveDatas[index].xValue;
        //            //if (ECP_WYDic.Keys.Contains(ecp))
        //            //{
        //            //    float wy = ECP_WYDic[ecp];
        //            //    CurveDataEntity tempCurveData = YCurve.curveDatas.Where(o => o.xValue == wy).FirstOrDefault();
        //            //    if (tempCurveData != null)
        //            //    {
        //            //        List<float> X_Y = new List<float>();
        //            //        X_Y.Add(XCurve.curveDatas[index].yValue);
        //            //        X_Y.Add(tempCurveData.yValue);
        //            //        ECP_X_Y.Add(ecp, X_Y);
        //            //    }
        //            //}
        //        }
        //        if (ECP_X_Y.Count <= 0)
        //            return;

        //        foreach (float ECP_Key in ECP_X_Y.Keys)
        //        {
        //            int colIndex = FindItemCodeValueColIndexfromSpecRow(dataGridView, ECP_Key, 2);
        //            if (colIndex != -1)
        //            {
        //                dataGridView.Rows[FrmCurveAGlobal._curveRowXIndex].Cells[colIndex].Value = ECP_X_Y[ECP_Key][0];
        //                dataGridView.Rows[FrmCurveAGlobal._curveRowYIndex].Cells[colIndex].Value = ECP_X_Y[ECP_Key][1];
        //            }
        //        }
        //        #endregion
        //    }
        //}
        #endregion
        /// <summary>
        /// 渣油曲线内插和外延后设置渣油曲线的单元格最后一行的值
        /// </summary>
        /// <param name="dataGridView"></param>
        /// <param name="typeCode"></param>
        /// <param name="CurveXParmType"></param>
        /// <param name="CurveYParmType"></param>
        /// <param name="ECP_WYDataBDic"></param>
        /// <param name="DataBaseBDic"></param>
        public static void addValueToDataGridViewDataBaseBYWhenRESIDUE(ref DataGridView dataGridView, CurveTypeCode typeCode, CurveParmTypeEntity CurveXParmType, CurveParmTypeEntity CurveYParmType, Dictionary <int, float> ECP_WYDataBDic, Dictionary <float, float> DataBaseBDic)
        {
            #region "输入条件判断"
            if (dataGridView.RowCount != 5)
            {
                return;
            }
            if (DataBaseBDic.Count <= 0)
            {
                return;
            }
            if (typeCode != CurveTypeCode.RESIDUE)
            {
                return;
            }

            if (ECP_WYDataBDic == null)
            {
                return;
            }
            if (ECP_WYDataBDic.Count != DataBaseBDic.Count)
            {
                return;
            }
            #endregion

            OilTools          oilTool  = new OilTools();
            OilTableRowEntity tempRowX = OilTableRowBll._OilTableRow.Where(o => o.itemCode == CurveXParmType.ItemCode && o.oilTableTypeID == CurveXParmType.OilTableTypeID).FirstOrDefault();
            OilTableRowEntity tempRowY = OilTableRowBll._OilTableRow.Where(o => o.itemCode == CurveYParmType.ItemCode && o.oilTableTypeID == CurveYParmType.OilTableTypeID).FirstOrDefault();

            dataGridView[FrmCurveAGlobal._dataColStart, FrmCurveAGlobal._curveRowXIndex].Value = dataGridView[FrmCurveAGlobal._dataColStart, 0].Value; //原油性质赋值
            dataGridView[FrmCurveAGlobal._dataColStart, FrmCurveAGlobal._curveRowYIndex].Value = dataGridView[FrmCurveAGlobal._dataColStart, 1].Value; //原油性质赋值

            foreach (int cutPoint in  ECP_WYDataBDic.Keys)
            {
                int colNum = FindItemCodeValueColIndexfromSpecRow(dataGridView, cutPoint, FrmCurveAGlobal._ECPRowIndex);
                if (colNum == -1)
                {
                    continue;
                }
                if (ECP_WYDataBDic[cutPoint].Equals(float.NaN))
                {
                    continue;
                }
                if (DataBaseBDic[ECP_WYDataBDic[cutPoint]].Equals(float.NaN))
                {
                    continue;
                }

                //string strItemCodeValue = oilTool.calDataDecLimit(DataBaseBDic[ECP_WYDataBDic[cutPoint]].ToString(), tempRowY.decNumber,tempRowY.valDigital);
                //dataGridView[colNum, FrmCurveAGlobal._curveRowYIndex].Value = strItemCodeValue;
                dataGridView[colNum, FrmCurveAGlobal._curveRowYIndex].Tag   = DataBaseBDic[ECP_WYDataBDic[cutPoint]].ToString();
                dataGridView[colNum, FrmCurveAGlobal._curveRowYIndex].Value = DataBaseBDic[ECP_WYDataBDic[cutPoint]];
            }
        }
        /// <summary>
        /// 行的数据转为实体
        /// </summary>
        /// <param name="row">行</param>
        /// <returns>OilTableRowEntity实体</returns>
        private OilTableRowEntity rowToEntity(DataGridViewRow row)
        {
            OilTableRowEntity col = new OilTableRowEntity();

            col.ID         = int.Parse(row.Cells["ID"].Value.ToString());
            col.itemName   = row.Cells["itemName"].Value.ToString();
            col.itemOrder  = int.Parse(row.Cells["itemOrder"].Value.ToString());
            col.itemEnName = row.Cells["itemEnName"].Value == null ? "" : (string)row.Cells["itemEnName"].Value;
            col.itemUnit   = row.Cells["itemUnit"].Value == null ? "" : (string)row.Cells["itemUnit"].Value;
            col.itemCode   = row.Cells["itemCode"].Value == null ? "" : (string)row.Cells["itemCode"].Value;
            col.dataType   = row.Cells["dataType"].Value == null ? "" : (string)row.Cells["dataType"].Value;

            if (row.Cells["decNumber"].Value == null)
            {
                col.decNumber = null;
            }
            else
            {
                col.decNumber = Convert.ToInt32(row.Cells["decNumber"].Value.ToString().Trim());
            }

            col.valDigital = row.Cells["valDigital"].Value == null ? 0 : Convert.ToInt32(row.Cells["valDigital"].Value.ToString().Trim());

            col.isKey     = row.Cells["isKey"].Value == null ? false : (bool)row.Cells["isKey"].Value;
            col.isDisplay = row.Cells["isDisplay"].Value == null ? false : (bool)row.Cells["isDisplay"].Value;

            if (row.Cells["errDownLimit"].Value == null)
            {
                col.errDownLimit = null;
            }
            else
            {
                col.errDownLimit = float.Parse(row.Cells["errDownLimit"].Value.ToString());
            }

            if (row.Cells["errUpLimit"].Value == null)
            {
                col.errUpLimit = null;
            }
            else
            {
                col.errUpLimit = float.Parse(row.Cells["errUpLimit"].Value.ToString());
            }

            col.trend = row.Cells["trend"].Value == null ? "" : (string)row.Cells["trend"].Value;

            col.descript       = row.Cells["descript"].Value == null ? "" : row.Cells["descript"].Value.ToString();
            col.subItemName    = "";
            col.isSystem       = row.Cells["isSystem"].Value == null ? false : Convert.ToBoolean(row.Cells["isSystem"].Value);
            col.oilTableTypeID = (int)this._trendTableType;

            return(col);
        }
示例#3
0
        /// <summary>
        /// 批注的表类型下拉菜单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmbRemarkTableName_SelectedIndexChanged(object sender, EventArgs e)
        {
            var selectedItem = (OilTableTypeEntity)this.cmbRemarkTableName.SelectedItem;//确定馏分段的菜单中的数据
            List <OilTableRowEntity> cmbRangeItemList = this._tableRowList.Where(o => o.oilTableTypeID == selectedItem.ID).OrderBy(o => o.itemOrder).ToList();

            if ("GC输入表".Equals(this.cmbRemarkTableName.Text))
            {
                #region "范围查询物性数据绑定"
                if (null != this.cmbRemarkItemName.Items)
                {
                    this.cmbRemarkItemName.Items.Clear();//将上一次所选择的内容清零
                }
                int i = 0;
                foreach (GCMatch1Entity temp in this._GCMatch1List)
                {
                    OilTableRowEntity tableRow = new OilTableRowEntity
                    {
                        itemName  = temp.itemName,
                        itemOrder = i++,
                        ID        = i++
                    };
                    this.cmbRemarkTableName.Items.Add(tableRow);
                }

                this.cmbRemarkItemName.DisplayMember = "itemName";
                this.cmbRemarkItemName.ValueMember   = "ID";

                this.cmbRemarkItemName.SelectedIndex = 0;
                #endregion
            }
            else
            {
                #region  "性质控件的绑定"
                if (null != this.cmbRemarkItemName.Items)
                {
                    this.cmbRemarkItemName.Items.Clear();                    //将上一次所选择的内容清零
                }
                this.cmbRemarkItemName.DisplayMember = "ItemName";           //设置显示名称
                this.cmbRemarkItemName.ValueMember   = "ItemCode";           //设置保存代码

                if (cmbRangeItemList != null && 0 != cmbRangeItemList.Count) //存在返回的数据不为空
                {
                    foreach (OilTableRowEntity row in cmbRangeItemList)
                    {
                        this.cmbRemarkItemName.Items.Add(row);
                    }

                    this.cmbRemarkItemName.SelectedIndex = 0;//选择第一个选项
                }
                #endregion
            }
        }
示例#4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dataGridView"></param>
        /// <param name="OilDataCols"></param>
        /// <param name="OilDataRows"></param>
        /// <param name="allDatas"></param>
        /// <param name="strTableName"></param>
        private void InitDataGridView(string strTableName, DataGridView dataGridView, List <OilDataSearchColEntity> OilDataCols, List <OilDataSearchRowEntity> OilDataRows, List <OilDataSearchEntity> allDatas)
        {
            #region "内部计算"
            List <OilDataSearchColEntity> Cols      = OilDataCols.Where(o => o.OilTableName.Contains(strTableName)).OrderBy(o => o.itemOrder).ToList();
            List <OilDataSearchRowEntity> Rows      = OilDataRows.Where(o => o.OilDataColID == Cols[0].ID).OrderBy(o => o.OilTableRow.itemOrder).ToList();
            List <OilTableRowEntity>      TableRows = new List <OilTableRowEntity>();
            for (int i = 0; i < Rows.Count; i++)
            {
                OilTableRowEntity oilTableRow = OilTableRowBll._OilTableRow.Where(o => o.ID == Rows[i].OilTableRowID).FirstOrDefault();
                TableRows.Add(oilTableRow);
            }

            List <OilDataSearchEntity> Datas = new List <OilDataSearchEntity>();
            for (int i = 0; i < Cols.Count; i++)
            {
                List <OilDataSearchEntity> Data = allDatas.Where(o => o.oilTableColID == Cols[i].OilTableColID).ToList();
                Datas.AddRange(Data);
            }

            initData(dataGridView, Cols, TableRows, Datas);

            if (strTableName == "原油信息")
            {
                this._dgvInfoNeedSave = false;
            }
            else if (strTableName == "原油性质")
            {
                this._dgvWholeNeedSave = false;
            }
            else if (strTableName == "石脑油")
            {
                this._dgvNaphthaNeedSave = false;
            }
            else if (strTableName == "航煤")
            {
                this._dgvAviationKeroseneNeedSave = false;
            }
            else if (strTableName == "柴油")
            {
                this._dgvDieselNeedSave = false;
            }
            else if (strTableName == "VGO")
            {
                this._dgvVGONeedSave = false;
            }
            else if (strTableName == "渣")
            {
                this._dgvResidualNeedSave = false;
            }
            #endregion
        }
示例#5
0
 /// <summary>
 /// 更新数据库,如果是新添加的行则添加数据库,否则更新数据库
 /// </summary>
 /// <param name="row">OilTableRowEntity实体</param>
 private void updateRow(OilTableRowEntity row)
 {
     if (row == null)
     {
         return;
     }
     if (row.ID != 0)      //如果行在数据库中存在(即ID字段不为0)则从更新数据库,否则(该行是才添加的还没存到数据库)添加到数据库
     {
         _bll[row.itemCode, _tableType] = row;
     }
     else
     {
         _bll.Add(row);
     }
 }
示例#6
0
        /// <summary>
        /// 将导入的B库数据变为OilData
        /// </summary>
        /// <param name="OilInfoBEntity"></param>
        /// <param name="OilInfoOut"></param>
        /// <param name="oilTableRows"></param>
        /// <param name="oilTableCols"></param>
        public void toOilDatas(ref OilInfoBEntity oilInfoEntity, OilInfoOut oilInfoOut, List <OilTableRowOut> oilTableRows, List <OilTableColOut> oilTableCols)
        {
            OilTableRowBll rowBll = new OilTableRowBll();
            OilTableColBll colBll = new OilTableColBll();

            foreach (OilDataOut oilDataOut in oilInfoOut.oilDatas)  //插入原油数据
            {
                OilDataBEntity oilData        = new OilDataBEntity();
                OilTableColOut oilTableColOut = oilTableCols.Where(c => c.ID == oilDataOut.oilTableColID).FirstOrDefault();
                if (oilTableColOut == null)
                {
                    continue;
                }
                string         colCode        = oilTableColOut.colCode;
                OilTableRowOut oilTableRowOut = oilTableRows.Where(c => c.ID == oilDataOut.oilTableRowID).FirstOrDefault();
                if (oilTableRowOut == null)
                {
                    continue;
                }
                string itemCode = oilTableRowOut.itemCode;
                //if (itemCode == "CLA" && oilTableRowOut.oilTableTypeID == 2)
                //    continue;
                //if (itemCode == "A10" && oilTableRowOut.oilTableTypeID == 4)
                //    itemCode = "10A";

                try
                {
                    OilTableColEntity col = colBll[colCode, (EnumTableType)oilTableRowOut.oilTableTypeID];
                    OilTableRowEntity row = rowBll[itemCode, (EnumTableType)oilTableRowOut.oilTableTypeID];
                    if (row != null && col != null)
                    {
                        oilData.oilInfoID     = oilInfoEntity.ID;
                        oilData.oilTableColID = col.ID;
                        oilData.oilTableRowID = row.ID;
                        oilData.labData       = oilDataOut.labData;
                        oilData.calData       = oilDataOut.calData;

                        oilInfoEntity.OilDatas.Add(oilData);
                    }
                }
                catch (Exception ex)
                {
                    Log.Error("导入应用库 :" + ex.ToString());
                }
            }
        }
示例#7
0
        /// <summary>
        /// 添加所有
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddAll_Click(object sender, EventArgs e)
        {
            if (this.comboBox1.SelectedItem != null && this.comboBox2.Items.Count > 0)
            {
                for (int colIndex = 0; colIndex < this.comboBox2.Items.Count; colIndex++)
                {
                    ListViewItem item = new ListViewItem();
                    for (int j = 0; j < this.listView1.Columns.Count; j++)
                    {
                        ListViewItem.ListViewSubItem temp = new ListViewItem.ListViewSubItem();
                        temp.Name = this.listView1.Columns[j].Name;
                        item.SubItems.Add(temp);
                    }


                    OilDataSearchColEntity col = (OilDataSearchColEntity)this.comboBox1.SelectedItem;
                    OilTableRowEntity      row = (OilTableRowEntity)this.comboBox2.Items[colIndex];
                    bool Have = false;
                    for (int i = 0; i < this.listView1.Items.Count; i++)
                    {
                        if (this.listView1.Items[i].SubItems[0].Text == col.OilTableName && this.listView1.Items[i].SubItems[2].Text == row.itemName)
                        {
                            Have = true;
                        }
                    }
                    //for (int i = 0; i < this._TemplistView.Items.Count; i++)
                    //{
                    //    if (this._TemplistView.Items[i].SubItems[0].Text == col.OilTableName && this._TemplistView.Items[i].SubItems[2].Text == row.itemName)
                    //    {
                    //        Have = true;
                    //    }
                    //}
                    if (!Have)
                    {
                        item.SubItems[0].Text = col.OilTableName;
                        item.SubItems[1].Text = ":";
                        item.SubItems[2].Text = row.itemName;

                        item.SubItems[0].Tag = col.OilTableColID;
                        item.SubItems[2].Tag = row.ID;
                        this.listView1.Items.Add(item);
                    }
                }
            }
        }
示例#8
0
        /// <summary>
        /// 显示相似查找的基础值
        /// </summary>
        /// <param name="oil"></param>
        private void selectOilData()
        {
            string crudeIndex = this.gridList.CurrentRow != null ? this.gridList.CurrentRow.Cells["原油编号"].Value.ToString() : string.Empty;

            OilInfoBAccess oilInfoB     = new OilInfoBAccess();
            OilInfoBEntity tempOilInfoB = oilInfoB.Get("crudeIndex = '" + crudeIndex + "'").FirstOrDefault();

            if (tempOilInfoB == null)
            {
                return;
            }

            int oilInfoID = tempOilInfoB.ID;
            OilTableRowEntity selectOiltableRowEntity = (OilTableRowEntity)cmbSimilarItem.SelectedItem;         //获取物性下拉菜单选择项实体
            int oilTableRowID = selectOiltableRowEntity.ID;
            OilDataSearchColEntity selectedItem = (OilDataSearchColEntity)this.cmbSimilarFraction.SelectedItem; //确定当前菜单中的数据
            int oilTableColID = selectedItem.OilTableColID;

            OilDataSearchAccess oilDataSearchAccess = new OilDataSearchAccess();
            OilDataSearchEntity oilData             = oilDataSearchAccess.Get("oilInfoID = " + oilInfoID + " and oilTableColID = " + oilTableColID + " and oilTableRowID =" + oilTableRowID).FirstOrDefault();

            if (oilData != null)
            {
                if (oilData.calData != string.Empty && oilData.calData != "非数字" && oilData.calData != "正无穷大" && oilData.calData != "负无穷大")
                {
                    float temp = 0;
                    if (float.TryParse(oilData.calData, out temp))
                    {
                        this.txtSimilarFoundationValue.Text = oilData.calData;
                    }
                    else
                    {
                        this.txtSimilarFoundationValue.Text = string.Empty;
                    }
                }
                else
                {
                    this.txtSimilarFoundationValue.Text = string.Empty;
                }
            }
            else
            {
                this.txtSimilarFoundationValue.Text = string.Empty;
            }
        }
        /// <summary>
        /// 添加所有
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddAll_Click(object sender, EventArgs e)
        {
            if (this.cmbTable.SelectedItem != null && this.cmbItemName.Items.Count > 0)
            {
                string valueType = this.radioButton1.Checked ? this.radioButton1.Text : this.radioButton2.Text;
                for (int colIndex = 0; colIndex < this.cmbItemName.Items.Count; colIndex++)
                {
                    ListViewItem item = new ListViewItem();
                    for (int j = 0; j < this.listView1.Columns.Count; j++)
                    {
                        ListViewItem.ListViewSubItem temp = new ListViewItem.ListViewSubItem();
                        temp.Name = this.listView1.Columns[j].Name;
                        item.SubItems.Add(temp);
                    }

                    OilTableTypeEntity col = (OilTableTypeEntity)this.cmbTable.SelectedItem;
                    OilTableRowEntity  row = (OilTableRowEntity)this.cmbItemName.Items[colIndex];
                    bool Have = false;
                    for (int i = 0; i < this.listView1.Items.Count; i++)
                    {
                        if (this.listView1.Items[i].SubItems[0].Text == col.tableName && this.listView1.Items[i].SubItems[2].Text == row.itemName &&
                            this.listView1.Items[i].SubItems[4].Text == valueType)
                        {
                            Have = true;
                        }
                    }

                    if (!Have)
                    {
                        item.SubItems[0].Text = col.tableName;
                        item.SubItems[0].Tag  = col.ID;
                        item.SubItems[1].Text = ":";
                        item.SubItems[2].Text = row.itemName;
                        item.SubItems[3].Text = ":";
                        item.SubItems[4].Text = valueType;

                        item.SubItems[0].Tag = col.ID;
                        item.SubItems[2].Tag = row.ID;
                        item.SubItems[4].Tag = valueType;
                        this.listView1.Items.Add(item);
                    }
                }
            }
        }
示例#10
0
        /// <summary>
        /// 移动行
        /// </summary>
        private void toolStripBtnMove_Click(object sender, EventArgs e)
        {
            if (_isValidate == false)
            {
                return;
            }
            _currentRow = dgdViewAll.CurrentRow.Index;
            this.dgdViewAll.EndEdit();                         //结束编辑状态
            int    currRowIndex = dgdViewAll.CurrentRow.Index; //当前行序号
            int    nextRowIndex;                               //要交换的行序号
            string temp = ((ToolStripButton)sender).Tag.ToString();

            if (((ToolStripButton)sender).Tag.ToString() == "MoveUp")
            {
                nextRowIndex = currRowIndex - 1;
            }
            else
            {
                nextRowIndex = currRowIndex + 1;
            }
            if (nextRowIndex < 0 || nextRowIndex >= dgdViewAll.Rows.Count) //如果上移的交换行<0或超过表格控件的行数
            {
                return;
            }

            OilTableRowEntity currCol = this.rowToEntity(dgdViewAll.CurrentRow);
            OilTableRowEntity nextCol = this.rowToEntity(dgdViewAll.Rows[nextRowIndex]);

            int tempOrder; //两个行交换序号

            tempOrder         = currCol.itemOrder;
            currCol.itemOrder = nextCol.itemOrder;
            nextCol.itemOrder = tempOrder;

            updateRow(currCol);
            updateRow(nextCol);

            _bll.refreshRows(); //更新静态存储变量

            dgdViewAll.Rows[currRowIndex].Tag = true;
            dgdViewAll.Rows[nextRowIndex].Tag = true;
            _isValidate = true;
            BindDgdViewAll();
        }
示例#11
0
        /// <summary>
        /// 设置渣油表的行
        /// </summary>
        public static void _setResidueRow(DataGridView dataGridView, string XItemCode, string YItemCode)
        {
            dataGridView.Rows.Clear();
            List <OilTableRowEntity> tempRowList = OilTableRowBll._OilTableRow.Where(o => o.oilTableTypeID == (int)EnumTableType.Residue).ToList();
            OilTableRowEntity        ICPRow      = tempRowList.Where(o => o.itemCode == "ICP").FirstOrDefault();
            OilTableRowEntity        tempRowX    = tempRowList.Where(o => o.itemCode == XItemCode).FirstOrDefault();
            OilTableRowEntity        tempRowY    = tempRowList.Where(o => o.itemCode == YItemCode).FirstOrDefault();

            #region "添加行"
            GridOilRow rowAX = new GridOilRow();
            rowAX.RowEntity = tempRowX;
            rowAX.CreateCells(dataGridView, tempRowX.itemName, tempRowX.itemUnit, "原始库");
            rowAX.ReadOnly = true;
            dataGridView.Rows.Add(rowAX);
            tempRowX.RowIndex = rowAX.Index;

            GridOilRow rowAY = new GridOilRow();
            rowAY.RowEntity = tempRowY;
            rowAY.CreateCells(dataGridView, tempRowY.itemName, tempRowY.itemUnit, "原始库");
            rowAY.ReadOnly = true;
            dataGridView.Rows.Add(rowAY);
            tempRowY.RowIndex = rowAY.Index;
            #endregion
            #region "添加行"
            GridOilRow ICP = new GridOilRow();
            ICP.RowEntity = ICPRow;
            ICP.CreateCells(dataGridView, ICPRow.itemName, ICPRow.itemUnit, "  ");
            ICP.ReadOnly = true;
            dataGridView.Rows.Add(ICP);//添加第三行
            #endregion
            #region "添加行"
            GridOilRow row = new GridOilRow();
            row.RowEntity = tempRowX;
            row.CreateCells(dataGridView, tempRowX.itemName, tempRowX.itemUnit, "应用库");
            row.ReadOnly = true;
            dataGridView.Rows.Add(row);//添加第四行

            GridOilRow LastRow = new GridOilRow();
            LastRow.RowEntity = tempRowY;
            LastRow.CreateCells(dataGridView, tempRowY.itemName, tempRowY.itemUnit, "应用库");
            LastRow.ReadOnly = false;
            dataGridView.Rows.Add(LastRow);//添加第五行
            #endregion
        }
示例#12
0
        /// <summary>
        /// 行的数据转为实体
        /// </summary>
        /// <param name="row">行</param>
        /// <returns>OilTableRowEntity实体</returns>
        private OilTableRowEntity rowToEntity(DataGridViewRow row)
        {
            OilTableRowEntity col = new OilTableRowEntity();

            col.ID         = int.Parse(row.Cells["ID"].Value.ToString());
            col.itemName   = row.Cells["itemName"].Value.ToString();
            col.itemOrder  = int.Parse(row.Cells["itemOrder"].Value.ToString());
            col.itemEnName = row.Cells["itemEnName"].Value == null ? "" : (string)row.Cells["itemEnName"].Value;
            col.itemUnit   = row.Cells["itemUnit"].Value == null ? "" : (string)row.Cells["itemUnit"].Value;
            col.itemCode   = row.Cells["itemCode"].Value == null ? "" : (string)row.Cells["itemCode"].Value;
            col.dataType   = row.Cells["dataType"].Value == null ? "" : (string)row.Cells["dataType"].Value;

            if (row.Cells["decNumber"].Value == null)
            {
                col.decNumber = null;
            }
            else
            {
                col.decNumber = Convert.ToInt32(row.Cells["decNumber"].Value.ToString().Trim());
            }

            //col.decNumber = row.Cells["decNumber"].Value.ToString() == null ? null : Convert.ToInt32(row.Cells["decNumber"].Value.ToString().Trim()) as int?;
            col.valDigital = row.Cells["valDigital"].Value == null ? 0 : Convert.ToInt32(row.Cells["valDigital"].Value.ToString().Trim());

            col.isKey     = row.Cells["isKey"].Value == null ? false : (bool)row.Cells["isKey"].Value;
            col.isDisplay = row.Cells["isDisplay"].Value == null ? false : (bool)row.Cells["isDisplay"].Value;

            if (row.Cells["errDownLimit"].Value == null)
            {
                //col.errDownLimit = row.Cells["errDownLimit"].Value == null ? DBNull.Value : float.Parse(row.Cells["errDownLimit"].Value.ToString());
                col.errDownLimit = null;
            }
            else if (row.Cells["errDownLimit"].Value != null)
            {
                col.errDownLimit = float.Parse(row.Cells["errDownLimit"].Value.ToString());
            }

            if (row.Cells["errUpLimit"].Value == null)
            {
                col.errUpLimit = null;
            }
            else
            {
                col.errUpLimit = float.Parse(row.Cells["errUpLimit"].Value.ToString());
            }
            col.trend = row.Cells["trend"].Value == null ? "" : (string)row.Cells["trend"].Value;

            if (row.Cells["outExcel"].Value == null)
            {
                col.OutExcel = enumOutExcelMode.None;
            }
            else
            {
                if (row.Cells["outExcel"].Value.Equals("实测值优先"))
                {
                    col.OutExcel = enumOutExcelMode.LabFirst;
                }
                else if (row.Cells["outExcel"].Value.Equals("校正值优先"))
                {
                    col.OutExcel = enumOutExcelMode.CalFirst;
                }
                else if (row.Cells["outExcel"].Value.Equals("只实测值"))
                {
                    col.OutExcel = enumOutExcelMode.OnlyLab;
                }
                else if (row.Cells["outExcel"].Value.Equals("只校正值"))
                {
                    col.OutExcel = enumOutExcelMode.OnlyCla;
                }
            }

            col.descript       = row.Cells["descript"].Value == null ? "" : row.Cells["descript"].Value.ToString();
            col.subItemName    = "";
            col.isSystem       = row.Cells["isSystem"].Value == null ? false : Convert.ToBoolean(row.Cells["isSystem"].Value);
            col.oilTableTypeID = (int)this._tableType;

            return(col);
        }
示例#13
0
        /// <summary>
        /// 添加单个
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ListViewItem item = new ListViewItem();

            for (int colIndex = 0; colIndex < this.listView1.Columns.Count; colIndex++)
            {
                ListViewItem.ListViewSubItem temp = new ListViewItem.ListViewSubItem();
                temp.Name = this.listView1.Columns[colIndex].Name;
                item.SubItems.Add(temp);
            }

            if (this.cmbTable.SelectedItem != null && this.cmbItemName.SelectedItem != null)
            {
                string strTableName = string.Empty;
                string strItemName  = string.Empty;
                string strItemCode  = string.Empty;

                if (this.cmbTable.SelectedIndex == 0)
                {
                    strTableName = enumToolQueryDataBTableName.WhoTable.GetDescription();
                    OilTableRowEntity row = (OilTableRowEntity)this.cmbItemName.SelectedItem;
                    strItemName = row.itemName;
                    strItemCode = row.itemCode;
                }
                else if (this.cmbTable.SelectedIndex == 1)
                {
                    strTableName = enumToolQueryDataBTableName.FraTable.GetDescription();

                    CurveSubTypeEntity row = (CurveSubTypeEntity)this.cmbItemName.SelectedItem;
                    strItemName = row.descript;
                    strItemCode = row.propertyY;
                }
                else if (this.cmbTable.SelectedIndex == 2)
                {
                    strTableName = enumToolQueryDataBTableName.ResTable.GetDescription();
                    CurveSubTypeEntity row = (CurveSubTypeEntity)this.cmbItemName.SelectedItem;
                    strItemName = row.descript;
                    strItemCode = row.propertyY;
                }
                else if (this.cmbTable.SelectedIndex == 3)
                {
                    strTableName = enumToolQueryDataBTableName.GCTable.GetDescription();
                    OilTableRowEntity row = (OilTableRowEntity)this.cmbItemName.SelectedItem;
                    strItemName = row.itemName;
                    strItemCode = row.itemCode;
                }


                bool Have = false;
                for (int i = 0; i < this.listView1.Items.Count; i++)
                {
                    if (this.listView1.Items[i].SubItems[0].Text == strTableName && this.listView1.Items[i].SubItems[2].Text == strItemName)
                    {
                        Have = true;
                    }
                }

                if (!Have)
                {
                    item.SubItems[0].Text = strTableName;
                    item.SubItems[1].Text = ":";
                    item.SubItems[2].Text = strItemName;
                    item.SubItems[2].Tag  = strItemCode;

                    this.listView1.Items.Add(item);
                }
            }
        }
示例#14
0
        /// <summary>
        /// 将宽馏分的列数据写入原油
        /// </summary>
        /// <param name="oilA"></param>
        /// <param name="Data"></param>
        /// <param name="tableType"></param>
        private static void WriteToOilA(ref OilInfoEntity oilA, List <WCol> Data, EnumTableType tableType)
        {
            try
            {
                int colNum = 0;
                foreach (var col in Data)
                {
                    #region "获取列ID"
                    colNum++;
                    int oilTableColID = 0;

                    try
                    {
                        oilTableColID = _colCache["Cut" + colNum.ToString(), tableType].ID;
                    }
                    catch
                    {
                        MessageBox.Show("获取不到colID" + colNum.ToString());
                    }
                    #endregion

                    #region "添加ICP ECP"
                    if (tableType == EnumTableType.Narrow || tableType == EnumTableType.Wide || tableType == EnumTableType.Residue)
                    {
                        if (tableType == EnumTableType.Narrow || tableType == EnumTableType.Wide)//添加icp ecp
                        {
                            #region
                            var           oilTableICPRowID = _rowCache["ICP", tableType].ID;
                            OilDataEntity oilDataICP       = new OilDataEntity();
                            oilDataICP.oilInfoID     = oilA.ID;
                            oilDataICP.oilTableColID = oilTableColID;
                            oilDataICP.oilTableRowID = oilTableICPRowID;
                            string data = col.ICP == 0 ? "" : col.ICP.ToString();
                            oilDataICP.labData = data;
                            oilDataICP.calData = data;
                            oilA.OilDatas.Add(oilDataICP);



                            var           oilTableECPRowID = _rowCache["ECP", tableType].ID;
                            OilDataEntity oilDataECP       = new OilDataEntity();
                            oilDataECP.oilInfoID     = oilA.ID;
                            oilDataECP.oilTableColID = oilTableColID;
                            oilDataECP.oilTableRowID = oilTableECPRowID;

                            data = col.ECP == 0 ? "" : col.ECP.ToString();
                            oilDataECP.labData = data;
                            oilDataECP.calData = data;
                            oilA.OilDatas.Add(oilDataECP);
                            #endregion
                        }
                        if (tableType == EnumTableType.Residue)//添加icp ecp
                        {
                            #region
                            var           ICProw     = _rowCache["ICP", tableType];
                            OilDataEntity oilDataICP = new OilDataEntity();
                            oilDataICP.oilInfoID     = oilA.ID;
                            oilDataICP.oilTableColID = oilTableColID;
                            oilDataICP.oilTableRowID = ICProw.ID;
                            string data = col.ICP.ToString();
                            oilDataICP.labData = data;
                            oilDataICP.calData = data;
                            oilA.OilDatas.Add(oilDataICP);
                            #endregion
                        }
                    }
                    #endregion

                    #region "添加ICP ECP"

                    if (tableType == EnumTableType.Wide || tableType == EnumTableType.Residue) //如果是“宽馏分”和“渣油” 温度判断是什么油  ,宽 和 渣 才有 WCT
                    {
                        string              oilType   = GetOilType(col.ICP, col.ECP);          //得到wct的种类
                        S_ParmBll           s_ParmBll = new S_ParmBll();
                        List <S_ParmEntity> wCutTypes;                                         //todo 如果是“渣油”变为rct
                        if (tableType == EnumTableType.Residue)
                        {
                            wCutTypes = s_ParmBll.GetParms("RCT");
                        }
                        else
                        {
                            wCutTypes = s_ParmBll.GetParms("WCT");
                        }

                        string WCT = "";
                        try
                        {
                            WCT = wCutTypes.Where(c => c.parmName == oilType).FirstOrDefault().parmValue;
                        }
                        catch
                        {
                            MessageBox.Show("ICP:" + col.ICP + "ECP:" + col.ECP + "未找到对应原油类型");
                        }
                        //宽馏分的wct行
                        var           rowWCT     = _rowCache["WCT", tableType];
                        OilDataEntity oilDataWCT = new OilDataEntity();
                        oilDataWCT.oilInfoID     = oilA.ID;
                        oilDataWCT.oilTableColID = oilTableColID;
                        oilDataWCT.oilTableRowID = rowWCT.ID;
                        string data = WCT;
                        if (data.Length > 12)
                        {
                            data = data.Substring(0, 12);
                        }
                        oilDataWCT.labData = data;
                        oilDataWCT.calData = data;
                        oilA.OilDatas.Add(oilDataWCT);
                    }
                    #endregion

                    #region "其他数据赋值"

                    foreach (var item in col.Cells)
                    {
                        OilTableRowEntity rowEntity = null;//根据itemcode得到行id
                        try
                        {
                            if (item.ItemCode == "TYP")
                            {
                                //rowEntity = _rowCache["TYP", EnumTableType.Info];
                                oilA.type = item.LabData;
                                //更新原油信息
                                OilBll.saveInfo(oilA);
                                continue;
                            }
                            else
                            {
                                rowEntity = _rowCache[item.ItemCode, tableType];
                            }
                            if (rowEntity == null)
                            {
                                continue;
                            }
                        }
                        catch
                        {
                            MessageBox.Show("rowEntity获取失败");
                        }
                        OilDataEntity oilData = new OilDataEntity();
                        oilData.oilInfoID     = oilA.ID;
                        oilData.oilTableColID = oilTableColID;
                        oilData.oilTableRowID = rowEntity.ID;
                        string labData;
                        try
                        {
                            OilTools tools = new OilTools();
                            if (rowEntity.decNumber != null)
                            {
                                labData = tools.calDataDecLimit(item.LabData, rowEntity.decNumber + 2, rowEntity.valDigital);//输入Execl表的过程中转换数据精度
                            }
                            else
                            {
                                labData = tools.calDataDecLimit(item.LabData, rowEntity.decNumber, rowEntity.valDigital);//输入Execl表的过程中转换数据精度
                            }
                        }
                        catch
                        {
                            MessageBox.Show("lab:" + item.LabData);
                        }
                        oilData.labData = item.LabData;
                        oilData.calData = item.LabData;
                        oilA.OilDatas.Add(oilData);
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                Log.Error("erro:" + ex);
            }
        }
示例#15
0
        /// <summary>
        /// 设置非渣油曲线的单元格最后一行的值
        /// </summary>
        /// <param name="dataGridView">需要填充的单元格</param>
        /// <param name="typeCode">曲线的类型</param>
        /// <param name="DataBaseBDic">需要填充的数据</param>
        /// <param name="CurveYParmType">最后一行物性</param>
        public static void addValueToDataGridViewDataBaseBYWhenNORESIDUE(ref DataGridView dataGridView, CurveTypeCode typeCode, Dictionary <float, float> DataBaseBDic, CurveParmTypeEntity CurveYParmType)
        {
            #region "输入条件判断"
            if (dataGridView.RowCount != 5)
            {
                return;
            }
            if (DataBaseBDic.Count <= 0)
            {
                return;
            }
            if (typeCode == CurveTypeCode.RESIDUE)
            {
                return;
            }
            #endregion

            OilTableRowEntity tempRowY = OilTableRowBll._OilTableRow.Where(o => o.itemCode == CurveYParmType.ItemCode && o.oilTableTypeID == CurveYParmType.OilTableTypeID).FirstOrDefault();
            OilTools          oilTool  = new OilTools();

            for (int colIndex = FrmCurveAGlobal._dataColStart; colIndex < dataGridView.ColumnCount; colIndex++)
            {
                object xValue = dataGridView.Rows[FrmCurveAGlobal._curveRowXIndex].Cells[colIndex].Value;//取出第四行的数据

                #region "数据判断"
                if (xValue == null)
                {
                    continue;
                }
                if (xValue.ToString() == "非数字" || xValue.ToString() == "")
                {
                    continue;
                }
                float temp;
                if (!float.TryParse(xValue.ToString(), out temp))
                {
                    continue;
                }
                if (!DataBaseBDic.Keys.Contains(temp))
                {
                    continue;
                }

                float fTempY = DataBaseBDic[temp];
                if (fTempY.Equals(float.NaN))
                {
                    continue;
                }
                #endregion

                object obj = null;
                if (tempRowY.errDownLimit.HasValue && fTempY < tempRowY.errDownLimit ||
                    tempRowY.errUpLimit.HasValue && fTempY > tempRowY.errUpLimit)
                {
                    obj = null;
                }
                else
                {
                    obj = fTempY;
                }
                //if (obj != null)
                //{
                //    if (tempRowY.errUpLimit.HasValue && fTempY > tempRowY.errUpLimit)
                //    {
                //        obj = null;
                //    }
                //    else
                //    {
                //        obj = fTempY;
                //    }
                //}

                //string strTemp = oilTool.calDataDecLimit(fTempY.ToString(), tempRowY.decNumber, tempRowY.valDigital);
                //dataGridView.Rows[FrmCurveAGlobal._curveRowYIndex].Cells[colIndex].Value = strTemp;
                //dataGridView.Rows[FrmCurveAGlobal._curveRowYIndex].Cells[colIndex].Tag = fTempY;
                //dataGridView.Rows[FrmCurveAGlobal._curveRowYIndex].Cells[colIndex].Value = fTempY;

                dataGridView.Rows[FrmCurveAGlobal._curveRowYIndex].Cells[colIndex].Tag   = obj;
                dataGridView.Rows[FrmCurveAGlobal._curveRowYIndex].Cells[colIndex].Value = obj;
            }
        }
示例#16
0
        /// <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
        }
示例#17
0
        /// <summary>
        /// 转换
        /// </summary>
        /// <param name="oil"></param>
        /// <returns></returns>
        public static RefineryAssays ConvertFrom(OilInfoBEntity oil)
        {
            var r = new RefineryAssays();

            if (oil == null)
            {
                return(r);
            }

            var maps = Newtonsoft.Json.JsonConvert.DeserializeObject <RefineryAssaysMapItem[]>(File.ReadAllText("RefineryAssaysMaps.json"));

            #region 原油信息

            var name = $"{oil.crudeIndex} - {oil.englishName ?? oil.crudeName}";
            r.RefineryAssay = new RefineryAssaysRefineryAssay()
            {
                Name = name,
                RefineryAssayName      = name,
                SourceType             = oil.sourceRef,
                AssociatedFluidPackage = "Basis-1",
                PlantDataGroups        = new RefineryAssaysRefineryAssayPlantDataGroups()
                {
                    PlantDataGroup = new RefineryAssaysRefineryAssayPlantDataGroupsPlantDataGroup()
                    {
                        Name = "Plant Data Group-1",
                        PlantDataGroupName = "Plant Data Group-1"
                    },
                }
            };

            var ps = new List <RefineryAssaysRefineryAssayPlantDataGroupsPlantDataGroupPropertiesProperty>();

            foreach (var p in maps)
            {
                var tr = oil.OilTableRows.FirstOrDefault(o => o.itemCode == p.ripp_code);
                if (tr == null)
                {
                    continue;
                }
                var index = oil.OilTableRows.IndexOf(tr);
                var d     = oil.OilDatas[index];

                ps.Add(new RefineryAssaysRefineryAssayPlantDataGroupsPlantDataGroupPropertiesProperty()
                {
                    Name                   = p.name,
                    PropertyName           = p.property_name,
                    PropertyKey            = p.key,
                    PropertyQualifierValue = p.GetValue(d.calData),
                });
            }

            var plant = r.RefineryAssay.PlantDataGroups.PlantDataGroup;
            plant.Properties = ps;

            #endregion 原油信息

            #region 切割曲线

            OilDataSearchColAccess        oilDataColAccess = new OilDataSearchColAccess();
            List <OilDataSearchColEntity> OilDataCols      = oilDataColAccess.Get("1=1");

            OilDataSearchRowAccess        oilDataRowAccess = new OilDataSearchRowAccess();
            List <OilDataSearchRowEntity> OilDataRows      = oilDataRowAccess.Get("1=1");

            OilDataSearchAccess        oilDataSearchAccess = new OilDataSearchAccess();
            List <OilDataSearchEntity> allDatas            = oilDataSearchAccess.Get("oilInfoID = " + oil.ID).ToList();

            var cuts = new List <RefineryAssaysRefineryAssayPlantDataGroupsPlantDataGroupCutsCut>();

            BuildCut("石脑油", "15-140", "Naph");
            BuildCut("煤油", "140-240", "Kero");
            BuildCut("柴油", "240-350", "Disel");
            BuildCut("蜡油", "350-540", "VGO");
            BuildCut("渣油", ">540", "Reside");

            //构造切割曲线
            void BuildCut(string name1, string name2, string type)
            {
                var Cols = OilDataCols.Where(o => o.OilTableName.Contains(name1) && o.OilTableName.Contains(name2)).OrderBy(o => o.itemOrder).ToList();

                if (Cols.Count == 0)
                {
                    return;
                }
                var Rows = OilDataRows.Where(o => o.OilDataColID == Cols[0].ID).OrderBy(o => o.OilTableRow.itemOrder).ToList();

                if (Rows.Count == 0)
                {
                    return;
                }
                var TableRows = new List <OilTableRowEntity>();

                for (int i = 0; i < Rows.Count; i++)
                {
                    OilTableRowEntity oilTableRow = OilTableRowBll._OilTableRow.Where(o => o.ID == Rows[i].OilTableRowID).FirstOrDefault();
                    TableRows.Add(oilTableRow);
                }

                for (int i = 0; i < Cols.Count; i++)
                {
                    var Data = allDatas.Where(o => o.oilTableColID == Cols[i].OilTableColID).ToList();
                    if (Data?.Any() != true)
                    {
                        continue;
                    }

                    var cut = new RefineryAssaysRefineryAssayPlantDataGroupsPlantDataGroupCutsCut()
                    {
                        CutName = type,
                        Name    = type,
                        CutType = 0,
                    };

                    var ps2 = new List <RefineryAssaysRefineryAssayPlantDataGroupsPlantDataGroupCutsCutPropertiesProperty>();

                    foreach (var p in maps)
                    {
                        var tr = Data.FirstOrDefault(o => o.OilTableRow.itemCode == p.ripp_code);
                        if (tr == null)
                        {
                            continue;
                        }

                        ps2.Add(new RefineryAssaysRefineryAssayPlantDataGroupsPlantDataGroupCutsCutPropertiesProperty()
                        {
                            Name         = p.name,
                            PropertyName = p.property_name,
                            InputValue   = p.GetValue(tr.calData)
                        });
                    }

                    cut.Properties = ps2;
                    cuts.Add(cut);
                }
            }

            if (cuts.Any() == true)
            {
                plant.Cuts = cuts;
            }

            #endregion 切割曲线

            return(r);
        }
示例#18
0
        /// <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);
        }