1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using CCWin;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace MOKA_Factory_Tools
- {
- public partial class SanhuaMES : Skin_Color
- {
- public SanhuaMES()
- {
- InitializeComponent();
- }
- private void SanhuaMES_Load(object sender, EventArgs e)
- {
- Text_MES_URL.Text = SanhuaMethod.sanhuaLoginInfo.url;
- Text_StaffCode.Text = SanhuaMethod.sanhuaLoginInfo.staffCode;
- Text_ResuorceCode.Text = SanhuaMethod.sanhuaLoginInfo.resourceCode;
- Text_MES_Password.Text = SanhuaMethod.sanhuaLoginInfo.password;
- Text_JigEdtion.Text = SanhuaMethod.sanhuaLoginInfo.jigEdtion;
- }
- private void Btn_MES_Login_Click(object sender, EventArgs e)
- {
- SanhuaMethod.sanhuaLoginInfo.url = Text_MES_URL.Text;
- SanhuaMethod.sanhuaLoginInfo.staffCode = Text_StaffCode.Text;
- SanhuaMethod.sanhuaLoginInfo.resourceCode = Text_ResuorceCode.Text;
- SanhuaMethod.sanhuaLoginInfo.password = Text_MES_Password.Text;
- SanhuaMethod.sanhuaLoginInfo.jigEdtion = Text_JigEdtion.Text;
- if ( SanhuaMethod.sanhuaLoginInfo.url.EndsWith("/") )
- {
- SanhuaMethod.sanhuaLoginInfo.url = SanhuaMethod.sanhuaLoginInfo.url.Replace("/", "");
- }
- SaveLoginInfo();
- if ( SanhuaMethod.CheckLogin(SanhuaMethod.sanhuaLoginInfo.url) )
- {
- DialogResult = DialogResult.OK;
- }
- else
- {
- MessageBox.Show("登录失败,原因请查看日志");
- DialogResult = DialogResult.Cancel;
- }
- }
- private void SaveLoginInfo()
- {
- JObject jObject;
- using (StreamReader file = File.OpenText(LocalPath.localpath + "\\Config.json"))
- {
- using (JsonTextReader reader = new JsonTextReader(file))
- {
- jObject = (JObject)JToken.ReadFrom(reader);
- reader.Close();
- if (jObject["SanhuaLoginInfo"] == null)
- {
- JObject item = new JObject();
- item.Add("url", SanhuaMethod.sanhuaLoginInfo.url);
- item.Add("staffCode", SanhuaMethod.sanhuaLoginInfo.staffCode);
- item.Add("resourceCode", SanhuaMethod.sanhuaLoginInfo.resourceCode);
- item.Add("password", SanhuaMethod.sanhuaLoginInfo.password);
- item.Add("jigEdtion", SanhuaMethod.sanhuaLoginInfo.jigEdtion);
- jObject.Add("SanhuaLoginInfo", item);
- }
- else
- {
- jObject["SanhuaLoginInfo"]["url"] = SanhuaMethod.sanhuaLoginInfo.url;
- jObject["SanhuaLoginInfo"]["staffCode"] = SanhuaMethod.sanhuaLoginInfo.staffCode;
- jObject["SanhuaLoginInfo"]["resourceCode"] = SanhuaMethod.sanhuaLoginInfo.resourceCode;
- jObject["SanhuaLoginInfo"]["password"] = SanhuaMethod.sanhuaLoginInfo.password;
- jObject["SanhuaLoginInfo"]["jigEdtion"] = SanhuaMethod.sanhuaLoginInfo.jigEdtion;
- }
- }
- }
- using (StreamWriter writer = new StreamWriter(LocalPath.localpath + "\\Config.json"))
- {
- writer.Write(jObject.ToString());
- }
- }
- }
- }
|