Ejemplo n.º 1
0
		public Form1 ()
			{
			if (WMB.Basics.IAmActiveBefore ())
				{
				Close ();
				return;
				}
			InitializeComponent ();
			m_DataBaseSynchronizer = new BackgroundWorker ();
			m_DataBaseSynchronizer.DoWork += new DoWorkEventHandler (m_DataBaseSynchronizer_DoWork);
			m_DataBaseSynchronizer.RunWorkerCompleted += new RunWorkerCompletedEventHandler (m_DataBaseSynchronizer_RunWorkerCompleted);

			m_Rollen = CVM.LoginHandler.CheckUser ("Heinz", "monika");
			//WMB.Basics.ReportInformationToEventViewer ("MBRWahl.Constructor", "MBRWahl Started");
			m_CVM = new MBRWahl.CommonValues ();
			m_CVM.CloseRequestedCall += new MBRWahl.CloseRequestedEvent (CloseRequestedCall_Fired);
			m_CVM.StatusMessageCall += new MBRWahl.StatusMessageEvent (StatusMessageCall_Fired);
			m_DataBase = new WCFStandardsNS.WCFStandards (); 
			m_DataBase.DefaultConnectionStringName = Settings.Default.WebConnectionStringName;
			//m_DataBase.UserName = "******";
			//m_DataBase.PassWord = "******";
			m_CVM.m_DataBase = m_DataBase;

			m_LocalDataBase = new WCFStandardsNS.WCFStandards (); 
			m_LocalDataBase.DefaultConnectionStringName = Settings.Default.LocalConnectionStringName;
			//m_LocalDataBase.UserName = "******";
			//m_LocalDataBase.PassWord = "******";
			m_CVM.m_LocalDataBase = m_LocalDataBase;

			if (!m_CVM.TestDataBase (false))
				{
				MessageBox.Show ("Lokales WebService (\"" + m_LocalDataBase.DefaultConnectionStringName
						+ "\") ist bei der Initialisierung nicht erreichbar. "
					+ MBRWahl.MBRStatics.ASSISTANCE_FROM_WPMEDIA);
				Close ();
				}

			m_CVM.WebDataRoot = null;

			MBRWahlControlUserControl.HideTheApplicationEventCall += new MBRWahlControlUserControl.HideTheApplicationEvent
							(MBRWahlControlUserControl_HideTheApplicationEventCall);
			MBRWahlControlUserControl.CloseTheApplicationEventCall += new MBRWahlControlUserControl.CloseTheApplicationEvent
							(MBRWahlControlUserControl_CloseTheApplicationEventCall);
			MBRWahlControlUserControl.CreateAbstimmListeEventCall += new MBRWahlControlUserControl.CreateAbstimmListeEvent
							(MBRWahlControlUserControl_CreateAbstimmListeEventCall);
			MBRWahlControlUserControl.CreateBackupRuntimeEventCall += new MBRWahlControlUserControl.CreateBackupRuntimeEvent
							(MBRWahlControlUserControl_CreateBackupRuntimeEventCall);
			MBRWahlControlUserControl.RefreshStatusEventCall += new MBRWahlControlUserControl.RefreshStatusEvent
							(MBRWahlControlUserControl_RefreshStatusEventCall);
			MBRWahlControlUserControl.RunDataBaseCheckUpCall += new MBRWahl.RunDataBaseCheckUpEvent
							(MBRWahlControlUserControl_RunDataBaseCheckUpCall);
			m_AvailableForeignMachines = new StringCollection ();

			DataSet ConfigDataSet = m_LocalDataBase.GetCommonDataSet ("select * from Verwaltung where Maschine = '"
					+ WMB.Basics.GetComputerName ().ToUpper() + "' and WahlID = '" + WahlID + "'");
			if (ConfigDataSet == null)
				{
				MessageBox.Show ("Die lokale Wahl-Datenbank oder das lokale WebServive ist für Sie nicht erreichbar. "
					+ "\r\nConnectionStringName = \""
				+ m_LocalDataBase.DefaultConnectionStringName + "\"\r\nEndPointName = \"" + m_LocalDataBase.ToString() + "\". "
				+ MBRWahl.MBRStatics.ASSISTANCE_FROM_WPMEDIA);
				Close ();
				return;
				}
			if (ConfigDataSet.Tables ["Verwaltung"].Rows.Count == 0)
				{
				MessageBox.Show ("Ihre Maschine \""
					+ System.Windows.Forms.SystemInformation.ComputerName
					+ "\" ist derzeit nicht für die MBR Wahl zugelassen. "
				+ "Bitte warten Sie die Aktualisierung der Daten ab (einige Minuten!!), "
				+ "danach wird neuerlich geprüft");
				}

			m_CVM.SetConfigData (ConfigDataSet.Tables ["Verwaltung"], null);
			m_CVM.IsTestRun = true;
			m_FirstTimeDoDataBaseCheckUp = true;
			if (m_CVM.TestDataBase (true) == true)
				{
//				m_Rollen = m_DataBase.CheckUser (ref m_UserName);
				bool AccessIsNotAllowed = true;
				foreach (String Rolle in m_Rollen)
					{
					if (Rolle == "MBRWahl")
						AccessIsNotAllowed = false;
					if (Rolle == "MBRWahlLeiter")
						AccessIsNotAllowed = false;
					}
				if (AccessIsNotAllowed == true)
					{
					MessageBox.Show ("User / PWD ist nicht für die Mieterbeiratswahl zugelassen");

					Close ();
					return;
					}
				}
			else
				{
				//MessageBox.Show ("Das Netz zu Ihrer Maschine ist nicht aktiv,\r\n"
				//                + "Sie arbeiten offline. "
				//                + "Daher gelten die\r\nentsprechenden Einschränkungen "
				//                + "(= nur Wähler des eigenen\r\nBlockes können Ihre Stimme abgeben).");
				m_CVM.Notbetrieb = true;
				}
			if (m_CVM.Notbetrieb == false)
				{
				m_CVM.DoProcessingCommand ();
				DoDataBaseCheckUp (false, true);
				}
			MBRWahlControlUserControl.m_DataBase = m_DataBase;
			MBRWahlControlUserControl.SetData (m_CVM);
			}
