Exemplo n.º 1
0
        private new void Update()
        {
            this.progressBar1.Maximum = this.lisUpdateFile.Items.Count;
            bool          blnDownload = true;
            DirectoryInfo directory   = new DirectoryInfo(updatefolder);

            if (!directory.Exists)
            {
                directory.Create();
            }
            string            key    = "";
            PMLoginSoapClient client = new PMLoginSoapClient();

            foreach (object name in this.lisUpdateFile.Items)
            {
                try
                {
                    byte[]     content    = Convert.FromBase64String(client.Update(name.ToString()));
                    FileStream fileStream = File.Create(updatefolder + "/" + name.ToString());
                    fileStream.Write(content, 0, content.Length);
                    fileStream.Close();
                }
                catch
                {
                    blnDownload = false;
                    break;
                }
                ++this.progressBar1.Value;
            }
            this.Invoke(blnDownload ? new MethodInvoker(UpdateSuccessful) : new MethodInvoker(UpdateFailure));
        }
Exemplo n.º 2
0
        private void Login()
        {
            if (string.IsNullOrEmpty(txtBoxUserName.Text))
            {
                MessageBox.Show(Properties.Resources.frmLogin_Login_Username_is_required, "Login");
                txtBoxUserName.Focus();
                return;
            }
            if (string.IsNullOrEmpty(txtBoxPassword.Text))
            {
                MessageBox.Show(Properties.Resources.frmLogin_Login_Password_is_required, "Login");
                txtBoxPassword.Focus();
                return;
            }

            pBtnLogin.BeginInvoke(new InvokeDelegate(WaitingCursor));

            string            id = string.Empty;
            PMLoginSoapClient pMLoginSoapClient = new PMLoginSoapClient();

            try
            {
                string result = pMLoginSoapClient.Login(
                    DESEncrypt.Encrypt(UserName),
                    DESEncrypt.Encrypt(Password),
                    isRemember,
                    out id);
                onLogin(result, id, UserName, Password, isRemember);

                CancelWaiting();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }