public string UpdatePipe(string strParam) { JObject result = new JObject(); JArray projects = JArray.Parse(strParam); using (OracleConnection conn = Common.GetSqlConnection()) { OracleTransaction transaction = null; try { transaction = conn.BeginTransaction(); OracleCommand cmd = conn.CreateCommand(); cmd.Connection = conn; cmd.Transaction = transaction; for (int i = 0; i < projects.Count; i++) { JObject proj = (JObject)projects[i]; SqlBuilder sb = new SqlBuilder(); JToken token; if (proj.TryGetValue("projectId", out token)) { sb.AddField("PROJECTID", (int)token); } if (proj.TryGetValue("name", out token)) { sb.AddField("NAME", (string)token); } if (proj.TryGetValue("location", out token)) { sb.AddField("LOCATION", (string)token); } if (proj.TryGetValue("startWellId", out token)) { sb.AddField("STARTWELLID", (int)token); } if (proj.TryGetValue("endWellId", out token)) { sb.AddField("ENDWELLID", (int)token); } cmd.CommandText = sb.BuildUpdateSQL("TBL_PIPE", "ID", proj.GetValue("id").ToString()); cmd.ExecuteNonQuery(); } transaction.Commit(); result.Add("error", 0); } catch (Exception ex) { if (transaction != null) { transaction.Rollback(); } result.Add("error", 1); result.Add("message", ex.Message); } conn.Close(); } return(result.ToString(Newtonsoft.Json.Formatting.Indented, null)); }
public string InsertWell(string strParam) { JObject result = new JObject(); JArray wells = JArray.Parse(strParam); using (OracleConnection conn = Common.GetSqlConnection()) { OracleTransaction transaction = null; try { transaction = conn.BeginTransaction(); OracleCommand cmd = conn.CreateCommand(); cmd.Connection = conn; cmd.Transaction = transaction; for (int i = 0; i < wells.Count; i++) { JObject well = (JObject)wells[i]; SqlBuilder sb = new SqlBuilder(); sb.AddField("OBJECTID", (int)well.GetValue("id")); sb.AddField("NAME", (string)well.GetValue("name")); sb.AddField("LOCATION", (string)well.GetValue("location")); sb.AddField("PROJECTID", (int)well.GetValue("projectId")); JArray coords = (JArray)well.GetValue("coords"); sb.AddField("SHAPE", string.Format("SDE.ST_Point({0}, {1}, 2)", (double)coords[0], (double)coords[1]), false); cmd.CommandText = sb.BuildInsertSQL("TBL_WELL"); cmd.ExecuteNonQuery(); } transaction.Commit(); result.Add("error", 0); } catch (Exception ex) { if (transaction != null) { transaction.Rollback(); } result.Add("error", 1); result.Add("message", ex.Message); } conn.Close(); } return(result.ToString(Newtonsoft.Json.Formatting.Indented, null)); }
public string InsertProject(string strParam) { JObject result = new JObject(); JArray projects = JArray.Parse(strParam); using (OracleConnection conn = Common.GetSqlConnection()) { OracleTransaction transaction = null; try { transaction = conn.BeginTransaction(); OracleCommand cmd = conn.CreateCommand(); cmd.Connection = conn; cmd.Transaction = transaction; for (int i = 0; i < projects.Count; i++) { JObject proj = (JObject)projects[i]; SqlBuilder sb = new SqlBuilder(); sb.AddField("ID", (int)proj.GetValue("id")); sb.AddField("NAME", (string)proj.GetValue("name")); cmd.CommandText = sb.BuildInsertSQL("TBL_PROJECT"); cmd.ExecuteNonQuery(); } transaction.Commit(); result.Add("error", 0); } catch (Exception ex) { if (transaction != null) { transaction.Rollback(); } result.Add("error", 1); result.Add("message", ex.Message); } conn.Close(); } return(result.ToString(Newtonsoft.Json.Formatting.Indented, null)); }
public SelectQuery(IDataProvider provider) { if (provider == null) { throw new ArgumentNullException("provider"); } Init(provider); //MetaType metaType = MetaManager.GetMetaType(); var tableName = DbMetaDataManager.GetTableName(ModelType); var metaDataList = DbMetaDataManager.GetMetaDatas(ModelType); SqlBuilder.AddFromTable(tableName, TableIndex); foreach (var parameter in metaDataList) { SqlBuilder.AddField(string.Format("T{0}.{1}", TableIndex, parameter.FieldName)); } }