Esempio n. 1
0
        /// <summary>
        /// Associate the note with a specific URL so that we can display the note when the user clicks on a bookmarked field.
        /// </summary>
        protected void AssociateBookmarkNote(ICarrier carrier)
        {
            string url  = carrier.ParentCarrier.Signal.RSSFeedUrl.Url.Value;
            string note = carrier.ParentCarrier.Signal.BookmarkNote.Note.Text.Value;

            urlNote[url] = note ?? "";
        }
Esempio n. 2
0
		public Carrier(ISemanticTypeStruct protocol, string protocolPath, dynamic signal, ICarrier parentCarrier)
		{
			Protocol = protocol;
			Signal = signal;
			ProtocolPath = protocolPath;
			ParentCarrier = parentCarrier;
		}
Esempio n. 3
0
        protected void LogImage(string url, string fn, string keywords, string title, string explanation, List <string> errors)
        {
            ICarrier recordCarrier = CreateAPODRecordCarrier();

            recordCarrier.Signal.URL.Value = url;
            recordCarrier.Signal.ImageFilename.Filename = fn;
            recordCarrier.Signal.Keywords.Text.Value    = keywords;
            recordCarrier.Signal.Explanation.Text.Value = explanation;
            recordCarrier.Signal.Title.Text.Value       = title;
            recordCarrier.Signal.Errors = String.Join(", ", errors.ToArray());

            ISemanticTypeStruct protocol = rsys.SemanticTypeSystem.GetSemanticTypeStruct("DatabaseRecord");
            dynamic             signal   = rsys.SemanticTypeSystem.Create("DatabaseRecord");

            signal.TableName = "APOD";
            signal.Action    = "insert";
            signal.Row       = recordCarrier;
            rsys.CreateCarrier(this, protocol, signal);

            // Use the debug message receptor to display error counts.
            if (errors.Count > 0)
            {
                ++totalErrors;
                ISemanticTypeStruct dbgMsgProtocol = rsys.SemanticTypeSystem.GetSemanticTypeStruct("DebugMessage");
                dynamic             dbgMsgSignal   = rsys.SemanticTypeSystem.Create("DebugMessage");
                dbgMsgSignal.Message = totalErrors.ToString() + ": " + recordCarrier.Signal.Errors;
                rsys.CreateCarrier(this, dbgMsgProtocol, dbgMsgSignal);
            }
        }
Esempio n. 4
0
 public LocalDelivery(ICarrier carrier, IResource route, LocalFileDestination fileDestination, int cost)
 {
     this.carrier         = carrier;
     this.route           = route;
     this.fileDestination = fileDestination;
     this.cost            = cost;
 }
Esempio n. 5
0
        public override async void ProcessCarrier(ICarrier carrier)
        {
            string url = carrier.Signal.URL.Value;

            try
            {
                string html = await Task.Run(() =>
                {
                    // http://stackoverflow.com/questions/599275/how-can-i-download-html-source-in-c-sharp
                    using (WebClient client = new WebClient())
                    {
                        // For future reference, if there are parameters, like:
                        //   www.somesite.it/?p=1500
                        // use:
                        //   client.QueryString.Add("p", "1500"); //add parameters
                        return(client.DownloadString(url));
                    }
                });

                Emit(url, html);
            }
            catch (Exception ex)
            {
                EmitError(url, ex.Message);
            }
        }
Esempio n. 6
0
        public ICarrier Extract(ICarrierHeaderCollection headerCollection)
        {
            ICarrier carrier = NullableCarrier.Instance;

            if (headerCollection == null)
            {
                return(carrier);
            }
            foreach (var formatter in _carrierFormatters.OrderByDescending(x => x.Key))
            {
                if (!formatter.Enable)
                {
                    continue;
                }

                foreach (var header in headerCollection)
                {
                    if (formatter.Key == header.Key)
                    {
                        carrier = formatter.Decode(header.Value);
                        if (carrier.HasValue)
                        {
                            if (formatter.Key.EndsWith("sw3") && carrier is Carrier c)
                            {
                                c.Sampled = true;
                            }

                            return(carrier);
                        }
                    }
                }
            }

            return(carrier);
        }
Esempio n. 7
0
        public override async void ProcessCarrier(ICarrier carrier)
        {
            try
            {
                Tuple <string, string> location = await Task.Run(() =>
                {
                    string city      = String.Empty;
                    string stateAbbr = String.Empty;

                    string zipcode  = carrier.Signal.Value;
                    USZip zip       = new USZip();
                    XmlNode node    = zip.GetInfoByZIP(zipcode);
                    XDocument zxdoc = XDocument.Parse(node.InnerXml);
                    city            = zxdoc.Element("Table").Element("CITY").Value;
                    stateAbbr       = zxdoc.Element("Table").Element("STATE").Value;
                    return(new Tuple <string, string>(city, stateAbbr));
                });

                Emit(carrier.Signal.Value, location.Item1, location.Item2);
            }
            catch (Exception ex)
            {
                // Catch must happen on the main thread so that when we emit the exception, it is handled on the main thread.
                // TODO: Carriers should be able to be on their own threads and receceptors should indicate whether the
                // action needs to be marshalled onto the main application thread.
                EmitException(ex);
            }
        }
Esempio n. 8
0
 public Carrier(ISemanticTypeStruct protocol, string protocolPath, dynamic signal, ICarrier parentCarrier)
 {
     Protocol      = protocol;
     Signal        = signal;
     ProtocolPath  = protocolPath;
     ParentCarrier = parentCarrier;
 }
Esempio n. 9
0
		public override void ProcessCarrier(ICarrier carrier)
		{
			XmlNode node = xdoc.CreateElement("Carrier");
			node.Attributes.Append(CreateAttribute(xdoc, "Protocol", carrier.Protocol.DeclTypeName));
			carriersNode.AppendChild(node);
			ProcessCarrier(carrier, node);
		}
Esempio n. 10
0
        public override void ProcessCarrier(ICarrier carrier)
        {
            FullInfo fullInfo;

            // Duck-typing!
            if (!zipcodeInfoMap.TryGetValue(carrier.Signal.Zipcode, out fullInfo))
            {
                fullInfo = new FullInfo();
                zipcodeInfoMap[carrier.Signal.Zipcode] = fullInfo;
            }

            if (carrier.Protocol.DeclTypeName == "WeatherInfo")
            {
                fullInfo.WeatherInfo = carrier.Signal;
            }

            if (carrier.Protocol.DeclTypeName == "Location")
            {
                fullInfo.LocationInfo = carrier.Signal;
            }

            if (fullInfo.Completed)
            {
                string conditions = ProcessConditions(fullInfo.WeatherInfo);
                string hazards    = ProcessHazards(fullInfo.WeatherInfo);
                Say("Here is the weather for " + fullInfo.LocationInfo.City + " " + fullInfo.LocationInfo.State + ". ");
                Say("The low is " + fullInfo.WeatherInfo.Low + ".");
                Say("The high is " + fullInfo.WeatherInfo.High + ".");
                Say("The weather is: " + fullInfo.WeatherInfo.Summary + ".");
                Say(conditions);
                Say(hazards);
            }
        }
