コード例 #1
0
ファイル: DataWrapper.cs プロジェクト: heinzsack/DEV
		public static Byte[] LoadFileContent(Materialien MaterialContainer)
			{
			WCFStandards DataAccess = new WCFStandards();
			String SelectStatement = "select BlobContent from Materialien where ID = '" + MaterialContainer.ID.ToString() + "'";
			return DataAccess.GetCommonBlob(SelectStatement);
			}
コード例 #2
0
ファイル: DataWrapper.cs プロジェクト: heinzsack/DEV
		public static String LoadFileContentAsString(Materialien MaterialContainer)
			{
			WCFStandards DataAccess = new WCFStandards();
			String SelectStatement = "select BlobContent from Materialien where ID = '" + MaterialContainer.ID.ToString() + "'";
			Byte [] Result = DataAccess.GetCommonBlob (SelectStatement);
			if ((Result != null)
				&& (Result.Length > 0))
				using (MemoryStream Helper = new MemoryStream(Result))
					{
					return Basics.ConvertMemoryStreamToString(Helper);
					}
			return String.Empty;
			}
コード例 #3
0
ファイル: DataWrapper.cs プロジェクト: heinzsack/DEV
		public bool InsertOrUpdateNewMaterial(Guid InformationenID, Guid DataDependencyID, ref InformationenAddOn InfoAddOnID, ref Materialien Material,
											  String ContentToStore, String NameOfTheContentToStore,
											  String TypOfTheContentToStore)
			{
			return InsertOrUpdateNewMaterial(InformationenID, DataDependencyID, ref InfoAddOnID, ref Material,
									  Basics.ConvertStringToMemoryStream(ContentToStore), NameOfTheContentToStore,
									  TypOfTheContentToStore);
			}
コード例 #4
0
ファイル: DataWrapper.cs プロジェクト: heinzsack/DEV
		public bool InsertOrUpdateNewMaterial(Guid InformationenID, Guid DataDependencyID, ref InformationenAddOn NewInfAddOn, ref Materialien NewMaterial,
											  MemoryStream MemoryStreamContentToStore, String NameOfTheContentToStore,
											  String TypOfTheContentToStore)
			{
			String SizeString = String.Empty;
			if (MemoryStreamContentToStore.Length < (1024 * 5))
				{
				SizeString = String.Format(" {0:D} Bytes ", MemoryStreamContentToStore.Length);
				}
			else
				{
				SizeString = String.Format(" {0:D} kB ", MemoryStreamContentToStore.Length / 1024);
				}

			String StringToStore = Basics.ConvertMemoryStreamToString(MemoryStreamContentToStore);
			if (StringToStore.Length > 3599)
				StringToStore = StringToStore.Substring(0, 3595) + " ...";
			String FreiText = "Typ = \"" + TypOfTheContentToStore + "\" - " + NameOfTheContentToStore
								   + "." + TypOfTheContentToStore + SizeString
								   + "\r\n" + StringToStore;
			NewInfAddOn = UseOrInsertNewInformationenAddOn ("Materialien", (Guid?) null, FreiText,
				DataDependencyEnums.RootFDDIDsForAVEvent.InformationenMaterialRoot); //	Guid.Parse("5998F56D-0CA6-4FF4-B768-80C308B37394"));
			Guid InformationenAddOnID = NewInfAddOn.ID;

			NewInfAddOn.LastModifiedBy = "Auto";
			if (NewInfAddOn.ConnectedTableClass == null)
				FillConnectedTableClasses(NewInfAddOn, true, true);
			NewMaterial = (Materialien)NewInfAddOn.ConnectedTableClass;
			NewMaterial.OriginalMaterialName = NameOfTheContentToStore;
			NewMaterial.InformationenID = ActiveInformationen.ID;
			NewMaterial.InformationenAddOnID = NewInfAddOn.ID;
			NewMaterial.NameID = NameOfTheContentToStore;
			NewMaterial.Typ = TypOfTheContentToStore;

			CacheStoreMaterialBlobContentDataBaseCommand(NewMaterial, NameOfTheContentToStore,
											 MemoryStreamContentToStore, TypOfTheContentToStore);

			return true;
			}
