/// <summary> /// Performs custom arg validation for the utility, after invoking the base class parser. /// </summary> /// <param name="Settings">A settings instance to parse</param> /// <param name="CmdLineArgs">Command-line args array</param> /// <returns>True if args are valid, else False</returns> public new static bool Parse(SettingsSource Settings, string[] CmdLineArgs = null) { if (AppSettingsBase.Parse(Settings, CmdLineArgs)) { if (JobID.Initialized && !((string)JobID).IsGuid()) { ParseErrorMessage = "-jobid arg must be a GUID (nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn)"; return(false); } if (Attachment.Initialized && !System.IO.File.Exists(Attachment)) { ParseErrorMessage = "Attachment file does not exist or is not accessible: " + Attachment; return(false); } if (SSLType.Initialized && !SSLType.Value.In("auto", "onconnect")) { ParseErrorMessage = "Unsupported value in the -ssltype arg: " + SSLType; return(false); } if (LogLevel.Initialized && !LogLevel.Value.In("info", "warn", "error")) { ParseErrorMessage = "Unsupported value in the loglevel arg: " + LogLevel; return(false); } return(true); } return(false); }
/// <summary> /// Performs custom arg validation for the utility, after invoking the base class parser. /// </summary> /// <param name="Settings">A settings instance to parse</param> /// <param name="CmdLineArgs">Command-line args array</param> /// <returns>True if args are valid, else False</returns> public new static bool Parse(SettingsSource Settings, string[] CmdLineArgs = null) { if (AppSettingsBase.Parse(Settings, CmdLineArgs)) { if (HeaderLine.Initialized && SkipLines.Initialized && HeaderLine.Value > SkipLines.Value) { ParseErrorMessage = "The header line value cannot be greater than the skip lines value"; return(false); } if (HeaderLine.Initialized && ColFile.Initialized) { ParseErrorMessage = "Specify either a header line value or a column file value, but not both"; return(false); } if (Tbl.Initialized && Tbl.Value.Contains(".")) { if (Tbl.Value.Split('.').Length != 2) { ParseErrorMessage = "Accepted table name forms are \"tablename\" and \"schemaname.tablename\""; return(false); } } if (Delimiter.Initialized) { if (!Delimiter.Value.In("pipe", "comma", "tab", "auto")) { ParseErrorMessage = "Invalid value specified for the -delimiter arg"; return(false); } } if (JobID.Initialized && !JobID.Value.IsGuid()) { ParseErrorMessage = "-jobid arg must be a GUID (nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn)"; return(false); } if (!Db.Initialized && !NoLoad.Value && Preview.Value <= 0) { ParseErrorMessage = "-db argument is required unless the -noload argument is specified"; return(false); } if (Split.Initialized && !Prep.Initialized && Preview.Value <= 0) { ParseErrorMessage = "Splitting requires the -prep argument, because the input file has to be split out to a prep file."; return(false); } if (SQLTimeout.Initialized) { float Timeout; if (!float.TryParse(SQLTimeout.Value, out Timeout)) { ParseErrorMessage = "Uable to parse the specified SQL timeout value as a decimal value: " + SQLTimeout.Value; return(false); } } return(true); } return(false); }
/// <summary> /// Performs custom arg validation for the utility, after invoking the base class parser. /// </summary> /// <param name="Settings">A settings instance to parse</param> /// <param name="CmdLineArgs">Command-line args array</param> /// <returns>True if args are valid, else False</returns> public new static bool Parse(SettingsSource Settings, string[] CmdLineArgs = null) { if (AppSettingsBase.Parse(Settings, CmdLineArgs)) { bool YYYYMMParses = false; if (YYYYMM.Value.Equals("default", StringComparison.OrdinalIgnoreCase)) { int Year = DateTime.Now.Year; int Month = DateTime.Now.Month; Globals.FileYYYYMM = string.Format("{0:0000}{1:00}", Year, Month); YYYYMMParses = true; } else { int CmdLineMonth = 0; if (!Regex.IsMatch(YYYYMM.Value, "^\\d{6}$")) { YYYYMMParses = false; } else if (!int.TryParse(YYYYMM.Value.Substring(4), out CmdLineMonth)) { YYYYMMParses = false; } else if (!(1 <= CmdLineMonth && CmdLineMonth <= 12)) { YYYYMMParses = false; } else { Globals.FileYYYYMM = YYYYMM.Value; YYYYMMParses = true; } } if (!YYYYMMParses) { ParseErrorMessage = string.Format("yyyymm argument value {0} must be in the form YYYYMM", YYYYMM.Value); return(false); } if (!OnlyDownload && !Directory.Exists(Ingest.Value)) { ParseErrorMessage = string.Format("Ingest directory {0} does not exist", Ingest.Value); return(false); } if (!OnlyDownload) { if (!AccessKey.Initialized || !SecretKey.Initialized || !Bucket.Initialized || !Ingest.Initialized) { ParseErrorMessage = "S3 credentials/bucket name and ingest folder are required unless the -onlydownload option is specified"; return(false); } } return(true); } return(false); }
/// <summary> /// Provides custom parsing /// </summary> /// <param name="Src"></param> /// <param name="CmdLineArgs"></param> /// <returns></returns> public static new bool Parse(SettingsSource Src, string[] CmdLineArgs = null) { if (AppSettingsBase.Parse(Src, CmdLineArgs)) { string s = Settings.Value; if (s != null && s != "file" && s != "reg") { return(false); } return(true); } return(false); }
/// <summary> /// Performs custom arg validation for the utility, after invoking the base class parser. /// </summary> /// <param name="Settings">A settings instance to parse</param> /// <param name="CmdLineArgs">Command-line args array</param> /// <returns>True if args are valid, else False</returns> public new static bool Parse(SettingsSource Settings, string[] CmdLineArgs = null) { if (AppSettingsBase.Parse(Settings, CmdLineArgs)) { if (!Type.Value.In("delimited", "fixed")) { ParseErrorMessage = "Invalid value specified for the -type arg"; return(false); } if (Header.Initialized && Type.Value == "fixed" && !Header.Value.In("trunc", "fit")) { ParseErrorMessage = "Invalid value specified for the -header arg"; return(false); } if (Tbl.Initialized && Tbl.Value.Contains(".")) { if (Tbl.Value.Split('.').Length != 2) { ParseErrorMessage = "Accepted table name forms are \"tablename\" and \"schemaname.tablename\""; return(false); } } if (Delimiter.Initialized) { if (!Delimiter.Value.In("pipe", "comma", "tab")) { ParseErrorMessage = "Invalid value specified for the -delimiter arg"; return(false); } } if (JobID.Initialized && !JobID.Value.IsGuid()) { ParseErrorMessage = "-jobid arg must be a GUID (nnnnnnnn-nnnn-nnnn-nnnn-nnnnnnnnnnnn)"; return(false); } if (SQLTimeout.Initialized) { float Timeout; if (!float.TryParse(SQLTimeout.Value, out Timeout)) { ParseErrorMessage = "Uable to parse the specified SQL timeout value as a decimal value: " + SQLTimeout.Value; return(false); } } return(true); } return(false); }