初始化
This commit is contained in:
347
Face.Services/Manager/Logs.cs
Normal file
347
Face.Services/Manager/Logs.cs
Normal file
@@ -0,0 +1,347 @@
|
||||
using Face.Services.Tool;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity.Validation;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
|
||||
namespace Face.Services.Manager
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志类
|
||||
/// </summary>
|
||||
public partial class Logs
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 锁1 路径/App_Data/Log/
|
||||
/// </summary>
|
||||
private static readonly object _lock = new object();
|
||||
|
||||
/// <summary>
|
||||
/// 锁2 路径/App_Data/TimingPlan/
|
||||
/// </summary>
|
||||
private static readonly object _lock1 = new object();
|
||||
|
||||
/// <summary>
|
||||
/// 锁3 路径/App_Data/UDPlog/
|
||||
/// </summary>
|
||||
private static readonly object _lockUdp = new object();
|
||||
|
||||
public static void WriteErrorLog(Exception ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ex != null)
|
||||
{
|
||||
string content = "类型:错误代码\r\n";
|
||||
content += "时间:" + DateTime.Now.ToString() + "\r\n";
|
||||
content += "来源:" + ex.TargetSite.ReflectedType.ToString() + "." + ex.TargetSite.Name + "\r\n";
|
||||
content += "内容:" + ex.Message + "\r\n";
|
||||
|
||||
Page page = new Page();
|
||||
HttpServerUtility server = page.Server;
|
||||
string dir = server.MapPath("/App_Data/Log/");
|
||||
if (!Directory.Exists(dir))
|
||||
{
|
||||
Directory.CreateDirectory(dir);
|
||||
}
|
||||
|
||||
string path = dir + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
|
||||
|
||||
StreamWriter FileWriter = new StreamWriter(path, true, System.Text.Encoding.UTF8); //创建日志文件
|
||||
FileWriter.Write("---------------------------------------------------\r\n");
|
||||
FileWriter.Write(content);
|
||||
FileWriter.Close(); //关闭StreamWriter对象
|
||||
|
||||
|
||||
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteLog(string msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(msg))
|
||||
{
|
||||
|
||||
string content = "类型:调试日志\r\n";
|
||||
content += "时间:" + DateTime.Now.ToString() + "\r\n";
|
||||
content += "内容:" + msg + "\r\n";
|
||||
|
||||
Page page = new Page();
|
||||
HttpServerUtility server = page.Server;
|
||||
string dir = server.MapPath("/App_Data/Log/");
|
||||
if (!Directory.Exists(dir))
|
||||
{
|
||||
Directory.CreateDirectory(dir);
|
||||
}
|
||||
|
||||
string path = dir + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
|
||||
|
||||
StreamWriter FileWriter = new StreamWriter(path, true, System.Text.Encoding.UTF8); //创建日志文件
|
||||
FileWriter.Write("---------------------------------------------------\r\n");
|
||||
FileWriter.Write(content);
|
||||
FileWriter.Close(); //关闭StreamWriter对象
|
||||
//}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteErrorLog(string errsrc, Exception ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
string errtxt = "";
|
||||
string exname = ex.GetType().ToString();
|
||||
if (exname == "System.Data.Entity.Validation.DbEntityValidationException")
|
||||
{
|
||||
foreach (var item in ((DbEntityValidationException)ex).EntityValidationErrors)
|
||||
{
|
||||
foreach (var err in item.ValidationErrors)
|
||||
{
|
||||
errtxt += "EntityValidationErrors >>>>>> “" + err.PropertyName + "”字段" + err.ErrorMessage + "\r\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string content = (!string.IsNullOrEmpty(errsrc) ? "来自页面:" + errsrc : "") + "\r\n";
|
||||
content += "发生时间:" + DateTime.Now.ToString() + "\r\n";
|
||||
content += "异常对像:" + ex.TargetSite.ReflectedType.ToString() + "." + ex.TargetSite.Name + "\r\n";
|
||||
content += "错误追踪:" + ex.StackTrace + "\r\n";
|
||||
content += "错误提示:" + ex.Message + "\r\n" + errtxt;
|
||||
if (ex.InnerException != null && ex.InnerException.InnerException != null)
|
||||
content += ex.InnerException.InnerException.Message + "\r\n";
|
||||
//if (BaseConfigs.GetLogInDB == 1)
|
||||
//{
|
||||
//TSysLog log = new TSysLog();
|
||||
//log.Content = content;
|
||||
//log.Type = "系统日志";
|
||||
//log.CreateTime = DateTime.Now;
|
||||
//DataAccess.CreateSysLog().Add(log);
|
||||
//}
|
||||
//if (BaseConfigs.GetLogInFile == 1)
|
||||
//{
|
||||
Page page = new Page();
|
||||
HttpServerUtility server = page.Server;
|
||||
string dir = server.MapPath("/App_Data/Log/");
|
||||
if (!Directory.Exists(dir))
|
||||
{
|
||||
Directory.CreateDirectory(dir);
|
||||
}
|
||||
|
||||
string path = dir + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
|
||||
|
||||
StreamWriter FileWriter = new StreamWriter(path, true, System.Text.Encoding.UTF8); //创建日志文件
|
||||
FileWriter.Write("---------------------------------------------------\r\n");
|
||||
FileWriter.Write(content);
|
||||
FileWriter.Close(); //关闭StreamWriter对象
|
||||
//}
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void WriteTimingPlanLog(string msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(msg))
|
||||
{
|
||||
|
||||
string content = "类型:调试日志 ";
|
||||
content += "时间:" + DateTime.Now.ToString() + " ";
|
||||
content += "内容:" + msg + "\r\n";
|
||||
|
||||
string dir = AppDomain.CurrentDomain.BaseDirectory + "/App_Data/TimingPlan/";
|
||||
if (!Directory.Exists(dir))
|
||||
{
|
||||
Directory.CreateDirectory(dir);
|
||||
}
|
||||
|
||||
string path = dir + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
|
||||
|
||||
lock (_lock1)
|
||||
{
|
||||
StreamWriter FileWriter = new StreamWriter(path, true, Encoding.UTF8); //创建日志文件
|
||||
//FileWriter.Write("---------------------------------------------------\r\n");
|
||||
FileWriter.Write(content);
|
||||
FileWriter.Close(); //关闭StreamWriter对象
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelp.WriteExceptionLog(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteErrorTimingPlanLog(string errsrc, Exception ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ex != null)
|
||||
{
|
||||
string content = (!string.IsNullOrEmpty(errsrc) ? "来自作业线程:" + errsrc : "") + "\r\n";
|
||||
content += "发生时间:" + DateTime.Now.ToString() + "\r\n";
|
||||
content += "异常对像:" + ex.TargetSite.ReflectedType.ToString() + "." + ex.TargetSite.Name + "\r\n";
|
||||
content += "错误追踪:" + ex.StackTrace + "\r\n";
|
||||
content += "错误提示:" + ex.Message + "\r\n";
|
||||
if (ex.InnerException != null && ex.InnerException.InnerException != null)
|
||||
content += ex.InnerException.InnerException.Message + "\r\n";
|
||||
|
||||
string dir = AppDomain.CurrentDomain.BaseDirectory + "/App_Data/TimingPlan/";
|
||||
if (!Directory.Exists(dir))
|
||||
{
|
||||
Directory.CreateDirectory(dir);
|
||||
}
|
||||
|
||||
string path = dir + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
|
||||
lock (_lock1)
|
||||
{
|
||||
StreamWriter FileWriter = new StreamWriter(path, true, Encoding.UTF8); //创建日志文件
|
||||
FileWriter.Write("---------------------------------------------------\r\n");
|
||||
FileWriter.Write(content);
|
||||
FileWriter.Close(); //关闭StreamWriter对象
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exl)
|
||||
{
|
||||
LogHelp.WriteExceptionLog(ex);
|
||||
LogHelp.WriteExceptionLog(exl);
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteTimingUDPLog(string msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(msg))
|
||||
{
|
||||
|
||||
string content = "类型:调试日志 ";
|
||||
content += "时间:" + DateTime.Now.ToString() + " ";
|
||||
content += "内容:" + msg + "\r\n";
|
||||
|
||||
string dir = AppDomain.CurrentDomain.BaseDirectory + "/App_Data/UDPLog/";
|
||||
if (!Directory.Exists(dir))
|
||||
{
|
||||
Directory.CreateDirectory(dir);
|
||||
}
|
||||
|
||||
string path = dir + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
|
||||
|
||||
lock (_lockUdp)
|
||||
{
|
||||
StreamWriter FileWriter = new StreamWriter(path, true, Encoding.UTF8); //创建日志文件
|
||||
//FileWriter.Write("---------------------------------------------------\r\n");
|
||||
FileWriter.Write(content);
|
||||
FileWriter.Close(); //关闭StreamWriter对象
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelp.WriteExceptionLog(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void WriteErrorTimingUDPLog(string errsrc, Exception ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ex != null)
|
||||
{
|
||||
string content = (!string.IsNullOrEmpty(errsrc) ? "来自作业线程:" + errsrc : "") + "\r\n";
|
||||
content += "发生时间:" + DateTime.Now.ToString() + "\r\n";
|
||||
content += "异常对像:" + ex.TargetSite.ReflectedType.ToString() + "." + ex.TargetSite.Name + "\r\n";
|
||||
content += "错误追踪:" + ex.StackTrace + "\r\n";
|
||||
content += "错误提示:" + ex.Message + "\r\n";
|
||||
if (ex.InnerException != null && ex.InnerException.InnerException != null)
|
||||
content += ex.InnerException.InnerException.Message + "\r\n";
|
||||
|
||||
string dir = AppDomain.CurrentDomain.BaseDirectory + "/App_Data/UDPLog/";
|
||||
if (!Directory.Exists(dir))
|
||||
{
|
||||
Directory.CreateDirectory(dir);
|
||||
}
|
||||
|
||||
string path = dir + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
|
||||
lock (_lockUdp)
|
||||
{
|
||||
StreamWriter FileWriter = new StreamWriter(path, true, Encoding.UTF8); //创建日志文件
|
||||
FileWriter.Write("---------------------------------------------------\r\n");
|
||||
FileWriter.Write(content);
|
||||
FileWriter.Close(); //关闭StreamWriter对象
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exl)
|
||||
{
|
||||
LogHelp.WriteExceptionLog(ex);
|
||||
LogHelp.WriteExceptionLog(exl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class LogHelp
|
||||
{
|
||||
/// <summary>
|
||||
/// 写入日志
|
||||
/// </summary>
|
||||
/// <param name="ex">异常对象</param>
|
||||
/// <param name="operationer">操作人</param>
|
||||
/// <param name="actionName">功能站点名称</param>
|
||||
public static void WriteExceptionLog(Exception ex, string operationer = "")
|
||||
{
|
||||
if (HttpContext.Current == null)
|
||||
{
|
||||
Log4Net.ExceptionLogHelper.Log(new Face.Log4Net.ExceptionLogMessage() { exception = ex, Header = "", Url = "线程", Operationer = "线程", IP = "" });
|
||||
}
|
||||
else
|
||||
{
|
||||
Log4Net.ExceptionLogHelper.Log(new Face.Log4Net.ExceptionLogMessage() { exception = ex, Header = HttpContext.Current.Request.Headers.ToString(), Url = HttpContext.Current.Request.Url.ToString(), Operationer = operationer, IP = IPHelper.GetIP() });
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写入日志
|
||||
/// </summary>
|
||||
/// <param name="ex">异常对象</param>
|
||||
/// <param name="operationer">操作人</param>
|
||||
/// <param name="actionName">功能站点名称</param>
|
||||
public static void WriteExceptionLogAddTxt(Exception ex, string operationer = "", string txt = "")
|
||||
{
|
||||
if (HttpContext.Current == null)
|
||||
{
|
||||
Log4Net.ExceptionLogHelper.Log(new Face.Log4Net.ExceptionLogMessage() { exception = ex, Header = "", Url = "线程", Operationer = "线程", IP = "" + txt });
|
||||
}
|
||||
else
|
||||
{
|
||||
Log4Net.ExceptionLogHelper.Log(new Face.Log4Net.ExceptionLogMessage() { exception = ex, Header = HttpContext.Current.Request.Headers.ToString(), Url = HttpContext.Current.Request.Url.ToString(), Operationer = operationer, IP = IPHelper.GetIP() });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
41
Face.Services/Manager/OperatorOperate.cs
Normal file
41
Face.Services/Manager/OperatorOperate.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Face.Domain.Entities;
|
||||
using Face.Domain.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Face.Services.Manager
|
||||
{
|
||||
public class OperatorOperate
|
||||
{
|
||||
|
||||
//public static ReturnResult<object> OperatorOperates(string Opname, List<UserInfo> opList)
|
||||
//{
|
||||
// ReturnResult<object> result = new ReturnResult<object>();
|
||||
// try
|
||||
// {
|
||||
// var project = opList.SingleOrDefault(x => x.Uid == Opname);
|
||||
// if (project == null)
|
||||
// {
|
||||
// result.Message = "无效";
|
||||
// return result;
|
||||
// }
|
||||
// var OpModel = new UserInfo()
|
||||
// {
|
||||
// //Operatorid = project.Id,
|
||||
// //name = project.Uid,
|
||||
|
||||
// };
|
||||
|
||||
// }
|
||||
// catch (System.Exception)
|
||||
// {
|
||||
|
||||
// throw;
|
||||
// }
|
||||
// return null;
|
||||
//}
|
||||
}
|
||||
}
|
||||
14
Face.Services/Manager/Users.cs
Normal file
14
Face.Services/Manager/Users.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace Face.Services.Manager
|
||||
{
|
||||
class Users
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user