public void FixtureSetup() { InstanceManager.Load(); FConfigurationManager = new SQLCEServerConfigurationManager(); FConfiguration = FConfigurationManager.GetTestConfiguration("TestOOPInstance"); if (InstanceManager.Instances.HasInstance("TestOOPInstance")) { InstanceManager.Instances.Remove("TestOOPInstance"); } InstanceManager.Instances.Add("TestOOPInstance", FConfiguration); InstanceManager.Save(); ProcessStartInfo LProcessStartInfo = new ProcessStartInfo(); LProcessStartInfo.FileName = Path.Combine(ServerConfigurationManager.GetInstallationDirectory(), "Dataphor\\bin\\DAEServer.exe"); LProcessStartInfo.WorkingDirectory = Path.GetDirectoryName(LProcessStartInfo.FileName); LProcessStartInfo.Arguments = "-n \"TestOOPInstance\""; LProcessStartInfo.UseShellExecute = false; LProcessStartInfo.RedirectStandardInput = true; FProcess = Process.Start(LProcessStartInfo); // TODO: This should be a wait for the process, but WaitForInputIdle only works on GUI apps //Thread.Sleep(10000); ConnectionAlias LAlias = new ConnectionAlias(); LAlias.Name = "TestOOPInstanceConnection"; LAlias.InstanceName = "TestOOPInstance"; int LRetryCount = 0; while ((FDataSession == null) && (LRetryCount++ < 3)) { Thread.Sleep(500); try { FDataSession = new DataSession(); FDataSession.Alias = LAlias; FDataSession.Open(); } catch { FDataSession = null; } } }
public void BeginLogin() { Status = ConnectStatus.Connecting; Session.Invoke <LoginResult> ( () => { var dataSession = new DataSession() { Alias = new ConnectionAlias() { HostName = _hostName, InstanceName = _instanceName } }; dataSession.Alias.SessionInfo.UserID = _userName; dataSession.Alias.SessionInfo.Password = _password == null ? "" : _password; dataSession.Alias.SessionInfo.Environment = "SilverlightClient"; dataSession.Open(); try { var applicationRows = new List <object[]>(); using (var applications = dataSession.OpenReadOnlyDataView(".Frontend.Applications")) { foreach (DAE.Runtime.Data.Row row in applications) { applicationRows.Add((object[])((NativeRow)row.AsNative).Values.Clone()); } } return(new LoginResult() { Applications = applicationRows, DataSession = dataSession }); } catch { dataSession.Dispose(); throw; } }, (Exception AException) => { Status = ConnectStatus.Login; Exception = AException; }, (LoginResult AResult) => { DataSession = AResult.DataSession; Applications = AResult.Applications; // If there is only 1 application, skip to login if (Applications.Count == 1) { ApplicationID = (string)Applications[0][0]; BeginStartApplication(); } else { Status = ConnectStatus.SelectApplication; } } ); }
public int Run() { bool hasErrors = true; try { using (DataSession dataphorConnection = new DataSession()) { if (File != null) { using (StreamReader file = new StreamReader(File)) { Script = file.ReadToEnd(); } } if (Script == null) // Script was not in the commandline or specified in a file { Console.WriteLine("\r\nMissing D4 script; include on command line or use /File: switch.\r\n"); Console.WriteLine(CommandLine.Parser.ArgumentsUsage(this.GetType())); return(1); } if (AliasName == String.Empty) { ConnectionAlias alias = new ConnectionAlias(); alias.HostName = Host; alias.InstanceName = Instance; if (Port > 0) { alias.OverridePortNumber = Port; } dataphorConnection.Alias = alias; } else { dataphorConnection.AliasName = AliasName; } if (User != null) { dataphorConnection.SessionInfo.UserID = User; } if (Password != null) { if (PasswordEncrypted == true) { dataphorConnection.SessionInfo.UnstructuredData = Password; } else { dataphorConnection.SessionInfo.Password = Password; } } dataphorConnection.Open(); if (!Quiet) { Console.WriteLine("Executing D4 Script:\r\n{0}\r\n", Script); } ErrorList errors; TimeSpan timeSpan; ScriptExecutionUtility.ExecuteScript ( dataphorConnection.ServerSession, Script, Options, out errors, out timeSpan, delegate(PlanStatistics AStatistics, string AResults) { Console.WriteLine(AResults); }, File == null ? null : new DebugLocator("file:" + Path.GetFullPath(File), 1, 1) ); foreach (Exception exception in errors) { Console.WriteLine(exception.Message); } hasErrors = ScriptExecutionUtility.ContainsError(errors); if (!Quiet) { Console.WriteLine("Status: {0} Total Time: {1}", (hasErrors ? "Failed" : "Succeeded"), timeSpan); } } if (Prompt) { if (!Quiet) { Console.Write("Press any key to continue."); } Console.Read(); } } catch (Exception exception) { Console.WriteLine(exception.Message); } if (hasErrors) { return(1); } return(0); }