public static void GetAllLocation(string path) { string strReadLine; WellModel wm = new WellModel(); ListToDataTableUtil ltdtu = new ListToDataTableUtil(); List <WellModel> lstWM = new List <WellModel>(); dtSK = ltdtu.ListToDataTable(lstWM); FileStream fs = new FileStream(path, FileMode.Open); StreamReader sr = new StreamReader(fs); strReadLine = sr.ReadLine(); while (strReadLine != null) { if (strReadLine.Equals("COMPDAT")) { strReadLine = sr.ReadLine(); string[] strArray = Regex.Split(strReadLine, @"\s+"); if (strArray[5].Equals("'OPEN'")) { DataRow dr = dtSK.NewRow(); wm = new WellModel(); dr["jh"] = strArray[0].Substring(1, strArray[0].Length - 2); dr["x"] = Convert.ToInt32(strArray[1]); dr["y"] = Convert.ToInt32(strArray[2]); dr["k"] = Convert.ToInt32(strArray[3]); dtSK.Rows.Add(dr); } } strReadLine = sr.ReadLine(); } sr.Close(); fs.Close(); }
public void Insert() { try { WellModel model = new WellModel(); model.DrillingPlanDoc = new List <WellDrillingPlanModel>(); try { FileStream stream = File.OpenRead(openFileDialog1.FileName); byte[] fileBytes = new byte[stream.Length]; stream.Read(fileBytes, 0, fileBytes.Length); stream.Close(); model.DrillingPlanDoc.Add(new WellDrillingPlanModel { WellId = WellId, WellDrillPlanId = 0, WellDrillDocExt = System.IO.Path.GetExtension(openFileDialog1.FileName.ToString()), WellDrillDoc = fileBytes, WellDrilDocName = lblFileName.Text }); } catch (Exception) { } model.LocationId = Convert.ToInt32(lstLocation.Properties.GetKeyValueByDisplayValue(lstLocation.Text)); model.WellCode = txtCode.Text; model.WellDepth = Convert.ToDecimal(txtWellDepth.Text.Replace(",", "")); model.WellId = 0; model.WellName = txtName.Text; model.WellPlannedDate = txtPlannedDate.DateTime; model.WellTypeId = Convert.ToInt32(lstWellType.Properties.GetKeyValueByDisplayValue(lstWellType.Text)); model.RigId = Convert.ToInt32(lstRig.Properties.GetKeyValueByDisplayValue(lstRig.Text)); model.WellSections = new List <WellSectionModel>(); for (int i = 0; i < gridView2.RowCount; i++) { model.WellSections.Add(new WellSectionModel() { SecDepth = Convert.ToDecimal(gridView2.GetRowCellValue(i, "SecDepth").ToString()), SecId = Convert.ToInt32(gridView2.GetRowCellValue(i, "SecId").ToString()), SectionName = gridView2.GetRowCellValue(i, "SectionName").ToString(), WellId = 0, WellSecId = Convert.ToInt32(gridView2.GetRowCellValue(i, "WellSecId").ToString()) }); } model = well.Insert(model); if (model.WellId > 0) { MessageBox.Show("Saved Successfully"); } } catch (Exception ex) { MessageBox.Show(ex.InnerException == null ? ex.Message : ex.InnerException.Message); } }
public async Task Create(WellModel model) { const string query = @"INSERT INTO wells (name, company_id, field_id, workshop_id) VALUES (@name, @company_id, @field_id, @workshop_id);"; await using var conn = BaseRepository.Connection(); await conn.OpenAsync(); await conn.QueryAsync(query, model); }
public ActionResult Add(WellModel model) { model.CreateTime = DateTime.Now; model.CreateUserId = Operator.UserId; model.UpdateTime = DateTime.Now; model.UpdateUserId = Operator.UserId; var result = WellService.AddWell(model) ? SuccessTip("添加成功") : ErrorTip("添加失败"); return(Json(result)); }
public IActionResult Put(int id, [FromBody] WellModel updatedWell) { var well = _wellService.Update(updatedWell.ToDomainModel()); if (well == null) { return(NotFound()); } return(Ok(well.ToApiModel())); }
private void Form1_Load(object sender, EventArgs e) { gridResult.Visible = false; ReadFilesDAL.ReadPermX(); ReadFilesDAL.ReadDZ(); ReadFilesDAL.ReadPORO(); ReadFilesDAL.CalcDCXS(); WellModel wm = new WellModel(); List <ResultModel> lstRM = new List <ResultModel>(); List <WellModel> lstOil = new List <WellModel>(); List <WellModel> lstWater = new List <WellModel>(); ///List<WellModel> lstDY = new List<WellModel>(); ListToDataTableUtil ltdu = new ListToDataTableUtil(); dtResult = ltdu.ListToDataTable(lstRM); string[] sj = File.ReadAllLines("水.txt"); for (int i = 0; i < sj.Count(); i++) { wm = new WellModel(); string[] str = Regex.Split(sj[i], @"\s+"); wm.jhs = str[0]; wm.date = str[1]; wm.x = Convert.ToInt32(str[2]); wm.y = Convert.ToInt32(str[3]); wm.k = Convert.ToInt32(str[4]); wm.mncs = Convert.ToDouble(str[5]); lstWater.Add(wm); } dtWater = ltdu.ListToDataTable(lstWater); string[] yj = File.ReadAllLines("油.txt"); for (int i = 0; i < yj.Count(); i++) { wm = new WellModel(); string[] str = Regex.Split(yj[i], @"\s+"); wm.jhy = str[0]; wm.date = str[1]; wm.x = Convert.ToInt32(str[2]); wm.y = Convert.ToInt32(str[3]); wm.k = Convert.ToInt32(str[4]); wm.mncs = Convert.ToDouble(str[5]); wm.mncy = Convert.ToDouble(str[6]); wm.mncye = Convert.ToDouble(str[7]); wm.hs = Convert.ToDouble(str[8]); lstOil.Add(wm); } dtOil = ltdu.ListToDataTable(lstOil); DataTable dtDate = dtWater.DefaultView.ToTable(true, "date"); for (int i = 0; i < dtDate.Rows.Count; i++) { cmbDate.Properties.Items.Add(dtDate.Rows[i]["date"]); } }
public ActionResult Edit(WellModel model) { string sid = model.IO_ServerID.Split('/')[0]; string cid = model.IO_ServerID.Split('/')[1]; model.IO_ServerID = sid; model.IO_CommunicateID = cid; model.UpdateTime = DateTime.Now; model.UpdateUserId = Operator.UserId; var result = WellService.UpdateById(model) ? SuccessTip("修改成功") : ErrorTip("修改失败"); return(Json(result)); }
public IActionResult Post([FromBody] WellModel well) { try { _wellService.Add(well.ToDomainModel()); } catch (System.Exception ex) { ModelState.AddModelError("AddWell", ex.GetBaseException().Message); return(BadRequest(ModelState)); } return(CreatedAtAction("Get", new { Id = well.Id }, well)); }
public WellModel GetSingleLocation(string strJH, int k) { WellModel wm = new WellModel(); DataRow[] rows = dtSK.Select("JH = '" + strJH + "' and K = " + k); if (rows.Count() > 0) { //wm.jh = strJH; wm.x = (Int32)rows[0]["x"]; wm.y = (Int32)rows[0]["y"]; wm.k = k; } return(wm); }
/// <summary> /// 将水井或油井坐标按升序排序 /// </summary> /// <param name="arr">排序数组</param> private void Sort(WellModel[] arr) { if (arr[0].x > arr[1].x) { WellModel temp = arr[0]; arr[0] = arr[1]; arr[1] = temp; } else if (arr[0].x == arr[1].x) { if (arr[0].y > arr[1].y) { WellModel temp = arr[0]; arr[0] = arr[1]; arr[1] = temp; } } }
private void FillWellDetails() { try { WellModel model = repo.GetWellDetails(RigId); WellId = model.WellId; if (model != null) { txtLocation.Text = model.LocName; txtPlannedDepth.Text = model.WellDepth.ToString("#0"); txtWellName.Text = model.WellName; txtWellType.Text = model.WellTypeName; } } catch (Exception ex) { MessageBox.Show(ex.InnerException == null ? ex.Message : ex.InnerException.Message); } }
/// <summary> /// 油水井距范围内影响因素 /// </summary> /// <param name="path">读取影响因素文件路径</param> /// <param name="strJHLocation">目标井</param> /// <param name="dbjhLocation">目标连通井</param> /// <param name="fipoilAverage">剩余储量</param> /// <param name="presAverage">平均压力</param> /// <param name="soilAverage">平均含油饱和度</param> /// <param name="permxAverage">平均渗透率</param> /// <param name="presDiff">注采压差</param> public InfFactorModel InfluencingFactors(WellModel strJHLocation, WellModel dbjhLocation, List <decimal> lstPressure, List <decimal> lstSoil, List <decimal> lstFipoil /*, List<decimal> lstKX, List<decimal> lstDCXS, List<decimal> lstPORO*/) { InfFactorModel ifm = new InfFactorModel(); decimal fipoilTotal = 0, presTotal = 0, soilTotal = 0, kxTotal = 0, dcxsTotal = 0, poroTotal = 0; List <WellModel> lstSpacingRange = SpacingRange(strJHLocation, dbjhLocation); int index = 0; for (int i = 0; i < lstSpacingRange.Count; i++) { index = (lstSpacingRange[i].k - 1) * 152 * 223 + ((lstSpacingRange[i].y - 1) * 223 + lstSpacingRange[i].x) - 1; soilTotal += lstSoil[index]; presTotal += lstPressure[index]; fipoilTotal += lstFipoil[index]; //kxTotal += lstKX[index]; //dcxsTotal += lstDCXS[index]; //poroTotal += lstPORO[index]; } ifm.jhy = strJHLocation.jh; ifm.jhs = dbjhLocation.jh; ifm.k = strJHLocation.k; ifm.presAverage = presTotal / lstSpacingRange.Count; ifm.fipoilAverage = fipoilTotal / lstSpacingRange.Count; ifm.soilAverage = soilTotal / lstSpacingRange.Count; //ifm.wellSpacing = WellSpacing(strJHLocation, dbjhLocation); //ifm.kxAverage = kxTotal / lstSpacingRange.Count; //ifm.dcxsAverage = dcxsTotal / lstSpacingRange.Count; //ifm.poroAverage = poroTotal / lstSpacingRange.Count; int jhIndex = 0, dbjhIndex = 0; jhIndex = (strJHLocation.k - 1) * 152 * 223 + ((strJHLocation.y - 1) * 223 + strJHLocation.x) - 1; dbjhIndex = (dbjhLocation.k - 1) * 152 * 223 + ((dbjhLocation.y - 1) * 223 + dbjhLocation.x) - 1; //ifm.yy = lstPressure[jhIndex]; //ifm.sy = lstPressure[dbjhIndex]; //ifm.presDiff = ifm.sy - ifm.yy; return(ifm); }
private void ShowWell() { try { WellModel model = well.GetWellDetails(WellId); txtCode.Text = model.WellCode; txtName.Text = model.WellName; txtPlannedDate.DateTime = model.WellPlannedDate; txtWellDepth.Text = model.WellDepth.ToString(); lstLocation.EditValue = model.LocationId; lstRig.EditValue = model.RigId; lstWellType.EditValue = model.WellTypeId; txtPlannedDays.Text = model.PlannedDays.ToString(); gridControl1.DataSource = model.DrillingPlanDoc; gridControl2.DataSource = model.WellSections; } catch (Exception ex) { MessageBox.Show(ex.InnerException == null ? ex.Message : ex.InnerException.Message); } }
public async Task Update(WellModel model) { var query = new StringBuilder("UPDATE wells SET"); foreach (var prop in model.GetType().GetProperties()) { if (prop.Name == nameof(model.Id)) { continue; } if (prop.GetValue(model, null) != null) { query.Append($", {prop.Name} = @{prop.Name}"); } } query.Append("WHERE id = @Id"); query.Replace("SET, ", "SET "); await using var conn = BaseRepository.Connection(); await conn.OpenAsync(); await conn.QueryAsync(query.ToString(), model); }
private async Task LoadTanks(WellModel well) { if (well == null) { return; } using (SetIsBusy()) { //checks for any dirty models and saves those before reloading var dirty = TankItems.Where(x => x.IsDirty()).ToArray(); if (dirty.Any()) { var tanks = await Task.Run(() => _tankProvider.Save(dirty)); await Task.Run(() => MessageQueue.Enqueue($"{tanks} record(s) updated.")); } TankItems.Clear(); var results = await Task.Run(() => _tankProvider.GetByWellId(well.Id)); await Execute.OnUIThreadAsync(() => TankItems.AddRange(results)); } }
public Task Update(WellModel model) { return(_wellRepository.Update(model)); }
public Task Create(WellModel well) { return(_wellRepository.Create(well)); }
public void GetTracer(string strPath, string strTrace) { GetTraceJH gtj = new GetTraceJH(); DataTable dtTracerJH = gtj.GetTraceJHMethod(strTrace); DateUtil du = new DateUtil(); string strStartDate = du.DateTimeCovertToString(DateTime.ParseExact((MainForm.strStartDate), "yyyyMM", null)); string strEndDate = du.DateTimeCovertToString(DateTime.ParseExact((MainForm.strEndDate), "yyyyMM", null).AddMonths(1)); string strReadLine; string strJH = string.Empty; string strDate = string.Empty; string strTracer = string.Empty; bool isWell = false; bool isRead = false; bool isWater = false; bool isDate = false; FileStream fs = new FileStream(strPath, FileMode.Open); StreamReader sr = new StreamReader(fs); WellModel wm; List <WellModel> lstWM = new List <WellModel>(); List <WellModel> lstOilM = new List <WellModel>(); List <WellModel> lstWaterM = new List <WellModel>(); strReadLine = sr.ReadLine().Replace(":", " ").Replace(",", " "); string trim = strReadLine.Trim(); while (strReadLine != null) { trim = strReadLine.Trim(); string[] strArray = Regex.Split(trim, @"\s+"); if (((strArray.Length == 12) && (strArray[0].Equals("STEP")) && (strArray[8].Equals("REPT"))) || ((strArray.Length == 11) && (strArray[0].Equals("STEP")) && (strArray[7].Equals("REPT")))) { strDate = strArray[strArray.Length - 1]; if (strDate.Equals(strStartDate)) { isDate = true; } if (strDate.Equals(strEndDate)) { isDate = false; break; } } if (isDate) { if (strArray[0].Equals("TRACER") && strArray.Count() == 6 && strArray[5].Equals("PASSIVE") && strArray[3].Equals("WATER") && strArray[4].Equals("PHASE")) { DataRow[] drTracer = dtTracerJH.Select("trace = '" + strArray[2] + "'"); { if (drTracer.Count() > 0) { strTracer = drTracer[0]["smjh"].ToString(); } } } if (((strArray.Count() == 11) && strArray[3].Equals("PROD")) || ((strArray.Count() == 11) && strArray[3].Equals("WINJ")) || ((strArray.Count() == 10) && strArray[0].Equals("BLOCK"))) { if ((strArray.Count() == 11) && strArray[3].Equals("PROD")) { isWater = false; } else if ((strArray.Count() == 11) && strArray[3].Equals("WINJ")) { isWater = true; } if (!strArray[0].Equals("BLOCK")) { strJH = strArray[0]; } isWell = true; while (isWell) { strArray = Regex.Split(trim, @"\s+"); if (strArray[0].Equals("BLOCK")) { wm = new WellModel(); if (isWater) { if (!strArray[4].Equals("SHUT")) { if (Convert.ToDouble(strArray[4]) > 0) { wm.jhy = ""; wm.jhs = strJH; wm.mncs = Convert.ToDouble(strArray[4]); wm.szj = strTracer; wm.szjnd = Convert.ToDouble(strArray[7]); wm.date = strDate; wm.dtDate = du.TextDateStringCovertToDateTime(strDate); wm.x = Convert.ToInt32(strArray[1]); wm.y = Convert.ToInt32(strArray[2]); wm.k = Convert.ToInt32(strArray[3]); lstWM.Add(wm); } } } else { if (!strArray[4].Equals("SHUT")) { if (Convert.ToDouble(strArray[5]) > 0) { wm.jhy = strJH; wm.jhs = ""; wm.mncs = Convert.ToDouble(strArray[5]); wm.szj = strTracer; wm.szjnd = Convert.ToDouble(strArray[7]); wm.date = strDate; wm.dtDate = du.TextDateStringCovertToDateTime(strDate); wm.x = Convert.ToInt32(strArray[1]); wm.y = Convert.ToInt32(strArray[2]); wm.k = Convert.ToInt32(strArray[3]); lstWM.Add(wm); } } } strReadLine = sr.ReadLine(); if (strReadLine != null) { strReadLine = strReadLine.Replace(":", " ").Replace(",", " "); trim = strReadLine.Trim(); } } else { isWell = false; } } } else { if (trim.Equals("INJECTION REPORT")) { isRead = true; isWater = true; } else if (trim.Equals("PRODUCTION REPORT")) { isRead = true; isWater = false; } else if (trim.Equals("CUMULATIVE PRODUCTION/INJECTION TOTALS")) { isRead = false; } if (isRead) { trim = strReadLine.Trim(); strArray = Regex.Split(trim, @"\s+"); if (isWater) { if ((strArray.Count() >= 12) && (strArray.Count() <= 13)) { if (strArray.Count() == 12 || strArray[4].Equals("SHUT")) { if (strArray[0].Length > 0) { if (!strArray[0].Equals("BLOCK")) { strJH = strArray[0]; } isWell = true; if (strArray[1].Equals("GROUP") || strArray[0].Equals("REPORT")) { isWell = false; } while (isWell) { strArray = Regex.Split(trim, @"\s+"); if (strArray[0].Equals("BLOCK")) { if (!strArray[4].Equals("SHUT")) { wm = new WellModel(); wm.date = strDate; wm.dtDate = du.TextDateStringCovertToDateTime(strDate); wm.jhs = strJH; wm.x = Convert.ToInt32(strArray[1]); wm.y = Convert.ToInt32(strArray[2]); wm.k = Convert.ToInt32(strArray[3]); if (Convert.ToDouble(strArray[5]) > 0) { wm.mncs = Convert.ToDouble(strArray[5]); lstWaterM.Add(wm); } } strReadLine = sr.ReadLine().Replace(":", " ").Replace(",", " "); trim = strReadLine.Trim(); } else { isWell = false; } } } } } } else { if (strArray.Count() >= 16) { if (strArray.Count() == 16 || strArray[4].Equals("SHUT")) { if (strArray[0].Length > 0) { if (!strArray[0].Equals("BLOCK")) { strJH = strArray[0]; } isWell = true; if (strArray[1].Equals("GROUP") || strArray[0].Equals("REPORT")) { isWell = false; } while (isWell) { strArray = Regex.Split(trim, @"\s+"); if (strArray[0].Equals("BLOCK")) { if (!strArray[4].Equals("SHUT")) { wm = new WellModel(); wm.date = strDate; wm.dtDate = du.TextDateStringCovertToDateTime(strDate); wm.jhy = strJH; wm.x = Convert.ToInt32(strArray[1]); wm.y = Convert.ToInt32(strArray[2]); wm.k = Convert.ToInt32(strArray[3]); if (Convert.ToDouble(strArray[5]) < 0) { wm.mncs = 0; } else { wm.mncs = Convert.ToDouble(strArray[5]); } if (Convert.ToDouble(strArray[4]) > 0) { wm.mncy = Convert.ToDouble(strArray[4]); wm.mncye = wm.mncy + wm.mncs; lstOilM.Add(wm); } } strReadLine = sr.ReadLine().Replace(":", " ").Replace(",", " "); trim = strReadLine.Trim(); } else { isWell = false; } } } } } } } } } strReadLine = sr.ReadLine(); if (strReadLine != null) { strReadLine = strReadLine.Replace(":", " ").Replace(",", " "); } //break; } dtTracer.Merge(ListToDataTableUtil.ListToDataTable(lstWM)); dtOil = ListToDataTableUtil.ListToDataTable(lstOilM); dtWater = ListToDataTableUtil.ListToDataTable(lstWaterM); sr.Close(); fs.Close();; }
public Task Post(WellModel well) { return(_wellRequestHandler.Create(well)); }
private void btnSubmit_Click(object sender, EventArgs e) { splashScreenManager1.ShowWaitForm(); splashScreenManager1.SetWaitFormCaption("正在处理数据"); splashScreenManager1.SetWaitFormDescription("请稍后..."); //FileStream fs = new FileStream(txtResultPath.Text, FileMode.Append); //StreamWriter sw = new StreamWriter(fs); //sw.WriteLine("油井 层位 产液 含水 水井 注水 井距 注采压差 平均圧力 平均含油饱和度 平均储量 平均渗透率 平均地层系数"); ReadFilesDAL.ReadFiles(txtFAPath.Text); FactorsAnalysisDAL fad = new FactorsAnalysisDAL(); DataTable dtLtjh = ExcelToDataTableUtil.ExcelToDataTable(txtLTKPath.Text); for (int i = 0; i < dtLtjh.Rows.Count; i++) { DataRow[] drJHY = dtOil.Select("JHY = '" + dtLtjh.Rows[i]["JHY"] + "' AND DATE = '" + strDate + "'"); if (drJHY.Count() > 0) { foreach (DataRow dr in drJHY) { //DataTable dtLtjhy = dtLtjh.Select("JHS = '" + dtLtjh.Rows[i]["JHS"] + "'").CopyToDataTable(); //DataRow[] drJHS = dtWater.Select("JHS = '" + dtLtjh.Rows[i]["JHS"] + "' AND K = " + dr["K"] + " AND DATE = '" + strDate + "'"); DataRow[] drJHS = dtWater.Select("JHS = '" + dtLtjh.Rows[i]["JHS"] + "' AND DATE = '" + strDate + "'"); if (drJHS.Count() > 0) { //for (int j = 0; j < dtLtjhy.Rows.Count; j++) //{ //DataRow[] drOthrJHY = dtOil.Select("JHY = '" + dtLtjhy.Rows[j]["JHY"] + "' AND K = " + dr["K"] + " AND DATE = '" + strDate + "'"); //if (drOthrJHY.Count() > 0) //{ //foreach (DataRow drOthr in drOthrJHY) //{ WellModel jhy = new WellModel(); //jhy.x = Convert.ToInt32(drOthr["X"]); //jhy.y = Convert.ToInt32(drOthr["Y"]); //jhy.k = Convert.ToInt32(drOthr["K"]); //DataRow[] drMNCYE = dtOil.Select("JHY = '" + drOthr["JHY"] + "' AND DATE = '" + strDate + "' AND K = " + dr["k"]); jhy.x = Convert.ToInt32(dr["X"]); jhy.y = Convert.ToInt32(dr["Y"]); jhy.k = Convert.ToInt32(dr["K"]); jhy.mncye = Convert.ToDouble(dr["MNCYE"]); WellModel jhs = new WellModel(); jhs.x = Convert.ToInt32(drJHS[0]["X"]); jhs.y = Convert.ToInt32(drJHS[0]["Y"]); //jhs.k = Convert.ToInt32(drJHS[0]["K"]); jhs.k = Convert.ToInt32(dr["K"]); //DataRow[] drMNCS = dtWater.Select("JHS = '" + dtLtjh.Rows[i]["JHS"] + "' AND DATE = '" + strDate + "' AND K = " + dr["k"]); InfFactorModel ifm = new InfFactorModel(); ifm = fad.InfluencingFactors(jhy, jhs, ReadFilesDAL.lstPressure, ReadFilesDAL.lstSoil, ReadFilesDAL.lstFipoil, ReadFilesDAL.lstKX, ReadFilesDAL.lstDCXS, ReadFilesDAL.lstPORO); DataRow drResult = dtResult.NewRow(); //drResult["序号"] = i + 1; drResult["油井"] = dr["JHY"]; drResult["层位"] = dr["k"]; drResult["产液"] = dr["MNCYE"]; drResult["含水"] = dr["HS"]; drResult["水井"] = drJHS[0]["JHS"]; //drResult["注入量"] = drMNCS[0]["MNCS"]; drResult["井距"] = ifm.wellSpacing; drResult["注采压差"] = ifm.presDiff; drResult["平均圧力"] = ifm.presAverage; drResult["平均含油饱和度"] = ifm.soilAverage; drResult["平均剩余储量"] = ifm.fipoilAverage; drResult["平均渗透率"] = ifm.kxAverage; drResult["平均地层系数"] = ifm.dcxsAverage; drResult["平均孔隙度"] = ifm.poroAverage; dtResult.Rows.Add(drResult); // } //} //} } } } //sw.WriteLine("---------------------------------------------------------------------"); } gridResult.DataSource = dtResult; DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions(); gridResult.ExportToXls(txtResultPath.Text); //sw.Close(); //fs.Close(); splashScreenManager1.CloseWaitForm(); DevExpress.XtraEditors.XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void GetLTOilJH(WellModel jhs, string strDate, string sjjhs) { if (jhs.jh != null) { DataTable dtLtjhy = cdu.SelectDatabase("select * from ltk where jh = '" + sjjhs + "'"); if (dtLtjhy.Rows.Count > 0) { int dbjs = Convert.ToInt32(dtLtjhy.Rows[0]["dbjs"]); for (int j = 1; j <= dbjs; j++) { DataTable dtIsYJ = cdu.SelectDatabase("select * from yjjh where jh = '" + dtLtjhy.Rows[0]["dbjh" + j] + "'"); if (dtIsYJ.Rows.Count > 0) { // DataTable dtSMYJH = ConnDatabaseUtil.SelectDBF("select * from 井号 where 实际井号 = '" + dtLtjhy.Rows[0]["dbjh" + j] + "'"); DataTable dtSMYJH = cdu.SelectDatabase("select * from dyjh where sjjh = '" + dtLtjhy.Rows[0]["dbjh" + j] + "'"); if (dtSMYJH.Rows.Count > 0) { WellModel Othrjhy = ld.GetSingleLocation(dtSMYJH.Rows[0]["smjh"].ToString(), jhs.k); if (Othrjhy.jh != null) { InfFactorModel ifm = new InfFactorModel(); ifm = fad.InfluencingFactors(Othrjhy, jhs, ReadFilesDAL.lstPressure, ReadFilesDAL.lstSoil, ReadFilesDAL.lstFipoil /*, ReadFilesDAL.lstKX, ReadFilesDAL.lstDCXS, ReadFilesDAL.lstPORO*/); DataRow drResult = dtResult.NewRow(); //DataTable dtSJ = cdu.SelectDatabase("select * from sj where jh = '" + jhs.jh + "' and ny = '" + strDate + "' and k = " + jhs.k); //if (dtSJ.Rows.Count > 0) //{ // drResult["注入量"] = dtSJ.Rows[0]["rzsl"]; // drResult["水bhp"] = dtSJ.Rows[0]["bhp"]; //} //DataTable dtYJ = cdu.SelectDatabase("select * from yj where jh = '" + Othrjhy.jh + "' and ny = '" + strDate + "' and k = " + Othrjhy.k); //if (dtYJ.Rows.Count > 0) //{ // drResult["产液"] = dtYJ.Rows[0]["rcyl1"]; // drResult["含水"] = dtYJ.Rows[0]["HS"]; // drResult["产油"] = Convert.ToDouble(dtYJ.Rows[0]["rcyl1"]) * (1 - Convert.ToDouble(dtYJ.Rows[0]["HS"])); // drResult["油bhp"] = dtYJ.Rows[0]["bhp"]; //} drResult["日期"] = strDate; drResult["油井"] = ifm.jhy; drResult["层位"] = ifm.k; drResult["水井"] = ifm.jhs; drResult["平均圧力"] = ifm.presAverage; drResult["平均含油饱和度"] = ifm.soilAverage; drResult["平均剩余储量"] = ifm.fipoilAverage; dtResult.Rows.Add(drResult); } } } } } else { for (int k = 1; k <= connNumber; k++) { string strColumnOilName = "DBJH" + k; dtLtjhy = cdu.SelectDatabase("select * from LTK where " + strColumnOilName + " = '" + sjjhs + "'"); foreach (DataRow drLtjhy in dtLtjhy.Rows) { DataTable dtIsYJ = cdu.SelectDatabase("select * from yjjh where jh = '" + drLtjhy["jh"] + "'"); if (dtIsYJ.Rows.Count > 0) { //DataTable dtSMYJH = ConnDatabaseUtil.SelectDBF("select * from 井号 where 实际井号 = '" + drLtjhy["jh"] + "'"); DataTable dtSMYJH = cdu.SelectDatabase("select * from dyjh where sjjh = '" + drLtjhy["jh"] + "'"); if (dtSMYJH.Rows.Count > 0) { WellModel Othrjhy = ld.GetSingleLocation(dtSMYJH.Rows[0]["smjh"].ToString(), jhs.k); if (Othrjhy.jh != null) { InfFactorModel ifm = new InfFactorModel(); ifm = fad.InfluencingFactors(Othrjhy, jhs, ReadFilesDAL.lstPressure, ReadFilesDAL.lstSoil, ReadFilesDAL.lstFipoil /*, ReadFilesDAL.lstKX, ReadFilesDAL.lstDCXS, ReadFilesDAL.lstPORO*/); DataRow drResult = dtResult.NewRow(); //DataTable dtSJ = cdu.SelectDatabase("select * from sj where jh = '" + jhs.jh + "' and ny = '" + strDate + "' and k = " + jhs.k); //if (dtSJ.Rows.Count > 0) //{ // drResult["注入量"] = dtSJ.Rows[0]["rzsl"]; // drResult["水bhp"] = dtSJ.Rows[0]["bhp"]; //} //DataTable dtYJ = cdu.SelectDatabase("select * from yj where jh = '" + Othrjhy.jh + "' and ny = '" + strDate + "' and k = " + Othrjhy.k); //if (dtYJ.Rows.Count > 0) //{ // drResult["产液"] = dtYJ.Rows[0]["rcyl1"]; // drResult["含水"] = dtYJ.Rows[0]["HS"]; // drResult["产油"] = Convert.ToDouble(dtYJ.Rows[0]["rcyl1"]) * (1 - Convert.ToDouble(dtYJ.Rows[0]["HS"])); // drResult["油bhp"] = dtYJ.Rows[0]["bhp"]; //} drResult["日期"] = strDate; drResult["油井"] = ifm.jhy; drResult["层位"] = ifm.k; drResult["水井"] = ifm.jhs; drResult["平均圧力"] = ifm.presAverage; drResult["平均含油饱和度"] = ifm.soilAverage; drResult["平均剩余储量"] = ifm.fipoilAverage; dtResult.Rows.Add(drResult); } } } } } } GC.Collect(); } }
/// <summary> /// 计算井距 /// </summary> /// <param name="strJHLocation">目标井</param> /// <param name="dbjhLocation">目标连通井</param> /// <returns></returns> public double WellSpacing(WellModel strJHLocation, WellModel dbjhLocation) { return(Math.Pow(Math.Pow((strJHLocation.y - dbjhLocation.y), 2) + Math.Pow((strJHLocation.x - dbjhLocation.x), 2), 0.5)); }
public JsonResult QueryWellHistoryAlarm(WellScadaAlarmModel model, PageInfo pageInfo) { List <WellScadaAlarmModel> alarms = new List <WellScadaAlarmModel>(); InfluxDBHistoryResult realResult = null; if (string.IsNullOrEmpty(model.WellID)) { realResult = null; } else { WellModel well = WellService.GetById(int.Parse(model.WellID)); if (well != null) { realResult = mWebInfluxDbManager.DbQuery_Alarms(well.IO_ServerID, well.IO_CommunicateID, well.IO_DeviceID, Convert.ToDateTime(model.StartDate), Convert.ToDateTime(model.EndDate), model.IO_ALARM_TYPE, model.IO_ALARM_LEVEL, pageInfo.limit, pageInfo.page); } } if (realResult != null && realResult.Seres.Count() > 0) { var s = realResult.Seres.First(); for (int i = 0; i < s.Values.Count; i++) { WellScadaAlarmModel mymodel = new WellScadaAlarmModel(); int index = s.Columns.IndexOf("time"); object time = s.Values[i][index]; mymodel.time = time != null?time.ToString() : ""; index = -1; index = s.Columns.IndexOf("field_io_alarm_date"); if (index >= 0) { object v = s.Values[i][index]; mymodel.IO_ALARM_DATE = v != null?v.ToString() : ""; } index = -1; index = s.Columns.IndexOf("field_io_alarm_disposalidea"); if (index >= 0) { object v = s.Values[i][index]; mymodel.IO_ALARM_DISPOSALIDEA = v != null?v.ToString() : ""; } index = -1; index = s.Columns.IndexOf("field_io_alarm_disposaluser"); if (index >= 0) { object v = s.Values[i][index]; mymodel.IO_ALARM_DISPOSALUSER = v != null?v.ToString() : ""; } index = -1; index = s.Columns.IndexOf("field_io_alarm_level"); if (index >= 0) { object v = s.Values[i][index]; mymodel.IO_ALARM_LEVEL = v != null?v.ToString() : ""; } index = -1; index = s.Columns.IndexOf("field_io_alarm_type"); if (index >= 0) { object v = s.Values[i][index]; mymodel.IO_ALARM_TYPE = v != null?v.ToString() : ""; } index = -1; index = s.Columns.IndexOf("field_io_alarm_value"); if (index >= 0) { object v = s.Values[i][index]; mymodel.IO_ALARM_VALUE = v != null?v.ToString() : ""; } index = -1; index = s.Columns.IndexOf("field_io_label"); if (index >= 0) { object v = s.Values[i][index]; mymodel.IO_LABEL = v != null?v.ToString() : ""; } index = -1; index = s.Columns.IndexOf("field_io_name"); if (index >= 0) { object v = s.Values[i][index]; mymodel.IO_NAME = v != null?v.ToString() : ""; } index = -1; index = s.Columns.IndexOf("tag_did"); if (index >= 0) { object v = s.Values[i][index]; mymodel.IO_DEVICE_ID = v != null?v.ToString() : ""; } index = -1; index = s.Columns.IndexOf("tag_cid"); if (index >= 0) { object v = s.Values[i][index]; mymodel.IO_COMMUNICATE_ID = v != null?v.ToString() : ""; } index = -1; index = s.Columns.IndexOf("tag_sid"); if (index >= 0) { object v = s.Values[i][index]; mymodel.IO_SERVER_ID = v != null?v.ToString() : ""; } index = -1; index = s.Columns.IndexOf("tag_ioid"); if (index >= 0) { object v = s.Values[i][index]; mymodel.IO_ID = v != null?v.ToString() : ""; } index = -1; index = s.Columns.IndexOf("tag_device_name"); if (index >= 0) { object v = s.Values[i][index]; mymodel.DEVICE_NAME = v != null?v.ToString() : ""; } alarms.Add(mymodel); } } var result = Pager.Paging(alarms, realResult.RecordCount); //读取以下10行的实时数据,从influxDB中读取 return(Json(result, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 计算井距范围 /// </summary> /// <param name="strJHLocation">目标井</param> /// <param name="dbjhLocation">目标连通井</param> /// <returns></returns> private List <WellModel> SpacingRange(WellModel strJHLocation, WellModel dbjhLocation) { double slope;//斜率 int x = 0, y = 0; List <WellModel> lstSpacingRange = new List <WellModel>(); WellModel lm = new WellModel(); WellModel[] array = { strJHLocation, dbjhLocation }; Sort(array); slope = (array[1].y - array[0].y) / (double)(array[1].x - array[0].x); if (double.IsInfinity(slope)) { for (int i = 0; i < 3; i++) { y = array[0].y; while (y <= array[1].y) { lm = new WellModel(); lm.x = array[0].x - 1 + i; lm.y = y; lm.k = array[0].k; if ((lm.x > 0) && (lm.y > 0)) { lstSpacingRange.Add(lm); } y++; } } } else { double[] intercept = new double[3];//截距 if (slope > 0) { intercept[0] = (array[0].y + 1) - slope * (array[0].x - 1); intercept[1] = array[0].y - slope * array[0].x; intercept[2] = (array[0].y - 1) - slope * (array[0].x + 1); for (int i = 0; i < 3; i++) { x = array[0].x; while ((x - 1 + i) <= (array[1].x - 1 + i)) { lm = new WellModel(); lm.x = x - 1 + i; lm.y = (int)(slope * lm.x + intercept[i]); lm.k = array[0].k; if ((lm.x > 0) && (lm.y > 0)) { lstSpacingRange.Add(lm); } x++; } } } else if (slope < 0) { intercept[0] = (array[0].y - 1) - slope * (array[0].x - 1); intercept[1] = array[0].y - slope * array[0].x; intercept[2] = (array[0].y + 1) - slope * (array[0].x + 1); for (int i = 0; i < 3; i++) { x = array[0].x; while ((x - 1 + i) <= (array[1].x - 1 + i)) { lm = new WellModel(); lm.x = x - 1 + i; lm.y = (int)(slope * lm.x + intercept[i]); lm.k = array[0].k; if ((lm.x > 0) && (lm.y > 0)) { lstSpacingRange.Add(lm); } x++; } } } else if (slope == 0) { for (int i = 0; i < 3; i++) { x = array[0].x; while (x <= array[1].x) { lm = new WellModel(); lm.x = x; lm.y = array[0].y - 1 + i; lm.k = array[0].k; if ((lm.x > 0) && (lm.y > 0)) { lstSpacingRange.Add(lm); } x++; } } } } return(lstSpacingRange); }
public void GetLTJInf(string strDate) { DataTable dtOil = new DataTable(); DataTable dtWater = new DataTable(); List <ResultModel> lstRm = new List <ResultModel>(); dtResult = ListToDataTableUtil.ListToDataTable(lstRm); dtOil = cdu.SelectDatabase("select * from yjjh"); for (int i = 0; i < dtOil.Rows.Count; i++) { //DataTable dtSMYJH = ConnDatabaseUtil.SelectDBF("select * from 井号 where 实际井号 = '" + dtOil.Rows[i]["jh"] + "'"); DataTable dtSMYJH = cdu.SelectDatabase("select * from dyjh where sjjh = '" + dtOil.Rows[i]["jh"] + "'"); if (dtSMYJH.Rows.Count > 0) { DataRow[] drJHY = LocationDAL.dtSK.Select("jh = '" + dtSMYJH.Rows[0]["smjh"] + "'"); foreach (DataRow dr in drJHY) { DataTable dtLtjhs = cdu.SelectDatabase("select * from ltk where jh = '" + dtOil.Rows[i]["jh"] + "'"); if (dtLtjhs.Rows.Count > 0) { int dbjs = Convert.ToInt32(dtLtjhs.Rows[0]["dbjs"]); for (int j = 1; j <= dbjs; j++) { DataTable dtIsSJ = cdu.SelectDatabase("select * from sjjh where jh = '" + dtLtjhs.Rows[0]["dbjh" + j] + "'"); if (dtIsSJ.Rows.Count > 0) { //DataTable dtSMSJH = ConnDatabaseUtil.SelectDBF("select * from 井号 where 实际井号 = '" + dtLtjhs.Rows[0]["dbjh" + j] + "'"); DataTable dtSMSJH = cdu.SelectDatabase("select * from dyjh where sjjh = '" + dtLtjhs.Rows[0]["dbjh" + j] + "'"); if (dtSMSJH.Rows.Count > 0) { WellModel jhs = ld.GetSingleLocation(dtSMSJH.Rows[0]["smjh"].ToString(), Convert.ToInt32(dr["k"])); GetLTOilJH(jhs, strDate, dtLtjhs.Rows[0]["dbjh" + j].ToString()); } } } } else { for (int j = 1; j <= connNumber; j++) { string strColumnName = "DBJH" + j; dtLtjhs = cdu.SelectDatabase("select * from LTK where " + strColumnName + " = '" + dtOil.Rows[i]["jh"] + "'"); foreach (DataRow drLtjhs in dtLtjhs.Rows) { DataTable dtIsSJ = cdu.SelectDatabase("select * from sjjh where jh = '" + drLtjhs["jh"] + "'"); if (dtIsSJ.Rows.Count > 0) { //DataTable dtSMSJH = ConnDatabaseUtil.SelectDBF("select * from 井号 where 实际井号 = '" + drLtjhs["jh"] + "'"); DataTable dtSMSJH = cdu.SelectDatabase("select * from dyjh where sjjh = '" + drLtjhs["jh"] + "'"); if (dtSMSJH.Rows.Count > 0) { WellModel jhs = ld.GetSingleLocation(dtSMSJH.Rows[0]["smjh"].ToString(), Convert.ToInt32(dr["k"])); GetLTOilJH(jhs, strDate, drLtjhs["jh"].ToString()); } } } } } } } GC.Collect(); } try { ConnDatabaseUtil cdu = new ConnDatabaseUtil(); string strTableName = "T_WELL_ENDFACTOR"; string strSQL = "select count(*) as count from user_tables where table_name = '" + strTableName.ToUpper() + "'"; DataTable dtExist = cdu.SelectDatabase(strSQL); if (Convert.ToInt32(dtExist.Rows[0]["Count"]) > 0) { strSQL = "drop table " + strTableName.ToUpper(); cdu.CreateOrDeleteDatabase(strSQL); } strSQL = "create table " + strTableName.ToUpper() + " (油井 VARCHAR2(16), 日期 VARCHAR2(6), 层位 NUMBER(2), 水井 VARCHAR2(16), 平均剩余储量 NUMBER(17, 10), 平均圧力 NUMBER(17, 10), 平均含油饱和度 NUMBER(17, 10))"; cdu.CreateOrDeleteDatabase(strSQL); cdu.InsertDatabase(dtResult, strTableName.ToUpper()); } catch (Exception) { } }
public Task Put(int id, WellModel model) { model.Id = id; return(_wellRequestHandler.Update(model)); }
public JsonResult List(WellModel model, PageInfo pageInfo) { var result = WellService.GetListByFilter(model, pageInfo); return(Json(result, JsonRequestBehavior.AllowGet)); }