public College Add(SystemEnvironment environment, College college) { college.Id = Guid.NewGuid(); college.Environment = environment; return(_collegeRepository.Insert(college)); }
public async Task <VerifyRecordResult> DeleteAsync(int id) { try { CleanTrackingHelper.Clean <SystemEnvironment>(context); SystemEnvironment item = await context.SystemEnvironment .AsNoTracking() .FirstOrDefaultAsync(x => x.Id == id); if (item == null) { return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.無法刪除紀錄)); } else { CleanTrackingHelper.Clean <SystemEnvironment>(context); context.Entry(item).State = EntityState.Deleted; await context.SaveChangesAsync(); CleanTrackingHelper.Clean <SystemEnvironment>(context); return(VerifyRecordResultFactory.Build(true)); } } catch (Exception ex) { Logger.LogError(ex, "刪除記錄發生例外異常"); return(VerifyRecordResultFactory.Build(false, "刪除記錄發生例外異常", ex)); } }
public void SystemEnvironmentTest() { var env = new SystemEnvironment(); Assert.True(Environment.Is64BitOperatingSystem != env.Is32BitOperatingSystem); Assert.True(Environment.Is64BitProcess != env.Is32BitProcess); }
public async Task <VerifyRecordResult> UpdateAsync(SystemEnvironmentAdapterModel paraObject) { try { SystemEnvironment itemData = Mapper.Map <SystemEnvironment>(paraObject); CleanTrackingHelper.Clean <SystemEnvironment>(context); SystemEnvironment item = await context.SystemEnvironment .AsNoTracking() .FirstOrDefaultAsync(x => x.Id == paraObject.Id); if (item == null) { return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.無法修改紀錄)); } else { CleanTrackingHelper.Clean <SystemEnvironment>(context); context.Entry(itemData).State = EntityState.Modified; await context.SaveChangesAsync(); CleanTrackingHelper.Clean <SystemEnvironment>(context); return(VerifyRecordResultFactory.Build(true)); } } catch (Exception ex) { Logger.LogError(ex, "修改記錄發生例外異常"); return(VerifyRecordResultFactory.Build(false, "修改記錄發生例外異常", ex)); } }
private async Task 建立系統定義參數Async() { #region 建立系統定義參數 CleanTrackingHelper.Clean <SystemEnvironment>(context); #region 新增系統定義紀錄 SystemEnvironment systemEnvironment = new SystemEnvironment() { EnableLoginFailDetection = true, LoginFailMaxTimes = 3, LoginFailTimesLockMinutes = 5, MinimumPasswordLength = 3, PasswordAge = 42, PasswordComplexity = 3, // PasswordStrength.Medium PasswordHistory = 20, EnableCheckPasswordAge = true, }; context.SystemEnvironment.Add(systemEnvironment); await context.SaveChangesAsync(); CleanTrackingHelper.Clean <SystemEnvironment>(context); #endregion #endregion }
public SecondHeader(byte[] secondHeader) { var dseb = secondHeader.Take(2).ToArray(); var mseb = secondHeader.Skip(2).Take(4).ToArray(); var grbS = secondHeader.Skip(6).Take(2).ToArray(); if (BitConverter.IsLittleEndian) { Array.Reverse(dseb); Array.Reverse(mseb); //Array.Reverse (grbS); } var daysSinceEpoch = BitConverter.ToUInt16(dseb, 0); var msOfDay = BitConverter.ToUInt32(mseb, 0); Timestamp = new DateTime(2000, 1, 1, 0, 0, 0); Timestamp = Timestamp.AddDays(daysSinceEpoch); Timestamp = Timestamp.AddMilliseconds(msOfDay); var grbSU = BitConverter.ToUInt16(grbS, 0); GRBVersion = grbSU & 0x1F; PayloadType = (PayloadType)(((grbS [1] & 3) << 5) + ((grbS [0] & 0xE0) >> 5)); AssembleIdentifier = (AssembleIdentifier)((grbSU & 0xC00) >> 10); SystemEnvironment = (SystemEnvironment)((grbSU & 0x9000) >> 12); }
public StudentViewModel Add(Guid idEnvironment, StudentViewModel studentViewModel) { Student student = _mapper.Map <Student>(studentViewModel); SystemEnvironment environment = _mapper.Map <SystemEnvironment>(_environmentService.GetById(idEnvironment)); return(_mapper.Map <StudentViewModel>(_studentService.Add(environment, student))); }
public async Task <string> CheckWetherCanChangePassword(MyUserAdapterModel myUserAdapterModel, string newPassword) { string result = ""; CleanTrackingHelper.Clean <SystemEnvironment>(context); CleanTrackingHelper.Clean <MyUserPasswordHistory>(context); SystemEnvironment systemEnvironment = await context.SystemEnvironment .OrderBy(x => x.Id) .FirstOrDefaultAsync(); string encodePassword = PasswordHelper.GetPasswordSHA(myUserAdapterModel.Salt, newPassword); if (encodePassword == myUserAdapterModel.Password) { result = "不可以變更成為現在正在使用的密碼"; } else { if (systemEnvironment.EnablePasswordHistory) { var history = await context.MyUserPasswordHistory .FirstOrDefaultAsync(x => x.MyUserId == myUserAdapterModel.Id && x.Password == encodePassword); if (history != null) { result = "不可以變更成為之前用過的密碼"; } } } return(result); }
public void Add(SystemEnvironment environment) { Random random = new Random(4); environment.CompanyCode = environment.CompanyCode + random; _environmentRepository.Insert(environment); }
public SystemEnvironment GetStudentsNotEnroled(Guid idEnvironment) { SystemEnvironment systemEnvironmentEntity = _environmentRepository.GetById(idEnvironment); var culturalExchangeEntity = systemEnvironmentEntity.CulturalExchange; return(_environmentRepository.GetById(idEnvironment)); }
// --------------------------------------------------------------------------------------------------------------------- private void AddRow(string tcLabel, string tcValue) { var loSystem = new SystemEnvironment { Label = tcLabel, Value = tcValue }; this.foDataCollection.Add(loSystem); }
public void ItCanGetFolderPathWithNoVerifyOption() { var expected = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.DoNotVerify); var actual = new SystemEnvironment().GetFolderPath(Environment.SpecialFolder.ApplicationData, Environment.SpecialFolderOption.DoNotVerify); actual.Should().Be(expected); }
public void ItCanGetFolderPathWithCreateOption() { var expected = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile, Environment.SpecialFolderOption.Create); var actual = new SystemEnvironment().GetFolderPath(Environment.SpecialFolder.UserProfile, Environment.SpecialFolderOption.Create); actual.Should().Be(expected); }
public ImageFileGenerationModel(string diagramText, string diagramName) { SystemSettings settings = SystemEnvironment.GetSettings(); this.JavaPath = settings.JavaPath; DiagramText = diagramText; DiagramName = diagramName; }
protected void discoverEnvironment() { // are we running on Windows? isWindows = Path.DirectorySeparatorChar == '\\'; // are we on a 64-bit OS? is64Bit = true; if (isWindows) { is64Bit = SystemEnvironment.IsOS64Bit(); } }
public async Task <SystemEnvironmentAdapterModel> GetAsync(int id) { SystemEnvironment item = await context.SystemEnvironment .AsNoTracking() .FirstOrDefaultAsync(x => x.Id == id); SystemEnvironmentAdapterModel result = Mapper.Map <SystemEnvironmentAdapterModel>(item); await OhterDependencyData(result); return(result); }
// Constructor. public CommandSettings(IHostContext context, string[] args, IScopedEnvironment environmentScope = null) { ArgUtil.NotNull(context, nameof(context)); _promptManager = context.GetService <IPromptManager>(); _trace = context.GetTrace(nameof(CommandSettings)); // Parse the command line args. _parser = new CommandLineParser( hostContext: context, secretArgNames: Constants.Agent.CommandLine.Args.Secrets); _parser.Parse(args); if (environmentScope == null) { environmentScope = new SystemEnvironment(); } // Store and remove any args passed via environment variables. var environment = environmentScope.GetEnvironmentVariables(); string envPrefix = "VSTS_AGENT_INPUT_"; foreach (DictionaryEntry entry in environment) { // Test if starts with VSTS_AGENT_INPUT_. string fullKey = entry.Key as string ?? string.Empty; if (fullKey.StartsWith(envPrefix, StringComparison.OrdinalIgnoreCase)) { string val = (entry.Value as string ?? string.Empty).Trim(); if (!string.IsNullOrEmpty(val)) { // Extract the name. string name = fullKey.Substring(envPrefix.Length); // Mask secrets. bool secret = Constants.Agent.CommandLine.Args.Secrets.Any(x => string.Equals(x, name, StringComparison.OrdinalIgnoreCase)); if (secret) { context.SecretMasker.AddValue(val); } // Store the value. _envArgs[name] = val; } // Remove from the environment block. _trace.Info($"Removing env var: '{fullKey}'"); environmentScope.SetEnvironmentVariable(fullKey, null); } } }
protected override void ExcuteJob(IJobExecutionContext context, CancellationTokenSource cancellationSource) { if (string.IsNullOrWhiteSpace(ConfigModel.node_name) == false) { var time = DateTime.Now; SystemEnvironment info = new SystemEnvironment(); ServerTargetHelper.ServerTarget(time, new ServerTargetModel { cpu_rate = info.GetCpuRate(), disk_rate = info.GetDriverRate(), mem_rate = info.GetMemRate() }); } }
private async Task SystemEnvironmentReset() { var fooSystemEnvironment = new SystemEnvironment() { AppName = $"LOB 應用練習專案", AndroidVersion = "1.0.0.0", AndroidUrl = "", iOSVersion = "1.0.0.0", iOSUrl = "", }; lobDatabaseContext.SystemEnvironment.Add(fooSystemEnvironment); await lobDatabaseContext.SaveChangesAsync(); }
public List <ComicVineIssue> SearchIssue(string volumeName, int issueNumber) { List <ComicVineVolume> comicVineVolumeList = this.FindVolumeIdByName(volumeName); ConcurrentBag <ComicVineIssue> comicVineIssueBag = new ConcurrentBag <ComicVineIssue>(); int parallelThreads = SystemEnvironment.ProcessorCountOptimizedForEnvironment(); Parallel.ForEach(comicVineVolumeList, new ParallelOptions() { MaxDegreeOfParallelism = parallelThreads }, comicVineVolume => { try { if (comicVineVolume != null) { ComicVineIssue detailedComicVineIssue = this.GetComicVineIssue(comicVineVolume.id, issueNumber); if (detailedComicVineIssue.issue_number == issueNumber.ToString()) { comicVineIssueBag.Add(detailedComicVineIssue); } } } catch (AggregateException aggregateException) { foreach (var exception in aggregateException.InnerExceptions) { if (exception is ArgumentException) { // Don't act on this } else { throw exception; } } } }); return(comicVineIssueBag.ToList()); }
void Test(string source, string expectedResult) { Name.Init( ); SystemEnvironment.Init( ); try { Tokenizer lexer = new Tokenizer(new StringReader(source), "AstTest.cs/sample code"); System.Text.StringBuilder sb = new System.Text.StringBuilder(); bool addSpace = false; do { Syntax result = SyntaxParser.Parse(lexer); if (result == null) { break; } var env = new Environment(SystemEnvironment.Top, EName.None, true); var ast = AstBuilder.Expand(result, env); if (addSpace) { sb.Append(" "); } else { addSpace = true; } sb.Append(Inspector.InspectObject(ast.GetDatum())); } while (lexer.LastToken != null); string sresult = sb.ToString(); Assert.AreEqual(expectedResult, sresult); } catch (BaseSchemeError ex) { Debug.LogError(string.Format("{0}\n{1}\n{2}", source, ex.Message, ex.StackTrace)); } Name.DeInit( ); }
public async Task <VerifyRecordResult> AddAsync(SystemEnvironmentAdapterModel paraObject) { try { SystemEnvironment itemParameter = Mapper.Map <SystemEnvironment>(paraObject); CleanTrackingHelper.Clean <SystemEnvironment>(context); await context.SystemEnvironment .AddAsync(itemParameter); await context.SaveChangesAsync(); CleanTrackingHelper.Clean <SystemEnvironment>(context); return(VerifyRecordResultFactory.Build(true)); } catch (Exception ex) { Logger.LogError(ex, "新增記錄發生例外異常"); return(VerifyRecordResultFactory.Build(false, "新增記錄發生例外異常", ex)); } }
public async Task CheckPasswordAge(CancellationToken cancellationToken) { CleanTrackingHelper.Clean <SystemEnvironment>(context); CleanTrackingHelper.Clean <MyUser>(context); SystemEnvironment systemEnvironment = await context.SystemEnvironment .OrderBy(x => x.Id) .FirstOrDefaultAsync(); cancellationToken.ThrowIfCancellationRequested(); List <MyUser> myUsers = await context.MyUser .ToListAsync(); cancellationToken.ThrowIfCancellationRequested(); var enableCheckPasswordAge = systemEnvironment.EnableCheckPasswordAge; var passwordAge = systemEnvironment.PasswordAge; if (enableCheckPasswordAge == true) { foreach (var item in myUsers) { cancellationToken.ThrowIfCancellationRequested(); if (DateTime.Now > item.ForceChangePasswordDatetime) { #region 該使用者已經達到要變更密碼的時間 item.ForceChangePasswordDatetime = DateTime.Now.AddDays(passwordAge); item.ForceChangePassword = true; context.Update(item); await context.SaveChangesAsync(); #endregion } } } CleanTrackingHelper.Clean <MyUser>(context); CleanTrackingHelper.Clean <SystemEnvironment>(context); }
public Student Add(SystemEnvironment environment, Student student) { student.Id = Guid.NewGuid(); student.Environment = environment; student.DateOfInsert = DateTime.Now; student.ValidationResult = new List <ValidationResult>(); bool studentOver18YearsOld = new StudentOver18YearsOld() .IsSatisfiedBy(student); bool studentCustomerId = new IdentityCustomerId(_studentRepository) .IsSatisfiedBy(student); if (!student.ValidationResult.Any()) { _studentRepository.Insert(student); } return(student); }
private void OnValidate() { Name.Init( ); SystemEnvironment.Init( ); System.Text.StringBuilder sb; try { // ------------------------------------------------------------------ // Just tokenized it // ------------------------------------------------------------------ sb = new System.Text.StringBuilder(); lexer = new Tokenizer(new StringReader(testString), "AstTest"); var token = lexer.ReadToken(); while (token != null) { sb.Append(Inspector.InspectObject(token) + " "); token = lexer.ReadToken(); } tokensString = sb.ToString(); // ------------------------------------------------------------------ // Parse scheme // ------------------------------------------------------------------ lexer = new Tokenizer(new StringReader(testString), "AstTest"); sb = new System.Text.StringBuilder(); do { SObject result = SyntaxParser.Parse(lexer); if (result == null) { break; } sb.AppendLine(Inspector.InspectObject(result)); } while (lexer.LastToken != null); syntaxString = sb.ToString(); // ------------------------------------------------------------------ // Parse scheme // ------------------------------------------------------------------ lexer = new Tokenizer(new StringReader(testString), "AstTest"); sb = new System.Text.StringBuilder(); do { var result = SyntaxParser.Parse(lexer); if (result == null) { break; } var ast = AstBuilder.Expand(result, SystemEnvironment.Top); sb.AppendLine(Inspector.InspectObject(ast)); } while (lexer.LastToken != null); astString = sb.ToString(); envString = SystemEnvironment.Top.Inspect(); } catch (SchemeError ex) { astString = ex.Message; throw ex; } Name.DeInit( ); }
public void Update(SystemEnvironment environment) { _environmentRepository.Update(environment); }
public void SaveChanges() { SystemEnvironment.SetSettings(new SystemSettings { JavaPath = _screen.JavaPath }); }
public void Start() { SystemSettings settings = SystemEnvironment.GetSettings(); _screen.JavaPath = settings.JavaPath; }
private List <ComicVineVolume> FindVolumeIdByName(string volumeName) { string query = null; if (this.SearchType == SearchType.Xml) { query = this.ComicVineAddress + "volumes/?api_key=" + this.ComicVineKey + "&format=xml&field_list=id,name,publisher&filter=name:" + volumeName; } else { query = this.ComicVineAddress + "volumes/?api_key=" + this.ComicVineKey + "&format=json&field_list=id,name,publisher&filter=name:" + volumeName; } Task <ComicVineResponse> comicVineResponse = ComicVineConnection.ConnectAndRequest(query); ConcurrentBag <List <ComicVineVolume> > comicVineVolumeLists = new ConcurrentBag <List <ComicVineVolume> >(); if (comicVineResponse.Result.Status == "OK") { ComicVineResponseData firstData = ComicVineReader.GetFirstVolumeQueryResponse(this.SearchType, comicVineResponse.Result.Response); if (firstData.number_of_total_results > 0) { int parallelThreads = SystemEnvironment.ProcessorCountOptimizedForEnvironment(); int numberOfIterations = (int)Math.Ceiling(((double)firstData.number_of_total_results / (double)firstData.limit)); Parallel.For(0, numberOfIterations, new ParallelOptions() { MaxDegreeOfParallelism = parallelThreads }, i => { int offset = i * firstData.limit; string secondQuery = query + "&offset=" + offset.ToString(); Task <ComicVineResponse> secondResponse = ComicVineConnection.ConnectAndRequest(secondQuery); var volumeList = ComicVineReader.GetVolumeQueryResponse(this.SearchType, secondResponse.Result.Response); comicVineVolumeLists.Add(volumeList); secondResponse = null; }); } } if (this.MatchType == MatchType.AbsoluteMatch) { ConcurrentBag <List <ComicVineVolume> > filteredComicVineVolumeLists = new ConcurrentBag <List <ComicVineVolume> >(); List <ComicVineVolume> filteredComicVineVolumeList = new List <ComicVineVolume>(); foreach (var volumeList in comicVineVolumeLists) { foreach (var volume in volumeList) { if (volume.name == volumeName) { filteredComicVineVolumeList.Add(volume); } } } filteredComicVineVolumeLists.Add(filteredComicVineVolumeList); comicVineVolumeLists = filteredComicVineVolumeLists; } List <ComicVineVolume> comicVineVolumeList = new List <ComicVineVolume>(); foreach (List <ComicVineVolume> comicVineVolume in comicVineVolumeLists) { comicVineVolumeList.AddRange(comicVineVolume); } return(comicVineVolumeList); }
public async Task ChangePassword(MyUserAdapterModel myUserAdapterModel, string newPassword, string ip) { CleanTrackingHelper.Clean <SystemEnvironment>(context); CleanTrackingHelper.Clean <MyUserPasswordHistory>(context); SystemEnvironment systemEnvironment = await context.SystemEnvironment .OrderBy(x => x.Id) .FirstOrDefaultAsync(); string encodePassword = PasswordHelper.GetPasswordSHA(myUserAdapterModel.Salt, newPassword); myUserAdapterModel.Password = encodePassword; var myUser = Mapper.Map <MyUser>(myUserAdapterModel); CleanTrackingHelper.Clean <MyUser>(context); #region 更新下次要變更密碼的時間 if (systemEnvironment.EnableCheckPasswordAge) { myUser.ForceChangePasswordDatetime = DateTime.Now .AddDays(systemEnvironment.PasswordAge); } myUser.ForceChangePassword = false; #endregion context.Entry(myUser).State = EntityState.Modified; await context.SaveChangesAsync(); if (systemEnvironment.EnablePasswordHistory == true) { MyUserPasswordHistory myUserPasswordHistory = new MyUserPasswordHistory() { MyUserId = myUser.Id, IP = ip, Password = myUser.Password, ChangePasswordDatetime = DateTime.Now, }; await context.AddAsync(myUserPasswordHistory); await context.SaveChangesAsync(); while (true) { #region 只會記錄下系統指定的變更密碼數量 systemEnvironment.PasswordHistory var myUserPasswordHistories = await context.MyUserPasswordHistory .Where(x => x.MyUserId == myUser.Id) .OrderBy(x => x.ChangePasswordDatetime) .ToListAsync(); if (myUserPasswordHistories.Count > systemEnvironment.PasswordHistory) { var first = myUserPasswordHistories.First(); context.Remove(first); await context.SaveChangesAsync(); continue; } else { break; } #endregion } } CleanTrackingHelper.Clean <SystemEnvironment>(context); CleanTrackingHelper.Clean <MyUser>(context); CleanTrackingHelper.Clean <MyUserPasswordHistory>(context); }