Esempio n. 11
0
        protected void ProcessCarrier(ICarrier carrier, XmlNode node)
        {
            Type t = carrier.Signal.GetType();

            t.GetProperties(BindingFlags.Instance | BindingFlags.Public).ForEach(p =>
            {
                object val = p.GetValue(carrier.Signal);

                if (val != null)
                {
                    // If this is a collection...
                    if (val is List <dynamic> )
                    {
                        // Must be a collection of semantic types!
                        CreateSubNodes(xdoc, node, p.Name, (List <dynamic>)val);
                    }
                    else if (val is ICarrier)
                    {
                        CreateSubNodes(xdoc, node, p.Name, (ICarrier)val);
                    }
                    else if (val is IRuntimeSemanticType)
                    {
                        CreateSubNodes(xdoc, node, p.Name, (IRuntimeSemanticType)val);
                    }
                    else
                    {
                        node.Attributes.Append(CreateAttribute(xdoc, p.Name, val.ToString()));
                    }
                }
            });
        }
Esempio n. 12
0
        public SegmentContext CreateEntrySegment(string operationName, ICarrier carrier)
        {
            var traceId        = GetTraceId(carrier);
            var segmentId      = GetSegmentId();
            var sampled        = GetSampled(carrier, operationName);
            var segmentContext = new SegmentContext(traceId, segmentId, sampled, _runtimeEnvironment.ServiceId.Value,
                                                    _runtimeEnvironment.ServiceInstanceId.Value, operationName, SpanType.Entry);

            if (carrier.HasValue)
            {
                var segmentReference = new SegmentReference
                {
                    Reference               = Reference.CrossProcess,
                    EntryEndpoint           = carrier.EntryEndpoint,
                    NetworkAddress          = carrier.NetworkAddress,
                    ParentEndpoint          = carrier.ParentEndpoint,
                    ParentSpanId            = carrier.ParentSpanId,
                    ParentSegmentId         = carrier.ParentSegmentId,
                    EntryServiceInstanceId  = carrier.EntryServiceInstanceId,
                    ParentServiceInstanceId = carrier.ParentServiceInstanceId
                };
                segmentContext.References.Add(segmentReference);
            }

            _entrySegmentContextAccessor.Context = segmentContext;
            return(segmentContext);
        }
        // TODO: clean up the casting in this method
        public bool EntityInteraction(NewPackets.EntityInteraction parameters)
        {
            //Debug.Log($"Entity Interaction | E1: {FactionID} {parameters.myEntityIndex} | E2: {parameters.otherFactionIndex} {parameters.otherEntityIndex}!");

            ICarrier carrier = Entities[parameters.myEntityIndex] as ICarrier;

            if (carrier == null)
            {
                return(false);
            }

            if (parameters.otherFactionIndex == 0)                                                      // Entity is in the neutral faction (pickup)
            {
                carrier.Carry(GameManager.PlayerFactions[0].Entities[parameters.otherEntityIndex]);
            }
            else if (parameters.otherFactionIndex == FactionID)                                         // Entity is in own faction
            {
                if (parameters.myEntityIndex == parameters.otherEntityIndex)                            // "self click" defines a pop-deploy request
                {
                    carrier.TryDeploy();
                }
                else                                                                                    // Otherwise pass
                {
                    carrier.Pass(Entities[parameters.otherEntityIndex]);
                }
            }

            return(true);
        }
Esempio n. 14
0
 public ISpanContext Extract(ICarrierReader carrierReader, ICarrier carrier)
 {
     if (carrierReader == null)
     {
         throw new ArgumentNullException(nameof(carrierReader));
     }
     return(carrierReader.Read(carrier));
 }
Esempio n. 15
0
        protected ICarrier CreateAPODRecordCarrier()
        {
            ISemanticTypeStruct protocol      = rsys.SemanticTypeSystem.GetSemanticTypeStruct("APOD");
            dynamic             record        = rsys.SemanticTypeSystem.Create("APOD");
            ICarrier            recordCarrier = rsys.CreateInternalCarrier(protocol, record);

            return(recordCarrier);
        }
Esempio n. 16
0
        public override void ProcessCarrier(ICarrier carrier)
        {
            XmlNode node = xdoc.CreateElement("Carrier");

            node.Attributes.Append(CreateAttribute(xdoc, "Protocol", carrier.Protocol.DeclTypeName));
            carriersNode.AppendChild(node);
            ProcessCarrier(carrier, node);
        }
Esempio n. 17
0
 // ICarrierFactory
 public void SetBumperCoDirection(IScrollController <TData> controller)
 {
     if (_current is SuspendedCarrier <TData> )
     {
         return;
     }
     _current = new BouncingCoDirectionCarrier <TData>();
     controller.OnCarrierChange(_current);
 }
Esempio n. 18
0
 // ICarrierFactory
 public void SetCarrierCoDirection(IScrollController <TData> controller)
 {
     if (_current is SuspendedCarrier <TData> )
     {
         return;
     }
     _current = new OneItemHopCoDirectionCarrier <TData>(controller);
     controller.OnCarrierChange(_current);
 }
Esempio n. 19
0
        /// <summary>
        /// Create a carrier of the specified protocol and signal.
        /// </summary>
        /// <param name="from">The source receptor.  Cay be null.</param>
        /// <param name="protocol">The protocol.</param>
        /// <param name="signal">The signal in the protocol's format.</param>
        public ICarrier CreateCarrier(IReceptorInstance from, ISemanticTypeStruct protocol, dynamic signal)
        {
            // This calls the internal method with recursion set to false.  We don't want to expose this
            // flag, so this method is a public front, as receptors should never set the "stop recursion" flag
            // to true when creating carriers.
            ICarrier carrier = CreateCarrier(from, protocol, signal, false);

            return(carrier);
        }
 // ICarrierFactory
 public void SetBumperCounterDirection(IScrollComponent <TData> component)
 {
     if (_current is SuspendedCarrier <TData> )
     {
         return;
     }
     _current = new BouncingCounterDirectionCarrier <TData>();
     component.OnCarrierChange(_current);
 }
