Esempio n. 1
0
		/*
										private void ConvertToMMUnitsLoop(ButtonData parentButton, Object ParentObject, int level)
											{
											if (!EntriesPerLevel.ContainsKey(level))
												EntriesPerLevel[level] = 0;
											int sortOrder = 0;
											foreach (ButtonData buttonData in allOldButton
														.Where(whe => whe.ParentButton != null
														&& whe.ParentButton == parentButton).OrderBy(ord => ord.Row).ToArray())
												{
												MMUnit RootMMUnit = null;
												DbEntities.dbserver3.multimedia.rows.Page contentPage = null;
												if (level == 0)
													{
													RootMMUnit = Data.DbServer3.MultiMedia.MMUnits.FindOrLoad(buttonData.Id);
													if (RootMMUnit != null)
														{
														RootMMUnit.Delete();
														Data.DbServer3.MultiMedia.SaveKatabolic(new Object());
														Data.DbServer3.MultiMedia.AcceptChanges();
														}
													RootMMUnit = Data.DbServer3.MultiMedia.MMUnits.NewRow();
													RootMMUnit.Id = buttonData.Id;
													if (String.IsNullOrWhiteSpace(buttonData.NameId))
														buttonData.NameId = "Fahrplan";
													RootMMUnit.NameId = buttonData.NameId;
													RootMMUnit.Title = buttonData.Text;
													if (buttonData.EntryType == "Entry")
														RootMMUnit.MMUnitTyp = mmUnitTypForButtonData;
													if (buttonData.EntryType == "StaticEntry")
														RootMMUnit.MMUnitTyp = mmUnitTypForButtonDataStatic;
													RootMMUnit.Table.Rows.Add(RootMMUnit);
													RootMMUnit.PagingType = DirectPlayerPage;
													Data.DbServer3.MultiMedia.MMUnits.SaveChanges(new Object());
													Data.DbServer3.MultiMedia.MMUnits.AcceptChanges();
													}
												contentPage = Data.DbServer3.MultiMedia.Pages.NewRow();
												contentPage.Id = buttonData.Id;
												contentPage.SortOrder = ++sortOrder;
												contentPage.DiagnosticText = buttonData.NameId;
												if (level == 0)
													{
													contentPage.MMUnit = RootMMUnit;
													}
												else
													{
													contentPage.ParentPage = ParentObject as DbEntities.dbserver3.multimedia.rows.Page;
													}
												contentPage.Table.Rows.Add(contentPage);

												AddDrawingElements(buttonData, contentPage);
												Data.DbServer3.MultiMedia.SaveAnabolic(new Object());
												Data.DbServer3.MultiMedia.AcceptChanges();
												ConvertToMMUnitsLoop(buttonData, contentPage, level + 1);
												EntriesPerLevel[level]++;
												LoopCounter++;
												}

											}
								*/
		private void AddDrawingElements(ButtonData buttonData, DbEntities.dbserver3.multimedia.rows.Page page)
			{
			XmlDocument FileContent = null;
			if (!String.IsNullOrWhiteSpace(buttonData.FileName))
				{
				FileInfo fileInfo = new FileInfo(Path.Combine(@"\\webserver2\WPMediaSender\Haus\ButtonData",
					buttonData.FileName));
				if (fileInfo.Exists)
					{
					FileContent = new XmlDocument();
					FileContent.Load(fileInfo.FullName);
					}
				}
			if (!String.IsNullOrWhiteSpace(buttonData.ImageAfter))
				{
				String OldButtonRootDirectory = @"D:\WPMediaSender\AutoContent\ButtonData";
				FileInfo imageFileInfo = new FileInfo(Path.Combine(OldButtonRootDirectory, buttonData.ImageAfter));
				if (imageFileInfo.Exists)
					{
					Byte[] pictureBytes = imageFileInfo.LoadAs_ByteArray();
					String extension = Path.GetExtension(imageFileInfo.Name).Replace(".", "").ToLower();
					MMPicture picture = Data.DbServer3.MultiMedia.MMPictures.LoadOrCreate(pictureBytes,
						Path.GetFileNameWithoutExtension(imageFileInfo.Name), extension);
					Image newImage = Data.DbServer3.MultiMedia.Images.NewRow();
					newImage.Id = Guid.NewGuid();
					newImage.Page = page;
					newImage.DiagnosticText = $"Image zu {buttonData.NameId}";
					newImage.Extension = extension;
					newImage.SortOrder = 1;
					newImage.MMPicture = picture;
					newImage.Background = Colors.Transparent.ToString();
					newImage.BorderThickness = new Thickness(0).ToString();
					newImage.MarginThickness = new Thickness(0).ToString();
					newImage.Rotation = 0D;
					newImage.Table.Rows.Add(newImage);

					}
				}
			if (buttonData.LinkType == "ButtonPage")
				return;
			if ((buttonData.LinkType == "Internet")
				&& (!String.IsNullOrWhiteSpace(buttonData.LinkData)))
				{
				Link newLink = Data.DbServer3.MultiMedia.Links.NewRow();
				newLink.Id = Guid.NewGuid();
				newLink.Page = page;
				newLink.DiagnosticText = $"Link zu {buttonData.NameId}";
				newLink.SortOrder = 1;
				newLink.LinkColumn = buttonData.LinkData;
				newLink.FontWeight = FontWeights.ExtraLight.ToString();
				newLink.Foreground = Colors.Black.ToString();
				newLink.MarginThickness = new Thickness(0).ToString();
				newLink.Table.Rows.Add(newLink);
				}

			if ((buttonData.LinkType == "Content")
				&& (!String.IsNullOrWhiteSpace(buttonData.LinkData)))
				{
				Text newText = Data.DbServer3.MultiMedia.Texts.NewRow();
				newText.Id = Guid.NewGuid();
				newText.Page = page;
				newText.DiagnosticText = $"Text zu {buttonData.NameId}";
				newText.SortOrder = 1;
				newText.TextColumn = buttonData.LinkData;
				newText.FontWeight = FontWeights.ExtraLight.ToString();
				newText.Foreground = Colors.Black.ToString();
				newText.MarginThickness = new Thickness(0).ToString();
				newText.Table.Rows.Add(newText);
				}

			}
		public bool ImportData()
			{
			foreach (string fileNameToImport in ListOfFileNamesToImport)
				{
				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!!");
					continue;

					}
				newMaterialRow.LastWriteFileTime = fileInfo.LastWriteTime;
				newMaterialRow.TypId = TypeOfMaterial;
                Guid foreignKey;
                if (IsOrtOrProjekt)
	                {
	                newMaterialRow.NameId = "Ort PictureTaken " + fileInfo.LastWriteTime.ToString();
					newMaterialRow.Description = "Ort_" + Path.GetFileName(fileNameToImport);
					newMaterialRow.WLaengeOrt = WordUpOrteHandlerModelInstance.SelectedOrt.WLaenge;
					newMaterialRow.WBreiteOrt = WordUpOrteHandlerModelInstance.SelectedOrt.WBreite;
	                foreignKey = WordUpOrteHandlerModelInstance.SelectedOrt.Id;
	                }
				else
					{
					newMaterialRow.NameId = "Projekt PictureTaken " + fileInfo.LastWriteTime.ToString();
					newMaterialRow.Description = "Projekt_" + Path.GetFileName(fileNameToImport);
					newMaterialRow.WLaengeOrt = ProjekteModellInstance.SelectedProjekt.Ort.WLaenge;
					newMaterialRow.WBreiteOrt = ProjekteModellInstance.SelectedProjekt.Ort.WBreite;
					foreignKey = ProjekteModellInstance.SelectedProjekt.Id;
					}
				newMaterialRow.LastLoadTime = DateTime.Now;
				newMaterialRow.PictureTakenDateTime = fileInfo.LastWriteTime;
				Data.DbServer3.Blob.MaterialienJPG.Rows.Add(newMaterialRow);
				Data.DbServer3.Blob.SaveAnabolic(true);
				Data.DbServer3.Blob.AcceptChanges();
				MaterialJPGForeignKeyConnector foreignConnector
					= Data.DbServer3.Blob.MaterialJPGForeignKeyConnectoren.NewRow();
				foreignConnector.Id = Guid.NewGuid();
				foreignConnector.Description = newMaterialRow.Description;
				foreignConnector.ForeignId = foreignKey;
				foreignConnector.JPGId = newMaterialRow.Id;
				foreignConnector.TypId = TypeOfMaterial;
				Data.DbServer3.Blob.MaterialJPGForeignKeyConnectoren.Rows.Add(foreignConnector);
				Data.DbServer3.Blob.SaveAnabolic();
				Data.DbServer3.Blob.AcceptChanges();
				}

			return true;
			}
