Ejemplo n.º 1
0
        public void noid()
        {
            File.Delete("mocument");
            var s = new SQLiteStore("mocument");
            s.ClearDatabase();
            var x = s.List();
            Assert.AreEqual(0, x.Count);

            var tape = new Tape()
                           {
                               Id = "foo.bar",
                               Comment = "comment",
                               Description = "desc",
                               OpenForRecording = false,
                               AllowedIpAddress = "1.2.2.2"
                           };

            s.Insert(tape);
            x = s.List();
            Assert.AreEqual(1, x.Count);

            s.Delete(tape.Id);
            x = s.List();
            Assert.AreEqual(0, x.Count);
        }
Ejemplo n.º 2
0
        public void InitSQLiteStore()
        {
            // Create it in a folder that doesn't already exist
            string storeName = nameof(InitSQLiteStore);
            string folder    = Path.Combine(Path.GetTempPath(), DateTime.UtcNow.ToString("yyyyMMddHHmmss"));
            string dbSpec    = Path.Combine(folder, storeName + ".ac-sqlite");

            try
            {
                CmdStore    cs = Init(dbSpec, StoreType.SQLite);
                SQLiteStore ss = (cs as SQLiteStore);

                Assert.IsNotNull(ss);
                Assert.IsTrue(Directory.Exists(folder));
                Assert.IsTrue(File.Exists(dbSpec));
                Assert.AreEqual <int>(Directory.GetFiles(folder).Length, 1);
                Assert.AreEqual <string>(storeName, cs.Name);
                Assert.AreEqual <string>(dbSpec, ss.FileName);
            }

            finally
            {
                Directory.Delete(folder, true);
            }
        }