Esempio n. 21
0
        protected void CreateSubNodes(XmlDocument xdoc, XmlNode node, string name, ICarrier carrier)
        {
            XmlNode subnode = xdoc.CreateElement(name);

            node.AppendChild(subnode);
            node.Attributes.Append(CreateAttribute(xdoc, "Protocol", carrier.Protocol.DeclTypeName));
            carriersNode.AppendChild(node);
            ProcessCarrier(carrier, subnode);
        }
 // ICarrierFactory
 public void SetDefaultCarrier(IScrollComponent <TData> component)
 {
     if (_current is SuspendedCarrier <TData> )
     {
         return;
     }
     _current = new DefaultCarrier <TData>();
     component.OnCarrierChange(_current);
 }
Esempio n. 23
0
        public override void ProcessCarrier(ICarrier carrier)
        {
            base.ProcessCarrier(carrier);

            if (carrier.Protocol.DeclTypeName == ProtocolName)
            {
                ShowSignal(carrier.Signal);
            }
        }
 // ICarrierFactory
 public void SetCarrierCounterDirection(IScrollComponent <TData> component)
 {
     if (_current is SuspendedCarrier <TData> )
     {
         return;
     }
     _current = new OneItemHopCounterDirectionCarrier <TData>(component);
     component.OnCarrierChange(_current);
 }
Esempio n. 25
0
        /// <summary>
        /// Create a carrier of the specified protocol and signal.
        /// </summary>
        /// <param name="from">The source receptor.  Cay be null.</param>
        /// <param name="protocol">The protocol.</param>
        /// <param name="signal">The signal in the protocol's format.</param>
        public ICarrier CreateCarrier(IReceptorInstance from, ISemanticTypeStruct protocol, dynamic signal, ICarrier parentCarrier = null, bool emitSubElements = true)
        {
            // This calls the internal method with recursion set to false.  We don't want to expose this
            // flag, so this method is a public front, as receptors should never set the "stop recursion" flag
            // to true when creating carriers.
            // TODO: Improve these "is it a system message" tests -- figure out how to get rid of these hardcoded string.
            ICarrier carrier = CreateCarrier(from, protocol, protocol.DeclTypeName, signal, false, protocol.DeclTypeName == "SystemMessage" || from.Name == "DropReceptor", parentCarrier, emitSubElements);

            return(carrier);
        }
Esempio n. 26
0
        /// <summary>
        /// Instantiate a carrier of the specified protocol and passing in the signal initialization action.
        /// Often used for instantiating carriers passed as the Row parameter to the persistence receptor.
        /// </summary>
        protected ICarrier InstantiateCarrier(string protocol, Action <dynamic> initializeSignal)
        {
            ISemanticTypeStruct semStruct = rsys.SemanticTypeSystem.GetSemanticTypeStruct(protocol);
            dynamic             signal    = rsys.SemanticTypeSystem.Create(protocol);

            initializeSignal(signal);
            ICarrier rowCarrier = rsys.CreateInternalCarrier(semStruct, signal);

            return(rowCarrier);
        }
Esempio n. 27
0
		protected Dictionary<string, object> GetColumnValueMap(ICarrier carrier)
		{
			// List<INativeType> types = rsys.SemanticTypeSystem.GetSemanticTypeStruct(carrier.Protocol.DeclTypeName).NativeTypes;

			List<IGetSetSemanticType> types = rsys.SemanticTypeSystem.GetSemanticTypeStruct(carrier.Protocol.DeclTypeName).AllTypes;
			Dictionary<string, object> cvMap = new Dictionary<string, object>();
			types.ForEach(t => cvMap[t.Name] = t.GetValue(rsys.SemanticTypeSystem, carrier.Signal));

			return cvMap;
		}
Esempio n. 28
0
    public bool Grab(ICarrier carryer)
    {
        Carryer            = carryer;
        rb2D.velocity      = Vector2.zero;
        rb2D.simulated     = false;
        transform.position = carryer.GrabPosition.position;
        transform.parent   = carryer.GrabPosition;

        return(true);
    }
Esempio n. 29
0
 public DepartureController(IDeparture departureService, ICity cityService, ICarrier carrierService, IPaymentCategory paymentCategoryService, IVehicle vehicleService, IDistance distanceService, IPriceManager priceManager)
 {
     _deparatureService      = departureService;
     _cityService            = cityService;
     _carrierService         = carrierService;
     _paymentCategoryService = paymentCategoryService;
     _vehicleService         = vehicleService;
     _distanceService        = distanceService;
     _priceService           = priceManager;
 }
Esempio n. 30
0
        /// <summary>
        /// Creates the carrier (as an internal carrier, not exposed to the system) for containing
        /// our record information.  Assuming only an update, this sets only the EventDateTime field.
        /// </summary>
        protected ICarrier CreateRow()
        {
            // Create the type for the updated data.
            ISemanticTypeStruct rowProtocol = rsys.SemanticTypeSystem.GetSemanticTypeStruct("LastEventDateTime");
            dynamic             rowSignal   = rsys.SemanticTypeSystem.Create("LastEventDateTime");

            rowSignal.EventDateTime = LastEventTime;
            ICarrier rowCarrier = rsys.CreateInternalCarrier(rowProtocol, rowSignal);

            return(rowCarrier);
        }
Esempio n. 31
0
        /// <summary>
        /// Creates a carrier instructing the persistor to update the LastEventDateTime field for our event name.
        /// </summary>
        protected void UpdateRecord(ICarrier rowCarrier)
        {
            ISemanticTypeStruct protocol = rsys.SemanticTypeSystem.GetSemanticTypeStruct("DatabaseRecord");
            dynamic             signal   = rsys.SemanticTypeSystem.Create("DatabaseRecord");

            signal.TableName = "LastEventDateTime";
            signal.Row       = rowCarrier;
            signal.Action    = "update";
            signal.Where     = "EventName = " + EventName.SingleQuote();
            rsys.CreateCarrier(receptor, protocol, signal);
        }
Esempio n. 32
0
		public override void ProcessCarrier(ICarrier carrier)
		{
			base.ProcessCarrier(carrier);

			List<string> filters;

			if (protocolFilterMap.TryGetValue(carrier.Protocol.DeclTypeName, out filters))
			{
				FilterSignal(carrier.Protocol.DeclTypeName, carrier.Signal, filters);
			}
		}
Esempio n. 33
0
        public override void ProcessCarrier(ICarrier carrier)
        {
            base.ProcessCarrier(carrier);

            List <string> filters;

            if (protocolFilterMap.TryGetValue(carrier.Protocol.DeclTypeName, out filters))
            {
                FilterSignal(carrier.Protocol.DeclTypeName, carrier.Signal, filters);
            }
        }
