Esempio n. 1
0
        public HttpResponseMessage AddUser(UserSignUpViewModel userParam)
        {
            UserManager userManager = new UserManager();
            HistoryManager historyManager = new HistoryManager();
            try
            {
                var user = new User();
                user.UserName = userParam.UserName;
                user.Password = userParam.Password;
                user.Email = userParam.Email;
                user.FirstName = userParam.FirstName;
                user.MiddleName = userParam.MiddleName;
                user.LastName = userParam.LastName;

                userManager.Create(user);
                var dbUser = userManager.FindUserEmail(user.Email);
                historyManager.AddHistory(new History(dbUser)
                {
                    Activity = Activities.Joined,
                    Description = Helper.GenerateActivityDescription(dbUser, Activities.Joined)
                });
                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, user);
                return response;
            }
            catch (Exception ex)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message);
            }
        }
Esempio n. 2
0
 public void Test4()
 {
     IHistoryManager<int> h = new HistoryManager<int>(1);
     h.Add(2);
     h.Undo();
     h.Add(3);
     Assert.False(h.CanRedo());
 }
Esempio n. 3
0
 public ImageEditControl()
 {
     Zoom = 1;
     InitializeComponent();
     _draw_pen = new Pen(Color.White);
     _draw_brush = new SolidBrush(Color.White);
     _h_manager = new HistoryManager();
 }
Esempio n. 4
0
        ////////////////////////////////////////
        // LOADS HISTORY ITEMS FROM DATABASE //
        //////////////////////////////////////
        private void History_Manager_Form_Load(object sender, EventArgs e)
        {
            var items = HistoryManager.GetItems();

            foreach (var item in items)
            {
                historyListBox.Items.Add(string.Format("[{0}] {1} ({2})", item.Date, item.Title, item.URL));
            }
        }
 private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedItem != null)
     {
         HistoryManager?.MakeHistory(null);
         list.Remove((MonsterSaveBonus)listBox1.SelectedItem);
     }
     fill();
 }
 void Awake()
 {
     board          = GetComponent <Tilemap>();
     redmapManager  = GameObject.Find("Redmap").GetComponent <RedmapManager>();
     historyManager = GameObject.Find("HistoryManager").GetComponent <HistoryManager>();
     selectedMoves  = new List <Move>();
     SimulateBoard  = new Piece[8, 8];
     IsSimulate     = false;
 }
        private void clearHistoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var history = HistoryManager.GetHistoryList();

            foreach (var item in history)
            {
                HistoryManager.DeleteHistoryItem(item);
            }
        }
Esempio n. 8
0
 public void Test3()
 {
     IHistoryManager<int> h = new HistoryManager<int>();
     Assert.Throws<ApplicationException>(delegate { h.Undo(); });
     Assert.Throws<ApplicationException>(delegate { h.Redo(); });
     h.Add(1);
     Assert.Throws<ApplicationException>(delegate { h.Undo(); });
     Assert.Throws<ApplicationException>(delegate { h.Redo(); });
 }
Esempio n. 9
0
    public static HistoryManager GetInstance()
    {
        if (Instance == null)
        {
            Instance = new GameObject("HistoryManager").AddComponent <HistoryManager> ();
        }

        return(Instance);
    }
Esempio n. 10
0
 public override void Execute()
 {
     if (clearhist)
     {
         HistoryManager.ClearHistory();
     }
     ResponseBox.KeyDown(EventHandler);
     ResponseBox.SetItems(HistoryManager.GetHistory());
 }
Esempio n. 11
0
        public void Constructor_WithPath()
        {
            string         path           = Path.Combine(@"Data\HistoryManager\BeatSyncHistory-TestCol1.json");
            HistoryManager historyManager = new HistoryManager(path);

            historyManager.Initialize();
            Assert.AreEqual(Path.GetFullPath(path), historyManager.HistoryPath);
            Assert.AreEqual(8, historyManager.Count);
        }
Esempio n. 12
0
 private void ClearBtn_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(this, "Do you really want to clear your training history?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No)
     {
         return;
     }
     HistoryManager.ClearTrainingHistoryList();
     lstView.Items.Clear();
 }
