????? ????? ??? ????? ??? ???? ??????? ???????? Visual C# ?? InfoPath 2003

?????? ????????? ?????? ?????????
???? ???????: 892730 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

?? Microsoft Office InfoPath 2007 ?? ?? Microsoft Office InfoPath 2003 Service Pack 1 (SP1)? ????? ??????? ??? ???? ?????? ????? ??? ????? ????? InfoPath. ?? ???? ?????? ?? ????? ??? ????? ??? ?? ?? ????? ????? ?????? ?? ??? ???? ???? ??????. ?? ??? ??????? ????? ??????? Microsoft Visual C# ?????? ???? ????? ??? ? a ???? ?? ????? ???. ???? ???? ????? ??????? ???? ????? ??? ? ???? ?? ????? ??? ????? ??? ????? ????? ????.

????? ???

???? ??? ?????? ????? ????? ??? ????? ??? ???? ??????? ???????? Microsoft Visual C# ?? InfoPath 2003. ?????? ??? ??????? ??? ????? ?????? ???? ?? InfoPath 2010 ?? ?? InfoPath 2007? ???? ?????? ??? ?????: ????? ????? ??? ????? ??? ???? ??????? ???????? Visual C# ?? InfoPath 2010 ?? ?? InfoPath 2007.

??????? ????

???? Microsoft ??????? ???????? ??????? ???? ??? ?? ???? ???? ?? ????. ???? ?????? ???? ??? ?????? ???????? ??????? ?????? ???????? ?? ???????? ?????? ?????. ????? ??? ??????? ??? ????? ?? ??????? ????? ???? ??? ????? ???????? ???? ??? ????????? ?????? ????????? ????????. ?????? ??? Microsoft ????? ????? ????? ????? ????? ???? ?? ?????? ?????? ??? ??????? ??? ????? ??????? ???????? ?? ????? ??????? ?????? ????? ?? ????????? ???????.

????? ????? Visual C# InfoPath 2003

  1. ??? ????? Microsoft Visual Studio.NET 2003.
  2. ??? ??? ???????? ???? ???????? ?? ???? ??? ???????.
  3. ?? ????? ???? ???? ??????? ???? ????????? visual C# ?? Microsoft Office InfoPath ???????? ????.
  4. ?? ??? ? ??????????????????????? ?? ???? ????????.
  5. ?? ????? Project Microsoft Office? ???? ???????? ???? ????? ????? ?? ???? ???????? ????????.

    ???? ????? Microsoft Office Project ???? Visual Studio.NET 2003 ????? ???? ??????????????????. ?? ??? ???? ????? ???? ????? InfoPath. ???? ????? InfoPath ???? ??????????????????.