コード例 #5
0
ファイル: DataWrapper.cs プロジェクト: heinzsack/DEV
		public Byte[] ModifyMaterialContentViaName(Materialien Material, MemoryStream NewMemoryStreamContentToUse,
				String NameOfTheNewContentToStore = "", String TypOfTheContentToStore = "")
			{
			if ((Material == null)
				|| (Material.ID == Guid.Empty))
				return null;
			if (String.IsNullOrEmpty(NameOfTheNewContentToStore))
				NameOfTheNewContentToStore = Material.NameID;
			if (String.IsNullOrEmpty(TypOfTheContentToStore))
				TypOfTheContentToStore = Material.Typ;

			CacheStoreMaterialBlobContentDataBaseCommand(Material, NameOfTheNewContentToStore,
								 NewMemoryStreamContentToUse, TypOfTheContentToStore);

			String ModifyAfterBlobChanged = "Update Materialien set BlobLength = " + Convert.ToString(Material.BlobLength)
											+ ", NameID = '" + NameOfTheNewContentToStore + "', Typ = '" + TypOfTheContentToStore
											+ "', ModifyTimeStamp = " + Basics.GetSQLFormattedDateTime(DateTime.Now) +
											" where ID = '"
											+ Material.ID.ToString() + "'";
			WCFStandards WCFAccess = new WCFStandards();
			WCFAccess.DefaultConnectionStringName = "AltErlaaInfoConnectionString";
			WCFAccess.RunSQLBatch(ModifyAfterBlobChanged);

			return LoadFileContent(Material);
			}
コード例 #6
0
ファイル: DataWrapper.cs プロジェクト: heinzsack/DEV
		public String GetMaterialContentViaName(Guid InformationenID,
			String NameOfTheContentToStore, out Materialien Material)
			{
			Material = null;
			if (WorkDataSet != null)
				if (WorkDataSet.Tables["Materialien"] != null)
					{
					DataRow[] MaterialEntries = WorkDataSet.Tables["Materialien"].Select("NameID = '"
							  + NameOfTheContentToStore + "' or OriginalMaterialName = '" + NameOfTheContentToStore + "'");
					if (MaterialEntries.Length == 1)
						{
						Material = new Materialien(MaterialEntries[0]);
						return LoadFileContentAsString(Material);
						}
					}

			DataTable MaterialTable = BasicAccess.AltErlaaInfoDataBase.GetCommonDataSet
				(String.Format("Select * From Materialien where NameID = '{0} or OriginalMaterialName = '{0}'",
					NameOfTheContentToStore)).Tables["Materialien"];
			if (MaterialTable.Rows.Count == 0)
				return String.Empty;
			if (WorkDataSet != null)
				WMB.Basics.MergeTableIntoDataSet (WorkDataSet, MaterialTable);

			Material = new Materialien(MaterialTable.Rows[0]);
			return LoadFileContentAsString(Material);
			}
コード例 #7
0
ファイル: DataWrapper.cs プロジェクト: heinzsack/DEV
		public bool CacheStoreMaterialBlobContentDataBaseCommand(Materialien MaterialContainer, String OriginalFileName,
						MemoryStream MeoryStreamContent, String Typ)
			{
			MeoryStreamContent.Seek(0, SeekOrigin.Begin);
			//WCFStandardsNS.WCFStandards WCFAccess = new WCFStandards();
			//WCFAccess.DefaultConnectionStringName = "AltErlaaInfoConnectionString";
			String UpdateCommand = "Update Materialien set BlobLength = "
								   + Convert.ToString(MeoryStreamContent.Length)
								   + ", BlobContent = @BlobParam, "
									+ "OriginalMaterialName = '" + 
									OriginalFileName.Replace("'", "''") + "', "
									+ "ModifyTimeStamp = " + Basics.GetSQLFormattedDateTime(DateTime.Now)
									+ ", Typ = '" + Typ + "' where ID = '"
								   + MaterialContainer.ID.ToString() + "'";

			RootDataClassLateDBHandler.CacheStoreMaterialBlobContentDataBaseCommand(UpdateCommand, MaterialContainer,
									OriginalFileName, MeoryStreamContent, Typ);

			//WCFAccess.SetCommonBlob(UpdateCommand, MeoryStreamContent.ToArray());
			//MaterialContainer.Typ = Typ;
			//MaterialContainer.OriginalMaterialName = OriginalFileName;
			//MaterialContainer.BlobLength = (int)MeoryStreamContent.Length;
			MeoryStreamContent.Close();
			return true;
			}
