public static void Execute(DAE.Client.DataView view) { using (ApplicationListForm form = new ApplicationListForm()) { form._dataSource.DataSet = view; if (form.ShowDialog() != DialogResult.OK) { throw new AbortException(); } } }
private void LoadToggleClicked(object sender, EventArgs args) { Dataphoria.Warnings.ClearErrors(Dataphoria); if (!Registered) { try { DAE.IServerCursor cursor = Dataphoria.OpenCursor ( String.Format ( @" select RequiredLibraries('{0}') group by {{ Library_Name }} add {{ Max(Level) Level }} where not exists (System.LoadedLibraries where Name = Library_Name) order by {{ Level desc }}; " , _libraryName ) ); try { using (DAE.Runtime.Data.IRow row = cursor.Plan.RequestRow()) { while (cursor.Next()) { cursor.Select(row); try { Dataphoria.ExecuteScript(String.Format("RegisterLibrary('{0}', false);", (string)row["Library_Name"])); } catch (Exception exception) { Dataphoria.Warnings.AppendError(Dataphoria, exception, false); } } } } finally { Dataphoria.CloseCursor(cursor); } try { Dataphoria.ExecuteScript(String.Format("RegisterLibrary('{0}', false);", _libraryName)); } catch (Exception exception) { Dataphoria.Warnings.AppendError(Dataphoria, exception, false); } } finally { ((LibraryListNode)Parent).RefreshRegistered(); } ((LibraryListNode)Parent).RefreshCurrent(); } else { try { using (Frontend.Client.Windows.IWindowsFormInterface form = (Frontend.Client.Windows.IWindowsFormInterface)Dataphoria.FrontendSession.CreateForm()) { Dataphoria.FrontendSession.CreateHost().Load(".Frontend.Form('Frontend', 'UnloadLibrary')", form); form.MainSource.Filter = GetFilter(); form.HostNode.Open(); if (form.ShowModal(Frontend.Client.FormMode.Query) != DialogResult.OK) { throw new AbortException(); } DAE.Client.DataView view = ((Frontend.Client.ISource)form.FindNode("Dependencies")).DataView; view.First(); foreach (DAE.Runtime.Data.Row row in view) { try { Dataphoria.ExecuteScript(String.Format("UnregisterLibrary('{0}', false);", (string)row["Library_Name"])); } catch (Exception exception) { Dataphoria.Warnings.AppendError(Dataphoria, exception, false); } } } try { Dataphoria.ExecuteScript(String.Format("UnregisterLibrary('{0}', false);", _libraryName)); } catch (Exception exception) { Dataphoria.Warnings.AppendError(Dataphoria, exception, false); } _canLoad = true; } finally { ((LibraryListNode)Parent).RefreshCurrent(); ((LibraryListNode)Parent).RefreshRegistered(); } } }
public static void Main(string[] args) { WinForms.Application.SetUnhandledExceptionMode(WinForms.UnhandledExceptionMode.CatchException, true); WinForms.Application.EnableVisualStyles(); WinForms.Application.ThreadException += new ThreadExceptionEventHandler(ThreadException); try { // Parse the command line string alias = String.Empty; string applicationID = String.Empty; string userID = String.Empty; int i = 0; while (i < args.Length) { switch (args[i].ToLower()) { case AliasParameter: alias = args[i + 1]; i++; break; case ApplicationParameter: applicationID = args[i + 1]; i++; break; case UserParameter: userID = args[i + 1]; i++; break; default: throw new ClientException(ClientException.Codes.InvalidCommandLine, args[i]); } i++; } AliasConfiguration configuration; if (alias == String.Empty) { configuration = ServerConnectForm.Execute(); } else { configuration = AliasManager.LoadConfiguration(); configuration.DefaultAliasName = alias; } if (userID != String.Empty) { configuration.Aliases[configuration.DefaultAliasName].SessionInfo.UserID = userID; } using (DataSession dataSession = new DataSession()) { dataSession.Alias = configuration.Aliases[configuration.DefaultAliasName]; dataSession.SessionInfo.Environment = "WindowsClient"; dataSession.Active = true; if (applicationID == String.Empty) { using (DAE.Client.DataView view = new DAE.Client.DataView()) { view.Session = dataSession; view.Expression = ApplicationListExpression; view.OrderString = ApplicationListOrder; view.IsReadOnly = true; view.Open(); // Count the number of applications System.Collections.IEnumerator enumValue = view.GetEnumerator(); // use explicit enumerator to avoid foreach unused var warning int count = 0; while (enumValue.MoveNext()) { count++; } // Prompt the user for the application if there is not exactly one row if (count != 1) { view.First(); ApplicationListForm.Execute(view); } applicationID = view.Fields["ID"].AsString; } } Session session = new Session(dataSession, false); // Pass false because the DataSession will be disposed by the using block session.Start(session.SetApplication(applicationID)); // This call will dispose the session. } } catch (AbortException) { // Do nothing (ignore abort) } catch (Exception exception) { Windows.Session.HandleException(exception); } }