Exemplo n.º 1
0
        /// <summary>
        /// 获取C库的校正值
        /// </summary>
        /// <param name="rangeSearchEntity"></param>
        /// <param name="oilInfoID">oilInfoID</param>
        /// <param name="value">查询的物性是否为原油信息表(true代表是)</param>
        /// <returns></returns>
        private static string getCalValueFromOilDataSearch(OilRangeSearchEntity rangeSearchEntity, int oilInfoID, EnumTableType tableType = EnumTableType.Info)
        {
            string result = string.Empty;

            OilDataSearchAccess oilDataSearchAccess = new OilDataSearchAccess();
            string sqlWhere = " oilInfoId ='" + oilInfoID.ToString() + "'" + "and oilTableRowID='" + rangeSearchEntity.OilTableRowID.ToString() + "'" + " and oilTableColId='" + rangeSearchEntity.OilTableColID + "'" + " and calData!=''";
            List <OilDataSearchEntity> oilDataSearchEntityList = oilDataSearchAccess.Get(sqlWhere);//获取对应物性的校正值

            if (oilDataSearchEntityList.Count != 0)
            {
                result = oilDataSearchEntityList.FirstOrDefault().calData;
            }

            //List<OilDataSearchEntity> calList = new List<OilDataSearchEntity>();
            //if (tableType == EnumTableType.Info)
            //{
            //    string itemCode = rangeSearchEntity.itemCode;
            //    string oilTableRowID = OilBll.GetOilTableRowIDFromOilTableRowByItemCode(itemCode, tableType).ToString();
            //    string sqlWhere = " oilInfoId ='" + oilInfoID.ToString() + "'" + "and oilTableRowID='" + oilTableRowID + "'" + " and oilTableColId='" + rangeSearchEntity.OilTableColID + "'" + " and calData!=''";
            //    calList = oilDataSearchAccess.Get(sqlWhere);//获取对应物性的校正值
            //}
            //else
            //{
            //    string sqlWhere = " oilInfoId ='" + oilInfoID.ToString() + "'" + "and oilTableRowID='" + rangeSearchEntity.OilTableRowID.ToString() + "'" + " and oilTableColId='" + rangeSearchEntity.OilTableColID + "'" + " and calData!=''";
            //    calList = oilDataSearchAccess.Get(sqlWhere);//获取对应物性的校正值
            //}

            return(result);
        }