コード例 #8
0
ファイル: DataWrapper.cs プロジェクト: heinzsack/DEV
		public String ModifyMaterialContentViaName(Materialien Material, String NewStringContentToUse,
														   String NameOfTheNewContentToStore = "",
														   String TypOfTheContentToStore = "")
			{
			Byte[] NewContent = ModifyMaterialContentViaName(Material,
															   Basics.ConvertStringToMemoryStream(NewStringContentToUse),
															   NameOfTheNewContentToStore, TypOfTheContentToStore);
			if (NewContent == null)
				return String.Empty;
			return Basics.ConvertByteArrayToString(NewContent);
			}
コード例 #9
0
ファイル: DataWrapper.cs プロジェクト: heinzsack/DEV
		public bool CacheStoreMaterialBlobContentDataBaseCommand(Materialien MaterialContainer, String FileName, bool FromClipBoard = false)
			{
			if ((FromClipBoard)
				|| (FileName.ToUpper().Contains("CLIPBOARD")))
				return CheckOrStoreMaterialBlobContentFromClipBoard(MaterialContainer, FileName);
			String Extension = System.IO.Path.GetExtension(FileName).Replace(".", "").ToUpper();

			FileInfo FInfo = new FileInfo(FileName);
			if ((FileName == MaterialContainer.OriginalMaterialName)
				&& (FInfo.Length == MaterialContainer.BlobLength)
				&& (MaterialContainer.ModifyTimeStamp > FInfo.LastWriteTime))
				{
				return false;
				}
			FileStream FileContent = new FileStream(FileName, FileMode.Open, FileAccess.Read, FileShare.Read);
			MemoryStream MeoryStreamContent = new MemoryStream();
			Basics.CopyStream(FileContent, MeoryStreamContent);
			bool ReturnValue = CacheStoreMaterialBlobContentDataBaseCommand(MaterialContainer, FileName,
						MeoryStreamContent, Extension);
			FileContent.Close();
			return ReturnValue;
			}
コード例 #10
0
ファイル: DataWrapper.cs プロジェクト: heinzsack/DEV
		public bool CacheStoreMaterialBlobContentDataBaseCommand(Materialien MaterialContainer, String StringName, String Content)
			{
			String Extension = System.IO.Path.GetExtension(StringName).Replace(".", "").ToUpper();
			bool ReturnValue = CacheStoreMaterialBlobContentDataBaseCommand(MaterialContainer, StringName,
						Basics.ConvertStringToMemoryStream(Content), Extension);
			return ReturnValue;
			}
