Exemple #1
0
 public async Task <ModuleAction> GetAction_RemoveAllAsync()
 {
     if (!IsAuthorized("RemoveLog"))
     {
         return(null);
     }
     using (LogDataProvider logDP = new LogDataProvider()) {
         if (!await logDP.IsInstalledAsync())
         {
             return(null);
         }
     };
     return(new ModuleAction(this)
     {
         Url = Utility.UrlFor(typeof(LogBrowseModuleController), "RemoveAll"),
         NeedsModuleContext = true,
         Image = await CustomIconAsync("RemoveAll.png"),
         Style = ModuleAction.ActionStyleEnum.Post,
         LinkText = this.__ResStr("removeAllLink", "Remove All"),
         MenuText = this.__ResStr("removeAllMenu", "Remove All"),
         Tooltip = this.__ResStr("removeAllTT", "Remove all scheduler log records"),
         Legend = this.__ResStr("removeAllLegend", "Removes all scheduler log records"),
         Category = ModuleAction.ActionCategoryEnum.Delete,
         Mode = ModuleAction.ActionModeEnum.Any,
         Location = ModuleAction.ActionLocationEnum.NoAuto,
         ConfirmationText = this.__ResStr("removeConfirm", "Are you sure you want to remove ALL scheduler log records?"),
     });
 }
Exemple #2
0
 public async Task <ModuleAction> GetAction_DownloadZippedLogAsync()
 {
     if (!IsAuthorized("Downloads"))
     {
         return(null);
     }
     using (LogDataProvider logDP = new LogDataProvider()) {
         if (!await logDP.IsInstalledAsync())
         {
             return(null);
         }
     };
     return(new ModuleAction(this)
     {
         Url = Utility.UrlFor(typeof(LogBrowseModuleController), "DownloadZippedLog"),
         NeedsModuleContext = true,
         CookieAsDoneSignal = true,
         Image = await CustomIconAsync("Download.png"),
         LinkText = this.__ResStr("dlZipLink", "Download Log (Zipped)"),
         MenuText = this.__ResStr("dlZipMenu", "Download Log (Zipped)"),
         Tooltip = this.__ResStr("dlZipTT", "Download the scheduler log file as a ZIP file"),
         Legend = this.__ResStr("dlZipLegend", "Downloads the scheduler log file as a ZIP file"),
         Style = ModuleAction.ActionStyleEnum.Normal,
         Category = ModuleAction.ActionCategoryEnum.Read,
         Mode = ModuleAction.ActionModeEnum.Any,
         Location = ModuleAction.ActionLocationEnum.NoAuto,
     });
 }
Exemple #3
0
        public async Task <ActionResult> DownloadLog(long cookieToReturn)
        {
            using (LogDataProvider logDP = new LogDataProvider()) {
                string filename = logDP.GetLogFileName();
                if (!await FileSystem.FileSystemProvider.FileExistsAsync(filename))
                {
                    throw new Error(this.__ResStr("logNotFound", "The scheduler log file '{0}' cannot be located", filename));
                }
#if MVC6
                Response.Headers.Remove("Cookie");
                Response.Cookies.Append(Basics.CookieDone, cookieToReturn.ToString(), new Microsoft.AspNetCore.Http.CookieOptions {
                    HttpOnly = false, Path = "/"
                });
#else
                HttpCookie cookie = new HttpCookie(Basics.CookieDone, cookieToReturn.ToString());
                Response.Cookies.Remove(Basics.CookieDone);
                Response.SetCookie(cookie);
#endif

                string contentType = "application/octet-stream";
#if MVC6
                return(new PhysicalFileResult(filename, contentType)
                {
                    FileDownloadName = "Logfile.txt"
                });
#else
                FilePathResult result = new FilePathResult(filename, contentType);
                result.FileDownloadName = "SchedulerLog.txt";
                return(result);
#endif
            }
        }
