Beispiel #1
0
		public bool CleanupWordUpCalendar ()
			{
			WPMediaGoogleCalendarUpdate.DoUpdate WordUpStaffGoogleUpdate = new DoUpdate();
			WordUpStaffGoogleUpdate.CalendarTitle = "word up!23 Staff";
			if (WordUpStaffGoogleUpdate.ErrorsOccured)
				return false;
			Dictionary<String, Dictionary<String, String>> WordUpStaffGoogleExistingIDs
					= WordUpStaffGoogleUpdate.LoadUsedGoogleIDsInSpecificCalendar();
			Dictionary<String, Dictionary<String, String>> WordUpStaffNonExistingTermineIDs
					= SelectWordUpNonExistingWPMediaIDs(WordUpStaffGoogleExistingIDs, 0);
			foreach (String EventID in WordUpStaffNonExistingTermineIDs.Keys)
				{
				WordUpStaffGoogleUpdate.DeleteCalendarEntry(EventID);
				}


			WPMediaGoogleCalendarUpdate.DoUpdate WordUpCommonGoogleUpdate = new DoUpdate();
			WordUpCommonGoogleUpdate.CalendarTitle = "word up!23 - Öffentliche Termine";
			if (WordUpStaffGoogleUpdate.ErrorsOccured)
				return false;
			Dictionary<String, Dictionary<String, String>> WordUpCommonGoogleExistingIDs
					= WordUpCommonGoogleUpdate.LoadUsedGoogleIDsInSpecificCalendar();
			Dictionary<String, Dictionary<String, String>> WordUpCommonNonExistingTermineIDs
					= SelectWordUpNonExistingWPMediaIDs(WordUpCommonGoogleExistingIDs, 1);
			foreach (String EventID in WordUpCommonNonExistingTermineIDs.Keys)
				{
				WordUpCommonGoogleUpdate.DeleteCalendarEntry(EventID);
				}
			return true;
			}
