using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebAPI.Models;
namespace WebAPI.Controllers.项目管理
{
public class PM_ProjectBill_WorkController : ApiController
{
private json objJsonResult = new json();
public DataSet ds = new DataSet();
public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
#region 反射构建更新SQL语句
private string generateModifyStrReflection(Object model,string tableName, params string[] keys)
{
try
{
string sql = "update " + tableName + " Set ";
string[] excludeNames = keys;
foreach (var fInfo in model.GetType().GetProperties()
.Where(property => !excludeNames.Contains(property.Name))
.ToArray())
{
string propName = fInfo.Name;
var propValue = fInfo.GetValue(model);
if (propValue != null)
{
sql += (propName + "='" + propValue.ToString() + "',");
}
}
sql = sql.Substring(0, sql.Length - 1);
sql += " where 1 = 1 ";
foreach (var key in keys)
{
sql += "and " + key + " = " + model.GetType().GetProperty(key).GetValue(model);
}
LogService.Write(sql);
return sql;
}catch(Exception e)
{
throw new ArgumentException(e.ToString());
}
}
#endregion
#region 工程项目 查询
///
/// 返回项目阶段列表
///参数:string sql。
///返回值:object。
///
[Route("PM_ProjectBill_Work/list")]
[HttpGet]
public object getProjectBill(string sWhere, string user, string stage)
{
try
{
List