????? ??? ???? ????? ?? Visual Studio.NET 2003

  1. ?? "?????? ??????"? ???? ????? ??????? ?????????????????????? ??? ??? ?????? ???? ??? ???? ??? ????? ???? ????.
  2. ?? ????? ???? ???? ???? ??????? ???? ?????? ?? ???? ???? ???InfoPathAttachmentEncoder.cs ????? ????? ??? ?? ???? ??? ???.
  3. ??????? ???? ????????? ???????? ?? InfoPathAttachmentEncoder.cs ??? ????????? ???????? ???????.
    using System;
    using System.IO;
    using System.Text;
    using System.Security.Cryptography;
    
    namespace InfoPathAttachmentEncoding
    {
    	/// <summary>
    	/// InfoPathAttachment encodes file data into the format expected by InfoPath for use in file attachment nodes.
    	/// </summary>
    	public class InfoPathAttachmentEncoder
    	{
    		private string base64EncodedFile = string.Empty;
    		private string fullyQualifiedFileName;
    
    		/// <summary>
    		/// Creates an encoder to create an InfoPath attachment string.
    		/// </summary>
    		/// <param name="fullyQualifiedFileName"></param>
    		public InfoPathAttachmentEncoder(string fullyQualifiedFileName)
    		{
    			if (fullyQualifiedFileName == string.Empty)
    				throw new ArgumentException("Must specify file name", "fullyQualifiedFileName");
    
    			if (!File.Exists(fullyQualifiedFileName))
    				throw new FileNotFoundException("File does not exist: " + fullyQualifiedFileName, fullyQualifiedFileName);
    
    			this.fullyQualifiedFileName = fullyQualifiedFileName;
    		}
    
    		/// <summary>
    		/// Returns a Base64 encoded string.
    		/// </summary>
    		/// <returns>String</returns>
    		public string ToBase64String()
    		{
    			if (base64EncodedFile != string.Empty)
    				return base64EncodedFile;
    
    			// This memory stream will hold the InfoPath file attachment buffer before Base64 encoding.
    			MemoryStream ms = new MemoryStream();
    
    			// Get the file information.
    			using (BinaryReader br = new BinaryReader(File.Open(fullyQualifiedFileName, FileMode.Open, FileAccess.Read, FileShare.Read)))
    			{
    				string fileName = Path.GetFileName(fullyQualifiedFileName);
    
    				uint fileNameLength = (uint)fileName.Length + 1;
    
    				byte[] fileNameBytes = Encoding.Unicode.GetBytes(fileName);
    
    				using (BinaryWriter bw = new BinaryWriter(ms))
    				{
    					// Write the InfoPath attachment signature. 
    					bw.Write(new byte[] { 0xC7, 0x49, 0x46, 0x41 });
    
    					// Write the default header information.
    					bw.Write((uint)0x14);	// size
    					bw.Write((uint)0x01);	// version
    					bw.Write((uint)0x00);	// reserved
    
    					// Write the file size.
    					bw.Write((uint)br.BaseStream.Length);
    
    					// Write the size of the file name.
    					bw.Write((uint)fileNameLength);
    
    					// Write the file name (Unicode encoded).
    					bw.Write(fileNameBytes);
    
    					// Write the file name terminator. This is two nulls in Unicode.
    					bw.Write(new byte[] {0,0});
    
    					// Iterate through the file reading data and writing it to the outbuffer.
    					byte[] data = new byte[64*1024];
    					int bytesRead = 1;
    
    					while (bytesRead > 0)
    					{
    						bytesRead = br.Read(data, 0, data.Length);
    						bw.Write(data, 0, bytesRead);
    					}
    				}
    			}
    
    
    			// This memorystream will hold the Base64 encoded InfoPath attachment.
    			MemoryStream msOut = new MemoryStream();
    
    			using (BinaryReader br = new BinaryReader(new MemoryStream(ms.ToArray())))
    			{
    				// Create a Base64 transform to do the encoding.
    				ToBase64Transform tf = new ToBase64Transform();
    
    				byte[] data = new byte[tf.InputBlockSize];
    				byte[] outData = new byte[tf.OutputBlockSize];
    
    				int bytesRead = 1;
    
    				while (bytesRead > 0)
    				{
    					bytesRead = br.Read(data, 0, data.Length);
    
    					if (bytesRead == data.Length)
    						tf.TransformBlock(data, 0, bytesRead, outData, 0);
    					else
    						outData = tf.TransformFinalBlock(data, 0, bytesRead);
    
    					msOut.Write(outData, 0, outData.Length);
    				}
    			}
    
    			msOut.Close();
    			
    			return base64EncodedFile = Encoding.ASCII.GetString(msOut.ToArray());
    		}
    	}
    }

