public static string GetKnowledgeBaseCategories(RestCommand command, bool orderByDateCreated = false) { KnowledgeBaseCategories categories = new KnowledgeBaseCategories(command.LoginUser); if (orderByDateCreated) { categories.LoadAllCategories(command.Organization.OrganizationID, "DateCreated DESC"); } else { categories.LoadAllCategories(command.Organization.OrganizationID); } return(categories.GetXml("KnowledgeBaseCategories", "KnowledgeBaseCategory", false, command.Filters)); }
private void ImportOrg(int orgID, LoginUser loginUser) { string existingImportID = GetImportID(orgID); if (!string.IsNullOrWhiteSpace(existingImportID)) { MessageBox.Show("This company has already been imported"); return; } try { _importID = orgID.ToString() + "-" + Guid.NewGuid().ToString(); _logs = new Logs(orgID.ToString() + " - Org.txt"); _usersAndContacts = new Users(loginUser); _usersAndContacts.LoadContactsAndUsers(orgID, false); _badProducts = new Products(GetCorrupteLoginUser()); _badProductVersions = new ProductVersions(GetCorrupteLoginUser()); _badGroups = new Groups(GetCorrupteLoginUser()); _badUsers = new Users(GetCorrupteLoginUser()); _badTicketTypes = new TicketTypes(GetCorrupteLoginUser()); _badTicketStatuses = new TicketStatuses(GetCorrupteLoginUser()); _badTicketSeverities = new TicketSeverities(GetCorrupteLoginUser()); _badTicketKBCategories = new KnowledgeBaseCategories(GetCorrupteLoginUser()); _badProducts.LoadByOrganizationID(orgID); _badProductVersions.LoadByParentOrganizationID(orgID); _badGroups.LoadByOrganizationID(orgID); _badUsers.LoadByOrganizationID(orgID, false); _badTicketTypes.LoadByOrganizationID(orgID); _badTicketStatuses.LoadByOrganizationID(orgID); _badTicketSeverities.LoadByOrganizationID(orgID); _badTicketKBCategories.LoadCategories(orgID); _goodProducts = new Products(loginUser); _goodProductVersions = new ProductVersions(loginUser); _goodGroups = new Groups(loginUser); _goodUsers = new Users(loginUser); _goodTicketTypes = new TicketTypes(loginUser); _goodTicketStatuses = new TicketStatuses(loginUser); _goodTicketSeverities = new TicketSeverities(loginUser); _goodTicketKBCategories = new KnowledgeBaseCategories(loginUser); _goodProducts.LoadByOrganizationID(orgID); _goodProductVersions.LoadByParentOrganizationID(orgID); _goodGroups.LoadByOrganizationID(orgID); _goodUsers.LoadByOrganizationID(orgID, false); _goodTicketTypes.LoadByOrganizationID(orgID); _goodTicketStatuses.LoadByOrganizationID(orgID); _goodTicketSeverities.LoadByOrganizationID(orgID); _goodTicketKBCategories.LoadCategories(orgID); _exceptionOcurred = false; if (cbCompanies.Checked) { RecoverCompanies(orgID, loginUser); } //RecoverContacts(orgID); if (cbProducts.Checked) { RecoverProducts(orgID, loginUser); } // RecoverAssets(orgID); if (cbOldActions.Checked) { RecoverActionsFromOldTickets(orgID, loginUser); } if (cbTickets.Checked) { RecoverTickets(orgID, loginUser); } if (_exceptionOcurred) { SaveOrgResults(orgID, "Finished with exceptions", _importID); } else { SaveOrgResults(orgID, "Success", _importID); } SqlExecutor.ExecuteNonQuery(loginUser, "update organizations set LastIndexRebuilt='1/1/2000' where OrganizationID=" + orgID.ToString()); MessageBox.Show("Import Complete"); } catch (Exception ex) { SaveOrgResults(orgID, "Failure: " + ex.Message, _importID); ExceptionLogs.LogException(GetCorrupteLoginUser(), ex, "recover"); } }