Exemplo n.º 1
0
        async Task SaveChangesEdit()
        {
            if (SelectedPassword.ApplicationId == SelectedApplicationAlias.Id &&
                SelectedPassword.PasswordAlias == PasswordAlias.Trim() &&
                SelectedPassword.Username == Username.Trim() &&
                SelectedPassword.Password == Password.Trim())
            {
                IsEditing = false;
                return;
            }

            int applicationId = SelectedApplicationAlias.Id;
            int passwordId    = SelectedPassword.Id;

            PasswordUpdateModel passwordUpdateModel = new PasswordUpdateModel()
            {
                ApplicationId = SelectedApplicationAlias.Id,
                PasswordAlias = PasswordAlias.Trim(),
                Username      = Username.Trim(),
                Password      = Password.Trim(),
                Encrypted     = false
            };

            await _passwordsEndPoint.UpdatePassword(passwordId, passwordUpdateModel);

            await LoadPasswords();

            SelectedApplication = Applications.FirstOrDefault(a => a.Id == applicationId);
            SelectedPassword    = Passwords.FirstOrDefault(p => p.Id == passwordId);

            IsEditing = false;
        }
Exemplo n.º 2
0
        public async Task DeletePassword()
        {
            int applicationId = SelectedApplicationAlias.Id;
            int passwordId    = SelectedPassword.Id;

            await _passwordsEndPoint.DeletePassword(passwordId);

            await LoadPasswords();

            SelectedApplication = Applications.FirstOrDefault(a => a.Id == applicationId);

            IsEditing = false;
        }
Exemplo n.º 3
0
        public void AddApplication(string path, int count)
        {
            string safePath = path.ToLowerInvariant();
            StatisticsItemViewModel item = Applications.FirstOrDefault(a => a.Path.ToLowerInvariant() == safePath);

            if (item == null)
            {
                Applications.Add(new StatisticsItemViewModel(path, count, generator.Next()));
            }
            else
            {
                item.Count += count;
            }
        }
Exemplo n.º 4
0
 private void UpdateApplications(IEnumerable <LogViewModel> logsToInsert)
 {
     try {
         foreach (var log in logsToInsert)
         {
             var application = Applications.FirstOrDefault(m => m.Name == log.Application);
             if (application == null)
             {
                 application = new ApplicationViewModel(log.Application, Logs, Namespaces, SelectedInitialLogLevel);
                 Applications.Add(application);
             }
         }
     } catch (Exception e) {
         Console.WriteLine("Could not update applications: " + e);
     }
 }