Ejemplo n.º 2
0
		private void CorrectStructuredMaterialDataBase ()
			{
			WCFStandardsNS.WCFStandards DataBase = new WCFStandardsNS.WCFStandards ();
			DataSet MaterialTypenDataSet = DataBase.GetCommonDataSet ("Select TechnicalTyp from MaterialType");
			DataTable MaterialTable = MaterialTypenDataSet.Tables ["MaterialType"];
			DataSet FileIDsDataSet = DataBase.GetCommonDataSet ("Select Distinct FileID from "
						+ "StructuredMaterialDataBase");
			foreach (DataRow FileIDRow in FileIDsDataSet.Tables ["StructuredMaterialDataBase"].Rows)

				{
				DataSet EntriesForOneFileID = DataBase.GetCommonDataSet
					(String.Format ("Select * from StructuredMaterialDataBase where FileID = '{0}' order by FoldedArchivePath",
							FileIDRow ["FileID"].ToString ()));
				bool ErrorFound = false;
				List<String> FoldedNames = new List<string> ();
				List<String> FoundIDs = new List<string> ();
				foreach (DataRow MaterialRow in EntriesForOneFileID.Tables ["StructuredMaterialDataBase"].Rows)
					{
					String FoldedArchivePath = MaterialRow ["FoldedArchivePath"].ToString ();
					FoldedNames.Add (FoldedArchivePath);

					foreach (DataRow MaterialTypenRow in MaterialTable.Rows)
						{
						String Replacement = "_" + MaterialTypenRow [0].ToString ().ToUpper () + "_";
						if (FoldedArchivePath.IndexOf (Replacement, StringComparison.InvariantCultureIgnoreCase) != -1)
							{
							ErrorFound = true;
							String NewSearchName = FoldedArchivePath.Replace (Replacement, "");
							MaterialRow ["FoldedArchivePath"] = NewSearchName;
							}
						}
					}
				if (ErrorFound == true)
					{
					//MessageBox.Show ("Fehler bei ID\r\n" + FileIDRow ["FileID"].ToString ()
					//    + "\r\n" + String.Join ("\r\n", FoldedNames.ToArray()));
					DataBase.SetCommonDataSet (EntriesForOneFileID);
					}

				}
			}
