public void ProcessRequest(HttpContext context) { Common.Transfer Trans = new Common.Transfer(); try { HttpRequest Request = context.Request; Trans.Class = Request["Class"].ToString(); Trans.Command = Request["Command"].ToString(); Trans.Attribute = HttpUtility.UrlDecode(Request["Attribute"].ToString()); Trans.Mac = Request["Mac"].ToString(); //验证令牌请求 string HashString = Trans.Attribute.ToString() + DateTime.Now.ToString("yyyyMMdd") + "ERPSaveFile"; string Mac = AppPKI.getMd5Hash(HashString); if (Trans.Mac == Mac) { switch (Trans.Command) { case "SaveFile": Trans.Result = SaveFiles(context, Trans); break; default: break; } } else { Trans.Error = "验证令牌错误"; } } catch (Exception E) { Trans.Error = E.Message.ToString(); } context.Response.ContentType = "text/plain"; context.Response.Write(Trans.Output()); }
private void RecordOperationLog(Transfer transNew1) { Common.Transfer tranNew2 = new Transfer() { Result = transNew1.Result, Attribute = transNew1.Attribute, Command = transNew1.Command, Class = transNew1.Class, Mac = transNew1.Mac, QYID = transNew1.QYID, QYUnitType = transNew1.QYUnitType, ClassLog = transNew1.Class, CommandLog = transNew1.Command }; tranNew2.Class = "RecordClientInfo"; tranNew2.Command = "RecordOperationLog"; var HashString = tranNew2.Attribute.ToString() + DateTime.Now.ToString("yyyyMMdd") + "20200110Client"; tranNew2.Mac = AppPKI.getMd5Hash(HashString); PubContext.Operate(ref tranNew2); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.AddHeader("Access-Control-Allow-Origin", "*"); try { Common.Transfer Trans = new Common.Transfer(); HttpRequest Request = context.Request; Dictionary <string, string> param = new Dictionary <string, string>(); foreach (string key in Request.Form.AllKeys) { param.Add(key, Request.Params[key]); } if (!param.ContainsKey("Class")) { context.Response.Write(new ApiResult(false, "缺少参数Class").toJson()); return; } Trans.Class = param["Class"].ToString(); if (string.IsNullOrEmpty(Trans.Class)) { context.Response.Write(new ApiResult(false, "Class不能为空").toJson()); return; } if (!param.ContainsKey("Command")) { context.Response.Write(new ApiResult(false, "缺少参数Command").toJson()); return; } Trans.Command = param["Command"].ToString(); if (string.IsNullOrEmpty(Trans.Command)) { context.Response.Write(new ApiResult(false, "Command不能为空").toJson()); return; } string json = JsonConvert.SerializeObject(new { Attribute = param }); Trans.Attribute = JsonConvert.DeserializeXmlNode(json).OuterXml; if (string.IsNullOrEmpty(Trans.Attribute)) { context.Response.Write(new ApiResult(false, "Attribute不能为空").toJson()); return; } PubInfo Rp = (PubInfo)Assembly.Load("Business").CreateInstance("Business." + Trans.Class); var HashString = Trans.Attribute.ToString() + DateTime.Now.ToString("yyyyMMdd") + Rp.Token; var Mac = AppPKI.getMd5Hash(HashString); Trans.Mac = Mac; if (Trans.Class == "Files") { new Files().ProcessRequest(context); } else { PubContext.Operate(ref Trans); } Compress(context); context.Response.Write(Trans.Output()); } catch (Exception ex) { context.Response.Write(new ApiResult(false, ex.Message + Environment.NewLine + ex.StackTrace).toJson()); } }