// **************************************************************************************** // Developer: Alrazen Estrella // Project: ISG12152 private void CounterIncrement(IAPL.Transport.Transactions.ServerDetails ServerDetails) { if (!ServerDetails.FileNamingConvention.Equals(string.Empty)) { ServerDetails.IncrementCounter(); } }
// Zip all the files in a folder public static string ZIPAll(string zipFileName, string sourcePath, string destPath, string password, out string ZipName) { Resco.IO.Zip.ZipArchive archive = null; ZipName = ""; try { string destFilePath = ""; string fileMask = "*.*"; // If no given Zip filename, then get the name of the first file IAPL.Transport.Transactions.ServerDetails SrvrDetails = new IAPL.Transport.Transactions.ServerDetails(); if (zipFileName.Equals("")) { ZipName = SrvrDetails.getFileNameOnly(System.IO.Directory.GetFiles(sourcePath, fileMask).GetValue(0).ToString()); ZipName = ZipName.Substring(0, ZipName.Length - 3) + "zip"; destFilePath = destPath + @"\" + ZipName; } else { destFilePath = destPath + @"\" + zipFileName; ZipName = destFilePath; } archive = new Resco.IO.Zip.ZipArchive(destFilePath, Resco.IO.Zip.ZipArchiveMode.Create, System.IO.FileShare.None); archive.AutoUpdate = true; archive.Add(sourcePath, @"\", password, true, null); return(destFilePath); } catch (Exception ex) { throw ex; } finally { archive.Close(); } }
// Picks up files extracted from zip and move it to root folder public static bool GetFilesOnlyInExtractedZip(string SourcePath) { bool success = false; try { IAPL.Transport.Transactions.ServerDetails SrvrDetails = new IAPL.Transport.Transactions.ServerDetails(); int FileExist = System.IO.Directory.GetFiles(SourcePath).Length; System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(SourcePath); if (FileExist.Equals(0)) { foreach (System.IO.DirectoryInfo g in dir.GetDirectories()) { string FolderInZip = SourcePath + @"\" + g.ToString(); foreach (string file in System.IO.Directory.GetFiles(FolderInZip)) { string FileInsideFolderInZip = file.ToString(); string DestinationFilePath = SourcePath + @"\" + SrvrDetails.getFileNameOnly(file.ToString()); File.Copy(FileInsideFolderInZip, DestinationFilePath); File.Delete(FileInsideFolderInZip); } if (!FolderInZip.Equals("")) { System.IO.Directory.Delete(FolderInZip, true); } } } success = true; } catch (Exception ex) { throw ex; } return(success); }
//private string errorMessage = ""; //private IAPL.Transport.Util.ConstantVariables.FileDirection fileDirection = IAPL.Transport.Util.ConstantVariables.FileDirection.RECEIVE; //private object transferInfo = null; //public FtpTransaction(string fileDirection, object transerInfo) { public Http(IAPL.Transport.Transactions.ServerDetails transferInfo) { this.serverInformation = transferInfo; }
public EmailTransaction(IAPL.Transport.Transactions.MessageDetails messageInfo) { this.serverInformation = new ServerDetails(); this.messageInformation = messageInfo; }
public EmailTransaction(IAPL.Transport.Transactions.ServerDetails transferInfo, IAPL.Transport.Transactions.MessageDetails messageInfo) { this.serverInformation = transferInfo; this.messageInformation = messageInfo; }
public void Dispose() { this.messageInformation = null; this.serverInformation = null; }
public NetTransaction(IAPL.Transport.Transactions.ServerDetails sDetails) { this.serverInformation = sDetails; }
//private string getFileNameOnly(string origFileName) { // string fName = ""; // int i = origFileName.LastIndexOf("\\"); // if (i >= 0) { // fName = origFileName.Substring(i+1); // } // return fName; //} #region StartProcess public bool StartProcess(string fileName, string threadName, string desFilePath, IAPL.Transport.Transactions.ServerDetails desServerDetails) { bool success = false; //ArrayList list = new ArrayList(); string srcFileName; //string fName = this.serverInformation.getFileNameOnly(fileName); //getFileNameOnly(fileName); this.threadName = threadName; if (this.serverInformation.FileDirection == IAPL.Transport.Util.ConstantVariables.FileDirection.RECEIVE) { #region RECEIVE srcFileName = this.serverInformation.GetNetworkSourceFile(this.serverInformation.ServerAddress, fileName); if (!IAPL.Transport.Util.CommonTools.DirectoryExist(desFilePath)) { this.ErrorMessage = "NetTransaction-StartProcess()|Backup folder does not exist. Failed to create backup folder! Failed to backup " + fileName + " to " + desFilePath; success = false; } else { desFilePath = this.serverInformation.GetBackupFolderPathWihFileName(desFilePath); success = this.backupFileFrom(srcFileName, desFilePath); //this.copyFile(srcFileName, desFilePath); } #endregion } else if (this.serverInformation.FileDirection == IAPL.Transport.Util.ConstantVariables.FileDirection.SEND) { #region SEND string srcFilePath = desFilePath; srcFileName = this.serverInformation.GetNetworkSourceFile(srcFilePath, fileName); //COMMENT CODE BELOW SR#33117 Ccenriquez / Capad -- November 13, 2009 // Add static value to counter //if (!this.serverInformation.FileNamingConvention.Equals(string.Empty)) //{ // if (WithTerminator) // { // desServerDetails.FileCounter = desServerDetails.FileCounter + FileCtr; // } //} //OLD CODE BELOW SR#33117 Ccenriquez / Capad -- November 13, 2009 //desFilePath = this.serverInformation.GetNetworkSourceFile(this.serverInformation.ServerAddress, this.serverInformation.GenFileName()); //NEW CODE BELOW SR#33117 Ccenriquez / Capad -- November 13, 2009 desFilePath = this.serverInformation.GetNetworkSourceFile(this.serverInformation.ServerAddress, this.serverInformation.DesFileName); // desFilePath = this.serverInformation.GetNetworkSourceFile(this.serverInformation.ServerAddress, desServerDetails.GenFileName()); // ***************************************************************** // Developer: Alrazen Estrella // Project: ISG12152 // Date: July 29, 2008 // Send files to destination //if (desFilePath.LastIndexOf(".") < 0) //{ // desFilePath = desFilePath.Substring(0, desFilePath.LastIndexOf("\\")) + @"\" + fileName; //} // ***************************************************************** success = this.moveFileTo(srcFileName, desFilePath); //success = this.MoveFileFromLocalFolder(list); //COMMENT CODE BELOW SR#33117 Ccenriquez / Capad -- November 13, 2009 //if (!this.serverInformation.FileNamingConvention.Equals(string.Empty)) //{ // FileCtr++; // CounterIncrement(desServerDetails); //} #endregion } return(success); }