Exemplo n.º 1
0
		private void MaterialProgressDataModellInstanceChanged(MaterialProgressDataModell OldValue,
			MaterialProgressDataModell NewValue)
			{
			}
		//public bool ImportData(String[] fileNamesToImport,
		//		Guid? foreignKeyToConnectTo = null,
		//		MaterialJPGForeignKeyConnectorenTyp foreignKeyTypToConnectTo = null)
		//	{
		//	List<MaterialJPG> NewMaterialJPGList = ImportData(fileNamesToImport,
		//		SelectedKoordinatenSource, SelectedMaterialJPGTyp, true,
		//		foreignKeyToConnectTo, foreignKeyTypToConnectTo);
		//	return (NewMaterialJPGList != null);
		//	}

		public List<MaterialJPG> ImportData(String[] fileNamesToImport, Ort selectedKoordinatenSource,
			MaterialJPGTyp selectedMaterialJPGTyp, bool showProgressUI, Guid? foreignKeyToConnectTo = null,
			MaterialJPGForeignKeyConnectorenTyp foreignKeyTypToConnectTo = null)
			{
			MaterialProgressDataModell ProgressModell = new MaterialProgressDataModell();
			Window ProgressWindow = new Window();
			if (showProgressUI)
				{
				ProgressModell = new MaterialProgressDataModell();
				ProgressModell.InsertProgressEntries(fileNamesToImport.ToList());
				ProgressWindow = new Window();
				ProgressWindow.Title = "ImportData gestarted";
				MaterialProgressView ProgressControl = new MaterialProgressView();
				ProgressControl.MaterialProgressDataModellInstance = ProgressModell;
				ProgressWindow.Content = ProgressControl;
				ProgressWindow.Show();
				}
			List<MaterialJPG> Result = new List<MaterialJPG>(); 
			ListOfFileNamesToImport = fileNamesToImport;
			int Index = 0;
			foreach (string fileNameToImport in ListOfFileNamesToImport)
				{
				if (showProgressUI)
					ProgressModell.SetStatus(Index, "Gestarted");
				MaterialJPG newMaterialRow = Data.DbServer3.Blob.MaterialienJPG.NewRow();
				newMaterialRow.Id = Guid.NewGuid();
				newMaterialRow.FullFileNameToLoadFrom = fileNameToImport.ToLower();
				FileInfo fileInfo = new FileInfo(fileNameToImport);

				newMaterialRow.Value = fileInfo.LoadAs_ByteArray();
				newMaterialRow.HashCode = newMaterialRow.Value.Sha1Hash().ConvertTo_Hex();
				newMaterialRow.ValueThumb = newMaterialRow.Value.ConvertTo_Image()
					.ResizeToMaximum(300, 200).ConvertTo_JpgByteArray(80);

				MaterialJPG[] EqualEntries = Data.DbServer3.Blob.MaterialienJPG.Load_AllForHashCode(newMaterialRow.HashCode);
				if (EqualEntries.Length > 0)
					{
					//MessageBox.Show("Es gibt einen Eintrag mit gleichem HashCode\r\n" +
					//                "gespeichert ist derzeit der File:\r\n\""
					//                + EqualEntries[0].FullFileNameToLoadFrom + "\"\r\n" +
					//                "der folgende File soll importiert werden:\r\n\"" +
					//                newMaterialRow.FullFileNameToLoadFrom + "\"\r\n" +
					//                "Dieser Eintrag wird übersprungen!!");
					if (showProgressUI)
						{
						ProgressModell.SetStatus(Index++, "Eintrag schon vorhanden");
						}

					Result.Add(EqualEntries[0]);
					continue;
					}
				newMaterialRow.LastWriteFileTime = fileInfo.LastWriteTime;
				newMaterialRow.TypId = selectedMaterialJPGTyp.Id;
				newMaterialRow.WLaengeOrt = selectedKoordinatenSource.WLaenge;
				newMaterialRow.WBreiteOrt = selectedKoordinatenSource.WBreite;
				String NamePart = Path.GetFileName(Path.GetDirectoryName(fileNameToImport)) + "\\"
				                  + Path.GetFileName(fileNameToImport);
				newMaterialRow.NameId = "Ort_" + fileInfo.LastWriteTime.ToString("yyyy-MM-dd_HH_mm") + "_" + NamePart;
				newMaterialRow.Description = "Ort_" + selectedKoordinatenSource.Bezeichnung;
				newMaterialRow.LastLoadTime = DateTime.Now;
				newMaterialRow.PictureTakenDateTime = fileInfo.LastWriteTime;
				Data.DbServer3.Blob.MaterialienJPG.Rows.Add(newMaterialRow);
				Data.DbServer3.Blob.SaveAnabolic(true);
				newMaterialRow.Value = null;
				Data.DbServer3.Blob.AcceptChanges();
				if (showProgressUI)
					ProgressModell.SetStatus(Index++, "Eintrag gespeichert");
				Result.Add(newMaterialRow);
				}
			if ((foreignKeyToConnectTo != null)
			    && (foreignKeyTypToConnectTo != null))
				{
				if (showProgressUI)
					{
					ProgressModell.CompletionStatus = "Bilder registriert";
					ProgressWindow.Title = "ImportData fertig, Die Daten werden jetzt verknüpft";
					}
				Index = 0;
				foreach (MaterialJPG materialJPG in Result)
					{
					MaterialJPGForeignKeyConnector foreignConnector
						= Data.DbServer3.Blob.MaterialJPGForeignKeyConnectoren.NewRow();
					foreignConnector.Id = Guid.NewGuid();
					foreignConnector.Description = materialJPG.Description;
					foreignConnector.ForeignId = foreignKeyToConnectTo;
					foreignConnector.JPGId = materialJPG.Id;
					foreignConnector.TypId = foreignKeyTypToConnectTo.Id;
					Data.DbServer3.Blob.MaterialJPGForeignKeyConnectoren.Rows.Add(foreignConnector);
					Data.DbServer3.Blob.SaveAnabolic();
					Data.DbServer3.Blob.AcceptChanges();
					if (showProgressUI)
						ProgressModell.SetStatus(Index++, "Eintrag verknüpft");
					}
				}
			if (showProgressUI)
				{
				ProgressModell.CompletionStatus = "Fertig";
				ProgressWindow.Title = "ImportData komplett fertig, Sie können dieses Fenster jetzt schließen";
				}
			return Result;
			}
Exemplo n.º 3
0
		public ProgressEntry(MaterialProgressDataModell parent, String description)
			{
			Parent = parent;
			Description = description;
			}