public string Update(string json, string columns, string clientInf) { Dictionary <string, string> resultDic = new Dictionary <string, string>(); resultDic["result"] = ""; resultDic["message"] = ""; try { sara.dd.ldsw.model.tbl_filescontent model = Eva.Library.Format.FormatEntityTool.FormatJsonToModel <sara.dd.ldsw.model.tbl_filescontent>(json); columns = FormatColumns(columns).Replace("^", ","); resultDic["result"] = "true"; resultDic["message"] = _idal_tbl_filescontent.Update(model, columns, null); NewLog("数据更新成功,更新的数据为:json:" + json + ",columns:" + columns, "sql_update", clientInf); } catch (Exception ex) { resultDic["result"] = "false"; resultDic["message"] = Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace); NewLog("数据更新失败,更新的数据为:json:" + json + ",columns:" + columns + ",异常信息:" + Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace), "sql_update", clientInf); } return(Eva.Library.Format.FormatEntityTool.FormatDicToJson(resultDic)); }
public string Add(string json, string clientInf) { Dictionary <string, string> resultDic = new Dictionary <string, string>(); resultDic["result"] = ""; resultDic["message"] = ""; try { sara.dd.ldsw.model.tbl_filescontent model = Eva.Library.Format.FormatEntityTool.FormatJsonToModel <sara.dd.ldsw.model.tbl_filescontent>(json); resultDic["result"] = "true"; resultDic["message"] = _idal_tbl_filescontent.Add(model, null); NewLog("数据创建成功,创建的数据为:" + json, "sql_insert", clientInf); } catch (Exception ex) { resultDic["result"] = "false"; resultDic["message"] = Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace); NewLog("数据创建失败,创建的数据为:" + json + ",异常信息:" + Eva.Library.Format.FormatTextTool.ErrorMessageFormat(ex.Message + ex.StackTrace), "sql_insert", clientInf); } return(Eva.Library.Format.FormatEntityTool.FormatDicToJson(resultDic)); }
/// <summary> /// 重写添加addlayerconfig /// </summary> /// <param name="json"></param> /// <param name="clientInf"></param> /// <returns></returns> public string Add(sara.dd.ldsw.model.tbl_filescontent model, Eva.Library.Data.AccessDataTrans.IAccessDataTrans t) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql_use = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); StringBuilder strSql3 = new StringBuilder(); if (Eva.Library.Configuration.ConfigurationManager.AppSettings["SqlEditMode"].ToString() == "parameter") { } else //如果是sql形式的话,则进行textFormat { model = Eva.Library.Format.FormatTextTool.ModelFormat(model); } List <OracleParameter> parameterList = new List <OracleParameter>(); OracleParameter parameter = null; string sid = ""; if (model.sys_id <= 0) { if (t == null) { sid = GetMaxId(null).ToString(); } else { sid = GetMaxId(t).ToString(); } model.sys_id = int.Parse(sid); } else { sid = model.sys_id.ToString(); } #region sqlString strSql1.Append("sys_id,"); strSql2.Append("'" + sid + "',"); strSql3.Append(":sys_id,"); parameter = new OracleParameter(":sys_id", OracleType.Number); parameter.Value = sid; parameterList.Add(parameter); if (model.sys_orderid != null) { strSql1.Append("sys_orderid,"); strSql2.Append("'" + (model.sys_orderid) + "',"); strSql3.Append(":sys_orderid,"); parameter = new OracleParameter(":sys_orderid", OracleType.VarChar); parameter.Value = model.sys_orderid; parameterList.Add(parameter); } if (model.sys_userid != null) { strSql1.Append("sys_userid,"); strSql2.Append("'" + (model.sys_userid) + "',"); strSql3.Append(":sys_userid,"); parameter = new OracleParameter(":sys_userid", OracleType.VarChar); parameter.Value = model.sys_userid; parameterList.Add(parameter); } if (model.sys_username != null) { strSql1.Append("sys_username,"); strSql2.Append("'" + (model.sys_username) + "',"); strSql3.Append(":sys_username,"); parameter = new OracleParameter(":sys_username", OracleType.VarChar); parameter.Value = model.sys_username; parameterList.Add(parameter); } if (model.sys_creatdate != null) { strSql1.Append("sys_creatdate,"); strSql2.Append("to_date('" + model.sys_creatdate.ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-MM-dd hh24:mi:ss'),"); strSql3.Append(":sys_creatdate,"); parameter = new OracleParameter(":sys_creatdate", OracleType.DateTime); parameter.Value = model.sys_creatdate; parameterList.Add(parameter); } if (model.sys_lastedituserid != null) { strSql1.Append("sys_lastedituserid,"); strSql2.Append("'" + (model.sys_lastedituserid) + "',"); strSql3.Append(":sys_lastedituserid,"); parameter = new OracleParameter(":sys_lastedituserid", OracleType.VarChar); parameter.Value = model.sys_lastedituserid; parameterList.Add(parameter); } if (model.sys_lasteditusername != null) { strSql1.Append("sys_lasteditusername,"); strSql2.Append("'" + (model.sys_lasteditusername) + "',"); strSql3.Append(":sys_lasteditusername,"); parameter = new OracleParameter(":sys_lasteditusername", OracleType.VarChar); parameter.Value = model.sys_lasteditusername; parameterList.Add(parameter); } if (model.sys_lasteditdate != null) { strSql1.Append("sys_lasteditdate,"); strSql2.Append("to_date('" + model.sys_lasteditdate.ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-MM-dd hh24:mi:ss'),"); strSql3.Append(":sys_lasteditdate,"); parameter = new OracleParameter(":sys_lasteditdate", OracleType.DateTime); parameter.Value = model.sys_lasteditdate; parameterList.Add(parameter); } if (model.sys_deluserid != null) { strSql1.Append("sys_deluserid,"); strSql2.Append("'" + (model.sys_deluserid) + "',"); strSql3.Append(":sys_deluserid,"); parameter = new OracleParameter(":sys_deluserid", OracleType.VarChar); parameter.Value = model.sys_deluserid; parameterList.Add(parameter); } if (model.sys_delusername != null) { strSql1.Append("sys_delusername,"); strSql2.Append("'" + (model.sys_delusername) + "',"); strSql3.Append(":sys_delusername,"); parameter = new OracleParameter(":sys_delusername", OracleType.VarChar); parameter.Value = model.sys_delusername; parameterList.Add(parameter); } if (model.sys_deldate != null) { strSql1.Append("sys_deldate,"); strSql2.Append("to_date('" + model.sys_deldate.ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-MM-dd hh24:mi:ss'),"); strSql3.Append(":sys_deldate,"); parameter = new OracleParameter(":sys_deldate", OracleType.DateTime); parameter.Value = model.sys_deldate; parameterList.Add(parameter); } if (model.sys_delflag != null) { strSql1.Append("sys_delflag,"); strSql2.Append("'" + (model.sys_delflag) + "',"); strSql3.Append(":sys_delflag,"); parameter = new OracleParameter(":sys_delflag", OracleType.VarChar); parameter.Value = model.sys_delflag; parameterList.Add(parameter); } if (model.fk_maintable_sys_id != null) { strSql1.Append("fk_maintable_sys_id,"); strSql2.Append("'" + (model.fk_maintable_sys_id) + "',"); strSql3.Append(":fk_maintable_sys_id,"); parameter = new OracleParameter(":fk_maintable_sys_id", OracleType.VarChar); parameter.Value = model.fk_maintable_sys_id; parameterList.Add(parameter); } if (model.fk_projclass_sys_id != null) { strSql1.Append("fk_projclass_sys_id,"); strSql2.Append("'" + (model.fk_projclass_sys_id) + "',"); strSql3.Append(":fk_projclass_sys_id,"); parameter = new OracleParameter(":fk_projclass_sys_id", OracleType.VarChar); parameter.Value = model.fk_projclass_sys_id; parameterList.Add(parameter); } if (model.filename != null) { strSql1.Append("filename,"); strSql2.Append("'" + (model.filename) + "',"); strSql3.Append(":filename,"); parameter = new OracleParameter(":filename", OracleType.VarChar); parameter.Value = model.filename; parameterList.Add(parameter); } if (model.filerealname != null) { strSql1.Append("filerealname,"); strSql2.Append("'" + (model.filerealname) + "',"); strSql3.Append(":filerealname,"); parameter = new OracleParameter(":filerealname", OracleType.VarChar); parameter.Value = model.filerealname; parameterList.Add(parameter); } if (model.fileclass != null) { strSql1.Append("fileclass,"); strSql2.Append("'" + (model.fileclass) + "',"); strSql3.Append(":fileclass,"); parameter = new OracleParameter(":fileclass", OracleType.VarChar); parameter.Value = model.fileclass; parameterList.Add(parameter); } if (model.filesize != null) { strSql1.Append("filesize,"); strSql2.Append("'" + (model.filesize) + "',"); strSql3.Append(":filesize,"); parameter = new OracleParameter(":filesize", OracleType.VarChar); parameter.Value = model.filesize; parameterList.Add(parameter); } if (model.filetitle != null) { strSql1.Append("filetitle,"); strSql2.Append("'" + (model.filetitle) + "',"); strSql3.Append(":filetitle,"); parameter = new OracleParameter(":filetitle", OracleType.VarChar); parameter.Value = model.filetitle; parameterList.Add(parameter); } if (model.filenote != null) { strSql1.Append("filenote,"); strSql2.Append("'" + (model.filenote) + "',"); strSql3.Append(":filenote,"); parameter = new OracleParameter(":filenote", OracleType.VarChar); parameter.Value = model.filenote; parameterList.Add(parameter); } if (model.fnumber != null) { strSql1.Append("fnumber,"); strSql2.Append("'" + (model.fnumber) + "',"); strSql3.Append(":fnumber,"); parameter = new OracleParameter(":fnumber", OracleType.VarChar); parameter.Value = model.fnumber; parameterList.Add(parameter); } strSql.Append("insert into tbl_filescontent("); strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql.Append(")"); strSql.Append(" values ("); strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1)); strSql.Append(")"); strSql_use.Append("insert into tbl_filescontent("); strSql_use.Append(strSql1.ToString().Remove(strSql1.Length - 1)); strSql_use.Append(")"); strSql_use.Append(" values ("); strSql_use.Append(strSql3.ToString().Remove(strSql3.Length - 1)); strSql_use.Append(")"); #endregion if (Eva.Library.Configuration.ConfigurationManager.AppSettings["SqlEditMode"].ToString() == "parameter") { #region parameter if (parameterList.Count > 0) { if (t == null) { _iAccessData.ExecuteSql(strSql_use.ToString(), parameterList.ToArray()); } else { t.ExecuteSql(strSql_use.ToString(), parameterList.ToArray()); } } #endregion } else { #region sql if (t == null) { _iAccessData.ExecuteSql(strSql.ToString()); } else { t.ExecuteSql(strSql.ToString()); } #endregion } return(sid); }
/// <summary> /// 重写更新updatepaper /// </summary> /// <param name="json"></param> /// <param name="columns"></param> /// <param name="clientInf"></param> /// <returns></returns> public string Update(sara.dd.ldsw.model.tbl_filescontent model, string columns, Eva.Library.Data.AccessDataTrans.IAccessDataTrans t) { String[] columnsArray = columns.Split(','); List <string> columsList = new List <string>(columnsArray); List <OracleParameter> parameterList = new List <OracleParameter>(); OracleParameter parameter = null; #region sqlString StringBuilder strSql = new StringBuilder(); StringBuilder strSql_use = new StringBuilder(); strSql.Append("update tbl_filescontent set "); strSql_use.Append("update tbl_filescontent set "); if (Eva.Library.Configuration.ConfigurationManager.AppSettings["SqlEditMode"].ToString() == "parameter") { } else //如果是sql形式的话,则进行textReturn { model = Eva.Library.Format.FormatTextTool.ModelFormat(model); } if (model.sys_orderid != null && columsList.Contains("sys_orderid")) { strSql.Append("sys_orderid='" + (model.sys_orderid) + "',"); strSql_use.Append("sys_orderid=:sys_orderid,"); parameter = new OracleParameter(":sys_orderid", OracleType.VarChar); parameter.Value = model.sys_orderid; parameterList.Add(parameter); } if (model.sys_userid != null && columsList.Contains("sys_userid")) { strSql.Append("sys_userid='" + (model.sys_userid) + "',"); strSql_use.Append("sys_userid=:sys_userid,"); parameter = new OracleParameter(":sys_userid", OracleType.VarChar); parameter.Value = model.sys_userid; parameterList.Add(parameter); } if (model.sys_username != null && columsList.Contains("sys_username")) { strSql.Append("sys_username='******',"); strSql_use.Append("sys_username=:sys_username,"); parameter = new OracleParameter(":sys_username", OracleType.VarChar); parameter.Value = model.sys_username; parameterList.Add(parameter); } if (model.sys_creatdate != null && columsList.Contains("sys_creatdate")) { strSql.Append("sys_creatdate=to_date('" + model.sys_creatdate.ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-MM-dd hh24:mi:ss'),"); strSql_use.Append("sys_creatdate=:sys_creatdate,"); parameter = new OracleParameter(":sys_creatdate", OracleType.DateTime); parameter.Value = model.sys_creatdate; parameterList.Add(parameter); } if (model.sys_lastedituserid != null && columsList.Contains("sys_lastedituserid")) { strSql.Append("sys_lastedituserid='" + (model.sys_lastedituserid) + "',"); strSql_use.Append("sys_lastedituserid=:sys_lastedituserid,"); parameter = new OracleParameter(":sys_lastedituserid", OracleType.VarChar); parameter.Value = model.sys_lastedituserid; parameterList.Add(parameter); } if (model.sys_lasteditusername != null && columsList.Contains("sys_lasteditusername")) { strSql.Append("sys_lasteditusername='******',"); strSql_use.Append("sys_lasteditusername=:sys_lasteditusername,"); parameter = new OracleParameter(":sys_lasteditusername", OracleType.VarChar); parameter.Value = model.sys_lasteditusername; parameterList.Add(parameter); } if (model.sys_lasteditdate != null && columsList.Contains("sys_lasteditdate")) { strSql.Append("sys_lasteditdate=to_date('" + model.sys_lasteditdate.ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-MM-dd hh24:mi:ss'),"); strSql_use.Append("sys_lasteditdate=:sys_lasteditdate,"); parameter = new OracleParameter(":sys_lasteditdate", OracleType.DateTime); parameter.Value = model.sys_lasteditdate; parameterList.Add(parameter); } if (model.sys_deluserid != null && columsList.Contains("sys_deluserid")) { strSql.Append("sys_deluserid='" + (model.sys_deluserid) + "',"); strSql_use.Append("sys_deluserid=:sys_deluserid,"); parameter = new OracleParameter(":sys_deluserid", OracleType.VarChar); parameter.Value = model.sys_deluserid; parameterList.Add(parameter); } if (model.sys_delusername != null && columsList.Contains("sys_delusername")) { strSql.Append("sys_delusername='******',"); strSql_use.Append("sys_delusername=:sys_delusername,"); parameter = new OracleParameter(":sys_delusername", OracleType.VarChar); parameter.Value = model.sys_delusername; parameterList.Add(parameter); } if (model.sys_deldate != null && columsList.Contains("sys_deldate")) { strSql.Append("sys_deldate=to_date('" + model.sys_deldate.ToString("yyyy-MM-dd HH:mm:ss") + "','yyyy-MM-dd hh24:mi:ss'),"); strSql_use.Append("sys_deldate=:sys_deldate,"); parameter = new OracleParameter(":sys_deldate", OracleType.DateTime); parameter.Value = model.sys_deldate; parameterList.Add(parameter); } if (model.sys_delflag != null && columsList.Contains("sys_delflag")) { strSql.Append("sys_delflag='" + (model.sys_delflag) + "',"); strSql_use.Append("sys_delflag=:sys_delflag,"); parameter = new OracleParameter(":sys_delflag", OracleType.VarChar); parameter.Value = model.sys_delflag; parameterList.Add(parameter); } if (model.fk_maintable_sys_id != null && columsList.Contains("fk_maintable_sys_id")) { strSql.Append("fk_maintable_sys_id='" + (model.fk_maintable_sys_id) + "',"); strSql_use.Append("fk_maintable_sys_id=:fk_maintable_sys_id,"); parameter = new OracleParameter(":fk_maintable_sys_id", OracleType.VarChar); parameter.Value = model.fk_maintable_sys_id; parameterList.Add(parameter); } if (model.fk_projclass_sys_id != null && columsList.Contains("fk_projclass_sys_id")) { strSql.Append("fk_projclass_sys_id='" + (model.fk_projclass_sys_id) + "',"); strSql_use.Append("fk_projclass_sys_id=:fk_projclass_sys_id,"); parameter = new OracleParameter(":fk_projclass_sys_id", OracleType.VarChar); parameter.Value = model.fk_projclass_sys_id; parameterList.Add(parameter); } if (model.filename != null && columsList.Contains("filename")) { strSql.Append("filename='" + (model.filename) + "',"); strSql_use.Append("filename=:filename,"); parameter = new OracleParameter(":filename", OracleType.VarChar); parameter.Value = model.filename; parameterList.Add(parameter); } if (model.filerealname != null && columsList.Contains("filerealname")) { strSql.Append("filerealname='" + (model.filerealname) + "',"); strSql_use.Append("filerealname=:filerealname,"); parameter = new OracleParameter(":filerealname", OracleType.VarChar); parameter.Value = model.filerealname; parameterList.Add(parameter); } if (model.fileclass != null && columsList.Contains("fileclass")) { strSql.Append("fileclass='" + (model.fileclass) + "',"); strSql_use.Append("fileclass=:fileclass,"); parameter = new OracleParameter(":fileclass", OracleType.VarChar); parameter.Value = model.fileclass; parameterList.Add(parameter); } if (model.filesize != null && columsList.Contains("filesize")) { strSql.Append("filesize='" + (model.filesize) + "',"); strSql_use.Append("filesize=:filesize,"); parameter = new OracleParameter(":filesize", OracleType.VarChar); parameter.Value = model.filesize; parameterList.Add(parameter); } if (model.filetitle != null && columsList.Contains("filetitle")) { strSql.Append("filetitle='" + (model.filetitle) + "',"); strSql_use.Append("filetitle=:filetitle,"); parameter = new OracleParameter(":filetitle", OracleType.VarChar); parameter.Value = model.filetitle; parameterList.Add(parameter); } if (model.filenote != null && columsList.Contains("filenote")) { strSql.Append("filenote='" + (model.filenote) + "',"); strSql_use.Append("filenote=:filenote,"); parameter = new OracleParameter(":filenote", OracleType.VarChar); parameter.Value = model.filenote; parameterList.Add(parameter); } if (model.fnumber != null && columsList.Contains("fnumber")) { strSql.Append("fnumber='" + (model.fnumber) + "',"); strSql_use.Append("fnumber=:fnumber,"); parameter = new OracleParameter(":fnumber", OracleType.VarChar); parameter.Value = model.fnumber; parameterList.Add(parameter); } int n = strSql.ToString().LastIndexOf(","); strSql.Remove(n, 1); strSql.Append(" where sys_id='" + model.sys_id + "'"); n = strSql_use.ToString().LastIndexOf(","); strSql_use.Remove(n, 1); strSql_use.Append(" where sys_id='" + model.sys_id + "'"); #endregion int columscount = 0; if (Eva.Library.Configuration.ConfigurationManager.AppSettings["SqlEditMode"].ToString() == "parameter") { #region parameter if (parameterList.Count > 0) { if (t == null) { columscount = _iAccessData.ExecuteSql(strSql_use.ToString(), parameterList.ToArray()); } else { columscount = t.ExecuteSql(strSql_use.ToString(), parameterList.ToArray()); } } #endregion } else { #region sql if (t == null) { columscount = _iAccessData.ExecuteSql(strSql.ToString()); } else { columscount = t.ExecuteSql(strSql.ToString()); } #endregion } return(columscount.ToString()); }