public override bool SaveToBase() { this.ds.Tables.Remove(this.table_workdata); this.table_setting.Clear(); DataRow[] dataRowArray = this.table_workdata.Select(); int count = this.table_workdata.Columns.Count; for (int index1 = 0; index1 < dataRowArray.Length; ++index1) { for (int index2 = 1; index2 < count; ++index2) { DataRow row = this.table_setting.NewRow(); this.table_setting.Rows.Add(row); row["width"] = (object)Useful.GetDouble((object)this.table_workdata.Columns[index2].ColumnName); row["height"] = dataRowArray[index1][0]; row["value"] = dataRowArray[index1][index2]; } } MemoryStream memoryStream = new MemoryStream(); this.ds.WriteXml((Stream)memoryStream, XmlWriteMode.WriteSchema); this.drSetting["blbvalue"] = (object)ZipArchiver.Zip(memoryStream.ToArray()); this.ds.Tables.Add(this.table_workdata); this.table_workdata.AcceptChanges(); this.ds.AcceptChanges(); return(true); }
private void CreateZipArchive(CommandPipelineContext context) { var archiver = new ZipArchiver(); if (!context.Options.PackageFileName.EndsWith(".zip")) { context.Options.PackageFileName = string.Format("{0}.zip", context.Options.PackageFileName); } var zip = Path.Combine(context.Options.PackageDirectory, context.Options.PackageFileName); Logger.InfoFormat("Creating package '{0}' as zip archive for path '{1}'...", Path.GetFileName(zip), context.Options.ScriptsPath); // create a working directory as a copy of the scripts path // due to zip archiver not being able to access directory // while it is zipping the contents: var workingDirectory = string.Format(@"{0}-working-{1}", context.Options.ScriptsPath, Guid.NewGuid().ToString("N")); _fileSystem.CopyFolderContents(context.Options.ScriptsPath, workingDirectory, true); var files = new HashSet <string>(); _fileSystem.GetFilesInPath(files, workingDirectory); var zipItems = files .Where(file => Path.GetExtension(file) == ".sql") .Select(file => new ZipItem(file, Path.GetDirectoryName(file))) .ToList(); archiver.Zip(zip, zipItems); _fileSystem.DeleteFolder(workingDirectory); Logger.InfoFormat("Package '{0}' created for path '{1}'.", Path.GetFileName(zip), context.Options.ScriptsPath); }
private void CreateZipArchiveForDelta(CommandPipelineContext context) { var archiver = new ZipArchiver(); var delta = context.Deltas.First(); var commits = delta.CommitScripts .Select(script => new ZipItem(script.GetFullPath(), Path.GetDirectoryName(script.GetFullPath()))) .ToList(); var rollbacks = delta.RollbackScripts .Select(script => new ZipItem(script.GetFullPath(), Path.GetDirectoryName(script.GetFullPath()))) .ToList(); var zipitems = new List <ZipItem>(commits); zipitems.AddRange(rollbacks); if (!context.Options.PackageName.EndsWith(".zip")) { context.Options.PackageName = string.Format("{0}.zip", context.Options.PackageName); } var zip = Path.Combine(Environment.CurrentDirectory, context.Options.PackageName); Logger.InfoFormat("Creating package '{0}' as zip archive at '{1}'...", Path.GetFileName(zip), Path.GetDirectoryName(zip)); archiver.Zip(zip, zipitems); Logger.InfoFormat("Package '{0}' created at '{1}'.", Path.GetFileName(zip), Path.GetDirectoryName(zip)); }