/// <summary> /// Open a GSA file. /// </summary> private void OpenGSAFile(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == true) { (SenderTab.Content as Grid).IsEnabled = false; (ReceiverTab.Content as Grid).IsEnabled = false; Status.ChangeStatus("Opening File"); Task.Run(() => GSA.OpenFile(openFileDialog.FileName, EmailAddress, RestApi)).ContinueWith( delegate { try { FileOpened = true; Application.Current.Dispatcher.BeginInvoke( DispatcherPriority.Background, new Action(() => { UpdateClientLists(); (SenderTab.Content as Grid).IsEnabled = FileOpened && LoggedIn; (ReceiverTab.Content as Grid).IsEnabled = FileOpened && LoggedIn; Status.ChangeStatus("Ready", 0); } )); } catch { Status.ChangeStatus("Failed to open file", 0); } }); } }
private void RunCLI() { if (cliMode == "receiver" && arguments.ContainsKey("h")) { Console.WriteLine("\n"); Console.WriteLine("Usage: SpeckleGSAUI.exe receiver\n"); Console.WriteLine("\n"); Console.Write("Required arguments:\n"); Console.Write("--server <server>\t\tAddress of Speckle server\n"); Console.Write("--email <email>\t\t\tEmail of account\n"); Console.Write("--token <token>\t\tJWT token\n"); Console.Write("--file <path>\t\t\tFile to save to. If file does not exist, a new one will be created\n"); Console.Write("--streamIDs <streamIDs>\t\tComma-delimited ID of streams to be received\n"); Console.WriteLine("\n"); Console.Write("Optional arguments:\n"); Console.Write("--layer [analysis|design]\tSet which layer to write to. Default is design layer\n"); Console.Write("--nodeAllowance <distance>\tMax distance before nodes are not merged\n"); return; } else if (cliMode == "sender" && arguments.ContainsKey("h")) { Console.WriteLine("\n"); Console.WriteLine("Usage: SpeckleGSAUI.exe sender\n"); Console.WriteLine("\n"); Console.Write("Required arguments:\n"); Console.Write("--server <server>\t\tAddress of Speckle server\n"); Console.Write("--email <email>\t\t\tEmail of account\n"); Console.Write("--token <token>\t\tJWT token\n"); Console.Write("--file <path>\t\t\tFile to open. If file does not exist, a new one will be created\n"); Console.WriteLine("\n"); Console.Write("Optional arguments:\n"); Console.Write("--layer [analysis|design]\tSet which layer to write to. Default is design layer\n"); Console.Write("--sendAllNodes\t\t\tSend all nodes in model. Default is to send only 'meaningful' nodes\n"); Console.Write("--separateStreams\t\tSeparate model into different streams\n"); Console.Write("--result <options>\t\tType of result to send. Each input should be in quotation marks. Comma-delimited\n"); Console.Write("--resultCases <cases>\t\tCases to extract results from. Comma-delimited\n"); Console.Write("--resultOnly\t\t\tSend only results\n"); Console.Write("--resultUnembedded\t\tSend results as separate objects\n"); Console.Write("--resultInLocalAxis\t\tSend results calculated at the local axis. Default is global\n"); Console.Write("--result1DNumPosition <num>\tNumber of additional result points within 1D elements\n"); return; } string[] neededArgs = new string[] { "server", "email", "token", "file" }; foreach (string a in neededArgs) { if (!arguments.ContainsKey(a)) { Console.WriteLine("Missing -" + a + " argument"); return; } } // Login EmailAddress = arguments["email"]; RestApi = arguments["server"]; ApiToken = arguments["token"]; // GSA File if (File.Exists(arguments["file"])) { GSA.OpenFile(arguments["file"], EmailAddress, RestApi, false); } else { GSA.NewFile(EmailAddress, RestApi, false); GSA.gsaProxy.SaveAs(arguments["file"]); } // We will receive all the things! if (cliMode == "receiver") { CLIReceiver(); } else if (cliMode == "sender") { CLISender(); } }