????? ??? ???? ?? ????? ?? Visual Studio.NET 2003

  1. ?? "?????? ??????"? ???? ????? ??????? ?????????????????????? ??? ??? ?????? ???? ??? ???? ??? ????? ???? ????.
  2. ?? ????? ???? ???? ???? ??????? ???? ?????? ?? ???? ???? ???InfoPathAttachmentDecoder.cs ????? ????? ??? ?? ???? ??? ???.
  3. ??????? ???? ????????? ???????? ?? InfoPathAttachmentDecoder.cs ??? ????????? ???????? ???????.
    using System;
    using System.IO;
    using System.Text;
    
    namespace InfoPathAttachmentEncoding
    {
    	/// <summary>
    	/// Decodes a file attachment and saves it to a specified path.
    	/// </summary>
    	public class InfoPathAttachmentDecoder
    	{
    		private const int SP1Header_Size = 20;
    		private const int FIXED_HEADER = 16;
    
    		private int fileSize;
    		private int attachmentNameLength;
    		private string attachmentName;
    		private byte[] decodedAttachment;
    
    		/// <summary>
    		/// Accepts the Base64 encoded string
    		/// that is the attachment.
    		/// </summary>
    		public InfoPathAttachmentDecoder(string theBase64EncodedString)
    		{
    			byte [] theData = Convert.FromBase64String(theBase64EncodedString);
    			using(MemoryStream ms = new MemoryStream(theData))
    			{
    				BinaryReader theReader = new BinaryReader(ms);			
    				DecodeAttachment(theReader);
    			}
    		}
    
    		private void DecodeAttachment(BinaryReader theReader)
    		{
    			//Position the reader to get the file size.
    			byte[] headerData = new byte[FIXED_HEADER];
    			headerData = theReader.ReadBytes(headerData.Length);
    
    			fileSize = (int)theReader.ReadUInt32();
    			attachmentNameLength = (int)theReader.ReadUInt32() * 2;
    			
    			byte[] fileNameBytes = theReader.ReadBytes(attachmentNameLength);
    			//InfoPath uses UTF8 encoding.
    			Encoding enc = Encoding.Unicode;
    			attachmentName = enc.GetString(fileNameBytes, 0, attachmentNameLength - 2);
    			decodedAttachment = theReader.ReadBytes(fileSize);
    		}
    
    		public void SaveAttachment(string saveLocation)
    		{
    			string fullFileName = saveLocation;
    			if(!fullFileName.EndsWith(Path.DirectorySeparatorChar))
    			{
    				fullFileName += Path.DirectorySeparatorChar;
    			}
    
    			fullFileName += attachmentName;
    
    			if(File.Exists(fullFileName))
    				File.Delete(fullFileName);
    			
    			FileStream fs = new FileStream(fullFileName, FileMode.CreateNew);
    			BinaryWriter bw = new BinaryWriter(fs);
    			bw.Write(decodedAttachment);
    
    			bw.Close();
    			fs.Close();
    		}
    
    		public string Filename
    		{
    			get{ return attachmentName; }
    		}
    
    		public byte[] DecodedAttachment
    		{
    			get{ return decodedAttachment; }
    		}
    	}	
    }
    
    

????? ???? ???? "????? ??????" ????? ???? "???? ??" ??? ????? InfoPath

  1. ?? ???? ????? InfoPath ??????????????????? ???? ??? ????? ?????? ?? ???? ??????? ?????? ?????.
  2. ?? ????? ????????? ??????? ???? ?????? ???? ???????? ????? ??????.
  3. ?? ?????? ?????? ??? ???? ???? ????? ??? ?? ???? ??? ????? ???? ?????.
  4. ?? ????? ???? ????? ???? ? ???? theAttachmentField ?? ??? ??? ????? ??? ?? ???? ??? ?????.
  5. ?? ????? ????????? ??????? ???? ??????? ?? ???????? ????? ??????.
  6. ?? ?????? ?????? ???? ?? ???? ????? ???? ??? ???? ??? ????? ???? ????.
  7. ?? ????? ???? ???? ???? ?????? ??? theAttachmentName ?? ??? ??? ????? ??? ?? ???? ??? ?????.

