public void GetListBiz_Should_CreateListBizInstance() { // Arrange var listId = Guid.Empty; ShimListBiz.ConstructorGuidGuid = (_, list, site) => { listId = list; }; // Act var result = reportBiz.GetListBiz(DummyGuid); // Assert result.ShouldSatisfyAllConditions( () => result.ShouldNotBeNull(), () => listId.ShouldBe(DummyGuid)); }
private bool DeleteList(SPListEventProperties properties) { bool isSuccessful = true; var reportBiz = new ReportBiz(properties.SiteId); Guid listId = properties.ListId; var DAO = new EPMData(properties.SiteId); DAO.Command = "SELECT TableName FROM RPTList WHERE RPTListID=@RPTListID"; DAO.AddParam("@RPTListID", listId); string sTableName = string.Empty; try { sTableName = DAO.ExecuteScalar(DAO.GetClientReportingConnection).ToString(); DataTable refTables = reportBiz.GetReferencingTables(DAO, sTableName); if (refTables.Rows.Count == 0) { reportBiz.GetListBiz(listId).Delete(); } else { isSuccessful = false; DAO.LogStatus(listId.ToString(), sTableName, "Database table delete attempt: Unable to delete " + sTableName + ".", sTableName + " is referenced by other tables.", 2, 5, Guid.NewGuid().ToString()); //Logged in the RefreshAll event log. } } catch (Exception ex) { DAO.LogStatus(listId.ToString(), sTableName, "Database table delete attempt: Unable to delete " + sTableName + ". " + ex.Message, ex.StackTrace, 2, 5, Guid.NewGuid().ToString()); //Logged in the RefreshAll event log. } reportBiz = null; DAO.Dispose(); return(isSuccessful); }
public void RaisePostBackEvent(string sAction) { string param = sAction.Remove(sAction.LastIndexOf("_")); sAction = sAction.Substring(sAction.LastIndexOf("_") + 1); switch (sAction) { case "cleanup": CleanupLists(param); break; case "snapshot": SnapshotLists(param); break; case "delete": var reportBiz = new ReportBiz(SPContext.Current.Site.ID, SPContext.Current.Web.ID, reportingV2Enabled); var listId = new Guid(param); _DAO.Command = "SELECT TableName FROM RPTList WHERE RPTListID=@RPTListID"; _DAO.AddParam("@RPTListID", param); string sTableName = _DAO.ExecuteScalar(_DAO.GetClientReportingConnection).ToString(); DataTable refTables = reportBiz.GetReferencingTables(_DAO, sTableName); if (refTables.Rows.Count == 0) { reportBiz.GetListBiz(new Guid(param)).Delete(); } else { SPUtility.Redirect("epmlive/ListMappings.aspx?delete=true&id=" + param + "&name=" + sTableName, SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current); } break; } SPUtility.Redirect("epmlive/ListMappings.aspx?", SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current); }
private void AddReport(SPList oList, int listParentMessageId) { if (bVerifyOnly) { addMessage(ErrorLevels.NoError, "Add to Reporting Database", string.Empty, listParentMessageId); } else { try { var reportingV2Enabled = false; try { reportingV2Enabled = Convert.ToBoolean(CoreFunctions.getConfigSetting(SPContext.Current.Site.RootWeb, "reportingV2")); } catch (Exception ex) { Trace.WriteLine(ex.ToString()); } var reportBiz = new ReportBiz(oList.ParentWeb.Site.ID, oList.ParentWeb.ID, reportingV2Enabled); var report = reportBiz.GetListBiz(oList.ID); if (string.IsNullOrEmpty(report.ListName)) { reportBiz.CreateListBiz(oList.ID); addMessage(ErrorLevels.NoError, "Add to Reporting Database", string.Empty, listParentMessageId); } } catch (Exception ex) { addMessage(ErrorLevels.Error, "Add to Reporting Database", ex.Message, listParentMessageId); Trace.WriteLine(ex.ToString()); } } }