Beispiel #1
0
        private static async Task <bool> AddSiblingFilesAsync(
            ContentURI uri, DirectoryInfo folder,
            string currentFilePath, string packageName, string fileType,
            string newFilePath, IDictionary <string, string> zipArgs)
        {
            bool   bHasCopied       = false;
            string sPackageFilePath = string.Empty;

            if (folder != null)
            {
                string sNoCalcDocExt = string.Concat(Helpers.GeneralHelpers.FILENAME_DELIMITER,
                                                     Helpers.GeneralHelpers.FILENAME_EXTENSIONS.addin.ToString());
                FileInfo[] files = folder.GetFiles();
                if (files != null)
                {
                    string sFileExtension = string.Empty;
                    foreach (FileInfo file in files)
                    {
                        if (fileType == Helpers.GeneralHelpers.EXTENSION_CSV)
                        {
                            bHasCopied = AddSiblingCSVFilesAsync(
                                uri, file, currentFilePath, sNoCalcDocExt,
                                packageName, fileType, newFilePath, zipArgs);
                        }
                        else
                        {
                            //current file is already in the package
                            if (!file.FullName.Equals(currentFilePath))
                            {
                                //package either all html or all xml files
                                if (Path.GetExtension(file.FullName).Equals(fileType))
                                {
                                    //v174 exclude calcdocs because too much unneeded docs in package
                                    if (!file.Name.Contains(sNoCalcDocExt))
                                    {
                                        sPackageFilePath = Path.Combine(newFilePath, Path.GetFileName(file.FullName));
                                        bHasCopied       = await FileStorageIO.CopyURIsAsync(
                                            uri, file.FullName, sPackageFilePath);

                                        if (Helpers.FileStorageIO.URIAbsoluteExists(
                                                uri, sPackageFilePath))
                                        {
                                            if (!zipArgs.ContainsKey(sPackageFilePath))
                                            {
                                                zipArgs.Add(sPackageFilePath, packageName);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(bHasCopied);
        }