private string BulidArgXml(FileIdentify file) { try { InputArg arg = _argMode.Copy(); arg.InputFilename = file.FileName; if (file.Identify.OrbitDateTime == DateTime.MinValue)//没解析出来时间。 { PrintInfo("获取轨道时间失败:" + file.FileName); } else if (_orbitDataTime == null || (Math.Abs((_orbitDataTime.Value - file.Identify.OrbitDateTime).TotalMinutes) >= 20)) { _orbitDataTime = file.Identify.OrbitDateTime; arg.PervObservationDate = _orbitDataTime.Value.ToString("yyyyMMdd"); arg.PervObservationTime = _orbitDataTime.Value.ToString("HHmm"); arg.OrbitIdentify = _orbitDataTime.Value.ToString("HHmm"); } else { arg.PervObservationDate = _orbitDataTime.Value.ToString("yyyyMMdd"); arg.PervObservationTime = _orbitDataTime.Value.ToString("HHmm"); arg.OrbitIdentify = _orbitDataTime.Value.ToString("HHmm"); } string xml = Path.Combine(arg.OutputDir, "batchArgs\\" + Path.GetFileName(file.FileName) + ".xml"); arg.ToXml(xml); return(xml); } catch (Exception ex) { PrintInfo("创建执行程序参数失败 " + ex.Message); return(null); } }
private bool Help() { InputArg remainingParameters = ExpectRemainingParameters(); if (remainingParameters == null) { Console.WriteLine("USAGE: {0}.EXE [OPTIONS]", AppName); } else { Console.WriteLine("USAGE: {0}.EXE [OPTIONS] {1}.", AppName, remainingParameters.Name); } Console.WriteLine("OPTIONS:"); foreach (InputArg arg in Options) { if (arg != remainingParameters) { Console.WriteLine("{0,14}: {1}", "/" + arg.Name.ToUpper(), string.Format(arg.HelpString, arg.Value)); } } if (remainingParameters != null) { Console.WriteLine("{0,14}: {1}", remainingParameters.Name, remainingParameters.HelpString); } return(false); }
private void CreateTargetUriTestWithPath(InputArg input) { using (var memory = new MemoryStream()) using (var writer = new StreamWriter(memory)) { writer.Write(input.ToString()); writer.Flush(); memory.Seek(0, SeekOrigin.Begin); var oparg = new OperationArguments.Impl(memory); oparg.UseHttpPath = true; Assert.NotNull(oparg); Assert.Equal(input.Protocol ?? string.Empty, oparg.QueryProtocol); Assert.Equal(input.Host ?? string.Empty, oparg.QueryHost); Assert.Equal(input.Path, oparg.QueryPath); Assert.Equal(input.Username, oparg.CredUsername); Assert.Equal(input.Password, oparg.CredPassword); // file or unc paths are treated specially if (oparg.QueryUri.Scheme != System.Uri.UriSchemeFile) { Assert.Equal("/" + input.Path, oparg.QueryUri.AbsolutePath); } } }
internal virtual bool OnProcessOption(InputArg option, string arg) { switch (option.Type) { case InputArgType.ExistingDirectory: ExpectedArg = option; CurrentArgMethod = ExpectNewDirectory; return(true); case InputArgType.SizeInBytes: ExpectedArg = option; CurrentArgMethod = ExpectSizeInBytes; return(true); case InputArgType.Parameter: ExpectedArg = option; CurrentArgMethod = ExpectParameter; return(true); case InputArgType.StringList: ExpectedArg = option; CurrentArgMethod = ExpectStringList; return(true); case InputArgType.Flag: option.Value = true; option.HasBeenSeen = true; CurrentArgMethod = DefaultProcessFunc; return(true); default: Console.WriteLine("Error, argument type {0} not implemented yet.", option.Type); return(false); } }
private void CreateTargetUriTestDefault(InputArg input) { using (var memory = new MemoryStream()) using (var writer = new StreamWriter(memory)) { writer.Write(input.ToString()); writer.Flush(); memory.Seek(0, SeekOrigin.Begin); var oparg = new OperationArguments(memory); Assert.IsNotNull(oparg); Assert.AreEqual(input.Protocol ?? string.Empty, oparg.QueryProtocol); Assert.AreEqual(input.Host ?? string.Empty, oparg.QueryHost); Assert.AreEqual(input.Path, oparg.QueryPath); Assert.AreEqual(input.Username, oparg.CredUsername); Assert.AreEqual(input.Password, oparg.CredPassword); // file or unc paths are treated specially if (oparg.QueryUri.Scheme != "file") { Assert.AreEqual("/", oparg.QueryUri.AbsolutePath); } } }
public ActionResult <Result> CalculateResult([FromBody] InputArg content) { Result result = new Result(); result.H = calculator.Get_H(content.A, content.B, content.C); result.K = calculator.Get_K(result.H, content.D, content.E, content.F); return(result); }
public void CreateTargetUriUncColloquial() { var input = new InputArg() { Host = @"\\windows\has\weird\paths", }; CreateTargetUriTestDefault(input); }
public Byte[] PrintReportService(string reportID, InputArg parameter) { //try //{ // var reportParameters = new List<ReportParameter> //{ // new ReportParameter() { ParaName = "Operate", ParaValue = "Report" }, // new ReportParameter() { ParaName = "UserID", ParaValue = parameter.UserID }, // new ReportParameter() { ParaName = "SchoolYear", ParaValue =parameter.SchoolYear }, // new ReportParameter() { ParaName = "SchoolCode", ParaValue = parameter.SchoolCode }, // new ReportParameter() { ParaName = "PersonID", ParaValue = parameter.ObjID} //}; var goPageparameter = new { Operate = "", UserID = "mif", UserRole = "Admin", SchoolYear = "20202021", SchoolCode = "0205", Grade = "", StudentID = "00881172306", PageID = reportID, Term = "1" }; var myGoPageItem = AppsPage.GoPageItemsList <GoPageItems>(goPageparameter)[0]; string reportingService = myGoPageItem.PageSite; string reportPath = myGoPageItem.PagePath; string reportName = myGoPageItem.PageFile; string PagePara = myGoPageItem.PagePara; var reportPara = new ReportBase { ReportService = myGoPageItem.PageSite, ReportPath = myGoPageItem.PagePath, ReportName = myGoPageItem.PageFile, ReportType = "IEP", ReportFormat = "PDF" }; Byte[] myReport = null; try { myReport = GeneratePDFReport.GetOneReport(reportPara, parameter); return(myReport); } catch (Exception ex) { var em = ex.Message; return(null); } }
public void CreateTargetUri_VstsSimple() { var input = new InputArg() { Protocol = "https", Host = "team.visualstudio.com", }; CreateTargetUriTestDefault(input); }
public void CreateTargetUriWithPortNumber() { var input = new InputArg() { Protocol = "https", Host = "onpremis:8080", }; CreateTargetUriTestDefault(input); }
public void CreateTargetUriGitHubSimple() { var input = new InputArg() { Protocol = "https", Host = "github.com", }; CreateTargetUriTestDefault(input); }
public List <string> FindOrCreateStringList(string argName) { InputArg option = GetOptionByName(argName); if (option.Value == null) { option.Value = new List <string>(); } return((List <string>)option.Value); }
public void StartBatch(string path, string searchOption) { _argMode = InputArg.ParseXml(path); if (_argMode == null) { Console.WriteLine("请提供参数文件"); return; } else { //判断InputFilename参数值是否为文件列表 string[] fileList = _argMode.InputFilename.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (fileList.Length > 1) { foreach (string file in fileList) { if (!File.Exists(file)) { Console.WriteLine("文件" + file + "不存在!"); return; } } _isFileList = true; _fileList = fileList; } else { Match match = InputFileRex.Match(_argMode.InputFilename); if (match.Groups["dir"].Success) { _path = match.Groups["dir"].Value; } if (match.Groups["filter"].Success) { _searchOption = match.Groups["filter"].Value; } if (string.IsNullOrWhiteSpace(_path) || !Directory.Exists(_path)) { Console.WriteLine("要扫描的文件路径为空,或者该路径不存在" + _path); return; } PrintInfo("启动扫描路径" + _path); if (!string.IsNullOrWhiteSpace(_searchOption)) { PrintInfo(" 文件过滤为" + _searchOption); } } } _timer = new Timer(5 * 1000); _timer.Elapsed += new ElapsedEventHandler(timer_Elapsed); _timer.Start(); _processTimer = new Timer(5 * 1000); _processTimer.Elapsed += new ElapsedEventHandler(StartProcess); _processTimer.Start(); }
void frmArgumentSetting_Load(object sender, EventArgs e) { _envList = new List <PrjEnvelopeItem>(); InputArg arg = InputArg.ParseXml(_path); if (arg != null) { InitSetting(arg); } cmbProjectID.SelectedIndex = 0; }
public void CreateTargetUri_UncColloquial() { var input = new InputArg() { Host = @"\\windows\has\weird\paths", }; CreateTargetUriTestDefault(input); CreateTargetUriTestSansPath(input); CreateTargetUriTestWithPath(input); }
public void CreateTargetUriGitHubComplex() { var input = new InputArg() { Protocol = "https", Host = "github.com", Path = "Microsoft/Git-Credential-Manager-for-Windows.git" }; CreateTargetUriTestDefault(input); }
public void CreateTargetUriComplexAndMessy() { var input = new InputArg() { Protocol = "https", Host = "foo.bar.com:8181", Path = "this-is/a/path%20with%20spaces", }; CreateTargetUriTestDefault(input); }
public void CreateTargetUriUnc() { var input = new InputArg() { Protocol = "file", Host = "unc", Path = "server/path", }; CreateTargetUriTestDefault(input); }
public void CreateTargetUriWithCredentials() { var input = new InputArg() { Protocol = "http", Host = "insecure.com", Username = "******", Password = "******", }; CreateTargetUriTestDefault(input); }
public void CreateTargetUri_GithubSimple() { var input = new InputArg() { Protocol = "https", Host = "github.com", }; CreateTargetUriTestDefault(input); CreateTargetUriTestSansPath(input); CreateTargetUriTestWithPath(input); }
public void CreateTargetUri_ComplexAndMessy() { var input = new InputArg() { Protocol = "https", Host = "foo.bar.com:8181", Path = "this-is/a/path%20with%20spaces", }; CreateTargetUriTestDefault(input); CreateTargetUriTestSansPath(input); CreateTargetUriTestWithPath(input); }
public void CreateTargetUri_Unc() { var input = new InputArg() { Protocol = "file", Host = "unc", Path = "server/path", }; CreateTargetUriTestDefault(input); CreateTargetUriTestSansPath(input); CreateTargetUriTestWithPath(input); }
public void CreateTargetUri_GithubComplex() { var input = new InputArg() { Protocol = "https", Host = "github.com", Path = "Microsoft/Git-Credential-Manager-for-Windows.git" }; CreateTargetUriTestDefault(input); CreateTargetUriTestSansPath(input); CreateTargetUriTestWithPath(input); }
public void UsernameWithDomain() { var input = new InputArg { Host = "example.visualstudio.com", Password = "******", Path = "path", Protocol = Uri.UriSchemeHttps, Username = @"DOMAIN\username" }; var cut = CreateTargetUriTestDefault(input); Assert.Equal(@"https://DOMAIN\[email protected]/path", cut.TargetUri.ToString(), StringComparer.Ordinal); Assert.Equal(input.ToString(), cut.ToString(), StringComparer.Ordinal); }
public async Task SpecialCharacters() { var input = new InputArg { Host = "example.visualstudio.com", Password = "******", Path = "path", Protocol = Uri.UriSchemeHttps, Username = "******" }; var cut = await CreateTargetUriTestDefault(input); Assert.Equal("https://userNamể@example.visualstudio.com/path", cut.TargetUri.ToString(), StringComparer.Ordinal); Assert.Equal(input.ToString(), cut.ToString(), StringComparer.Ordinal); }
public void EmailAsUserName() { var input = new InputArg { Host = "example.visualstudio.com", Password = "******", Path = "path", Protocol = Uri.UriSchemeHttps, Username = "******" }; var cut = CreateTargetUriTestDefault(input); Assert.Equal("https://[email protected]@example.visualstudio.com/path", cut.TargetUri.ToString(), StringComparer.Ordinal); Assert.Equal(input.ToString(), cut.ToString(), StringComparer.Ordinal); }
public void Typical() { var input = new InputArg { Host = "example.visualstudio.com", Password = "******", Path = "path", Protocol = "https", Username = "******", }; var cut = CreateTargetUriTestDefault(input); Assert.Equal("https://[email protected]/path", cut.TargetUri.ToString()); Assert.Equal(input.ToString(), cut.ToString(), StringComparer.Ordinal); }
public bool Process(string[] args) { Console.WriteLine("{0} - {1}\r\n", AppName, Caption); RemainingArgs = ExpectRemainingParameters(); CurrentArgMethod = DefaultProcessFunc; ExpectedArg = null; foreach (string arg in args) { if (!CurrentArgMethod(arg)) return false; } if (!AreAllRequiredArgumentsPresent()) return false; return true; }
private void CreateTargetUriTestDefault(InputArg input) { using (var memory = new MemoryStream()) using (var writer = new StreamWriter(memory)) { writer.Write(input.ToString()); writer.Flush(); memory.Seek(0, SeekOrigin.Begin); var oparg = new OperationArguments(RuntimeContext.Default, memory); Assert.NotNull(oparg); Assert.Equal(input.Protocol ?? string.Empty, oparg.QueryProtocol, StringComparer.Ordinal); Assert.Equal(input.Host ?? string.Empty, oparg.QueryHost, StringComparer.Ordinal); Assert.Equal(input.Path, oparg.QueryPath, StringComparer.Ordinal); Assert.Equal(input.Username, oparg.Username, StringComparer.Ordinal); Assert.Equal(input.Password, oparg.Password, StringComparer.Ordinal); } }
public void SpecialCharacters() { var input = new InputArg { Host = "example.visualstudio.com", Password = "******", Path = "path", Protocol = Uri.UriSchemeHttps, Username = "******" }; OperationArguments cut; using (var memory = new MemoryStream()) using (var writer = new StreamWriter(memory)) { writer.Write(input.ToString()); writer.Flush(); memory.Seek(0, SeekOrigin.Begin); cut = new OperationArguments(RuntimeContext.Default, memory); } Assert.Equal(input.Protocol, cut.QueryProtocol, StringComparer.Ordinal); Assert.Equal(input.Host, cut.QueryHost, StringComparer.Ordinal); Assert.Equal(input.Path, cut.QueryPath, StringComparer.Ordinal); Assert.Equal(input.Username, cut.Username, StringComparer.Ordinal); Assert.Equal(input.Password, cut.Password, StringComparer.Ordinal); Assert.Equal("https://userNamể@example.visualstudio.com/path", cut.TargetUri.ToString(), StringComparer.Ordinal); var expected = input.ToString(); var actual = cut.ToString(); Assert.Equal(expected, actual, StringComparer.Ordinal); }
public void Typical() { var input = new InputArg { Host = "example.visualstudio.com", Password = "******", Path = "path", Protocol = "https", Username = "******", }; OperationArguments cut; using (var memory = new MemoryStream()) using (var writer = new StreamWriter(memory)) { writer.Write(input.ToString()); writer.Flush(); memory.Seek(0, SeekOrigin.Begin); cut = new OperationArguments(RuntimeContext.Default, memory); } Assert.Equal(input.Protocol, cut.QueryProtocol); Assert.Equal(input.Host, cut.QueryHost); Assert.Equal(input.Path, cut.QueryPath); Assert.Equal(input.Username, cut.Username); Assert.Equal(input.Password, cut.Password); Assert.Equal("https://[email protected]/path", cut.TargetUri.ToString()); var expected = ReadLines(input.ToString()); var actual = ReadLines(cut.ToString()); Assert.Equal(expected, actual); }
public bool Process(string[] args) { Console.WriteLine("{0} - {1}\r\n", AppName, Caption); RemainingArgs = ExpectRemainingParameters(); CurrentArgMethod = DefaultProcessFunc; ExpectedArg = null; foreach (string arg in args) { if (!CurrentArgMethod(arg)) { return(false); } } if (!AreAllRequiredArgumentsPresent()) { return(false); } return(true); }
private void btnExcute_Click(object sender, EventArgs e) { //Save arg xml ////check argments if (CheckArgument() == false) { MessageBox.Show("参数设置不完整!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } InputArg arg = new InputArg(); if (rdbInputFiles.Checked) { arg.InputFilename = txtInputFiles.Text; } else { arg.InputFilename = txtInputDir.Text + " " + txtFilter.Text; } if (rdoAllBands.Checked == true) { arg.Bands = null; } else { int bandNo; string[] bandNos = txtBands.Text.Trim().Split(','); arg.Bands = new int[bandNos.Length]; for (int i = 0; i < bandNos.Length; i++) { if (int.TryParse(bandNos[i], out bandNo)) { arg.Bands[i] = bandNo; } } } arg.OutputDir = txtOutputDir.Text; if (rdoCResolution.Checked == true) { float resX; if (float.TryParse(txtResolution.Text, out resX)) { arg.ResolutionX = arg.ResolutionY = resX; } } //region arg.ValidEnvelopes = new PrjEnvelopeItem[_envList.Count()]; arg.Envelopes = new PrjEnvelopeItem[_envList.Count()]; if (ckbMoasic.Checked == true) { arg.MosaicInputArg = new MosaicInputArg(); RasterProject.PrjEnvelope envelope = GetEnvelopeFromUI(); arg.MosaicInputArg.Envelope = new PrjEnvelopeItem(txtRegionName.Text, envelope); arg.MosaicInputArg.OutputDir = txtMoasicOutDir.Text; } for (int i = 0; i < _envList.Count; i++) { arg.ValidEnvelopes[i] = arg.Envelopes[i] = _envList[i]; } arg.IsOnlySaveMosaicFile = ckbOnlyMoasicFile.Checked; arg.ProjectionIdentify = "GLL"; arg.ToXml(_path); DialogResult = DialogResult.OK; Close(); }
public void CreateTargetUri_VstsSimple() { var input = new InputArg() { Protocol = "https", Host = "team.visualstudio.com", }; CreateTargetUriTestDefault(input); CreateTargetUriTestSansPath(input); CreateTargetUriTestWithPath(input); }
private void CreateTargetUriTestWithPath(InputArg input) { using (var memory = new MemoryStream()) using (var writer = new StreamWriter(memory)) { writer.Write(input.ToString()); writer.Flush(); memory.Seek(0, SeekOrigin.Begin); var oparg = new OperationArguments(memory); oparg.UseHttpPath = true; Assert.IsNotNull(oparg); Assert.AreEqual(input.Protocol ?? string.Empty, oparg.QueryProtocol); Assert.AreEqual(input.Host ?? string.Empty, oparg.QueryHost); Assert.AreEqual(input.Path, oparg.QueryPath); Assert.AreEqual(input.Username, oparg.CredUsername); Assert.AreEqual(input.Password, oparg.CredPassword); // file or unc paths are treated specially if (oparg.QueryUri.Scheme != "file") { Assert.AreEqual("/" + input.Path, oparg.QueryUri.AbsolutePath); } } }
private bool MatchesOption(string arg, InputArg option) { return(option.Name.Equals(arg, SCType)); }
public void CreateTargetUri_WithPortNumber() { var input = new InputArg() { Protocol = "https", Host = "onpremis:8080", }; CreateTargetUriTestDefault(input); CreateTargetUriTestSansPath(input); CreateTargetUriTestWithPath(input); }
public bool Process(ref string[] args) { Console.WriteLine("{0} - {1}\r\n", AppName, Caption); RemainingArgs = ExpectRemainingParameters(); CurrentArgMethod = DefaultProcessFunc; ExpectedArg = null; for (int i = 0; i < args.Length; i++ ) { if (!CurrentArgMethod(ref args[i])) return false; } if (!AreAllRequiredArgumentsPresent()) return false; return true; }
internal virtual bool OnProcessOption(InputArg option, string arg) { switch (option.Type) { case InputArgType.ExistingDirectory: ExpectedArg = option; CurrentArgMethod = ExpectNewDirectory; return true; case InputArgType.Parameter: ExpectedArg = option; CurrentArgMethod = ExpectParameter; return true; case InputArgType.StringList: ExpectedArg = option; CurrentArgMethod = ExpectStringList; return true; case InputArgType.Flag: option.Value = true; option.HasBeenSeen = true; CurrentArgMethod = DefaultProcessFunc; return true; default: Console.WriteLine("Error, argument type {0} not implemented yet.", option.Type); return false; } }
public void CreateTargetUri_WithCredentials() { var input = new InputArg() { Protocol = "http", Host = "insecure.com", Username = "******", Password = "******", }; CreateTargetUriTestDefault(input); CreateTargetUriTestSansPath(input); CreateTargetUriTestWithPath(input); }
private void InitSetting(InputArg arg) { //band setting string bandsString = ""; if (arg.Bands == null || arg.Bands.Length == 0) { rdoAllBands.Checked = true; } else { int i = 0; for (; i < arg.Bands.Length - 1; i++) { bandsString += (arg.Bands[i].ToString() + ","); } bandsString += arg.Bands[i].ToString(); bandsString.Remove(bandsString.Length - 1); rdoCustomBands.Checked = true; txtBands.Text = bandsString; } //Input dir if (!string.IsNullOrEmpty(arg.InputFilename)) { //解析inputFilename string inputFilename = arg.InputFilename; if (!inputFilename.Contains(";")) { string[] inputFName = arg.InputFilename.Split(' '); if (inputFName != null && inputFName.Length > 0) { rdoInputDir.Checked = true; txtInputDir.Text = inputFName[0]; txtFilter.Text = inputFName[inputFName.Length - 1]; } } else { rdbInputFiles.Checked = true; txtInputFiles.Text = inputFilename; } } //Output dir txtOutputDir.Text = arg.OutputDir; //Project ID switch (arg.ProjectionIdentify) { case "GLL": cmbProjectID.SelectedIndex = 0; break; default: cmbProjectID.SelectedIndex = 0; break; } //Resultion if (arg.ResolutionX != 0 || arg.ResolutionY != 0) { rdoCResolution.Checked = true; txtResolution.Text = arg.ResolutionX.ToString() + "," + arg.ResolutionY.ToString(); } //Region if (arg.Envelopes != null && arg.Envelopes.Length > 0) { foreach (PrjEnvelopeItem item in arg.Envelopes) { lstRegions.Items.Add(item.Name); _envList.Add(new PrjEnvelopeItem(item.Name, (item.PrjEnvelope.Clone() as RasterProject.PrjEnvelope))); } lstRegions.SelectedIndex = 0; txtRegionName.Text = arg.ValidEnvelopes[0].Name; ucOutputRegion.MaxX = arg.ValidEnvelopes[0].PrjEnvelope.MaxX; ucOutputRegion.MaxY = arg.ValidEnvelopes[0].PrjEnvelope.MaxY; ucOutputRegion.MinX = arg.ValidEnvelopes[0].PrjEnvelope.MinX; ucOutputRegion.MinY = arg.ValidEnvelopes[0].PrjEnvelope.MinY; } if (arg.MosaicInputArg != null) { ckbMoasic.Checked = true; ckbOnlyMoasicFile.Checked = arg.IsOnlySaveMosaicFile; txtMoasicOutDir.Text = arg.MosaicInputArg.OutputDir; } else { ckbMoasic.Checked = false; } }
private bool MatchesOption(string arg, InputArg option) { return option.Name.Equals(arg, SCType); }