public ActionResult CreateGroupTemplate(Guid id) { try { LcpsAdsGroup ou = new LcpsAdsGroup(id); GroupTemplate t = new GroupTemplate(); t.GroupId = id; t.TemplateName = ou.Name; if (string.IsNullOrEmpty(ou.Description)) t.Description = "No aescription available"; else t.Description = ou.Description; DbContext.GroupTemplates.Add(t); DbContext.SaveChanges(); return Content("Success", "text/html"); } catch (Exception ex) { AnvilExceptionCollector ec = new AnvilExceptionCollector(ex); return Content(ec.ToUL(), "text/html"); } }
public ActionResult CreateOuTemplate(Guid id) { try { LcpsAdsOu ou = new LcpsAdsOu(id); OUTemplate t = new OUTemplate(); t.OUId = id; t.TemplateName = ou.Name; t.Description = ou.Description; DbContext.OUTemplates.Add(t); DbContext.SaveChanges(); return Content("Success", "text/html"); } catch (Exception ex) { AnvilExceptionCollector ec = new AnvilExceptionCollector(ex); return Content(ec.ToUL(), "text/html"); } }
public ActionResult GetShares(string server) { string result = ""; try { SharedFolderTree n = new SharedFolderTree(server); n.Recursive = false; n.Refresh(); result = "<div class='tree'>" + n.ToUL() + "</div>"; } catch(Exception ex) { AnvilExceptionCollector ec = new AnvilExceptionCollector(ex); result = ec.ToUL(); } return Content(result); }
public ActionResult RelocateComputer(string b, string r, string u, string n) { string result = "Success"; try { if (String.IsNullOrEmpty(b)) throw new Exception("Building ID is required"); if (String.IsNullOrEmpty(r)) throw new Exception("Room ID is required"); if (String.IsNullOrEmpty(u)) throw new Exception("Unit Number is required"); if (String.IsNullOrEmpty(n)) throw new Exception("Computer Name is required"); ApplicationBase app = LcpsDbContext.DefaultApp; string un = string.Format("{0}\\{1}", app.LDAPDomain, app.LDAPUserName); RemoteComputer c = new RemoteComputer(n, un, app.LDAPPassword); c.Refresh(); ComputerInfo info = c.ToComputerInfo(); info.BuildingId = new Guid(b); info.RoomId = new Guid(r); info.UnitNumber = u.PadLeft(3, '0'); c.DBAcrchive(info, User.Identity.Name); info.UpdateLDAP(); } catch (Exception ex) { AnvilExceptionCollector ec = new AnvilExceptionCollector(ex); result = ec.ToUL(); } return Content(result); }
public ActionResult LookupComputer(string name) { string result = "Success"; try { if (String.IsNullOrEmpty(name)) throw new Exception("Please supply a computer name to search for"); ApplicationBase app = LcpsDbContext.DefaultApp; string un = string.Format("{0}\\{1}", app.LDAPDomain, app.LDAPUserName); RemoteComputer c = new RemoteComputer(name, un, app.LDAPPassword); c.Refresh(); } catch(Exception ex) { AnvilExceptionCollector ec = new AnvilExceptionCollector(ex); result = ec.ToUL(); } return Content(result); }
public ActionResult DeleteOUTemplate(Guid id) { string result = "The template was successfully deleted"; try { OUTemplate t = DbContext.OUTemplates.Find(id); List<StaffFilterClause> stf = DbContext.StaffFilterClauses.Where(x => x.FilterId.Equals(t.OUId)).ToList(); List<StudentFilterClause> stu = DbContext.StudentFilterClauses.Where(x => x.FilterId.Equals(t.OUId)).ToList(); DbContext.StaffFilterClauses.RemoveRange(stf); DbContext.StudentFilterClauses.RemoveRange(stu); DbContext.OUTemplates.Remove(t); DbContext.SaveChanges(); } catch (Exception ex) { AnvilExceptionCollector ec = new AnvilExceptionCollector(ex); result = ec.ToUL(); } return Content(result, "text/html"); }
public ActionResult DeleteStaffFilterClause(Guid id) { string result = "Success"; try { StaffFilterClause c = db.StaffFilterClauses.Find(id); db.StaffFilterClauses.Remove(c); db.SaveChanges(); } catch (Exception ex) { AnvilExceptionCollector ec = new AnvilExceptionCollector(ex); result = ec.ToUL(); } return Content(result, "text/html"); }
private void CreateUl(AnvilTreeNode n, ref string output) { if (n.ItemError == null) { bool IsParent = (n.Children.Count() > 0); if (IsParent) { output += "<li><span style='margin-right: 8px;' selectedGlyph='" + n.SelectedItemGlyphCss + "' normalGlyph='" + n.ItemGlyphCss + "'><i class='" + n.InitGlyph + "'></i></span><a value='" + n.Value + "' class='" + n.LinkClass + "'>" + n.Text + "</a>\n"; output += "<ul>\n"; foreach (AnvilTreeNode child in n.Children) { CreateUl(child, ref output); } output += "</ul></li>\n"; } else { output += "<li><span style='margin-right: 8px;' selectedGlyph='" + n.SelectedItemGlyphCss + "' normalGlyph='" + n.ItemGlyphCss + "'><i class='" + n.InitGlyph + "'></i></span><a value='" + n.Value + "' class='" + n.LinkClass + "'>" + n.Text + "</a></li>\n"; } } else { AnvilExceptionCollector ec = new AnvilExceptionCollector(ItemError); string result = "<li class='text-danger'>"; result += ec.ToUL() + "</li>\n"; output += result; } }