Beispiel #2
0
		public Dictionary<String, String> RunPublishWordUpCalendar(String CalendarTitle, String LastUpdate, 
			List<String> TerminTypeIDsToProcess, int GoogleIDIndex)
			{
			int UpdateCounter = 0;
			DataTable KalenderTable = CreateKalendarTable ();
			String TypeIDSelectClause = WordUp23.Basics.Instance.GetTypSelectPart (TerminTypeIDsToProcess);
			String SelectStatement = "Select * from Termine where " + TypeIDSelectClause + "Order by LastUpdateToken desc";
			if (WMB.Basics.IsTestRun)
				WMB.Basics.ReportInformationToEventViewer ("PublishAltErlaaInfo.RunPublishAltErlaaInfo",
										"Before Select Statement \"" + SelectStatement + "\"");

			DataSet ToProcessCalendarDataSet =
				WordUpWCFAccess.GetCommonDataSet (SelectStatement);

			if (ToProcessCalendarDataSet.Tables ["Termine"].Rows.Count == 0)
				{
				if (WMB.Basics.IsTestRun)
					WMB.Basics.ReportInformationToEventViewer ("PublishAltErlaaInfo.RunPublishAltErlaaInfo",
						"Number of Termine-Entries to Process = 0");
				return new Dictionary<String, String> ();
				}
			if (WMB.Basics.IsTestRun)
				WMB.Basics.ReportInformationToEventViewer ("PublishAltErlaaInfo.RunPublishAltErlaaInfo",
					"Number of Termine-Entries to Process = "
						+ Convert.ToString (ToProcessCalendarDataSet.Tables ["Termine"].Rows.Count));

			List<System.Guid> ListOfTerminTypenWithTypOrtNaming = WordUp23.Basics.Instance.GetTerminTypenWithTypOrtNaming ();
	
			WPMediaGoogleCalendarUpdate.DoUpdate GoogleUpdate = new DoUpdate ();
			GoogleUpdate.CalendarTitle = CalendarTitle;
			GoogleUpdate.MissingGoogleEventIDs.Clear ();

			bool AllRunsCorrect = true;
			int CountHasGoogleIDAndIsProcessedBefore = 0;

			foreach (DataRow IwTRow in ToProcessCalendarDataSet.Tables ["Termine"].Rows)
				{
				String EventEntryElementID = String.Empty;
				try
					{
					if (IwTRow ["ID"] == Convert.DBNull)
						{
						continue;
						}

					if ((IwTRow ["Von"] == Convert.DBNull)
						|| (IwTRow ["Bis"] == Convert.DBNull))
						continue;
		
					EventEntryElementID = IwTRow ["ID"].ToString ();
					String [] GoogleEventID = IwTRow ["GoogleEventID"].ToString ().Split (';');
					if (GoogleEventID.Length == 0)
						GoogleEventID = new String[] {"", ""};

					if (GoogleEventID.Length == 1)
						GoogleEventID = new String [] { GoogleEventID [0], "" };

					if (!String.IsNullOrEmpty (GoogleEventID [GoogleIDIndex]))
						CountHasGoogleIDAndIsProcessedBefore++;
					if (CountHasGoogleIDAndIsProcessedBefore > 20)
						break;

					EventEntry EventEntryElement = GoogleUpdate.GetEventEntry (EventEntryElementID, GoogleEventID [GoogleIDIndex]);
					if (EventEntryElement == null)
						{
						WMB.Basics.ReportErrorToEventViewer ("Beim Eintrag \"" + EventEntryElementID
							+ "\" mit der GoogleIDEventID \"" + GoogleEventID + "\"\r\n" + "kam es zu einem Fehler");
						continue;
						}
					if (EventEntryElement.EventId != GoogleEventID [GoogleIDIndex])		// do BackLink activities
						{
						GoogleEventID [GoogleIDIndex] = EventEntryElement.EventId;
						String ModifyStatement = "Update Termine set GoogleEventID = '"
												 + String.Join (";", GoogleEventID) + "' where ID = '" + EventEntryElementID + "'";
						WordUpWCFAccess.RunSQLBatch (ModifyStatement);
						}
					EventEntryElement.Dirty = true;
					String OrteID = IwTRow ["OrteID"].ToString ();
					String Ortsbezeichnung = "Nicht definiert";
					if (String.IsNullOrEmpty (OrteID) == false)
						Ortsbezeichnung = WordUp23.Basics.Instance.Orte [OrteID] ["Bezeichnung"].ToString ()
							+ " " + WordUp23.Basics.Instance.Orte [OrteID] ["Beschreibung"].ToString ();
					if (ListOfTerminTypenWithTypOrtNaming.Contains ((System.Guid) IwTRow ["TermineTypID"]) == true)
						{
						EventEntryElement.Title.Text = WordUp23.Basics.Instance.GetTypeBeschreibung (IwTRow) + "-" + Ortsbezeichnung;
						}
					else
						{
						//if (String.IsNullOrEmpty (IwTRow ["NameID"].ToString ()) == false)
						//    EventEntryElement.Title.Text = IwTRow ["NameID"].ToString ();
						//else
							EventEntryElement.Title.Text = WordUp23.Basics.Instance.GetTypeBeschreibung (IwTRow) + "-" + Ortsbezeichnung;
						}

					if (IwTRow ["TermineTypID"].ToString () == "f61d9cb1-59a4-430b-ad67-ebdcc5df1d11")
						{
						EventEntryElement.IsDraft = true;
						}


					When EntryTiming;
					if (EventEntryElement.Times.Count > 0)
						{
						EntryTiming = EventEntryElement.Times [0];
						EntryTiming.StartTime = Convert.ToDateTime (IwTRow ["Von"]);
						EntryTiming.EndTime = Convert.ToDateTime (IwTRow ["Bis"]);
						}
					else
						{
						EntryTiming = new When (Convert.ToDateTime (IwTRow ["Von"]), Convert.ToDateTime (IwTRow ["Bis"]));
						EventEntryElement.Times.Add (EntryTiming);
						}

					Where EntryLocation;
					if (EventEntryElement.Locations.Count > 0)
						EntryLocation = EventEntryElement.Locations [0];
					else
						{
						EntryLocation = new Where ();
						EventEntryElement.Locations.Add (EntryLocation);
						}

					String TerminBeschreibung = FillTerminBeschreibung (IwTRow);
					String OrtsBeschreibung = FillLocation (IwTRow, EntryLocation);
					String PersonenBeschreibung = WordUp23.Basics.Instance.GetTypeParticipantText (IwTRow);

// da passiert es
					Google.GData.Extensions.ExtensionCollection<Who> Participants = new Google.GData.Extensions.ExtensionCollection<Who>();
//					PersonenBeschreibung = FillPersonen(IwTRow, EventEntryElement.Participants);
					PersonenBeschreibung = FillPersonen(IwTRow, Participants);

// da ist es passiert		
					String OrganisationsBeschreibung = FillOrganisationsBeschreibung (IwTRow);

					EventEntryElement.Content.Content = TerminBeschreibung + OrtsBeschreibung
						+ OrganisationsBeschreibung + PersonenBeschreibung;

					if (GoogleUpdate.SaveEventEntry (EventEntryElement, EventEntryElementID) == false)
						{
						WMB.Basics.ReportErrorToEventViewer ("GoogleCalendarUpdate.RunPublishAltErlaaInfo",
						                                     "Beim \"" + CalendarTitle + "\" Eintrag \"" + EventEntryElementID +
						                                     "\" ist ein Fehler aufgetreten\r\n"
						                                     + EntryTiming.StartTime.ToString () + " - " + EntryTiming.EndTime.ToString ());
						GoogleEventID[GoogleIDIndex] = "";
						String ModifyStatement = "Update Termine set GoogleEventID = '"
												 + String.Join(";", GoogleEventID) + "' where ID = '" + EventEntryElementID + "'";
						WordUpWCFAccess.RunSQLBatch(ModifyStatement);
						}
					//else
					//	{
					//	WMB.Basics.ReportInformationToEventViewer("GoogleCalendarUpdate.RunPublishAltErlaaInfo",
					//		"Beim \"" + CalendarTitle + "\" Eintrag \"" + EventEntryElementID + "\" ist alles OK\r\n"
					//		+ EntryTiming.StartTime.ToString() + " - " + EntryTiming.EndTime.ToString());
					//	}
					continue;
					}

				catch (Exception Excp)
					{
					WMB.Basics.ReportErrorToEventViewer ("GoogleCalendarUpdate.RunPublishAltErlaaInfo",
						"Beim Eintrag \"" + EventEntryElementID + "\" ist folgender Fehler aufgetreten:\r\n"
						+ Excp.ToString());
					AllRunsCorrect = false;
					
					}
				}

			if ((AllRunsCorrect == true)
				&& (CloseRequestedCall != null))
				{
				CloseRequestedCall (this, "SaveNextStartDataTime");
				}
			return GoogleUpdate.MissingGoogleEventIDs;
			}