Esempio n. 13
0
        public void Initialize_FileDoesntExist()
        {
            string         fileName       = "BeatSyncHistory-DoesntExist.json";
            string         filePath       = Path.Combine(HistoryTestPathDir, fileName);
            HistoryManager historyManager = new HistoryManager(filePath);

            historyManager.Initialize();
            Assert.AreEqual(historyManager.Count, 0);
        }
Esempio n. 14
0
 /// <summary>
 /// Secondary initializer
 /// </summary>
 /// <param name="javascriptEngine"></param>
 /// <param name="styleEngine"></param>
 /// <param name="restClient"></param>
 /// <param name="cookieContainer"></param>
 /// <param name="historyManager"></param>
 /// <param name="styleScrapingEnabled"></param>
 /// <param name="javascriptScrapingEnabled"></param>
 /// <param name="defaultUriProtocol"></param>
 public StandardCore(JavascriptEngine javascriptEngine, StyleEngine styleEngine,
                     RestClient restClient, CookieContainer cookieContainer,
                     HistoryManager historyManager, bool styleScrapingEnabled,
                     bool javascriptScrapingEnabled, string defaultUriProtocol) :
     base(javascriptEngine, styleEngine, restClient,
          cookieContainer, historyManager, styleScrapingEnabled,
          javascriptScrapingEnabled, defaultUriProtocol)
 {
 }
Esempio n. 15
0
        private async void LoadHistory()
        {
            var history = await HistoryManager.GetHistory();

            foreach (var item in history)
            {
                lvHistoryList.Items.Add(new FileInfo(item));
            }
        }
Esempio n. 16
0
    static void Save(string guid, UIElement root)
    {
        var di = HistoryManager.GetDataInfo(guid, true, typeof(HCanvas), typeof(HImage), typeof(TextBox), typeof(HText),
                                            typeof(HLine), typeof(HGraphics), typeof(UIElement));
        UnsafeDataWriter dw2 = new UnsafeDataWriter();
        var db = dw2.Write <HCanvas>(root, di);

        HistoryManager.AddRecord("ui", guid, db.ToBytes());
    }
Esempio n. 17
0
        public void TryAdd_NotInitialized()
        {
            var    historyManager = new HistoryManager(HistoryTestPathDir);
            string key            = "LKSJDFLKJASDLFKJ";
            string songName       = null;
            string mapperName     = null;

            Assert.ThrowsException <InvalidOperationException>(() => historyManager.TryAdd(key, songName, mapperName, 0));
        }
Esempio n. 18
0
        private void clearHistoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var hm = new HistoryManager();

            foreach (var item in HistoryManager.GetItems())
            {
                hm.DeleteItem(item.Id); //deletes from db
            }
        }
Esempio n. 19
0
 private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (listBox1.SelectedItem != null)
     {
         HistoryManager.MakeHistory(null);
         list.Remove((Description)listBox1.SelectedItem);
     }
     fill();
 }
Esempio n. 20
0
 public void OnToggleTrigger(bool isOn)
 {
     if (GlobalData.FrameToggleModifyByUndo)
     {
         GlobalData.FrameToggleModifyByUndo = false;
         return;
     }
     HistoryManager.Do(BehaviorFactory.GetUpdateFrameVisibleBehavior(isOn));
 }
 /// <summary>
 /// Performs the metadata refresh.
 /// </summary>
 public void PerformMetadataRefresh()
 {
     if (this.CheckConnectivity())
     {
         UPSyncManager syncManager = ServerSession.CurrentSession.SyncManager;
         syncManager.PerformMetadataSync();
         HistoryManager.ReleaseHistoryManager();
     }
 }