Exemplo n.º 2
0
 /// <summary>
 /// 删除一条记录
 /// </summary>
 public void delete()
 {
     if (this.gridList.CurrentRow != null)
     {
         if (MessageBox.Show("是否要删除!", "信息提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
         {
             try
             {
                 string strID = this.gridList.CurrentRow.Cells["ID"].Value.ToString();
                 int    ID    = 0;
                 if (int.TryParse(strID, out ID))
                 {
                     this.IsBusy = true;
                     OilDataSearchAccess dataSearchAccess = new OilDataSearchAccess();
                     dataSearchAccess.deleteData("Delete from OilDataSearch where oilInfoID =" + ID);
                     this.IsBusy = false;
                 }
             }
             catch (Exception ex)
             {
                 Log.Error("数据管理" + ex);
             }
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 获取C库的校正值
        /// </summary>
        /// <param name="rangeSimilarEntity"></param>
        /// <param name="oilInfoID">oilInfoID</param>
        /// <param name="value">查询的物性是否为原油信息表(true代表是)</param>
        /// <returns></returns>
        private static string getCalValueFromOilDataSearch(OilSimilarSearchEntity rangeSimilarEntity, int oilInfoID)
        {
            string result = string.Empty;

            OilDataSearchAccess oilDataSearchAccess = new OilDataSearchAccess();
            string sqlWhere = " oilInfoId ='" + oilInfoID.ToString() + "'" + "and oilTableRowID='" + rangeSimilarEntity.OilTableRowID.ToString() + "'" + " and oilTableColId='" + rangeSimilarEntity.OilTableColID + "'" + " and calData!=''";
            List <OilDataSearchEntity> oilDataSearchEntityList = oilDataSearchAccess.Get(sqlWhere);//获取对应物性的校正值

            if (oilDataSearchEntityList.Count != 0)
            {
                result = oilDataSearchEntityList.FirstOrDefault().calData;
            }
            return(result);
        }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dataGridView"></param>
        /// <param name="strValue"></param>
        /// <param name="_columnIndex"></param>
        /// <param name="_rowIndex"></param>
        public void CPaste(DataGridView dataGridView, string strValue, int _columnIndex, int _rowIndex)
        {
            if (strValue == string.Empty)
            {
                return;
            }

            if (_columnIndex < 0 || _columnIndex >= dataGridView.Columns.Count)
            {
                return;
            }

            if (_rowIndex < 0 || _rowIndex >= dataGridView.Rows.Count)
            {
                return;
            }

            OilDataSearchEntity searchData = null;
            int oilTableColID = 0, oilTableRowID = 0;

            string colTag = dataGridView.Columns[_columnIndex].Tag == null ? string.Empty : dataGridView.Columns[_columnIndex].Tag.ToString();
            string rowTag = dataGridView.Rows[_rowIndex].Tag == null ? string.Empty : dataGridView.Rows[_rowIndex].Tag.ToString();

            if (colTag != string.Empty && rowTag != string.Empty)
            {
                if (int.TryParse(dataGridView.Columns[_columnIndex].Tag.ToString(), out oilTableColID) && int.TryParse(dataGridView.Rows[_rowIndex].Tag.ToString(), out oilTableRowID))
                {
                    searchData               = new OilDataSearchEntity();
                    searchData.calData       = strValue;
                    searchData.oilInfoID     = this._COilID;
                    searchData.oilTableColID = oilTableColID;
                    searchData.oilTableRowID = oilTableRowID;

                    OilDataSearchAccess dataSearch = new OilDataSearchAccess();
                    OilDataSearchEntity temp       = dataSearch.Get("oilInfoID = " + this._COilID + "and  oilTableColID = " + oilTableColID + "and  oilTableRowID = " + oilTableRowID).FirstOrDefault();
                    if (temp == null)
                    {
                        dataSearch.Insert(searchData);
                    }
                    else
                    {
                        dataSearch.Update(searchData, temp.ID.ToString());
                    }
                }
            }
        }
Exemplo n.º 5
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;
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="dataGridView"></param>
        public void CSave(DataGridView dataGridView)
        {
            dataGridView.EndEdit();
            for (int colIndex = 3; colIndex < dataGridView.Columns.Count; colIndex++)
            {
                for (int rowIndex = 0; rowIndex < dataGridView.Rows.Count; rowIndex++)
                {
                    OilDataSearchEntity searchData = null;
                    int oilTableColID = 0, oilTableRowID = 0;

                    string colTag = dataGridView.Columns[colIndex].Tag == null ? string.Empty : dataGridView.Columns[colIndex].Tag.ToString();
                    string rowTag = dataGridView.Rows[rowIndex].Tag == null ? string.Empty : dataGridView.Rows[rowIndex].Tag.ToString();
                    string strValue = dataGridView.Rows[rowIndex].Cells[colIndex].Value == null ? string.Empty : dataGridView.Rows[rowIndex].Cells[colIndex].Value.ToString();
                    if (colTag != string.Empty && rowTag != string.Empty)
                    {
                        if (int.TryParse(colTag, out oilTableColID) && int.TryParse(rowTag, out oilTableRowID))
                        {
                            OilDataSearchAccess dataSearch = new OilDataSearchAccess();
                            OilDataSearchEntity temp       = dataSearch.Get("oilInfoID = " + this._COilID + "and  oilTableColID = " + oilTableColID + "and  oilTableRowID = " + oilTableRowID).FirstOrDefault();
                            if (temp == null)
                            {
                                searchData               = new OilDataSearchEntity();
                                searchData.calData       = strValue;
                                searchData.oilInfoID     = this._COilID;
                                searchData.oilTableColID = oilTableColID;
                                searchData.oilTableRowID = oilTableRowID;
                                dataSearch.Insert(searchData);
                            }
                            else if (temp.calData != strValue)
                            {
                                searchData               = new OilDataSearchEntity();
                                searchData.calData       = strValue;
                                searchData.oilInfoID     = this._COilID;
                                searchData.oilTableColID = oilTableColID;
                                searchData.oilTableRowID = oilTableRowID;
                                dataSearch.Update(searchData, temp.ID.ToString());
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 相似查找,返回对应的原油ID
        /// </summary>
        /// <param name="oilProperty">相似查找条件的实体集合OilSimilarSearchEntityList</param>
        /// <returns></returns>
        public IDictionary <string, double> GetOilSimInfoCrudeIndex(IList <OilSimilarSearchEntity> similarSearchEntityList)
        {
            IDictionary <string, double> crudeIndexSimDic = new Dictionary <string, double>();

            #region "输入条件判断"
            IList <string> resultCrudeIndexList = new List <string>(); //存放满足条件的原油编号
            if (similarSearchEntityList == null)                       //查找条件为空
            {
                return(crudeIndexSimDic);
            }
            if (similarSearchEntityList.Count == 0)//查找条件为空
            {
                return(crudeIndexSimDic);
            }
            #endregion

            #region "初始化判断条件"
            string sqlWhere = "select distinct(oilInfoID) from OilDataSearch";
            OilDataSearchAccess oilDataSearchAccess        = new OilDataSearchAccess();
            List <int>          oilDataSearchOilInfoIDList = oilDataSearchAccess.getId(sqlWhere); //获取OilDataSearch表中的所有oilInfoID

            foreach (int oilInfoBID in oilDataSearchOilInfoIDList)                                //从C库中查找到的原油编号
            {
                OilInfoBEntity           bEntity  = OilBll.GetOilBByID(oilInfoBID);
                List <TempsimliarEntity> tempList = new List <TempsimliarEntity>();
                if (bEntity != null)
                {
                    tempSimliarDic[bEntity.crudeIndex] = tempList;
                }
            }

            #endregion

            #region "范围查找中And和or两种类型的判断的归类"
            IList <OilSimilarSearchEntity> searchAnd = new List <OilSimilarSearchEntity>(); //范围查找用(and条件)
            IList <OilSimilarSearchEntity> searchOr  = new List <OilSimilarSearchEntity>(); //范围查找用(or条件)
            foreach (OilSimilarSearchEntity currentOilSimilarSearchEntity in similarSearchEntityList)
            {
                if (currentOilSimilarSearchEntity.IsAnd && currentOilSimilarSearchEntity.RightParenthesis.Trim() == "")//如果该条件是And,添加到searchAnd中去
                {
                    searchAnd.Add(currentOilSimilarSearchEntity);
                    continue;
                }
                else if (!currentOilSimilarSearchEntity.IsAnd && currentOilSimilarSearchEntity.LeftParenthesis.Trim() == "(" && currentOilSimilarSearchEntity.RightParenthesis.Trim() == "")//如果该条件是Or,但不是最后一个Or,则添加到searchOr中去,暂时不进行计算
                {
                    searchOr.Add(currentOilSimilarSearchEntity);
                    continue;
                }
                else if (!currentOilSimilarSearchEntity.IsAnd && currentOilSimilarSearchEntity.LeftParenthesis.Trim() == "" && currentOilSimilarSearchEntity.RightParenthesis.Trim() == "")//如果该条件是Or,但不是最后一个Or,则添加到searchOr中去,暂时不进行计算
                {
                    searchOr.Add(currentOilSimilarSearchEntity);
                    continue;
                }
                else if (currentOilSimilarSearchEntity.RightParenthesis.Trim() == ")")////如果该条件是Or,且是括号中的最后一个Or,则添加到searchOr中去,并进行或的计算
                {
                    #region "Or的计算"
                    searchOr.Add(currentOilSimilarSearchEntity);

                    foreach (int ID in oilDataSearchOilInfoIDList)//根据ID循环每一条原油
                    {
                        OilInfoBEntity infoB = OilBll.GetOilBByID(ID);
                        if (!tempSimliarDic.Keys.Contains(infoB.crudeIndex))
                        {
                            continue;
                        }

                        if (searchOr.Count <= 0)
                        {
                            continue;
                        }

                        TempsimliarEntity tempsimliarEntity = getDataFromOrSimilarSearchList(searchOr, ID);
                        if (tempSimliarDic.Keys.Contains(infoB.crudeIndex))
                        {
                            tempSimliarDic[infoB.crudeIndex].Add(tempsimliarEntity);
                        }
                    }
                    searchOr.Clear();//该Or括号计算完后,情况OrList,用于后面的Or括号计算
                    continue;

                    #endregion
                }
            }
            #endregion

            #region "处理And条件或计算的结果和And条件取交集"
            foreach (int oilInfoID in oilDataSearchOilInfoIDList)//根据ID循环每一条原油
            {
                OilInfoBEntity infoB = OilBll.GetOilBByID(oilInfoID);
                if (!tempSimliarDic.Keys.Contains(infoB.crudeIndex))
                {
                    continue;
                }
                if (searchAnd.Count <= 0)
                {
                    continue;
                }

                TempsimliarEntity tempsimliarEntity = getDataFromAndSimilarSearchList(searchAnd, oilInfoID);
                if (tempSimliarDic.Keys.Contains(infoB.crudeIndex))
                {
                    tempSimliarDic[infoB.crudeIndex].Add(tempsimliarEntity);
                }
            }
            #endregion

            foreach (string key in tempSimliarDic.Keys)
            {
                double sum = 0, sumWeight = 0;
                foreach (TempsimliarEntity tempsimliarEntity in tempSimliarDic[key])
                {
                    if (tempsimliarEntity.Match == 0 || tempsimliarEntity.Match.Equals(double.NaN))
                    {
                        sum       = double.NaN;
                        sumWeight = tempsimliarEntity.Weight;
                    }
                    else
                    {
                        sum       += tempsimliarEntity.Match;
                        sumWeight += tempsimliarEntity.Weight;
                    }
                }

                if (sumWeight != 0 && !sum.Equals(double.NaN))
                {
                    crudeIndexSimDic.Add(key, sum / sumWeight);
                }
            }

            return(crudeIndexSimDic);
        }
Exemplo n.º 8
0
        Dictionary <string, List <TempsimliarEntity> > tempSimliarDic = new Dictionary <string, List <TempsimliarEntity> >();//存储暂时的相似查找的原有编号和相识度。

        #region "范围查询函数"
        /// <summary>
        /// 范围查询函数
        /// 根据原油属性查询找到满足条件的原油的ID
        /// </summary>
        /// <param name="cutPropertys">要查询的属性(包括范围)列表</param>
        /// <returns>key为原油数据中的InfoID,值为该ID满足条件的次数或null</returns>
        public Dictionary <int, int> GetInfoID(IList <OilRangeSearchEntity> cutPropertys)
        {
            if (cutPropertys.Count == 0)
            {
                return(null);
            }

            Dictionary <int, int> infoIDAnd = new Dictionary <int, int>();     //范围查询满足and条件的oilInfoId
            Dictionary <int, int> infoIDOr  = new Dictionary <int, int>();     //范围查询满足or条件的oilInfoId
            string sqlWhereAnd = "";                                           //按属性或查询原油数据表,既把查询属性的所有原油数据全查出来,只查关于And的选项
            string sqlWhereOr  = "";                                           //按属性或查询原油数据表,只查关于or选项的选项。
            Dictionary <int, int> resutlDictory = new Dictionary <int, int>(); //返回最后查询的合适ID的结果

            OilDataSearchAccess access = new OilDataSearchAccess();

            foreach (var item in cutPropertys)
            {
                if (item.IsAnd)
                {
                    sqlWhereAnd += "or  oilTableRowID= '" + item.OilTableRowID + "' ";
                }
                else
                {
                    sqlWhereOr += "or  oilTableRowID= '" + item.OilTableRowID + "' ";
                }
            }
            /*获取And条件下适合的数据*/
            if ("" != sqlWhereAnd)
            {
                infoIDAnd = GetAndOilInfoId(cutPropertys, sqlWhereAnd, access);
            }

            /*获取Or条件下适合的数据,返回or条件下只要满足一个条件的id*/
            if ("" != sqlWhereOr)
            {
                infoIDOr = GetOrOilInfoID(cutPropertys, sqlWhereOr, access);
            }

            /*求And条件下满足的ID和or条件下满足条件的ID的交集即为此次查询的结果
             * 求出and条件和or条件的个数,如果如果cutProperties只有一个条件则返回其中不为空的数据
             *如果and的个数为0则返回or条件查询出的数据,如果or为0则返回and查询条件的结果,
             *如果and 和or的个数都不为0的话则求两个条件的交集即为查询的结果
             */
            #region
            int andCount = cutPropertys.Where(s => s.IsAnd == true).Count();
            int orCount  = cutPropertys.Count() - andCount;
            if (cutPropertys.Count() == 1)
            {
                return(cutPropertys[0].IsAnd == true ? infoIDAnd : infoIDOr);
            }
            else if (orCount == 0)
            {
                return(infoIDAnd);//or为0则只返回and的查询结果集
            }
            else if (andCount == 0)
            {
                return(infoIDOr);//and为0则只返回or的查询结果集
            }
            else
            {
                foreach (var item in infoIDOr)
                {
                    if (infoIDAnd.ContainsKey(item.Key))
                    {
                        resutlDictory[item.Key] = item.Value;
                    }
                }
                return(resutlDictory);//返回or查询数据和and查询数据的交集
            }
            #endregion
        }
Exemplo n.º 9
0
        /// <summary>
        /// 范围查询-从C库查找满足条件的原油编号
        /// </summary>
        /// <returns></returns>
        public static IDictionary <string, double> GetRangOilInfoCrudeIndex(IList <OilRangeSearchEntity> rangeSearchEntityList)
        {
            int count = 0; //输入条件的个数
            IDictionary <string, double> crudeIndexRanDic = new Dictionary <string, double>();

            //IList<string> resultCrudeIndexList = new List<string>();//存放满足条件的原油编号

            #region "输入条件判断"
            if (rangeSearchEntityList == null)//查找条件为空
            {
                return(crudeIndexRanDic);
            }
            if (rangeSearchEntityList.Count == 0)//查找条件为空
            {
                return(crudeIndexRanDic);
            }
            #endregion

            #region "标志条件"
            Dictionary <string, int> oilInfoCrudeIndex_And_Result = new Dictionary <string, int>();//满足条件的原油对应值为1,不满足为0
            string sqlWhere = "select distinct(oilInfoID) from OilDataSearch";
            OilDataSearchAccess oilDataSearchAccess         = new OilDataSearchAccess();
            List <int>          oilDataSearchOilInfoBIDList = oilDataSearchAccess.getId(sqlWhere); //获取OilDataSearch表中的所有oilInfoID

            foreach (int oilInfoBID in oilDataSearchOilInfoBIDList)                                //从C库中查找到的原油编号
            {
                OilInfoBEntity bEntity = OilBll.GetOilBByID(oilInfoBID);
                if (bEntity != null)
                {
                    oilInfoCrudeIndex_And_Result[bEntity.crudeIndex] = 0;
                }
            }
            #endregion

            #region "范围查找中And和or两种类型的判断的归类"
            IList <OilRangeSearchEntity> searchAnd = new List <OilRangeSearchEntity>(); //范围查找用(and条件)
            IList <OilRangeSearchEntity> searchOr  = new List <OilRangeSearchEntity>(); //范围查找用(or条件)
            foreach (OilRangeSearchEntity currentOilRangeSearchEntity in rangeSearchEntityList)
            {
                if (currentOilRangeSearchEntity.IsAnd && currentOilRangeSearchEntity.RightParenthesis.Trim() == "")//如果该条件是And,添加到searchAnd中去
                {
                    searchAnd.Add(currentOilRangeSearchEntity);
                    count++;
                    continue;
                }
                else if (!currentOilRangeSearchEntity.IsAnd && currentOilRangeSearchEntity.RightParenthesis.Trim() != ")")//如果该条件是Or,但不是最后一个Or,则添加到searchOr中去,暂时不进行计算
                {
                    searchOr.Add(currentOilRangeSearchEntity);
                    continue;
                }
                else if (currentOilRangeSearchEntity.RightParenthesis.Trim() == ")")////如果该条件是Or,且是括号中的最后一个Or,则添加到searchOr中去,并进行或的计算
                {
                    #region "Or的计算"
                    searchOr.Add(currentOilRangeSearchEntity);

                    foreach (int oilInfoBID in oilDataSearchOilInfoBIDList)//从C库中查找到的原油编号
                    {
                        OilInfoBEntity infoB = OilBll.GetOilBByID(oilInfoBID);
                        int            temp  = getDataFromOrRangeSearchList(searchOr, oilInfoBID);
                        oilInfoCrudeIndex_And_Result[infoB.crudeIndex] += temp;
                    }
                    count++;
                    searchOr.Clear();//该Or括号计算完后,情况OrList,用于后面的Or括号计算
                    continue;
                    #endregion
                }
            }
            #endregion

            #region "处理And条件(或计算的结果和And条件取交集"
            foreach (int oilInfoBID in oilDataSearchOilInfoBIDList)//从C库中查找到的原油编号
            {
                OilInfoBEntity infoB = OilBll.GetOilBByID(oilInfoBID);
                oilInfoCrudeIndex_And_Result[infoB.crudeIndex] += getDataFromAndRangeSearchList(searchAnd, oilInfoBID);
            }
            #endregion

            foreach (string key in oilInfoCrudeIndex_And_Result.Keys)
            {
                if (oilInfoCrudeIndex_And_Result[key] == count)
                {
                    crudeIndexRanDic.Add(key, 0);
                }
            }
            searchAnd.Clear();
            searchOr.Clear();
            return(crudeIndexRanDic);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 返回And条件下的OilInfoID
        /// </summary>
        /// <param name="cutPropertys"></param>
        /// <param name="sqlWhereAnd"></param>
        /// <param name="access"></param>
        /// <returns></returns>
        private Dictionary <int, int> GetAndOilInfoId(IList <OilRangeSearchEntity> cutPropertys, string sqlWhereAnd, OilDataSearchAccess access)
        {
            sqlWhereAnd = " (" + sqlWhereAnd.Substring(2) + ") and calData!='' ";
            IList <OilDataSearchEntity> oilDatas = access.Get(sqlWhereAnd);
            Dictionary <int, int>       infoID   = new Dictionary <int, int>();

            //对每条原油数据,遍历属性列表,如果原油属性=属性列表中的某个属性,并且在查询范围内。
            //如果字典键值中存在该原油的OilInfoID则该键对应的值加1,如果不存在则该键值为1.
            foreach (OilDataSearchEntity oilData in oilDatas)
            {
                foreach (var cutProperty in cutPropertys.Where(s => s.IsAnd == true))
                {
                    float calData = 0;
                    if (float.TryParse(oilData.calData, out calData))
                    {//判断字符串是否能够转换为float类型
                    }
                    else
                    {
                        calData = -9999999;
                    }
                    if (oilData.OilTableRow.itemCode == cutProperty.itemCode && oilData.oilTableColID == cutProperty.OilTableColID && calData > float.Parse(cutProperty.downLimit) && float.Parse(cutProperty.upLimit) > calData)
                    {
                        if (infoID.Keys.Contains(oilData.oilInfoID))
                        {
                            infoID[oilData.oilInfoID] = infoID[oilData.oilInfoID] + 1;
                        }
                        else
                        {
                            infoID[oilData.oilInfoID] = 1;
                        }
                    }
                }
            }
            //键的值=属性个数值符合要求
            Dictionary <int, int> infoID2 = new Dictionary <int, int>();

            foreach (var item in infoID)
            {
                if (item.Value == cutPropertys.Where(s => s.IsAnd == true).Count())
                {
                    infoID2[item.Key] = item.Value;
                }
            }
            return(infoID2);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 初始化表格格式
        /// </summary>
        private void initDataGridView()
        {
            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 = " + this._oilInfoID).ToList();

            #region "原油信息"
            //List<OilDataSearchColEntity> oilInfoCols = OilDataCols.Where(o =>o.OilTableName == "原油信息").ToList();
            //List<OilDataSearchRowEntity> oilInfoRows = OilDataRows.Where(o => o.OilDataColID == oilInfoCols[0].ID).ToList();

            //List<OilTableRowEntity> oilInfoTableRows = new List<OilTableRowEntity>();
            //for (int i = 0; i < oilInfoRows.Count; i++)
            //{
            //    OilTableRowEntity oilTableRow = OilTableRowBll._OilTableRow.Where(o => o.ID == oilInfoRows[i].OilTableRowID).FirstOrDefault();
            //    oilInfoTableRows.Add(oilTableRow);
            //}

            //#region "做列字典和行字典"
            ////Dictionary<int, OilDataSearchColEntity> colDic = new Dictionary<int, OilDataSearchColEntity>();//判断有多少列
            ////foreach (var temp in oilInfoCols)
            ////{
            ////    if (!colDic.Keys.Contains(temp.OilTableColID))
            ////    {
            ////        colDic.Add(temp.OilTableColID, temp);
            ////    }
            ////}

            //Dictionary<string, int> rowIDDic = new Dictionary<string, int>();//表的行和oiltableRowID对应
            //int rowID = 0;//设置行ID=0
            //foreach (var temp in oilInfoTableRows)
            //{
            //    if (!rowIDDic.Keys.Contains(temp.itemCode))
            //    {
            //        rowIDDic.Add(temp.itemCode, rowID);
            //        rowID++;
            //    }
            //}
            //#endregion

            //#region "初列:序号,项目,代码"
            //this.dataGridView1.Columns.Clear();

            //DataGridViewTextBoxColumn colID = new DataGridViewTextBoxColumn()
            //{
            //    Name = "序号",
            //    AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells,
            //    ReadOnly = true
            //};
            //DataGridViewTextBoxColumn Code = new DataGridViewTextBoxColumn()
            //{
            //    Name = "itemCode",
            //    AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells,
            //    ReadOnly = true
            //};
            //DataGridViewTextBoxColumn Name = new DataGridViewTextBoxColumn()
            //{
            //    Name = "itemName",
            //    AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells,
            //    ReadOnly = true
            //};

            //this.dataGridView1.Columns.Add(colID);
            //this.dataGridView1.Columns.Add(Code);
            //this.dataGridView1.Columns.Add(Name);

            //foreach (var temp in oilInfoCols)
            //{
            //    DataGridViewTextBoxColumn column = new DataGridViewTextBoxColumn
            //    {
            //        HeaderText = temp.OilTableName,
            //        Name = temp.OilTableName,
            //        AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells,
            //        Width = 200,
            //        Tag = temp.OilTableColID
            //    };
            //    this.dataGridView1.Columns.Add(column);
            //}
            //#endregion

            //#region "初始化所有行"
            //this.dataGridView1.Rows.Clear();
            //int col = 0;
            //foreach (OilTableRowEntity temp in oilInfoTableRows)
            //{
            //    int index = this.dataGridView1.Rows.Add();
            //    this.dataGridView1.Rows[index].Cells["序号"].Value = col;
            //    this.dataGridView1.Rows[index].Cells["itemCode"].Value = temp.itemCode;
            //    this.dataGridView1.Rows[index].Cells["itemName"].Value = temp.itemName;
            //    this.dataGridView1.Rows[index].Tag = temp.ID;
            //    col++;
            //}
            //#endregion

            //this.dataGridView1.Rows[rowIDDic["CNA"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.crudeName;
            //this.dataGridView1.Rows[rowIDDic["ENA"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.englishName;
            //this.dataGridView1.Rows[rowIDDic["IDC"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.crudeIndex;
            //this.dataGridView1.Rows[rowIDDic["COU"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.country;
            //this.dataGridView1.Rows[rowIDDic["GRC"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.region;
            //this.dataGridView1.Rows[rowIDDic["ADA"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.receiveDate;
            //this.dataGridView1.Rows[rowIDDic["ALA"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.assayLab;

            //this.dataGridView1.Rows[rowIDDic["AER"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.assayer;
            //this.dataGridView1.Rows[rowIDDic["SR"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.sourceRef;
            //this.dataGridView1.Rows[rowIDDic["ASC"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.assayCustomer;
            //this.dataGridView1.Rows[rowIDDic["RIN"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.reportIndex;
            //this.dataGridView1.Rows[rowIDDic["CLA"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.type;
            //this.dataGridView1.Rows[rowIDDic["TYP"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.classification;
            //this.dataGridView1.Rows[rowIDDic["SCL"]].Cells[oilInfoCols[0].OilTableName].Value = oilInfoB.sulfurLevel;
            //InitStyle(this.dataGridView1);
            #endregion

            InitDataGridView("原油信息", this.dataGridView1, OilDataCols, OilDataRows, allDatas);
            InitDataGridView("原油性质", this.dataGridView2, OilDataCols, OilDataRows, allDatas);
            InitDataGridView("石脑油", this.dataGridView3, OilDataCols, OilDataRows, allDatas);
            InitDataGridView("航煤", this.dataGridView4, OilDataCols, OilDataRows, allDatas);
            InitDataGridView("柴油", this.dataGridView5, OilDataCols, OilDataRows, allDatas);
            InitDataGridView("VGO", this.dataGridView6, OilDataCols, OilDataRows, allDatas);
            InitDataGridView("渣", this.dataGridView7, OilDataCols, OilDataRows, allDatas);
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 以Lib的形式导出B库
        /// </summary>
        /// <param name="fileName"></param>
        private void outLib(string fileName)
        {
            this.gridList.EndEdit();
            string strWhere  = "";  //获取选中的原油ID,用于在oilInfoB表中获取数据
            string strWhere2 = "";  //获取选中的原油ID,用于在oilDataB表中获取数据

            //string strWhereDataSearch = ""; //获取选中的原油ID,用于在oilDataSearch表中获取数据
            foreach (DataGridViewRow row in this.gridList.Rows)
            {
                if (bool.Parse(row.Cells["select"].Value.ToString()) == true)
                {
                    strWhere  += " or ID=" + int.Parse(row.Cells["ID"].Value.ToString());
                    strWhere2 += " or oilInfoID=" + int.Parse(row.Cells["ID"].Value.ToString());
                    //strWhereDataSearch += " or oilInfoID=" + int.Parse(row.Cells["ID"].Value.ToString());
                }
            }
            strWhere  = strWhere.Trim().Substring(2);
            strWhere2 = strWhere2.Trim().Substring(2);
            // strWhereDataSearch = strWhere2.Trim().Substring(2);

            #region "要导入的oilInfoB数据"
            OilInfoOutAccess  oilInfoOutAccess = new OilInfoOutAccess("OilInfoB"); //导出数据连接
            List <OilInfoOut> oilInfoOuts      = oilInfoOutAccess.Get(strWhere);   //oilInfoB表中获取数据
            #endregion

            #region "B库未切割的数据"
            OilDataBAccess        acess = new OilDataBAccess();
            List <OilDataBEntity> OilDataBEntityAlls = acess.Get(strWhere2);          //在OilDataB表中获取B库要的性质表,GC标准表数据
            List <OilDataBEntity> OilDataBEntityBs   = OilDataBEntityAlls.Where(c => c.OilTableRow.oilTableTypeID == (int)EnumTableType.Whole || c.OilTableRow.oilTableTypeID == (int)EnumTableType.GCLevel).ToList();


            List <OilDataOut> oilDataAlls = new List <OilDataOut>();
            foreach (OilDataBEntity OilDataBEntity in OilDataBEntityBs)  //把OilDataBEntity数据转为OilDataBOut数据
            {
                OilDataOut oilDataOut = new OilDataOut();
                oilDataOut.ID            = OilDataBEntity.ID;
                oilDataOut.oilInfoID     = OilDataBEntity.oilInfoID;
                oilDataOut.oilTableColID = OilDataBEntity.oilTableColID;
                oilDataOut.oilTableRowID = OilDataBEntity.oilTableRowID;
                oilDataOut.labData       = "";
                oilDataOut.calData       = OilDataBEntity.calData;
                oilDataAlls.Add(oilDataOut);
            }
            #endregion

            #region "B库切割后(查询库)的数据"
            OilDataSearchAccess        oilDataSearchAccess     = new OilDataSearchAccess();
            List <OilDataSearchEntity> oilDataSearchEntityList = oilDataSearchAccess.Get(strWhere2); //在oilDataSearch表中获取C库要数据
            List <OilDataSearchOut>    oilDataSearchAlls       = new List <OilDataSearchOut>();
            foreach (OilDataSearchEntity OilDataSearchEntity in oilDataSearchEntityList)             //把OilDataSearchEntity数据转为OilDataSearchOut数据
            {
                OilDataSearchOut oilDataSearchOut = new OilDataSearchOut();
                oilDataSearchOut.ID            = OilDataSearchEntity.ID;
                oilDataSearchOut.oilInfoID     = OilDataSearchEntity.oilInfoID;
                oilDataSearchOut.oilTableColID = OilDataSearchEntity.oilTableColID;
                oilDataSearchOut.oilTableRowID = OilDataSearchEntity.oilTableRowID;
                oilDataSearchOut.labData       = "";
                oilDataSearchOut.calData       = OilDataSearchEntity.calData;
                oilDataSearchAlls.Add(oilDataSearchOut);
            }
            #endregion

            #region "新建OutLib"
            OutLib outLib = new OutLib();
            OilTableRowOutAccess oilTableRowAccess = new OilTableRowOutAccess();
            OilTableColOutAccess oilTableColAccess = new OilTableColOutAccess();
            CurveTypeAccess      curveTypeAccess   = new CurveTypeAccess();   //添加曲线类别
            outLib.oilTableRows = oilTableRowAccess.Get("1=1");               //获取oilTableRow表中所有行
            outLib.oilTableCols = oilTableColAccess.Get("1=1");               //获取oilTableCol表中所有列
            outLib.curveTypes   = curveTypeAccess.Get("1=1");                 //添加曲线类别
            #endregion

            #region "根据选择原油编号来选择原油曲线类型"
            CurveAccess        curveAccess = new CurveAccess();
            CurveDataAccess    dataAccess  = new CurveDataAccess();
            List <CurveEntity> curvesAll   = new List <CurveEntity>();
            curvesAll = curveAccess.Get(strWhere2);            //获取选中原油的所有曲线
            #endregion

            #region "根据选择原油编号的选择原油曲线类型来选择曲线对应的数据"
            string strWherecurveID = "";//根据选中的原有的曲线ID来选择对应的曲线数据
            foreach (var curve in curvesAll)
            {
                strWherecurveID += " or curveID=" + curve.ID;
            }
            List <CurveDataEntity> curveDatasAll = new List <CurveDataEntity>();
            if (strWherecurveID.Length > 2)
            {
                strWherecurveID = strWherecurveID.Trim().Substring(2);
                curveDatasAll   = dataAccess.Get(strWherecurveID); //获取选中原油的所有曲线的所有曲线数据
            }
            #endregion


            foreach (OilInfoOut oilInfoOut in oilInfoOuts)                                                          //循环查看导出了多少条数据
            {
                oilInfoOut.oilDatas          = oilDataAlls.Where(c => c.oilInfoID == oilInfoOut.ID).ToList();       //添加oilDatas数据
                oilInfoOut.oilDataSearchOuts = oilDataSearchAlls.Where(c => c.oilInfoID == oilInfoOut.ID).ToList(); //添加oilDataSearchs数据
                oilInfoOut.curves            = curvesAll.Where(c => c.oilInfoID == oilInfoOut.ID).ToList();         //添加一条原油数据的曲线

                foreach (CurveEntity curve in oilInfoOut.curves)                                                    //添加一条原油数据的曲线的曲线点数据
                {
                    curve.curveDatas = new List <CurveDataEntity>();
                    curve.curveDatas = curveDatasAll.Where(c => c.curveID == curve.ID).ToList();
                }
                outLib.oilInfoOuts.Add(oilInfoOut);                 //构建一条一条的原油信息,形成原油列表
            }
            Serialize.Write <OutLib>(outLib, fileName);
        }
Exemplo n.º 14
0
        /// <summary>
        /// 表格控件绑定
        /// </summary>
        public void InitGridListBind()
        {
            dgvHeader.SetAppDataBaseBColHeader(this.gridList);

            OilInfoBAccess         acess   = new OilInfoBAccess();
            IList <OilInfoBEntity> oilInfo = acess.Get(this._sqlWhere);

            OilDataSearchAccess dataSearchAccess = new OilDataSearchAccess();

            //绑定数据
            for (int i = 0; i < oilInfo.Count; i++)
            {
                List <OilDataSearchEntity> dataList = dataSearchAccess.Get("oilInfoID =" + oilInfo[i].ID).ToList();
                if (dataList.Count > 0)
                {
                    List <OilDataSearchEntity> oilinfoDataList = dataList.Where(o => o.OilTableTypeID == (int)EnumTableType.Info).ToList();
                    #region "日期处理"
                    string receiveDate = oilInfo[i].receiveDate == null ? string.Empty : oilInfo[i].receiveDate.Value.ToString(dateFormat);
                    string updataDate  = string.Empty;
                    if (oilInfo[i].updataDate != string.Empty)
                    {
                        var updataDateTime = oilDataCheck.GetDate(oilInfo[i].updataDate);
                        updataDate = updataDateTime == null ? string.Empty : updataDateTime.Value.ToString(LongDateFormat);
                    }
                    #endregion
                    int rowIndex = this.gridList.Rows.Add();
                    this.gridList.Rows[rowIndex].Cells["ID"].Value = oilInfo[i].ID;
                    foreach (var data in oilinfoDataList)
                    {
                        switch (data.OilTableRow.itemCode)
                        {
                        case "CNA":
                            this.gridList.Rows[rowIndex].Cells["原油名称"].Value = data.calData;
                            break;

                        case "ENA":
                            this.gridList.Rows[rowIndex].Cells["英文名称"].Value = data.calData;
                            break;

                        case "IDC":
                            this.gridList.Rows[rowIndex].Cells["原油编号"].Value = data.calData;
                            break;

                        case "COU":
                            this.gridList.Rows[rowIndex].Cells["产地国家"].Value = data.calData;
                            break;

                        case "GRC":
                            this.gridList.Rows[rowIndex].Cells["地理区域"].Value = data.calData;
                            break;


                        case "ADA":
                            this.gridList.Rows[rowIndex].Cells["评价日期"].Value = data.calData;
                            break;

                        case "UDD":
                            this.gridList.Rows[rowIndex].Cells["入库日期"].Value = data.calData;
                            break;

                        case "SR":
                            this.gridList.Rows[rowIndex].Cells["数据来源"].Value = data.calData;
                            break;

                        case "CLA":
                            this.gridList.Rows[rowIndex].Cells["类别"].Value = data.calData;
                            break;


                        case "TYP":
                            this.gridList.Rows[rowIndex].Cells["基属"].Value = data.calData;
                            break;

                        case "SCL":
                            this.gridList.Rows[rowIndex].Cells["硫水平"].Value = data.calData;
                            break;

                        case "ACL":
                            this.gridList.Rows[rowIndex].Cells["酸水平"].Value = data.calData;
                            break;
                        }
                    }
                    //this.gridList.Rows.Add(
                    //            oilInfo[i].ID,
                    //            oilInfo[i].crudeName,
                    //            oilInfo[i].englishName,
                    //            oilInfo[i].crudeIndex,
                    //            oilInfo[i].country,
                    //            oilInfo[i].region,
                    //            receiveDate,
                    //            updataDate,
                    //            oilInfo[i].sourceRef,
                    //            oilInfo[i].type,
                    //            oilInfo[i].classification,
                    //            oilInfo[i].sulfurLevel,
                    //            oilInfo[i].acidLevel);
                }
            }
            //lbResult.Text = "共有" + oilInfo.Count.ToString() + "条信息满足条件。";
        }
Exemplo n.º 15
0
        /// <summary>
        /// 相似查找的确定按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void btnSimilarSubmit_Click(object sender, EventArgs e)
        {
            if (this.similarListView.Items.Count <= 0)
            {
                return;
            }
            try
            {
                this.StartWaiting();
                this._similarSearchList = new List <OilSimilarSearchEntity>();
                #region "相似查找实体集合"
                OilDataSearchAccess oilDataSearchAccess = new OilDataSearchAccess();
                foreach (ListViewItem item in this.similarListView.Items)
                {
                    OilSimilarSearchEntity similarSearch = new OilSimilarSearchEntity();
                    similarSearch.ItemCode         = item.Tag.ToString();
                    similarSearch.LeftParenthesis  = item.SubItems[0].Tag.ToString();
                    similarSearch.OilTableColID    = Convert.ToInt32(item.SubItems[1].Tag.ToString());
                    similarSearch.OilTableRowID    = Convert.ToInt32(item.SubItems[3].Tag.ToString());
                    similarSearch.Fvalue           = Convert.ToSingle(item.SubItems[5].Tag.ToString());
                    similarSearch.Weight           = Convert.ToSingle(item.SubItems[7].Tag.ToString());
                    similarSearch.RightParenthesis = item.SubItems[8].Tag.ToString();
                    similarSearch.FracitonName     = item.SubItems[1].Text;
                    similarSearch.ItemName         = item.SubItems[3].Text;


                    string sqlWhere = "oilTableRowID='" + similarSearch.OilTableRowID.ToString() + "'" + " and oilTableColId='" + similarSearch.OilTableColID + "'" + " and calData!=''";
                    List <OilDataSearchEntity> oilDataSearchEntityList = oilDataSearchAccess.Get(sqlWhere);//获取对应物性的校正值

                    float?MaxValue = float.MinValue, MinValue = float.MaxValue;
                    if (oilDataSearchEntityList.Count > 0)
                    {
                        MaxValue = oilDataSearchEntityList.Max(o => o.fCal);
                        MinValue = oilDataSearchEntityList.Min(o => o.fCal);

                        MaxValue = MaxValue > similarSearch.Fvalue ? MaxValue : similarSearch.Fvalue; //如果最大值比基础值要小,则最大值取基础值
                        MinValue = MinValue < similarSearch.Fvalue ? MinValue : similarSearch.Fvalue; //如果最小值比基础值要大,则最小值取基础值
                    }

                    if (!MaxValue.Equals(float.MinValue) && !MinValue.Equals(float.MaxValue) && MaxValue != null && MinValue != null)
                    {
                        similarSearch.Diff = MaxValue.Value - MinValue.Value;
                    }
                    else
                    {
                        similarSearch.Diff = 0;
                    }

                    if (this.similarListView.Items.Count == 1)
                    {
                        similarSearch.IsAnd = true;
                    }
                    else
                    {
                        similarSearch.IsAnd = item.SubItems[9].Tag.ToString() == "And" ? true : false;
                    }
                    this._similarSearchList.Add(similarSearch);
                }
                #endregion

                #region "当前显示原油的集合"
                List <CrudeIndexIDAEntity> currentCrudeIndexIDList = new List <CrudeIndexIDAEntity>();
                foreach (DataGridViewRow row in this.gridList.Rows)
                {
                    CrudeIndexIDAEntity tempCrudeIndexIDAEntity = new CrudeIndexIDAEntity();
                    tempCrudeIndexIDAEntity.ID         = Convert.ToInt32(row.Cells["ID"].Value.ToString());
                    tempCrudeIndexIDAEntity.crudeIndex = row.Cells["原油编号"].Value.ToString();
                    tempCrudeIndexIDAEntity.crudeName  = row.Cells["原油名称"].Value.ToString();
                    currentCrudeIndexIDList.Add(tempCrudeIndexIDAEntity);
                }
                #endregion

                OilBll oilBll = new OilBll();

                IDictionary <string, double> CrudeIndexSumDic = oilBll.GetOilSimInfoCrudeIndex(this._similarSearchList); //从C库获取满足条件的原油编号

                GetSimSearchResult(CrudeIndexSumDic, currentCrudeIndexIDList);                                           //绑定控件
            }
            catch (Exception ex)
            {
                Log.Error("原油B库相似查找错误:" + ex.ToString());
                return;
            }
            finally
            {
                this.StopWaiting();
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// 生成C库
        /// </summary>
        public override void newC()
        {
            string strID      = this.gridList.CurrentRow.Cells["ID"].Value.ToString();
            string crudeIndex = this.gridList.CurrentRow.Cells["原油编号"].Value.ToString();
            int    ID         = 0;

            if (int.TryParse(strID, out ID))
            {
                OilDataSearchAccess        dataSearchAccess = new OilDataSearchAccess();
                List <OilDataSearchEntity> dataList         = dataSearchAccess.Get("oilInfoID =" + ID).ToList();
                if (dataList.Count > 0)
                {
                    DialogResult r = MessageBox.Show("原油" + crudeIndex + "的查询库数据已经存在是否替换?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (r == DialogResult.Yes)
                    {
                        dataSearchAccess.deleteData("Delete from OilDataSearch where oilInfoID =" + ID);

                        OilInfoBEntity oilB = OilBll.GetOilByCrudeIndex(crudeIndex);
                        OilInfoEntity  oilA = OilBll.GetOilById(crudeIndex);
                        if (oilA == null)
                        {
                            OilBll.SaveC(oilB);
                        }
                        else
                        {
                            OilBll.SaveC(oilA, oilB);
                        }
                        MessageBox.Show("原油" + crudeIndex + "生成查询库成功!", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                        FrmMain frmMain             = this.MdiParent as FrmMain;
                        DatabaseC.FrmOilDataC child = (DatabaseC.FrmOilDataC)frmMain.GetChildFrm(crudeIndex + "C");

                        if (child != null)
                        {
                            MessageBox.Show("原油" + crudeIndex + "的数据窗体需关闭重新打开才有效!", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                        }
                    }
                }
                else
                {
                    DialogResult r = MessageBox.Show("是否保存数据到快速查询库!", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (r == DialogResult.Yes)
                    {
                        dataSearchAccess.deleteData("Delete from OilDataSearch where oilInfoID =" + ID);

                        OilInfoBEntity oilB = OilBll.GetOilByCrudeIndex(crudeIndex);
                        OilInfoEntity  oilA = OilBll.GetOilById(crudeIndex);
                        if (oilA == null)
                        {
                            OilBll.SaveC(oilB);
                        }
                        else
                        {
                            OilBll.SaveC(oilA, oilB);
                        }
                        MessageBox.Show("原油" + crudeIndex + "生成查询库成功!", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                        FrmMain frmMain             = this.MdiParent as FrmMain;
                        DatabaseC.FrmOilDataC child = (DatabaseC.FrmOilDataC)frmMain.GetChildFrm(crudeIndex + "C");

                        if (child != null)
                        {
                            MessageBox.Show("原油" + crudeIndex + "的数据窗体需关闭重新打开才有效!", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("应用库无此条原油!", "警告信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// 获取or条件下的满足条件的oilInfoID
        /// </summary>
        /// <param name="cutPropertys"></param>
        /// <param name="sqlWhereOr"></param>
        /// <param name="access"></param>
        /// <returns>满足条件的OilInfoId</returns>
        private Dictionary <int, int> GetOrOilInfoID(IList <OilRangeSearchEntity> cutPropertys, string sqlWhereOr, OilDataSearchAccess access)
        {
            sqlWhereOr = " (" + sqlWhereOr.Substring(2) + ") and calData!='' ";
            //OilDataAccess acessOr = new OilDataAccess();
            IList <OilDataSearchEntity> oilDatasOr = access.Get(sqlWhereOr);
            Dictionary <int, int>       infoID     = new Dictionary <int, int>();

            foreach (OilDataSearchEntity oilData in oilDatasOr)
            {
                foreach (var cutProperty in cutPropertys.Where(s => s.IsAnd == false))
                {
                    float calData = 0;
                    if (float.TryParse(oilData.calData, out calData))
                    {//判断字符串是否能够转换为float类型
                    }
                    else
                    {
                        calData = -9999999;
                    }
                    if (oilData.OilTableRow.itemCode == cutProperty.itemCode && oilData.oilTableColID == cutProperty.OilTableColID && float.Parse(oilData.calData) >= float.Parse(cutProperty.downLimit) && float.Parse(cutProperty.upLimit) >= float.Parse(oilData.calData))
                    {
                        if (infoID.Keys.Contains(oilData.oilInfoID))
                        {
                            infoID[oilData.oilInfoID] = infoID[oilData.oilInfoID] + 1;
                        }
                        else
                        {
                            infoID[oilData.oilInfoID] = 1;
                        }
                    }
                }
            }
            return(infoID);
        }