Esempio n. 1
0
        private List <string> GetFolders(BOAuthentication authModel)
        {
            XmlDocument   docRecv       = new System.Xml.XmlDocument();
            List <string> _lstfolderIds = new List <string>();

            _biRepository.CreateWebRequest(send: null, recv: docRecv, method: "GET", URI: authModel.URI, URIExtension: "/biprws/infostore/Root%20Folder/children",
                                           pLogonToken: authModel.LogonToken);

            XmlNamespaceManager nsmgrGET = new XmlNamespaceManager(docRecv.NameTable);

            nsmgrGET.AddNamespace("rest", authModel.NameSpace);

            ReportCategory category = new ReportCategory();
            XmlNodeList    nodeList = docRecv.SelectNodes("//rest:attr[@name='type']", nsmgrGET);

            for (int i = 0; i < nodeList.Count; i++)
            {
                if (nodeList.Item(i).InnerText == "Folder")
                {
                    category.Name        = docRecv.SelectNodes("//rest:attr[@name='name']", nsmgrGET)[i].InnerText;
                    category.InfoStoreId = docRecv.SelectNodes("//rest:attr[@name='id']", nsmgrGET)[i].InnerText;
                    category.Description = docRecv.SelectNodes("//rest:attr[@name='description']", nsmgrGET)[i].InnerText;
                    category.Cuid        = docRecv.SelectNodes("//rest:attr[@name='cuid']", nsmgrGET)[i].InnerText;
                    _lstfolderIds.Add(category.InfoStoreId);
                    //GetChildren(authModel, category);
                }
            }

            return(_lstfolderIds);
        }
