/// <summary>
        /// Login failed
        /// </summary>
        /// <param name="resp"></param>
        protected void OnLoginFailed(UFEPacket resp)
        {
            Cursor = Cursors.Default;
            //CloseConnection();
            Action successCallback = null;
            Action failCallback    = null;
            var    action          = new LogoffAction(Current, successCallback, failCallback, false);

            action.Perform();

            const string ftpError = "Auth fail";

            if (resp.ActionError.Message.Contains(ftpError))
            {
                MsgBox.Warning("SSH server auth fail. Disconnect the connection.");
                Close();
            }
            else
            {
                string msg = " Please try again.";
                if (resp.ActionError.Message.Contains("logged"))
                {
                    msg = " Please try again later.";
                }
                MsgBox.Warning(resp.ActionError.Message + msg);
            }
        }
        private void CancelConnect()
        {
            Action successCallback = null;
            Action failCallback    = null;
            var    action          = new LogoffAction(Current, successCallback, failCallback, false);

            action.Perform();
        }
        /// <summary>
        /// Disconnect
        /// </summary>
        private void DoDisconnect()
        {
            IsDisconnection = true;
            Action successCallback = delegate { isSaveClose = true; Close(); };
            Action failCallback    = delegate { isSaveClose = true; Close(); };

            var action = new LogoffAction(Current, successCallback, failCallback);

            action.Perform();
            this.btnSave.Enabled = true;
        }
Beispiel #4
0
        void disConnectToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            _IsDisconnection = true;
            SignInfo sign = treeList.FocusedNode.Tag as SignInfo;

            Action successCallback = null;
            Action failCallback    = null;
            var    action          = new LogoffAction(sign, successCallback, failCallback);

            action.Perform();
        }
        /// <summary>
        /// Update sign info when Connect success
        /// </summary>
        void UpdateSignInfo()
        {
            //判断是否添加新项成功
            if (!_IsEdit)
            {
                if (!_Parent.AddSign(Current))
                {
                    Action successCallback = null;
                    Action failCallback    = null;
                    var    action          = new LogoffAction(Current, successCallback, failCallback, false);
                    action.Perform();

                    btnSave.Enabled       = true;
                    txtServerName.Enabled = true;
                    txtConnectPWD.Enabled = true;

                    MsgBox.Warning(Resource.GetString(Resource.Strings.DashBoard_SaveSignRepeat));
                    return;
                }
            }

            if (this.ddlSignParent.Text == SelectText)
            {
                Current.Parent = DataGate.Project.RootGroup;
            }
            else
            {
                Current.Parent = ddlSignParent.SelectedItem as SignGroupInfo;
            }
            //判断是否需要上传图片
            if (btSignImage.Text.Length > 0)
            {
                //DataGate.Upload(btSignImage.Text);
                UpLoad();
                Current.Image = Current.Template.Sign.Image = strImageFullName;
            }
            Current.IsWebCam = rdbWebCam.Checked;

            DataGate.Update();
            this.IsRefresh = true;
            LocalMessageBus.Send(Current, new LoginSuccessMessage());
            //ActionHelper.OnAfterLogin(Current.Controller.Connection.User);

            //Close();
            isSaveClose = true;

            this.Close();
        }
Beispiel #6
0
        /// <summary>
        /// Login
        /// </summary>
        /// <param name="sign"></param>
        /// <param name="password"></param>
        private void DoLogin(SignInfo sign, string password)
        {
            if (password.Trim() == "")
            {
                password = "******";
            }

            sign.Controller.UserManager.Login(sign.LoginInfomation.UserName, password, p =>
            {
                if (p.IsSuccessed)
                {
                    int h       = sign.Height;
                    int w       = sign.Width;
                    sign.Height = 10000;
                    sign.Width  = 10000;
                    LocalMessageBus.Send(this, new DataChangedMessage(PWDataType.Dashboard));
                    LocalMessageBus.Send(this, new ActiveChange(sign, false));

                    sign.Height = h;
                    sign.Width  = w;
                    PopulateTree();
                    treeList.FocusedNode = treeList.FindNodeByFieldValue(_.Name, sign.Name);
                    var focusedNode      = treeList.FindNodeByFieldValue(_.Name, sign.Name);
                    if (focusedNode != null)
                    {
                        focusedNode.ImageIndex = _.SignConnectImageIndex;
                    }
                    ControlService.SignCombo.Current = sign;
                    ActionHelper.OnAfterLogin(sign.Controller.Connection.User);
                    if (focusedNode != null)
                    {
                        focusedNode.ImageIndex = _.SignConnectImageIndex;
                    }
                }
                else
                {
                    Action successCallback = null;
                    Action failCallback    = null;
                    var action             = new LogoffAction(sign, successCallback, failCallback, false);
                    action.Perform();
                    OnLoginFailed(p.Packet);
                }
            });
            Cursor = Cursors.Default;
        }
        /// <summary>
        /// Login
        /// </summary>
        /// <param name="sign"></param>
        /// <param name="password"></param>
        private void DoLogin(SignInfo sign, string password)
        {
            if (string.IsNullOrEmpty(password) || password.Trim() == "")
            {
                password = "******";
            }
            DataGate.Log.Info("Start logon.");
            connStatus.Login = sign.Controller.UserManager.Login("adm", "123", p =>
            {
                if (ftpOpenTask.IsCanceled)
                {
                    return;
                }
                if (p.IsSuccessed)
                {
                    DataGate.Log.Info("Logon successed.");



                    this.picSuccess.Image            = Resources.Resource.GetImage(Resources.Resource.Images.Pass);
                    System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
                    timer.Tick    += new EventHandler(timer_tick2);
                    timer.Interval = 200;
                    timer.Start();
                    Thread.Sleep(1000);
                    this.Result = true;
                    if (IsTreeList)
                    {
                        int h       = sign.Height;
                        int w       = sign.Width;
                        sign.Height = 10000;
                        sign.Width  = 10000;
                        LocalMessageBus.Send(this, new DataChangedMessage(PWDataType.Dashboard));
                        LocalMessageBus.Send(this, new ActiveChange(sign, false));

                        sign.Height = h;
                        sign.Width  = w;

                        ControlService.DashboardTree.DashboardTreeList.Cursor = Cursors.Default;
                        ControlService.DashboardTree.PopulateTree();
                        ControlService.DashboardTree.DashboardTreeList.FocusedNode = ControlService.DashboardTree.DashboardTreeList.FindNodeByFieldValue("Name", sign.Name);
                        var focusedNode = ControlService.DashboardTree.DashboardTreeList.FindNodeByFieldValue("Name", sign.Name);
                        if (focusedNode != null)
                        {
                            focusedNode.ImageIndex = 2;
                        }
                        ControlService.SignCombo.Current = sign;
                        ActionHelper.OnAfterLogin(sign.Controller.Connection.User);
                    }

                    //Close();
                }
                else
                {
                    DataGate.Log.Error("Logon failed.");
                    Result                = false;
                    picError.Visible      = true;
                    lblError.Visible      = true;
                    this.btnRetry.Enabled = true;
                    this.Cursor           = Cursors.Default;

                    Action successCallback = null;
                    Action failCallback    = null;
                    var action             = new LogoffAction(sign, successCallback, failCallback, false);
                    action.Perform();
                    OnLoginFailed(p.Packet);
                }
                connStatus = null;
            });
            if (IsTreeList)
            {
                ControlService.DashboardTree.DashboardTreeList.Cursor = Cursors.Default;
            }
        }