Esempio n. 3
0
		private void LoadMissingBlobsDoThumbDoHashing()
			{
			foreach (MaterialJPG entryWithoutFilledBlobs in
					Data.DbServer3.Blob.MaterialienJPG.Load_AllWithEmptyBlobs())
				{
				FileInfo fileInfo = new FileInfo(entryWithoutFilledBlobs.FullFileNameToLoadFrom);
				if (!fileInfo.Exists)
					continue;

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

				Data.DbServer3.Blob.SaveAnabolic(true);
				entryWithoutFilledBlobs.Delete();
				Data.DbServer3.Blob.AcceptChanges();
                }
			}
		//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;
			}
Esempio n. 5
0
		public void StoreOutlookPictures()
			{
			//String TestInputFileName = "D:\\Temp\\BinaryFormatterInput.JPG";
			//String TestOutputFileName = "D:\\Temp\\BinaryFormatterOutput.JPG";
			//FileInfo fileInfoInput = new FileInfo(TestInputFileName);
			//FileInfo fileInfoOutput = new FileInfo(TestOutputFileName);
			//byte[] InputArray = fileInfoInput.LoadAs_ByteArray();
			//InputArray.SaveAs_Binary(fileInfoOutput);
			//return;
			foreach (Projekt projekt in Data.DbServer3.WordUp.Projekte.Find_PhasenCorrectProjekte("Planungen"))
				{
				String ProjektDirectory = DataWrapper.Instance.GetProjekteMaterialDirectory(projekt);
				if (!Directory.Exists(ProjektDirectory))
					Directory.CreateDirectory(ProjektDirectory);
				String PPTBildFileName = "PictureForPlenumsPPT.jpg";
				FileInfo fileInfo = new FileInfo(Path.Combine(ProjektDirectory, PPTBildFileName));
				String ExistingHash = String.Empty;
				if (fileInfo.Exists)
					{
					byte[] PictureBytes = fileInfo.LoadAs_ByteArray();
					ExistingHash = PictureBytes.Sha1Hash().ConvertTo_Hex();

					}
				MaterialJPG PreferedPPTPicture = GetPreferedPPTPicture(projekt);
				if (PreferedPPTPicture == null)
					continue;
				byte[] NewPictureBytes = PreferedPPTPicture.Get_Value();
                if (!String.IsNullOrEmpty(ExistingHash))
	                {
	                if (ExistingHash == PreferedPPTPicture.HashCode)
		                continue;
					fileInfo.Delete();
                    }
				NewPictureBytes.SaveTo_File(fileInfo);
                }
			}