Ejemplo n.º 3
0
		private void RemoveDuplicateStructuredMaterialDataBaseEntries ()
			{
			WCFStandardsNS.WCFStandards DataBase = new WCFStandardsNS.WCFStandards ();
			DataSet MaterialTypenDataSet = DataBase.GetCommonDataSet ("Select TechnicalTyp from MaterialType");
			DataTable MaterialTable = MaterialTypenDataSet.Tables ["MaterialType"];
			DataSet FileIDsDataSet = DataBase.GetCommonDataSet ("Select Distinct FileID from "
						+ "StructuredMaterialDataBase");
			int DeleteCounter = 0;
			int UniqueCounter = 0;
			foreach (DataRow FileIDRow in FileIDsDataSet.Tables ["StructuredMaterialDataBase"].Rows)
				{
				DataSet EntriesForOneFileID = DataBase.GetCommonDataSet
					(String.Format ("Select * from StructuredMaterialDataBase where FileID = '{0}' order by ArchiveID, "
				+ "TechnicalTyp, ModifyTimeStamp",
							FileIDRow ["FileID"].ToString ()));
				UniqueCounter++;
				String OldArchiveID = String.Empty;
				String OldTechnicalTyp = String.Empty;
				DateTime OldModifyTimeStamp = DateTime.MinValue;
				List<String> FoundIDs = new List<string> ();
				String FoldedArchivePath = String.Empty;
				foreach (DataRow MaterialRow in EntriesForOneFileID.Tables ["StructuredMaterialDataBase"].Rows)
					{
					FoldedArchivePath = MaterialRow ["FoldedArchivePath"].ToString ();
					String ArchiveID = MaterialRow ["ArchiveID"].ToString ();
					String TechnicalTyp = MaterialRow ["TechnicalTyp"].ToString ();
					DateTime ModifyTimeStamp;
					if (Convert.IsDBNull (MaterialRow ["ModifyTimeStamp"]))
						ModifyTimeStamp = DateTime.Parse ("1990-01-01 23:59:59");
					else
						ModifyTimeStamp = Convert.ToDateTime (MaterialRow ["ModifyTimeStamp"]);
					if ((OldArchiveID == ArchiveID)
						&& (OldTechnicalTyp == TechnicalTyp)
						&& (OldModifyTimeStamp == ModifyTimeStamp))
						{
						DeleteCounter++;
						FoundIDs.Add (MaterialRow ["ID"].ToString ());
						DataBase.RunSQLBatch (String.Format ("Delete StructuredMaterialDataBase where ID = '{0}'",
															 MaterialRow ["ID"].ToString ()));
						}
					else
						{
						OldArchiveID = ArchiveID;
						OldTechnicalTyp = TechnicalTyp;
						OldModifyTimeStamp = ModifyTimeStamp;
						}
						
					}
				//if (FoundIDs.Count > 0)
				//    MessageBox.Show ("Bei FoldedArchivePath \"" + FoldedArchivePath + "\"\r\n"
				//                 + String.Join("\r\n", FoundIDs.ToArray ()));

				}
			MessageBox.Show ("Insgesamt Gelöscht = " + Convert.ToString (DeleteCounter) + "\r\n"
							+ "Remainig Entries = " + Convert.ToString (UniqueCounter) + "\r\n");
							 

			}