Esempio n. 34
0
		public override void ProcessCarrier(ICarrier carrier)
		{
			string url = carrier.Signal.Value;
			try
			{
				Process.Start(url);
			}
			catch
			{
				// Eat exceptions.
			}
		}
Esempio n. 35
0
		public override void ProcessCarrier(ICarrier carrier)
		{
			try
			{
				FullInfo fullInfo;

				// Duck-typing! -- Both USLocation and WeatherInfo have a Zip5 member.
				if (!zipcodeInfoMap.TryGetValue(carrier.Signal.Zip5.Value, out fullInfo))
				{
					fullInfo = new FullInfo();
					zipcodeInfoMap[carrier.Signal.Zip5.Value] = fullInfo;
				}

				if (carrier.Protocol.DeclTypeName == "WeatherInfo")
				{
					fullInfo.WeatherInfo = carrier.Signal;
				}

				if (carrier.Protocol.DeclTypeName == "USLocation")
				{
					fullInfo.LocationInfo = carrier.Signal;
				}

				if (fullInfo.Completed)
				{
					string conditions = ProcessConditions(fullInfo.WeatherInfo);
					string hazards = ProcessHazards(fullInfo.WeatherInfo);
					Say("Here is the weather for " + fullInfo.LocationInfo.City.Value + " " + fullInfo.LocationInfo.USState.Value + ". ");
					Say("The low is " + fullInfo.WeatherInfo.Low + ".");
					Say("The high is " + fullInfo.WeatherInfo.High + ".");
					Say("The weather is: " + fullInfo.WeatherInfo.Summary + ".");
					Say(conditions);
					Say(hazards);
				}
			}
			catch (Exception ex)
			{
				EmitException(ex);
			}
		}
Esempio n. 36
0
		public override void ProcessCarrier(ICarrier carrier)
		{
			base.ProcessCarrier(carrier);

			//if (carrier.ParentCarrier != null)
			{
				// Additional behavior if this is a web image
				// if (carrier.ParentCarrier.Protocol.DeclTypeName == "WebImage")
				if (carrier.ProtocolPath == "WebImage")
				{
					url = carrier.Signal.Url.Value;

					if (!String.IsNullOrEmpty(url))
					{
						AddEmitProtocol("Url");
					}
					else
					{
						RemoveEmitProtocol("Url");
					}
				}
			}
		}
Esempio n. 37
0
		public override void ProcessCarrier(ICarrier carrier)
		{
			dynamic signal = carrier.Signal;

			// Assign the ID to an index in the cave system that represent a vertex.
			idToIndexMap[signal.ID] = idToIndexMap.Count;

			// If we've got all 20 caves, tell each cave who it is and where it is.
			// The order in which the carriers are received here and by the cave receptors
			// is irrelevant.
			if (idToIndexMap.Count == 20)
			{
				AssignPits();
				AssignBats();
				AssignWumpus();
				AssignPlayer();

				idToIndexMap.ForEach((kvp) =>
					{
						int idx = kvp.Value;
						CreateCarrier("HW_YouAre", (outSignal) =>
							{
								outSignal.ID = kvp.Key;
								outSignal.CaveNumber = idx;
								outSignal.AdjoiningCave1 = caveMatrix[idx][0];
								outSignal.AdjoiningCave2 = caveMatrix[idx][1];
								outSignal.AdjoiningCave3 = caveMatrix[idx][2];
								outSignal.HasBottomlessPit = pits.Contains(idx);
								outSignal.HasSuperBats = bats.Contains(idx);
								outSignal.HasWumpus = wumpus == idx;
								outSignal.HasPlayer = player == idx;
							});
					});

				rsys.Remove(this);
			}
		}
Esempio n. 38
0
		/// <summary>
		/// Associate the note with a specific URL so that we can display the note when the user clicks on a bookmarked field.
		/// </summary>
		protected void AssociateBookmarkNote(ICarrier carrier)
		{
			string url = carrier.ParentCarrier.Signal.RSSFeedUrl.Url.Value;
			string note = carrier.ParentCarrier.Signal.BookmarkNote.Note.Text.Value;
			urlNote[url] = note ?? "";
		}