コード例 #11
0
ファイル: DataWrapper.cs プロジェクト: heinzsack/DEV
		public bool CheckOrStoreMaterialBlobContentFromClipBoard(Materialien MaterialContainer, String FileName)
			{
			if (FileName.IndexOf("Clipboard", StringComparison.CurrentCultureIgnoreCase) == -1)
				return false;
			String Extension = System.IO.Path.GetExtension(FileName).Replace(".", "").ToUpper();
			MemoryStream MemoryFileContent = null;

			Object CBData = Clipboard.GetDataObject();
			if (CBData == null)
				{
				return false;
				}
			String ContentFormat = String.Empty;
			String ClipboardContent = null;
			System.Windows.Media.Imaging.BitmapSource ClipboardContentImage = null;
			IDataObject ObjectInterface = CBData as IDataObject;
			String[] Formats = ObjectInterface.GetFormats(true);
			foreach (String Format in Formats)
				{
				//			Object InnerObject = ObjectInterface.GetData (Format);
				}
			if (Clipboard.ContainsText(TextDataFormat.Html))
				{
				ClipboardContent = Clipboard.GetText(TextDataFormat.Html);
				ContentFormat = Enum.GetName(typeof(TextDataFormat), TextDataFormat.Html);
				}
			else if (Clipboard.ContainsText(TextDataFormat.Rtf))
				{
				ClipboardContent = Clipboard.GetText(TextDataFormat.Rtf);
				ContentFormat = Enum.GetName(typeof(TextDataFormat), TextDataFormat.Rtf);
				}
			else if (Clipboard.ContainsText(TextDataFormat.Text))
				{
				ClipboardContent = Clipboard.GetText(TextDataFormat.Text);
				ContentFormat = Enum.GetName(typeof(TextDataFormat), TextDataFormat.Text);
				}
			else if (Clipboard.ContainsText(TextDataFormat.UnicodeText))
				{
				ClipboardContent = Clipboard.GetText(TextDataFormat.UnicodeText);
				ContentFormat = Enum.GetName(typeof(TextDataFormat), TextDataFormat.UnicodeText);
				}
			else if (Clipboard.ContainsImage())
				{
				ClipboardContentImage = Clipboard.GetImage();
				ContentFormat = "BitmapSource";
				}
			else
				{
				ClipboardContent = String.Empty;
				return false;
				}

			if (ContentFormat == Enum.GetName(typeof(TextDataFormat), TextDataFormat.Text))
				{
				MemoryFileContent = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(ClipboardContent));
				}
			if (ContentFormat == Enum.GetName(typeof(TextDataFormat), TextDataFormat.Rtf))
				{
				MemoryFileContent = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(ClipboardContent));
				}
			if (ContentFormat == Enum.GetName(typeof(TextDataFormat), TextDataFormat.Html))
				{
				MemoryFileContent = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(ClipboardContent));
				}
			if (ContentFormat == Enum.GetName(typeof(TextDataFormat), TextDataFormat.UnicodeText))
				{
				MemoryFileContent = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(ClipboardContent));
				}
			if (ContentFormat == "BitmapSource")
				{
				MemoryFileContent = Basics.ConvertBitmapSourceToJPegStream(ClipboardContentImage);
				}
			return CacheStoreMaterialBlobContentDataBaseCommand(MaterialContainer, FileName,
											 MemoryFileContent, Extension);
			}
コード例 #12
0
ファイル: DataWrapper.cs プロジェクト: heinzsack/DEV
		public String GetMaterialLink(Materialien Material)
			{
			if ((Material == null)
				|| (Material.BlobLength == 0))
				return String.Empty;
			String[] Result = new String[(int)WMB.DataWrapper.MaterialElementIndex.TechnicalTableLength];

			Result[(int)WMB.DataWrapper.MaterialElementIndex.UsedConnectionString] = "AltErlaaInfoConnectionString";
			Result[(int)WMB.DataWrapper.MaterialElementIndex.UsedMaterialTableName] = "Materialien";
			Result[(int)WMB.DataWrapper.MaterialElementIndex.UsedMaterialTableID] = Material.ID.ToString();
			Result[(int)WMB.DataWrapper.MaterialElementIndex.UsedTableName] = "";
			Result[(int)WMB.DataWrapper.MaterialElementIndex.UsedTableID] = "";
			Result[(int)WMB.DataWrapper.MaterialElementIndex.UsedNameID] = "";
			Result[(int)WMB.DataWrapper.MaterialElementIndex.UsedType] = Material.Typ;
			Result[(int)WMB.DataWrapper.MaterialElementIndex.UsedSubEntryID] = Material.SubEntryID;

			return String.Join(",", Result);
			}
コード例 #13
0
		void OpenMaterialWindow (Materialien MaterialEntry)
			{
			if (MaterialEntry == null)
				return;
			Byte[] FileContent = DataWrapper.LoadFileContent(MaterialEntry);
			String HelperFileName = System.IO.Path.ChangeExtension(System.IO.Path.GetTempFileName(), MaterialEntry.Typ);
			FileStream HelperFile = new FileStream (HelperFileName, FileMode.Create);
			HelperFile.Write(FileContent, 0, (int)MaterialEntry.BlobLength);
			HelperFile.Close ();
			Basics.StartExternalAssoziation (HelperFileName, "open");
			}