Example #1
0
		public byte [] LoadPictureBytes(String NameID)
			{
			String Extension = VirtualPathUtility.GetExtension( NameID).Replace(".", "").ToLower( );
			if (Extension == "jpg")
				{
				ContentType = "image/jpeg";
				if ((Path.IsPathRooted(NameID))
					|| (NameID.StartsWith("\\\\")))
					{
					FileInfo fileInfo = new FileInfo(NameID);
					if (fileInfo.Exists)
						return fileInfo.LoadAs_Image().ConvertTo_JpgByteArray();
					}
				return Data.DbServer3.Blob.MaterialienJPG.FindOrLoad_Short_ByNameID(NameID).Value;
				}
			else
				if (Extension == "png")
					{
					ContentType = "image/png";
				return Data.DbServer3.Blob.MaterialienPNG.FindOrLoad_ByNameID(NameID).Value;
				}
			ContentType = "text/plain";
			String FileName = Data.DbServer3.WordUp.Materialien.FindOrLoad_ByNameID(NameID).LastAssignedFilePath;
			BinaryReader BinReader = new BinaryReader(File.Open(FileName, 
				FileMode.Open, FileAccess.Read, FileShare.Read));
			byte[] Content = BinReader.BaseStream.ToByteArray((int) BinReader.BaseStream.Length);
			BinReader.Close();
			return Content;
			}
Example #2
0
		/// <summary>Opens the dialog to gather an image.</summary>
		public static BitmapSource GatherImage(this OpenFileDialog ofd)
		{
			ofd.Filter = "Bilder|*.png;*.jpg;*.gif;*.bmp;*.tiff;*.wmp";
			ofd.CheckFileExists = true;
			ofd.Multiselect = false;
			var result = ofd.ShowDialog(Application.Current.Windows.OfType<Window>().FirstOrDefault(x => x.IsActive));

			if (result != true)
				return null;

			var fi = new FileInfo(ofd.FileName);
			if (!fi.Exists)
				return null;
			return fi.LoadAs_Image();
		}
