public RegisteredApps Get(string appId)
 {
     try
     {
         return(List(0, 1, x => x.AppId == appId, null, null).List.FirstOrDefault());
     }
     catch (Exception ex)
     {
         _logger.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType + " " + System.Reflection.MethodBase.GetCurrentMethod().Name + " : " + ex.Message, ex);
         return(null);
     }
 }
 public string GenerateVerificationString()
 {
     try
     {
         var firstNum  = new Random().Next(999);
         var secondNum = new Random().Next(999);
         return(firstNum + "-" + secondNum);
     }
     catch (Exception ex)
     {
         _logger.Error(ex.Message, ex);
         return(null);
     }
 }
示例#3
0
        /// <summary>
        /// 构造函数,初始化计数器等
        /// </summary>
        public SystemInfo()
        {
            try
            {
                //初始化CPU计数器
                pcCpuLoad             = new PerformanceCounter("Processor", "% Processor Time", "_Total");
                pcCpuLoad.MachineName = ".";
                pcCpuLoad.NextValue();

                //CPU个数
                _processorCount = Environment.ProcessorCount;

                //获得物理内存
                ManagementClass            mc  = new ManagementClass("Win32_ComputerSystem");
                ManagementObjectCollection moc = mc.GetInstances();
                foreach (ManagementObject mo in moc)
                {
                    if (mo["TotalPhysicalMemory"] != null)
                    {
                        _physicalMemory = long.Parse(mo["TotalPhysicalMemory"].ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                _logService.Error(string.Format("ExistCatch:error:<-{0}->:{1} \r\n error detail:{2}", "SystemInfo", ex.Message, ex.ToString()));
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            ILogService logService = new FileLogService(typeof(Program));

            logService.Debug("Debug started");
            logService.Error("Logging Error");
            logService.Fatal("Fatal message");
            Console.WriteLine("Fatal message");
            Console.WriteLine("Debugging");
            Console.ReadLine();
        }
        public AppAccessTokens Add(AppAccessTokens item, Users actionUser)
        {
            try
            {
                if (item != null)
                {
                    item.AddedDate   = DateTime.Now;
                    item.UpdatedDate = DateTime.Now;

                    _context.AppAccessTokens.Add(item);
                    _context.SaveChanges();
                    Task.Factory.StartNew(() => {
                        new ActionLogRepository(_context).Add(enActionTypes.ADD.ToInt(), enModules.AppAccessTokens.ToInt(), item, actionUser);
                    });
                    return(item);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType + " " + System.Reflection.MethodBase.GetCurrentMethod().Name + " : " + ex.Message, ex);
            }
            return(null);
        }
示例#6
0
        public AppAccessTokens GenerateAccessForUser(Users user, string appId, string deviceToken, Users actionUser)
        {
            try
            {
                var appAccessToken = new AppAccessTokens()
                {
                    Token              = TokenHelper.GenerateUserAccessToken(user.UserId),
                    DeviceToken        = deviceToken,
                    AppId              = appId,
                    AllowNotifications = true,
                };

                return(Add(appAccessToken, actionUser));
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message, ex);
                return(null);
            }
        }
        public GList <Users> List(int?pageIndex, int?pageSize, Expression <Func <Users, bool> > where, string sortBy, ListSortDirection?sortDirection)
        {
            try
            {
                GList <Users> lstToReturn = new GList <Users>();

                var objs = _context.Users.Where(x => x.Status != (byte)enStatus.DELETED);

                if (where != null)
                {
                    objs = objs.Where(where);
                }

                if (sortDirection == null)
                {
                    sortDirection = ListSortDirection.Ascending;
                }

                if (sortBy != null)
                {
                    objs = objs.OrderBy(sortBy, sortDirection.Value);
                }

                if (pageIndex != null && pageSize != null)
                {
                    if (sortBy == null)
                    {
                        objs = objs.OrderBy(x => x.UserId);
                    }

                    lstToReturn.SetPaging(pageIndex.Value, pageSize.Value, objs.Count());

                    objs = objs.Skip(pageIndex.Value * pageSize.Value).Take(pageSize.Value);
                }

                lstToReturn.List = objs.Select(x => new
                {
                    x.UserId,
                    x.UserTypeId,
                    x.Username,

                    x.FirstName,
                    x.LastName,

                    x.IsVerificationEmailSent,
                    x.VerificationToken,
                    x.Approved,

                    x.Status,
                    x.AddedDate,
                    x.UpdatedDate,
                }).AsEnumerable().Select(x => new Users()
                {
                    UserId     = x.UserId,
                    UserTypeId = x.UserTypeId,
                    Username   = x.Username,

                    FirstName = x.FirstName,
                    LastName  = x.LastName,

                    IsVerificationEmailSent = x.IsVerificationEmailSent,
                    VerificationToken       = x.VerificationToken,
                    Approved = x.Approved,

                    Status      = x.Status,
                    AddedDate   = x.AddedDate,
                    UpdatedDate = x.UpdatedDate,
                }).ToList();

                return(lstToReturn);
            }
            catch (Exception ex)
            {
                _logger.Error(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType + " " + System.Reflection.MethodBase.GetCurrentMethod().Name + " : " + ex.Message, ex);
                return(null);
            }
        }