public ActionResult Create([Bind(Include = "Id,ConcurrencyKey,ReportName,CreatedOn,ReportType,CreatedByUserID,Description,EntityName,ResultProperty,ColumnOrder,OrderBy,GroupBy,CrossTabRow,CrossTabColumn,AggregateEntity,AggregateProperty,AggregateFunction,FilterProperty,FilterCondition,FilterType,FilterValue,SelectValueFromList,SelectProperty,RelatedEntity,ForeignKeyEntity,RelationName,EntityValues,CrossTabPropertyValues,QueryConditionValues,RelationsValues,OtherValues")] CustomReports customreports, string UrlReferrer, bool?IsDDAdd) { ViewBagForReports(); if (ModelState.IsValid) { string command = Request.Form["hdncommand"]; db.CustomReportss.Add(customreports); db.SaveChanges(); if (command == "Create & Continue") { return(RedirectToAction("Edit", new { Id = customreports.Id, UrlReferrer = UrlReferrer })); } if (!string.IsNullOrEmpty(UrlReferrer)) { return(Redirect(UrlReferrer)); } else { return(RedirectToAction("Index")); } } if (IsDDAdd != null) { ViewBag.IsDDAdd = Convert.ToBoolean(IsDDAdd); } LoadViewDataAfterOnCreate(customreports); return(View(customreports)); }
public void AddTest() { VerifyDoesntExist(); bool value = CustomReports.Add(_databasePath, _crReportName, _crSql, out _errOut); General.HasTrueValue(value, _errOut); }
public ActionResult Edit([Bind(Include = "Id,ConcurrencyKey,ReportName,CreatedOn,ReportType,CreatedByUserID,Description,EntityName,ResultProperty,ColumnOrder,OrderBy,GroupBy,CrossTabRow,CrossTabColumn,AggregateEntity,AggregateProperty,AggregateFunction,FilterProperty,FilterCondition,FilterType,FilterValue,SelectValueFromList,SelectProperty,RelatedEntity,ForeignKeyEntity,RelationName,EntityValues,CrossTabPropertyValues,QueryConditionValues,RelationsValues,OtherValues")] CustomReports customreports, string UrlReferrer) { if (ModelState.IsValid) { string command = Request.Form["hdncommand"]; db.Entry(customreports).State = EntityState.Modified; db.SaveChanges(); if (command != "Save") { return(RedirectToAction("Edit", new { Id = customreports.Id, UrlReferrer = UrlReferrer })); } if (!string.IsNullOrEmpty(UrlReferrer)) { var uri = new Uri(UrlReferrer); var query = HttpUtility.ParseQueryString(uri.Query); if (Convert.ToBoolean(query.Get("IsFilter")) == true) { return(RedirectToAction("Index")); } else { return(Redirect(UrlReferrer)); } } else { return(RedirectToAction("Index")); } } LoadViewDataAfterOnEdit(customreports); return(View(customreports)); }
internal void LoadComponents() { // Get all the report components registered in our category foreach (var component in Categories.GetComponentElements("AcmeCustom_Reports")) { try { //access the content element var content = component.GetContent(); var version = content.Attribute("version").Value; //get the underlying report and test for the presence of //the contract var reportItem = component.CreateComponent() as IAcmeCustomReport; if (reportItem != null) { CustomReports.Add(reportItem); } } catch (Exception e) { //TODO handle exception as needed string x = e.Message; } } }
public ActionResult DeleteConfirmed(CustomReports customreports, string UrlReferrer) { if (!User.CanDelete("CustomReports")) { return(RedirectToAction("Index", "Error")); } if (CheckBeforeDelete(customreports)) { //Delete Document db.Entry(customreports).State = EntityState.Deleted; db.CustomReportss.Remove(customreports); db.SaveChanges(); if (!string.IsNullOrEmpty(UrlReferrer)) { return(Redirect(UrlReferrer)); } if (ViewData["CustomReportsParentUrl"] != null) { string parentUrl = ViewData["CustomReportsParentUrl"].ToString(); ViewData["CustomReportsParentUrl"] = null; return(Redirect(parentUrl)); } else { return(RedirectToAction("Index")); } } return(View(customreports)); }
// GET: /CustomReports/Edit/5 public ActionResult Edit(int?id, string UrlReferrer, string HostingEntityName, string AssociatedType, string defaultview) { if (!User.CanEdit("CustomReports")) { return(RedirectToAction("Index", "Error")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CustomReports customreports = db.CustomReportss.Find(id); if (customreports == null) { return(HttpNotFound()); } if (UrlReferrer != null) { ViewData["CustomReportsParentUrl"] = UrlReferrer; } if (ViewData["CustomReportsParentUrl"] == null && Request.UrlReferrer != null && !Request.UrlReferrer.AbsolutePath.EndsWith("/CustomReports") && !Request.UrlReferrer.AbsolutePath.EndsWith("/CustomReports/Edit/" + customreports.Id + "") && !Request.UrlReferrer.AbsolutePath.EndsWith("/CustomReports/Create")) { ViewData["CustomReportsParentUrl"] = Request.UrlReferrer; } ViewData["HostingEntityName"] = HostingEntityName; ViewData["AssociatedType"] = AssociatedType; LoadViewDataBeforeOnEdit(customreports); ViewBagForReportsEdit(customreports); ViewBag.CustomReportsIsHiddenRule = checkHidden("CustomReports", "OnEdit"); return(View(customreports)); }
public void HasSavedReportsTest() { VerifyExists(); bool value = CustomReports.HasSavedReports(_databasePath, out _errOut); General.HasTrueValue(value, _errOut); }
/// <summary> /// Verifies the exists. /// </summary> private void VerifyExists() { if (!CustomReports.Exists(_databasePath, _crReportName, out _errOut)) { CustomReports.Add(_databasePath, _crReportName, _crSql, out _errOut); } }
public void ListTest() { VerifyExists(); List <CustomReportsLists> value = CustomReports.List(_databasePath, out _errOut); PrintList(value); General.HasTrueValue(value.Count > 0, _errOut); }
public void DeleteTest() { VerifyExists(); long id = CustomReports.GetId(_databasePath, _crReportName, out _errOut); bool value = CustomReports.Delete(_databasePath, id, out _errOut); General.HasTrueValue(value, _errOut); }
public void GetId() { VerifyExists(); long value = CustomReports.GetId(_databasePath, _crReportName, out _errOut); TestContext.WriteLine($"ID = {value}"); General.HasTrueValue(value > 0, _errOut); }
/// <summary> /// Verifies the doesnt exist. /// </summary> private void VerifyDoesntExist() { if (CustomReports.Exists(_databasePath, _crReportName, out _errOut)) { long id = CustomReports.GetId(_databasePath, _crReportName, out _errOut); CustomReports.Delete(_databasePath, id, out _errOut); } }
public void ListByIdTest() { VerifyExists(); long id = CustomReports.GetId(_databasePath, _crReportName, out _errOut); List <CustomReportsLists> value = CustomReports.List(_databasePath, (int)id, out _errOut); PrintList(value); General.HasTrueValue(value.Count > 0, _errOut); }
public void UpdateTest() { VerifyExists(); long id = CustomReports.GetId(_databasePath, _crReportName, out _errOut); bool value = CustomReports.Update(_databasePath, id, _crReportName, $"{_crSql} where id={id}", out _errOut); General.HasTrueValue(value, _errOut); }
public ActionResult DeleteBulk(long[] ids, string UrlReferrer) { foreach (var id in ids.Where(p => p > 0)) { CustomReports customreports = db.CustomReportss.Find(id); db.Entry(customreports).State = EntityState.Deleted; db.CustomReportss.Remove(customreports); try { db.SaveChanges(); } catch { } } return(Json("Success", "application/json", System.Text.Encoding.UTF8, JsonRequestBehavior.AllowGet)); }
public void ViewBagForReportsEdit(CustomReports customreports) { //ViewBag.AssociatedCustomerStatusID = new SelectList(db.Customerstatuss, "ID", "DisplayValue", customer.AssociatedCustomerStatusID); Dictionary <string, string> ResultPropertyDict = new Dictionary <string, string>(); ViewBag.ResultPropertyDD = new SelectList(ResultPropertyDict, "Key", "Value"); Dictionary <string, string> CrossTabRowDict = new Dictionary <string, string>(); ViewBag.CrossTabRowDD = new SelectList(CrossTabRowDict, "Key", "Value"); Dictionary <string, string> CrossTabColumnDict = new Dictionary <string, string>(); ViewBag.CrossTabColumnDD = new SelectList(CrossTabColumnDict, "Key", "Value"); Dictionary <string, string> AggregateEntityDict = new Dictionary <string, string>(); ViewBag.AggregateEntityDD = new SelectList(AggregateEntityDict, "Key", "Value"); Dictionary <string, string> AggregatePropertyDict = new Dictionary <string, string>(); ViewBag.AggregatePropertyDD = new SelectList(AggregatePropertyDict, "Key", "Value"); Dictionary <string, string> AggregateFunctionDict = new Dictionary <string, string>(); ViewBag.AggregateFunctionDD = new SelectList(AggregateFunctionDict, "Key", "Value"); Dictionary <string, string> FilterPropertyDict = new Dictionary <string, string>(); ViewBag.FilterPropertyDD = new SelectList(FilterPropertyDict, "Key", "Value"); Dictionary <string, string> FilterConditionDict = new Dictionary <string, string>(); ViewBag.FilterConditionDD = new SelectList(FilterConditionDict, "Key", "Value"); Dictionary <string, string> SelectPropertyDict = new Dictionary <string, string>(); ViewBag.SelectPropertyDD = new SelectList(SelectPropertyDict, "Key", "Value"); Dictionary <string, string> SelectValueFromListDict = new Dictionary <string, string>(); ViewBag.SelectValueFromListDD = new SelectList(SelectValueFromListDict, "Key", "Value"); ViewBag.EntityNameDD = new SelectList(EnityDictionary(), "Key", "Value"); }
// GET: /CustomReports/Details/5 public ActionResult Details(int?id, string HostingEntityName, string AssociatedType, string defaultview) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CustomReports customreports = db.CustomReportss.Find(id); if (customreports == null) { return(HttpNotFound()); } ViewData["AssociatedType"] = AssociatedType; ViewData["HostingEntityName"] = HostingEntityName; ViewBagForReportsEdit(customreports); LoadViewDataBeforeOnEdit(customreports); return(View("Details", customreports)); }
// GET: /CustomReports/Delete/5 public ActionResult Delete(int id) { if (!User.CanDelete("CustomReports")) { return(RedirectToAction("Index", "Error")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CustomReports customreports = db.CustomReportss.Find(id); if (customreports == null) { throw (new Exception("Deleted")); } if (ViewData["CustomReportsParentUrl"] == null && Request.UrlReferrer != null && !Request.UrlReferrer.AbsolutePath.EndsWith("/CustomReports")) { ViewData["CustomReportsParentUrl"] = Request.UrlReferrer; } return(View(customreports)); }
public ActionResult DashBoard(CustomReports obj, FormCollection form, string Column) { DSRCManagementSystemEntities1 objdb = new DSRCManagementSystemEntities1(); List <DSRCManagementSystem.Models.CustomReports> value = new List <DSRCManagementSystem.Models.CustomReports>(); List <DSRCManagementSystem.Models.CustomReports> Report = new List <DSRCManagementSystem.Models.CustomReports>(); List <DSRCManagementSystem.Models.CustomReports> ExportValue = new List <DSRCManagementSystem.Models.CustomReports>(); TempData["Column"] = Column; ViewBag.Column = Column; int roleid = Convert.ToInt32(Session["RoleID"]); try { if (Column == null) { string CusReportId = (form["Id3"] == "") ? "0" : form["Id3"].ToString(); int cusId = Convert.ToInt32(CusReportId); var Id = objdb.CustomReports.Where(x => x.ReportID == cusId && x.IsActive == true) .Select(o => o.ReportQuery) .FirstOrDefault(); string ZoneId = Id; var temp = objdb.CustomReports.Where(r => r.ReportQuery == Id).Select(f => f.ReportName).ToList(); foreach (var list in temp) { ViewBag.ReportName = list; } if (CusReportId == Convert.ToString(0)) { var Purpose = (from cr in objdb.CustomReports join cru in objdb.CustomReports_UserMapping on cr.ReportID equals cru.ReportID where (cru.RoleID == roleid && cr.IsActive == true) select new { ReportID = cr.ReportID, ReportName = cr.ReportName }).ToList(); ViewBag.Purpose = new SelectList(Purpose, "ReportID", "ReportName", 0); ModelState.AddModelError("RoleName", "Select Report Name"); } TempData["cusId"] = cusId; TempData["ReportID"] = ZoneId; if (CusReportId != Convert.ToString(0)) { List <string> Parameter = new List <string>(); List <string> value1 = objdb.SP_GetName(Id).ToList(); foreach (var s in value1) { DSRCManagementSystem.Models.CustomReports ob = new DSRCManagementSystem.Models.CustomReports(); var trims = s.TrimStart('@'); var newValue = trims.Substring(trims.IndexOf('_') + 1); var trim = Regex.Replace(newValue, "([a-z])([A-Z])", "$1 $2"); ob.CustomName = trim; value.Add(ob); Parameter.Add(ob.CustomName); } ViewData["Parameter"] = Parameter; ViewBag.Id = value; string id1 = Id; if (value.Count() == 0) { var pose = (from cr in objdb.CustomReports join cru in objdb.CustomReports_UserMapping on cr.ReportID equals cru.ReportID where (cru.RoleID == roleid && cr.IsActive == true) select new { ReportID = cr.ReportID, ReportName = cr.ReportName }).ToList(); ViewBag.Purpose = new SelectList(pose, "ReportID", "ReportName", cusId); string constr = ConfigurationManager.AppSettings["connstr"]; DataSet ds = new DataSet(); SqlConnection objcon = new SqlConnection(constr); SqlCommand cmd = new SqlCommand(id1, objcon); cmd.CommandText = id1; cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter adap = new SqlDataAdapter(cmd); adap.Fill(ds); List <object> chartData = new List <object>(); List <DSRCManagementSystem.Models.CustomReports> value5 = new List <DSRCManagementSystem.Models.CustomReports>(); List <object> Listvalue = new List <object>(); List <object> Val = new List <object>(); foreach (DataRow dr in ds.Tables[0].Rows) { DSRCManagementSystem.Models.CustomReports ob = new DSRCManagementSystem.Models.CustomReports(); Array x = dr.ItemArray; ob.ReportName1 = x; Listvalue.Add(ob.ReportName1); chartData.Add(new object[] { dr[0] }); ExportValue.Add(ob); } foreach (DataColumn dr in ds.Tables[0].Columns) { DSRCManagementSystem.Models.CustomReports ob1 = new DSRCManagementSystem.Models.CustomReports(); ob1.CustomNameId = dr.ColumnName; Val.Add(ob1.CustomNameId); } ViewBag.Val = Val; ViewBag.ListValue = Listvalue; ViewBag.data = chartData; return(View(ExportValue)); } var Purpose = (from cr in objdb.CustomReports join cru in objdb.CustomReports_UserMapping on cr.ReportID equals cru.ReportID where (cru.RoleID == roleid && cr.IsActive == true) select new { ReportID = cr.ReportID, ReportName = cr.ReportName }).ToList(); foreach (var item in value) { ViewBag.Purpose = new SelectList(Purpose, "ReportID", "ReportName", cusId); } } } } catch (Exception Ex) { //string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); //string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); //ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName); //return Json("Warning", JsonRequestBehavior.AllowGet); ModelState.AddModelError("RoleName", "Stored Procedure Was Not Supported "); } try { if (Column != null) { string Id = Convert.ToString(TempData["ReportID"]); List <string> value1 = objdb.SP_GetName(Id).ToList(); foreach (var s in value1) { DSRCManagementSystem.Models.CustomReports ob = new DSRCManagementSystem.Models.CustomReports(); ob.CustomName = s; value.Add(ob); } ViewBag.Id = value; string values = string.Empty; List <string> objuser = new List <string>(); string[] value2 = Column.Split(','); for (int k = 0; k < value2.Count(); k++) { if (value2[k] != "") { objuser.Add(value2[k].Replace(",", "''")); } } var pose = (from pi in objdb.CustomReports select new { Id3 = pi.ReportQuery, Template = pi.ReportName }).ToList(); ViewBag.Purpose = new SelectList(pose, "Id3", "Template"); string constr1 = ConfigurationManager.AppSettings["connstr"]; DataSet ds1 = new DataSet(); SqlConnection objcon1 = new SqlConnection(constr1); SqlCommand cmd1 = new SqlCommand(Id, objcon1); TempData["ReportID"] = ds1; int i = 0; foreach (var s in value1) { cmd1.Parameters.Add(s, SqlDbType.VarChar).Value = value2[i]; i++; } cmd1.CommandText = Id; // Stored procedure name cmd1.CommandType = CommandType.StoredProcedure; // set it to stored proc SqlDataAdapter adap1 = new SqlDataAdapter(cmd1); adap1.Fill(ds1); TempData["ID"] = adap1; List <object> chartData = new List <object>(); List <object> List = new List <object>(); List <object> valueList = new List <object>(); foreach (DataRow dr in ds1.Tables[0].Rows) { DSRCManagementSystem.Models.CustomReports ob = new DSRCManagementSystem.Models.CustomReports(); Array column = dr.ItemArray; ob.ReportName1 = column; List.Add(ob.ReportName1); Report.Add(ob); } foreach (DataColumn dr in ds1.Tables[0].Columns) { DSRCManagementSystem.Models.CustomReports ob1 = new DSRCManagementSystem.Models.CustomReports(); ob1.CustomNameId = dr.ColumnName; valueList.Add(ob1.CustomNameId); } ViewBag.List = Report.ToList(); TempData["Value"] = Report.ToList(); TempData["List"] = ViewBag.Val = valueList; TempData["ReportIDs"] = TempData["cusId"]; ViewBag.Val = valueList; ViewBag.ListValue = List; } } catch (Exception Ex) { string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName); return(Json("Warning", JsonRequestBehavior.AllowGet)); } var userid = Convert.ToInt32(Session["UserID"]); ViewBag.permission = (from p in objdb.ReportsPermissions where p.UserId == userid && p.IsAuthorized == true select p.UserId).SingleOrDefault(); ViewBag.UserID = Convert.ToInt32(Session["UserID"]); return(View(value)); }