New file |
| | |
| | | using Newtonsoft.Json; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.IO; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | |
| | | public class LogService |
| | | { |
| | | private static readonly object lockObj = new object(); |
| | | |
| | | public static void WriteAsync(object obj, string filePath = "Vlog", bool isAppend = true) |
| | | { |
| | | Task.Run(() => |
| | | { |
| | | Write(obj, filePath, isAppend); |
| | | }); |
| | | } |
| | | |
| | | public static void WriteAsync<T>(object obj, string filePath = "Vlog", bool isAppend = true) |
| | | { |
| | | Task.Run(() => |
| | | { |
| | | Write(obj, $@"{filePath}\{typeof(T).Name}", isAppend); |
| | | }); |
| | | } |
| | | |
| | | #region 日志 |
| | | public static void Write(object obj, string filePath = "Vlog", bool isAppend = true) |
| | | { |
| | | try |
| | | { |
| | | lock (lockObj) |
| | | { |
| | | filePath = $@"{filePath}\webapi{DateTime.Now.ToString("yyyyMMdd")}.txt"; |
| | | |
| | | filePath = AppDomain.CurrentDomain.BaseDirectory + filePath; |
| | | |
| | | if (!System.IO.Directory.Exists(Path.GetDirectoryName(filePath))) |
| | | { |
| | | System.IO.Directory.CreateDirectory(Path.GetDirectoryName(filePath)); |
| | | } |
| | | |
| | | bool fileExists = System.IO.File.Exists(filePath); |
| | | //不存在 则创建该文件 |
| | | if (!fileExists) |
| | | { |
| | | System.IO.File.Create(filePath).Close(); |
| | | } |
| | | |
| | | using (StreamWriter writer = new StreamWriter(filePath, isAppend)) |
| | | { |
| | | //存在的时候才写一行 |
| | | if (fileExists && isAppend) |
| | | { |
| | | writer.WriteLine(); |
| | | } |
| | | |
| | | var content = obj is string ? obj : JsonConvert.SerializeObject(obj); |
| | | writer.WriteLine($"{DateTime.Now} {content}"); |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | |
| | |
| | | //连接SQL Server数据库的连接串,应该修改为与实际一致。如果是运行Grid++Report本身的例子,应该首先附加例子数据库到 |
| | | //SQL Server2000/2005数据库上。 |
| | | //public const string SqlConnStr = "Data Source=(local);Initial Catalog=gridreport;Persist Security Info=True;User ID=sa;Password=;"; |
| | | // public const string SqlConnStr = "Data Source=47.96.97.237,15127;Initial Catalog=HX_LMESsys;Persist Security Info=True;User ID=HX_USER;Password=lc@841022;"; |
| | | //public const string SqlConnStr = "Data Source=47.96.97.237,15127;Initial Catalog=HX_LMESsys;Persist Security Info=True;User ID=HX_USER;Password=lc@841022;"; |
| | | //夏宝 |
| | | public const string SqlConnStr = "Data Source=192.168.1.239;Initial Catalog=HX_LimsSys;Persist Security Info=True;User ID=HX_USER;Password=lc@841022;"; |
| | | public const string SqlConnStr = "Data Source=192.168.1.239;Initial Catalog=HX_LMESsys;Persist Security Info=True;User ID=HX_USER;Password=lc@841022;"; |
| | | //安瑞 |
| | | //public const string SqlConnStr = "Data Source=.;Initial Catalog=HX_LimsSys;Persist Security Info=True;User ID=HX_USER;Password=lc@841022;"; |
| | | |
| | | //public string sServer; |
| | | //public string sDataBase; |
| | |
| | | //根据查询SQL,产生提供给报表生成需要的 XML 或 JSON 数据 |
| | | protected static void DoGenDetailData(System.Web.UI.Page DataPage, string QuerySQL, ResponseDataType DataType, bool IsJSON) |
| | | { |
| | | LogService.Write(QuerySQL); |
| | | //SqlConnection conn = new SqlConnection(SqlConnStr); |
| | | //try |
| | | //{ |
| | | // conn.Open(); |
| | | // LogService.Write("Connection opened."); |
| | | // LogService.Write("Connection Properties:"); |
| | | // LogService.Write("Connection String:{0}", conn.ConnectionString); |
| | | // LogService.Write("Database:{0}", conn.Database); |
| | | // LogService.Write("DataSource:{0}", conn.DataSource); |
| | | // LogService.Write("ServerVersion:{0}", conn.ServerVersion); |
| | | // LogService.Write("State:{0}", conn.State.ToString()); |
| | | // LogService.Write("WorkstationId:{0}", conn.WorkstationId); |
| | | //} |
| | | //catch (SqlException e) |
| | | //{ |
| | | // LogService.Write("Error: " + e); |
| | | //} |
| | | //finally |
| | | //{ |
| | | // conn.Close(); |
| | | // LogService.Write("Connection close."); |
| | | //} |
| | | SqlConnection ReportConn = new SqlConnection(SqlConnStr); |
| | | SqlDataAdapter ReportDataAdapter = new SqlDataAdapter(QuerySQL, ReportConn); |
| | | DataSet ReportDataSet = new DataSet(); |
| | | ReportConn.Open(); |
| | | LogService.Write("State:" + ReportConn.State); |
| | | ReportDataAdapter.Fill(ReportDataSet); |
| | | ReportConn.Close(); |
| | | LogService.Write("hangshu :" + ReportDataSet.Tables[0].Rows.Count); |
| | | |
| | | if (IsJSON) |
| | | JSONReportData.GenDataSet(DataPage, ReportDataSet, DataType); |
| | |
| | | //using System.Collections; |
| | | using System.Text; |
| | | using System.Data; |
| | | using System.Configuration; |
| | | using System.IO; |
| | | using System.IO.Compression; |
| | | using System.Web; |
| | | using System.Web.Security; |
| | | using System.Web.UI; |
| | | using System.Web.UI.WebControls; |
| | | using System.Web.UI.WebControls.WebParts; |
| | | using System.Web.UI.HtmlControls; |
| | | using System.Threading.Tasks; |
| | | |
| | | |
| | | ///////////////////////////////////////////////////////////////////////////////////////////////////////// |
| | | //以下枚举指定报表数据的格式类型 |
| | |
| | | { |
| | | //"recordset":[ |
| | | sbJSONText.Append('"'); |
| | | sbJSONText.Append(dt.TableName); |
| | | sbJSONText.Append(dt.TableName); |
| | | sbJSONText.Append("\":[\n"); |
| | | foreach (DataRow dr in dt.Rows) |
| | | { |
| | |
| | | public static void PrepareValueText(ref string ValueText) |
| | | { |
| | | bool HasSpecialChar = false; |
| | | foreach(char ch in ValueText) |
| | | foreach (char ch in ValueText) |
| | | { |
| | | if (ch == '"' || ch == '\\' || ch == '\r' || ch == '\n' || ch == '\t') |
| | | { |
| | |
| | | { |
| | | if (ch == '"' || ch == '\\' || ch == '\r' || ch == '\n' || ch == '\t') |
| | | { |
| | | NewValueText.Append( '\\'); |
| | | NewValueText.Append('\\'); |
| | | if (ch == '"' || ch == '\\') |
| | | NewValueText.Append( ch ); |
| | | NewValueText.Append(ch); |
| | | else if (ch == '\r') |
| | | NewValueText.Append( 'r' ); |
| | | NewValueText.Append('r'); |
| | | else if (ch == '\n') |
| | | NewValueText.Append( 'n' ); |
| | | NewValueText.Append('n'); |
| | | else if (ch == '\t') |
| | | NewValueText.Append( 't' ); |
| | | NewValueText.Append('t'); |
| | | } |
| | | else |
| | | { |
| | | NewValueText.Append( ch ); |
| | | NewValueText.Append(ch); |
| | | } |
| | | } |
| | | ValueText = NewValueText.ToString(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //public class LogService |
| | | //{ |
| | | // private static readonly object lockObj = new object(); |
| | | |
| | | // public static void WriteAsync(object obj, string filePath = "Vlog", bool isAppend = true) |
| | | // { |
| | | // Task.Run(() => |
| | | // { |
| | | // Write(obj, filePath, isAppend); |
| | | // }); |
| | | // } |
| | | |
| | | // public static void WriteAsync<T>(object obj, string filePath = "Vlog", bool isAppend = true) |
| | | // { |
| | | // Task.Run(() => |
| | | // { |
| | | // Write(obj, $@"{filePath}\{typeof(T).Name}", isAppend); |
| | | // }); |
| | | // } |
| | | |
| | | // #region 日志 |
| | | // public static void Write(object obj, string filePath = "Vlog", bool isAppend = true) |
| | | // { |
| | | // try |
| | | // { |
| | | // lock (lockObj) |
| | | // { |
| | | // filePath = $@"{filePath}\webapi{DateTime.Now.ToString("yyyyMMdd")}.txt"; |
| | | |
| | | // filePath = AppDomain.CurrentDomain.BaseDirectory + filePath; |
| | | |
| | | // if (!System.IO.Directory.Exists(Path.GetDirectoryName(filePath))) |
| | | // { |
| | | // System.IO.Directory.CreateDirectory(Path.GetDirectoryName(filePath)); |
| | | // } |
| | | |
| | | // bool fileExists = System.IO.File.Exists(filePath); |
| | | // //不存在 则创建该文件 |
| | | // if (!fileExists) |
| | | // { |
| | | // System.IO.File.Create(filePath).Close(); |
| | | // } |
| | | |
| | | // using (StreamWriter writer = new StreamWriter(filePath, isAppend)) |
| | | // { |
| | | // //存在的时候才写一行 |
| | | // if (fileExists && isAppend) |
| | | // { |
| | | // writer.WriteLine(); |
| | | // } |
| | | |
| | | // var content = obj is string ? obj : obj; |
| | | // writer.WriteLine($"{DateTime.Now} {content}"); |
| | | // } |
| | | // } |
| | | // } |
| | | // catch (Exception ex) |
| | | // { |
| | | // } |
| | | // } |
| | | // #endregion |
| | | //} |
| | |
| | | <HintPath>..\packages\Microsoft.AspNet.Membership.OpenAuth.2.0.1\lib\net45\Microsoft.AspNet.Membership.OpenAuth.dll</HintPath> |
| | | </Reference> |
| | | <Reference Include="Microsoft.CSharp" /> |
| | | <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> |
| | | <SpecificVersion>False</SpecificVersion> |
| | | <HintPath>..\..\..\..\办公\K3Cloud\WebSite\bin\Newtonsoft.Json.dll</HintPath> |
| | | </Reference> |
| | | <Reference Include="System" /> |
| | | <Reference Include="System.Data" /> |
| | | <Reference Include="System.ComponentModel.DataAnnotations" /> |
| | |
| | | <ItemGroup> |
| | | <Compile Include="App_Data\Class1.cs" /> |
| | | <Compile Include="App_Data\JScript.cs" /> |
| | | <Compile Include="App_Data\LogService.cs" /> |
| | | <Compile Include="App_Data\MssqlReportData.cs" /> |
| | | <Compile Include="App_Data\ReportData.cs" /> |
| | | <Compile Include="App_Data\StringUtil.cs" /> |
| | |
| | | , where: { sMsg: linterid, sMsg2: lentryid } |
| | | , cols: [[ |
| | | , { field: 'HMaterID', title: '物料ID', width: 100, hide: true } |
| | | , { field: 'HMaterShortNumber', title: '物料编码', width: 120 } |
| | | , { field: 'HMaterNumber', title: '物料代码', width: 120 } |
| | | , { field: 'HMaterNumber', title: '物料编码', width: 120 } |
| | | , { field: 'HMaterShortNumber', title: '物料代码', width: 120 } |
| | | , { field: 'HMaterName', title: '物料名称', width: 120 } |
| | | , { field: 'HMaterModel', title: '规格型号', width: 120 } |
| | | , { field: 'HUnitName', title: '计量单位', width: 100 } |
| | |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline"> |
| | | <label class="layui-form-label">源单单号</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" class="layui-input" name="HBillNoFrom" id="HBillNoFrom"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-inline"> |
| | | <label class="layui-form-label">送货单号</label> |
| | | <div class="layui-input-block"> |
| | | <input type="text" class="layui-input" name="HInnerBillNo" id="HInnerBillNo"> |
| | |
| | | </div> |
| | | </div> |
| | | <!--<div class="layui-inline"> |
| | | <label class="layui-form-label">状态</label> |
| | | <div class="layui-input-block"> |
| | | <select name="HStatus" id="HStatus" lay-filter=""> |
| | | <option value="">全部</option> |
| | | <option value="未打印" selected="">未打印</option> |
| | | <option value="已打印">已打印</option> |
| | | </select> |
| | | </div> |
| | | </div>--> |
| | | <label class="layui-form-label">状态</label> |
| | | <div class="layui-input-block"> |
| | | <select name="HStatus" id="HStatus" lay-filter=""> |
| | | <option value="">全部</option> |
| | | <option value="未打印" selected="">未打印</option> |
| | | <option value="已打印">已打印</option> |
| | | </select> |
| | | </div> |
| | | </div>--> |
| | | |
| | | <div class="layui-inline"> |
| | | <label class="layui-form-label">采购组织</label> |
| | |
| | | |
| | | if ($("#HBillNo").val() != "") |
| | | sqlWhere += " and 单据号 like ^^%" + $("#HBillNo").val() + "%^^"; |
| | | if ($("#HBillNoFrom").val() != "") |
| | | sqlWhere += " and 源单单号 like ^^%" + $("#HBillNoFrom").val() + "%^^"; |
| | | if ($("#HInnerBillNo").val() != "") |
| | | sqlWhere += " and 送货单号 like ^^%" + $("#HInnerBillNo").val() + "%^^"; |
| | | if ($("#HShortNumber").val() != "") |