Esempio n. 39
0
		public override void ProcessCarrier(ICarrier carrier)
		{
			base.ProcessCarrier(carrier);

			if (carrier.Protocol.DeclTypeName == "BookmarkCategory" && carrier.ParentCarrier.Protocol.DeclTypeName == "RSSFeedBookmark")
			{
				AssociateBookmarkNote(carrier);
			}

			if (carrier.Protocol.DeclTypeName == "RSSFeedItem")
			{
				// Seems it actually is best to do this for every new row added.
				// Certainly, the sort glyph does not appear until we do this, after data has been received.
				// TODO: The problem with this is that it will override the user's selection.
				dgvSignals.Columns[pubDateColumnName].SortMode = DataGridViewColumnSortMode.Programmatic;
				dgvSignals.Columns[pubDateColumnName].HeaderCell.SortGlyphDirection = SortOrder.Descending;
				dgvSignals.Sort(dgvSignals.Columns[pubDateColumnName], System.ComponentModel.ListSortDirection.Descending);

				// ShowSignal(carrier.Signal);

				// We are interested in the existence of the root and whether an UrlVisited ST exists on it.
				// We determine the following:

				// RSSFeedItem with no parent: this is a new feed coming off the FeedReader itself
				// RSSFeedItem with parent: this is an existing feed (which may also be duplicated from FeedReader, we have no way of knowing the order)
				//		If UrlVisited exists, mark it as visited
				//		If UrlVisited is null, mark it as "old but no visited"
				// Otherwise, any RSSFeedItems with no parent an no (even null) RSSFeedVisted are marked as actually being new!

				// We potentially have a race condition:
				// A new feed (not seen) is stored to the DB
				// The query occurs, and while the UrlVisited is null, it's now viewed as "old"

				// HOWEVER: THE ABOVE IS INCORRECT!!!

				// I'm leaving the above comments for now so one can see how to think "wrongly" about architecture.
				// The reason the above is wrong is that we're determining feed "old" state from information that has nothing to do with managing 
				// whether the feed has been seen or not.
				// Instead, we actually need a type, something like "seen before" to tell us the state.  After all, the feed reader may be persisting
				// data without a viewer, or we just have a viewer without the feed reader being present.  Or we have a feed reader and viewer, but no
				// database.  The architecture MUST be flexible to handle these different scenarios.

				// Another interesting point is that the "seen before" state is not a flag, it's actually a semantic type!  This is a vitally important
				// distinction to make with regards to semantic systems -- they manage state semantically rather than with some non-semantic boolean that
				// just happens to be lableled "seen before".  It's going to be hard to convince people that this is a better way, because in all reality,
				// we have no real use cases to say it's better other than to say, look, you can determine state semantically rather than by querying a field
				// within a record.  What advantage does that have?  Well, it's a semantic state, but that isn't necessarily convincing enough.

				// Anyways, this explains why we have an RSSFeedItemDisplayed ST, so we know whether the feed viewer has ever displayed this feed before.

				// This url value is the same as val.RSSFeedUrl.Url.Value -- we know this because this is what is being joined on in the composite ST.
				// Therefore, it's simpler to match on url in the code below.
				string url = carrier.Signal.RSSFeedUrl.Url.Value;

				if (carrier.ParentCarrier != null)
				{
					dynamic val;

					// Visited takes precedence over displayed.
					// If it's visited, of course it's been displayed.
					if (rsys.SemanticTypeSystem.TryGetSignalValue(carrier.ParentCarrier.Signal, "UrlVisited", out val))
					{
						foreach (DataGridViewRow row in dgvSignals.Rows)
						{
							if (row.Cells[urlColumnName].Value.ToString() == url)
							{
								row.DefaultCellStyle.BackColor = visitedColor;
								rowStateByUrl[url] = ItemStates.Visited;
								break;
							}
						}
					}
					else   // not visited, however, possibly displayed previously.
					{
						// Do we have an RSSFeedItemDisplayed ST?
						if (rsys.SemanticTypeSystem.TryGetSignalValue(carrier.ParentCarrier.Signal, "RSSFeedItemDisplayed", out val))
						{
							// Find the row and set the background color to a light blue to indicate "old feed item"
							foreach (DataGridViewRow row in dgvSignals.Rows)
							{
								if (row.Cells[urlColumnName].Value.ToString() == url)
								{
									row.DefaultCellStyle.BackColor = displayedColor;
									rowStateByUrl[url] = ItemStates.Displayed;
									break;
								}
							}
						}
						else
						{
							// This record has not been seen before.
							// Emit the "ItemDisplayed" ST for this URL but keep our display state as new until the DB is re-queried.
							// CreateCarrierIfReceiver("RSSFeedItemDisplayed", signal => signal.RSSFeedUrl.Url.Value = url, false);
							rowStateByUrl[url] = ItemStates.New;
							AnnounceNewItem(carrier.Signal.RSSFeedTitle.Title.Text.Value);
						}
					}
				}
				else
				{
					// No parent carrier, the feed is possibly coming from the feed reader directly.  Regardless, try marking that the feed has been displayed.
					// However, keep our display state as "new" until we receive something from the database indicating that we've displayed this feed item before.
					// CreateCarrierIfReceiver("RSSFeedItemDisplayed", signal => signal.RSSFeedUrl.Url.Value = url, false);

					// Only update if the row state is not currently set, as we don't want to reset displayed or visited to the "new" state.
					if (!rowStateByUrl.ContainsKey(url))
					{
						rowStateByUrl[url] = ItemStates.New;
						AnnounceNewItem(carrier.Signal.RSSFeedTitle.Title.Text.Value);
					}
				}
			}
		}
Esempio n. 40
0
		public override void ProcessCarrier(ICarrier carrier)
		{
			base.ProcessCarrier(carrier);

			int idx = 0;
			
			foreach(string pq in ProtocolHierarchy.Split(';'))
			{
				string p = pq.LeftOf(',');
				if (carrier.ProtocolPath == p)			// only top-level protocols are processed, otherwise we end up adding signals at all parent levels of the tree!
				{
					ShowSignal(carrier.Signal, p, idx);
					break;
				}

				++idx;
			}
		}
Esempio n. 41
0
		protected void ProcessCarrier(ICarrier carrier, XmlNode node)
		{
			Type t = carrier.Signal.GetType();
			t.GetProperties(BindingFlags.Instance | BindingFlags.Public).ForEach(p =>
			{
				object val = p.GetValue(carrier.Signal);

				if (val != null)
				{
					// If this is a collection...
					if (val is List<dynamic>)
					{
						// Must be a collection of semantic types!
						CreateSubNodes(xdoc, node, p.Name, (List<dynamic>)val);
					}
					else if (val is ICarrier)
					{
						CreateSubNodes(xdoc, node, p.Name, (ICarrier)val);
					}
					else if (val is IRuntimeSemanticType)
					{
						CreateSubNodes(xdoc, node, p.Name, (IRuntimeSemanticType)val);
					}
					else
					{
						node.Attributes.Append(CreateAttribute(xdoc, p.Name, val.ToString()));
					}
				}
			});
		}
Esempio n. 42
0
		public override async void ProcessCarrier(ICarrier carrier)
		{
			try
			{
				// TODO: Do we expose this configuration capability to the user?
				// TODO: We don't really want this, but we need it to prevent the Weather Service receptor from triggering another "get the US Location for the zipcode"
				// when it emits the WeatherInfo ST.  Fascinating stuff and is why Semtrex will be necessary.
				if (carrier.ProtocolPath == "Zip5")
				{
					string zipcode = carrier.Signal.Value;	// We only use the zip5 portion.

					Tuple<string, string> location = await Task.Run(() =>
					{
						string city = String.Empty;
						string stateAbbr = String.Empty;

						USZip zip = new USZip();
						XmlNode node = zip.GetInfoByZIP(zipcode);
						XDocument zxdoc = XDocument.Parse(node.InnerXml);
						city = zxdoc.Element("Table").Element("CITY").Value;
						stateAbbr = zxdoc.Element("Table").Element("STATE").Value;
						return new Tuple<string, string>(city, stateAbbr);

					});

					Emit(zipcode, location.Item1, location.Item2);
				}
			}
			catch (Exception ex)
			{
				// Catch must happen on the main thread so that when we emit the exception, it is handled on the main thread.
				// TODO: Carriers should be able to be on their own threads and receceptors should indicate whether the 
				// action needs to be marshalled onto the main application thread.
				EmitException(ex);
			}
		}