Exemple #4
0
        public async Task <ActionResult> RemoveAll()
        {
            using (LogDataProvider logDP = new LogDataProvider()) {
                await logDP.RemoveItemsAsync(null);

                return(Reload(null, Reload: ReloadEnum.ModuleParts));
            }
        }
        public async Task LoadAsyncData_Test(DateTime pocatek, DateTime konec)
        {
            // Act
            var output = await LogDataProvider.LoadAsyncData(pocatek, konec);

            // Assert
            Assert.True(output.Pocatek == pocatek && output.Konec == konec);
        }
        public async Task LoadAsyncData_SameDateForPocatekAndKonec()
        {
            // Arrange
            DateTime datum = DateTime.Parse("7.5.2020 18:22:11");
            // Act
            var output = await LogDataProvider.LoadAsyncData(datum, datum);

            // Assert
            Assert.True(output.Count == 1 && output.First().Datum == datum);
        }
        public async Task LoadAsyncData_ErrorWhenDataAreTooBig()
        {
            // Arrange
            DateTime pocatek = DateTime.Parse("7.5.2020 18:22:11");
            DateTime konec   = DateTime.Parse("28.5.2020 18:22:11");
            // Act
            Func <Task> action = async() => await LogDataProvider.LoadAsyncData(pocatek, konec);

            // Assert
            var ex = await Assert.ThrowsAsync <ProcesEndedByUserException>(action);

            Assert.Contains("Too many data rows", ex.Message);
        }
        public async Task <ActionResult> LogDisplay(int logEntry)
        {
            using (LogDataProvider logDP = new LogDataProvider()) {
                LogData data = await logDP.GetItemAsync(logEntry);

                if (data == null)
                {
                    throw new Error(this.__ResStr("notFound", "Scheduler log entry with id {0} not found"), logEntry);
                }
                DisplayModel model = new DisplayModel();
                model.SetData(data);
                return(View(model));
            }
        }
Exemple #9
0
 public async Task <ActionResult> LogBrowse()
 {
     using (LogDataProvider logDP = new LogDataProvider()) {
         BrowseModel model = new BrowseModel {
             LogAvailable      = await logDP.IsInstalledAsync(),
             BrowsingSupported = logDP.CanBrowse,
         };
         if (logDP.CanBrowse)
         {
             model.GridDef = GetGridModel();
         }
         return(View(model));
     }
 }
Exemple #10
0
        public override async Task <MenuList> GetModuleMenuListAsync(ModuleAction.RenderModeEnum renderMode, ModuleAction.ActionLocationEnum location)
        {
            MenuList menuList = await base.GetModuleMenuListAsync(renderMode, location);

            if (location == ModuleAction.ActionLocationEnum.ModuleLinks)
            {
                using (LogDataProvider logDP = new LogDataProvider()) {
                    if (logDP.CanBrowse)
                    {
                        menuList.New(await GetAction_RemoveAllAsync());
                    }
                    else
                    {
                        menuList.New(await GetAction_DownloadZippedLogAsync());
                        menuList.New(await GetAction_DownloadLogAsync());
                    }
                }
            }
            return(menuList);
        }
Exemple #11
0
        private GridDefinition GetGridModel()
        {
            return(new GridDefinition {
                SizeStyle = GridDefinition.SizeStyleEnum.SizeToFit,
                ModuleGuid = Module.ModuleGuid,
                SettingsModuleGuid = Module.PermanentGuid,
                RecordType = typeof(BrowseItem),
                InitialPageSize = 20,
                AjaxUrl = GetActionUrl(nameof(LogBrowse_GridData)),
                DirectDataAsync = async(int skip, int take, List <DataProviderSortInfo> sort, List <DataProviderFilterInfo> filters) => {
                    using (LogDataProvider logDP = new LogDataProvider()) {
                        DataProviderGetRecords <LogData> browseItems = await logDP.GetItemsAsync(skip, take, sort, filters);

                        return new DataSourceResult {
                            Data = (from s in browseItems.Data select new BrowseItem(Module, s)).ToList <object>(),
                            Total = browseItems.Total
                        };
                    }
                },
            });
        }
Exemple #12
0
        public async Task <ActionResult> DownloadZippedLog(long cookieToReturn)
        {
            using (LogDataProvider dataProvider = new LogDataProvider()) {
                string filename = dataProvider.GetLogFileName();
                if (!await FileSystem.FileSystemProvider.FileExistsAsync(filename))
                {
                    throw new Error(this.__ResStr("logNotFound", "The scheduler log file '{0}' cannot be located", filename));
                }
#if MVC6
#else
                HttpCookie cookie = new HttpCookie(Basics.CookieDone, cookieToReturn.ToString());
                Response.Cookies.Remove(Basics.CookieDone);
                Response.SetCookie(cookie);
#endif
                string        zipName = "Logfile.zip";
                YetaWFZipFile zipFile = new YetaWFZipFile {
                    FileName = zipName,
                };
                zipFile.AddFile(filename, "SchedulerLog.txt");
                return(new ZippedFileResult(zipFile, cookieToReturn));
            }
        }
Exemple #13
0
 public LogBusiness()
 {
     _provider = new LogDataProvider();
 }
Exemple #14
0
 internal void Init()
 {
     logDP = new LogDataProvider();
 }