public static void ProcessUserCenterDb(BaseUserInfo userInfo, ServiceInfo parameter, ProcessFun fun) { if (BaseSystemInfo.IsAuthorized(userInfo)) { ProcessDb(parameter, fun, DbType.UserCenter); } }
public static void ProcessUserCenterWriteDbWithLock(BaseUserInfo userInfo, ServiceInfo parameter, object locker, ProcessFunWithLock fun) { if (BaseSystemInfo.IsAuthorized(userInfo)) { int milliStart = Begin(parameter.UserInfo, parameter.CurrentMethod); bool getOnLine = false; lock (locker) { using (IDbHelper dbHelper = DbHelperFactory.GetHelper(GetDbType(DbType.UserCenterWrite))) { try { dbHelper.Open(GetDbConnection(DbType.UserCenterWrite)); getOnLine = fun(dbHelper, getOnLine); AddLog(parameter); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, parameter.UserInfo, ex); throw; } finally { dbHelper.Close(); } } } End(parameter.UserInfo, milliStart, parameter.CurrentMethod, getOnLine); } }
public static void ProcessUserCenterWriteDbWithTransaction(BaseUserInfo userInfo, ServiceInfo parameter, ProcessFun fun) { if (BaseSystemInfo.IsAuthorized(userInfo)) { ProcessDb(parameter, fun, DbType.UserCenterWrite, true); } }
/// <summary> /// 获取用户的角色列表 /// </summary> /// <param name="userInfo">用户</param> /// <returns>数据表</returns> public DataTable GetRoleDT(BaseUserInfo userInfo) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) BaseSystemInfo.IsAuthorized(userInfo); #endif DataTable dataTable = new DataTable(BaseRoleEntity.TableName); using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseRoleEntity.FieldEnabled, 1)); parameters.Add(new KeyValuePair <string, object>(BaseRoleEntity.FieldDeletionStateCode, 0)); BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo); // 获取有效的,未必删除的数据,按排序码排序 dataTable = roleManager.GetDataTable(parameters, BaseRoleEntity.FieldSortCode); // 不是超级管理员,不能添加超级管理员 if (!userInfo.IsAdministrator) { foreach (DataRow dataRow in dataTable.Rows) { if (dataRow[BaseRoleEntity.FieldCode].ToString().Equals(DefaultRole.Administrators.ToString())) { dataRow.Delete(); } } dataTable.AcceptChanges(); } dataTable.TableName = BaseUserEntity.TableName; dataTable.DefaultView.Sort = BaseUserEntity.FieldSortCode; BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.UserService_GetRoleDT, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(dataTable); }
public static void ProcessUserCenterWriteDbWithLock(BaseUserInfo userInfo, ServiceInfo parameter, object locker, ProcessFun fun) { if (BaseSystemInfo.IsAuthorized(userInfo)) { int milliStart = Begin(parameter.UserInfo, parameter.CurrentMethod); lock (locker) { ProcessDbHelp(parameter, fun, DbType.UserCenterWrite, false); } End(parameter.UserInfo, milliStart, parameter.CurrentMethod); } }
/// <summary> /// 获取角色列表 /// </summary> /// <param name="userInfo">用户</param> /// <returns>数据表</returns> public DataTable GetDataTable(BaseUserInfo userInfo) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) BaseSystemInfo.IsAuthorized(userInfo); #endif DataTable dataTable = new DataTable(BaseRoleEntity.TableName); using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); string tableName = BaseRoleEntity.TableName; if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode)) { tableName = BaseSystemInfo.SystemCode + "Role"; } // 获得角色列表 BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo, tableName); List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseRoleEntity.FieldDeletionStateCode, 0)); parameters.Add(new KeyValuePair <string, object>(BaseRoleEntity.FieldEnabled, 1)); parameters.Add(new KeyValuePair <string, object>(BaseRoleEntity.FieldIsVisible, 1)); dataTable = roleManager.GetDataTable(parameters, BaseRoleEntity.FieldSortCode); dataTable.TableName = BaseRoleEntity.TableName; BaseLogManager.Instance.Add(dbHelper, userInfo, serviceName, AppMessage.RoleService_GetDataTable, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(dataTable); }
/// <summary> /// 用户登录 /// </summary> /// <param name="userInfo">用户</param> /// <param name="userName">用户名</param> /// <param name="password">密码</param> /// <param name="ipAddress">IP地址</param> /// <param name="statusCode">返回状态码</param> /// <param name="statusMessage">返回状消息</param> /// <returns>用户实体</returns> public BaseUserInfo UserLogOn(BaseUserInfo userInfo, string userName, string password, bool createOpenId, out string returnStatusCode, out string returnStatusMessage) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif returnStatusCode = StatusCode.DbError.ToString(); returnStatusMessage = string.Empty; // 加强安全验证防止未授权匿名调用 #if (!DEBUG) BaseSystemInfo.IsAuthorized(userInfo); #endif BaseUserInfo returnUserInfo = null; // statusCode = ServiceSecurityContext.Current.PrimaryIdentity.Name; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo); // 先侦测是否在线 userManager.CheckOnLine(); // 再进行登录 returnUserInfo = userManager.LogOn(userName, password, createOpenId); returnStatusCode = userManager.ReturnStatusCode; returnStatusMessage = userManager.GetStateMessage(returnStatusCode); // 登录时会自动记录进行日志记录,所以不需要进行重复日志记录 // BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart, ConsoleColor.Red); #endif return(returnUserInfo); }
/// <summary> /// 添加用户 /// </summary> /// <param name="dbHelper">数据库连接</param> /// <param name="userInfo">用户信息</param> /// <param name="entity">用户实体</param> /// <param name="userLogonEntity">用户登录实体</param> /// <param name="userContactEntity">用户联系方式</param> /// <param name="status">状态</param> /// <param name="statusMessage">状态信息</param> /// <returns>主键</returns> public string CreateUser(IDbHelper dbHelper, BaseUserInfo userInfo, BaseUserEntity entity, BaseUserLogonEntity userLogonEntity, BaseUserContactEntity userContactEntity, out Status status, out string statusMessage) { var result = string.Empty; // 加强安全验证防止未授权匿名调用 #if (!DEBUG) BaseSystemInfo.IsAuthorized(userInfo); #endif var userManager = new BaseUserManager(dbHelper, userInfo); result = userManager.AddUser(entity, userLogonEntity); status = userManager.Status; statusMessage = userManager.GetStateMessage(); // 20140219 JiRiGaLa 添加成功的用户才增加联系方式 if (!string.IsNullOrEmpty(result) && status == Status.OkAdd && userContactEntity != null) { // 添加联系方式 userContactEntity.UserId = int.Parse(result); var userContactManager = new BaseUserContactManager(dbHelper, userInfo); userContactEntity.CompanyId = entity.CompanyId; userContactManager.Add(userContactEntity); } // 自己不用给自己发提示信息,这个提示信息是为了提高工作效率的,还是需要审核通过的,否则垃圾信息太多了 if (entity.Enabled == 0 && status == Status.OkAdd) { // 不是系统管理员添加 if (!BaseUserManager.IsAdministrator(userInfo.Id)) { // 给超级管理员群组发信息 var roleManager = new BaseRoleManager(dbHelper, userInfo); var roleIds = roleManager.GetIds(new KeyValuePair <string, object>(BaseRoleEntity.FieldCode, "Administrators")); var userIds = userManager.GetIds(new KeyValuePair <string, object>(BaseUserEntity.FieldCode, "Administrator")); // 发送请求审核的信息 //var messageEntity = new BaseMessageEntity //{ // FunctionCode = MessageFunction.WaitForAudit.ToString(), // // Pcsky 2012.05.04 显示申请的用户名 // Contents = userInfo.RealName + "(" + userInfo.IpAddress + ")" + AppMessage.UserServiceApplication + entity.UserName + AppMessage.UserServiceCheck //}; //messageEntity.Contents = result.RealName + "(" + result.IPAddress + ")" + AppMessage.UserService_Application + userEntity.RealName + AppMessage.UserService_Check; //var messageManager = new BaseMessageManager(dbHelper, userInfo); //messageManager.BatchSend(userIds, null, roleIds, messageEntity, false); } } return(result); }
/// <summary> /// 按用户名登录 /// </summary> /// <param name="userInfo">用户</param> /// <param name="userName">用户名</param> /// <param name="returnStatusCode">返回状态码</param> /// <param name="returnStatusMessage">返回状消息</param> /// <returns>用户实体</returns> public BaseUserInfo LogOnByUserName(BaseUserInfo userInfo, string userName, out string returnStatusCode, out string returnStatusMessage) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) BaseSystemInfo.IsAuthorized(userInfo); #endif BaseUserInfo returnUserInfo = null; returnStatusCode = string.Empty; returnStatusMessage = string.Empty; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo); // 先侦测是否在线 userManager.CheckOnLine(); // 再进行登录 returnUserInfo = userManager.LogOnByUserName(userName, userInfo.IPAddress, userInfo.MACAddress); returnStatusCode = userManager.ReturnStatusCode; returnStatusMessage = userManager.GetStateMessage(); // 登录时会自动记录进行日志记录,所以不需要进行重复日志记录 // BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(returnUserInfo); }
/// <summary> /// 获得用户列表 /// </summary> /// <param name="userInfo">用户</param> /// <returns>数据表</returns> public DataTable GetUserDT(BaseUserInfo userInfo) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) BaseSystemInfo.IsAuthorized(userInfo); #endif DataTable dataTable = new DataTable(BaseUserEntity.TableName); using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); // 检查用户在线状态(服务器专用) BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo); userManager.CheckOnLine(); // 获取允许登录列表 List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldEnabled, 1)); parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldDeletionStateCode, 0)); dataTable = userManager.GetDataTable(parameters, BaseUserEntity.FieldSortCode); dataTable.TableName = BaseUserEntity.TableName; BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.LogOnService_GetUserDT, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(dataTable); }
/// <summary> /// 获取部门列表 /// </summary> /// <param name="userInfo">用户</param> /// <param name="parameters">参数</param> /// <returns>数据表</returns> public DataTable GetDataTable(BaseUserInfo userInfo, List <KeyValuePair <string, object> > parameters) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) BaseSystemInfo.IsAuthorized(userInfo); #endif DataTable dataTable = new DataTable(BaseOrganizeEntity.TableName); using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); // 获得组织机构列表 BaseOrganizeManager organizeManager = new BaseOrganizeManager(dbHelper, userInfo); dataTable = organizeManager.GetDataTable(parameters, BaseOrganizeEntity.FieldSortCode); dataTable.DefaultView.Sort = BaseOrganizeEntity.FieldSortCode; dataTable.TableName = BaseOrganizeEntity.TableName; BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.OrganizeService_GetDataTable, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(dataTable); }
/// <summary> /// 添加用户 /// </summary> /// <param name="dbHelper">数据库连接</param> /// <param name="userInfo">用户信息</param> /// <param name="userEntity">用户实体</param> /// <param name="statusCode">状态码</param> /// <param name="statusMessage">状态信息</param> /// <returns>主键</returns> public string AddUser(IDbHelper dbHelper, BaseUserInfo userInfo, BaseUserEntity userEntity, out string statusCode, out string statusMessage) { // 加强安全验证防止未授权匿名调用 #if (!DEBUG) BaseSystemInfo.IsAuthorized(userInfo); #endif string returnValue = string.Empty; BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo); // 若是系统需要用加密的密码,这里需要加密密码。 if (BaseSystemInfo.ServerEncryptPassword) { userEntity.UserPassword = userManager.EncryptUserPassword(userEntity.UserPassword); // 安全通讯密码、交易密码也生成好 userEntity.CommunicationPassword = userManager.EncryptUserPassword(userEntity.CommunicationPassword); } returnValue = userManager.Add(userEntity, out statusCode); statusMessage = userManager.GetStateMessage(statusCode); // 自己不用给自己发提示信息,这个提示信息是为了提高工作效率的,还是需要审核通过的,否则垃圾信息太多了 if (userEntity.Enabled == 0 && statusCode.Equals(StatusCode.OKAdd.ToString())) { // 不是系统管理员添加 if (!userInfo.IsAdministrator) { // 给超级管理员群组发信息 BaseRoleManager roleManager = new BaseRoleManager(dbHelper, userInfo); string[] roleIds = roleManager.GetIds(new KeyValuePair <string, object>(BaseRoleEntity.FieldCode, "Administrators")); string[] userIds = userManager.GetIds(new KeyValuePair <string, object>(BaseUserEntity.FieldCode, "Administrator")); // 发送请求审核的信息 BaseMessageEntity messageEntity = new BaseMessageEntity(); messageEntity.FunctionCode = MessageFunction.WaitForAudit.ToString(); // Pcsky 2012.05.04 显示申请的用户名 messageEntity.Contents = userInfo.RealName + "(" + userInfo.IPAddress + ")" + AppMessage.UserService_Application + userEntity.UserName + AppMessage.UserService_Check; //messageEntity.Contents = userInfo.RealName + "(" + userInfo.IPAddress + ")" + AppMessage.UserService_Application + userEntity.RealName + AppMessage.UserService_Check; BaseMessageManager messageManager = new BaseMessageManager(dbHelper, userInfo); messageManager.BatchSend(userIds, null, roleIds, messageEntity, false); } } return(returnValue); }
/// <summary> /// 更新员工 /// </summary> /// <param name="userInfo">用户</param> /// <param name="staffEntity">实体</param> /// <param name="statusCode">返回状态码</param> /// <param name="statusMessage">返回状消息</param> /// <returns>影响行数</returns> public int UpdateStaff(BaseUserInfo userInfo, BaseStaffEntity staffEntity, out string statusCode, out string statusMessage) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 if (!BaseSystemInfo.IsAuthorized(userInfo)) { throw new Exception(AppMessage.MSG0800); } int returnValue = 0; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); // 3.员工的修改 BaseStaffManager staffManager = new BaseStaffManager(dbHelper, userInfo); returnValue = staffManager.Update(staffEntity, out statusCode); statusMessage = staffManager.GetStateMessage(statusCode); BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.StaffService_UpdateStaff, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(returnValue); }
/// <summary> /// 添加用户 /// </summary> /// <param name="userInfo">用户信息</param> /// <param name="userEntity">用户实体</param> /// <param name="statusCode">状态码</param> /// <param name="statusMessage">状态信息</param> /// <returns>主键</returns> public string AddUser(BaseUserInfo userInfo, BaseUserEntity userEntity, out string statusCode, out string statusMessage) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) BaseSystemInfo.IsAuthorized(userInfo); #endif string returnValue = string.Empty; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); returnValue = AddUser(dbHelper, userInfo, userEntity, out statusCode, out statusMessage); BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.UserService_AddUser, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(returnValue); }
/// <summary> /// 获取实体 /// </summary> /// <param name="userInfo">用户</param> /// <param name="id">主键</param> /// <returns>实体</returns> public BaseOrganizeEntity GetEntity(BaseUserInfo userInfo, string id) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) BaseSystemInfo.IsAuthorized(userInfo); #endif BaseOrganizeEntity organizeEntity = null; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseOrganizeManager organizeManager = new BaseOrganizeManager(dbHelper, userInfo); organizeEntity = organizeManager.GetEntity(id); BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.OrganizeService_GetEntity, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return(organizeEntity); }
/// <summary> /// 用户是否已经登录了系统? /// </summary> /// <param name="taskId">任务标识</param> /// <param name="userInfo">用户</param> /// <returns>是否登录</returns> public static bool UserIsLogOn(string taskId, BaseUserInfo userInfo) { // 加强安全验证防止未授权匿名调用 if (!BaseSystemInfo.IsAuthorized(userInfo)) { throw new Exception(AppMessage.MSG0800); } // 这里表示是没登录过的用户 // if (string.IsNullOrEmpty(result.OpenId)) // { // throw new Exception(AppMessage.MSG0900); // } // 确认用户是否登录了?是否进行了匿名的破坏工作 /* * IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbConnection); * var userManager = new BaseUserManager(dbHelper, result); * if (!userManager.UserIsLogOn(result)) * { * throw new Exception(AppMessage.MSG0900); * } */ return(true); }
public static int CollectSystemInfo() { if (IsRunningOnMono() == true) { FoxEventLog.WriteEventLog("Running on Mono is not supported!", EventLogEntryType.Error); Console.WriteLine("Running on Mono is not supported!"); return(1); } if (GetWineVersion() != "") { FoxEventLog.WriteEventLog("Running on Wine/CrossOver is not supported!", EventLogEntryType.Error); Console.WriteLine("Running on Wine/CrossOver is not supported!"); return(1); } SysInfo = new BaseSystemInfo(); SysInfo.RunningInWindowsPE = WindowsPE.IsRunningInWindowsPE; SysInfo.ComputerModel = GetComputerModel(); SysInfo.ComputerName = SystemInformation.ComputerName; SysInfo.CPU = GetCPU().ToString(); SysInfo.MachineID = RegistryData.MachineID; SysInfo.IsTSE = IsSystemTSE(); SysInfo.OSName = SysInfo.RunningInWindowsPE == true ? "Windows PE / MiniNT" : GetWindowsProduct(); SysInfo.OSSuite = GetOSSuite().ToString(); SysInfo.OSVerBuild = Environment.OSVersion.Version.Build; SysInfo.OSVerMaj = Environment.OSVersion.Version.Major; SysInfo.OSVerMin = Environment.OSVersion.Version.Minor; SysInfo.Language = CultureInfo.InstalledUICulture.Name; SysInfo.DisplayLanguage = CultureInfo.InstalledUICulture.EnglishName; SysInfo.RunningInHypervisor = ProgramAgent.CPP.IsInHypervisor(); SysInfo.BIOS = GetBIOSData(); SysInfo.BIOSType = ProgramAgent.CPP.FoxGetFirmwareType(); GetProcessorInfos(out SysInfo.NumberOfProcessors, out SysInfo.NumberOfLogicalProcessors, out SysInfo.TotalPhysicalMemory); SysInfo.CPUName = GetProcessorName(); SysInfo.SecureBootState = GetSecureBootState(); SysInfo.SystemRoot = Environment.GetFolderPath(Environment.SpecialFolder.Windows); SysInfo.SUSID = GetSUSID(); try { SysInfo.IsMeteredConnection = MeteredConnection.IsMeteredConnection(); } catch (Exception ee) { Debug.WriteLine(ee.ToString()); SysInfo.IsMeteredConnection = null; } OSVERSIONINFOEX os = new OSVERSIONINFOEX(); os.dwOSVersionInfoSize = Marshal.SizeOf(os); GetVersionEx(ref os); SysInfo.OSVerType = os.wSuiteMask; #if DEBUG SysInfo.AgentVersion = VulpesBranding.AgentIdentifier + " [DEBUG] " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); #else SysInfo.AgentVersion = VulpesBranding.AgentIdentifier + " " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); #endif SysInfo.AgentVersionID = FoxVersion.Version; CPUType CPU = GetCPU(); if (CPU != CPUType.Intel32 && CPU != CPUType.EM64T && CPU != CPUType.ARM64) { FoxEventLog.WriteEventLog("Only i386, AMD64 (EM64T) or ARM64 CPU are supported!", EventLogEntryType.Error); return(1); } if (CPU == CPUType.EM64T) { if (Is64Bit() == null) { FoxEventLog.WriteEventLog("Cannot determine WOW state.", EventLogEntryType.Error); return(1); } if (Is64Bit() == false && CPU == CPUType.EM64T) { FoxEventLog.WriteEventLog("If you've a 64 bit CPU, then run this process as 64 bit!!!!", EventLogEntryType.Error); return(1); } SysInfo.Is64Bit = Is64Bit().Value; } else { SysInfo.Is64Bit = false; } if (SysInfo.MachineID == "") { FoxEventLog.WriteEventLog("Cannot get machine ID.", EventLogEntryType.Error); return(1); } if (SysInfo.ComputerModel == null) { FoxEventLog.WriteEventLog("Cannot get Computer Model.", EventLogEntryType.Error); return(1); } PasswordID = RegistryData.MachinePassword; if (PasswordID == "") { FoxEventLog.WriteEventLog("Cannot get PassID.", EventLogEntryType.Error); return(1); } if (SysInfo.OSSuite == "Unknown") { FoxEventLog.WriteEventLog("Unknown OS Suite.", EventLogEntryType.Error); return(1); } if (RegistryData.UseOnPrem == true) { ServerURL = RegistryData.ServerURL; } else { ServerURL = ProgramAgent.VulpesURL; } if (ServerURL == "") { FoxEventLog.WriteEventLog("Cannot get Server URL.", EventLogEntryType.Error); return(1); } ProgramData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); if (ProgramData.EndsWith("\\") == false) { ProgramData += "\\"; } ProgramData += "Fox\\SDC Agent\\"; try { if (Directory.Exists(ProgramData) == false) { Directory.CreateDirectory(ProgramData); } } catch { FoxEventLog.WriteEventLog("Error accessing " + ProgramData, EventLogEntryType.Error); return(1); } SysInfo.UCID = UCID.GetUCID(); SysInfo.LegacyUCID = UCID.GetUCIDLegacy(); if (RegistryData.UCIDOverride != "") { string UUU = RegistryData.UCIDOverride.Trim().ToUpper(); if (UUU.Length == 32) { FoxEventLog.WriteEventLog("UCID Overriden from " + SysInfo.UCID + " to " + UUU, EventLogEntryType.Warning); SysInfo.UCID = UUU; } } string SysInfoResumee = ""; ContractID = RegistryData.ContractID.Trim(); ContractPassword = RegistryData.ContractPassword; SysInfoResumee += "System Info:\r\n"; SysInfoResumee += "Agent: " + SysInfo.AgentVersion + "\r\n"; SysInfoResumee += SysInfo.OSName + "\r\n"; SysInfoResumee += "aka Windows NT " + SysInfo.OSVerMaj.ToString() + "." + SysInfo.OSVerMin.ToString() + "." + SysInfo.OSVerBuild.ToString() + "\r\n"; SysInfoResumee += "Suite: " + SysInfo.OSSuite + "\r\n"; SysInfoResumee += "Language: " + SysInfo.Language + " (" + SysInfo.DisplayLanguage + ")\r\n"; SysInfoResumee += "Bits: " + (SysInfo.Is64Bit == true ? "64 bit" : "32 bit") + "\r\n"; SysInfoResumee += "TSE: " + (SysInfo.IsTSE == false ? "no" : "yes") + "\r\n"; SysInfoResumee += "OS Suite: " + SysInfo.OSVerType + "\r\n"; SysInfoResumee += "CPU: " + CPU.ToString() + "\r\n"; SysInfoResumee += "Model: " + SysInfo.ComputerModel + "\r\n"; SysInfoResumee += "BIOS: " + SysInfo.BIOS + "\r\n"; SysInfoResumee += "Computername: " + SysInfo.ComputerName + "\r\n"; SysInfoResumee += "Machine ID: " + SysInfo.MachineID + "\r\n"; SysInfoResumee += "Server URL: " + ServerURL + "\r\n"; SysInfoResumee += "UCID: " + SysInfo.UCID + "\r\n"; SysInfoResumee += "Program Data: " + ProgramData + "\r\n"; SysInfoResumee += "Running in Hypervisor: " + (SysInfo.RunningInHypervisor == false ? "no" : "yes") + "\r\n"; FoxEventLog.WriteEventLog("Fox SDC Agent starting: " + SysInfoResumee, EventLogEntryType.Information); return(0); }
/// <summary> /// 职员登录,保存登录信息 /// </summary> /// <param name="userInfo">职员实体</param> private void Login(BaseUserInfo userInfo) { BaseSystemInfo.Login(userInfo); }