Esempio n. 22
0
        private void InitializeForm(String[] args)
        {
            if (urlToolStripTextBox.TextBox != null)
            {
                urlToolStripTextBox.TextBox.ContextMenuStrip = urlContextMenuStrip;
            }

            helpWebBrowser.StatusTextChanged += helpWebBrowser_StatusTextChanged;

            switch (args.Length)
            {
            case 1:
                GuideManager.ReadHelpGuide(this, args[0]);
                break;

            default:
                WindowManager.DisableInterface(this);
                break;
            }

            HistoryManager.InitGoBack(this);
            HistoryManager.InitGoForward(this);

            office2003ToolStripMenuItem.Checked = true;
            searchPanel.Visible = false;

            if (helpWebBrowser.IsOffline)
            {
                connectionStatusToolStripStatusLabel.Image = ToolbarResource.disconnect;
                String text = LanguageUtil.GetCurrentLanguageString("connectionStatus_Disconnected", Name, OptionManager.GetLanguage(this));
                connectionStatusToolStripStatusLabel.Text        = text;
                connectionStatusToolStripStatusLabel.ToolTipText = text;
            }
            else
            {
                connectionStatusToolStripStatusLabel.Image = ToolbarResource.connect;
                String text = LanguageUtil.GetCurrentLanguageString("connectionStatus_Connected", Name, OptionManager.GetLanguage(this));
                connectionStatusToolStripStatusLabel.Text        = text;
                connectionStatusToolStripStatusLabel.ToolTipText = text;
            }

            switch (LanguageUtil.GetReallyShortCulture(CultureInfo.CurrentCulture.Name))
            {
            case "en":
                englishToolStripMenuItem.Checked = true;
                break;

            case "it":
                italianoToolStripMenuItem.Checked = true;
                break;

            default:
                englishToolStripMenuItem.Checked = true;
                break;
            }
        }
Esempio n. 23
0
 private void button1_Click(object sender, EventArgs e)
 {
     HistoryManager?.MakeHistory(null);
     foreach (string s in input.Text.Split(new char[] { ',', ';' }))
     {
         Items.Add(s.Trim());
     }
     input.Text = "";
     fill();
 }
Esempio n. 24
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (input.Text.Length > 0)
     {
         HistoryManager?.MakeHistory(null);
         Items.Add(input.Text);
     }
     input.Text = "";
     fill();
 }
Esempio n. 25
0
 private void listBox1_DoubleClick(object sender, EventArgs e)
 {
     if (this.listBox1.SelectedItem == null)
     {
         return;
     }
     HistoryManager?.MakeHistory(null);
     Items.RemoveAt(listBox1.SelectedIndex);
     fill();
 }
        private void HistoryManagerUI_Load(object sender, EventArgs e)
        {
            var history = HistoryManager.GetHistoryData();

            foreach (var log in history)
            {
                string logItem = String.Format("[{0}] | {1} | ({2}) ", log.Date, log.Name, log.URL);
                listBox1.Items.Add(logItem);
            }
        }
        private void FilteredHistoryBox_Load(object sender, EventArgs e)
        {
            termLabel.Text = String.Format("Results for {0}", term);
            var list = HistoryManager.filterHistory(term);

            foreach (var item in list)
            {
                searchResults.Items.Add(item);
            }
        }
Esempio n. 28
0
        private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            // whenever  web page is loaded, add it to the history here
            var item = new HistoryItem();

            item.URL   = currentUrl;
            item.title = webBrowser1.DocumentTitle;
            item.date  = DateTime.Now;
            HistoryManager.AddItem(item);
        }
Esempio n. 29
0
 public void AddCommand(ICommand command)
 {
     //History manager can happen if some events were not released properly.
     //Project was closed however so change should be take into consideration
     if (HistoryManager == null)
     {
         return;
     }
     HistoryManager.AddToHistory(command);
 }
Esempio n. 30
0
        private void HistoryManagerForm_Load(object sender, EventArgs e)
        {
            var items = HistoryManager.GetAllItems();

            foreach (var item in items)
            {
                listBox1.Items.Add(item.date + ": " + item.title + " " + item.URL);
                // do better here
            }
        }
Esempio n. 31
0
    public static void RemoveConnection(Connection connection, bool markHistory = true)
    {
        if (markHistory)
        {
            HistoryManager.RecordEditor();
        }

        mainEditor.connections.Remove(connection);
        RemoveConnectionHistory(connection);
    }
        private void HistoryManagerForm_Load(object sender, EventArgs e)
        {
            var history = HistoryManager.GetItems();

            listBox1.Items.Clear();
            foreach (var pages in history)
            {
                listBox1.Items.Add(string.Format("[{0}] {1}({2})", pages.Date, pages.Title, pages.URL));
            }
        }
Esempio n. 33
0
        ///////////////////////////////////////
        // DELETES SEARCH ITEM FROM HISTORY //
        /////////////////////////////////////
        private void histDeleteButton_Click(object sender, EventArgs e)
        {
            // finds candidate for deletion
            string candidate = historyListBox.GetItemText(historyListBox.SelectedItem);

            // calls HistoryManager RemoveHist method which deletes the row
            HistoryManager.RemoveHist(candidate);
            // deletes the list box selected row as well.
            historyListBox.Items.RemoveAt(historyListBox.SelectedIndex);
        }
