示例#1
0
        public static async Task InitializePcLastMinute(DiagnosticData diagnosticData, PcHealthContext db)
        {
            await db.LastMinutes.AddAsync(ModelCreation.CreateOrUpdateLastMinute(diagnosticData)).ConfigureAwait(false);

            for (var i = 1; i < 60; i++)
            {
                await db.LastMinutes.AddAsync(new LastMinute()
                {
                    Second = i,
                    PcId   = diagnosticData.PcId,
                    PcNetworkAverageBytesSend = 0,
                    PcCpuUsage    = 0,
                    PcMemoryUsage = 0,
                    PcNetworkAverageBytesReceived = 0
                }).ConfigureAwait(false);
            }
        }
示例#2
0
        public static async Task <string> CreateNewCredentials(PcHealthContext dbContext, NewAccountInfo newAccountInfo)
        {
            var(salt, passwordHash) = Services.HashServices.Encrypt(newAccountInfo.CredentialsPassword);
            var pcCredentialsPassword = ModelCreation.GenerateRandomString();
            var newCredential         = new Credential()
            {
                CredentialsUsername  = newAccountInfo.CredentialsUsername,
                CredentialsPassword  = passwordHash,
                CredentialsSalt      = salt,
                PcCredentialPassword = pcCredentialsPassword
            };
            await dbContext.Credentials.AddAsync(newCredential).ConfigureAwait(false);

            StaticStorageServices.AdminMapper.Add(newAccountInfo.CredentialsUsername, pcCredentialsPassword);
            await dbContext.SaveChangesAsync().ConfigureAwait(false);

            return(pcCredentialsPassword);
        }