/// <summary> /// 下载文件 /// </summary> /// <param name="path"></param> /// <returns>{ /// code:'success-成功,failed-失败', /// msg:'提示信息', /// filetype:'文件的content-type类型' /// filename:'文件名称', /// filelength:'文件长度', /// file:'文件内容,采用base64加密' /// }</returns> public object DoDownLoad(string path) { path = path.Replace("~", upload_root_path); if (!File.Exists(path)) { return(new { code = "failed", msg = "文件不存在" }); } var filecontent = File.ReadAllBytes(path); var width = ""; var height = ""; if (new string[] { "jpg", "png", "bmp", "gif", "jpeg" }.Contains(Path.GetExtension(path).Replace(".", "").ToLower())) { using (System.Drawing.Image image = System.Drawing.Image.FromFile(path)) { width = image.Width.ToString(); height = image.Height.ToString(); } } return(new { code = "success", msg = "", filetype = ResponseHeader_ContentType.Map(Path.GetExtension(path).ToLower().Replace(".", "")), filename = Path.GetFileName(path), filelength = filecontent.Count(), file = ComFunc.Base64Code(filecontent), pic_width = width, pic_heigth = height }); }
/// <summary> /// 转换成串 /// </summary> /// <returns></returns> public override string ToString() { string rtn = ""; rtn = ComFunc.Base64Code(this._id + ";" + this._expired + ";" + this._starttime.ToFileTimeUtc() + ";" + ComFunc.Enum2String <TransStatus>(this._transstatus)) + ";" + _isExpired; return(rtn); }
/// <summary> /// 通过公钥做key进行加密,AES算法 /// </summary> /// <param name="text"></param> /// <returns></returns> private string EncryptByPublicKey(string text) { if (string.IsNullOrEmpty(text)) { return(null); } var content = File.ReadAllText(PublicKeySavePath.Replace("~", CallContext_Parameter.ServerRootPath)); var key = ComFunc.getMD5_String(ComFunc.Base64Code(content)); Byte[] toEncryptArray = Encoding.UTF8.GetBytes(text); System.Security.Cryptography.RijndaelManaged rm = new System.Security.Cryptography.RijndaelManaged { Key = Encoding.UTF8.GetBytes(key), Mode = System.Security.Cryptography.CipherMode.ECB, Padding = System.Security.Cryptography.PaddingMode.PKCS7 }; System.Security.Cryptography.ICryptoTransform cTransform = rm.CreateEncryptor(); Byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); return(Convert.ToBase64String(resultArray, 0, resultArray.Length)); }
/// <summary> /// 将对象写入session /// </summary> /// <param name="session"></param> /// <param name="key"></param> /// <param name="value"></param> public static void SetObject(this ISession session, string key, object value) { if (value == null) { session.Remove(key); return; } var t = value.GetType(); string assemblyQualifiedName = t.AssemblyQualifiedName; var controlType = t.FullName; string assemblyInformation = assemblyQualifiedName.Substring(assemblyQualifiedName.IndexOf(",")); var assemblefullname = controlType + assemblyInformation; if (value is FrameDLRObject) { session.SetString(key, assemblefullname + ";" + ComFunc.Base64Code(((FrameDLRObject)value).ToJSONString())); } else if (value is IJSONable) { session.SetString(key, assemblefullname + ";" + ComFunc.Base64Code(((IJSONable)value).ToJSONString())); } else if (value is string) { session.SetString(key, assemblefullname + ";" + ComFunc.Base64Code(ComFunc.nvl(value))); } else if (value is int) { session.SetString(key, assemblefullname + ";" + ComFunc.Base64Code(ComFunc.nvl(value))); } else if (value is long) { session.SetString(key, assemblefullname + ";" + ComFunc.Base64Code(ComFunc.nvl(value))); } else if (value is double) { session.SetString(key, assemblefullname + ";" + ComFunc.Base64Code(ComFunc.nvl(value))); } else if (value is float) { session.SetString(key, assemblefullname + ";" + ComFunc.Base64Code(ComFunc.nvl(value))); } else if (value is decimal) { session.SetString(key, assemblefullname + ";" + ComFunc.Base64Code(ComFunc.nvl(value))); } else if (value is DateTime) { session.SetString(key, assemblefullname + ";" + ComFunc.Base64Code(((DateTime)value).ToString("yyyy/MM/dd HH:mm:ss fff"))); } else if (value is bool) { session.SetString(key, assemblefullname + ";" + ComFunc.Base64Code(ComFunc.nvl(value))); } else { FrameDLRObject dobj = FrameDLRObject.CreateInstance(value); session.SetString(key, assemblefullname + ";" + ComFunc.Base64Code(dobj.ToJSONString())); } }
public static void Test() { var s = ComFunc.getMD5_String("123"); var body = @"{ ""USER_ID"":""oa_app_0003"", ""CUST_ID"":""1000131460"", ""STATUS"":""1"", ""PAGE_SIZE"":500, ""CURRENT_PAGE"":1, ""START_DATE"":""2018-04-25 00:00:00"", ""END_DATE"":""2018-05-25 00:00:00"" }"; body = body.Replace("\r", ""); var key = "MIICYwIBAAKBgQDdxOYZnligFD/9/0WuurksM1Py8iGRZChGl6vSKlLUMm6uZ0t09+CF0x6QbF+2z1UcAO+sZXuwb06zZ4rsoR++XTOpTCz8CTK5uSIcI8kv9vrOH5xi1gJXu1MB8VdBWc0w2OTp4+3Euom+cnswBtqV7qcpcV1J9XFClKBiBgI43wIDAQABAoGBALE9npE3BqnZxVMg4/ZD8Z6r3xo5/i4PGEljCsXLYauKKv9kOuBfA6ixFKpkkxKuHd1luifUa8iVDRdBVvYGXzQgfzUm430Ju069JUU/uOsfT/0rhBZ7gooCT5tR00TOdvwvhT+qFH4Mgww85XLMsN53paiFAS/fhMl8tYIoIhMhAkUA+LR0AKQEDuzffdiBQZa6WoOXtnYwA4W/D4An2cIe8i2wRUsfObhaLh4nY9oyFFrJ8FeO9EF5pCjuHLZQxPL1b5F+w7kCPQDkRi7Gj8c0H1Mxqn6n31Ygc3zU4i7/YqjsnopQ5LpYl1qUl926JRVFCjlcStx/me86ao/0NuRAN+Yv3VcCRQDxdOjmslZKU0jL+kXLctXsCLRjbi1BTjlniCmobaHzx83KCJwBQu0ytw3REMbsIhTKZYehtmutqBs8/vg9rhABSIWE6QI9AIylPU6z6X2Qy1ZvgMf3z/4Aieo0TdamOARKDliXBMVuw62IAGIfVQKLsRnPOhoYgxAP9g/2/h0fE+Fr0wJFANOEUqkMaQ9p2Z2rP46Zmo31K45VIDhG3Ygwhv04egfftrB+O5hUeEsNlhwxOkaexr6VwlldtqisanmhMIINpw23vLD9"; var base64 = ComFunc.Base64Code(body); var sign = ComFunc.SHA256hash(base64 + "|" + key).ToLower(); }
object ExportReport(string id) { SetCacheEnable(false); dynamic result = FrameDLRObject.CreateInstance(QueryReport(id)); if (result.code != "success") { return(result); } var columns = ((IEnumerable <object>)result.columns).Select(d => (FrameDLRObject)FrameDLRObject.CreateInstance(d)).ToList(); var data = ((IEnumerable <object>)result.data).Select(d => (FrameDLRObject)FrameDLRObject.CreateInstance(d)).ToList(); var file = GenerateExcel(columns, data); return(new { code = "success", msg = "", filetype = ResponseHeader_ContentType.Map("xlsx"), filename = result.report_name, filelength = file.Length, file = ComFunc.Base64Code(file) }); }
public string Base64Encode(string str) { return(ComFunc.Base64Code(str)); }
/// <summary> /// 执行事件 /// </summary> /// <param name="up"></param> /// <param name="id"></param> /// <param name="this_data"></param> /// <returns></returns> private object DoCallEvent(UnitParameter up, string id, object this_data) { var list = (from t in DB.LamdaTable(up, "EXTEND_EVENTS", "a") where t.EventNo == id select new { no = t.EventNo, name = t.EventName, category = t.EventCategory, type = t.EventType, at = t.EventAt, parent = t. desc = t.EventDesc, parameters = t.EventParameters }).GetQueryList(up); if (list.Count <= 0) { return(new { code = "failed", msg = "执行失败:事件设定不存在" }); } dynamic info = list.First(); var event_call = new EventsCall(); var parameters = FrameDLRObject.IsJsonThen(info.parameters, null, FrameDLRFlags.SensitiveCase); if (parameters == null) { return(new { code = "failed", msg = "执行失败:确少执行参数" }); } string url = ComFunc.nvl(parameters.RequestUrl); string method = ComFunc.nvl(parameters.RequestMethod); FrameDLRObject query_string = ComFunc.nvl(parameters.RequestQueryString) == "" ? null : parameters.RequestQueryString; FrameDLRObject header = ComFunc.nvl(parameters.RequestHeader) == "" ? null : parameters.RequestHeaders; FrameDLRObject post_data = ComFunc.nvl(parameters.RequestPostData) == "" ? null : parameters.RequestPostData; var call_context = new EventsCall.EventsCallContext(); call_context.RowData = ComFunc.Base64Code(FrameDLRObject.CreateInstance(this_data, FrameDLRFlags.SensitiveCase).tojsonstring()); call_context.Login_ID = TokenPayLoad.ID; call_context.Login_Name = ComFunc.nvl(TokenPayLoad["username"]); if (url.StartsWith("~")) { return(CallLocalLogic(url.Replace("~", ""), method, header, query_string, post_data)); } else { if (query_string != null) { var qs = ""; foreach (var item in query_string.Items) { qs += $"{item.Key}={ComFunc.UrlEncode(item.Value)}&"; } qs = qs.Length > 0 ? qs.Substring(0, qs.Length - 1) : ""; if (url.IndexOf("?") > 0) { url += $"&{qs}"; } else { url += $"?{qs}"; } } string result = event_call.Send(url, method, call_context, header, post_data); if (result == null) { return(new { code = "failed", msg = "执行失败:返回结果为空" }); } else if (result.StartsWith("Failed:")) { return(new { code = "failed", msg = $"执行失败:{result}" }); } else { return(FrameDLRObject.IsJsonThen(result, null, FrameDLRFlags.SensitiveCase)); } } }