Example #3
0
		public void CreatePictureInformationForOneEntry (InformationenSource Source, Guid TypID)
			{

			Source.InformationToProcess = Data.DbServer3.AltErlaaInfo.CreateNewInformation(TypID, UserName);
			Source.InformationToProcess.Titel = NameForThisCollection;

			Source.InformationToProcess.BearbeitungsHinweis = "Fertig";

			if (Source.ConnectedBildDaten.Count > 1)
				{
				int GenerationIndex = 1;
				InformationAddOn StartSibling = null;
				foreach (InformationAddOn Entry in Source.InformationToProcess.InformationenAddOns)
					{
					if (Entry.DataDependencyId == DataDependencyEnums.RootFDDIDsForBildOnlyInformation.StandBildMaterialRoot)	//Guid.Parse("1186353e-c896-43e4-9921-f976d3a91e95")) // WerbungMaterial
						{
						StartSibling = Entry;
						break;
						}
					}
				if (StartSibling != null)
					while (GenerationIndex < Source.ConnectedBildDaten.Count)
						{
						StartSibling = Data.DbServer3.AltErlaaInfo.InformationenAddOns.InsertNewSibling (StartSibling);
						GenerationIndex++;
						}
				}
			List<InformationAddOn> materialInformationAddOns = new List<InformationAddOn>();

			foreach (InformationAddOn DefinedMaterialEntry in Source.InformationToProcess.InformationenAddOns)
				if (DefinedMaterialEntry.DataDependencyId == DataDependencyEnums.RootFDDIDsForBildOnlyInformation.StandBildMaterialRoot)
					materialInformationAddOns.Add(DefinedMaterialEntry);
			int ConnectedBildDatenToProcess = 0;
			String OrganisationenNameID = String.Empty;
			DbEntities.dbserver3.alterlaainfo.rows.ProcessConnector NewStandBildConnector = null;
			Timing NewStandBildAnzTiming = null; 
			foreach (InformationAddOn InfoAddOn in Source.InformationToProcess.InformationenAddOns)
				{
				if (InfoAddOn.DataDependencyId == DataDependencyEnums.RootFDDIDsForBildOnlyInformation.AuftraggeberFirmaRoot)	//	 Guid.Parse("c4194cab-b13d-4207-a945-f37f59ec8146")) // Auftraggeber(Firma)
					{
					InfoAddOn.Tabelle = "Organisationen";
					InfoAddOn.TabelleId =  Source.OrganisationToProcess.Id;
					InfoAddOn.FreiText = Source.OrganisationToProcess.FreiText;
                    OrganisationenNameID = Source.OrganisationToProcess.NameId;
					if (String.IsNullOrEmpty(Source.InformationToProcess.Titel))
						{
						Source.InformationToProcess.Titel = Source.OrganisationToProcess.Name;
						}
					else
						{
						Source.InformationToProcess.Titel += " - " + Source.OrganisationToProcess.Name;
						}
					if (String.IsNullOrEmpty(Source.InformationToProcess.NameId))
						Source.InformationToProcess.NameId = Basics.ConvertToCorrectFileNameElement
							(NameForThisCollection + "_" + OrganisationenNameID).Replace(" ", "");

					continue;
					}
				if (InfoAddOn.DataDependencyId == DataDependencyEnums.RootFDDIDsForBildOnlyInformation.StandBildMaterialRoot)	//Guid.Parse("1186353e-c896-43e4-9921-f976d3a91e95")) // WerbungMaterial
					{
					Material NewMaterial = InfoAddOn.GetOrCreate_ConnectedMaterial();
					String NameID = String.Format("{0}_{1}_Seite{2:D1}_Bild1",
						NameForThisCollection, OrganisationenNameID, ConnectedBildDatenToProcess + 1);
					NewMaterial.NameId = NameID;
					NewMaterial.SubEntryId = String.Format("Seite{0:D1}_Bild1",
											ConnectedBildDatenToProcess + 1);
					NewMaterial.OriginalMaterialName = Source.ConnectedBildDaten [ConnectedBildDatenToProcess].BildDatenSource;
					FileInfo pictureFileInfo = new FileInfo(NewMaterial.OriginalMaterialName);
					if (pictureFileInfo.Exists)
						{
						NewMaterial.BlobContent = pictureFileInfo.LoadAs_Image().ConvertTo_JpgByteArray();
						NewMaterial.BlobLength = (int) NewMaterial.BlobContent.Length;
						}

					NewMaterial.ModifyTimeStamp = DateTime.Now;
					NewMaterial.NameId = Path.GetFileNameWithoutExtension (NewMaterial.OriginalMaterialName);
					NewMaterial.Typ = Path.GetExtension (NewMaterial.OriginalMaterialName).Replace (".", "").ToUpper( );
					NewMaterial.OriginalMaterialName = Path.GetFileNameWithoutExtension(NewMaterial.OriginalMaterialName);
					InfoAddOn.FreiText = NewMaterial.FreiText;
					InfoAddOn.TechnicalAddOn = "BackGround(" + NewMaterial.MaterialLink + ")";
					ConnectedBildDatenToProcess++;
					continue;
					}
				if (InfoAddOn.DataDependencyId == DataDependencyEnums.RootFDDIDsForBildOnlyInformation.ConnectorStandBildRoot)		//	Guid.Parse("d48e159b-a985-4c23-8d8c-0fc75852a79d")) // WerbungMultiMedia
					{
					NewStandBildConnector = InfoAddOn.GetOrCreate_ConnectedProcessConnector();
					NewStandBildConnector.TableName = SelectedTableDefinitionToCreate.TableName;
					NewStandBildConnector.Redaktion = "StandBild";
					NewStandBildConnector.ConnectionStringName = "WPMediaAddOnDataConnectionString";
					NewStandBildConnector.NameId = Basics.ConvertToCorrectFileNameElement(Source.InformationToProcess.Titel);
					NewStandBildConnector.TemplateId = DbBasics.TemplateBildOnlyGuidId;
					continue;
					}
				if (InfoAddOn.DataDependencyId == DataDependencyEnums.RootFDDIDsForBildOnlyInformation.AktivVonBisRoot)		 //Guid.Parse("2b854b0a-b2f3-46e9-b273-79fd1568ac07")) // AktivZeitVonBis
					{
					Timing NewTiming = InfoAddOn.GetOrCreate_ConnectedTiming();
					NewTiming.ConnectedType = "Informationen";
					NewTiming.TimingTypId = "AktivVonBis";
					//NewTiming.TimeA = Source.Von;
					//NewTiming.TimeB = Source.Bis;
					NewTiming.ModifyTimeStamp = DateTime.Now;
					InfoAddOn.FreiText = NewTiming.FreiText;
					continue;
					}
//				if (InfoAddOn.DataDependencyId == DataDependencyEnums.RootFDDIDsForBildOnlyInformation.TimingsBerichtAnzVonBisRoot)//	Guid.Parse("2b854b0a-b2f3-46e9-b273-79fd1568ac07")) // AktivZeitVonBis
				if (InfoAddOn.DataDependencyId == DataDependencyEnums.RootFDDIDsForBildOnlyInformation.TimingsStandBildAnzVonBisRoot)//	Guid.Parse("2b854b0a-b2f3-46e9-b273-79fd1568ac07")) // AktivZeitVonBis
					{
					NewStandBildAnzTiming = InfoAddOn.Get_ConnectedTiming;
					NewStandBildAnzTiming.ConnectedType = "Informationen";
					NewStandBildAnzTiming.TimingTypId = "AnzVonBis";
					//NewStandBildAnzTiming.TimeA = Source.Von;
					//NewStandBildAnzTiming.TimeB = Source.Bis;
					NewStandBildAnzTiming.ModifyTimeStamp = DateTime.Now;
					InfoAddOn.FreiText = NewStandBildAnzTiming.FreiText;
					continue;
					}
				}
			if ((NewStandBildConnector != null)
			    && (NewStandBildAnzTiming != null))
				{
                NewStandBildConnector.ConnectedTimingsId = NewStandBildAnzTiming.TimingsId;
				NewStandBildConnector.TemplateId = DbBasics.TemplateBildOnlyGuidId;
				foreach (ChapterBase chapterBase in Source.InformationToProcess.GetChapters)
					{
					NewStandBildConnector.AddToUsedChapters(chapterBase);
					}
				Data.DbServer3.AltErlaaInfo.InformationenAddOns.Find
					(NewStandBildConnector.InformationenAddOnId).FreiText = NewStandBildConnector.FreiText;

				}


			}
		public static void LoadPersonenPictures
			(List<Guid> InformationenIDs, ref DbEntities.CustomClasses.StandardModelle.CommonSearchClass SelectedEntry)
			{
			String PictureRoot = "\\\\master4\\Daten\\Bilder Hausschirm\\Wohnpark\\KAE\\AV\\Personen";
			foreach (Person person in Data.DbServer3.AltErlaaInfo.Personen.Load_WithFilledMaterialConnector())
				{
				String MaterialConnector = person.MaterialConnector;
				if (String.IsNullOrEmpty(MaterialConnector))
					continue;
				String[] Elemente = MaterialConnector.Split(',');
				if (Elemente.Length < 5)
					continue;
				Guid MaterialID = Guid.Parse(Elemente[2]);
				Material material = Data.DbServer3.AltErlaaInfo.Materialien.FindOrLoad(MaterialID);
				if (material == null)
					{
					material = Data.DbServer3.AltErlaaInfo.Materialien.NewRow();
					material.Id = MaterialID;
					material.NameId = person.Name + " " + person.Vorname;
					Data.DbServer3.AltErlaaInfo.Materialien.Rows.Add(material);
					}
				String PictureFileName = Path.Combine(PictureRoot, person.Vorname + " " + person.Name + ".png");
				FileInfo fileInfo = new FileInfo(PictureFileName);
				if (!fileInfo.Exists)
					continue;
				material.OriginalMaterialName = PictureFileName;
				material.BlobLength = (int?) fileInfo.Length;
				material.BlobContent = fileInfo.LoadAs_Image().ConvertTo_PngByteArray();
				}
			Data.DbServer3.AltErlaaInfo.SaveAnabolic(new Object());
			Data.DbServer3.AltErlaaInfo.AcceptChanges();
			}