Ejemplo n.º 4
0
		private void ProcessDataBaseCorrection ()
			{
			WCFStandardsNS.WCFStandards DataBase = new WCFStandardsNS.WCFStandards ();
			DataSet WrongVideoFiles = DataBase.GetCommonDataSet ("SELECT DISTINCT FoldedArchivePath, COUNT(*) AS Number "
																 + "FROM  VideoFiles "
																 + "GROUP BY FoldedArchivePath "
																 + "ORDER BY FoldedArchivePath");
			int NumberOfNonAssignedVideoFiles = 0;
			int NumberOfSingleAssignedVideoFiles = 0;
			int NumberOfMultipleAssignedVideoFiles = 0;
			int OverallNumberOfWrongEntries = 0;
			foreach (DataRow WrongEntry in WrongVideoFiles.Tables ["VideoFiles"].Rows)
				{
				int NumberOfWrongEntries = Convert.ToInt32 (WrongEntry ["Number"]);
				if (NumberOfWrongEntries < 2)
					continue;
				OverallNumberOfWrongEntries++;
				String WrongFoldedPath = WrongEntry ["FoldedArchivePath"].ToString ();
				DataSet VideoFilesPlusMaterial = DataBase.GetCommonMultiDataSet (new String[]
						{
						String.Format (
							"Select * from VideoFiles where FoldedArchivePath = '{0}' order by ModifyTimeStamp",
							WrongFoldedPath),
						String.Format (
							"Select * from  StructuredMaterialDataBase where FoldedArchivePath = '{0}' order by ArchiveID",
							WrongFoldedPath)
						});
				if (WCFStandardsNS.WCFStandards.GetErrorMessages(VideoFilesPlusMaterial) != null)
					{
					String[] ErrorStrings = WCFStandardsNS.WCFStandards.GetErrorMessages (VideoFilesPlusMaterial);
					}
				List<String> FoundIDs = new List<string> ();

				int NumberOfAssignedVideoFiles = 0;
				String ArchiveIDs = String.Empty;
				foreach (DataRow VideoRow in VideoFilesPlusMaterial.Tables ["VideoFiles"].Rows)
					{
					String FileID = VideoRow ["FileID"].ToString ();
					DataSet Zuordnung = DataBase.GetCommonDataSet (String.Format
						("Select * from VideoFilesZuBeitraege where FileID = '{0}'", FileID));
					String ModifyTimeStamp = VideoRow ["ModifyTimeStamp"].ToString ();
					if (Zuordnung.Tables ["VideoFilesZuBeitraege"].Rows.Count == 0)
						{
						FoundIDs.Add (FileID);
						}
					else
						{
						NumberOfAssignedVideoFiles++;
						FoundIDs.Add (FileID);
						foreach (DataRow ZuordnungRow in Zuordnung.Tables ["VideoFilesZuBeitraege"].Rows)
							{
							}
						}
					}
				foreach (DataRow MaterialRow in VideoFilesPlusMaterial.Tables ["StructuredMaterialDataBase"].Rows)
					{
					ArchiveIDs = ArchiveIDs + MaterialRow ["ArchiveID"].ToString () + " ";
					}
				if (NumberOfAssignedVideoFiles > 1)
					{
					NumberOfMultipleAssignedVideoFiles++;
					MessageBox.Show ("Bei \"" + WrongFoldedPath + "\" ist mehr als ein VideoFile Entry zugeordnet\r\n"
						+ String.Join ("\r\n", FoundIDs.ToArray ()));
					}
				if (NumberOfAssignedVideoFiles== 1)
					{
					NumberOfSingleAssignedVideoFiles++;
					MessageBox.Show ("Bei \"" + WrongFoldedPath + "\" ist ein VideoFile Entry zugeordnet\r\n"
						+ String.Join ("\r\n", FoundIDs.ToArray ()));
					}
				if (NumberOfAssignedVideoFiles == 0)
					{
					NumberOfNonAssignedVideoFiles++;
					DataSet MaterialToChange = DataBase.GetCommonDataSet
						(String.Format ("Select * from StructuredMaterialDataBase where FoldedArchivePath = '{0}'",
										WrongFoldedPath));
					String IDToRetain = FoundIDs [0];
					FoundIDs.RemoveAt (0);
					foreach (DataRow MaterialRowToChange in MaterialToChange.Tables ["StructuredMaterialDataBase"].Rows)
						{
						String MaterialID = MaterialRowToChange ["ID"].ToString ();
						String OldFileID = MaterialRowToChange ["FileID"].ToString ();
						if (OldFileID != IDToRetain)
							DataBase.RunSQLBatch (String.Format ("Update StructuredMaterialDataBase set FileID = '{0}' where ID = '{1}'",
															 IDToRetain, MaterialID));
						}
					foreach (String IDToDelete in FoundIDs)
						{
						DataBase.RunSQLBatch (String.Format ("Delete VideoFiles where FileID = '{0}'",
															 IDToDelete));
						}
					//MessageBox.Show ("Bei \"" + WrongFoldedPath + "\" ist kein VideoFile Entry zugeordnet\r\n"
					//    + String.Join ("\r\n", FoundIDs.ToArray ()));
					}
				}
			MessageBox.Show ("Insgesamt falsch = " + Convert.ToString (OverallNumberOfWrongEntries) + "\r\n"
							 + "Non  Assigned = " + Convert.ToString (NumberOfNonAssignedVideoFiles) + "\r\n"
							 + "Single  Assigned = " + Convert.ToString (NumberOfSingleAssignedVideoFiles) + "\r\n"
							 + "Multi  Assigned = " + Convert.ToString (NumberOfMultipleAssignedVideoFiles) + "\r\n");
			
			}
