예제 #1
0
파일: 登录.cs 프로젝트: lyc1359001996/hrb
 public void login()
 {
     if (ini.IniReadValue("mySqlCon2", "authorization").Equals("") && ini.IniReadValue("mySqlCon2", "authorization1").Equals(""))
     {
         var json = WebUtils.MakeRequest(ini.IniReadValue("mySqlCon1", "loginurl"), "{\"userAccount\":\"" + textEdit2.Text + "\",\"password\":\"" + textEdit1.Text + "\"}", "post", "http").Replace("\"", "").Replace("{", "").Replace("}", "");
         if (json.Split(',')[1].Split(':')[1].Equals("4"))
         {
             MessageBox.Show("帐户未激活");
         }
         else if (json.Split(',')[1].Split(':')[1].Equals("3"))
         {
             MessageBox.Show("账号或密码错误");
         }
         else if (json.Split(',')[1].Split(':')[1].Equals("0"))
         {
             ini.IniWriteValue("mySqlCon3", "merchantId", json.Split(',')[4].Replace("merchantId:", ""));
             ini.IniWriteValue("mySqlCon3", "storeId", json.Split(',')[5].Replace("storeId:", ""));
             ini.IniWriteValue("mySqlCon3", "userId", json.Split(',')[6].Replace("userId:", ""));
             ini.IniWriteValue("mySqlCon2", "authorization", json.Split(',')[3].Replace("data:authorization:", "").Substring(0, 66));
             ini.IniWriteValue("mySqlCon2", "authorization1", json.Split(',')[3].Replace("data:authorization:", "").Substring(66));
             Console.WriteLine(json.Split(',')[3].Replace("data:authorization:", "").Substring(0, 66) + json.Split(',')[3].Replace("data:authorization:", "").Substring(66));
             Console.WriteLine(json.Split(',')[3].Replace("data:authorization:", ""));
             var json1 = WebUtils.MakeRequest1(ini.IniReadValue("mySqlCon1", "StoreInfo"), "{\"userId\":" + json.Split(',')[6].Replace("userId:", "") + ",\"storeId\":" + json.Split(',')[5].Replace("storeId:", "") + "}", "post", "http", ini.IniReadValue("mySqlCon2", "authorization") + ini.IniReadValue("mySqlCon2", "authorization1"));
             ini.IniWriteValue("mySqlCon2", "username", textEdit2.Text);
             string[]  condition = { "}," };
             StoreName StoreName = ConvertJson.DeserializeJsonToObject <StoreName>(json1.Replace("{\"success\":true,\"errorCode\":0,\"msg\":\"success\",\"data\":[", "").Replace("]}", "").Split(condition, StringSplitOptions.RemoveEmptyEntries)[0] + "}");
             ini.IniWriteValue("mySqlCon3", "username", StoreName.userName);
             ini.IniWriteValue("mySqlCon3", "roleId", StoreName.roleId.ToString());
             ini.IniWriteValue("mySqlCon3", "storeName", StoreName.storeName);
             ini.IniWriteValue("mySqlCon3", "userAccount", StoreName.userAccount);
             Main main = new Main();
             this.Visible = false;
             UserInfo info = new UserInfo();
             info.Show();
             Thread.Sleep(2500);
             info.Dispose();
             main.Show();
         }
     }
 }