public ActionResult EditField(int id) { var field = new Field(); try { if (id < 1) { field.Error = "Invalid Selection!"; field.ErrorCode = -1; return(Json(field, JsonRequestBehavior.AllowGet)); } var myViewObj = new FieldServices().GetField(id); if (myViewObj == null || myViewObj.FieldId < 1) { field.Error = "Field Information could not be retrieved."; field.ErrorCode = -1; return(Json(field, JsonRequestBehavior.AllowGet)); } Session["_field"] = myViewObj; myViewObj.ErrorCode = myViewObj.FieldId; return(Json(myViewObj, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); field.Error = "An unknown error was Field Information could not be retrieved."; field.ErrorCode = -1; return(Json(field, JsonRequestBehavior.AllowGet)); } }
public ActionResult GetFields2(int queryId) { if (queryId < 1) { return(Json(new List <FieldReportObject>(), JsonRequestBehavior.AllowGet)); } var query = new FieldQueryBuilderServices().GetFieldQuery(queryId); if (query == null || query.FieldQueryId < 1) { return(Json(new List <FieldReportObject>(), JsonRequestBehavior.AllowGet)); } var fieldList = new FieldServices().GetOrderedFieldReportObjects(query) ?? new List <FieldReportObject>(); if (!fieldList.Any()) { return(Json(new List <FieldReportObject>(), JsonRequestBehavior.AllowGet)); } var jsonResult = Json(fieldList, JsonRequestBehavior.AllowGet); jsonResult.MaxJsonLength = int.MaxValue; return(jsonResult); }
public ActionResult GetFieldsByCompany(long companyId) { var fieldList = new FieldServices().GetFieldsByCompanyId(companyId); if (!fieldList.Any()) { return(Json(new List <Field>(), JsonRequestBehavior.AllowGet)); } return(Json(fieldList, JsonRequestBehavior.AllowGet)); }
private List <Field> GetFields(int itemsPerPage, int pageNumber) { var fields = new FieldServices().GetAllOrderedFields(itemsPerPage, pageNumber); if (!fields.Any()) { return(new List <Field>()); } fields.Remove(fields.Find(m => m.FieldId == (int)OtherNotAvailable.Not_Available)); return(fields); }
private List <Field> GetFields() { var fielList = new FieldServices().GetFields() ?? new List <Field>(); if (!fielList.Any()) { return(new List <Field>()); } return(fielList); }
/// <summary> /// Initializes a new instance of the <see cref="StreakServices"/> class. /// </summary> /// <param name="apiKey">The API key.</param> /// <param name="apiBaseUrl">The API base URL.</param> /// <param name="includeRawResponse">if set to <c>true</c> [include raw JSON response from Streak API].</param> public StreakServices(string apiKey, string apiBaseUrl, bool includeRawResponse) { Users = new UserServices(apiKey, apiBaseUrl, includeRawResponse); Pipelines = new PipelineServices(apiKey, apiBaseUrl, includeRawResponse); Boxes = new BoxServices(apiKey, apiBaseUrl, includeRawResponse); Stages = new StageServices(apiKey, apiBaseUrl, includeRawResponse); Fields = new FieldServices(apiKey, apiBaseUrl, includeRawResponse); Tasks = new TaskServices(apiKey, apiBaseUrl, includeRawResponse); Tasks = new TaskServices(apiKey, apiBaseUrl, includeRawResponse); Files = new FileServices(apiKey, apiBaseUrl, includeRawResponse); Threads = new ThreadServices(apiKey, apiBaseUrl, includeRawResponse); Comments = new CommentServices(apiKey, apiBaseUrl, includeRawResponse); Snippets = new SnippetServices(apiKey, apiBaseUrl, includeRawResponse); }
public ActionResult AddField(Field field) { ModelState.Clear(); ViewBag.LoadStatus = "0"; try { if (!ModelState.IsValid) { field.Error = "Please supply all required fields and try again"; field.ErrorCode = -1; return(Json(field, JsonRequestBehavior.AllowGet)); } var wx = ValidateControl(field); if (wx.Code < 1) { field.Error = wx.Error; field.ErrorCode = -1; return(Json(field, JsonRequestBehavior.AllowGet)); } var k = new FieldServices().AddFieldCheckDuplicate(field); if (k < 1) { if (k == -3) { field.Error = "Field already exists"; field.ErrorCode = -3; return(Json(field, JsonRequestBehavior.AllowGet)); } field.Error = "Process Failed! Please contact the Admin or try again later"; field.ErrorCode = 0; return(Json(field, JsonRequestBehavior.AllowGet)); } field.Error = "Record was added successfully"; field.ErrorCode = 1; field.FieldId = k; return(Json(field, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); field.Error = "An unknown error was encountered. Request could not be serviced. Please try again later."; field.ErrorCode = 0; return(Json(field, JsonRequestBehavior.AllowGet)); } }
private List <FieldReportObject> GetMoreFields(int itemsPerPage, int pageNumber) { try { var fields = new FieldServices().GetMoreFields(itemsPerPage, pageNumber); if (!fields.Any()) { return(new List <FieldReportObject>()); } fields.Remove(fields.Find(m => m.FieldId == (int)OtherNotAvailable.Not_Available)); return(fields); } catch (Exception ex) { return(new List <FieldReportObject>()); } }
private List <Field> GetFields() { try { var fieldList = new FieldServices().GetFields() ?? new List <Field>(); if (!fieldList.Any()) { return(new List <Field>()); } return(fieldList); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); return(new List <Field>()); } }
public ActionResult GetFieldsByBlock(int blockId) { try { if (blockId < 1) { return(Json(new List <FieldReportObject>(), JsonRequestBehavior.AllowGet)); } var blocklist = new FieldServices().GetFieldsByBlockId(blockId); if (!blocklist.Any()) { return(Json(new List <FieldReportObject>(), JsonRequestBehavior.AllowGet)); } return(Json(blocklist, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(new List <FieldReportObject>(), JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 获取域权限信息 /// </summary> /// <typeparam name="CType">string 类型</typeparam> /// <param name="ocode">组织号</param> /// <param name="logid">登录账户</param> /// <param name="objs">目标sql</param> /// <returns></returns> public CType GetInfo <CType>(string ocode, string logid, params object[] objs) { if (objs == null) { return(default(CType)); } try { services = new FieldServices(logid, ocode); object sql = services.LimitBuilder(objs[0].ToString()); CType type = default(CType); type = (CType)sql; return(type); } catch (Exception ex) { //TODO: 记录出错日志 //NG3.Log.Log4Net.ILogger logger = (new NG3.Log.Log4Net.Log4NetLoggerFactory()).CreateLogger(typeof(NoLoginException), NG3.Log.Log4Net.LogType.authorization); //logger.Info(ex.Message, ex); return(default(CType)); } }
public ActionResult GetFields(FieldQuery queryBuilder) { if (queryBuilder == null) { return(Json(new List <FieldReportObject>(), JsonRequestBehavior.AllowGet)); } if (queryBuilder.TerrainId < 1 && queryBuilder.CompanyId < 1 && queryBuilder.ZoneId < 1) { return(Json(new List <FieldReportObject>(), JsonRequestBehavior.AllowGet)); } var fieldList = new FieldServices().GetOrderedFieldReportObjects(queryBuilder) ?? new List <FieldReportObject>(); if (!fieldList.Any()) { return(Json(new List <FieldReportObject>(), JsonRequestBehavior.AllowGet)); } Session["_successfulFieldQuery"] = queryBuilder; var jsonResult = Json(fieldList, JsonRequestBehavior.AllowGet); jsonResult.MaxJsonLength = int.MaxValue; return(jsonResult); }
private Field ProcessRecord(DataRowView dv, ref string msg) { if (dv == null) { return(null); } try { var mInfo = new Field { Name = dv.Row["Field_Name"].ToString().Trim() }; //[Field_Name], [Block_Name] var companyName = dv.Row["Company_Name"].ToString().Trim(); if (string.IsNullOrEmpty(companyName)) { mInfo.CompanyId = 1; } else { var cannonicalName = ""; if (string.IsNullOrEmpty(dv.Row["Canonial_Name"].ToString().Trim())) { cannonicalName = dv.Row["Canonial_Name"].ToString().Trim(); } var companyId = new CompanyServices().GetCompanyId(companyName, cannonicalName); if (companyId < 1) { mInfo.CompanyId = 1; } mInfo.CompanyId = companyId; } var terrainName = dv.Row["Terrain_Name"].ToString().Trim(); if (string.IsNullOrEmpty(terrainName)) { mInfo.TerrainId = 1; } else { var terrainId = new TerrainServices().GetTerrainIdByName(terrainName.Trim()); if (terrainId < 1) { mInfo.TerrainId = 1; } mInfo.TerrainId = terrainId; } mInfo.ZoneId = 1; var techAllowed = dv.Row["Technical_Allowable"].ToString().Trim(); if (!string.IsNullOrEmpty(techAllowed)) { float outTech = 0; var techResult = float.TryParse(techAllowed, out outTech); if (techResult && outTech > 0) { mInfo.TechnicalAllowable = outTech; } } var blockName = dv.Row["Block_Name"].ToString().Trim(); if (string.IsNullOrEmpty(blockName)) { msg = "Block Name is empty"; return(mInfo);; } var ttsd = new FieldServices().AddFieldCheckDuplicate(mInfo); if (ttsd < 1) { msg = "Field could not be processed."; return(null); } if (blockName.Contains("/")) { var dxx = blockName.Split('/'); dxx.ForEach(v => { if (!string.IsNullOrEmpty(v)) { var tId = 0; if (v.Trim().ToLower().Contains("oml")) { tId = 1; } if (v.Trim().ToLower().Contains("opl")) { tId = 2; } var block = new Block { CompanyId = mInfo.CompanyId, BlockTypeId = tId, Name = blockName, LeaseTypeId = 1, YearOfAward = DateTime.Now.Year }; var ssd = new BlockServices().AddBlockCheckDuplicate(block); if (ssd < 1) { return; } } }); } else { var tId = 0; if (blockName.Trim().ToLower().Contains("oml")) { tId = 1; } if (blockName.Trim().ToLower().Contains("opl")) { tId = 2; } var block = new Block { CompanyId = mInfo.CompanyId, BlockTypeId = tId, Name = blockName, LeaseTypeId = 1, YearOfAward = DateTime.Now.Year }; var ssd = new BlockServices().AddBlockCheckDuplicate(block); if (ssd < 1) { mInfo.FieldId = ttsd; return(mInfo); } } mInfo.FieldId = ttsd; return(mInfo); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); return(null); } }
private Well ProcessRecord(DataRowView dv, ref string msg) { if (dv == null) { return(null); } try { var mInfo = new Well { Name = dv.Row["Well_Name"].ToString().Trim() }; var spuDate = dv.Row["SPud_Date"].ToString().Trim(); if (!string.IsNullOrEmpty(spuDate)) { DateTime d1; var realDate = DateTime.TryParse(spuDate, out d1); if (!realDate) { msg = "Invalid Spud Date"; return(null); } mInfo.SpudDate = d1; } ////else ////{ //// msg = "Please provide Spud Date."; //// return null; ////} var fieldName = mInfo.Name.Trim().Trim().ToLower().Split('-')[0]; if (!string.IsNullOrEmpty(fieldName)) { var field = new FieldServices().GetFieldIdByFieldName(fieldName); if (field.FieldId < 1) { msg = "Field Information could not be processed."; return(null); } mInfo.FieldId = field.FieldId; } else { msg = "Please provide Field Name"; return(null); } double dept = 0; if (!string.IsNullOrEmpty(dv.Row["Total_Dept"].ToString().Trim())) { var totalDeptStr = dv.Row["Total_Dept"].ToString().Trim(); var deptResult = double.TryParse(totalDeptStr, out dept); if (!deptResult || dept < 1) { dept = 0; } } mInfo.TotalDept = dept; var remarks = dv.Row["Remarks"].ToString().Trim(); if (!string.IsNullOrEmpty(remarks)) { mInfo.Remarks = remarks.Trim(); } var wellTypeName = dv.Row["WellType_Name"].ToString().Trim(); if (!string.IsNullOrEmpty(wellTypeName)) { var wellTypeId = new WellTypeServices().GetWellTypeId(wellTypeName); mInfo.WellTypeId = wellTypeId; } else { msg = "Well Type name is empty"; return(null); } var techAllowed = dv.Row["Technical_Allowed"].ToString().Trim(); if (!string.IsNullOrEmpty(techAllowed)) { double outRes; var techAllowedResult = double.TryParse(techAllowed, out outRes); if (techAllowedResult && outRes > 0) { mInfo.TechnicalAllowable = outRes; } } var wellClassName = dv.Row["WellClass_Name"].ToString().Trim(); if (!string.IsNullOrEmpty(wellClassName)) { mInfo.WellClassName = wellClassName.Trim(); } return(mInfo); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); return(null); } }
private Production ProcessRecord(DataRowView dv, ref string msg) { if (dv == null) { return(null); } try { var quantity = dv.Row["quantity(barrels)"].ToString().Trim(); double qt = 0; if (string.IsNullOrEmpty(quantity)) { msg = "Quantity produced is empty."; return(null); } double outQt = 0; var dt = double.TryParse(quantity, out outQt); if (!dt && outQt < 1) { msg = "Invalid value for Quantity produced."; return(null); } var mInfo = new Production { Quantity = outQt.ToString(CultureInfo.InvariantCulture) }; var field = dv.Row["field"].ToString().Trim(); if (string.IsNullOrEmpty(field)) { msg = "Production Field is empty."; return(null); } var fieldInfo = new FieldServices().GetFieldIdByFieldName(field); if (fieldInfo.FieldId < 1) { msg = "Field Information could not be processed."; return(null); } mInfo.FieldId = fieldInfo.FieldId; var product = dv.Row["product"].ToString().Trim(); if (string.IsNullOrEmpty(product)) { msg = "Product is empty."; return(null); } var productId = new ProductServices().GetProductIdId(product); if (productId < 1) { msg = "Product Information could not be processed."; return(null); } mInfo.ProductId = productId; var month = dv.Row["month(eg: January)"].ToString().Trim(); if (string.IsNullOrEmpty(month)) { msg = "Month of Production is empty"; return(null); } var monthValue = 0; switch (month.Trim().ToLower()) { case "january": monthValue = 1; break; case "february": monthValue = 2; break; case "march": monthValue = 3; break; case "april": monthValue = 4; break; case "may": monthValue = 5; break; case "june": monthValue = 6; break; case "july": monthValue = 7; break; case "august": monthValue = 8; break; case "september": monthValue = 9; break; case "october": monthValue = 10; break; case "november": monthValue = 11; break; case "december": monthValue = 12; break; } mInfo.Month = monthValue; var year = dv.Row["year(eg: 2010)"].ToString().Trim(); if (string.IsNullOrEmpty(month)) { msg = "Year of Production is empty"; return(null); } long yearValue; var yearResult = long.TryParse(year, out yearValue); if (!yearResult || yearValue < 1) { msg = "Invalid Year of Production"; return(null); } if (yearValue < 1) { msg = "Invalid Year of Production"; return(null); } mInfo.Year = yearValue; if (!string.IsNullOrEmpty(dv.Row["APIgravity"].ToString().Trim())) { mInfo.APIGravity = dv.Row["APIgravity"].ToString().Trim(); } if (!string.IsNullOrEmpty(dv.Row["remark"].ToString().Trim())) { mInfo.Remark = dv.Row["remark"].ToString().Trim(); } return(mInfo); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); return(null); } }
public ActionResult FieldUpload(HttpPostedFileBase file) { try { var successList = new List <Field>(); var errorList = new List <Field>(); if (file.ContentLength > 0) { const string folderPath = "~/BulkUploadTemplate"; var fileName = file.FileName; var path = folderPath + "/" + fileName; if (System.IO.File.Exists(Server.MapPath(path))) { System.IO.File.Delete(Server.MapPath(path)); } file.SaveAs(Server.MapPath(folderPath + "/" + fileName)); var mList = new List <Field>(); var msg = string.Empty; if (!new FieldUploadManager().Import(Server.MapPath(path), "Fields", ref mList, ref msg)) { ViewBag.ErrorCode = -1; ViewBag.ErrorMessage = msg; return(View()); } if (!mList.Any()) { ViewBag.ErrorCode = -1; ViewBag.ErrorMessage = msg; return(View()); } foreach (var fieldInfo in mList) { var fieldId = new FieldServices().AddFieldCheckDuplicate(fieldInfo); if (fieldId < 1) { errorList.Add(fieldInfo); } else { successList.Add(fieldInfo); } } if (errorList.Any() && successList.Any()) { var ts = successList.Count + " record(s) were successfully uploaded." + "\n" + errorList.Count + " record(s) could not be uploaded due to duplicates/unknown errors encountered."; ViewBag.ErrorCode = -1; if (msg.Length > 0) { ts += "<br/>" + msg; } ViewBag.ErrorMessage = ts; return(View()); } if (errorList.Any() && !successList.Any()) { var ts = errorList.Count + " record(s) could not be uploaded due to duplicates/unknown errors encountered."; ViewBag.ErrorCode = -1; if (msg.Length > 0) { ts += "<br/>" + msg; } ViewBag.ErrorMessage = ts; return(View()); } if (!errorList.Any() && successList.Any()) { ViewBag.ErrorCode = 5; //ViewBag.ErrorMessage = mList.Count + " records were successfully uploaded."; var tsx = successList.Count + " records were successfully uploaded."; if (msg.Length > 0) { tsx += "<br/>" + msg; } ViewBag.ErrorMessage = tsx; return(View()); } } ViewBag.ErrorCode = -1; ViewBag.ErrorMessage = "Error: File is empty or the content could not be accessed"; return(View()); } catch (Exception ex) { const string error = "Bulk upload Failed! unknown error occurred"; ViewBag.ErrorCode = -1; ViewBag.ErrorMessage = error; ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); return(View()); } }
public ActionResult EditField(Field field) { ModelState.Clear(); ViewBag.LoadStatus = "0"; try { if (Session["_field"] == null) { field.Error = "Session has expired"; field.ErrorCode = 0; return(Json(field, JsonRequestBehavior.AllowGet)); } var oldField = Session["_field"] as Field; if (oldField == null || oldField.FieldId < 1) { field.Error = "Session has expired"; field.ErrorCode = 0; return(Json(field, JsonRequestBehavior.AllowGet)); } if (!ModelState.IsValid) { field.Error = "Please supply all required fields and try again"; field.ErrorCode = -1; return(Json(field, JsonRequestBehavior.AllowGet)); } var wx = ValidateControl(field); if (wx.Code < 1) { field.Error = wx.Error; field.ErrorCode = -1; return(Json(field, JsonRequestBehavior.AllowGet)); } oldField.Name = field.Name; oldField.TechnicalAllowable = field.TechnicalAllowable; oldField.CompanyId = field.CompanyId; oldField.BlockId = field.BlockId; oldField.TerrainId = field.TerrainId; oldField.ZoneId = field.ZoneId; var k = new FieldServices().UpdateFieldCheckDuplicate(oldField); if (k < 1) { if (k == -3) { field.Error = "Field already exists"; field.ErrorCode = 0; return(Json(field, JsonRequestBehavior.AllowGet)); } field.Error = "Process Failed! Please contact the Admin or try again later"; field.ErrorCode = 0; return(Json(field, JsonRequestBehavior.AllowGet)); } field.Error = "Field Information was successfully updated"; field.ErrorCode = 1; return(Json(field, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); field.Error = "An unknown error was encountered. Request could not be serviced. Please try again later."; field.ErrorCode = 0; return(Json(field, JsonRequestBehavior.AllowGet)); } }