Пример #1
0
        public void CLIReceiver()
        {
            if (!arguments.ContainsKey("streamIDs"))
            {
                Console.WriteLine("Missing -streamIDs argument");
                return;
            }

            var streamIds = arguments["streamIDs"].Split(new char[] { ',' });

            foreach (string id in streamIds)
            {
                GSA.ReceiverInfo.Add(new Tuple <string, string>(id, null));
            }
            GSA.SetSpeckleClients(EmailAddress, RestApi);

            if (arguments.ContainsKey("layer"))
            {
                if (arguments["layer"].ToLower() == "analysis")
                {
                    GSA.Settings.TargetLayer = GSATargetLayer.Analysis;
                }
            }

            if (arguments.ContainsKey("nodeAllowance"))
            {
                try
                {
                    GSA.Settings.CoincidentNodeAllowance = Convert.ToDouble(arguments["nodeAllowance"]);
                }
                catch { }
            }

            GSA.GetSpeckleClients(EmailAddress, RestApi);
            var gsaReceiver = new Receiver();

            Task.Run(() =>
            {
                var nonBlankReceivers = GSA.ReceiverInfo.Where(r => !string.IsNullOrEmpty(r.Item1)).ToList();

                foreach (var streamInfo in nonBlankReceivers)
                {
                    Status.AddMessage("Creating receiver " + streamInfo.Item1);
                    gsaReceiver.Receivers[streamInfo.Item1] = new SpeckleGSAReceiver(RestApi, ApiToken);
                }
            });
            Task.Run(() => gsaReceiver.Initialize(RestApi, ApiToken)).Wait();
            GSA.SetSpeckleClients(EmailAddress, RestApi);
            gsaReceiver.Trigger(null, null);
            gsaReceiver.Dispose();

            GSA.gsaProxy.SaveAs(arguments["file"]);
            GSA.Close();

            Console.WriteLine("Receiving complete");
        }
Пример #2
0
        public void CLISender()
        {
            if (arguments.ContainsKey("layer"))
            {
                if (arguments["layer"].ToLower() == "analysis")
                {
                    GSA.Settings.TargetLayer = GSATargetLayer.Analysis;
                }
            }

            if (arguments.ContainsKey("sendAllNodes"))
            {
                GSA.Settings.SendOnlyMeaningfulNodes = false;
            }

            if (arguments.ContainsKey("separateStreams"))
            {
                GSA.Settings.SeparateStreams = true;
            }

            if (arguments.ContainsKey("resultOnly"))
            {
                GSA.Settings.SendOnlyResults = true;
            }

            if (arguments.ContainsKey("resultUnembedded"))
            {
                GSA.Settings.EmbedResults = false;
            }

            if (arguments.ContainsKey("resultInLocalAxis"))
            {
                GSA.Settings.ResultInLocalAxis = true;
            }

            if (arguments.ContainsKey("result1DNumPosition"))
            {
                try
                {
                    GSA.Settings.Result1DNumPosition = Convert.ToInt32(arguments["result1DNumPosition"]);
                }
                catch { }
            }

            if (arguments.ContainsKey("result"))
            {
                GSA.Settings.SendResults = true;

                var results = arguments["result"].Split(new char[] { ',' }).Select(x => x.Replace("\"", ""));

                foreach (string r in results)
                {
                    if (Result.NodalResultMap.ContainsKey(r))
                    {
                        GSA.Settings.NodalResults[r] = Result.NodalResultMap[r];
                    }
                    else if (Result.Element1DResultMap.ContainsKey(r))
                    {
                        GSA.Settings.Element1DResults[r] = Result.Element1DResultMap[r];
                    }
                    else if (Result.Element2DResultMap.ContainsKey(r))
                    {
                        GSA.Settings.Element2DResults[r] = Result.Element2DResultMap[r];
                    }
                    else if (Result.MiscResultMap.ContainsKey(r))
                    {
                        GSA.Settings.MiscResults[r] = Result.MiscResultMap[r];
                    }
                }
            }

            if (arguments.ContainsKey("resultCases"))
            {
                GSA.Settings.ResultCases = arguments["resultCases"].Split(new char[] { ',' }).ToList();
            }

            GSA.GetSpeckleClients(EmailAddress, RestApi);
            var gsaSender = new Sender();

            Task.Run(() => gsaSender.Initialize(RestApi, ApiToken, (restApi, apiToken) => new SpeckleGSASender(restApi, apiToken))).Wait();
            GSA.SetSpeckleClients(EmailAddress, RestApi);
            gsaSender.Trigger();
            gsaSender.Dispose();

            GSA.gsaProxy.SaveAs(arguments["file"]);
            GSA.Close();

            Console.WriteLine("Sending complete");
        }