Exemplo n.º 1
0
 // ****************************************************************************************
 // Developer: Alrazen Estrella
 // Project: ISG12152
 private void CounterIncrement(IAPL.Transport.Transactions.ServerDetails ServerDetails)
 {
     if (!ServerDetails.FileNamingConvention.Equals(string.Empty))
     {
         ServerDetails.IncrementCounter();
     }
 }
Exemplo n.º 2
0
        // 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();
            }
        }
Exemplo n.º 3
0
        // 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);
        }
Exemplo n.º 4
0
        //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;
        }
Exemplo n.º 5
0
 public EmailTransaction(IAPL.Transport.Transactions.MessageDetails messageInfo)
 {
     this.serverInformation  = new ServerDetails();
     this.messageInformation = messageInfo;
 }
Exemplo n.º 6
0
 public EmailTransaction(IAPL.Transport.Transactions.ServerDetails transferInfo, IAPL.Transport.Transactions.MessageDetails messageInfo)
 {
     this.serverInformation  = transferInfo;
     this.messageInformation = messageInfo;
 }
Exemplo n.º 7
0
 public void Dispose()
 {
     this.messageInformation = null;
     this.serverInformation  = null;
 }
Exemplo n.º 8
0
 public NetTransaction(IAPL.Transport.Transactions.ServerDetails sDetails)
 {
     this.serverInformation = sDetails;
 }
Exemplo n.º 9
0
        //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);
        }