/// <summary> /// 初始化jquery的引用,目地是asp.net从bin目录下拷贝到应用跟目录,获得目录的html访问权限 /// </summary> /// <param name="globalServer">HttpServerUtility对象Server</param> /// <param name="ILog1">ILog对象</param> public void initJquery(System.Web.HttpServerUtility globalServer, log4net.ILog ILog1) { string result = moveHTML(globalServer.MapPath("bin/jqueryJs"), globalServer.MapPath("jqueryJs")); if (result != null) { ILog1.Info("jquery初始化失败:" + result); } }
/// <summary> /// 初始化Bootstrap的引用,目地是asp.net从bin目录下拷贝到应用跟目录,获得目录的html访问权限 /// </summary> /// <param name="globalServer">HttpServerUtility对象Server</param> /// <param name="ILog1">ILog对象</param> public void initBootstrap(System.Web.HttpServerUtility globalServer,log4net.ILog ILog1) { string result = moveHTML(globalServer.MapPath("bin/bootstrapCss"), globalServer.MapPath("bootstrapCss")); if (result != null) { ILog1.Info("Bootstrap初始化失败:" + result); } result = moveHTML(globalServer.MapPath("bin/bootstrapJs"), globalServer.MapPath("bootstrapJs")); if (result != null) { ILog1.Info("Bootstrap初始化失败:" + result); } result = moveHTML(globalServer.MapPath("bin/fonts"), globalServer.MapPath("fonts")); if (result != null) { ILog1.Info("Bootstrap初始化失败:" + result); } }
/// <summary> /// 初始化html库的引用,目地是asp.net从bin目录下拷贝到应用跟目录,获得目录的html访问权限 /// </summary> /// <param name="globalServer">HttpServerUtility对象Server</param> /// <param name="ILog1">ILog对象</param> public void initHtmlLibrary(System.Web.HttpServerUtility globalServer, log4net.ILog ILog1) { string result = moveHTML(globalServer.MapPath("bin/CSSLibrary"), globalServer.MapPath("CSSLibrary")); if (result != null) { ILog1.Info("HtmlLibrary初始化失败:" + result); } result = moveHTML(globalServer.MapPath("bin/ImgLibrary"), globalServer.MapPath("ImgLibrary")); if (result != null) { ILog1.Info("HtmlLibrary初始化失败:" + result); } result = moveHTML(globalServer.MapPath("bin/JSLibrary"), globalServer.MapPath("JSLibrary")); if (result != null) { ILog1.Info("HtmlLibrary初始化失败:" + result); } result = moveHTML(globalServer.MapPath("bin/fonts"), globalServer.MapPath("fonts")); if (result != null) { ILog1.Info("HtmlLibrary初始化失败:" + result); } }
/// <summary> /// 执行sql非查询操作,并输出日志到ILog1 /// </summary> /// <param name="MysqlClass1">MysqlClass对象</param> /// <param name="sqlString">sql非查询语句</param> /// <param name="businessLog">mysql执行成功时的log4net.ILog对象</param> /// <param name="errorLog">mysql执行失败时的log4net.ILog对象</param> /// <param name="logHeadString">log4net日志每一行的前面字符</param> /// <returns>mysql语句执行成功返回true,失败返回false</returns> public bool doMysqlAlterWithLog4net(MysqlClass MysqlClass1, string sqlString, log4net.ILog businessLog, log4net.ILog errorLog, string logHeadString) { lock (MysqlClass1) { bool queryResult = doMysqlAlter(MysqlClass1, sqlString); if (!queryResult) { errorLog.Info(logHeadString + "mysql插入失败:" + sqlString + ":" + MysqlClass1.exceptionString); return false; } else { businessLog.Info(logHeadString + "mysql插入成功:" + sqlString); MysqlClass1.exceptionString = null; return true; } } }
private void Log(log4net.ILog logger, LogLevel logLevel, string message, Exception excpetion) { switch (logLevel) { case LogLevel.Debug: if (logger.IsDebugEnabled) logger.Debug(message, excpetion); break; case LogLevel.Info: if (logger.IsInfoEnabled) logger.Info(message, excpetion); break; case LogLevel.Warn: if (logger.IsWarnEnabled) logger.Warn(message, excpetion); break; case LogLevel.Error: if (logger.IsErrorEnabled) logger.Error(message, excpetion); break; case LogLevel.Fatal: if (logger.IsFatalEnabled) logger.Fatal(message, excpetion); break; case LogLevel.Off: break; default: throw new Exception(string.Format("Unrecognized log level '{0}'.", logLevel.ToString())); } }
private void LogInformation(Object[] logObjects, log4net.ILog logger) { int count = 0; StringBuilder formatSt = new StringBuilder(); foreach (Object obj in logObjects) formatSt.Append("{" + (count++) + "};"); String statusLog = String.Format(formatSt.ToString(), logObjects); logger.Info(statusLog); }
public static void QuanShiPushChange(string sysId, int newStatus, log4net.ILog logger) { string msgId = GetMsgId(sysId); try { string data = TaskPush.CreateQuanShiToKen(); LoginRequestModel re = new LoginRequestModel(); re = JsonConvert.DeserializeObject<LoginRequestModel>(data); if (re.crrorCode == 0) { OANewsChangeModel ch = new OANewsChangeModel() { username = re.data.username, token = re.data.token }; OANewsChangeDataModel item = new OANewsChangeDataModel(); item.msgId = msgId; item.newStatus = newStatus; ch.data = item; string psp = JsonConvert.SerializeObject(ch); string dataCheck = TaskPush.PostWebRequest(QuanShiOASendChangeAPIUrl, psp, Encoding.UTF8); JObject obj = JObject.Parse(dataCheck); if (obj["errorCode"].ToString() == "0") { logger.Info("QuanShiPushChange_OA消息状态更新成功,请求数据:" + sysId + ",返回数据:" + dataCheck); } else { logger.Warn("QuanShiPushChange_OA消息状态更新失败,请求数据:" + sysId + ",返回数据:" + dataCheck); } } else { logger.Warn("QuanShiPushChange_管理员登录失败,请求数据:" + sysId + ",返回数据:" + data); } } catch (Exception ex) { logger.Error("QuanShiPushChange_Login请求失败,在执行过程中出现异常", ex); } }
public static int QuanShiPush(TaskDto task, string[] actions, log4net.ILog logger) { //_sem.Wait(); try { //var CreateQuanShiToKenAsync = TaskPush.CreateQuanShiToKenAsync(); //_sem.Wait(); string data = TaskPush.CreateQuanShiToKen(); LoginRequestModel re = new LoginRequestModel(); re = JsonConvert.DeserializeObject<LoginRequestModel>(data); if (re.crrorCode == 0) { OANewsModel oa = new OANewsModel(); oa.username = re.data.username; oa.token = re.data.token; OANewsDataModel oaData = new OANewsDataModel(); List<string> users = new List<string>(); if (string.IsNullOrEmpty(IsEmail)) { users.Add(task.Destination.Replace(WindowDomain + @"\", "")); } else { users.Add(task.Destination.Replace(WindowDomain + @"\", "") + IsEmail); } oaData.toUsers = users.ToArray(); oaData.toPartyIds = new int[] { }; oaData.appId = 136; oaData.title = task.Folio; oaData.color = "red"; oaData.status = 11; oaData.elements = new List<object>(); string sharedUser = string.IsNullOrEmpty(task.SharedUser) ? "null" : task.SharedUser; oaData.detailURL = string.Format(TaskUrl + "task/{0}/{1}/{2}/{3}", task.SN, task.ProcInstID, System.Web.HttpUtility.UrlEncode(task.Destination), sharedUser); oaData.detailAuth = 1; //申请信息 OANewsDataTextRichModel text1 = new OANewsDataTextRichModel(); text1.type = "text"; //text1.status = 11; text1.content = new List<OANewsDataTextContentModel>(); OANewsDataTextContentModel content = new OANewsDataTextContentModel() { size = 2, bold = 1, text = "申请信息" }; text1.content.Add(content); oaData.elements.Add(text1); OANewsDataTextModel text6 = new OANewsDataTextModel() { type = "text", content = " " }; oaData.elements.Add(text6); //申请人 OANewsDataTextRichModel text2 = new OANewsDataTextRichModel(); text2.type = "text"; //text2.status = 11; text2.content = new List<OANewsDataTextContentModel>(); content = new OANewsDataTextContentModel() { bold = 1, text = "申请人:" }; text2.content.Add(content); content = new OANewsDataTextContentModel() { bold = 0, text = task.Originator }; text2.content.Add(content); oaData.elements.Add(text2); OANewsDataTextRichModel text3 = new OANewsDataTextRichModel(); text3.type = "text"; //text3.status = 11; text3.content = new List<OANewsDataTextContentModel>(); content = new OANewsDataTextContentModel() { bold = 1, text = "申请时间:" }; text3.content.Add(content); content = new OANewsDataTextContentModel() { bold = 0, text = task.StartDate.ToString("yyyy-MM-dd HH:mm") }; text3.content.Add(content); oaData.elements.Add(text3); OANewsDataTextRichModel text4 = new OANewsDataTextRichModel(); text4.type = "text"; //text4.status = 11; text4.content = new List<OANewsDataTextContentModel>(); content = new OANewsDataTextContentModel() { bold = 1, text = "当前环节:" }; text4.content.Add(content); content = new OANewsDataTextContentModel() { bold = 0, text = task.ActivityName }; text4.content.Add(content); oaData.elements.Add(text4); OANewsDataTextModel text7 = new OANewsDataTextModel() { type = "text", content = " " }; oaData.elements.Add(text7); //操作 OANewsDataTextRichModel text5 = new OANewsDataTextRichModel(); text5.type = "text"; text5.status = 11; text5.content = new List<OANewsDataTextContentModel>(); content = new OANewsDataTextContentModel() { size = 2, bold = 1, text = "操作" }; text5.content.Add(content); oaData.elements.Add(text5); //操作 OANewsDataTextRichModel text11 = new OANewsDataTextRichModel(); text11.type = "text"; text11.status = 12; text11.content = new List<OANewsDataTextContentModel>(); content = new OANewsDataTextContentModel() { size = 2, bold = 1, text = "操作" }; text11.content.Add(content); oaData.elements.Add(text11); OANewsDataTextRichModel text10 = new OANewsDataTextRichModel(); text10.type = "text"; text10.status = 12; text10.content = new List<OANewsDataTextContentModel>(); content = new OANewsDataTextContentModel() { color = "#FF0000", bold = 1, text = "审批过程中出现错误,请重试或联系管理员处理!" }; text10.content.Add(content); oaData.elements.Add(text10); // status=11 OANewsDataActionModel action = new OANewsDataActionModel(); action.type = "action"; action.status = 11; action.buttons = new List<OANewsDataButtonModel>(); Guid sysId = Guid.NewGuid(); foreach (var item in actions) { string actionUrl = string.Format(TaskUrl + "quanShiExecuteTask?ActionName={0}&SN={1}&Destination={2}&SharedUser={3}&ProcInstID={4}", System.Web.HttpUtility.UrlEncode(item), task.SN, System.Web.HttpUtility.UrlEncode(task.Destination), sharedUser, sysId); OANewsDataButtonModel button = new OANewsDataButtonModel() { title = item, url = actionUrl }; action.buttons.Add(button); } oaData.elements.Add(action); // status=11 action = new OANewsDataActionModel(); action.type = "action"; action.status = 12; action.buttons = new List<OANewsDataButtonModel>(); foreach (var item in actions) { string actionUrl = string.Format(TaskUrl + "quanShiExecuteTask?ActionName={0}&SN={1}&Destination={2}&SharedUser={3}&ProcInstID={4}", System.Web.HttpUtility.UrlEncode(item), task.SN, System.Web.HttpUtility.UrlEncode(task.Destination), sharedUser, sysId); OANewsDataButtonModel button = new OANewsDataButtonModel() { title = item, url = actionUrl }; action.buttons.Add(button); } oaData.elements.Add(action); //状态 OANewsDataTextRichModel text8 = new OANewsDataTextRichModel(); text8.type = "text"; text8.status = 1; text8.content = new List<OANewsDataTextContentModel>(); content = new OANewsDataTextContentModel() { bold = 1, color = "#808080", text = "状态:" }; text8.content.Add(content); content = new OANewsDataTextContentModel() { bold = 0, color = "#FF0000", text = "已处理" }; text8.content.Add(content); oaData.elements.Add(text8); OANewsDataTextRichModel text9 = new OANewsDataTextRichModel(); text9.type = "text"; text9.status = 9; text9.content = new List<OANewsDataTextContentModel>(); content = new OANewsDataTextContentModel() { bold = 1, color = "#808080", text = "状态:" }; text9.content.Add(content); content = new OANewsDataTextContentModel() { bold = 0, color = "#FF0000", text = "任务已经被处理" }; text9.content.Add(content); oaData.elements.Add(text9); oa.data = oaData; string psp = JsonConvert.SerializeObject(oa); //var CreateQuanShiOAAsync = TaskPush.CreateQuanShiOAAsync(psp); string dataCheck = TaskPush.PostWebRequest(QuanShiOASendAPIUrl, psp, Encoding.UTF8); JObject obj = JObject.Parse(dataCheck); if (obj["errorCode"].ToString() == "0") { QuanShiMsgModel msg = new QuanShiMsgModel() { sysId = sysId.ToString(), msgId = obj["data"][0]["msgId"].ToString() }; SaveMsgId(msg); logger.Info("QuanShiPush_任务推送请求成功,请求消息:" + psp + ";返回消息:" + dataCheck); } else { logger.Error("QuanShiPush_任务推送请求失败,请求消息:" + psp + ";返回消息:" + dataCheck); } } //_sem.Release(); return 1; } catch (Exception ex) { logger.Error("QuanShiPush_请求失败,在执行过程中出现异常", ex); //_sem.Release(); return 2; } }
/// <summary> /// 打印出asp.net服务器的错误 /// </summary> /// <param name="globalServer">System.Web.HttpServerUtility对象</param> /// <param name="Ilog1">log4net.ILog对象</param> public void doAspDotNetError(System.Web.HttpServerUtility globalServer, log4net.ILog Ilog1) { Exception lastExcetion = globalServer.GetLastError().GetBaseException(); Ilog1.Info("应用发生异常:" + lastExcetion.Message); }
/// <summary> /// 检查http请求的参数,如果参数不存在或者为空,则打印日志并停止该页执行,并回复给客户端指定的内容 /// </summary> /// <param name="context">HttpContext对象</param> /// <param name="para">参数名称</param> /// <param name="Ilog1">ILog对象</param> /// <param name="replyMessage">回复给客户端的内容</param> /// <returns>返回参数的值</returns> public string getParaWithLogAndReply(HttpContext context,string para,log4net.ILog Ilog1,string replyMessage) { para = getRequestPara(context, para); if (para == "") { Ilog1.Info(context.Request.Url+"该请求的参数"+para+"为空,停止执行该页面"); replyClient(context, replyMessage); } return para; }
protected void identifyPendingContexts(long delay,log4net.ILog log) { try { foreach (OrderContext cntx in _activeContextMap.Values) { if (cntx.isPending(delay)) { log.Info("identifyPendingContexts:pending:" + cntx.ToString()); } } } catch (Exception myE) { log.Error("identifyPendingContexts", myE); } }
/// <summary> /// mysql查询操作 /// </summary> /// <param name="MysqlClass1">MysqlClass对象</param> /// <param name="sqlCommand">sql语句</param> /// <param name="businessLog">mysql执行成功时的log4net.ILog对象</param> /// <param name="errorLog">mysql执行失败时的log4net.ILog对象</param> /// <param name="logHeadString">log4net日志每一行的前面字符</param> /// <returns>成功返回指定的json(按查询结果的行构建),失败返回null</returns> public string doMysqlSelectToRowsJsonWithLog4net(MysqlClass MysqlClass1, string sqlCommand, log4net.ILog businessLog, log4net.ILog errorLog, string logHeadString) { string result = null; DataTable DataTable1 = mysqlSelectToDataSet(MysqlClass1, sqlCommand); if (MysqlClass1.exceptionString != null) { errorLog.Info(logHeadString + "mysql查询失败:" + sqlCommand + ":" + MysqlClass1.exceptionString); return result; } businessLog.Info(logHeadString + "mysql查询成功:" + sqlCommand); StringBuilder jsonStringBuilder = new StringBuilder(); jsonStringBuilder.Append("["); for (int i = 0; i < DataTable1.Rows.Count; i++) { jsonStringBuilder.Append("["); for (int j = 0; j < DataTable1.Columns.Count; j++) { jsonStringBuilder.Append("\"" + DataTable1.Rows[i][j].ToString() + "\","); } //移除最后的逗号 if (jsonStringBuilder.ToString().Substring(jsonStringBuilder.Length - 1) == ",") { jsonStringBuilder.Remove(jsonStringBuilder.Length - 1, 1); } jsonStringBuilder.Append("],"); } //移除最后的逗号 if (jsonStringBuilder.ToString().Substring(jsonStringBuilder.Length - 1) == ",") { jsonStringBuilder.Remove(jsonStringBuilder.Length - 1, 1); } jsonStringBuilder.Append("]"); result = jsonStringBuilder.ToString(); MysqlClass1.exceptionString = null; return result; }
/// <summary> /// mysql查询操作 /// </summary> /// <param name="MysqlClass1">MysqlClass对象</param> /// <param name="sqlString">sql语句</param> /// <param name="businessLog">mysql执行成功时的log4net.ILog对象</param> /// <param name="errorLog">mysql执行失败时的log4net.ILog对象</param> /// <param name="logHeadString">log4net日志每一行的前面字符</param> /// <returns>返回DataTable类型的结果</returns> public DataTable doMysqlSelectToDataSetWithLog4net(MysqlClass MysqlClass1, string sqlString, log4net.ILog businessLog, log4net.ILog errorLog, string logHeadString) { DataTable DataTable1 = mysqlSelectToDataSet(MysqlClass1, sqlString); if (MysqlClass1.exceptionString != null) { errorLog.Info(logHeadString + "mysql查询失败:" + sqlString + ":" + MysqlClass1.exceptionString); return null; } businessLog.Info(logHeadString + "mysql查询成功:" + sqlString); MysqlClass1.exceptionString = null; return DataTable1; }