Example #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddDbContext <AppSurveyDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("AppSurveyDbContext")));
            services.AddDbContext <AppSurveyIdDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("AppSurveyIdDbContext")));
            services.AddIdentity <AppUser, IdentityRole>().AddEntityFrameworkStores <AppSurveyIdDbContext>();
            services.Configure <IdentityOptions>(options =>
            {
                options.Password.RequireDigit           = true;
                options.Password.RequiredLength         = 8;
                options.Password.RequireNonAlphanumeric = false;
                options.Password.RequireUppercase       = true;
                options.Password.RequireLowercase       = false;

                // Lockout settings
                options.Lockout.DefaultLockoutTimeSpan  = TimeSpan.FromMinutes(30);
                options.Lockout.MaxFailedAccessAttempts = 10;

                // Cookie settings
                options.Cookies.ApplicationCookie.ExpireTimeSpan = TimeSpan.FromDays(150);
                options.Cookies.ApplicationCookie.LoginPath      = "/Account/LogIn";
                options.Cookies.ApplicationCookie.LogoutPath     = "/Account/LogOff";

                // User settings
                options.User.RequireUniqueEmail = true;
            });
            services.AddScoped <File>(sp => SessionFile.GetFile(sp));
            services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddMemoryCache();
            services.AddSession();
            services.AddMvc();
        }
Example #2
0
        public void Store(TabsCollectionView tabs, ActionBarView actionBar)
        {
            var userFolder = new UserFolderPath();

            var contents = new List <IPath>();
            var queries  = new List <IQuery>();

            foreach (var tab in tabs.OpenedCustomTabs)
            {
                if (tab.Data is IQuery query)
                {
                    queries.Add(query);
                }

                if (tab.Data is IContent content)
                {
                    var path = new PartsPath(content.Source.Parts.SkipWhile(x => x.PlainText != userFolder.Name.PlainText).Skip(1));

                    contents.Add(path);
                }
            }

            var file = new SessionFile(queries.Select(x => x.PlainText), contents, new UserInterfaceSettings()
            {
                IsSideBarHidden = actionBar.IsPanelHidden
            }, new UserFolderPath());

            file.Save();
        }
Example #3
0
 /// <summary>
 /// Normalize configuration values
 /// </summary>
 public void Sanitize()
 {
     //we want to force everyone to load and sanitize so we know it's completed.
     NetworkViewer.Sanitize();
     Packager.Sanitize();
     Publisher.Sanitize();
     SessionFile.Sanitize();
     Server.Sanitize();
 }
Example #4
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Updates the session file info.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 private void UpdateSessionFileInfo(SessionFile sessionFile)
 {
     if (sessionFile == null)            // || tabSessions.SelectedTab != tpgFiles)
     {
         _infoPanel.Visible = false;
         return;
     }
     _currSessionFile    = sessionFile;
     _infoPanel.Icon     = sessionFile.LargeIcon;
     _infoPanel.FileName = sessionFile.FileName;
     _fileInfoNotes.Text = sessionFile.Notes;
     _infoPanel.LoadData(sessionFile.Fields);
     _infoPanel.Visible = true;
 }
Example #5
0
        /// <summary>
        /// Normalize configuration values
        /// </summary>
        public void Sanitize()
        {
            //we want to force everyone to load and sanitize so we know it's completed.
            NetworkViewer ??= new NetworkViewerConfiguration();
            Packager ??= new PackagerConfiguration();
            Publisher ??= new PublisherConfiguration();
            SessionFile ??= new SessionFileConfiguration();
            Server ??= new ServerConfiguration();

            NetworkViewer?.Sanitize();
            Packager?.Sanitize();
            Publisher?.Sanitize();
            SessionFile?.Sanitize();
            Server?.Sanitize();
        }
        public async Task <bool> SetHeader(string sessionName, SessionFile sessionFile, int streamChunkIndex, int totalDemoTimeMs)
        {
            if (SessionList.ContainsKey(sessionName) == false)
            {
                LogError($"Session {sessionName} not found");
                return(false);
            }

            var session = SessionList[sessionName];

            session.HeaderFile      = sessionFile;
            session.TotalDemoTimeMs = totalDemoTimeMs;

            Log($"[HEADER] Stats for {sessionName}: TotalDemoTimeMs={session.TotalDemoTimeMs}");

            return(true);
        }
