Beispiel #1
0
 public SyncSitesJob(ILogger <SyncSitesJob> logger,
                     IFtpManager ftpManager,
                     IOptions <Dictionary <string, SiteSetting> > options,
                     IPowerShellScriptRunner powerShellScriptRunner,
                     Microsoft.Extensions.Hosting.IHostEnvironment hostingEnvironment,
                     INotificationManager notificationManager,
                     IConfiguration configuration,
                     CheckRunner checkRunner)
 {
     _logger                 = logger;
     _ftpManager             = ftpManager;
     _powerShellScriptRunner = powerShellScriptRunner;
     _hostingEnvironment     = hostingEnvironment;
     _notificationManager    = notificationManager;
     _checkRunner            = checkRunner;
     _webConfigsPath         = configuration["WebConfigs"];
     _basePath               = configuration["BasePath"];
     _replaceWebConfigs      = bool.Parse(configuration["ReplaceWebConfigs"]);
     _webDeployTimeout       = configuration.GetValue <int>("WebDeployTimeout");
     _sites = options.Value;
 }
Beispiel #2
0
 public DifferenceGenerator(ChecksumDataStorage checksumDataStorage, IFtpDirectoryTreeBuilder ftpDirectoryTreeBuilder, IFtpManager ftpManager, ILocalDirectoryTreeBuilder localDirectoryTreeBuilder, IClassLogger logger, ITreeComparer treeComparer) =>
 (_checksumDataStorage, _ftpDirectoryTreeBuilder, _ftpManager, _localDirectoryTreeBuilder, _logger, _treeComparer) = (checksumDataStorage, ftpDirectoryTreeBuilder, ftpManager, localDirectoryTreeBuilder, logger, treeComparer);
        /// <summary>
        /// Connect
        /// </summary>
        private void DoConnect()
        {
            Init();

            this.Cursor = Cursors.WaitCursor;
            if (IsTreeList)
            {
                ControlService.DashboardTree.DashboardTreeList.Cursor = Cursors.WaitCursor;
            }
            if (IsCancel)
            {
                if (connStatus != null)
                {
                    if (connStatus.Connection != null)
                    {
                        connStatus.Connection.Cancel();
                    }
                    else if (connStatus.Login != null)
                    {
                        connStatus.Login.Cancel();
                    }
                    connStatus = null;

                    ControlService.DashboardTree.DashboardTreeList.FocusedNode.ImageIndex = 1;
                    ActionHelper.OnDisconnected(true);

                    ControlService.DashboardTree.DashboardTreeList.Cursor = Cursors.Default;
                }
                return;
            }

            ConnectionExceptionAction.IsCancel = false;
            IPEndPoint endPoint      = null;
            IPEndPoint proxyEndPoint = null;

            endPoint = new IPEndPoint(IPAddress.Parse(Current.LoginInfomation.IpAddress), Current.LoginInfomation.Port);
            Current.Controller.Connection.FtpUser.Account       = Current.LoginInfomation.ConnectionUserName;
            Current.Controller.Connection.FtpUser.NoSecurityPWD = Pwd;// Current.LoginInfomation.ConnectionPassword;

            TcpUFEConnection tcpConn = Current.Controller.Connection as TcpUFEConnection;

            if (tcpConn != null)
            {
                var connParams = new TcpConnectionParams(endPoint, proxyEndPoint, Current.LoginInfomation.ProxyType, Current.LoginInfomation.PorxyUserName, Current.LoginInfomation.PorxyPassword);
                tcpConn.Params = connParams;
            }
            ProWrite.UI.Controls.Actions.UFE.Responses.UFEResponseService.Init(Current);
            ActionHelper.OnCancelConnect();
            DataGate.Log.Info("Start connect.");
            IFtpManager ftpMgr = Current.Controller.Connection.FtpManager;


            //Connect task
            ftpOpenTask = Task.Create(p =>
            {
                try
                {
                    //Connect ftp
                    Log.Info("Start connect ftp");
                    ftpMgr.Open();
                    if (ftpOpenTask.IsCanceled)
                    {
                        Log.Info("Cancel connect ftp");
                        return;
                    }
                    picCommunication.InvokeProperty("Image", Resources.Resource.GetImage(Resources.Resource.Images.Pass));
                    Log.Info("Connect ftp successful.");
                    ftpMgr.IsConnected = true;
                }
                catch (Exception ex)
                {
                    DataGate.Log.Error("Connect ftp failed.");
                    if (!ftpOpenTask.IsCanceled)
                    {
                        this.InvokeMethod(delegate
                        {
                            picError.Visible      = true;
                            lblError.Visible      = true;
                            this.btnRetry.Enabled = true;
                            this.Cursor           = Cursors.Default;
                            ftpMgr.IsConnected    = false;
                            SocketException inner = ex.InnerException as SocketException;
                            if (inner != null && inner.SocketErrorCode == SocketError.TimedOut)
                            {
                            }
                            else
                            {
                                this.lblError.Text = "Sorry,connection failed,please check your user name or password.";
                            }
                            ControlService.DashboardTree.DashboardTreeList.Cursor = Cursors.Default;
                        });
                    }
                    return;
                }

                connStatus = new ConnectionEntity();
                if (ftpOpenTask.IsCanceled)
                {
                    return;
                }
                //Start connect
                connStatus.Connection = Current.Controller.Connection.OpenAsync(p2 =>
                {
                    ControlService.DashboardTree.Cursor = Cursors.Default;
                    if (ftpOpenTask.IsCanceled)
                    {
                        return;
                    }
                    if (p2.IsSuccessed)
                    {
                        DataGate.Log.Info("Connect successed.");
                        picNetWork.Image = Resources.Resource.GetImage(Resources.Resource.Images.Pass);
                        Thread.Sleep(100);
                        picConnection.Image = Resources.Resource.GetImage(Resources.Resource.Images.Pass);
                        Thread.Sleep(200);
                        if (ftpOpenTask.IsCanceled)
                        {
                            return;
                        }

                        //Start login
                        DoLogin(Current, Current.LoginInfomation.Password);
                    }
                    else
                    {
                        if (ftpOpenTask.IsCanceled)
                        {
                            return;
                        }
                        DataGate.Log.Error("Connect failed.");
                        picError.Visible = true;
                        lblError.Visible = true;
                        //picError.Image = Resources.Resource.GetImage(Resources.Resource.Images.Baffle);
                        this.btnRetry.Enabled = true;
                        this.Cursor           = Cursors.Default;
                        connStatus            = null;
                        //_isCancelConnect = false;
                        if (!IsCancel)
                        {
                            new ConnectionExceptionAction(p2.Exception).Perform();
                        }
                        ActionHelper.OnDisconnected(true);
                        ControlService.DashboardTree.DashboardTreeList.Cursor = Cursors.Default;
                    }
                });
            });
        }
 public ContentUpdater(ChecksumDataStorage checksumDataStorage, IFtpManager ftpManager, IClassLogger logger) =>
 (_checksumDataStorage, _ftpManager, _logger) = (checksumDataStorage, ftpManager, logger);