Beispiel #3
0
		//public bool DeleteGoogleCalendarItem (SymbolicCalendar SymbolicCalendarName, String GoogleID)
		//	{
		//	WPMediaGoogleCalendarUpdate.DoUpdate GoogleUpdate = new DoUpdate();
		//	switch (SymbolicCalendarName)
		//		{
		//		case SymbolicCalendar.AltErlaaInfo:
		//			GoogleUpdate.CalendarTitle = "Termine in Alt Erlaa";
		//			break;
		//		case SymbolicCalendar.WordUpPublic:
		//			GoogleUpdate.CalendarTitle = "word up!23 - Öffentliche Termine";
		//			break;
		//		case SymbolicCalendar.WordUpStaff:
		//			GoogleUpdate.CalendarTitle = "word up!23 Staff";
		//			break;
		//		}
		//	GoogleUpdate.DeleteCalendarEntry (GoogleID);
		//	return true;
		//	}


		public bool CleanupWPMediaCalendar ()
			{
			WPMediaGoogleCalendarUpdate.DoUpdate AltErlaaGoogleUpdate = new DoUpdate ();
			AltErlaaGoogleUpdate.CalendarTitle = "Termine in Alt Erlaa";

			if (AltErlaaGoogleUpdate.ErrorsOccured)
				return false;
			Dictionary<String, Dictionary<String, String>> WPMediaExistingGoogleIDs = AltErlaaGoogleUpdate.LoadUsedGoogleIDsInSpecificCalendar();
			Dictionary<String, Dictionary<String, String>> WPMediaNonExistingWPMediaIDs = SelectWPMediaNonExistingWPMediaIDs(WPMediaExistingGoogleIDs);
			foreach (String EventID in WPMediaNonExistingWPMediaIDs.Keys)
				{
				AltErlaaGoogleUpdate.DeleteCalendarEntry (EventID);
				}
			return true;
			}