Esempio n. 2
0
        void DrawCategory(ReportCategory category)
        {
            var first = true;

            if (category == ReportCategory.All)
            {
                for (int i = 0, length = Report.ReportsCount; i < length; i++)
                {
                    var r = Report.GetReport(i);
                    if (showHidden || !r.IsHidden)
                    {
                        if (first)
                        {
                            first = false;
                            DrawCategoryHeader(category);
                        }
                        DrawReport(r);
                    }
                }
            }
            else if (category == ReportCategory.None)
            {
                for (int i = 0, length = Report.ReportsCount; i < length; i++)
                {
                    var r = Report.GetReport(i);
                    if (r.Category == ReportCategory.None)
                    {
                        if (showHidden || !r.IsHidden)
                        {
                            if (first)
                            {
                                first = false;
                                DrawCategoryHeader(category);
                            }
                            DrawReport(r);
                        }
                    }
                }
            }
            else
            {
                for (int i = 0, length = Report.ReportsCount; i < length; i++)
                {
                    var r = Report.GetReport(i);
                    if (r.Category.HasFlag(category))
                    {
                        if (showHidden || !r.IsHidden)
                        {
                            if (first)
                            {
                                first = false;
                                DrawCategoryHeader(category);
                            }
                            DrawReport(r);
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// This will create and add a new report to the report system and be visible in the Report Window. Supports multiple actions and no action.
        /// </summary>
        /// <param name="name">Name of the report</param>
        /// <param name="description">Description to why this report exists and/or what Trail is doing behind the scenes.</param>
        /// <param name="category">Category the report should show up in. Category is a mask and can show up in multiple categories.</param>
        /// <param name="httpReference">A reference link to open a web page for the users to read more about the report.</param>
        /// <param name="stateCheck">A function to check whether to show or hide the report from the window.</param>
        /// <param name="actions">An array of potential actions to be made to hide the report.</param>
        public static Report Create(string name, string description, ReportCategory category, string httpReference, ReportStateCheck stateCheck, bool threaded, params ReportAction[] actions)
        {
            var report = new Report(name, description, category, httpReference, stateCheck, actions);

            report.Threaded = threaded;
            reports.Add(report);
            return(report);
        }
Esempio n. 4
0
 public IActionResult EditReportCategory(ReportCategory model)
 {
     if (ModelState.IsValid)
     {
         dataManager.ReportCategories.SaveReportCategory(model);
         return(RedirectToAction("ReportCategories"));
     }
     return(View(model));
 }
Esempio n. 5
0
        public static string GetMrtPath(ReportCategory category)
        {
            var path = ConfigurationManager.AppSettings.AllKeys.FirstOrDefault(x => x == category.ToString());

            if (path == null)
            {
                throw new ArgumentOutOfRangeException(nameof(category), category, null);
            }

            return(HttpContext.Current.Server.MapPath("~/" + ConfigurationManager.AppSettings[path]));
        }
Esempio n. 6
0
 public void SaveReportCategory(ReportCategory category)
 {
     if (category.Id == default)
     {
         context.Entry(category).State = EntityState.Added;
     }
     else
     {
         context.Entry(category).State = EntityState.Modified;
     }
     context.SaveChanges();
 }
        /// <summary>
        /// Adds a single report category to the repository
        /// </summary>
        /// <param name="category">The category to add</param>
        public void AddCategory
        (
            ReportCategory category
        )
        {
            Validate.IsNotNull(category);

            _context.Set <ReportCategory>().Add
            (
                category
            );
        }
Esempio n. 8
0
            public long ReportsOfCategory(ReportCategory category)
            {
                long count = 0;

                for (int i = 0; i < reports.Length; ++i)
                {
                    if (reports[i].reason.category == category)
                    {
                        count += reports[i].count;
                    }
                }
                return(count);
            }
        public ReportCategoryModel GetReportCategoryByPrimaryKey(Int64 CategoryId)
        {
            ReportCategory result = this.dataContext
                                    .ReportCategories
                                    .FirstOrDefault(pk => pk.CategoryId == CategoryId);

            if (result == null)
            {
                return(null);
            }

            return(result.CopyToObject(new ReportCategoryModel()) as ReportCategoryModel);
        }
        /// <summary>
        /// Updates a single report category to the repository
        /// </summary>
        /// <param name="category">The category to update</param>
        public void UpdateCategory
        (
            ReportCategory category
        )
        {
            Validate.IsNotNull(category);

            var entry = _context.Entry <ReportCategory>
                        (
                category
                        );

            entry.State = EntityState.Modified;
        }
        public async Task Report(Entities.Entry entry, string userName, ReportCategory category, string comment = "")
        {
            var url      = $"{BaseUrl}/entry.report";
            var contents = new Dictionary <string, string>
            {
                { "rks", RksForBookmark },
                { "eid", entry.Id.ToString() },
                { "name", userName },
                { "category", category.GetHashCode().ToString() },
                { "comment", comment }
            };

            await PostAsync(url, contents, GetCookieHeader());
        }
Esempio n. 12
0
        private void GetChildren(BOAuthentication authModel, ReportCategory parentCat)
        {
            XmlDocument docRecv = new System.Xml.XmlDocument();

            _biRepository.CreateWebRequest
            (
                send: null,
                recv: docRecv,
                method: "GET",
                URI: authModel.URI,
                URIExtension: string.Format("/biprws/infostore/{0}/children", parentCat.InfoStoreId),
                pLogonToken: authModel.LogonToken
            );

            XmlNamespaceManager nsmgrGET = new XmlNamespaceManager(docRecv.NameTable);

            nsmgrGET.AddNamespace("rest", authModel.NameSpace);

            XmlNodeList list = docRecv.GetElementsByTagName("entry");

            for (int i = 1; i <= list.Count; i++)
            {
                XmlNode x      = list[i - 1];
                string  format = "(//rest:attr[@name='{0}'])[{1}]";
                if (x.SelectSingleNode(string.Format(format, "type", i), nsmgrGET).InnerText == "Folder" && x.SelectSingleNode(string.Format(format, "name", i), nsmgrGET).InnerText != "Dashboards")
                {
                    ReportCategory subCat = new ReportCategory()
                    {
                        Name        = x.SelectSingleNode(string.Format(format, "name", i), nsmgrGET).InnerText,
                        InfoStoreId = x.SelectSingleNode(string.Format(format, "id", i), nsmgrGET).InnerText,
                        Description = x.SelectSingleNode(string.Format(format, "description", i), nsmgrGET).InnerText,
                        Cuid        = x.SelectSingleNode(string.Format(format, "cuid", i), nsmgrGET).InnerText
                    };

                    parentCat.SubCategories.Add(subCat);
                    GetChildren(authModel, subCat);
                }
                else if (x.SelectSingleNode(string.Format(format, "name", i), nsmgrGET).InnerText != "Dashboards")
                {
                    parentCat.Reports.Add(new Report()
                    {
                        Name        = x.SelectSingleNode(string.Format(format, "name", i), nsmgrGET).InnerText,
                        InfoStoreId = x.SelectSingleNode(string.Format(format, "id", i), nsmgrGET).InnerText,
                        Description = x.SelectSingleNode(string.Format(format, "description", i), nsmgrGET).InnerText,
                        Cuid        = x.SelectSingleNode(string.Format(format, "cuid", i), nsmgrGET).InnerText
                    });
                }
            }
        }
Esempio n. 13
0
        public ReportCategory GetReportList(BOAuthentication authModel, string defaultFolderId)
        {
            //TODO: Unit test it or Understand refactor it for readability
            ReportCategory category = new ReportCategory();
            XmlDocument    docRecv  = new System.Xml.XmlDocument();

            try
            {
                _logMessages.Append("Getting reports list from BO System.");
                //Get all folders from Root Folder
                List <string> _lstfolderIds = GetFolders(authModel);

                //For every folder
                for (int i = 0; i < _lstfolderIds.Count(); i++)
                {
                    //Get the list of reports within that folder
                    //TODO: Check with the send param,it should not be null
                    _biRepository.CreateWebRequest(send: null, recv: docRecv, method: "GET", URI: authModel.URI, URIExtension: "/biprws/infostore/" + _lstfolderIds[i],
                                                   pLogonToken: authModel.LogonToken);

                    XmlNamespaceManager nsmgrGET = new XmlNamespaceManager(docRecv.NameTable);
                    nsmgrGET.AddNamespace("rest", authModel.NameSpace);
                    XmlNodeList nodeList = docRecv.SelectNodes("//rest:attr[@name='type']", nsmgrGET);
                    if (nodeList.Item(0).InnerText.Equals("Folder", StringComparison.OrdinalIgnoreCase))
                    {
                        ReportCategory parentCat = new ReportCategory()
                        {
                            Name        = docRecv.SelectSingleNode("//rest:attr[@name='name']", nsmgrGET).InnerText,
                            InfoStoreId = docRecv.SelectSingleNode("//rest:attr[@name='id']", nsmgrGET).InnerText,
                            Description = docRecv.SelectSingleNode("//rest:attr[@name='description']", nsmgrGET).InnerText,
                            Cuid        = docRecv.SelectSingleNode("//rest:attr[@name='cuid']", nsmgrGET).InnerText
                        };
                        category.ParentCategories.Add(parentCat);

                        //Find sub reports of this report
                        GetChildren(authModel, parentCat);
                    }
                }
                _logMessages.Append("Finished Iterating all reports folder");
            }
            catch (Exception ex)
            {
                _logMessages.AppendFormat("An Error occurred getting reports list Exception message {0}.", ex.Message);
                _logger.Info(_logMessages.ToString());
                throw;
            }
            _logger.Info(_logMessages.ToString());
            return(category);
        }
Esempio n. 14
0
        public void UpdateCategoryTests()
        {
            var builder = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString());

            applicationDbContext  = new ApplicationDbContext(builder.Options, _configuration);
            repository            = new Repository <ReportCategory>(applicationDbContext);
            reportCategoryService = new ReportCategoryService(repository);
            reportCategoryService.Add(new ReportCategory()
            {
                Id = Guid.Parse("2eb1d729-8d4c-4a94-90b6-ed9dfbd0bc76")
            });
            applicationDbContext.SaveChanges();
            ReportCategory reports = applicationDbContext.ReportCategories.SingleOrDefault(s => s.Id == Guid.Parse("2eb1d729-8d4c-4a94-90b6-ed9dfbd0bc76"));

            reportCategoryService.Update(reports);
            Assert.Equal(1, applicationDbContext.ReportCategories.Count());
        }
Esempio n. 15
0
        public ReportCategory GetReportList(string sapToken)
        {
            _boAuthmodel.LogonToken = sapToken;

            _logMessages.AppendFormat("Getting report list with base Uri {0}, UrlwithHostname {1} and Token {2}.", _baseUrl, _baseUrlWithHostName, sapToken);
            ReportCategory reportCategory = null;

            try
            {
                _logMessages.AppendFormat("Invoking BO Report service to get report categories with default folder id {0}.", _defaultFolderId);
                reportCategory = _boReportService.GetReportList(_boAuthmodel, _defaultFolderId);
            }
            catch (System.Exception ex)
            {
                _logMessages.AppendFormat("An error occurred. Exception information {0}.", ex.Message);
                Elmah.ErrorLog.GetDefault(null).Log(new Elmah.Error(ex));
            }
            _logger.Info(_logMessages.ToString());
            return(reportCategory);
        }
Esempio n. 16
0
        public void DeleteCategory(long categoryId)
        {
            int reportCount = base.dataContext
                              .ReportsMaster
                              .Where(ci => ci.CategoryId == categoryId)
                              .Count();

            if (reportCount > 0)
            {
                throw new ApplicationException("Cannot delete Category while reports are attached.");
            }

            ReportCategory category = base.dataContext
                                      .ReportCategories
                                      .First(rc => rc.CategoryId == categoryId);

            category.IsActive = false;

            base.dataContext.SaveChanges();
        }
Esempio n. 17
0
        public void UpdateReportTypeCategory(ReportType reportType, ReportCategory category)
        {
            dbLock.Wait();

            try
            {
                updateReportType.ExecuteNonQuery(new Dictionary <string, object>()
                {
                    ["id"]       = reportType.id,
                    ["category"] = category.ToString(),
                });

                reportType.category = category;
            }
            finally
            {
                dbLock.Release();
            }

            TriggerCallbacks();
        }
        public void UpdateReportCategory(ReportCategoryModel model)
        {
            ReportCategory existing = this.dataContext
                                      .ReportCategories
                                      .Where(rx => rx.CategoryId == model.CategoryId)
                                      .FirstOrDefault();

            if (existing == null)
            {
                existing = model.CopyToObject(new ReportCategory()) as ReportCategory;

                this.dataContext.ReportCategories.Add(existing);
            }
            else
            {
                existing = model.CopyToObject(existing) as ReportCategory;
            }

            this.dataContext.SaveChanges();

            model = existing.CopyToObject(model) as ReportCategoryModel;
        }
Esempio n. 19
0
        private Report(string name, string description, ReportCategory category, string httpReference, ReportStateCheck stateCheck, params ReportAction[] actions)
        {
            this.Name          = name;
            this.Description   = description;
            this.Category      = category;
            this.HttpReference = httpReference;
            this.stateCheck    = stateCheck;
            this.Actions       = actions;

            // Handle a no description case. Should most of time not happen.
            if (string.IsNullOrEmpty(description))
            {
                if (string.IsNullOrEmpty(httpReference))
                {
                    this.Description = "No current information regarding this report is provided.\nIf you need support or help regarding this issue, talk to us on Discord: https://discord.gg/trail";
                }
                else
                {
                    this.Description = string.Format("More information about '{0}' exists at '{1}'\nUse the question mark '?' to enter the web page.", name, httpReference);
                }
            }
        }
        /// <summary>
        /// Removes a single report category from the repository
        /// </summary>
        /// <param name="category">The category to remove</param>
        public void RemoveCategory
        (
            ReportCategory category
        )
        {
            var entry = _context.Entry <ReportCategory>
                        (
                category
                        );

            // Ensure the entity has been attached to the object state manager
            if (entry.State == EntityState.Detached)
            {
                _context.Set <ReportCategory>().Attach
                (
                    category
                );
            }

            _context.Set <ReportCategory>().Remove
            (
                category
            );
        }
Esempio n. 21
0
        public ActionResult SendReport(int?articleId, int?reportId)
        {
            if (reportId == null || articleId == null)
            {
                return(HttpNotFound());
            }

            Article        article        = db.Articles.Find(articleId);
            ReportCategory reportCategory = db.ReportCategories.Find(reportId);

            if (article == null || reportCategory == null)
            {
                return(HttpNotFound());
            }

            Report report = new Report()
            {
                ReportCategoryId = reportCategory.Id, ApplicationUserId = User.Identity.GetUserId(), ArticleId = article.Id, ReportTime = DateTime.Now, IsInvestigated = false
            };

            db.Reports.Add(report);
            db.SaveChanges();
            return(Json(new EmptyResult()));
        }
Esempio n. 22
0
        /// <summary>
        ///  Create a ReportCategory
        /// </summary>
        /// <param name="currentUser"></param>
        /// <param name="user"></param>
        /// <param name="appID"></param>
        /// <param name="overrideID"></param>
        /// <param name="dc"></param>
        /// <param name="dataRepository"></param>
        /// <param name="uow"></param>
        public ReportCategoryVMDC CreateReportCategory(string currentUser, string user, string appID, string overrideID, ReportCategoryDC dc, IRepository <ReportCategory> dataRepository, IUnitOfWork uow, IExceptionManager exceptionManager, IMappingService mappingService)
        {
            try
            {
                #region Parameter validation

                // Validate parameters
                if (string.IsNullOrEmpty(currentUser))
                {
                    throw new ArgumentOutOfRangeException("currentUser");
                }
                if (string.IsNullOrEmpty(user))
                {
                    throw new ArgumentOutOfRangeException("user");
                }
                if (string.IsNullOrEmpty(appID))
                {
                    throw new ArgumentOutOfRangeException("appID");
                }
                if (null == dc)
                {
                    throw new ArgumentOutOfRangeException("dc");
                }
                if (null == dataRepository)
                {
                    throw new ArgumentOutOfRangeException("dataRepository");
                }
                if (null == uow)
                {
                    throw new ArgumentOutOfRangeException("uow");
                }
                if (null == exceptionManager)
                {
                    throw new ArgumentOutOfRangeException("exceptionManager");
                }
                if (null == mappingService)
                {
                    throw new ArgumentOutOfRangeException("mappingService");
                }

                #endregion

                using (uow)
                {
                    // Create a new ID for the ReportCategory item
                    dc.Code = Guid.NewGuid();

                    // Map data contract to model
                    ReportCategory destination = mappingService.Map <ReportCategoryDC, ReportCategory>(dc);

                    // Add the new item
                    dataRepository.Add(destination);

                    // Commit unit of work
                    uow.Commit();

                    // Map model back to data contract to return new row id.
                    dc = mappingService.Map <ReportCategory, ReportCategoryDC>(destination);
                }

                // Create aggregate data contract
                ReportCategoryVMDC returnObject = new ReportCategoryVMDC();

                // Add new item to aggregate
                returnObject.ReportCategoryItem = dc;

                return(returnObject);
            }
            catch (Exception e)
            {
                //Prevent exception from propogating across the service interface
                exceptionManager.ShieldException(e);

                return(null);
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Retrieve a ReportCategory with associated lookups
        /// </summary>
        /// <param name="currentUser"></param>
        /// <param name="user"></param>
        /// <param name="appID"></param>
        /// <param name="overrideID"></param>
        /// <param name="code"></param>
        /// <param name="dataRepository"></param>
        /// <param name="uow"></param>
        /// <returns></returns>
        public ReportCategoryVMDC GetReportCategory(string currentUser, string user, string appID, string overrideID, string code, IUnitOfWork uow, IRepository <ReportCategory> dataRepository
                                                    , IExceptionManager exceptionManager, IMappingService mappingService)

        {
            try
            {
                #region Parameter validation

                // Validate parameters
                if (string.IsNullOrEmpty(currentUser))
                {
                    throw new ArgumentOutOfRangeException("currentUser");
                }
                if (string.IsNullOrEmpty(user))
                {
                    throw new ArgumentOutOfRangeException("user");
                }
                if (string.IsNullOrEmpty(appID))
                {
                    throw new ArgumentOutOfRangeException("appID");
                }
                if (null == dataRepository)
                {
                    throw new ArgumentOutOfRangeException("dataRepository");
                }
                if (null == uow)
                {
                    throw new ArgumentOutOfRangeException("uow");
                }
                if (null == exceptionManager)
                {
                    throw new ArgumentOutOfRangeException("exceptionManager");
                }
                if (null == mappingService)
                {
                    throw new ArgumentOutOfRangeException("mappingService");
                }

                #endregion

                using (uow)
                {
                    ReportCategoryDC destination = null;

                    // If code is null then just return supporting lists
                    if (!string.IsNullOrEmpty(code))
                    {
                        // Convert code to Guid
                        Guid codeGuid = Guid.Parse(code);

                        // Retrieve specific ReportCategory
                        ReportCategory dataEntity = dataRepository.Single(x => x.Code == codeGuid);

                        // Convert to data contract for passing through service interface
                        destination = mappingService.Map <ReportCategory, ReportCategoryDC>(dataEntity);
                    }



                    // Create aggregate contract
                    ReportCategoryVMDC returnObject = new ReportCategoryVMDC();

                    returnObject.ReportCategoryItem = destination;

                    return(returnObject);
                }
            }
            catch (Exception e)
            {
                //Prevent exception from propogating across the service interface
                exceptionManager.ShieldException(e);

                return(null);
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Update a ReportCategory
        /// </summary>
        /// <param name="currentUser"></param>
        /// <param name="user"></param>
        /// <param name="appID"></param>
        /// <param name="overrideID"></param>
        /// <param name="code"></param>
        /// <param name="lockID"></param>
        /// <param name="dataRepository"></param>
        /// <param name="uow"></param>
        public void DeleteReportCategory(string currentUser, string user, string appID, string overrideID, string code, string lockID, IRepository <ReportCategory> dataRepository, IUnitOfWork uow, IExceptionManager exceptionManager, IMappingService mappingService)
        {
            try
            {
                #region Parameter validation

                // Validate parameters
                if (string.IsNullOrEmpty(currentUser))
                {
                    throw new ArgumentOutOfRangeException("currentUser");
                }
                if (string.IsNullOrEmpty(user))
                {
                    throw new ArgumentOutOfRangeException("user");
                }
                if (string.IsNullOrEmpty(appID))
                {
                    throw new ArgumentOutOfRangeException("appID");
                }
                if (string.IsNullOrEmpty(code))
                {
                    throw new ArgumentOutOfRangeException("code");
                }
                if (string.IsNullOrEmpty(lockID))
                {
                    throw new ArgumentOutOfRangeException("lockID");
                }
                if (null == dataRepository)
                {
                    throw new ArgumentOutOfRangeException("dataRepository");
                }
                if (null == uow)
                {
                    throw new ArgumentOutOfRangeException("uow");
                }
                if (null == exceptionManager)
                {
                    throw new ArgumentOutOfRangeException("exceptionManager");
                }
                if (null == mappingService)
                {
                    throw new ArgumentOutOfRangeException("mappingService");
                }

                #endregion

                using (uow)
                {
                    // Convert string to guid
                    Guid codeGuid = Guid.Parse(code);

                    // Find item based on ID
                    ReportCategory dataEntity = dataRepository.Single(x => x.Code == codeGuid);

                    // Delete the item
                    dataRepository.Delete(dataEntity);

                    // Commit unit of work
                    uow.Commit();
                }
            }
            catch (Exception e)
            {
                //Prevent exception from propogating across the service interface
                exceptionManager.ShieldException(e);
            }
        }
Esempio n. 25
0
 public void Update(ReportCategory category)
 {
     _repository.Update(category);
 }
Esempio n. 26
0
 public void Add(ReportCategory category)
 {
     _repository.Add(category);
 }
Esempio n. 27
0
        public IQueryable <Report> GetReportsByCategory(ReportCategory category)
        {
            var reports = context.Reports.Where(r => r.ReportCategoryId == category.Id);

            return(reports);
        }
Esempio n. 28
0
        protected override void Seed(BlogMVC.Models.ApplicationDbContext context)
        {
            if (!context.Roles.Any(x => x.Name == "admin"))
            {
                var roleStore   = new RoleStore <IdentityRole>(context);
                var roleManager = new RoleManager <IdentityRole>(roleStore);
                roleManager.Create(new IdentityRole("admin"));
            }

            if (!context.Users.Any(x => x.UserName == "*****@*****.**"))
            {
                var userStore   = new UserStore <ApplicationUser>(context);
                var userManager = new ApplicationUserManager(userStore);
                var user        = new ApplicationUser()
                {
                    UserName       = "******",
                    Email          = "*****@*****.**",
                    EmailConfirmed = true,
                    NickName       = "Admin01"
                };

                userManager.Create(user, "1234.Lol");
                userManager.AddToRole(user.Id, "admin");
            }

            if (!context.Categories.Any())
            {
                context.Categories.AddRange(new List <Category>
                {
                    new Category {
                        Name = "Sports", Description = "Sport (or sports) is all forms of usually competitive physical activity which, through casual or organised participation, aim to use, maintain or improve physical ability and skills while providing entertainment to participants, and in some cases, spectators."
                    },
                    new Category {
                        Name = "Politic", Description = "Politics is the set of activities that are associated with making decisions in groups, or other forms of power relations between individuals, such as the distribution of resources or status. The academic study of politics is referred to as political science."
                    },
                    new Category {
                        Name = "Politics", Description = "Politics is the set of activities that are associated with making decisions in groups, or other forms of power relations between individuals, such as the distribution of resources or status. The academic study of politics is referred to as political science."
                    },
                    new Category {
                        Name = "Software", Description = "Software, instructions that tell a computer what to do. Software comprises the entire set of programs, procedures, and routines associated with the operation of a computer system. The term was coined to differentiate these instructions from hardware, the physical components of a computer system."
                    },
                    new Category {
                        Name = "Future", Description = "Future studies, futures research or futurology is the systematic, interdisciplinary and holistic study of social and technological advancement, and other environmental trends, often for the purpose of exploring how people will live and work in the future. "
                    },
                    new Category {
                        Name = "Movie", Description = "Movies, or films, are a type of visual communication which uses moving pictures and sound to tell stories or teach people something. Most people watch (view) movies as a type of entertainment or a way to have fun."
                    },
                    new Category {
                        Name = "Science", Description = "Movies, or films, are a type of visual communication which uses moving pictures and sound to tell stories or teach people something. Most people watch (view) movies as a type of entertainment or a way to have fun."
                    },
                    new Category {
                        Name = "Research", Description = "Movies, or films, are a type of visual communication which uses moving pictures and sound to tell stories or teach people something. Most people watch (view) movies as a type of entertainment or a way to have fun."
                    },
                    new Category {
                        Name = "Lifestyle", Description = "Movies, or films, are a type of visual communication which uses moving pictures and sound to tell stories or teach people something. Most people watch (view) movies as a type of entertainment or a way to have fun."
                    }
                });
            }


            if (!context.ReportCategories.Any())
            {
                ReportCategory reportCategory1 = new ReportCategory();
                reportCategory1.Name = "Spam";

                ReportCategory reportCategory2 = new ReportCategory();
                reportCategory2.Name = "Harassment";

                ReportCategory reportCategory3 = new ReportCategory();
                reportCategory3.Name = "Rules Violation";

                context.ReportCategories.Add(reportCategory1);
                context.ReportCategories.Add(reportCategory2);
                context.ReportCategories.Add(reportCategory3);
            }
        }
Esempio n. 29
0
 /*
  * this function add new report to data base
  * return value is result
  */
 public bool NewReport(Report r, ReportCategory rc, Attachment a);
Esempio n. 30
0
 private Response NewReport(Report report, ReportCategory category, Attachments attachment)
 {
     //_dbCenter.NewReport(report, category, attachment);
     return(_response);
 }
Esempio n. 31
0
        //Guid _reportLinkId;

        #endregion Class Level Members

        #region How To Sample Code
        /// <summary>
        /// Create and configure the organization service proxy.        
        /// Retrieve the history limit of a report.
        /// </summary>
        /// <param name="serverConfig">Contains server connection information.</param>
        /// <param name="promptforDelete">When True, the user will be prompted to delete all
        /// created entities.</param>
        public void Run(ServerConnection.Configuration serverConfig, bool promptForDelete)
        {
            try
            {

                // Connect to the Organization service. 
                // The using statement assures that the service proxy will be properly disposed.
                using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri, serverConfig.HomeRealmUri,serverConfig.Credentials, serverConfig.DeviceCredentials))
                {
                    // This statement is required to enable early-bound type support.
                    _serviceProxy.EnableProxyTypes();

                    // Call the method to create any data that this sample requires.
                    CreateRequiredRecords();

                    //<snippetPublishReport1>

                    // Define an anonymous type to define the possible values for
                    // report type.
                    var ReportTypeCode = new
                    {
                        ReportingServicesReport = 1,
                        OtherReport = 2,
                        LinkedReport = 3
                    };

                    // Define an anonymous type to define the possible values for
                    // report category.
                    var ReportCategoryCode = new
                    {
                        SalesReports = 1,
                        ServiceReports = 2,
                        MarketingReports = 3,
                        AdministrativeReports = 4
                    };

                    // Define an anonymous type to define the possible values for
                    // report visibility
                    var ReportVisibilityCode = new
                    {
                        ReportsGrid = 1,
                        Form = 2,
                        Grid = 3,
                    };

                    // Instantiate a report object.
                    // See the Entity Metadata topic in the SDK documentation to determine
                    // which attributes must be set for each entity.

                    Report sampleReport = new Report
                    {
                        Name = "Sample Report",
                        BodyText = File.ReadAllText("SampleReport.rdl"),
                        FileName = "SampleReport.rdl",
                        LanguageCode = 1033, // US English
                        ReportTypeCode = new OptionSetValue(ReportTypeCode.ReportingServicesReport)
                    };
                    // Create a report record named Sample Report.
                    _reportId = _serviceProxy.Create(sampleReport);


                    // Set the report category.
                    ReportCategory sampleReportCategory = new ReportCategory
                    {
                        ReportId = new EntityReference(Report.EntityLogicalName, _reportId),
                        CategoryCode = new OptionSetValue(ReportCategoryCode.AdministrativeReports)
                    };
                    _reportCategoryId = _serviceProxy.Create(sampleReportCategory);

                    // Define which entity this report uses.
                    ReportEntity reportEntity = new ReportEntity
                    {
                        ReportId = new EntityReference(Report.EntityLogicalName, _reportId),
                        ObjectTypeCode = Account.EntityLogicalName
                    };
                    _reportEntityId = _serviceProxy.Create(reportEntity);


                    // Set the report visibility.
                    ReportVisibility rv = new ReportVisibility
                    {
                        ReportId = new EntityReference(Report.EntityLogicalName, _reportId),
                        VisibilityCode = new OptionSetValue(ReportVisibilityCode.Form)
                    };
                    _reportVisibilityId1 = _serviceProxy.Create(rv);

                    rv = new ReportVisibility
                    {
                        ReportId = new EntityReference(Report.EntityLogicalName, _reportId),
                        VisibilityCode = new OptionSetValue(ReportVisibilityCode.Grid)
                    };
                    _reportVisibilityId2 = _serviceProxy.Create(rv);

                    rv = new ReportVisibility
                    {
                        ReportId = new EntityReference(Report.EntityLogicalName, _reportId),
                        VisibilityCode = new OptionSetValue(ReportVisibilityCode.ReportsGrid)
                    };
                    _reportVisibilityId3 = _serviceProxy.Create(rv);

                    Console.WriteLine("{0} published in Microsoft Dynamics CRM.", sampleReport.Name);


                    //</snippetPublishReport1>

                    DeleteRequiredRecords(promptForDelete);
                }
            }
            // Catch any service fault exceptions that Microsoft Dynamics CRM throws.
            catch (FaultException<Microsoft.Xrm.Sdk.OrganizationServiceFault>)
            {
                // You can handle an exception here or pass it back to the calling method.
                throw;
            }
        }