Esempio n. 34
0
 public SquiggleContextFactory(IInstanceFactory <PluginLoader> pluginLoaderFactory,
                               HistoryManager history,
                               MainWindow window,
                               string clientId)
 {
     this.pluginLoaderFactory = pluginLoaderFactory;
     this.history             = history;
     this.window   = window;
     this.clientId = clientId;
 }
Esempio n. 35
0
 public HttpResponseMessage AuthenticateUser(UserSignInViewModel userParam)
 {
     UserManager userManager = new UserManager();
     HistoryManager historyManager = new HistoryManager();
     try
     {
         var user = userManager.FindAuthenticatedUser(userParam.UserName, userParam.Password);
         var dbUser = userManager.FindUserEmail(user.Email);
         historyManager.AddHistory(new History(dbUser)
         {
             Activity = Activities.Login,
             Description = Helper.GenerateActivityDescription(dbUser, Activities.Login)
         });
         HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, user);
         return response;
     }
     catch (Exception ex)
     {
         return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message);
     }
 }
Esempio n. 36
0
 public void Test5()
 {
     IHistoryManager<int> h = new HistoryManager<int>(1);
     Assert.False(h.CanUndo());
     Assert.False(h.CanRedo());
 }
Esempio n. 37
0
		private bool InitializeBot()
		{
			// Read Config File
			const string configFilePath = "configTS3AudioBot.cfg";
			ConfigFile cfgFile = ConfigFile.Open(configFilePath) ?? ConfigFile.Create(configFilePath) ?? ConfigFile.GetDummy();
			var afd = cfgFile.GetDataStruct<AudioFrameworkData>(typeof(AudioFramework), true);
			var bcd = cfgFile.GetDataStruct<BobControllerData>(typeof(BobController), true);
			var qcd = cfgFile.GetDataStruct<QueryConnectionData>(typeof(QueryConnection), true);
			var hmd = cfgFile.GetDataStruct<HistoryManagerData>(typeof(HistoryManager), true);
			var pmd = cfgFile.GetDataStruct<PluginManagerData>(typeof(PluginManager), true);
			var pld = cfgFile.GetDataStruct<PlaylistManagerData>(typeof(PlaylistManager), true);
			mainBotData = cfgFile.GetDataStruct<MainBotData>(typeof(MainBot), true);
			cfgFile.Close();

			if (consoleOutput)
			{
				Log.RegisterLogger("[%T]%L: %M", "", Console.WriteLine);
			}

			if (writeLog && !string.IsNullOrEmpty(mainBotData.logFile))
			{
				var encoding = new UTF8Encoding(false);
				logStream = new StreamWriter(File.Open(mainBotData.logFile, FileMode.Append, FileAccess.Write, FileShare.Read), encoding);
				Log.RegisterLogger("[%T]%L: %M\n" + (writeLogStack ? "%S\n" : ""), "", (msg) =>
				{
					if (logStream != null)
						try
						{
							logStream.Write(msg);
							logStream.Flush();
						}
						catch (IOException) { }
				});
			}

			Log.Write(Log.Level.Info, "[============ TS3AudioBot started =============]");
			string dateStr = DateTime.Now.ToLongDateString();
			Log.Write(Log.Level.Info, "[=== Date: {0}{1} ===]", new string(' ', Math.Max(0, 32 - dateStr.Length)), dateStr);
			string timeStr = DateTime.Now.ToLongTimeString();
			Log.Write(Log.Level.Info, "[=== Time: {0}{1} ===]", new string(' ', Math.Max(0, 32 - timeStr.Length)), timeStr);
			Log.Write(Log.Level.Info, "[==============================================]");

			Log.Write(Log.Level.Info, "[============ Initializing Commands ===========]");
			CommandManager = new CommandManager();
			CommandManager.RegisterMain(this);

			Log.Write(Log.Level.Info, "[============ Initializing Modules ============]");
			QueryConnection = new QueryConnection(qcd);
			var playlistManager = new PlaylistManager(pld);
			BobController = new BobController(bcd, QueryConnection);
			// old: new VLCConnection(afd.vlcLocation);
			// new: BobController
			AudioFramework = new AudioFramework(afd, BobController, playlistManager);
			SessionManager = new SessionManager();
			HistoryManager = new HistoryManager(hmd);
			PluginManager = new PluginManager(this, pmd);

			Log.Write(Log.Level.Info, "[=========== Initializing Factories ===========]");
			FactoryManager = new ResourceFactoryManager(AudioFramework);
			FactoryManager.DefaultFactorty = new MediaFactory();
			FactoryManager.AddFactory(new YoutubeFactory());
			FactoryManager.AddFactory(new SoundcloudFactory());
			FactoryManager.AddFactory(new TwitchFactory());

			Log.Write(Log.Level.Info, "[=========== Registering callbacks ============]");
			// Inform our HistoryManager when a new resource started successfully
			AudioFramework.OnResourceStarted += HistoryManager.LogAudioResource;
			// Inform the BobClient on start/stop
			AudioFramework.OnResourceStarted += BobController.OnResourceStarted;
			AudioFramework.OnResourceStopped += BobController.OnResourceStopped;
			// In own favor update the own status text to the current song title
			AudioFramework.OnResourceStarted += SongUpdateEvent;
			// Register callback for all messages happening
			QueryConnection.OnMessageReceived += TextCallback;
			// Register callback to remove open private sessions, when user disconnects
			QueryConnection.OnClientDisconnect += (s, e) => SessionManager.RemoveSession(e.InvokerId);


			Log.Write(Log.Level.Info, "[================= Finalizing =================]");
			// Create a default session for all users in all chat
			SessionManager.DefaultSession = new PublicSession(this);
			// Connect the query after everyting is set up
			try { QueryConnection.Connect(); }
			catch (QueryCommandException qcex)
			{
				Log.Write(Log.Level.Error, "There is either a problem with your connection configuration, or the query has not all permissions it needs. ({0})", qcex);
				return false;
			}

			Log.Write(Log.Level.Info, "[============== Connected & Done ==============]");
			return true;
		}
