Ejemplo n.º 1
0
 /// <summary>
 /// 发送登录完成事件
 /// </summary>
 public static void SendLogined(LoginDataV2Model data)
 {
     Logined?.Invoke(null, data);
 }
Ejemplo n.º 2
0
        private void Login()
        {
            string greeningURL = "http://10.1.1.163/greening2/shared";
            string moduleURL   = "http://10.1.1.163/modules/shared";

            XmlDocument doc      = new XmlDocument();
            string      filename = Path.Combine(Environment.CurrentDirectory, "Setup.config");

            this.ShowMessage("載入設定檔");

            if (File.Exists(filename))
            {
                doc.Load(filename);
                XmlHelper config = new XmlHelper(doc.DocumentElement);
                greeningURL = config.GetText("GreeningAccessPoint");
                moduleURL   = config.GetText("ModuleAccessPoint");
            }

            try
            {
                this.ShowMessage("登入 ischool ....");
                Connection greenCon = new Connection();
                greenCon.EnableSecureTunnel = true;
                greenCon.EnableSession      = false;
                try
                {
                    greenCon.Connect(greeningURL, "user", txtUser.Text.Trim(), txtPassword.Text);
                }
                catch (Exception ex)
                {
                    throw new Exception("ischool Account 認證失敗" + ex.Message);
                }

                Envelope rsp = greenCon.SendRequest("DS.Base.GetPassportToken", new Envelope());
                PassportSecurityToken stt = new PassportSecurityToken(rsp.Body.XmlString);

                XmlHelper h1 = new XmlHelper(rsp.Body);
                string    id = h1.GetText("Content/Attributes/ID");

                string     ftpUser     = string.Empty;
                string     ftpPassword = string.Empty;
                string     ftpUrl      = string.Empty;
                bool       succeedLoginModuleService = false;
                Connection modCon = null;
                try
                {
                    this.ShowMessage("載入線上儲存空間設定...");

                    modCon = new Connection();
                    modCon.EnableSession      = true;
                    modCon.EnableSecureTunnel = true;

                    modCon.Connect(moduleURL, "developer", stt);

                    Envelope  env = modCon.SendRequest("GetFTPInfo", new Envelope());
                    XmlHelper h   = new XmlHelper(env.Body);
                    ftpUser     = TripleDESHelper.Decrypt(h.GetText("User"), USE_KEY);
                    ftpPassword = TripleDESHelper.Decrypt(h.GetText("Password"), USE_KEY);
                    ftpUrl      = TripleDESHelper.Decrypt(h.GetText("FTP"), USE_KEY);
                    succeedLoginModuleService = true;
                }
                catch
                {
                    this.ShowMessage("載入失敗!");
                    succeedLoginModuleService = false;
                }
                string pwd = string.Empty;
                if (chkRemember.Checked)
                {
                    pwd = txtPassword.Text;
                }
                MainForm.Storage.SetPropertyValues("LoginName", txtUser.Text, pwd);
                MainForm.Storage.SetProperty("LastLoginName", txtUser.Text);
                MainForm.Storage.SetProperty("LastLoginPassword", pwd);
                MainForm.Storage.SetProperty("RememberPassword", chkRemember.Checked.ToString().ToLower());

                if (Logined != null)
                {
                    this.ShowMessage("登入開發站台...");
                    LoginEventArgs arg = new LoginEventArgs();
                    arg.FtpPassword        = ftpPassword;
                    arg.FtpUser            = ftpUser;
                    arg.FtpURL             = ftpUrl;
                    arg.GreeningConnection = greenCon;
                    arg.ModuleConnection   = modCon;
                    arg.SetModuleConnectionInfo(moduleURL);
                    arg.LoginUser          = txtUser.Text;
                    arg.GreeningID         = id;
                    arg.SucceedModuleLogin = succeedLoginModuleService;

                    this.ShowMessage("載入開發站台資訊");
                    Logined.Invoke(this, arg);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                this.ShowMessage("※請輸入 ischool Account 密碼");
            }
        }
Ejemplo n.º 3
0
 public static void Login(string token, User user)
 {
     Token = token;
     User  = user;
     Logined?.Invoke(user);
 }
Ejemplo n.º 4
0
 protected virtual void OnLogined()
 {
     Logined?.Invoke(this, EventArgs.Empty);
 }