public void WriteManifest(string manifestName, string SFEPath, ModuleInfoPackage package) { string manifestfile = manifestName + ".SFE"; // "sfe_" + string manifestPath = Path.Combine(SFEPath, manifestfile); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.OmitXmlDeclaration = true; settings.NewLineOnAttributes = false; XmlWriter writer = XmlWriter.Create(manifestPath, settings); WriteManifestStartElement(writer); WritePackageStartElement(writer); WriteModuleElements(writer); WriteFilesInfo(writer); WriteFileMoveInfo(writer); WriteManifestEndElement(writer); // WriteManifestEndElement(writer); //Close Writer writer.Close(); package.FileNames.Add(manifestPath); }
public void CreatePackage(string archiveName, string manifestName,List<string> FileList,HttpResponse Response,string SFEPath,ModuleInfoPackage package,string strFiles) { strFilesToMove = strFiles; WriteManifest(manifestName, SFEPath, package); CreateZipResponse(FileList, Response, Module.FolderName, SFEPath); }
public ModuleSfeWriter(ModuleInfoPackage module) { _module = module; }
public void WriteManifest(string manifestName, string SFEPath,ModuleInfoPackage package) { string manifestfile = manifestName+".SFE";// "sfe_" + string manifestPath = Path.Combine(SFEPath, manifestfile); XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.OmitXmlDeclaration = true; settings.NewLineOnAttributes = false; XmlWriter writer = XmlWriter.Create(manifestPath, settings); WriteManifestStartElement(writer); WritePackageStartElement(writer); WriteModuleElements(writer); WriteFilesInfo(writer); WriteFileMoveInfo(writer); WriteManifestEndElement(writer); // WriteManifestEndElement(writer); //Close Writer writer.Close(); package.FileNames.Add(manifestPath); }
protected void btnSubmit_Click(object sender, EventArgs e) { ClientScriptManager script = Page.ClientScript; Button btn = sender as Button; if (btn.Text == "Next" || hdnPrev.Value == "0") { string module = lbAvailableModules.SelectedItem.Value as string; BindFolderFilesDropDown(module); if (!script.IsClientScriptBlockRegistered(GetType(), "divShow1")) { script.RegisterClientScriptBlock(this.GetType(), "divShow1", "<script>$(function(){$('#div1').hide();$('#div2').show(); counter=1;$('#' + NewPackage.Settings.next).val('Next');});</script>"); } btn.Text = "Submit"; } else if (btn.Text == "Submit" && hdnPrev.Value != "0") { string rootPath = HostingEnvironment.ApplicationPhysicalPath; ModuleInfoPackage package = new ModuleInfoPackage(); package.Description = this.PackageDetails1.Description; package.Version = this.PackageDetails1.FirstVersion + "." + this.PackageDetails1.SecondVersion + "." + this.PackageDetails1.LastVersion; package.ReleaseNotes = this.PackageDetails1.ReleaseNotes; package.Owner = this.PackageDetails1.Owner; package.Organization = this.PackageDetails1.Organization; package.URL = this.PackageDetails1.Url; package.Email = this.PackageDetails1.Email; package.FriendlyName = this.txtfriendlyname.Text; package.ModuleName = this.txtmodulename.Text; package.BusinessControllerClass = this.txtbusinesscontrollerclass.Text; if (lbAvailableModules.SelectedItem != null) package.FolderName = lbAvailableModules.SelectedItem.Value as string; package.License = this.PackageDetails1.License; package.CompatibleVersions = this.txtcompatibleversions.Text; //Populate ModuleElement and add to package ModuleElement moduleElement = new ModuleElement(); moduleElement.FriendlyName = this.txtfriendlyname.Text; moduleElement.CacheTime = this.txtCacheTime.Text; moduleElement.Controls = GetControls(); package.ModuleElements.Add(moduleElement); package.FileNames.AddRange(GetSelectedItems(this.lstAssembly, Path.Combine(rootPath, "bin\\"))); package.FileNames.AddRange(GetSelectedItems(this.lstFolderFiles, Path.Combine(rootPath, "Modules\\" + package.FolderName + "\\"))); string tempFolderPath = rootPath + GetTempPath(); if (this.hdnInstallScriptFileName.Value != null && this.hdnInstallScriptFileName.Value.Length > 0) { string InstalltempPath = Path.Combine(tempFolderPath, hdnInstallScriptFileName.Value); StreamReader reader = new StreamReader(InstalltempPath); string InstallScript = reader.ReadToEnd(); reader.Close(); string InstallfilePath = tempFolderPath + package.Version + ".SqlDataProvider"; StreamWriter writer = File.CreateText(InstallfilePath); writer.Write(InstallScript); writer.Flush(); writer.Close(); writer.Dispose(); package.FileNames.Add(InstallfilePath); } else if (!string.IsNullOrEmpty(this.InstallScriptTxt.Text)) { try { string filePath = tempFolderPath + package.Version + ".SqlDataProvider"; StreamWriter writer = File.CreateText(filePath); writer.Write(this.InstallScriptTxt.Text); writer.Flush(); writer.Close(); writer.Dispose(); package.FileNames.Add(filePath); } catch (Exception ex) { throw ex; } } if (this.hdnUnInstallSQLFileName.Value != null && this.hdnUnInstallSQLFileName.Value.Length > 0) { string UnInstalltempPath = Path.Combine(tempFolderPath, hdnUnInstallSQLFileName.Value); StreamReader reader = new StreamReader(UnInstalltempPath); string UnInstallScript = reader.ReadToEnd(); reader.Close(); string UnInstallfilePath = tempFolderPath + "Uninstall.SqlDataProvider"; StreamWriter writer = File.CreateText(UnInstallfilePath); writer.Write(UnInstallScript); writer.Flush(); writer.Close(); writer.Dispose(); package.FileNames.Add(UnInstallfilePath); } else if (!string.IsNullOrEmpty(this.UnistallScriptTxt.Text)) { string filePath = tempFolderPath + "Uninstall.SqlDataProvider"; StreamWriter writer = File.CreateText(filePath); writer.Write(this.UnistallScriptTxt.Text); writer.Flush(); writer.Close(); writer.Dispose(); package.FileNames.Add(filePath); } if (!string.IsNullOrEmpty(this.hdnSrcZipFile.Value) && this.hdnSrcZipFile.Value.Trim().Length > 1) { package.FileNames.Add(Path.Combine(tempFolderPath, this.hdnSrcZipFile.Value)); } ModuleSfeWriter moduleWriter = new ModuleSfeWriter(package); try { moduleWriter.CreatePackage(package.FolderName, "SFE_" + package.FolderName, package.FileNames, this.Context.Response, tempFolderPath, package); if (script.IsClientScriptBlockRegistered(GetType(), "script1")) { script.RegisterClientScriptBlock(GetType(), "script1", "<script>$(function(){ counter=0;});</script>"); } } catch (Exception) { //ReturnBack(); } // ReturnBack(); } }
protected void btnSubmit_Click(object sender, EventArgs e) { ClientScriptManager script = Page.ClientScript; Button btn = sender as Button; if (btn.Text == "Next" || hdnPrev.Value == "0") { string module = lbAvailableModules.SelectedItem.Value as string; BindFolderFilesDropDown(module); if (!script.IsClientScriptBlockRegistered(GetType(), "divShow1")) { script.RegisterClientScriptBlock(this.GetType(), "divShow1", "<script>$(function(){$('#div1').hide();$('#div2').show(); counter=1;$('#' + NewPackage.Settings.next).val('Next');});</script>"); } btn.Text = "Submit"; } else if (btn.Text == "Submit" && hdnPrev.Value != "0") { string rootPath = HostingEnvironment.ApplicationPhysicalPath; ModuleInfoPackage package = new ModuleInfoPackage(); package.Description = this.PackageDetails1.Description; package.Version = this.PackageDetails1.FirstVersion + "." + this.PackageDetails1.SecondVersion + "." + this.PackageDetails1.LastVersion; package.ReleaseNotes = this.PackageDetails1.ReleaseNotes; package.Owner = this.PackageDetails1.Owner; package.Organization = this.PackageDetails1.Organization; package.URL = this.PackageDetails1.Url; package.Email = this.PackageDetails1.Email; package.FriendlyName = this.txtfriendlyname.Text; package.ModuleName = this.txtmodulename.Text; package.BusinessControllerClass = this.txtbusinesscontrollerclass.Text; if (lbAvailableModules.SelectedItem != null) { package.FolderName = lbAvailableModules.SelectedItem.Value as string; } package.License = this.PackageDetails1.License; package.CompatibleVersions = this.txtcompatibleversions.Text; //Populate ModuleElement and add to package ModuleElement moduleElement = new ModuleElement(); moduleElement.FriendlyName = this.txtfriendlyname.Text; moduleElement.CacheTime = this.txtCacheTime.Text; moduleElement.Controls = GetControls(package.FolderName); package.ModuleElements.Add(moduleElement); package.FileNames.AddRange(GetSelectedItems(this.lstAssembly, Path.Combine(rootPath, "bin\\"))); package.FileNames.AddRange(GetSelectedItems(this.lstFolderFiles, Path.Combine(rootPath, "Modules\\" + package.FolderName + "\\"))); string tempFolderPath = rootPath + GetTempPath(); if (this.hdnInstallScriptFileName.Value != null && this.hdnInstallScriptFileName.Value.Length > 0) { string InstalltempPath = Path.Combine(tempFolderPath, hdnInstallScriptFileName.Value); StreamReader reader = new StreamReader(InstalltempPath); string InstallScript = reader.ReadToEnd(); reader.Close(); string InstallfilePath = tempFolderPath + package.Version + ".SqlDataProvider"; StreamWriter writer = File.CreateText(InstallfilePath); writer.Write(InstallScript); writer.Flush(); writer.Close(); writer.Dispose(); package.FileNames.Add(InstallfilePath); } else if (!string.IsNullOrEmpty(this.InstallScriptTxt.Text)) { try { string filePath = tempFolderPath + package.Version + ".SqlDataProvider"; StreamWriter writer = File.CreateText(filePath); writer.Write(this.InstallScriptTxt.Text); writer.Flush(); writer.Close(); writer.Dispose(); package.FileNames.Add(filePath); } catch (Exception ex) { throw ex; } } if (this.hdnUnInstallSQLFileName.Value != null && this.hdnUnInstallSQLFileName.Value.Length > 0) { string UnInstalltempPath = Path.Combine(tempFolderPath, hdnUnInstallSQLFileName.Value); StreamReader reader = new StreamReader(UnInstalltempPath); string UnInstallScript = reader.ReadToEnd(); reader.Close(); string UnInstallfilePath = tempFolderPath + "Uninstall.SqlDataProvider"; StreamWriter writer = File.CreateText(UnInstallfilePath); writer.Write(UnInstallScript); writer.Flush(); writer.Close(); writer.Dispose(); package.FileNames.Add(UnInstallfilePath); } else if (!string.IsNullOrEmpty(this.UnistallScriptTxt.Text)) { string filePath = tempFolderPath + "Uninstall.SqlDataProvider"; StreamWriter writer = File.CreateText(filePath); writer.Write(this.UnistallScriptTxt.Text); writer.Flush(); writer.Close(); writer.Dispose(); package.FileNames.Add(filePath); } if (!string.IsNullOrEmpty(this.hdnSrcZipFile.Value) && this.hdnSrcZipFile.Value.Trim().Length > 1) { package.FileNames.Add(Path.Combine(tempFolderPath, this.hdnSrcZipFile.Value)); } ModuleSfeWriter moduleWriter = new ModuleSfeWriter(package); try { moduleWriter.CreatePackage(package.FolderName, "SFE_" + package.FolderName, package.FileNames, this.Context.Response, tempFolderPath, package); if (script.IsClientScriptBlockRegistered(GetType(), "script1")) { script.RegisterClientScriptBlock(GetType(), "script1", "<script>$(function(){ counter=0;});</script>"); } } catch (Exception) { //ReturnBack(); } // ReturnBack(); } }
public void CreatePackage(string archiveName, string manifestName, List <string> FileList, HttpResponse Response, string SFEPath, ModuleInfoPackage package, string strFiles) { strFilesToMove = strFiles; WriteManifest(manifestName, SFEPath, package); CreateZipResponse(FileList, Response, Module.FolderName, SFEPath); }