public ResultLog Login(string CompanyCode, string UserName, string PasswrodMd5) { ResultLog loginResult = new ResultLog(); string userKey = $"[{CompanyCode}]-[{UserName}]"; if (isLogin(userKey) == true) { //该用户已经登录 } UserInfo loginUser = CheckUserID(userKey); if (loginUser == null) { loginResult.IsSuccess = false; loginResult.ErrorMessage = "该用户不存在"; //该用户不存在 return(loginResult); } if (VerifyUserPassword(userKey, PasswrodMd5, loginUser.Password) == false) { loginResult.IsSuccess = false; loginResult.ErrorMessage = "用户名或密码不正确"; return(loginResult); } loginResult.IsSuccess = true; return(loginResult); }
protected override ExitCode ExecuteFileTask() { string target = Arguments.GetOption <string>("target", "t"); int redirector = Array.IndexOf(Arguments.Targets, ">"); if (target == null && redirector == -1) { ResultLog.WriteLine(string.Join(" ", Arguments.Targets)); return(ExitCode.Success); } if (target == null) { if (redirector == Arguments.Targets.Length - 1) { StatusLog.WriteLine(WriteStyle.Error, XFileStrings.ErrorNoTargetSpecified); return(ExitCode.InvalidArgument); } target = Arguments.Targets[redirector + 1]; } target = GetFullPath(target); FileService.WriteAllText(target, string.Join(" ", redirector == -1 ? Arguments.Targets : Arguments.Targets.Take(redirector))); return(ExitCode.Success); }
public void ComputeResult(string mId, int c, int w, int u, string allWrongEntry, DateTime finishTime, string remark) { var findtest = _db.ResultManagers.Where(x => x.MemberProfile.Member.Id == mId && x.Status == "STARTED") .OrderByDescending(x => x.StarTime).FirstOrDefault(); if (findtest != null) { findtest.EndTime = finishTime; //findtest..TotalCorrect = c; //findtest..TotalWrong = w; // findtest.TotalUnanswered = u; findtest.Status = "FINISHED"; findtest.Remark = remark; _db.Entry(findtest).State = EntityState.Modified; } _db.SaveChanges(); var entity = new ResultLog { ResultManager = findtest, TotalCorrect = c, TotalUnanswered = u, TotalWrong = w, WrongQuestionandAnswerSelected = allWrongEntry }; _db.ResultLogs.Add(entity); _db.SaveChanges(); }
public ResultLogForm(ResultLog log = null) { _resultLog = log ?? new ResultLog(); InitializeComponent(); UpdateForm(); DataContext = new ResultLogView(_resultLog); }
public async Task <IActionResult> Create(AccountAddModel account) { ResultLog resultLog = new ResultLog(); if (ModelState.IsValid) { if (!await _redisService.IsExistKey(accountTableKey, account.AccountNumber)) { //ToDo: Use AutoMapper and DTO resultLog.IsError = !await _redisService.CreateHashSetDataAsync(accountTableKey, account.AccountNumber, new Account { AccountNumber = account.AccountNumber, Balance = Math.Round(account.Balance, 2), //limited 2 digits CurrencyCode = account.CurrencyCode.ToString() }); if (resultLog.IsError) { return(StatusCode((int)Enums.Enums.StatusCode.ISSUER_OR_SWITCH_INOPERATIVE, resultLog)); } return(StatusCode((int)Enums.Enums.StatusCode.CREATED, resultLog)); } else { return(StatusCode((int)Enums.Enums.StatusCode.CONFLICT, ActionResultHelper.CreateActionResultJson(Enums.Enums.StatusCode.CONFLICT, "AccountNumber should be unique"))); } } return(ValidationProblem()); }
public ResultLogForm(ResultLogView resultLogView) { _resultLog = resultLogView.ResultLog; InitializeComponent(); UpdateForm(); DataContext = resultLogView; }
protected override ExitCode ExecuteFileTask() { VolumeInformation info = ExtendedFileService.GetVolumeInformation(Arguments.Target); Table table = Table.Create(new ColumnFormat(1, ContentVisibility.ShowAll, Justification.Right), new ColumnFormat(1)); table.HasHeader = false; table.AddRow("Volume Name", info.VolumeName); table.AddRow("Serial Number", info.VolumeSerialNumber.ToString()); table.AddRow("Max Component Length", info.MaximumComponentLength.ToString()); table.AddRow("File System Name", info.FileSystemName.ToString()); foreach (var value in Enum.GetValues(typeof(FileSystemFeature))) { FileSystemFeature feature = (FileSystemFeature)value; if ((feature & info.FileSystemFlags) == feature) { table.AddRow(feature.ToString(), "true"); } else { table.AddRow(feature.ToString(), "false"); } } ResultLog.Write(table); return(ExitCode.Success); }
public ResultDiffingVisitor(ResultLog resultLog) { this.AbsentResults = new HashSet <Result>(); this.SharedResults = new HashSet <Result>(); this.NewResults = new HashSet <Result>(); VisitResultLog(resultLog); }
public void CtorDefaultTest() { ResultLog l = new ResultLog(); Assert.Empty(l); Assert.Equal(0, l.GoodCount); Assert.Equal(0, l.BadCount); Assert.Equal(0, l.SuspectCount); }
/// <summary> /// Updates result log with supplied string. /// </summary> /// <param name="param"></param> void AddUpdate(object param) { // Dispatch update for result log. System.Windows.Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { // Add string to result log. ResultLog.Add(param as string); })); }
protected override ExitCode ExecuteFileTask() { foreach (var stream in ExtendedFileService.GetAlternateStreamInformation(GetFullTargetPath())) { ResultLog.WriteLine($"Stream '{stream.Name}', Size {stream.Size}"); } return(ExitCode.Success); }
protected override ExitCode ExecuteFileTask() { foreach (string pathName in ExtendedFileService.GetVolumeMountPoints(Arguments.Target)) { ResultLog.WriteLine(pathName); } return(ExitCode.Success); }
protected override ExitCode ExecuteFileTask() { foreach (string drive in ExtendedFileService.GetLogicalDriveStrings()) { ResultLog.WriteLine(drive); } return(ExitCode.Success); }
public void ToStringTest() { ResultLog l0 = new ResultLog(); l0.LogGood("Good result."); l0.LogBad("Error result."); string s = l0.ToString(); Assert.True(s.Contains("Good result") && s.Contains("Error result")); }
private void OutputSarifRulesMetada(string outputFilePath, ImmutableArray <IRuleDescriptor> skimmers, ImmutableArray <IOptionsProvider> options) { var log = new ResultLog(); log.Version = SarifVersion.ZeroDotFour; // The SARIF spec currently requires an array // of run logs with at least one member log.RunLogs = new List <RunLog>(); var runLog = new RunLog(); runLog.ToolInfo = new ToolInfo(); runLog.ToolInfo.InitializeFromAssembly(this.GetType().Assembly, Prerelease); runLog.Results = new List <Result>(); log.RunLogs.Add(runLog); runLog.ToolInfo.RuleInfo = new List <RuleDescriptor>(); SortedDictionary <int, RuleDescriptor> sortedRuleDescriptors = new SortedDictionary <int, RuleDescriptor>(); foreach (IRuleDescriptor descriptor in skimmers) { var ruleDescriptor = new RuleDescriptor(); ruleDescriptor.Id = descriptor.Id; ruleDescriptor.Name = descriptor.Name; ruleDescriptor.Options = descriptor.Options; ruleDescriptor.HelpUri = descriptor.HelpUri; ruleDescriptor.Properties = descriptor.Properties; ruleDescriptor.FullDescription = descriptor.FullDescription; ruleDescriptor.FormatSpecifiers = descriptor.FormatSpecifiers; ruleDescriptor.ShortDescription = ruleDescriptor.ShortDescription; int numericId = GetIdIntegerSuffix(ruleDescriptor.Id); sortedRuleDescriptors[numericId] = ruleDescriptor; } foreach (RuleDescriptor ruleDescriptor in sortedRuleDescriptors.Values) { runLog.ToolInfo.RuleInfo.Add(ruleDescriptor); } var settings = new JsonSerializerSettings() { ContractResolver = SarifContractResolver.Instance, Formatting = Formatting.Indented, }; File.WriteAllText(outputFilePath, JsonConvert.SerializeObject(log, settings)); }
public void ClearTest() { ResultLog l0 = new ResultLog(); l0.LogGood("Good result."); l0.LogBad("Error result."); l0.Clear(); Assert.Empty(l0); Assert.Equal(0, l0.GoodCount); Assert.Equal(0, l0.BadCount); Assert.True(l0.IsNull); }
protected override ExitCode ExecuteFileTask() { using (var reader = FileService.CreateReader(GetFullTargetPath())) { string nextLine = null; while ((nextLine = reader.ReadLine()) != null) { ResultLog.WriteLine(nextLine); } } return(ExitCode.Success); }
private void RunRules(StringBuilder sb, string inputFileName) { string fileName = Path.GetFileName(inputFileName); string actualDirectory = Path.Combine(Path.GetDirectoryName(inputFileName), "Actual"); string expectedDirectory = Path.Combine(Path.GetDirectoryName(inputFileName), "Expected"); if (Directory.Exists(actualDirectory)) { Directory.Delete(actualDirectory, true); } Directory.CreateDirectory(actualDirectory); string expectedFileName = Path.Combine(expectedDirectory, fileName + ".sarif"); string actualFileName = Path.Combine(actualDirectory, fileName + ".sarif"); AnalyzeCommand command = new AnalyzeCommand(); AnalyzeOptions options = new AnalyzeOptions(); options.TargetFileSpecifiers = new string[] { inputFileName }; options.OutputFilePath = actualFileName; options.Verbose = true; options.Recurse = false; options.ConfigurationFilePath = "default"; int result = command.Run(options); Assert.Equal(0, result); JsonSerializerSettings settings = new JsonSerializerSettings() { ContractResolver = SarifContractResolver.Instance, Formatting = Formatting.Indented }; string expectedText = File.ReadAllText(expectedFileName); string actualText = File.ReadAllText(actualFileName); // Make sure we can successfully deserialize what was just generated ResultLog expectedLog = JsonConvert.DeserializeObject <ResultLog>(expectedText, settings); ResultLog actualLog = JsonConvert.DeserializeObject <ResultLog>(actualText, settings); var visitor = new ResultDiffingVisitor(expectedLog); if (!visitor.Diff(actualLog.RunLogs[0].Results)) { string errorMessage = "The output of the tool did not match for input {0}."; sb.AppendLine(String.Format(CultureInfo.CurrentCulture, errorMessage, inputFileName)); sb.AppendLine("Check differences with:"); sb.AppendLine(GenerateDiffCommand(expectedFileName, actualFileName)); } }
internal static void ResultLogExample() { ResultLog log0 = new ResultLog("First log"); log0.LogBad("This is an error message."); log0.LogSuspect("This is a warning message"); ResultLog log1 = new ResultLog("Second Log", log0); log1.LogGood("This is a good message."); Console.Write(log1); // Result: // Error: This is an error message. // Warning: This is a warning message // This is a good message. }
public void IListTests() { ResultLog l0 = new ResultLog(); Result r0 = new Result(ResultType.Bad, "Error message"); l0.Insert(0, r0); Assert.Contains <Result>(r0, l0); Assert.Equal(0, l0.IndexOf(r0)); l0.Remove(r0); Assert.Empty(l0); l0.Add(r0); Assert.Single(l0); l0.RemoveAt(0); Assert.Empty(l0); }
protected override ExitCode ExecuteFileTask() { string target = Arguments.Target; if (target == null) { target = "."; } string fullPath = ExtendedFileService.GetFinalPath(GetFullPath(target)); FileService.CurrentDirectory = fullPath; ResultLog.WriteLine(FileService.CurrentDirectory); return(ExitCode.Success); }
private void RunConverter(StringBuilder sb, ToolFormat tool, string inputFileName) { string expectedFileName = inputFileName + ".sarif"; string generatedFileName = inputFileName + ".actual.sarif"; try { this.converter.ConvertToStandardFormat(tool, inputFileName, generatedFileName, ToolFormatConversionOptions.OverwriteExistingOutputFile | ToolFormatConversionOptions.PrettyPrint); } catch (Exception ex) { sb.AppendLine(String.Format(CultureInfo.InvariantCulture, "The converter {0} threw an exception for input \"{1}\".", tool, inputFileName)); sb.AppendLine(ex.ToString()); return; } string expectedSarif = File.ReadAllText(expectedFileName); string actualSarif = File.ReadAllText(generatedFileName); if (expectedSarif == actualSarif) { JsonSerializerSettings settings = new JsonSerializerSettings() { ContractResolver = SarifContractResolver.Instance, Formatting = Formatting.Indented }; // Make sure we can successfully deserialize what was just generated ResultLog log = JsonConvert.DeserializeObject <ResultLog>(actualSarif, settings); actualSarif = JsonConvert.SerializeObject(log, settings); if (expectedSarif == actualSarif) { return; } else { File.WriteAllText(generatedFileName, actualSarif); } } string errorMessage = "The output of the {0} converter did not match for input {1}."; sb.AppendLine(String.Format(CultureInfo.CurrentCulture, errorMessage, tool, inputFileName)); sb.AppendLine("Check differences with:"); sb.AppendLine(GenerateDiffCommand(expectedFileName, generatedFileName)); }
public static DesktopDocument Open(Window window, DocType docType, ResultLog log = null) { OpenFileDialog fd = new OpenFileDialog { InitialDirectory = DesktopApp.Instance.Settings.DocumentFolder, DefaultExt = docType.Extension, Filter = GetFilterString(true, docType), CheckFileExists = true, CheckPathExists = true }; if (fd.ShowDialog(window) == true) { return(BaseDocument.Open(fd.FileName, log) as DesktopDocument); } return(null); }
static public bool InsertResultLog(DateTime time, string opponentName, byte result) { ResultLog Data = new ResultLog(); Data.Time = time; Data.MyName = User.myInfo.NickName + " " + Helper.LevelConverter(User.myInfo.level); Data.OpponentName = opponentName; Data.Result = result; string DBPath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), "BD2.db"); var db = new SQLiteConnection(DBPath); db.CreateTable <ResultLog>(); db.Insert(Data); return(true); }
private void PopulateControlFromSarifText(string sarifText) { ResultLog log = SarifFile.CreateFromText(sarifText); // TODO currently we just grovel for the first result, if any, // that has either a stack or an execution flow bool foundData = false; ObservableCollection <AnnotatedCodeLocationModel> items = new ObservableCollection <AnnotatedCodeLocationModel>(); foreach (RunLog runLog in log.RunLogs) { if (foundData) { break; } if (runLog.Results != null) { foreach (Result result in runLog.Results) { if (result.Stacks != null) { PopulateControl(items, result.Stacks, AnnotatedCodeLocationKind.Stack); foundData = true; } if (result.ExecutionFlows != null) { PopulateControl(items, result.ExecutionFlows, AnnotatedCodeLocationKind.ExecutionFlow); foundData = true; } if (foundData) { break; } } } } //this.codeLocations.SetItems(items); }
public RunLog AnalyzeFile(string fileName) { string path = Path.GetTempFileName(); RunLog runLog = null; try { var options = new TestAnalyzeOptions { TargetFileSpecifiers = new string[] { fileName }, Verbose = true, Statistics = true, ComputeTargetsHash = true, PolicyFilePath = "default", Recurse = true, OutputFilePath = path, }; var command = new TestAnalyzeCommand(); command.DefaultPlugInAssemblies = new Assembly[] { this.GetType().Assembly }; int result = command.Run(options); Assert.Equal(TestAnalyzeCommand.SUCCESS, result); JsonSerializerSettings settings = new JsonSerializerSettings() { ContractResolver = SarifContractResolver.Instance }; ResultLog log = JsonConvert.DeserializeObject <ResultLog>(File.ReadAllText(path), settings); Assert.NotNull(log); Assert.Equal <int>(1, log.RunLogs.Count); runLog = log.RunLogs[0]; } finally { File.Delete(path); } return(runLog); }
public void Ctor2ArgTest() { ResultLog l0 = new ResultLog(); l0.LogGood("Good result."); l0.LogBad("Error result."); ResultLog l1 = new ResultLog(); l1.LogSuspect("Suspect result."); ResultLog l = new ResultLog("Merged", l0, l1); Assert.Equal("Merged", l.Caption); Assert.Equal(3, l.Count); Assert.Equal(1, l.GoodCount); Assert.Equal(1, l.BadCount); Assert.Equal(1, l.SuspectCount); Assert.False(l.IsGood); Assert.False(l.IsSuspect); Assert.True((l.IsBad)); Assert.False(l.IsNull); }
/// <summary> /// Execute parameterized SQL. /// For details, refer to the document of Dapper. /// </summary> /// <param name="cnn">Connection.</param> /// <param name="sql">Sql.</param> /// <param name="transaction">Transactions to be executed at the data source.</param> /// <param name="commandTimeout">Command timeout.</param> /// <param name="commandType">Command type.</param> /// <returns>Number of rows affected.</returns> public static Task <int> ExecuteAsync(this IDbConnection cnn, BuildedSql sql, IDbTransaction transaction = null, int?commandTimeout = default(int?), CommandType?commandType = default(CommandType?)) { //for testing. if (DapperAdapterTestPlugin.Execute != null) { return(Task.Factory.StartNew(() => DapperAdapterTestPlugin.Execute(cnn, sql))); } //debug. Debug(sql); try { var ret = DapperWrapperAsync.Execute(cnn, sql.Text, CreateDynamicParam(sql.GetParams()), transaction, commandTimeout, commandType); ResultLog?.Invoke(ret); return(ret); } catch (Exception e) { throw GetCoreException(e); } }
protected override ExitCode ExecuteFileTask() { string path = GetFullTargetPath(); var fileInfo = FileService.GetFileInfo(path); var extendedInfo = fileInfo as IExtendedFileSystemInformation; Table table = Table.Create(new ColumnFormat(1, ContentVisibility.ShowAll, Justification.Right), new ColumnFormat(1)); table.HasHeader = false; table.AddRow("Name", fileInfo.Name); table.AddRow("Path", fileInfo.Path); table.AddRow("Length", fileInfo.Length.ToString()); table.AddRow("Attributes", fileInfo.Attributes.ToString()); table.AddRow("Creation Time", fileInfo.CreationTime.ToString()); table.AddRow("Last Write Time", fileInfo.LastWriteTime.ToString()); table.AddRow("Last Access Time", fileInfo.LastAccessTime.ToString()); table.AddRow("Volume Serial Number", extendedInfo.VolumeSerialNumber.ToString()); table.AddRow("File Index", extendedInfo.FileIndex.ToString()); table.AddRow("Number of Links", extendedInfo.NumberOfLinks.ToString()); ResultLog.Write(table); return(ExitCode.Success); }
public void Post([FromBody] dynamic items) { var jsonString = JsonConvert.SerializeObject(items); var item = new ResultLog { CreatedOn = DateTime.Now, Data = jsonString }; var webRoot = _env.ContentRootPath; var file = System.IO.Path.Combine(webRoot, @"Json\results.json"); var json = System.IO.File.ReadAllText(file); List <ResultLog> lstExistingItems = string.IsNullOrEmpty(json) ? new List <ResultLog>() : (List <ResultLog>)JsonConvert.DeserializeObject(json, typeof(List <ResultLog>)); lstExistingItems.Add(item); var lstJsonItems = JsonConvert.SerializeObject(lstExistingItems); System.IO.File.WriteAllText(file, lstJsonItems); }