public CalOrg AddOrg(string orgName) { foreach (var item in RootOrgs) { if (item.OrgName == orgName) { System.Windows.Forms.MessageBox.Show("相同目录下已有此组织:" + orgName); break; } } CalOrg org = new CalOrg(); org.EID = Guid.NewGuid().ToString(); org.OrgName = orgName; org.MyModel = this; AllCalOrgs.Add(org); RootOrgs.Add(org); return(org); }
public void RemoveOrg(CalOrg org) { this.ChildCalOrgs.Remove(org); org.MyModel.AllCalOrgs.Remove(org); }
public CalTag GetTag(string tagName) { string shortTagName = tagName; CalOrg myOrg = null; if (tagName.Contains(".")) { string[] items = tagName.Split('.'); for (int i = 0; i < items.Length - 1; i++) { if (myOrg == null) { foreach (var org in this.RootOrgs) { if (org.OrgName == items[i]) { myOrg = org; break; } } } else { foreach (var org in myOrg.ChildCalOrgs) { if (org.OrgName == items[i]) { myOrg = org; break; } } } } shortTagName = items[items.Length - 1]; } CalTag result = null; if (myOrg == null) { foreach (var item in this.RootTags) { if (item.TagName == shortTagName) { result = item; break; } } //if (result == null) // result = this.AddTag(shortTagName); } else { foreach (var item in myOrg.CalTags) { if (item.TagName == shortTagName) { result = item; break; } } //if (result == null) // result = myOrg.AddTag(shortTagName); } return(result); }
public void RemoveOrg(CalOrg org) { RootOrgs.Remove(org); AllCalOrgs.Remove(org); }