Esempio n. 43
0
		/// <summary>
		/// Recurse into SE's of the protocol and emit carriers for those as well, if a receiver exists.
		/// </summary>
		protected void CreateCarriersForSemanticElements(IReceptorInstance from, ISemanticTypeStruct protocol, string protocolPath, dynamic signal, bool stopRecursion, ICarrier parentCarrier)
		{
			protocol.SemanticElements.ForEach(se =>
				{
					dynamic subsignal = SemanticTypeSystem.Clone(signal, se); // Clone the contents of the signal's semantic element into the subsignal.

					// We may have a null child, in which case, don't drill any further into the structure!
					if (subsignal != null)
					{
						ISemanticTypeStruct semStruct = SemanticTypeSystem.GetSemanticTypeStruct(se.Name);
						// Will result in recursive calls for all sub-semantic types.
						CreateCarrierIfReceiver(from, semStruct, protocolPath + "." + semStruct.DeclTypeName, subsignal, parentCarrier);
					}
				});
		}
Esempio n. 44
0
		/// <summary>
		/// If not overridden, will invoke the action associated with the receive protocol that is qualified by the qualifier function.
		/// </summary>
		/// <param name="carrier"></param>
		public virtual void ProcessCarrier(ICarrier carrier)
		{
			ProcessSignal(carrier.Protocol, carrier.Signal);
		}
Esempio n. 45
0
		/// <summary>
		/// Create a carrier of the specified protocol and signal.
		/// </summary>
		/// <param name="from">The source receptor.  Cay be null.</param>
		/// <param name="protocol">The protocol.</param>
		/// <param name="signal">The signal in the protocol's format.</param>
		public ICarrier CreateCarrier(IReceptorInstance from, ISemanticTypeStruct protocol, dynamic signal, ICarrier parentCarrier = null, bool emitSubElements = true)
		{
			// This calls the internal method with recursion set to false.  We don't want to expose this 
			// flag, so this method is a public front, as receptors should never set the "stop recursion" flag
			// to true when creating carriers.
			// TODO: Improve these "is it a system message" tests -- figure out how to get rid of these hardcoded string.
			ICarrier carrier = CreateCarrier(from, protocol, protocol.DeclTypeName, signal, false, protocol.DeclTypeName=="SystemMessage" || from.Name=="DropReceptor", parentCarrier, emitSubElements);

			return carrier;
		}
Esempio n. 46
0
		protected void CreateCarrierIfReceiver(IReceptorInstance from, ISemanticTypeStruct protocol, string protocolPath, dynamic signal, ICarrier parentCarrier, bool emitSubElements = true)
		{
			if (from.GetEnabledEmittedProtocols().Any(p => p.Protocol == protocol.DeclTypeName))
			{
				if (TargetReceptorExistsFor(ReceptorFromInstance(from), protocol, protocol.DeclTypeName == protocolPath))
				{
					// This call will recurse for us.
					// CreateCarrier(IReceptorInstance from, ISemanticTypeStruct protocol, string protocolPath, dynamic signal, bool stopRecursion, bool isSystemMessage = false, ICarrier parentCarrier = null)
					CreateCarrier(from, protocol, protocolPath, signal, false, false, parentCarrier, emitSubElements, protocol.DeclTypeName == protocolPath);
				}
				else
				{
					if (emitSubElements)
					{
						// Recurse into SE's of the protocol and emit carriers for those as well, if a receiver exists.
						// We do this even if there isn't a target for the top-level receptor.
						// However, we do create a Carrier instance as the parent so the child can reference it if necessary.
						Carrier carrier = new Carrier(protocol, protocolPath, signal, parentCarrier);
						CreateCarriersForSemanticElements(from, protocol, protocolPath, signal, false, carrier);
					}
				}
			}
			else
			{
				if (emitSubElements)
				{
					// Create a Carrier instance as the parent so the child can reference it if necessary.
					Carrier carrier = new Carrier(protocol, protocolPath, signal, parentCarrier);
					CreateCarriersForSemanticElements(from, protocol, protocolPath, signal, false, carrier);
				}
			}
		}
Esempio n. 47
0
		public override void ProcessCarrier(ICarrier carrier)
		{
			base.ProcessCarrier(carrier);

			if (carrier.Protocol.DeclTypeName == ProtocolName)
			{
				ShowSignal(carrier.Signal);
			}
		}
Esempio n. 48
0
		/// <summary>
		/// Creates a carrier instructing the persistor to update the LastEventDateTime field for our event name.
		/// </summary>
		protected void UpdateRecord(ICarrier rowCarrier)
		{
			ISemanticTypeStruct protocol = rsys.SemanticTypeSystem.GetSemanticTypeStruct("DatabaseRecord");
			dynamic signal = rsys.SemanticTypeSystem.Create("DatabaseRecord");
			signal.TableName = "LastEventDateTime";
			signal.Row = rowCarrier;
			signal.Action = "update";
			signal.Where = "EventName = " + EventName.SingleQuote();
			rsys.CreateCarrier(receptor, protocol, signal);
		}
Esempio n. 49
0
		public override void ProcessCarrier(ICarrier carrier)
		{
			string zipcode = carrier.Signal.Value;
			ProcessZipcode(zipcode);
		}
Esempio n. 50
0
		public NewCarrierEventArgs(IReceptorInstance from, ICarrier carrier)
		{
			From = from;
			Carrier = carrier;
		}
Esempio n. 51
0
		public override void ProcessCarrier(ICarrier carrier)
		{
			// Is it the "You are here" protocol?
			if (carrier.Protocol.DeclTypeName == "HW_YouAre")
			{
				// Save our cave # and neighbor cave numbers.
				caveNumber = carrier.Signal.CaveNumber;
				caveNeighbors[0] = carrier.Signal.AdjoiningCave1;
				caveNeighbors[1] = carrier.Signal.AdjoiningCave2;
				caveNeighbors[2] = carrier.Signal.AdjoiningCave3;

				hasBottomlessPit = carrier.Signal.HasBottomlessPit;
				hasSuperBats = carrier.Signal.HasSuperBats;
				hasWumpus = carrier.Signal.HasWumpus;
				hasPlayer = carrier.Signal.HasPlayer;

				// Configure emitters and listeners.
				UpdateEmitters();
				UpdateListeners();

				if (hasPlayer)
				{
					SayWhoIsNextToUs();
					AskAboutOurNeighbors();
					TalkToPlayer();
				}
			}
			else if (carrier.Protocol.DeclTypeName.StartsWith("HW_Announce"))
			{
				if (hasBottomlessPit)
				{
					CreateCarrier("Text", (outSignal) => outSignal.Value = "I feel a draft!");
				}

				if (hasSuperBats)
				{
					CreateCarrier("Text", (outSignal) => outSignal.Value = "I hear flapping!");							
				}

				if (hasWumpus)
				{
					CreateCarrier("Text", (outSignal) => outSignal.Value = "I smell a Wumpus!");
				}
			}
			else if (carrier.Protocol.DeclTypeName == "HW_MoveTo")
			{
				if (carrier.Signal.NewCaveNumber == caveNumber)
				{
					hasPlayer = true;
					
					if (CheckCaveState())
					{
						SayWhoIsNextToUs();
						AskAboutOurNeighbors();
						TalkToPlayer();
					}
				}
				else
				{
					hasPlayer = false;
				}
			}
			else if (carrier.Protocol.DeclTypeName == "HW_ShootInto")
			{
				if (hasPlayer)
				{
					CreateCarrier("Text", (outSignal) => outSignal.Value = "Ouch!  You shot yourself!!!!!!!!");
					CreateCarrier("HW_GameState", (outSignal) => outSignal.PlayerShotSelf = true);
				}
				// This is my cave the hunter is shooting into!
				else if (hasWumpus)
				{
					CreateCarrier("Text", (outSignal) => outSignal.Value = "Ouch!  You shot the Wumpus!!!!!!!!");
					CreateCarrier("HW_GameState", (outSignal) => outSignal.WumpusIsDead = true);
				}
				else
				{
					int arrowLife = carrier.Signal.RemainingLife;
					--arrowLife;

					if (arrowLife > 0)
					{
						// The arrow continues to a random room.
						CreateCarrier("HW_ShootInto", (signal) =>
						{
							signal.CaveNumber = caveNeighbors[rnd.Next(3)];
							signal.RemainingLife = arrowLife;
						});
					}
				}
			}
		}
