Exemplo n.º 1
0
        private void FunctionVI()
        {
            // here for the type name
            HtmlHelper  htmlHelper;
            FtpTransfer ftpTransfer;
            UIControl   uiControl;

            #region
            htmlHelper = new HtmlHelper();
            Assert.IsNotNull(htmlHelper);
            ftpTransfer = new FtpTransfer();
            Assert.IsNotNull(ftpTransfer);
            uiControl = new UIControl();
            Assert.IsNotNull(uiControl);

            #endregion
        }
Exemplo n.º 2
0
        static void Execute()
        {
            var logger = new Logger();
            var watch  = new Stopwatch();

            watch.Start();

            logger.Log("> Starting...\r\n");
            logger.Log(
                string.Format("  > Start Time: {0}\r\n", DateTime.Now)
                );

            foreach (TransferElement transfer in Configuration.DataTransfer.Transfers)
            {
                try
                {
                    logger.Log(
                        string.Format(
                            "    > Transfer Name: {0}\r\n", transfer.InvariantName
                            )
                        );

                    var from = transfer.From;
                    var to   = transfer.To;

                    if (from.IsFtp)
                    {
                        var sourceFtp = new FtpTransfer(from.Host, from.UserName, from.Password);

                        if (to.IsFtp)
                        {
                            var ftpFileInfo = new FtpFileInfo(to.Path, to.Host, to.UserName, to.Password);
                            sourceFtp.UploadFromFtp(from.Path, ftpFileInfo, from.SearchPattern, from.DeleteAfter, to.MaintainStructure);
                        }
                        else
                        {
                            sourceFtp.Download(from.Path, to.Path, from.SearchPattern, from.DeleteAfter, to.MaintainStructure);
                        }
                    }
                    else
                    {
                        if (to.IsFtp)
                        {
                            var destFtp = new FtpTransfer(to.Host, to.UserName, to.Password);
                            destFtp.Upload(from.Path, to.Path, from.SearchPattern, from.DeleteAfter, to.MaintainStructure);
                        }
                        else
                        {
                            Transfer.TransferFile(from.Path, to.Path, from.SearchPattern, to.MaintainStructure, from.DeleteAfter);
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Log(
                        string.Format(
                            "> Error: {0}\r\n", ex.Message
                            ),
                        Enumerators.LogColor.Error
                        );
                }
            }

            logger.Log(
                string.Format("  > End Time: {0}\r\n", DateTime.Now)
                );
            logger.Log(
                string.Format("  > Duration Time: {0}\r\n", watch.Elapsed)
                );
            logger.Log(
                string.Format("  > End Time: {0}\r\n", watch.Elapsed)
                );
            logger.Log("> End\r\n");
            watch.Stop();

            if (!Directory.Exists(Constants.LOG_RELATIVE_PATH))
            {
                Directory.CreateDirectory(Constants.LOG_RELATIVE_PATH);
            }

            var logPath = string.Format(
                "{0}{1}{2}{3}.log",
                Constants.LOG_RELATIVE_PATH,
                Path.DirectorySeparatorChar,
                Constants.LOG_FILE_NAME,
                DateTime.Now.ToString("yyyyMMddHHmmssfff")
                );

            logger.Write(logPath);

#if DEBUG
            Console.ReadLine();
#endif
            Environment.Exit(1);
        }