/// <summary> /// Initializes the HttpClient with the URL for the HelixALM REST API. /// </summary> static void InitClient() { // Sets up a custom HttpClientHandler that allows self signed certificates AppContext.SetSwitch("System.Net.Http.useSocketsHttpHandler", false); HttpClientHandler handler = new HttpClientHandler(); handler.ClientCertificateOptions = ClientCertificateOption.Manual; handler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, certChain, policyErrors) => { // If no errors, or specifically we are communicating with the configured server and the error is a certificate chain error, allow the connection if (policyErrors == System.Net.Security.SslPolicyErrors.None || (httpRequestMessage.RequestUri.AbsoluteUri.StartsWith(HelixALMRESTAPIUrl) && policyErrors == System.Net.Security.SslPolicyErrors.RemoteCertificateChainErrors)) { return true; } // Otherwise, reject the connection return false; }; // Create the HttpClient passing in the handler client = new HttpClient(handler); // Update the port number in the following line client.BaseAddress = new Uri(HelixALMRESTAPIUrl); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // Write all messages to the console System.Diagnostics.TraceListener listener = new System.Diagnostics.ConsoleTraceListener(); System.Diagnostics.Debug.Listeners.Add(listener); }
static void Main(string[] args) { { SolverContext context = SolverContext.GetContext(); // Load a model from file if (args.Length > 0) { using (TextReader streamReader = new StreamReader(args[0])) { context.LoadModel(FileFormat.MPS, streamReader); } // Select the Mosek interior point optimizer. MosekInteriorPointMethodDirective d = new MosekInteriorPointMethodDirective(); // Mosek specific parameters may optionally be set. // d[mosek.dparam.optimizer_max_time] = 100.0; // Optionally write log information to console using two lines below System.Diagnostics.ConsoleTraceListener listener = new System.Diagnostics.ConsoleTraceListener(); d.AddListener(listener); // Solve the problem Solution sol = context.Solve(d); // Print solution Report report = sol.GetReport(); } else { Console.WriteLine("Usage: MosekMsfExample filename"); } Console.WriteLine("Please press any key."); Console.ReadKey(); } }
/// <summary> /// start a self- / box-test for some diff cases and report to the debug output. /// </summary> /// <param name="args">not used</param> /// <returns>always 0</returns> public static int Main(string[] args) { StringBuilder ret = new StringBuilder(); string a, b; System.Diagnostics.ConsoleTraceListener ctl = new System.Diagnostics.ConsoleTraceListener(false); System.Diagnostics.Debug.Listeners.Add(ctl); System.Console.WriteLine("Diff Self Test..."); // test all changes a = "a,b,c,d,e,f,g,h,i,j,k,l".Replace(',', '\n'); b = "0,1,2,3,4,5,6,7,8,9".Replace(',', '\n'); System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "12.10.0.0*", "all-changes test failed."); System.Diagnostics.Debug.WriteLine("all-changes test passed."); // test all same a = "a,b,c,d,e,f,g,h,i,j,k,l".Replace(',', '\n'); b = a; System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "", "all-same test failed."); System.Diagnostics.Debug.WriteLine("all-same test passed."); // test snake a = "a,b,c,d,e,f".Replace(',', '\n'); b = "b,c,d,e,f,x".Replace(',', '\n'); System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "1.0.0.0*0.1.6.5*", "snake test failed."); System.Diagnostics.Debug.WriteLine("snake test passed."); // 2002.09.20 - repro a = "c1,a,c2,b,c,d,e,g,h,i,j,c3,k,l".Replace(',', '\n'); b = "C1,a,C2,b,c,d,e,I1,e,g,h,i,j,C3,k,I2,l".Replace(',', '\n'); System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "1.1.0.0*1.1.2.2*0.2.7.7*1.1.11.13*0.1.13.15*", "repro20020920 test failed."); System.Diagnostics.Debug.WriteLine("repro20020920 test passed."); // 2003.02.07 - repro a = "F".Replace(',', '\n'); b = "0,F,1,2,3,4,5,6,7".Replace(',', '\n'); System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "0.1.0.0*0.7.1.2*", "repro20030207 test failed."); System.Diagnostics.Debug.WriteLine("repro20030207 test passed."); // Muegel - repro a = "HELLO\nWORLD"; b = "\n\nhello\n\n\n\nworld\n"; System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "2.8.0.0*", "repro20030409 test failed."); System.Diagnostics.Debug.WriteLine("repro20030409 test passed."); // test some differences a = "a,b,-,c,d,e,f,f".Replace(',', '\n'); b = "a,b,x,c,e,f".Replace(',', '\n'); System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "1.1.2.2*1.0.4.4*1.0.7.6*", "some-changes test failed."); System.Diagnostics.Debug.WriteLine("some-changes test passed."); // test one change within long chain of repeats a = "a,a,a,a,a,a,a,a,a,a".Replace(',', '\n'); b = "a,a,a,a,-,a,a,a,a,a".Replace(',', '\n'); System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "0.1.4.4*1.0.9.10*", "long chain of repeats test failed."); System.Diagnostics.Debug.WriteLine("End."); System.Diagnostics.Debug.Flush(); return (0); }
/// <summary> /// start a self- / box-test for some diff cases and report to the debug output. /// </summary> /// <param name="args">not used</param> /// <returns>always 0</returns> public static int Main(string[] args) { StringBuilder ret = new StringBuilder(); string a, b; System.Diagnostics.ConsoleTraceListener ctl = new System.Diagnostics.ConsoleTraceListener(false); System.Diagnostics.Debug.Listeners.Add(ctl); System.Console.WriteLine("Diff Self Test..."); // test all changes a = "a,b,c,d,e,f,g,h,i,j,k,l".Replace(',', '\n'); b = "0,1,2,3,4,5,6,7,8,9".Replace(',', '\n'); System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "12.10.0.0*", "all-changes test failed."); System.Diagnostics.Debug.WriteLine("all-changes test passed."); // test all same a = "a,b,c,d,e,f,g,h,i,j,k,l".Replace(',', '\n'); b = a; System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "", "all-same test failed."); System.Diagnostics.Debug.WriteLine("all-same test passed."); // test snake a = "a,b,c,d,e,f".Replace(',', '\n'); b = "b,c,d,e,f,x".Replace(',', '\n'); System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "1.0.0.0*0.1.6.5*", "snake test failed."); System.Diagnostics.Debug.WriteLine("snake test passed."); // 2002.09.20 - repro a = "c1,a,c2,b,c,d,e,g,h,i,j,c3,k,l".Replace(',', '\n'); b = "C1,a,C2,b,c,d,e,I1,e,g,h,i,j,C3,k,I2,l".Replace(',', '\n'); System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "1.1.0.0*1.1.2.2*0.2.7.7*1.1.11.13*0.1.13.15*", "repro20020920 test failed."); System.Diagnostics.Debug.WriteLine("repro20020920 test passed."); // 2003.02.07 - repro a = "F".Replace(',', '\n'); b = "0,F,1,2,3,4,5,6,7".Replace(',', '\n'); System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "0.1.0.0*0.7.1.2*", "repro20030207 test failed."); System.Diagnostics.Debug.WriteLine("repro20030207 test passed."); // Muegel - repro a = "HELLO\nWORLD"; b = "\n\nhello\n\n\n\nworld\n"; System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "2.8.0.0*", "repro20030409 test failed."); System.Diagnostics.Debug.WriteLine("repro20030409 test passed."); // test some differences a = "a,b,-,c,d,e,f,f".Replace(',', '\n'); b = "a,b,x,c,e,f".Replace(',', '\n'); System.Diagnostics.Debug.Assert(TestHelper(Diff.DiffText(a, b, false, false, false)) == "1.1.2.2*1.0.4.4*1.0.6.5*", "some-changes test failed."); System.Diagnostics.Debug.WriteLine("some-changes test passed."); System.Diagnostics.Debug.WriteLine("End."); System.Diagnostics.Debug.Flush(); return(0); }
/// <summary> /// Performs an install of a database /// </summary> public override void Install(System.Collections.IDictionary stateSaver) { base.Install(stateSaver); var commandParams = GetCommandLineParameters(); var paramUICount = 0; var setup = new InstallSetup(); if (commandParams.Count > 0) { if (commandParams.ContainsKey(PARAMKEYS_SHOWSQL)) { if (commandParams[PARAMKEYS_SHOWSQL].ToLower() == "true" || commandParams[PARAMKEYS_SHOWSQL].ToLower() == "1" || commandParams[PARAMKEYS_SHOWSQL].ToLower() == string.Empty) { setup.ShowSql = true; } else if (commandParams[PARAMKEYS_SHOWSQL].ToLower() == "false" || commandParams[PARAMKEYS_SHOWSQL].ToLower() == "0") { setup.ShowSql = false; } else { throw new Exception("The /" + PARAMKEYS_SHOWSQL + " parameter must be set to 'true or false'."); } paramUICount++; } if (commandParams.ContainsKey(PARAMKEYS_LOGSQL)) { var logFile = commandParams[PARAMKEYS_LOGSQL]; if (!string.IsNullOrEmpty(logFile)) { //var isValid = !string.IsNullOrEmpty(logFile) && logFile.IndexOfAny(Path.GetInvalidFileNameChars()) < 0; //if (!isValid) // throw new Exception("The /" + PARAMKEYS_LOGSQL + " parameter must have a valid file name."); if (File.Exists(logFile)) { File.Delete(logFile); } setup.LogFilename = logFile; } paramUICount++; } if (commandParams.Any(x => PARAMKEYS_TRAN.Contains(x.Key))) { setup.UseTransaction = GetSetting(commandParams, PARAMKEYS_TRAN, true); paramUICount++; } if (commandParams.ContainsKey(PARAMKEYS_SKIPNORMALIZE)) { setup.SkipNormalize = true; paramUICount++; } if (commandParams.ContainsKey(PARAMKEYS_HASH)) { if (commandParams[PARAMKEYS_HASH].ToLower() == "true" || commandParams[PARAMKEYS_HASH].ToLower() == "1" || commandParams[PARAMKEYS_HASH].ToLower() == string.Empty) { setup.UseHash = true; } else if (commandParams[PARAMKEYS_HASH].ToLower() == "false" || commandParams[PARAMKEYS_HASH].ToLower() == "0") { setup.UseHash = false; } else { throw new Exception("The /" + PARAMKEYS_HASH + " parameter must be set to 'true or false'."); } paramUICount++; } if (commandParams.ContainsKey(PARAMKEYS_CHECKONLY)) { setup.CheckOnly = true; paramUICount++; } if (commandParams.ContainsKey(PARAMKEYS_QUIET)) { setup.SuppressUI = true; paramUICount++; } //Setup trace if need be. If showing SQL then auto trace on if (commandParams.ContainsKey(PARAMKEYS_TRACE) || setup.ShowSql) { var trc = new System.Diagnostics.ConsoleTraceListener(); System.Diagnostics.Trace.Listeners.Add(trc); paramUICount++; } if (commandParams.ContainsKey(PARAMKEYS_VERSIONWARN)) { if (commandParams[PARAMKEYS_VERSIONWARN].ToLower() == "all") { setup.AcceptVersionWarningsChangedScripts = true; setup.AcceptVersionWarningsNewScripts = true; } else if (commandParams[PARAMKEYS_VERSIONWARN].ToLower() == "none") { setup.AcceptVersionWarningsChangedScripts = false; setup.AcceptVersionWarningsNewScripts = false; } else if (commandParams[PARAMKEYS_VERSIONWARN].ToLower() == "new") { setup.AcceptVersionWarningsNewScripts = true; } else if (commandParams[PARAMKEYS_VERSIONWARN].ToLower() == "changed") { setup.AcceptVersionWarningsChangedScripts = true; } else { throw new Exception("The /" + PARAMKEYS_VERSIONWARN + " parameter must be set to 'all, none, new, or changed'."); } paramUICount++; } if (GetSetting(commandParams, PARAMKEYS_HELP, false)) { ShowHelp(); return; } //Try to drop database if (commandParams.Any(x => PARAMKEYS_DROP.Contains(x.Key))) { var masterConnectionString = GetSetting(commandParams, PARAMKEYS_MASTERDB, string.Empty); var dbname = commandParams.Where(x => PARAMKEYS_NEWNAME.Contains(x.Key)).Select(x => x.Value).FirstOrDefault(); if (commandParams.Count == 3 && !string.IsNullOrEmpty(masterConnectionString)) { if (!DropDatabase(dbname, masterConnectionString)) { throw new Exception("The database '" + dbname + "' could not dropped."); } System.Diagnostics.Trace.WriteLine("Database successfully dropped."); return; } throw new Exception("Invalid drop database configuration."); } setup.ConnectionString = GetSetting(commandParams, PARAMKEYS_APPDB, string.Empty); setup.MasterConnectionString = GetSetting(commandParams, PARAMKEYS_MASTERDB, string.Empty); if (GetSetting(commandParams, PARAMKEYS_UPGRADE, setup.IsUpgrade)) { setup.InstallStatus = InstallStatusConstants.Upgrade; } if (commandParams.Any(x => PARAMKEYS_CREATE.Contains(x.Key))) { setup.InstallStatus = InstallStatusConstants.Create; } if (commandParams.Any(x => PARAMKEYS_UPGRADE.Contains(x.Key)) && commandParams.Any(x => PARAMKEYS_CREATE.Contains(x.Key))) { throw new Exception("You cannot specify both the create and update action."); } if (commandParams.Count(x => PARAMKEYS_NEWNAME.Contains(x.Key)) > 1) { throw new Exception("The new database name was specified more than once."); } if (commandParams.Count(x => PARAMKEYS_MASTERDB.Contains(x.Key)) > 1) { throw new Exception("The master database connection string was specified more than once."); } if (commandParams.Count(x => PARAMKEYS_APPDB.Contains(x.Key)) > 1) { throw new Exception("The connection string was specified more than once."); } //Determine if calling as a script generator if (commandParams.ContainsKey(PARAMKEYS_SCRIPT)) { var scriptAction = commandParams[PARAMKEYS_SCRIPT].ToLower(); switch (scriptAction) { case "versioned": case "unversioned": case "create": break; default: throw new Exception("The script action must be 'create', 'versioned', or 'unversioned'."); } if (!commandParams.ContainsKey(PARAMKEYS_SCRIPTFILE)) { throw new Exception("The '" + PARAMKEYS_SCRIPTFILE + "' parameter must be set for script generation."); } var dumpFile = commandParams[PARAMKEYS_SCRIPTFILE]; if (!IsValidFileName(dumpFile)) { throw new Exception("The '" + PARAMKEYS_SCRIPTFILE + "' parameter is not valid."); } var fileCreate = true; if (commandParams.ContainsKey(PARAMKEYS_SCRIPTFILEACTION) && (commandParams[PARAMKEYS_SCRIPTFILEACTION] + string.Empty) == "append") { fileCreate = false; } if (File.Exists(dumpFile) && fileCreate) { File.Delete(dumpFile); System.Threading.Thread.Sleep(500); } switch (scriptAction) { case "versioned": if (commandParams.ContainsKey(PARAMKEYS_DBVERSION)) { if (!GeneratedVersion.IsValid(commandParams[PARAMKEYS_DBVERSION])) { throw new Exception("The '" + PARAMKEYS_DBVERSION + "' parameter is not valid."); } setup.Version = new GeneratedVersion(commandParams[PARAMKEYS_DBVERSION]); } else { if (string.IsNullOrEmpty(setup.ConnectionString)) { throw new Exception("Generation of versioned scripts requires a '" + PARAMKEYS_DBVERSION + "' parameter or valid connection string."); } else { var s = new nHydrateSetting(); s.Load(setup.ConnectionString); setup.Version = new GeneratedVersion(s.dbVersion); } } setup.InstallStatus = InstallStatusConstants.Upgrade; File.AppendAllText(dumpFile, UpgradeInstaller.GetScript(setup)); break; case "unversioned": setup.InstallStatus = InstallStatusConstants.Upgrade; setup.Version = UpgradeInstaller._def_Version; File.AppendAllText(dumpFile, UpgradeInstaller.GetScript(setup)); break; case "create": setup.InstallStatus = InstallStatusConstants.Create; setup.Version = new GeneratedVersion(-1, -1, -1, -1, -1); File.AppendAllText(dumpFile, UpgradeInstaller.GetScript(setup)); break; } return; } //If we processed all parameters and they were UI then we need to show UI if ((paramUICount < commandParams.Count) || setup.SuppressUI) { setup.NewDatabaseName = commandParams.Where(x => PARAMKEYS_NEWNAME.Contains(x.Key)).Select(x => x.Value).FirstOrDefault(); Install(setup); return; } } Console.WriteLine("Invalid configuration"); }
private static Udbus.Core.Logging.ILog CreateFormatLoggerImpl(System.Diagnostics.SourceLevels sourceLevel , string name, string format , params KeyValuePair<string, Udbus.Core.Logging.Formatter.StashDelegate>[] fields) { System.Diagnostics.ConsoleTraceListener consoleListener = new System.Diagnostics.ConsoleTraceListener(); return CreateFormatLogger(sourceLevel, name, format, consoleListener, fields); }
static TraceHelper() { _tracer.Listeners.Remove ("Default"); System.Diagnostics.Trace.AutoFlush = true; _console = new CleanConsole (); _console.Name = "console"; _console.TraceOutputOptions = System.Diagnostics.TraceOptions.None; _console.Filter = new System.Diagnostics.EventTypeFilter (System.Diagnostics.SourceLevels.Information); _consoleLevels = System.Diagnostics.SourceLevels.Information; _tracer.Listeners.Add (_console); }
protected bool isValidCredentials() { Progress("Validate Clearing House Setup.."); // Make Sure Clearing House is ClaimConnect Clearinghouse clearhouse = Clearinghouses.GetDefaultDental(); if(clearhouse == null) { Error("No clearinghouse is set as default."); return false; } if(clearhouse.CommBridge != EclaimsCommBridge.ClaimConnect) { Error("Your Clearinghouse does not offer Patient eBill functionality."); return false; } Progress("Extract Login Credentials.."); // Read LoginID & Password string loginID; string passWord; // Get Login / Password Clearinghouse dch=Clearinghouses.GetDefaultDental(); if(dch!=null) { loginID = dch.LoginID; passWord = dch.Password; } else { loginID = ""; passWord = ""; } if(loginID == "") { Error("Missing Login ID/Password." + DentalxChangeContactInfo); Cursor = Cursors.Default; return false; } Progress("Get Clearinghouse Authentication & Authorization.."); // Make 1st HTTP Call And Get the authenticaton PatienteBillServerAddress = PrefC.GetRaw("PatienteBillServerAddress"); if(PatienteBillServerAddress.Length == 0) { Error("Missing Patient eBill Server Information."+PWContactInfo); return false; } // string PatienteBillServer = PatienteBillServerAddress; string authRequest = @"Function=Auth&Source=STM&Username="******"&Password="******"&UploaderName=Practice-Web&UploaderVersion=3.0"; HttpUtility.UrlEncode(authRequest,System.Text.Encoding.Default); HttpWebRequest request = null; HttpWebResponse response = null; StreamReader sr = null; System.Diagnostics.ConsoleTraceListener trace = new System.Diagnostics.ConsoleTraceListener(); request = (HttpWebRequest)WebRequest.Create(PatienteBillServer + '?' + authRequest); request.AllowAutoRedirect = true; request.Method = "GET"; // Get The Respons response = (HttpWebResponse)request.GetResponse(); sr = new StreamReader(response.GetResponseStream()); String loginResponse = sr.ReadLine(); sr.Close(); string[] parseResponse; char[] separator = { '&' }; parseResponse = loginResponse.Split(separator); int responseStatus; string[] statusRespose; char[] separatorequal = { '=' }; statusRespose = parseResponse[0].Split(separatorequal); responseStatus = PIn.Int(statusRespose[1]); Progress("Process Clearinghouse Authorization Response.."); string errormessage = string.Empty; switch(responseStatus) { case 0: AuthenticationID = parseResponse[3].Remove(0,17); break; case 1: errormessage = "Authentication Failed.\r\n" + parseResponse[4].Remove(0,13); break; case 2: errormessage = "Cannot authorized at this time.\r\n" + parseResponse[4].Remove(0,13); break; case 3: errormessage = "Invalid Request.\r\n" + parseResponse[4].Remove(0,13); break; case 4: errormessage = "Invalid PMS Version.\r\n" + parseResponse[4].Remove(0,13); break; case 5: errormessage = "No Customer Contract.\r\n" + parseResponse[4].Remove(0,13); break; default: errormessage = "Unknown Status(" + responseStatus + ").\r\n" + parseResponse[4].Remove(0,13); break; } if(errormessage.Length > 0) { Error(errormessage + DentalxChangeContactInfo); return false; } // No error hence return true return true; }
private static System.Diagnostics.TraceListener[] MakeListenersForService(System.ServiceProcess.ServiceBase service) { System.Diagnostics.EventLogTraceListener eventListener = new System.Diagnostics.EventLogTraceListener(service.EventLog); System.Diagnostics.ConsoleTraceListener consoleListener = new System.Diagnostics.ConsoleTraceListener(); return(new System.Diagnostics.TraceListener[] { consoleListener, eventListener }); }
internal static Udbus.Core.Logging.ILog CreateWCFServiceLogger() { System.Diagnostics.ConsoleTraceListener consoleListener = new System.Diagnostics.ConsoleTraceListener(); return(Udbus.Core.Logging.LogCreation.CreateFormatLogger(defaultWCFServiceLevel, WCFServiceName, defaultWCFServiceFormat, consoleListener)); }
internal static Udbus.Core.Logging.ILog CreateIoDebugLogger() { System.Diagnostics.ConsoleTraceListener consoleListener = new System.Diagnostics.ConsoleTraceListener(); return(Udbus.Core.Logging.LogCreation.CreateFormatLogger(defaultIoDebugLevel, IoDebugName, defaultIoDebugFormat, consoleListener)); }
internal static Udbus.Core.Logging.ILog CreateDbusHostsLogger(DbusHosts dbusHosts) { System.Diagnostics.ConsoleTraceListener consoleListener = new System.Diagnostics.ConsoleTraceListener(); return(Udbus.Core.Logging.LogCreation.CreateFormatLogger(defaultSourceLevel, DbusHostsName, defaultFormat, consoleListener)); }