Esempio n. 52
0
		/// <summary>
		/// Create a carrier of the specified protocol and signal if a receiver currently exists.
		/// Note that because a carrier might not be created, there is no return value for this method.
		/// </summary>
		/// <param name="from">The source receptor.  Cay be null.</param>
		/// <param name="protocol">The protocol.</param>
		/// <param name="signal">The signal in the protocol's format.</param>
		public void CreateCarrierIfReceiver(IReceptorInstance from, ISemanticTypeStruct protocol, dynamic signal, ICarrier parentCarrier = null, bool emitSubElements = true)
		{
			CreateCarrierIfReceiver(from, protocol, protocol.DeclTypeName, signal, parentCarrier, emitSubElements);
		}
Esempio n. 53
0
		public override void ProcessCarrier(ICarrier carrier)
		{
			// Filter what protocol we display in the textbox.
			if ( (!String.IsNullOrEmpty(ProtocolFilter)) && (!ShowAll) )
			{
				if (carrier.ProtocolPath.Contains(ProtocolFilter))
				{
					base.ProcessCarrier(carrier);
				}
			}
			else
			{
				base.ProcessCarrier(carrier);
			}
		}
Esempio n. 54
0
		/// <summary>
		/// Internal carrier creation.  This includes the "stopRecursion" flag to prevent wildcard receptors from receiving ad-infinitum their own emissions.
		/// </summary>
		protected ICarrier CreateCarrier(IReceptorInstance from, ISemanticTypeStruct protocol, string protocolPath, dynamic signal, bool stopRecursion, bool isSystemMessage = false, ICarrier parentCarrier = null, bool emitSubElements = true, bool isRoot = true)
		{
			Carrier carrier = null;

			if (from.GetEnabledEmittedProtocols().Any(p => p.Protocol == protocol.DeclTypeName) || isSystemMessage)
			{
				carrier = new Carrier(protocol, protocolPath, signal, parentCarrier);
				// ************ MOVED TO A: **************
				// The reason this was moved is so that we fire NewCarrier only for actual receptors with protocols enabled for that receptor.
				// TODO: However, this means that we no longer queue protocols for which we have no receptors.  Not sure if we actually want this particular feature.
				// NewCarrier.Fire(this, new NewCarrierEventArgs(from, carrier));

				// We pass along the stopRecursion flag to prevent wild-card carrier receptor from receiving their own emissions, which would result in a new carrier,
				// ad-infinitum.
				ProcessReceptors(from, carrier, stopRecursion, isRoot);
			}

			// Recurse into SE's of the protocol and emit carriers for those as well, if a receiver exists.
			if (!isSystemMessage && emitSubElements)
			{
				// The carrier might be null if there's no receiver for the parent carrier.  In this case, we need to create a dummy carrier so we have a parent.
				if (carrier == null)
				{
					carrier = new Carrier(protocol, protocolPath, signal, parentCarrier);
				}

				CreateCarriersForSemanticElements(from, protocol, protocol.DeclTypeName, signal, stopRecursion, carrier);
			}

			return carrier;
		}
Esempio n. 55
0
		protected void CreateSubNodes(XmlDocument xdoc, XmlNode node, string name, ICarrier carrier)
		{
			XmlNode subnode = xdoc.CreateElement(name);
			node.AppendChild(subnode);
			node.Attributes.Append(CreateAttribute(xdoc, "Protocol", carrier.Protocol.DeclTypeName));
			carriersNode.AppendChild(node);
			ProcessCarrier(carrier, subnode);
		}
