Exemple #1
0
        public static SpeckleObject ToSpeckle(this GSA0DElement dummyObject)
        {
            if (Initialiser.GsaKit.GSASenderObjects.Count <GSA0DElement>() == 0)
            {
                return(new SpeckleNull());
            }

            var newLines = ToSpeckleBase <GSA0DElement>();
            var typeName = dummyObject.GetType().Name;
            var changed  = false;

            var nodesLock = new object();
            var nodes     = Initialiser.GsaKit.GSASenderObjects.Get <GSANode>();

            Parallel.ForEach(newLines.Keys, k =>
            {
                var pPieces = newLines[k].ListSplit(Initialiser.AppResources.Proxy.GwaDelimiter);
                var gsaId   = pPieces[1];
                if (pPieces[4].ParseElementNumNodes() == 1)
                {
                    try
                    {
                        var massNode = new GSA0DElement()
                        {
                            GWACommand = newLines[k]
                        };
                        massNode.ParseGWACommand();

                        GSANode match;
                        lock (nodesLock)
                        {
                            match = nodes.Where(n => n.Value.ApplicationId == massNode.Value.ApplicationId).First();

                            if (match != null)
                            {
                                match.Value.Mass = massNode.Value.Mass;
                                match.SubGWACommand.AddRange(massNode.SubGWACommand.Concat(new string[] { newLines[k] }));

                                match.ForceSend = true;

                                changed = true;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Initialiser.AppResources.Messenger.CacheMessage(MessageIntent.Display, MessageLevel.Error, typeName, gsaId);
                        Initialiser.AppResources.Messenger.CacheMessage(MessageIntent.TechnicalLog, MessageLevel.Error, ex, typeName, gsaId);
                    }
                }
            }
                             );

            return((changed) ? new SpeckleObject() : new SpeckleNull());
        }
        public static SpeckleObject ToSpeckle(this GSA0DElement dummyObject)
        {
            if (Initialiser.GSASenderObjects.Count <GSA0DElement>() == 0)
            {
                return(new SpeckleNull());
            }

            var newLines = ToSpeckleBase <GSA0DElement>();

            var changed = false;

            var nodesLock = new object();
            var nodes     = Initialiser.GSASenderObjects.Get <GSANode>();

            Parallel.ForEach(newLines.Values, p =>
            {
                var pPieces = p.ListSplit("\t");
                if (pPieces[4].ParseElementNumNodes() == 1)
                {
                    try
                    {
                        var massNode = new GSA0DElement()
                        {
                            GWACommand = p
                        };
                        massNode.ParseGWACommand();

                        GSANode match;
                        lock (nodesLock)
                        {
                            match = nodes.Where(n => n.Value.ApplicationId == massNode.Value.ApplicationId).First();
                        }

                        if (match != null)
                        {
                            match.Value.Mass = massNode.Value.Mass;
                            match.SubGWACommand.AddRange(massNode.SubGWACommand.Concat(new string[] { p }));

                            match.ForceSend = true;

                            changed = true;
                        }
                    }
                    catch { }
                }
            }
                             );

            return((changed) ? new SpeckleObject() : new SpeckleNull());
        }
Exemple #3
0
        public static SpeckleObject ToSpeckle(this GSA0DElement dummyObject)
        {
            if (!Initialiser.GSASenderObjects.ContainsKey(typeof(GSA0DElement)))
            {
                return(new SpeckleNull());
            }

            var newLines = ToSpeckleBase <GSA0DElement>();

            var changed = false;

            var nodes = Initialiser.GSASenderObjects[typeof(GSANode)].Cast <GSANode>().ToList();

            foreach (var p in newLines.Values)
            {
                var pPieces = p.ListSplit("\t");
                if (pPieces[4].ParseElementNumNodes() == 1)
                {
                    try
                    {
                        var massNode = new GSA0DElement()
                        {
                            GWACommand = p
                        };
                        massNode.ParseGWACommand();

                        var match = nodes
                                    .Where(n => n.Value.ApplicationId == massNode.Value.ApplicationId)
                                    .First();

                        if (match != null)
                        {
                            match.Value.Mass = massNode.Value.Mass;
                            match.SubGWACommand.AddRange(massNode.SubGWACommand.Concat(new string[] { p }));

                            match.ForceSend = true;

                            changed = true;
                        }
                    }
                    catch { }
                }
            }

            return((changed) ? new SpeckleObject() : new SpeckleNull());
        }