示例#1
0
	private void ImportMessage (WienerLinienDataModell NewDataModell, JProperty Start)
		{
		foreach (JObject MessageToken in Start.Children())
			{
			foreach (JProperty MessageChildProp in MessageToken.Properties())
				{
				if (MessageChildProp.Name == "value")
					{
					MessageType Output;
					if (Enum.TryParse(MessageChildProp.Value.ToString(), true, out Output))
						NewDataModell.MessType = Output;
					else
						NewDataModell.MessType = MessageType.Error;
					continue;
					}
				if (MessageChildProp.Name == "messageCode")
					{
					NewDataModell.MessageCode = MessageChildProp.Value.ToObject<Int32>();
					continue;
					}
				if (MessageChildProp.Name == "serverTime")
					{
					NewDataModell.ServerTime = MessageChildProp.Value.ToObject<DateTime>();
					continue;
					}
				}
			}
		}
示例#2
0
	private LocationStop ImportLocationStop(WienerLinienDataModell NewDataModell, JProperty Start)
		{
		LocationStop ActuallLocationStop = new LocationStop();
		ActuallLocationStop.Parent = NewDataModell;
		NewDataModell.LocationStops.Add(ActuallLocationStop);
		foreach (JProperty LocProp in Start.Values())
			{
			if (LocProp.Name == "type")
				{
				LocationType Output;
				if (Enum.TryParse(LocProp.Value.ToString(), true, out Output))
					ActuallLocationStop.LocType = Output;
				else
					ActuallLocationStop.LocType = LocationType.Error;
				continue;
				}
			if (LocProp.Name == "geometry")
				{
				foreach (JProperty geoProp in LocProp.Values())
					{
					if (geoProp.Name == "type")
						{
						GeometryType Output;
						if (Enum.TryParse(geoProp.Value.ToString(), true, out Output))
							ActuallLocationStop.GeoType = Output;
						else
							ActuallLocationStop.GeoType = GeometryType.Error;
						continue;
						}
					if (geoProp.Name == "coordinates")
						{
						ActuallLocationStop.GeoLon = geoProp.Value.ToArray()[0].ToObject<double>();
						ActuallLocationStop.GeoLat = geoProp.Value.ToArray()[1].ToObject<double>();
						}
					}
				}
			if (LocProp.Name == "properties")
				{
				foreach (JProperty propProp in LocProp.Values())
					{
					if (propProp.Name == "name")
						{
						ActuallLocationStop.Name = propProp.Value.ToString();
						continue;
						}
					if (propProp.Name == "title")
						{
						ActuallLocationStop.Title = propProp.Value.ToString();
						continue;
						}
					if (propProp.Name == "municipality")
						{
						ActuallLocationStop.Ort = propProp.Value.ToString();
						continue;
						}
					if (propProp.Name == "municipalityId")
						{
						ActuallLocationStop.OrtID = propProp.Value.ToObject<Int32>();
						continue;
						}
					if (propProp.Name == "type")
						{
						StopType Output;
						if (Enum.TryParse(propProp.Value.ToString(), true, out Output))
							ActuallLocationStop.StopType = Output;
						else
							ActuallLocationStop.StopType = StopType.Error;
						continue;
						}
					if (propProp.Name == "coordName")
						{
						CoordType Output;
						if (Enum.TryParse(propProp.Value.ToString(), true, out Output))
							ActuallLocationStop.CoType = Output;
						else
							ActuallLocationStop.CoType = CoordType.Error;
						continue;
						}
					if (propProp.Name == "gate")
						{
						ActuallLocationStop.Gate = propProp.Value.ToString();
						continue;
						}
					if (propProp.Name == "attributes")
						{
						foreach (JProperty attrPropProp in propProp.Values())
							{
							ActuallLocationStop.Attributes[attrPropProp.Name] =
											attrPropProp.Value.ToString();
							}
						continue;
						}

					}
				}
			}
		return ActuallLocationStop;
		}