Esempio n. 56
0
		// TODO: This code needs to be optimized.
		/// <summary>
		/// Returns the target receptors that will receive the carrier protocol, qualified by the receptor's optional condition on the signal.
		/// </summary>
		protected List<IReceptorConnection> GetTargetReceptorsFor(IReceptor from, ICarrier carrier, bool isRoot)
		{
			// Lastly, filter the list by qualified receptors that are not the source of the carrier.
			List<IReceptorConnection> newTargets = new List<IReceptorConnection>();

			// From can be null if we're changing the layout during the time when carriers are being processed,
			// specifically, when a receptor is moved into or out of a membrane or the receptor is taken off the surface.
			if (from != null)
			{
				List<IReceptorConnection> targets;
				ISemanticTypeStruct protocol = carrier.Protocol;

				// This annoying piece of code assumes that a receptor will have only one connection between "from" to "to".
				// In the case of the semantic database, a "from" receptor can have multiple connections with the same semantic database receptor.
				// In other words, the returned list consists of [n] identical instances, where [n] is the number of different protocols from "from" to the target receptor.
				if (!MasterReceptorConnectionList.TryGetValue(from, out targets))
				{
					// When the try fails, it sets targets to null.
					targets = new List<IReceptorConnection>();
				}

				// To fix the aformentioned problem, we get only the distinct instances.
				targets = targets.Distinct().ToList();

				// Only enabled receptors and receptors that are not the source of the carrier and our not ourselves.
				List<IReceptorConnection> filteredTargets = targets.Where(r => 
					(!r.RootOnly || isRoot) && 
					r.Receptor != from && 
					r.Receptor.Instance.Enabled && 
					r.PermeabilityProtocol == protocol.DeclTypeName).ToList(); // &&
					// r.Receptor.Instance.GetEnabledReceiveProtocols().Select(rq => rq.Protocol).Contains(protocol.DeclTypeName)).ToList();

				// Will have a count of 0 if the receptor is the system receptor, ie, carrier animations or other protocols.
				// TODO: This seems kludgy, is there a better way of working with this?
				// Also, if the emitting receptor doesn't declare its protocol, this count will be 0, leading to potentially strange results.
				// For example, comment out the persistence receptors "IDReturn" and run the feed reader example.  You'll see that TWO items
				// are returned as matching "RSSFeed" table name and for reasons unknown at the moment, protocolReceptorMap has two entries that qualify.
				if (filteredTargets.Count == 0)
				{
					// When the try fails, it sets targets to null.
					if (protocolReceptorMap.TryGetValue(protocol.DeclTypeName, out targets))
					{
						filteredTargets = targets.Where(r => r.Receptor.Instance.Enabled && (r.Receptor != from) && true).ToList();
						// Remove disabled receive protocols.
						filteredTargets = filteredTargets.Where(r => r.Receptor.Instance.GetReceiveProtocols().Exists(p => p.Protocol == protocol.DeclTypeName && p.Enabled)).ToList();
					}
				}

				filteredTargets.Where(r => r.Receptor != from && r.Receptor.Instance.Enabled).ForEach(t =>
					{
						// The PermeableProtocol may be a higher level protocol than the receiver receives, so we need to find the receivers that have sub-protocols of the current protocol enabled.
						List<ISemanticTypeStruct> protocols = protocol.FlattenedSemanticTypes();
						protocols.ForEach(se =>
							{
								string prot = se.DeclTypeName;
								// Get the list of receive actions and filters for the specific protocol.
								var receiveList = t.Receptor.Instance.GetEnabledReceiveProtocols().Where(rp => rp.Protocol == prot);
								receiveList.ForEach(r =>
									{
										// If qualified, add to the final target list.
										// REF: 03282015
										// TODO: It looks like we're already doing a qualifier check in BaseReceptor.  Probably we can remove THAT check!
										if (r.Qualifier(carrier.Signal))
										{
											newTargets.Add(t);
										}
									});
							});
					});

				// filteredTargets = filteredTargets.Where(t => t.Instance.GetReceiveProtocols().Any(rp => (rp.Protocol == protocol.DeclTypeName) && rp.Qualifier(carrier.Signal))).ToList();

				// Get the targets of the single receive protocol that matches the DeclTypeName and whose qualifier returns true.
				// filteredTargets = filteredTargets.Where(t => t.Instance.GetReceiveProtocols().Single(rp => rp.Protocol == protocol.DeclTypeName).Qualifier(carrier.Signal)).ToList();
			}
			else
			{
				// TODO: Should we log this error so we can further inspect the effects that it may have on processing carriers?
			}

			return newTargets;
		}
Esempio n. 57
0
		public override void ProcessCarrier(ICarrier carrier)
		{
			dynamic signal = carrier.Signal;

			if (carrier.Protocol.DeclTypeName == "HW_Player")
			{
				currentCaveNumber = signal.CaveNumber;
				moveButtons[0].Text = "Move to " + signal.AdjoiningCave1;
				moveButtons[0].Tag = (int)signal.AdjoiningCave1;
				moveButtons[1].Text = "Move to " + signal.AdjoiningCave2;
				moveButtons[1].Tag = (int)signal.AdjoiningCave2;
				moveButtons[2].Text = "Move to " + signal.AdjoiningCave3;
				moveButtons[2].Tag = (int)signal.AdjoiningCave3;
				moveButtons.ForEach(b => b.Visible = true);

				shootButtons[0].Text = "Shoot into " + signal.AdjoiningCave1;
				shootButtons[0].Tag = (int)signal.AdjoiningCave1;
				shootButtons[1].Text = "Shoot into " + signal.AdjoiningCave2;
				shootButtons[1].Tag = (int)signal.AdjoiningCave2;
				shootButtons[2].Text = "Shoot into " + signal.AdjoiningCave3;
				shootButtons[2].Tag = (int)signal.AdjoiningCave3;
				shootButtons.ForEach(b => b.Visible = true);

			}
			else if (carrier.Protocol.DeclTypeName == "HW_GameState")
			{
				if (signal.PlayerEatenByWumpus || signal.PlayerFellIntoPit || signal.PlayerShotSelf)
				{
					moveButtons.ForEach(b => b.Visible = false);
					shootButtons.ForEach(b => b.Visible = false);
					lblPlayerIsDead.Visible = true;
				}
				else if (signal.SuperBatSnatch)
				{
					// Move to some random cave:
					CreateCarrier("HW_MoveTo", (outSignal) => outSignal.NewCaveNumber = rnd.Next(20));
				}
				else if (signal.WumpusIsDead)
				{
					moveButtons.ForEach(b => b.Visible = false);
					shootButtons.ForEach(b => b.Visible = false);
					lblPlayerWins.Visible = true;
				}
			}
		}
Esempio n. 58
0
		/// <summary>
		/// Creates a carrier instructing the persistor to create a new entry.  Note that we also
		/// add the EventName to the field set.
		/// </summary>
		protected void InsertRecord(ICarrier rowCarrier)
		{
			// We also need the event name on an insert.
			rowCarrier.Signal.EventName = EventName;
			ISemanticTypeStruct protocol = rsys.SemanticTypeSystem.GetSemanticTypeStruct("DatabaseRecord");
			dynamic signal = rsys.SemanticTypeSystem.Create("DatabaseRecord");
			signal.TableName = "LastEventDateTime";
			signal.Row = rowCarrier;
			signal.Action = "insert";
			rsys.CreateCarrier(receptor, protocol, signal);
		}
Esempio n. 59
0
		// Process a carrier that we want to persist.
		public override void ProcessCarrier(ICarrier carrier)
		{
			base.ProcessCarrier(carrier);

			// TODO: This is a major kludge.  What we need to do is change Action to a Func, returning true of the base handler processed the carrier.
			if (carrier.Protocol.DeclTypeName == "Query")
			{
				return;
			}

			string st = carrier.Protocol.DeclTypeName;

			// Get the STS for the carrier's protocol:
			ISemanticTypeStruct sts = rsys.SemanticTypeSystem.GetSemanticTypeStruct(st);
			Dictionary<ISemanticTypeStruct, List<FKValue>> stfkMap = new Dictionary<ISemanticTypeStruct, List<FKValue>>();

			try
			{
				ProcessSTS(stfkMap, sts, carrier.Signal);
			}
			catch (Exception ex)
			{
				EmitException(ex);
			}
		}