Example #7
0
        public static PresetProvider CreateFromDirectory(string sessionsDirectoryPath)
        {
            var allMetaDataSets = new List <Dictionary <string, string> >();

            foreach (var sessionDirectoryPath in Directory.GetDirectories(sessionsDirectoryPath))
            {
                foreach (var path in Directory.GetFiles(sessionDirectoryPath))
                {
                    var file = SessionFile.Create(path);
                    Dictionary <string, string> dictionary = file.GetMetaDataDictionary();
                    if (dictionary.Count > 0)
                    {
                        allMetaDataSets.Add(dictionary);
                    }
                }
            }
            return(new PresetProvider(allMetaDataSets));
        }
        public async Task <StartSessionResponse> PostFile(string session, string filename, int?numChunks, int?time,
                                                          int?mTime1, int?mTime2, int?absSize)
        {
            _logger.LogInformation($"ReplayController.PostFile -- session: {session}, filename: {filename}, numChunks: {numChunks}, time: {time}" +
                                   $", mTime1: {mTime1}, mTime2: {mTime2}, absSize: {absSize}");

            byte[] data = null;
            using (var ms = new MemoryStream((int)Request.ContentLength))
            {
                await Request.Body.CopyToAsync(ms);

                data = ms.ToArray();  // returns base64 encoded string JSON result
            }

            _logger.LogDebug($"    data: {data.Length}");

            if (filename.ToLowerInvariant() == "replay.header")
            {
                SessionFile sessionFile = new SessionFile()
                {
                    Data     = data,
                    Filename = filename
                };
                await sessionDatabase.SetHeader(session, sessionFile, numChunks.Value, time.Value);
            }
            else if (filename.ToLowerInvariant().StartsWith("stream."))
            {
                if (int.TryParse(filename.ToLowerInvariant().Substring("stream.".Length), out int chunkIndex) == true)
                {
                    SessionFile sessionFile = new SessionFile()
                    {
                        Data        = data,
                        Filename    = filename,
                        StartTimeMs = mTime1.Value,
                        EndTimeMs   = mTime2.Value,
                        ChunkIndex  = chunkIndex
                    };
                    await sessionDatabase.AddChunk(session, sessionFile, time.Value, numChunks.Value, absSize.Value);
                }
            }

            return(null);
        }
        public async Task <bool> AddChunk(string sessionName, SessionFile sessionFile, int totalDemoTimeMs, int totalChunks, int totalBytes)
        {
            if (SessionList.ContainsKey(sessionName) == false)
            {
                LogError($"Session {sessionName} not found");
                return(false);
            }

            var session = SessionList[sessionName];

            session.TotalDemoTimeMs    = totalDemoTimeMs;
            session.TotalChunks        = totalChunks;
            session.TotalUploadedBytes = totalBytes;
            session.SessionFiles.Add(sessionFile);

            Log($"[CHUNK] Stats for {sessionName}: TotalDemoTimeMs={session.TotalDemoTimeMs}, TotalChunks={session.TotalChunks}, " +
                $"TotalUploadedBytes={session.TotalUploadedBytes}");

            return(true);
        }
        private void FilesListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var selector = (Selector)sender;

            if (selector.SelectedIndex == -1)
            {
                return;
            }

            if (selector.SelectedItem != null)
            {
                SessionFile selectedFile = selector.SelectedItem as SessionFile;

                if (selectedFile.FileURL != null)
                {
                    // Try to get the selected file.
                    WebBrowserTask browser = new WebBrowserTask();
                    browser.Uri = new Uri(selectedFile.FileURL);
                    browser.Show();
                }
            }
        }
Example #11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Refreshes the file list for the current session.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void RefreshFileList()
        {
            Utils.SetWindowRedraw(tabSessions, false);

            // TODO: keep track of currently selected file and try to restore
            // that after rebuilding the list.
            _currSessionFiles = (_currSession == null ? null :
                                 (from x in _currSession.Files
                                  select SessionFile.Create(x)).ToArray());

            lblEmptySessionMsg.Visible   = (_currSessionFiles != null && _currSessionFiles.Length == 0);
            splitFileTab.Panel2Collapsed = lblEmptySessionMsg.Visible;
            gridFiles.Visible            = (_currSessionFiles != null && _currSessionFiles.Length > 0);
            lnkSessionPath.Visible       = (_currSessionFiles != null && _currSessionFiles.Length == 0);
            lnkSessionPath.Text          = (_currSession != null && _currSession.Folder != null ?
                                            _currSession.Folder : string.Empty);

            if (_currSessionFiles != null)
            {
                gridFiles.RowCount = _currSessionFiles.Length;
            }

            Utils.SetWindowRedraw(tabSessions, true);
        }
Example #12
0
 public SessionContext(ILibrary library)
 {
     _library = library;
     _file    = new SessionFile(new UserFolderPath());
 }