public ActionResult Create(ReportViewModel reportviewModel)
        {
            ReportModel reportModel = reportviewModel.rm;

            if (db.ReportModels.Where(x => x.path == reportModel.path).Any())
            {
                ViewBag.ErrorMessage = "This Report already exists.";
                SelectList sl = Utility.GetReportsDDL();
                reportviewModel.lsReports = sl;
                return(View(reportviewModel));
            }
            else
            {
                ReportService2005.ReportingService2005 rs = new ReportService2005.ReportingService2005();
                rs.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["userName"].ToString(), ConfigurationManager.AppSettings["Password"].ToString());
                rs.Timeout     = Convert.ToInt32(ConfigurationManager.AppSettings["SOAPTimeout"].ToString());
                rs.Url         = ConfigurationManager.AppSettings["webServiceURL"].ToString();
                ReportService2005.CatalogItem[] items = rs.ListChildren("/", true);
                ReportService2005.CatalogItem   item  = items.Where(x => x.Path == reportModel.path).Single();
                reportModel.name        = item.Name;
                reportModel.description = item.Description;
                reportModel.ts          = DateTime.Now;
                reportModel.isActive    = true;
                db.ReportModels.Add(reportModel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
        }
示例#2
0
        public static SelectList GetReportsDDL()
        {
            ApplicationDbContext db = new ApplicationDbContext();

            ReportService2005.ReportingService2005 rs = new ReportService2005.ReportingService2005();
            rs.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["userName"].ToString(), ConfigurationManager.AppSettings["Password"].ToString());
            rs.Timeout     = Convert.ToInt32(ConfigurationManager.AppSettings["SOAPTimeout"].ToString());
            rs.Url         = ConfigurationManager.AppSettings["webServiceURL"].ToString();
            ReportService2005.CatalogItem[] items   = rs.ListChildren("/", true);
            List <SelectListItem>           slItems = new List <SelectListItem>();

            foreach (ReportService2005.CatalogItem item in items)
            {
                if (item.Type == ReportService2005.ItemTypeEnum.Report || item.Type == ReportService2005.ItemTypeEnum.LinkedReport)
                {
                    if (!db.ReportModels.Where(x => x.path == item.Path).Any())
                    {
                        SelectListItem sli = new SelectListItem();
                        sli.Value = item.Path;
                        sli.Text  = item.Name + " || " + item.Path;
                        slItems.Add(sli);
                    }
                }
            }
            SelectList sl = new SelectList(slItems, "Value", "Text");

            return(sl);
        }