Esempio n. 38
0
 /// <summary>
 /// Lists the history of edits for a page.
 /// </summary>
 /// <param name="id">The ID of the page.</param>
 /// <returns>An <see cref="IList`HistorySummary"/> as the model.</returns>
 public ActionResult History(int id)
 {
     HistoryManager manager = new HistoryManager();
     return View(manager.GetHistory(id).ToList());
 }
Esempio n. 39
0
        public ActionResult Revert(Guid versionId, int pageId)
        {
            // Check if the page is locked to admin edits only before reverting.
            PageManager pageManager = new PageManager();
            PageSummary page = pageManager.Get(pageId);
            if (page == null || (page.IsLocked && !RoadkillContext.Current.IsAdmin))
                return RedirectToAction("Index", "Home");

            HistoryManager manager = new HistoryManager();
            manager.RevertTo(versionId);

            return RedirectToAction("History", new { id = pageId });
        }
Esempio n. 40
0
        /// <summary>
        /// Gets a particular version of a page.
        /// </summary>
        /// <param name="id">The Guid ID for the version.</param>
        /// <returns>A <see cref="PageSummary"/> as the model, which contains the HTML diff
        /// output inside the <see cref="PageSummary.Content"/> property.</returns>
        public ActionResult Version(Guid id)
        {
            HistoryManager manager = new HistoryManager();
            IList<PageSummary> bothVersions = manager.CompareVersions(id).ToList();
            string diffHtml = "";

            if (bothVersions[1] != null)
            {
                string oldVersion = bothVersions[1].Content.WikiMarkupToHtml();
                string newVersion = bothVersions[0].Content.WikiMarkupToHtml();
                HtmlDiff diff = new HtmlDiff(oldVersion, newVersion);
                diffHtml = diff.Build();
            }
            else
            {
                diffHtml = bothVersions[0].Content.WikiMarkupToHtml();
            }

            PageSummary summary = bothVersions[0];
            summary.Content = diffHtml;
            return View(summary);
        }
Esempio n. 41
0
        private void toolStripButton5_Click(object sender, EventArgs e)
        {
            var hm = new HistoryManager();
            var hdg = new HistoryDg();
            hdg.InitList(hm.GetHead());

            var dr = hdg.ShowDialog();
            if (dr == DialogResult.OK)
            {
                _list = hm.Get<Entity>(hdg.GetSelected());
                ShowToView(_list);
            }
        }