Beispiel #5
0
        private void DoConnect()
        {
            this.lblError.Visible = false;
            this.picError.Visible = false;
            this.btnRetry.Enabled = false;
            this.Cursor           = Cursors.WaitCursor;
            if (IsTreeList)
            {
                ControlService.DashboardTree.DashboardTreeList.Cursor = Cursors.WaitCursor;
            }
            if (IsCancel)
            {
                if (connStatus != null)
                {
                    if (connStatus.Connection != null)
                    {
                        connStatus.Connection.Cancel();
                    }
                    else if (connStatus.Login != null)
                    {
                        connStatus.Login.Cancel();
                    }
                    connStatus = null;

                    ControlService.DashboardTree.DashboardTreeList.FocusedNode.ImageIndex = 1;
                    ActionHelper.OnDisconnected(true);

                    ControlService.DashboardTree.DashboardTreeList.Cursor = Cursors.Default;
                }
                return;
            }

            //SignInfo Current = ControlService.SignCombo.Current;

            ConnectionExceptionAction.IsCancel = false;
            IPEndPoint endPoint      = null;
            IPEndPoint proxyEndPoint = null;

            endPoint = new IPEndPoint(IPAddress.Parse(Current.LoginInfomation.IpAddress), Current.LoginInfomation.Port);
            Current.Controller.Connection.FtpUser.Account       = Current.LoginInfomation.ConnectionUserName;
            Current.Controller.Connection.FtpUser.NoSecurityPWD = Current.LoginInfomation.ConnectionPassword;

            TcpUFEConnection tcpConn = Current.Controller.Connection as TcpUFEConnection;

            if (tcpConn != null)
            {
                var connParams = new TcpConnectionParams(endPoint, proxyEndPoint, Current.LoginInfomation.ProxyType, Current.LoginInfomation.PorxyUserName, Current.LoginInfomation.PorxyPassword);
                tcpConn.Params = connParams;
            }
            ProWrite.UI.Controls.Actions.UFE.Responses.UFEResponseService.Init(Current);
            ActionHelper.OnCancelConnect();

            IFtpManager ftpMgr = Current.Controller.Connection.FtpManager;

            try
            {
                ftpMgr.Open();
                picCommunication.Image = Resources.Resource.GetImage(Resources.Resource.Images.Pass);
                Thread.Sleep(200);
                ftpMgr.IsConnected = true;
            }

            catch (Exception ex)
            {
                picError.Visible      = true;
                lblError.Visible      = true;
                this.btnRetry.Enabled = true;
                this.Cursor           = Cursors.Default;
                //picError.Image = Resources.Resource.GetImage(Resources.Resource.Images.Baffle);
                ftpMgr.IsConnected = false;
                SocketException inner = ex.InnerException as SocketException;
                if (inner != null && inner.SocketErrorCode == SocketError.TimedOut)
                {
                    //MsgBox.Warning("Unable to connect ¨C connection timed out after multiple attempts");
                }
                else
                {
                    //MsgBox.Warning("Sorry,connection failed,please check your user name or password.");
                }
                ControlService.DashboardTree.DashboardTreeList.Cursor = Cursors.Default;
                return;
            }

            connStatus = new ConnectionEntity();

            connStatus.Connection = Current.Controller.Connection.OpenAsync(p =>
            {
                ControlService.DashboardTree.Cursor = Cursors.Default;
                if (p.IsSuccessed)
                {
                    picNetWork.Image = Resources.Resource.GetImage(Resources.Resource.Images.Pass);
                    Thread.Sleep(100);
                    picConnection.Image = Resources.Resource.GetImage(Resources.Resource.Images.Pass);
                    Thread.Sleep(200);
                    DoLogin(Current, Current.LoginInfomation.Password);
                }
                else
                {
                    picError.Visible = true;
                    lblError.Visible = true;
                    //picError.Image = Resources.Resource.GetImage(Resources.Resource.Images.Baffle);
                    this.btnRetry.Enabled = true;
                    this.Cursor           = Cursors.Default;
                    connStatus            = null;
                    //_isCancelConnect = false;
                    if (!IsCancel)
                    {
                        new ConnectionExceptionAction(p.Exception).Perform();
                    }
                    ActionHelper.OnDisconnected(true);
                    ControlService.DashboardTree.DashboardTreeList.Cursor = Cursors.Default;
                }
            });
        }