Beispiel #1
0
        private void button1_Click(object sender, RibbonControlEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Multiselect = true;//该值确定是否可以选择多个文件
            dialog.Title       = "请选择文件";
            dialog.Filter      = "所有文件(*.*)|*.*";
            string fileName = "";

            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                fileName = dialog.FileName;
                string url = "{0}/ppttools/pptdata/save?token={1}";
                url = String.Format(url, Rigel.ServerUrl, Rigel.UserToken);
                ProgressWidget pro = new ProgressWidget();
                pro.Show();
                pro.SetInfoText("正在上传,请稍后···");
                pro.Show();
                string resultStr = Request.UploadFilesToRemoteUrl(url, fileName);
                pro.Hide();
                JObject jObject = JObject.Parse(resultStr);

                if (jObject.Value <String>("code").Equals("200"))
                {
                    PromptBox.Prompt("数据上传成功!");
                }
                else
                {
                    PromptBox.Error("上传失败:" + jObject.Value <String>("msg"));
                }
            }
        }
        private async void button_identCode_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(lineEdit_account.Text))
            {
                try
                {
                    if (!IsHandset(lineEdit_account.Text))
                    {
                        errorProvider.ErrorAlignment = ErrorAlignment.Top;
                        errorProvider.SetError(account_Layout, "手机号格式错误");
                        return;
                    }

                    int userFlag = await RequestHandle.SendIdentCode(lineEdit_account.Text);

                    button_identCode.Enabled = false;
                    m_TotalTime = 0;
                    m_timer.Start();
                    button_identCode.BackgroundImage = Properties.Resources.nor_btn;
                    if (userFlag == 0)//未注册
                    {
                        invite_Layout.Visible = true;
                    }
                    else if (userFlag == 1)
                    {
                        //none
                    }
                    else//2 出错
                    {
                        errorProvider.ErrorAlignment = ErrorAlignment.Top;
                        errorProvider.SetError(account_Layout, "手机号输入错误");
                        return;
                    }
                }
                catch (Exception ex)
                {
                    PromptBox.Error(ex.Message);
                }
            }
            else
            {
                errorProvider.ErrorAlignment = ErrorAlignment.Top;
                errorProvider.SetError(account_Layout, "请输入手机号");
            }
        }
Beispiel #3
0
        private async void button_login_Click(object sender, RibbonControlEventArgs e)
        {
            DialogResult result = DialogResult.None;

            if (String.IsNullOrEmpty(Rigel.UserID))
            {
                LoginWidget loginWidget = new LoginWidget();
                result = loginWidget.ShowDialog();
                if (result == DialogResult.OK)
                {
                    if (String.IsNullOrEmpty(Rigel.UserID))
                    {
                        PromptBox.Error("登录失败!");
                        return;
                    }
                    else
                    {
                        Regditer.WriteReg(Regditer.RootKey.CurrentUser, Rigel.UserRegKey,
                                          StrUserName, Rigel.UserName);
                        Regditer.WriteReg(Regditer.RootKey.CurrentUser, Rigel.UserRegKey,
                                          StrUserToken, Rigel.UserToken);
                        button_login.Label = Rigel.UserName;
                        button_login.Image = Properties.Resources.Login;
                        ResetButtonEnable(true);
                    }
                }
            }
            else
            {
                result = PromptBox.Prompt("确认退出登录?");
                if (result == DialogResult.OK)
                {
                    await RequestHandle.Logout(Rigel.UserName);

                    Rigel.UserID    = "";
                    Rigel.UserToken = "";
                    Regditer.WriteReg(Regditer.RootKey.CurrentUser, Rigel.UserRegKey,
                                      StrUserToken, String.Empty);
                    button_login.Label = "登录\r\n";
                    button_login.Image = Properties.Resources.Logout;
                    Globals.ThisAddIn.TaskWidget.Visible = false;
                    ResetButtonEnable(false);
                }
            }
        }
        private async void button_login_Click(object sender, EventArgs e)
        {
            String strAccount = "";
            String identCode  = "";
            String inviteCode = "";

            if (string.IsNullOrEmpty(lineEdit_account.Text))
            {
                errorProvider.ErrorAlignment = ErrorAlignment.Top;
                errorProvider.SetError(account_Layout, "手机号为空");
                return;
            }

            if (string.IsNullOrEmpty(lineEdit_identCode.Text))
            {
                errorProvider.ErrorAlignment = ErrorAlignment.Top;
                errorProvider.SetError(ident_Layout, "验证码为空");
                return;
            }
            strAccount = lineEdit_account.Text;
            identCode  = lineEdit_identCode.Text;
            inviteCode = lineEdit_inviteCode.Text;
            try
            {
                bool isLogin = await RequestHandle.Login(strAccount, identCode, inviteCode);

                if (isLogin)
                {
                    DialogResult = DialogResult.OK;
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                PromptBox.Error(ex.Message);
            }
        }