Beispiel #4
0
		public Dictionary<String,String>  RunPublishAltErlaaInfo (String SelectStatement)
			{
			if (WMB.Basics.IsTestRun)
				WMB.Basics.ReportInformationToEventViewer ("PublishAltErlaaInfo.RunPublishAltErlaaInfo",
				                                           "Before Select Statement \"" + SelectStatement + "\"");

			DataSet ToProcessCalendarDataSet =
				AltErlaaInfoWCFAccess.GetCommonDataSet (SelectStatement);

	
			if (ToProcessCalendarDataSet.Tables ["InformationenWithTimings"].Rows.Count == 0)
				{
				if (WMB.Basics.IsTestRun)
					WMB.Basics.ReportInformationToEventViewer ("PublishAltErlaaInfo.RunPublishAltErlaaInfo",
					                    "\"" + SelectStatement + "\"\r\nNumber of Entries to Process = 0");
				}
			else
				{
				if (WMB.Basics.IsTestRun)
					WMB.Basics.ReportInformationToEventViewer ("PublishAltErlaaInfo.RunPublishAltErlaaInfo",
					            "\"" + SelectStatement + "\"\r\nNumber of Entries to Process = " +
					            Convert.ToString (ToProcessCalendarDataSet.Tables ["InformationenWithTimings"].Rows.Count));
				}
			DataTable KalenderTable = CreateKalendarTable ();


			WPMediaGoogleCalendarUpdate.DoUpdate GoogleUpdate = new DoUpdate ();
			GoogleUpdate.CalendarTitle = "Termine in Alt Erlaa";
			if (GoogleUpdate.ErrorsOccured == false)
				return null;
			GoogleUpdate.MissingGoogleEventIDs.Clear();
			bool AllRunsCorrect = true;
			int CountHasGoogleIDAndIsProcessedBefore = 0;

			foreach (DataRow IwTRow in ToProcessCalendarDataSet.Tables ["InformationenWithTimings"].Rows)
				{
				System.Guid InformationenID = System.Guid.Empty;
				try
					{
					DataRow KalenderRowToImport = KalenderTable.NewRow ();
					if (IwTRow ["ID"] == Convert.DBNull)
						{
						continue;
						}
					InformationenID = (System.Guid) IwTRow ["ID"];
					if (IwTRow ["TimingsID"] == Convert.DBNull)
						{
						continue;
						}
					System.Guid TimingsID = (System.Guid) IwTRow ["TimingsID"];
					KalenderRowToImport ["ID"] = TimingsID;
					DateTime Von = Convert.ToDateTime (IwTRow ["TimeA"]);
					DateTime Bis = Convert.ToDateTime (IwTRow ["TimeB"]);
					if (Bis < Von)
						{
						WMB.Basics.ReportErrorToEventViewer ("GoogleCalendarUpdate.RunPublishAltErlaaInfo",
							"Beim Eintrag \"" + InformationenID.ToString () + "\" (\""
							+ IwTRow ["Titel"].ToString () + "\" ist das Von Datum kleiner als das Bis Datum");
						continue;
						}
					KalenderRowToImport ["Von"] = IwTRow ["TimeA"];
					KalenderRowToImport ["Bis"] = IwTRow ["TimeB"];
					KalenderRowToImport ["GoogleEventID"] = IwTRow ["GoogleEventID"];
					String GoogleEventID = IwTRow ["GoogleEventID"].ToString ();

					if (!String.IsNullOrEmpty (GoogleEventID))
						CountHasGoogleIDAndIsProcessedBefore++;
					if (CountHasGoogleIDAndIsProcessedBefore > 25)
						break;
					
					EventEntry EventEntryElement = GoogleUpdate.GetEventEntry (TimingsID.ToString( ), GoogleEventID);
					if (EventEntryElement == null)
						{
						WMB.Basics.ReportErrorToEventViewer ("PublishAltErlaaInfo.RunPublishWordUpCalendar",
							"Beim Eintrag \"" + TimingsID.ToString () + "\" mit der GoogleIDEventID \"" + GoogleEventID + "\"\r\n"
							+ "kam es zu einem Fehler");
						continue;
						}
					if (EventEntryElement.EventId != GoogleEventID)		// do BackLink activities
						{

						String ModifyStatement = "Update Timings set GoogleEventID = '"
												 + EventEntryElement.EventId + "' where TimingsID = '" + TimingsID.ToString () + "'";
						AltErlaaInfoWCFAccess.RunSQLBatch (ModifyStatement);
						}
					EventEntryElement.Dirty = true;



					DataSet EntryData = DataModell.GetEntryDataSet
						(InformationenID, new String [] {"EreignisMultiMedia", "EreignisMaterial" }, null);

					foreach (DataRow InfoAddOn in EntryData.Tables ["InformationenAddOn"].Rows)
						{
						if (InfoAddOn ["ActuallBezeichner"].ToString () == "Kontaktperson")
							{
							if ((InfoAddOn ["TabelleID"] != Convert.DBNull)
							    && (((System.Guid) InfoAddOn ["TabelleID"]) != System.Guid.Empty))
								KalenderRowToImport ["KontaktPerson"] = DataModell.GetTableClass 
									(InfoAddOn ["Tabelle"].ToString (), (System.Guid) InfoAddOn ["TabelleID"])
										.GetFreitext (FreiTextFormat.Small);
							else
								KalenderRowToImport ["KontaktPerson"] = InfoAddOn ["FreiText"].ToString ();
							}
						if (InfoAddOn ["ActuallBezeichner"].ToString () == "Veranstalter")
							{
							if ((InfoAddOn ["TabelleID"] != Convert.DBNull)
							    && (((System.Guid) InfoAddOn ["TabelleID"]) != System.Guid.Empty))
								KalenderRowToImport["Veranstalter"] = DataModell.GetTableClass
									(InfoAddOn["Tabelle"].ToString(), (System.Guid)InfoAddOn["TabelleID"])
										.GetFreitext(FreiTextFormat.Small);
							else
								KalenderRowToImport ["Veranstalter"] = InfoAddOn ["FreiText"].ToString ();
							}
						if (InfoAddOn ["ActuallBezeichner"].ToString () == "VeranstaltungsOrt")
							{
							if ((InfoAddOn ["TabelleID"] != Convert.DBNull)
							    && (((System.Guid) InfoAddOn ["TabelleID"]) != System.Guid.Empty))
								KalenderRowToImport["VeranstaltungsOrt"] = DataModell.GetTableClass
									(InfoAddOn["Tabelle"].ToString(), (System.Guid)InfoAddOn["TabelleID"])
										.GetFreitext(FreiTextFormat.Small);
							else
								KalenderRowToImport ["VeranstaltungsOrt"] = InfoAddOn ["FreiText"].ToString ();
							}
						}


					KalenderRowToImport["Titel"] = DataModell.GetTitleFromEntryDataSet(EntryData);
					KalenderRowToImport["Typ"] = DataModell.GetTypFromEntryDataSet(EntryData);
					KalenderRowToImport ["ZielGruppe"] =
						DataModell.GetZielGruppenFromEntryDataSet(EntryData);

					KalenderRowToImport["FullInfo"] = DataModell.GetFullUtilityDataView(EntryData);

					FillKalenderEntry (EventEntryElement, KalenderRowToImport);
					if (GoogleUpdate.SaveEventEntry (EventEntryElement, TimingsID.ToString ()) == true)
						{
						KalenderTable.Rows.Add (KalenderRowToImport);
						}
					else
						{
						WMB.Basics.ReportErrorToEventViewer ("GoogleCalendarUpdate.RunPublishAltErlaaInfo",
								"Beim Timings Eintrag \"" + TimingsID.ToString () + "\" ist ein Fehler aufgetreten");
						
						}

					}

				catch (Exception Excp)
					{
					WMB.Basics.ReportErrorToEventViewer ("GoogleCalendarUpdate.RunPublishAltErlaaInfo",
						"Beim Eintrag \"" + InformationenID.ToString( ) + "\" ist folgender Fehler aufgetreten:\r\n"
						+ Excp.ToString());
					AllRunsCorrect = false;
					}
				}

			if ((AllRunsCorrect == true)
				&& (CloseRequestedCall != null))
				{
				CloseRequestedCall (this, "SaveNextStartDataTime");
				}
			return GoogleUpdate.MissingGoogleEventIDs;
			}