Exemplo n.º 5
0
        private void UpdateNamespaces(IEnumerable <LogViewModel> logsToInsert)
        {
            try {
                foreach (var log in logsToInsert)
                {
                    var application = Applications.FirstOrDefault(m => m.Name == log.Application);
                    if (application == null)
                    {
                        Logger.Error("[UpdateNamespaces] The application has to be set at this point.");
                        return;
                    }
                    // Try to get existing root namespace with name of application
                    var nsApplication = Namespaces.FirstOrDefault(m => m.Name == log.Application);
                    if (nsApplication == null)
                    {
                        nsApplication = new NamespaceViewModel(log.Application, application);
                        Namespaces.Add(nsApplication);
                    }

                    // Example: Verbosus.VerbTeX.View
                    string nsLogFull = log.Namespace;
                    // Example: Verbosus
                    string nsLogPart = nsLogFull.Split(new string[] { Constants.NAMESPACE_SPLITTER }, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();
                    // Try to get existing namespace with name Verbosus
                    var nsChild = nsApplication.Children.FirstOrDefault(m => m.Name == nsLogPart);
                    if (nsChild == null)
                    {
                        nsChild           = new NamespaceViewModel(nsLogPart, application);
                        nsChild.IsChecked = nsApplication.IsChecked;
                        nsApplication.Children.Add(nsChild);
                        nsChild.Parent = nsApplication;
                    }
                    if (nsLogFull.Contains(Constants.NAMESPACE_SPLITTER))
                    {
                        HandleNamespace(nsChild, nsLogFull.Substring(nsLogFull.IndexOf(Constants.NAMESPACE_SPLITTER) + 1), application, log);
                    }
                    else
                    {
                        SetLogCountByLevel(log, nsChild);
                    }
                }
            } catch (Exception e) {
                Console.WriteLine("Could not update namespaces: " + e);
            }
        }
Exemplo n.º 6
0
 private void FixNames(ref string group, ref string log)
 {
     if (log.HasValue())
     {
         var dLog = log;
         var a    = Applications.FirstOrDefault(app => app.Name == dLog) ?? Applications.FirstOrDefault(app => app.ShortName == dLog);
         log = a != null ? a.Name : log;
         if (a != null && group.IsNullOrEmpty())
         {
             // Old links, that didn't know about groups
             var g = ApplicationGroups.FirstOrDefault(gr => gr[a.Name] != null);
             if (g != null)
             {
                 group = g.Name;
             }
         }
     }
 }
Exemplo n.º 7
0
 private void AddLogs(IEnumerable <LogViewModel> logsToInsert)
 {
     try {
         foreach (var logToInsert in logsToInsert)
         {
             var application = Applications.FirstOrDefault(m => m.Name == logToInsert.Application);
             if (application == null)
             {
                 Logger.Error("[AddLogs] The application has to be set at this point.");
                 return;
             }
             application.AddLog(logToInsert);
         }
     }
     catch (Exception e) {
         Console.WriteLine("Could not update logs: " + e);
     }
 }
Exemplo n.º 8
0
        public PadToKeyApp this[string process]
        {
            get
            {
                if (string.IsNullOrEmpty(process))
                {
                    return(null);
                }

                process = process.ToLowerInvariant();
                var ret = Applications.FirstOrDefault(i => i.ProcessNames.Contains(process));
                if (ret != null)
                {
                    return(ret);
                }

                return(null);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="host"></param>
        /// <param name="controller"></param>
        public ProfilesModel(ControllerBase controller, IWebHostEnvironment host) : base(controller)
        {
            if (host != null)
            {
                var fileName = Path.Combine(host.WebRootPath, Icon.TrimStart('~', '/').Replace('/', Path.DirectorySeparatorChar));

                // 数据库存储的个人图片有后缀 default.jpg?v=1234567
                fileName = fileName.Split('?').FirstOrDefault();
                if (File.Exists(fileName))
                {
                    Size     = new FileInfo(fileName).Length;
                    FileName = Path.GetFileName(fileName);
                }
            }

            if (controller.User.Identity.AuthenticationType != CookieAuthenticationDefaults.AuthenticationScheme)
            {
                External = true;
            }

            // 设置 当前用户默认应用名称
            AppName = Applications.FirstOrDefault(app => app.Key == AppId).Value;
        }
Exemplo n.º 10
0
 /// <summary>
 /// 构造函数 Blazor 页面调用
 /// </summary>
 public ProfilesModel(string?userName) : base(userName)
 {
     // 设置 当前用户默认应用名称
     AppName = Applications.FirstOrDefault(app => app.Key == AppId).Value;
 }
Exemplo n.º 11
0
 public IApplication GetExistingUserApplication(string ApplicationName)
 {
     return(Applications.FirstOrDefault(a => a is UserApplication && a.Name == ApplicationName.Trim()));
 }
Exemplo n.º 12
0
 /// <summary>
 /// 構造函数 Blazor 頁面調用
 /// </summary>
 public ProfilesModel(string?userName) : base(userName)
 {
     // 設置 當前用户預設應用名稱
     AppName = Applications.FirstOrDefault(app => app.Key == AppId).Value;
 }
Exemplo n.º 13
0
 public Application this[string name] =>
 Applications.FirstOrDefault(a => a.Name == name) ?? Applications.FirstOrDefault(a => a.ShortName == name);
Exemplo n.º 14
0
 public Application GetApplication(string token)
 {
     return(Applications.FirstOrDefault(x => x.Token.Equals(token) && x.IsActive));
 }