Ejemplo n.º 3
0
        public void noid()
        {
            File.Delete("mocument");
            var s = new SQLiteStore("mocument");

            s.ClearDatabase();
            var x = s.List();

            Assert.AreEqual(0, x.Count);

            var tape = new Tape()
            {
                Id               = "foo.bar",
                Comment          = "comment",
                Description      = "desc",
                OpenForRecording = false,
                AllowedIpAddress = "1.2.2.2"
            };

            s.Insert(tape);
            x = s.List();
            Assert.AreEqual(1, x.Count);

            s.Delete(tape.Id);
            x = s.List();
            Assert.AreEqual(0, x.Count);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Set things in motion so your service can do its work.
        /// </summary>
        protected override void OnStart(string[] args)
        {
            NameValueCollection appSettings = ConfigurationManager.AppSettings;

            _proxySSLPort  = int.Parse(appSettings["proxySSLPort"]);
            _proxyHostName = appSettings["proxyHostName"];
            _port          = int.Parse(appSettings["proxyPort"]);
            _secured       = bool.Parse(appSettings["proxySecured"]);
            _store         = new SQLiteStore("mocument");
            _server        = new Server(_port, _proxySSLPort, _proxyHostName, _secured, _store);
            _server.Start();
        }
Ejemplo n.º 5
0
        protected void AddButton_Click(object sender, EventArgs e)
        {
            var tape = new Tape()
            {
                Id               = ProxySettings.GetUserId() + "." + NameTextBox.Text,
                Description      = DescTextBox.Text,
                AllowedIpAddress = IpTextBox.Text,
                OpenForRecording = LockedCheckBox.Checked
            };
            var store = new SQLiteStore("mocument");

            store.Insert(tape);
            Response.Redirect("~/tapes/mytapes.aspx");
        }
Ejemplo n.º 6
0
        // ReSharper disable UnusedParameter.Local
        private static void Main(string[] args)
        // ReSharper restore UnusedParameter.Local
        {
            NameValueCollection appSettings = ConfigurationManager.AppSettings;

            _port          = int.Parse(appSettings["proxyPort"]);
            _secured       = bool.Parse(appSettings["proxySecured"]);
            _proxySSLPort  = int.Parse(appSettings["proxySSLPort"]);
            _proxyHostName = appSettings["proxyHostName"];
            _store         = new SQLiteStore("mocument");


            AppDomain.CurrentDomain.ProcessExit += CurrentDomainProcessExit;

            _server = new Server(_port, _proxySSLPort, _proxyHostName, _secured, _store);
            Console.CancelKeyPress += ConsoleCancelKeyPress;
            _server.Start();
            Console.WriteLine("Hit CTRL+C to end session.");


            bool bDone = false;

            do
            {
                Console.WriteLine(
                    "\nEnter a command [G=Collect Garbage; Q=Quit]:");
                Console.Write(">");
                ConsoleKeyInfo cki = Console.ReadKey();
                Console.WriteLine();
                switch (cki.KeyChar)
                {
                case 'g':
                    Console.WriteLine("Working Set:\t" + Environment.WorkingSet.ToString("n0"));
                    Console.WriteLine("Begin GC...");
                    GC.Collect();
                    Console.WriteLine("GC Done.\nWorking Set:\t" + Environment.WorkingSet.ToString("n0"));
                    break;

                case 'q':
                    bDone = true;
                    _server.Stop();
                    break;
                }
            } while (!bDone);
        }
Ejemplo n.º 7
0
        public MainWindowViewModel(MainWindow window)
        {
            this.window = window;

            this.ds  = new AppSettingsDataStore();
            this.api = new DevRantClient();
            this.db  = SQLiteStore.CreateInstance(ds.DBFolder);

            AppManager.Initialize(api, ds, db);

            SetLabels();


            statusMessages          = new MessageCollection();
            statusMessages.Changed += StatusChanged;

            feedView        = new CollectionViewSource();
            feedView.Source = feeds;

            //Initialize the properties
            userChecker           = new FollowedUserChecker();
            userChecker.OnUpdate += UpdateFollowedPosts;
            userChecker.Start();

            rantChecker           = new FollowedRantChecker();
            rantChecker.OnUpdate += UpdateFollowedPosts;
            rantChecker.Start();

            nchecker           = new NotificationsChecker();
            nchecker.OnUpdate += UpdateNotifications;

            Startup();

            //TestLogin();
            //Test();
        }
Ejemplo n.º 8
0
 public ContextDataSource()
 {
     _store = new SQLiteStore("mocument");
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Analyzes the command line for the AltCmd application, to determine
        /// which store (if any) should be initialized.
        /// </summary>
        /// <param name="args">The command line arguments.</param>
        /// <returns>The execution context (wraps a reference to the store that
        /// the user has specified)</returns>
        static ExecutionContext GetContext(string[] args)
        {
            // If the user is trying to initialize (or clone), don't try to determine
            // the initial store
            if (args.Length > 0)
            {
                string verb = args[0];

                if (verb.EqualsIgnoreCase("init") || verb.EqualsIgnoreCase("clone"))
                {
                    return(new ExecutionContext());
                }
            }

            // Check for a SQLite database
            if (args.Length == 1)
            {
                string dbFile = args[0];
                string dbType = Path.GetExtension(dbFile)?.ToLower();

                if (!dbType.IsDefined())
                {
                    dbType  = ".ac-sqlite";
                    dbFile += dbType;
                }

                if (File.Exists(dbFile) && dbType.Contains("sqlite"))
                {
                    // Load branch metadata for the store
                    var ss = SQLiteStore.Load(dbFile);
                    Log.Info($"Opened {ss.Name} (current branch is {ss.Current.Name})");

                    // Load up the command stream as well
                    ss.Stream = ss.Current.CreateStream();
                    return(new ExecutionContext(ss));
                }
            }

            string acSpec = null;
            string curDir = null;

            // If we've been given nothing, start by looking for
            // an AC file in the current folder. If we've been
            // given a specific folder, look in there instead.

            if (args.Length == 0)
            {
                curDir = Directory.GetCurrentDirectory();
            }
            else if (args.Length == 1 && Directory.Exists(args[0]))
            {
                curDir = args[0];
            }

            if (curDir != null)
            {
                acSpec = FileStore.GetAcFilePath(curDir);
            }

            // If we couldn't determine an initial branch based
            // on folder, see if we've been supplied with an AC file

            if (acSpec == null)
            {
                if (args.Length == 1 && File.Exists(args[0]))
                {
                    string fileName = args[0];

                    if (Path.GetExtension(fileName) == ".ac")
                    {
                        acSpec = fileName;
                    }
                    else
                    {
                        throw new ArgumentException("Unrecognized file type");
                    }
                }
            }

            // If that doesn't give us anything, look in C:\ProgramData\AltCmd
            // to obtain the last one we opened

            string progData = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
            string last     = Path.Combine(progData, "AltCmd", "last");

            if (acSpec == null && File.Exists(last))
            {
                string lastSpec = File.ReadAllText(last);
                if (File.Exists(lastSpec))
                {
                    acSpec = lastSpec;
                }
            }

            if (acSpec == null)
            {
                return(new ExecutionContext());
            }

            // Load branch metadata for the store
            FileStore fs = FileStore.Load(acSpec);

            Log.Info($"Opened {fs.Name} (current branch is {fs.Current.Name})");

            // Remember the store we opened as the last one
            fs.SaveCurrent();

            // Load up the command stream as well
            fs.Stream = fs.Current.CreateStream();

            return(new ExecutionContext(fs));
        }