Пример #1
0
        public void Executar(params string[] args)
        {
            var now      = DateTime.Now;
            var tempPath = this.GetImportTempPath();

            Directory.CreateDirectory(tempPath);

            Log.App.InfoFormat("Convertendo storage do ged6 para o salus");
            Log.App.InfoFormat("Pasta temporária: " + tempPath);
            Log.App.InfoFormat("Aguarde a execução até o fim. Não interrompa.");

            this.ftpClient = this.BuildFtpClient();

            var rootpath = this.ftpClient.Root;

            Log.App.InfoFormat(
                "Caminho do repositório antigo: {0}",
                rootpath);

            this.ProcessDirectory(rootpath);

            Log.App.InfoFormat(
                "Storage convertido em {0}. {1} arquivos importados",
                DateTime.Now.Subtract(now),
                this.filesMoved);
        }
Пример #2
0
 /// <summary>
 /// initialize parameters for ftp connection
 /// </summary>
 private static void Init()
 {
     _ftp    = new Ftp2();
     Success = _ftp.UnlockComponent("Anything for 30-day trial");
     if (!Success)
     {
         Debug.Assert(false, _ftp.LastErrorText);
     }
     _ftp.Hostname = "ftp.lokador.net";
     _ftp.Username = "******";
     _ftp.Password = "******";
     _ftp.Port     = 21;
     _ftp.Passive  = false;
 }
Пример #3
0
        private Ftp2 BuildFtpClient()
        {
            Ftp2 ftp = null;

            ImportDatabase.Using(session =>
            {
                const string Sql = @"
select 
	system_serverip Host,
	system_port Port,
	SYSTEM_SERVERUSR FtpUser,
	SYSTEM_SERVERPWD Password,
	SYSTEM_FTPROOT RootPath
from system";

                var ftpSettings = session.CreateSQLQuery(Sql)
                                  .SetResultTransformer(CustomResultTransformer <FtpSettings> .Do())
                                  .UniqueResult <FtpSettings>();

                ////ftp = new Ftp2(
                ////    ftpSettings.Host,
                ////    ftpSettings.Port,
                ////    ftpSettings.FtpUser,
                ////    ftpSettings.Password,
                ////    ftpSettings.RootPath);

                ftp = new Ftp2(
                    "192.168.10.105",
                    21,
                    "anonymous",
                    "anonymous",
                    "/");
            });

            return(ftp);
        }
Пример #4
0
        private void CollectFile(string filenameonly)
        {
            return;
          
            try
            {
                _FTPBUSY = true;
                Gurock.SmartInspect.SiAuto.Main.LogMessage("Starting CollectFile - filename = "+filenameonly);
                Boolean success;
                _ftp = new Ftp2();
                success = _ftp.UnlockComponent("FTP212345678_29E8FB35jA2U");
                if (success != true)
                {
                    _FTPBUSY = false;
                    return;
                }
                _ftp.Hostname = CORESERVICE_IP_ADDRESS;
                _ftp.Username = FTP_USERNAME;
                _ftp.Password = FTP_PASSWORD;

                // Connect and login to the FTP server.
                success = _ftp.Connect();
                if (success != true)
                {
                    //Wait and then try again
                    System.Threading.Thread.Sleep(250);
                    success = _ftp.Connect();
                    if (success != true)
                    {
                        //Andagain
                        System.Threading.Thread.Sleep(250);
                        success = _ftp.Connect();
                        if (success != true)
                        {
                        }
                    }
                }

                string fileext = System.IO.Path.GetExtension(filenameonly);
                string subFolder = "";
                if (fileext.ToLower() == ".wmv" || fileext.ToLower() == ".avi" || fileext.ToLower() == ".mpg")
                {
                    subFolder = "Video";
                }
                else
                    if (fileext.ToLower() == ".png" || fileext.ToLower() == ".jpg" || fileext.ToLower() == ".bmp")
                    {
                        subFolder = "Images";
                    }
                    else
                        if (fileext.ToLower() == ".swf")
                        {
                            subFolder = "Flash";
                        }
                        else
                            if (fileext.ToLower() == ".mp3")
                            {
                                subFolder = "Audio";
                            } else
                                if (fileext.ToLower() == ".txt")
                                {
                                    subFolder = "Ticker";
                                }
                                else
                                    if (fileext.ToLower() == ".xml")
                                    {
                                        subFolder = "Xml";
                                    };

                // Change to the remote directory where the file will be uploaded.
                success = _ftp.ChangeRemoteDir(subFolder);
                if (success != true)
                {
                    success = _ftp.ChangeRemoteDir(subFolder);
                    if (success != true)
                    {
                    }
                }

                string localFilename;
                if (fileext.ToLower() == ".xml")
                {
                    localFilename = @"c:\tmp\xml\" + filenameonly;
                } else
                {
                    localFilename = @"c:\content\_media\" + filenameonly;
                }
                string remoteFilename;
                remoteFilename = filenameonly;

                SiAuto.Main.LogMessage("FTPGET remotefilename - "+remoteFilename);
                SiAuto.Main.LogMessage("FTPGET localfilename - " + localFilename);

                success = _ftp.GetFile(remoteFilename, localFilename);
             
                if (success != true)
                {
                    success = _ftp.GetFile(remoteFilename, localFilename);
                    if (success != true)
                    {
                        _FTPBUSY = false;
                        return;
                    }
                }

                _ftp.Disconnect();
            }
            catch (Exception ex)
            {
                _FTPBUSY = false;
                Gurock.SmartInspect.SiAuto.Main.LogMessage("Collecting file error:"+ex.Message);
            }
            _FTPBUSY = false;
        }
