コード例 #1
0
        /// <summary>
        /// 导出Lib
        /// </summary>
        /// <param name="fileName"></param>
        private void outLib(string fileName)
        {
            this.gridList.EndEdit();
            string strWhere  = "";  //获取选中的原油ID,用于在oilInfo表中获取数据
            string strWhere2 = "";  //获取选中的原油ID,用于在oilData表中获取数据

            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());
                }
            }
            strWhere  = strWhere.Trim().Substring(2);
            strWhere2 = strWhere2.Trim().Substring(2);

            OilInfoOutAccess  oilInfoOutAccess = new OilInfoOutAccess();
            List <OilInfoOut> oilInfoOuts      = oilInfoOutAccess.Get(strWhere); //oilInfo表中获取数据

            OilDataOutAccess  acess       = new OilDataOutAccess();
            List <OilDataOut> oilDataAlls = acess.Get(strWhere2);          //在oilData表中获取数据

            OutLib outLib = new OutLib();
            OilTableRowOutAccess oilTableRowAccess = new OilTableRowOutAccess();
            OilTableColOutAccess oilTableColAccess = new OilTableColOutAccess();

            outLib.oilTableRows = oilTableRowAccess.Get("1=1"); //获取oilTableRow表中所有行
            outLib.oilTableCols = oilTableColAccess.Get("1=1"); //获取oilTableCol表中所有列

            foreach (OilInfoOut oilInfoOut in oilInfoOuts)      //构建一条一条的原油信息,形成原油列表
            {
                oilInfoOut.oilDatas = oilDataAlls.Where(c => c.oilInfoID == oilInfoOut.ID).ToList();
                outLib.oilInfoOuts.Add(oilInfoOut);
            }

            Serialize.Write <OutLib>(outLib, fileName);
        }
コード例 #2
0
ファイル: FrmLibBOut.cs プロジェクト: Volador17/OilCute
        /// <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);
        }