Ejemplo n.º 5
0
public void PreprocessAndLoadExternalDataBases ()
	{
	List<String> NothingChangedFileName = new List<string> ();
	XElement ExternalDefinitions = CreateExternalDataBaseDescriptions ();
	foreach (XElement ExternalDataBaseDescription in ExternalDefinitions.Elements (XML_AUTO_CONTENT_PARAMETER_ENTRY))
		{
		String DescriptionName = (String) ExternalDataBaseDescription.Attribute (XML_AUTO_CONTENT_ATTRIBUTE_NAME);
		String TargetFileName = ExternalDataBaseDescription.Element (XML_AUTO_CONTENT_TARGET_XML_BESTAND).Value;
		XElement DataBaseDefinitions = ExternalDataBaseDescription.Element (XML_AUTO_CONTENT_CONVERT_FROM_DATABASE);
		String ConnectionStringName = DataBaseDefinitions.Element (XML_AUTO_CONTENT_CONVERT_DATABASE).Value;
		String TableName = DataBaseDefinitions.Element (XML_AUTO_CONTENT_TABLE_NAME).Value;
		String SqlStatement = DataBaseDefinitions.Element (XML_AUTO_CONTENT_CONVERT_SQL_STATEMENT).Value.Replace ("\t\t", " ");
		try
			{
			WCFStandardsNS.WCFStandards SourceDataBase = new WCFStandardsNS.WCFStandards ();
			SourceDataBase.DefaultConnectionStringName = ConnectionStringName;
			DataSet SourceDataSet = SourceDataBase.GetCommonDataSet (SqlStatement);
			if (SourceDataSet == null)
				{
				WMB.Basics.ReportErrorToEventViewer ("WPMediaCreateStandBildTVUnits.PreprocessAndLoadExternalDataBases",
					"Bei der Datenbank mit dem ConnectionStringName \"" + ConnectionStringName
					+ "\" mit dem SqlStatement\r\n\"" + SqlStatement + "\" kam als DataSet null zurück");
				continue;
				}
			if (SourceDataSet.Tables [TableName] == null)
				{
				WMB.Basics.ReportErrorToEventViewer ("WPMediaCreateStandBildTVUnits.PreprocessAndLoadExternalDataBases",
					"Bei der Datenbank mit dem ConnectionStringName \"" + ConnectionStringName
					+ "\" mit dem SqlStatement\r\n\"" + SqlStatement + "\" kam als keine DataTable (\"" + TableName + "\") zurück");
				continue;
				}
			if (SourceDataSet.Tables [TableName].Rows.Count == 0)
				{
				WMB.Basics.ReportErrorToEventViewer ("WPMediaCreateStandBildTVUnits.PreprocessAndLoadExternalDataBases",
					"Bei der Datenbank mit dem ConnectionStringName \"" + ConnectionStringName
					+ "\" mit dem SqlStatement\r\n\"" + SqlStatement + "\" kam bei der DataTable (\"" + TableName + "\") keine Row zurück");
				continue;
				}
			if (SourceDataSet.Tables [TableName].Rows [0] [0] == null)
				{
				WMB.Basics.ReportErrorToEventViewer ("WPMediaCreateStandBildTVUnits.PreprocessAndLoadExternalDataBases",
					"Bei der Datenbank mit dem ConnectionStringName \"" + ConnectionStringName
					+ "\" mit dem SqlStatement\r\n\"" + SqlStatement + "\" kam bei der DataTable (\"" + TableName
					+ "\") in Row [0] kein Item zurück");
				continue;
				}
			String ConverterInputFormat = (String) ExternalDataBaseDescription.Element (XML_AUTO_CONTENT_INPUT_FORMAT);
			if (ConverterInputFormat != "ForXML")
				throw new NotImplementedException ("ConverterInputFormat != \"ForXML\"");

			String XmlFormattedTable = SourceDataSet.Tables [TableName].Rows [0] [0].ToString ();
			XmlWriterSettings WriterSettings = new XmlWriterSettings ();
			WriterSettings.Encoding = Encoding.UTF8;
			WriterSettings.Indent = true;
			WriterSettings.CheckCharacters = true;
			WriterSettings.NewLineHandling = NewLineHandling.Entitize;
			WriterSettings.ConformanceLevel = ConformanceLevel.Fragment;
			MemoryStream XmlStream = new MemoryStream ();
			XmlWriter XWriter = XmlWriter.Create (XmlStream, WriterSettings);
			XWriter.WriteRaw (XmlFormattedTable);
			XWriter.Flush ();
			if (WMB.Basics.IsTheContentEqual (TargetFileName, XmlStream))
				{
				NothingChangedFileName.Add (TargetFileName);
				continue;
				}
			FileStream TargetFile = new FileStream (TargetFileName, FileMode.Create, FileAccess.Write);
			XmlStream.Seek (0, SeekOrigin.Begin);
			XmlStream.CopyTo (TargetFile);
			XmlStream.Flush ();
			XmlStream.Close ();
			TargetFile.Close ();
			}
		catch (Exception Excp)
			{
			WMB.Basics.ReportErrorToEventViewer ("WPMediaCreateStandBildTVUnits.PreprocessAndLoadExternalDataBases",
				"Bei der Datenbank mit dem ConnectionStringName \"" + ConnectionStringName
				+ "\" mit dem SqlStatement\r\n\"" + SqlStatement + "\" kam bei der DataTable (\"" + TableName
				+ "\") trat folgender Fehler auf:\r\n" + Excp.Message);

			}
		}

	XElement ExternalPostProcessingDefinitions = CreateExternelXMLFilePostProcessings ();
	foreach (XElement ExternalPostProcessingDefinition in ExternalPostProcessingDefinitions.Elements (XML_POST_PROCESSING_TARGET_ENTRY))
		{
		String SourceFileName = ExternalPostProcessingDefinition.Element (XML_POST_PROCESSING_TARGET_XML_POST_INPUT_BESTAND).Value;
		String TargetFileName = ExternalPostProcessingDefinition.Element (XML_POST_PROCESSING_TARGET_XML_POST_OUTPUT_BESTAND).Value;
		String PreFixText = ExternalPostProcessingDefinition.Element (XML_POST_PROCESSING_PREFIX_TEXT).Value;
		String PostFixText = ExternalPostProcessingDefinition.Element (XML_POST_PROCESSING_POSTFIX_TEXT).Value;
		String ProcessingType = ExternalPostProcessingDefinition.Element (XML_POST_PROCESSING_TYPE).Value;


		if (NothingChangedFileName.Contains (SourceFileName))
			continue;
		if (File.Exists (TargetFileName))
			WMB.Basics.SecureFileDelete (TargetFileName);
		if (!Directory.Exists (Path.GetDirectoryName (TargetFileName)))
			Directory.CreateDirectory (Path.GetDirectoryName (TargetFileName));
		StreamWriter OutputStream = new StreamWriter (TargetFileName, true, Encoding.UTF8);
		OutputStream.Write (PreFixText);
		StreamReader InputStream = new StreamReader (SourceFileName, Encoding.UTF8);
//		if (ProcessingType == XML_POST_PROCESSING_TYPE_INSERT_AS_STRING)
		OutputStream.Write (InputStream.ReadToEnd ());	// unconditional XML Files Creation 
		if (ProcessingType == XML_POST_PROCESSING_TYPE_CREATE_HTML_FROM_STRING)
			CreateHTMLFromXMLFile (SourceFileName, TargetFileName);
		OutputStream.Write (PostFixText);
		OutputStream.Close ();
		}


	}