private Entity GetEntityForDomainByLinkAndUsernameAndPassword(int link, string username, string password) { using (ExecutorClient client = new ExecutorClient()) { string domain = ((Entity)client.Execute("Link", "GetEntityByField", new object[] { "Unique", link, "=" })).GetValue("Value").ToString(); try { if ((new PrincipalContext(ContextType.Domain, domain)).ValidateCredentials(username, password) == true) { Entity filter = Helper.Deserialize("{\"Value\": \"" + username + "\", \"Link\": " + link.ToString() + "}"); Entity connector = Helper.Deserialize("{\"Value\": \"=\", \"Link\": \"=\"}"); EntityCollection verificates = (EntityCollection)client.Execute("Verificate", "GetEntitiesByFilter", new object[] { filter, connector }); if (verificates.Count == 0) { return(Helper.GetEntity(false, "该用户未在本系统授权!", "Link")); } else { return(Helper.GetEntity(true, "登录成功!", this.GetTokenByLinkAndUsernameAndPassword(link, username, password))); } } else { return(Helper.GetEntity(false, "用户名/密码错误,请重新登录!", "Id")); } } catch (Exception exception) { return(Helper.GetEntity(false, exception.Message)); } } }
private Entity GetTokenByLinkAndIdAndPassword(int link, string id, string password) { using (ExecutorClient client = new ExecutorClient()) { Entity account = (Entity)client.Execute("Account", "GetEntityByField", new object[] { "Id", id, "=" }); if (account.IsEmpty == true) { return(Helper.GetEntity(false, "该用户名不存在!", "Id")); } Entity filter = Helper.Deserialize("{\"Account\": " + account.GetValue("Unique").ToString() + ", \"Link\": " + link.ToString() + "}"); Entity connector = Helper.Deserialize("{\"Account\": \"=\", \"Link\": \"=\"}"); EntityCollection verificates = (EntityCollection)client.Execute("Verificate", "GetEntitiesByFilter", new object[] { filter, connector }); if (verificates.Count == 0) { return(Helper.GetEntity(false, "该用户不支持该登录方式!", "Link")); } if (verificates[0].GetValue("Value").ToString() != password) { return(Helper.GetEntity(false, "密码错误!", "Password")); } EntityCollection functions = (EntityCollection)client.Execute("Act", "GetEntitiesWithFunctionByAccount", new object[] { account.GetValue("Unique").ToInt32() }); return(this.GetToken(account, verificates[0], functions)); } }
private Entity GetTokenForDomainByLinkAndUsernameAndPassword(int link, string username, string password) { using (ExecutorClient client = new ExecutorClient()) { string domain = ((Entity)client.Execute("Link", "GetEntityByField", new object[] { "Unique", link, "=" })).GetValue("Value").ToString(); if ((new PrincipalContext(ContextType.Domain, domain)).ValidateCredentials(username, password) == true) { Entity filter = Helper.Deserialize("{\"Value\": \"" + username + "\", \"Link\": " + link.ToString() + "}"); Entity connector = Helper.Deserialize("{\"Value\": \"=\", \"Link\": \"=\"}"); EntityCollection verificates = (EntityCollection)client.Execute("Verificate", "GetEntitiesByFilter", new object[] { filter, connector }); if (verificates.Count == 0) { return(Helper.GetEntity(false, "该用户未在本系统授权!", "Link")); } Entity account = (Entity)client.Execute("Account", "GetEntityByField", new object[] { "Unique", verificates[0].GetValue("Account").ToString(), "=" }); EntityCollection functions = (EntityCollection)client.Execute("Act", "GetEntitiesWithFunctionByAccount", new object[] { account.GetValue("Unique").ToInt32() }); return(this.GetToken(account, verificates[0], functions)); } else { return(Helper.GetEntity(false, "用户名/密码错误!", "Id")); } } }
private Entity GetTokenByLinkAndUsernameAndPassword(int link, string username, string password) { using (ExecutorClient client = new ExecutorClient()) { return((Entity)client.Execute("Token", "GetTokenByLinkAndUsernameAndPassword", new object[] { link, username, password })); } }
public void Update(string unique, Entity entity) { ExecutorClient client = new ExecutorClient(); client.Endpoint.Behaviors.Add(new WebHttpBehavior()); client.Execute("Exchange.Single", "Update", new object[] { unique, entity }); client.Close(); }
public MessageHelper() { this._PropertyCollection.Add(new SimpleProperty("Supplier", typeof(string))); this._PropertyCollection.Add(new SimpleProperty("Tree", typeof(string))); this._PropertyCollection.Add(new SimpleProperty("Make", typeof(Nullable <DateTime>))); this._PropertyCollection.Add(new SimpleProperty("Area", typeof(string))); this._PropertyCollection.Add(new SimpleProperty("Origin", typeof(string))); this._PropertyCollection.Add(new SimpleProperty("License", typeof(string))); this._PropertyCollection.Add(new SimpleProperty("Driver", typeof(string))); this._PropertyCollection.Add(new SimpleProperty("Ship", typeof(Nullable <DateTime>))); this._PropertyCollection.Add(new SimpleProperty("Line", typeof(string))); using (ExecutorClient client = new ExecutorClient()) { this._GsmOrigins = client.Execute("GsmOrigin", "GetEntitiesWithAreaNameByStartAndLength", new object[] { 1, int.MaxValue }) as EntityCollection; this._GsmLines = client.Execute("GsmLine", "GetEntities", new object[0]) as EntityCollection; this._GsmSuppliers = client.Execute("GsmSupplier", "GetEntities", new object[0]) as EntityCollection; this._GsmTrees = client.Execute("GsmTree", "GetEntities", new object[0]) as EntityCollection; } }
public bool Load() { if (this.Request.QueryString["Token"] == null) { return(this.Redirect()); } Entity entity; if (this.Request.QueryString["Token"] != null) { string token = this.Request.QueryString["Token"].ToString(); try { string oldEntity = this.Request.Cookies[token].ToString(); entity = Helper.Deserialize(oldEntity); this.Session["Token"] = entity; } catch { using (ExecutorClient client = new ExecutorClient()) { entity = (Entity)client.Execute("Token", "CheckToken", new object[] { token }); if (entity.PropertyCollection.IndexOf("Success") != -1) { return(this.Redirect()); } if (this._No != "Index") { if (((EntityCollection)entity.GetValue("Functions")).GetEntityCollection("No", this._No).Count == 0) { return(this.Redirect()); } } AddCookie("Token", entity.Serialize(entity), 60 * 8, this._No); this.Session["Token"] = entity; } } } Entity account = (Entity)((Entity)this.Session["Token"]).GetValue("Account"); this.SetAccount(account); return(true); }
private void Zhhwy_DataReceived(object sender, EventArgs e) { Entity result = (Entity)sender; string date = result.GetValue("Date").ToDateTime().ToString("yyyy-MM-dd HH:mm:ss"); string mobile = result.GetValue("Mobile").ToString(); string text = result.GetValue("Text").ToString(); Entity entity = new Entity(this._PropertyCollection); entity.SetValue("Unique", string.Empty); entity.SetValue("Parent", string.Empty); entity.SetValue("Mobile", mobile); entity.SetValue("Text", text); entity.SetValue("Date", date); entity.SetValue("Remark", string.Empty); entity.SetValue("Status", 0); entity.SetValue("Operator", Program.Account); ExecutorClient client = new ExecutorClient(); client.Endpoint.Behaviors.Add(new WebHttpBehavior()); int length = text.Length; for (int i = 0; i < length - 1; i++) { try { client.Execute("GsmMessage", "SaveEntity", new object[] { entity }); break; } catch { if (i == length - 1) { entity.SetValue("Text", "(全部是乱码)"); } else { entity.SetValue("Text", text.Substring(0, length - i - 1)); } } } client.Close(); if (this.DataReceived != null) { this.DataReceived(sender, e); } }
private void Logon_Load(object sender, EventArgs e) { ExecutorClient client = new ExecutorClient(); client.Endpoint.Behaviors.Add(new WebHttpBehavior()); EntityCollection collection = (EntityCollection)client.Execute("Link", "GetEntities", new object[] { }); client.Close(); for (int i = 0; i < collection.Count; i++) { this.ddlLink.Items.Add(new ListItem(collection[i].GetValue("Name").ToString(), collection[i].GetValue("Unique").ToString())); } this.ddlLink.SelectedIndex = 0; }
private void btnLogon_Click(object sender, EventArgs e) { if (this.txtUsername.Text.Trim() == string.Empty) { MessageBox.Show("用户名不能为空!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.txtUsername.Focus(); return; } if (this.txtPassword.Text.Trim() == string.Empty) { MessageBox.Show("密码不能为空!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.txtPassword.Focus(); return; } ExecutorClient client = new ExecutorClient(); client.Endpoint.Behaviors.Add(new WebHttpBehavior()); Entity entity = (Entity)client.Execute("Verificate", "GetEntityByLinkAndUsernameAndPassword", new object[] { ((ListItem)this.ddlLink.SelectedItem).Value.ToInt32(), this.txtUsername.Text, this.txtPassword.Text }); client.Close(); if (entity.GetValue("Success").ToBoolean() == false) { MessageBox.Show(entity.GetValue("Message").ToString(), "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error); if (entity.GetValue("Value").ToString() == "Id" || entity.GetValue("Value").ToString() == "Link") { this.txtUsername.Text = string.Empty; this.txtPassword.Text = string.Empty; this.txtUsername.Focus(); } else { this.txtPassword.Text = string.Empty; this.txtPassword.Focus(); } return; } Entity account = (Entity)((Entity)entity.GetValue("Value")).GetValue("Account"); Program.Account = account.GetValue("Unique").ToInt32(); this.DialogResult = DialogResult.OK; }
public Entity GetEntityByLinkAndUsernameAndPassword(int link, string username, string password) { using (ExecutorClient client = new ExecutorClient()) { int type = ((Entity)client.Execute("Link", "GetEntityByField", new object[] { "Unique", link, "=" })).GetValue("Type").ToInt32(); if (type == 0) { return(this.GetEntityByLinkAndIdAndPassword(link, username, password)); } else if (type == 1) { return(this.GetEntityForUrlByLinkAndUsernameAndPassword(link, username, password)); } else { return(this.GetEntityForDomainByLinkAndUsernameAndPassword(link, username, password)); } } }