Esempio n. 1
0
        /// <summary>
        /// Return the count of log files required for clean-up.
        /// </summary>
        /// <returns></returns>
        public static int CleanUpFileCount()
        {
            int fileCount = 0;

            fileCount = CleanUpFiles.Count();

            return(fileCount);
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the actions for the current working file for encryption and transmission
        /// </summary>
        /// <param name="workingFile"></param>
        private void HandleMovedVendorFile(VendorLite vl, int _count)
        {
            var source             = vl.filePath;
            var file               = Path.GetFileName(source);
            var dest               = String.Format(@"{0}\{1}", Server.MapPath(vl.workingPath), file);
            var PublicKeyFileName  = Server.MapPath(vl.publicKeyPath);
            var PrivateKeyFileName = Server.MapPath(appvars.SignPrivateKey);
            var vt             = (VendorType)Enum.Parse(typeof(VendorType), vl.VendorName, true);
            var EncryptionFile = String.Format("{0}{1}", dest.Replace(Path.GetFileName(dest), ""), appvars.ReturnNewFileName(vt));

            //Get the user info from their session var...
            SetUserInformation();
            vl.UserID = this.CurrentUser.UserObject.LoginID.ToLower();

            if (!File.Exists(dest))
            {
                FileStream fs = File.Create(dest);
                fs.Close();
            }

            File.Copy(source, dest, true);

            PgpEncryptionKeys encryptionKeys = new PgpEncryptionKeys(PublicKeyFileName, PrivateKeyFileName, appvars.SignPassWord);
            PgpEncrypt        encrypter      = new PgpEncrypt(encryptionKeys);

            using (Stream outputStream = File.Create(EncryptionFile))
            {
                //build out the encypted file...
                encrypter.EncryptAndSign(outputStream, new FileInfo(dest));

                //Our file transfer class requires a fully qualified clean-up set...
                CleanUpFiles cuf = new CleanUpFiles();
                cuf.EncryptedFilePath  = EncryptionFile;
                cuf.TxtWorkingFilePath = dest;
                // we'll put in the script path later.... cuf.ClientScriptFilePath = "";
                //set the vL item's cleanupItems for the next routine..
                vl.cleanUpItems = cuf;
            }        //end using statement

            //construct the object and run it...
            FileTransfer fT = new FileTransfer(vl);

            fT.RunUpload();

            //File the report and store the files before clean-up...
            FileReport fr = new FileReport(vl);

            fr.SubmitReport();



            //clean up...
            FileCleanUp.CleanUpFileTransfer(vl.cleanUpItems);
        }    //handle the HandleMovedVendorFile
Esempio n. 3
0
 /// <summary>
 /// Cleans up all files in the member class...
 /// </summary>
 /// <param name="cuf"></param>
 public static void CleanUpFileTransfer(CleanUpFiles cuf)
 {
     if (File.Exists(cuf.ClientScriptFilePath))
     {
         File.Delete(cuf.ClientScriptFilePath);
     }
     if (File.Exists(cuf.EncryptedFilePath))
     {
         File.Delete(cuf.EncryptedFilePath);
     }
     if (File.Exists(cuf.TxtWorkingFilePath))
     {
         File.Delete(cuf.TxtWorkingFilePath);
     }
     if (File.Exists(cuf.ClientBatFilePath))
     {
         File.Delete(cuf.ClientBatFilePath);
     }
 }
        /// <summary>
        /// Handles the actions for the current working file for encryption and transmission
        /// </summary>
        /// <param name="workingFile"></param>
        private void HandleMovedVendorFile(VendorLite vl, int _count)
        {
            string source = vl.filePath;
                string file = Path.GetFileName(source);
                string dest = String.Format(@"{0}\{1}", Server.MapPath(vl.workingPath), file);
                string PublicKeyFileName = Server.MapPath(vl.publicKeyPath);
                string PrivateKeyFileName = Server.MapPath(appvars.SignPrivateKey);
                VendorType vt = (VendorType)Enum.Parse(typeof(VendorType), vl.VendorName, true);
                string EncryptionFile = String.Format("{0}{1}", dest.Replace(Path.GetFileName(dest), ""), appvars.ReturnNewFileName(vt));

                //Get the user info from their session var...
                SetUserInformation();
                vl.UserID = this.CurrentUser.UserObject.LoginID.ToLower();

                if (!File.Exists(dest))
                {
                    FileStream fs = File.Create(dest);
                    fs.Close();
                }

                File.Copy(source, dest, true);

                PgpEncryptionKeys encryptionKeys = new PgpEncryptionKeys(PublicKeyFileName, PrivateKeyFileName, appvars.SignPassWord);
                PgpEncrypt encrypter = new PgpEncrypt(encryptionKeys);

                using (Stream outputStream = File.Create(EncryptionFile))
                {
                    //build out the encypted file...
                    encrypter.EncryptAndSign(outputStream, new FileInfo(dest));

                    //Our file transfer class requires a fully qualified clean-up set...
                    CleanUpFiles cuf = new CleanUpFiles();
                    cuf.EncryptedFilePath = EncryptionFile;
                    cuf.TxtWorkingFilePath = dest;
                    // we'll put in the script path later.... cuf.ClientScriptFilePath = "";
                    //set the vL item's cleanupItems for the next routine..
                    vl.cleanUpItems = cuf;
                }//end using statement

                //construct the object and run it...
                FileTransfer fT = new FileTransfer(vl);
                fT.RunUpload();

                //File the report and store the files before clean-up...
                FileReport fr = new FileReport(vl);
                fr.SubmitReport();

                //clean up...
                FileCleanUp.CleanUpFileTransfer(vl.cleanUpItems);
        }