????? ?? ????? ????? InfoPath

  1. ?? ????? ????????? ??????? ???? ????? ???????? ????? ??????.
  2. ???? ????? ??????? ??? ??????? ?? ???? ????? ? ?? ???? ??? ????? ????.
  3. ?? ????? ???? ???? ??????? ???????? ?? ????? ? ???????????? ?? ???? ????? ??? ?? ???? ???????? ????????? ???????? ???????.
  4. ????? ???????? ???????? ??????? ???? btnAttach_OnClick ?????.
    //Get a reference to the attachment node.
    IXMLDOMNode theAttachmentNode = thisXDocument.DOM.selectSingleNode("my:myFields/my:theAttachmentField");
    
    //Get a reference to the filename node.
    IXMLDOMNode fileNameNode = thisXDocument.DOM.selectSingleNode("my:myFields/my:theAttachmentName");
    //Get the text of the node.
    String fileName = fileNameNode.text;
    if(fileName.Length > 0)
    {
    	//Encode the file and assign it to the attachment node.
    	InfoPathAttachmentEncoding.Encoder myEncoder = new InfoPathAttachmentEncoding.Encoder(fileName);
    	if(theAttachmentNode.attributes.getNamedItem("xsi:nil") != null)
    		theAttachmentNode.attributes.removeNamedItem("xsi:nil");
    	theAttachmentNode.text = myEncoder.ToBase64String();
    }	
    

????? ?? ??? ??? ????? InfoPath

  1. ?? ???????? ??? ????? InfoPath ?????????????????? ????.
  2. ?? ????? ????????? ??????? ???? ????? ???????? ????? ??????.
  3. ???? ????? ??????? ??? ??????? ?? ???? ????? ? ?? ???? ??? ????? ????.
  4. ?? ????? ???? ???? ??????? ?????? ?? ????? ? ??????????? ?? ???? ????? ??? ?? ???? ???????? ????????? ???????? ???????.
  5. ????? ???????? ???????? ??????? ???? _OnClick ??????? ?????.
    //Get a reference to the attachment node.
    IXMLDOMNode n = thisXDocument.DOM.selectSingleNode("my:myFields/my:theAttachmentField");
    //Get the text of the node.
    String theAttachment = n.text;
    if(theAttachment.Length > 0)
    {
    	InfoPathAttachmentEncoding.Decoder myDecoder = new InfoPathAttachmentEncoding.Decoder(theAttachment);
    	myDecoder.SaveAttachment(@"<Path to save the file>");
    }			
    
    ?????? ?? ??? ????????? ????????? ?????? <Path to="" save="" the="" file=""></Path> ???????? ?????? ??? ???? ??? ???.

???? ?? ?? ???? ????? InfoPath ????? ?? ??? ?????

??? ????? ?????? ??? ??????? ???? ????? InfoPath ??? ?? ???? ????? ?? ??? ?????. ????? ??????? ???? ????? ??????? ?????? ??? ???? ????? InfoPath ???? ?????:
  • ?????? Microsoft.?????? ???????? ?????? NET Framework 1.1 ???? ?????? "??? ?????" ??? ????????? ???????? Visual C#.
  • ??????? ?????? ???????? RegForm ?? ?????? InfoPath ????? Kit (SDK) ???? ??????? ????? ?? ??? ?????. ???? ??? ???? ????? ??????? ????????? ???????? Visual C#.
  • ??????? ????? ????? ????????? ???????? ??????? ?????? ??? ???? (.xsn). ??? ??????? ????? ????? ????????? ???????? ??????? ?????? ??? ???? ???????? ??? ?????? ?????????? ?????? ???????? ??? ?????? ???? ???????. ??? ???? ??????? ????? ?? ??? ?????. ?????? ???? ???????? "????? ???????" ??? ????????? ???????? Visual C#.
  • ??????? IPFullTrust ????? ?? SDK InfoPath ???? ??????? ??? ???????. ????? IPFullTrust ????? ??????? ????? ??? ?????? (.xsf) ???????? ??? ???? ?? ??????? InfoPath ???? ?????? ???? ??? IPFullTrust ????? ????? ???????? ?? ???? ???????.

    ?? ??? ???? ?? ????????? ??? ????? ????? ???????? ???????? ?? ?????? ?????? ???? ??? Microsoft Developer Network (MSDN):
    .aspx http://msdn2.microsoft.com/en-us/library/aa202736 (office.11)
  • ??????? ??????? ???????? ?? InfoPath ??????? RegisterSolution ?????. ????????? ??? ??????? ??? ??????? ??? ?????? ??????? ??? ????? ????? ??????? ??? ??? ??????? ????. ??? ????? ??????? ??? ????? ?????????? ??????? ????? ?????? ??????? ????? ?????????. ?? ???? ??? ??????? ?????? ??????. ?? ???????? ?? ?? ????? ??????? ????? ???? ???? ???????.
