示例#1
0
            private static void AddCoreProperties(DocX doc)
            {
                System.IO.Packaging.PackagePart coreProp = doc.PackagePart.Package.CreatePart(
                    new System.Uri("/docProps/core.xml", System.UriKind.Relative),
                    "application/vnd.openxmlformats-package.core-properties+xml",
                    System.IO.Packaging.CompressionOption.Normal
                    );

                using (System.IO.TextWriter tr = new System.IO.StreamWriter(coreProp.GetStream(System.IO.FileMode.Open, System.IO.FileAccess.Write)))
                {
                    System.DateTime current = System.DateTime.UtcNow;
                    tr.Write(@"<cp:coreProperties
xmlns:cp=""http://schemas.openxmlformats.org/package/2006/metadata/core-properties""
xmlns:dc=""http://purl.org/dc/elements/1.1/""
xmlns:dcterms=""http://purl.org/dc/terms/""
xmlns:dcmitype=""http://purl.org/dc/dcmitype/""
xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"">
<dc:creator>MADI PK</dc:creator>
<dcterms:created xsi:type=""dcterms:W3CDTF"">" + current.ToString("o") + @"</dcterms:created>
</cp:coreProperties>"
                             );
                }

                doc.PackagePart.Package.CreateRelationship(coreProp.Uri,
                                                           System.IO.Packaging.TargetMode.Internal,
                                                           "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"
                                                           );
            }
示例#2
0
        internal static bool IsPackageFile(System.IO.Packaging.PackagePart part)
        {
            string path = UriUtility.GetPath(part.Uri);

            // We exclude any opc files and the manifest file (.nuspec)
            return(!ExcludePaths.Any(p => path.StartsWith(p, StringComparison.OrdinalIgnoreCase)) &&
                   !PackageHelper.IsManifest(path));
        }
示例#3
0
 private void SaveJsonDataToPart(byte[] bytes, System.IO.Packaging.Package package, string partName)
 {
     System.IO.Packaging.PackagePart part = package.CreatePart(System.IO.Packaging.PackUriHelper.CreatePartUri(new Uri(partName, UriKind.Relative)), System.Net.Mime.MediaTypeNames.Text.Plain);
     using (Stream outStream = part.GetStream())
     {
         outStream.Write(bytes, 0, bytes.Length);
     }
 }
示例#4
0
        void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                StreamResourceInfo zipStream = new StreamResourceInfo(e.Result as Stream, null);
                foreach (string file in FilesToDownload)
                {
                    UpdateProgress(0, "Decompressing " + file + "...");
                    Uri part = new Uri(file, UriKind.Relative);
#if !SILVERLIGHT
                    System.IO.Packaging.Package     zipFile = System.IO.Packaging.ZipPackage.Open(zipStream.Stream, FileMode.Open);
                    System.IO.Packaging.PackagePart thePart = zipFile.GetPart(part);
                    StreamReader sr           = new StreamReader(thePart.GetStream());
                    string       unzippedFile = sr.ReadToEnd();
                    StreamWriter writer       = new StreamWriter(file);
                    writer.Write(unzippedFile);
                    writer.Close();
#else
                    // This reading method only works in Silverlight due to the GetResourceStream not existing with 2 arguments in
                    // regular .Net-land
                    StreamResourceInfo fileStream   = Application.GetResourceStream(zipStream, part);
                    StreamReader       sr           = new StreamReader(fileStream.Stream);
                    string             unzippedFile = sr.ReadToEnd();
                    //Write it in a special way when using IsolatedStorage, due to IsolatedStorage
                    //having a huge performance issue when writing small chunks
                    IsolatedStorageFileStream isfs = GetFileStream(file, true);

                    char[] charBuffer = unzippedFile.ToCharArray();
                    int    fileSize   = charBuffer.Length;
                    byte[] byteBuffer = new byte[fileSize];
                    for (int i = 0; i < fileSize; i++)
                    {
                        byteBuffer[i] = (byte)charBuffer[i];
                    }
                    isfs.Write(byteBuffer, 0, fileSize);
                    isfs.Close();
#endif

                    UpdateProgress(0, "Finished " + file + "...");
                }
            }
            else
            {
                (App.Current as App).WriteLoadProgress(e.Error.Message);
            }
            if (StreamReady != null)
            {
                StreamReady.Invoke(this, EventArgs.Empty);
            }
        }
示例#5
0
 internal ExcelBarChart(ExcelDrawings drawings, XmlNode node, Uri uriChart, System.IO.Packaging.PackagePart part, XmlDocument chartXml, XmlNode chartNode) :
     base(drawings, node, uriChart, part, chartXml, chartNode)
 {
     SetChartNodeText(chartNode.Name);
 }
示例#6
0
 internal ExcelDoughnutChart(ExcelDrawings drawings, XmlNode node, Uri uriChart, System.IO.Packaging.PackagePart part, XmlDocument chartXml, XmlNode chartNode) :
     base(drawings, node, uriChart, part, chartXml, chartNode)
 {
     //SetPaths();
 }