示例#3
0
	private void ImportData (WienerLinienDataModell NewDataModell, JProperty Start)
		{
		foreach (JObject MonitorsChild in Start.Children())	//monitors
			{
			foreach (JProperty MonitorsChildProp in MonitorsChild.Properties())
				{
				String PropMonitorName = MonitorsChildProp.Name;
				if (PropMonitorName == "monitors")
					{
					foreach (JObject Entry in MonitorsChildProp.Values())
						{
						LocationStop ActuallLocationStop = null;
						foreach (JProperty PropEntry in Entry.Properties())
							{
							if (PropEntry.Name == "locationStop")
								{
								ActuallLocationStop = ImportLocationStop(NewDataModell, PropEntry);
								continue;
								}
							if (PropEntry.Name == "lines")
								{
								ImportLines(ActuallLocationStop, PropEntry);
								continue;
								}
							}
						}
					}
				}
			}
		}
示例#4
0
	//void LoadFromServerTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
	//	{
	//	System.Timers.Timer RunningTimer = sender as System.Timers.Timer;
	//	RunningTimer.Enabled = false;
	//	LoadFromServer(this);
	//	RunningTimer.Enabled = true;
	//	}

	private void LoadFromServer(Object ReaderObject)
		{
		int ActiveTreadID = Thread.CurrentThread.ManagedThreadId;
		if (++RefreshToCheckCounter > 10)
			{
			if (WienerLinienVerwaltungDataModell.LoadFromSaveStore(true) != null)
				VerwaltungsDatenModellShouldReloaded = true;
			RefreshToCheckCounter = 0;
			}

		WebRequest Anfrage = WebRequest.Create(String.Format(HttpTemplate, SacProduktionsToken));
		WebResponse Antwort = null;
		try
			{
			Antwort = Anfrage.GetResponse();
			}
		catch (Exception Excp)
			{
			ReportToEventLog($"Der Request für den Server {Anfrage.RequestUri.Host}" +
								$"- \"{Anfrage.RequestUri.PathAndQuery} \"\r\nwar fehlerhaft warf die Exception\r\n" +
								$"\"{Excp}\"");
            return;
			}


		System.IO.Stream AntwortStream = Antwort.GetResponseStream();
		StreamReader AntwortReader = new StreamReader(AntwortStream);
			//		String TestInput = AntwortReader.ReadToEnd ();
		JSonData = Newtonsoft.Json.Linq.JObject.Parse(AntwortReader.ReadToEnd());
		if (JSonData == null)
				{
				ReportToEventLog($"Der Request für den Server {Anfrage.RequestUri.Host}" +
									$"- \"{Anfrage.RequestUri.PathAndQuery}\"" +
								$"\r\nbrachte kein JSON Ergebnis");
				return;
				}

			if (PresentReaderContent)
			{
			if (PresentReaderContentCall != null)
				PresentReaderContentCall(this, Anfrage.RequestUri.AbsoluteUri
					.Replace("&", "\r\n&") + "\r\n\r\n" + JSonData.ToString());
			PresentReaderContent = false;
			}

		WienerLinienDataModell NewDataModell = new WienerLinienDataModell();

		foreach (JProperty Prop in JSonData.Properties())
			{
			if (Prop.Name == "data")
				{
				ImportData(NewDataModell, Prop);
				}
			if (Prop.Name == "message")
				{
				ImportMessage(NewDataModell, Prop);
				continue;
				}
			}

		if (VerwaltungsDatenModell == null)
			{
			return;
			}
		NewDataModell.CreateConfigurationEnvironment(VerwaltungsDatenModell);
		String CreatedFileName = NewDataModell.SaveToSaveStore();
		if (ReportAboutSynchronizingCall != null)
			{
			ReportAboutSynchronizingCall(this, CreatedFileName, NewDataModell.ServerTime, DateTime.Now,
										  NewDataModell.CorrectionSecondsBetweenLocalMachineAndServer);
			}

		}
示例#5
0
		static String SaveToSaveStore(String FileName, WienerLinienDataModell MappingData)
			{
			FileName = Basics.ConvertToCorrectFileNameElement(FileName);
			if (File.Exists(SaveStoreDirectoryName + "\\" + FileName + ".ser"))
				{
				SecureFileDelete(SaveStoreDirectoryName + "\\" + FileName + ".ser");
				}
			MappingData.CorrectionSecondsBetweenServerAndCentralMachineTime
				= (DateTime.Now - MappingData.ServerTime).TotalSeconds;
			Basics.SerializeObjectToFile(SaveStoreDirectoryName + "\\" + FileName + ".ser", MappingData);
			return FileName;
			}
	    private void WienerLinienDataModellInstanceChanged(WienerLinienDataModell OldValue,
		    WienerLinienDataModell NewValue)
		    {
		    }