using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Net.Security; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Web; using System.Web.Script.Serialization; using SuperMap.RealEstate.CoreFrameWork; using SuperMap.RealEstate.CoreFrameWork.Dictionary.Business; using SuperMap.RealEstate.FrameWork.Business; using SuperMap.RealEstate.Utility; using ServiceModel = SuperMap.RealEstate.ServiceModel; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using HZQR.Common; using System.Diagnostics; namespace Personnel.Handler { /// /// handler_ajax 的摘要说明 /// public class handler_ajax : IHttpHandler { //AppID(应用ID) //public const string AppID = "wx85e69a5fb601be16"; //AppSecret(应用密钥) //public const string AppSecret = "dfcf7748e6c7027695cbec8ffedc04dc"; //protected static string _serverpart_id = ConfigurationManager.AppSettings["UmiformCommodity"].ToString().Split('|')[0]; //protected static string _PROVINCE_CODE = ConfigurationManager.AppSettings["UmiformCommodity"].ToString().Split('|')[2]; //protected static string _CigaretteType = ConfigurationManager.AppSettings["CigaretteType"].ToString().Split('|')[0]; //protected static string _Seller = ConfigurationManager.AppSettings["Seller_ServicePoint"].ToString(); //protected static string _Member_Code = "";//ConfigurationManager.AppSettings["Member_Code"].ToString(); //protected static string _Checkout_Success = ConfigurationManager.AppSettings["Checkout_Success"].ToString(); //protected static string _NewOrder = ConfigurationManager.AppSettings["NewOrder"].ToString(); //protected static string _PROVINCECODE = ConfigurationManager.AppSettings["PROVINCE_CODE"].ToString(); public void ProcessRequest(HttpContext context) { DataTable _DataTable = null; string action_type = HttpContext.Current.Request.Form["action_type"]; string action_data = HttpContext.Current.Request.Form["action_data"]; string action_record = HttpContext.Current.Request.Form["action_record"]; string token = HttpContext.Current.Request.Form["token"]; string reString = string.Empty, StrSql = string.Empty; int pageSize = 10;//每页显示多少条 int pageIndex = 1;//页码 int count = 0; //总记录数 ServiceModel.Transaction _Transaction = new ServiceModel.Transaction(); Common.ResultObject _ResultObject = new Common.ResultObject(); if (string.IsNullOrEmpty(action_type)) { action_type = HttpContext.Current.Request.Params["action_type"]; action_data = HttpContext.Current.Request.Params["action_data"]; action_record = HttpContext.Current.Request.Params["action_record"]; token = HttpContext.Current.Request.Params["token"]; } //耗时监听 Stopwatch sw = new Stopwatch(); sw.Start(); try { switch (action_type) { //同步用户账户 case "SysncUserToThird": CommonInterface.BaseInformation.SysncUserToThird(); break; //获取图库列表 case "GetPictureList": reString = CommonInterface.BaseInformation.GetPictureList(_Transaction); break; //从API获取节假日写入数据库方便以后查询 case "AddHolidayDate": reString = CommonInterface.BaseInformation.AddHolidayDate(_Transaction); break; //异步计算员工薪资 case "SalaryCalculate": reString = CommonInterface.BaseInformation.SalaryCalculate(_Transaction).ToString(); break; default: break; } if (_Transaction.IsOpen) { _Transaction.AutoCommit(); } } catch (Exception ex) { SuperMap.RealEstate.Utility.ErrorLogHelper.Write(ex); } finally { _Transaction.Release(); _Transaction.Dispose(); } sw.Stop(); HZQR.Common.LogUtil.WriteLog(null, action_type + "接口耗时:" + sw.Elapsed.TotalSeconds.ToString(), DateTime.Now.ToString("yyyyMMdd") + "_Ex"); context.Response.ContentType = "text/plain"; context.Response.Write(reString); context.Response.End(); } public bool IsReusable { get { return false; } } #region 方法 -> Json 字符串 转换为 DataTable数据集合 /// /// Json 字符串 转换为 DataTable数据集合 /// /// /// public static DataTable ToDataTable(string json) { DataTable dataTable = new DataTable(); //实例化 DataTable result; try { JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer(); javaScriptSerializer.MaxJsonLength = Int32.MaxValue; //取得最大数值 ArrayList arrayList = javaScriptSerializer.Deserialize(json); if (arrayList.Count > 0) { foreach (Dictionary dictionary in arrayList) { if (dictionary.Keys.Count == 0) { result = dataTable; return result; } //Columns if (dataTable.Columns.Count == 0) { foreach (string current in dictionary.Keys) { if (Common.IsType(dictionary[current].GetType(), "System.Nullable`1[System.Int16]") || Common.IsType(dictionary[current].GetType(), "System.Nullable`1[System.Int32]") || Common.IsType(dictionary[current].GetType(), "System.Nullable`1[System.Int64]") || Common.IsType(dictionary[current].GetType(), "System.Nullable`1[System.Double]") || Common.IsType(dictionary[current].GetType(), "System.Nullable`1[System.Decimal]") || dictionary[current].GetType() == typeof(System.Int16) || dictionary[current].GetType() == typeof(System.Int32) || dictionary[current].GetType() == typeof(System.Int64) || dictionary[current].GetType() == typeof(System.Double) || dictionary[current].GetType() == typeof(System.Decimal)) { dataTable.Columns.Add(current, typeof(System.Decimal)); } else { dataTable.Columns.Add(current, dictionary[current].GetType()); } } } //Rows DataRow dataRow = dataTable.NewRow(); foreach (string current in dictionary.Keys) { try { dataRow[current] = dictionary[current]; } catch { } } dataTable.Rows.Add(dataRow); //循环添加行到DataTable中 } } } catch (Exception ex) { ErrorLogHelper.Write(ex); } result = dataTable; return result; } #endregion public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) { return true; } } }