??? ??? ??????? ??? ??????? ???????? ????? ??????? ????? ???. ?????? ????? ??? ????? InfoPath ?????????????????? ????? ?? ???? ??????? ???????:
  1. ??? ????? ???????? ???? ??? ????? ??????.
  2. ???? ??? ???? ?? ????? ???????.
  3. ???? ?????? ????? ????? ?????? ???????? ????? ???????? ??? ????? ??????? (??????) ???? ????????.

    ?????? ????? ??? InfoPath ???????? ?????? ???? ????? ????? ???? ????? ?????? "??? ?????". ?????? ??? ?? ???? ??? ???? ????? ?????????.
  4. ???? ??? ??? ?????? ?? ???? ????????.
  5. ?? ?????? ???? ????? InfoPath ??????????????????. ??? ?? ??????? ???? ?????????? ???? ??? ???.

    ?????? ?? ??? ????? Visual Studio.NET 2003 ???????.
  6. ?? Visual Studio.NET 2003? ???? ????? ??????? ???Manifest.xsf ????? ?? "?????? ??????". ????? Manifest.xsf ???.
  7. ?? ???? ?????? ??? ???? publishUrl ???. ????? publishUrl ????? ??????? publishUrl ???.
  8. ??? ????????? ?????? ??? ?? ?? ?????? Manifest.xsf ???.
  9. ???? ??? ??? ?????? ???? ??? ?????, ??? ?????? "???????"? ?? ???? ????????.
  10. ????? ???????? ???????? ??????? ??? ??? ?? ????.
    oApp = WScript.CreateObject("InfoPath.ExternalApplication");
    strAbsolutePath = "<project_folder_url>\\Manifest.xsf";
    oApp.RegisterSolution(strAbsolutePath,"overwrite"); 
    
    ?????? ?? ??? ????????? ????????? ??????<project_folder_url></project_folder_url> ???????? ?????? ????? Manifest.xsf ?? ???? ??????? ????? ??. ???? ?????? ?????? ????? Manifest.xsf. ??? ??????? ?? ???? ????? ????? () ?? ?????? ???????? ?????? ??????? ??????? (\).
  11. ??? ????? Manifest.xsf ??? ????????? ??? ????? Register.js.
  12. ??????? RegisterSolution ?????? ???? ????? ??????? ??? Register.js ??????? ???? ????? ?????.

?????? ???????

  1. ?? ?????????????????? Visual Studio.NET 2003 ???????? ???? ??? ??? ????? ??? ????? ??????? ???????. ???? ??? ??? ????? ????? InfoPath ?? ??? ????????.
  2. ?? ????? InfoPath? ???? ???? ????? ???? ???? ???? ?????? ?? ???? ????? ?? ???? ????????.

    ?????? ???? ????? ??????? ??? ??? ???? ???? ?????? ???? ?? ?? ??? ????? ????? ???? ????.
  3. ???? ??? ???. ????? ???? ?????? ???? ??? ???????? ?? "????? ??? ?? ?????? InfoPath " ????.
  4. ?????? ????????? ???? ??? ????? ??????.

?????

????? ?? ????????? ??? ??? ????? ?????? ?????? ?? ?????? ???? "msdn ??? ???" ???????:
????? ????? ?? InfoPath 2003
.aspx http://msdn2.microsoft.com/en-us/library/aa168351 (office.11)

???????

???? ???????: 892730 - ????? ??? ??????: 12/???? ??????/1433 - ??????: 0.1
????? ???
  • Microsoft Office InfoPath 2003
????? ??????: 
kbcode kbscript kbsample kbxml kbprogramming kbhowto kbmt KB892730 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????892730

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com