Пример #5
0
        private void cmdFTPTest_Click(object sender, EventArgs e)
        {
            Ftp2 ftp2 = new Ftp2();

            if (!ftp2.UnlockComponent("FTP287654321_28EB48A8oH1T"))
            {
                MessageBox.Show("Sorry, FTP Library Registration Error! Please Contact Us!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                ftp2.HeartbeatMs    = 100;
                ftp2.ConnectTimeout = 30;
                ftp2.Hostname       = this.txtHost.Text.Trim();
                ftp2.Username       = this.txtUser.Text;
                ftp2.Password       = this.txtPassword.Text;
                int port = 0;
                Int32.TryParse(this.txtPort.Text, out port);
                ftp2.Port               = port;
                this.cmdFTPTest.Text    = "Connecting to server...";
                this.cmdFTPTest.Enabled = false;
                Application.DoEvents();
                if (!ftp2.Connect())
                {
                    int num2 = (int)MessageBox.Show("Failed to connect FTP server! Please verify that you have input correct information.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    ftp2.Dispose();
                    this.cmdFTPTest.Text    = "Test FTP Connection";
                    this.cmdFTPTest.Enabled = true;
                }
                else
                {
                    this.txtFolder.Text = this.txtFolder.Text.Trim();
                    this.txtFolder.Text = this.txtFolder.Text.Replace("\\", "/");
                    if (this.txtFolder.Text.CompareTo("") != 0)
                    {
                        string[] strArray = this.txtFolder.Text.Split(new string[1] {
                            "/"
                        }, StringSplitOptions.None);
                        int lowerBound = strArray.GetLowerBound(0);
                        int upperBound = strArray.GetUpperBound(0);
                        int index      = lowerBound;
                        while (index <= upperBound)
                        {
                            this.cmdFTPTest.Text = "Accessing to folder: " + strArray[index];
                            Application.DoEvents();
                            if (!ftp2.ChangeRemoteDir(strArray[index]))
                            {
                                int num2 = (int)MessageBox.Show("Sorry, Failed to get access to following folder. Please make sure you have read and write access to that folder." + Environment.NewLine + Environment.NewLine + "Folder: /" + strArray[index] + "/", "FTP Folder Access Failed", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                ftp2.Disconnect();
                                ftp2.Dispose();
                                this.cmdFTPTest.Text    = "Test FTP Connection";
                                this.cmdFTPTest.Enabled = true;
                                return;
                            }
                            checked { ++index; }
                        }
                    }
                    MessageBox.Show("FTP Settings Looks Fine!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    ftp2.Disconnect();
                    ftp2.Dispose();
                    this.cmdFTPTest.Text    = "Test FTP Connection";
                    this.cmdFTPTest.Enabled = true;
                }
            }
        }