Exemplo n.º 1
0
        /// <summary>
        /// Executes the event sub-command.  
        /// </summary>
        static void EventCommand(string[] args)
        {
            string id = OptionLast(args);
            string[] options = OptionTrim(args);
            ArgvParser parser = new ArgvParser(options);

            if (!GlobalParametersLoad(parser))
            {
                return;
            }

            Vuzit.OptionList list = new Vuzit.OptionList();
            if (parser.GetArg("e", "event") != null)
            {
                list.Add("event", parser.GetArg("e", "event"));
            }
            if (parser.GetArg("c", "custom") != null)
            {
                list.Add("custom", parser.GetArg("c", "custom"));
            }
            if (parser.GetArg("l", "limit") != null)
            {
                list.Add("limit", parser.GetArg("l", "limit"));
            }
            if (parser.GetArg("o", "offset") != null)
            {
                list.Add("offset", parser.GetArg("o", "offset"));
            }

            Vuzit.Event[] events = null;
            try
            {
                 events = Vuzit.Event.FindAll(id, list);
            }
            catch(Exception ex)
            {
                Console.WriteLine("Load failed: " + ex.Message);
                return;
            }

            int i = 1;
            Console.WriteLine("{0} events found", events.Length);
            Console.WriteLine("");

            string format = "{0:yyyy-MM-dd HH:mm:ss}";

            foreach (Vuzit.Event e in events)
            {
                Console.Write("[" + String.Format(format, e.RequestedAt) + "] ");

                if (e.EventType == "page_view")
                {
                    Console.Write(e.Duration + "s -");
                }
                Console.Write(e.EventType);

                if (e.Page != -1)
                {
                    Console.Write(", p" + e.Page);
                }
                if (e.Custom != null)
                {
                    Console.Write(" (" + e.Custom + ")");
                }
                if (e.Referer != null)
                {
                    Console.Write(" - " + e.Referer.Substring(7, 8));
                }
                Console.Write(" - " + e.RemoteHost);
                Console.Write(" - " + e.UserAgent.Substring(0, 8));
                Console.WriteLine("");
                i++;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes the search sub-command.  
        /// </summary>
        static void SearchCommand(string[] args)
        {
            string[] options = OptionRemoveFirst(args);
            ArgvParser parser = new ArgvParser(options);

            if (!GlobalParametersLoad(parser))
            {
                return;
            }

            Vuzit.OptionList list = new Vuzit.OptionList();
            if (parser.GetArg("q", "query") != null)
            {
                list.Add("query", parser.GetArg("q", "query"));
            }
            if (parser.GetArg("l", "limit") != null)
            {
                list.Add("limit", parser.GetArg("l", "limit"));
            }
            if (parser.GetArg("o", "offset") != null)
            {
                list.Add("offset", parser.GetArg("o", "offset"));
            }
            if (parser.GetArg("O", "output") != null)
            {
                list.Add("output", parser.GetArg("O", "output"));
            }

            Vuzit.Document[] documents = Vuzit.Document.FindAll(list);

            int i = 1;
            Console.WriteLine("{0} documents found", documents.Length);
            Console.WriteLine("");

            foreach (Vuzit.Document document in documents)
            {
                Console.WriteLine("LOADED [{0}]: {1}", i, document.Id);

                if (document.PageCount != -1)
                {
                    Console.WriteLine("title: {0}", document.Title);
                    Console.WriteLine("pages: {0}", document.PageCount);
                    Console.WriteLine("size: {0}", document.FileSize);
                    Console.WriteLine("excerpt: {0}", document.Excerpt);

                    Console.WriteLine("Download URL: {0}",
                                      Vuzit.Document.DownloadUrl(document.Id, "pdf"));
                    Console.WriteLine("");
                }
                i++;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Executes the upload sub-command.  
        /// </summary>
        static void UploadCommand(string[] args)
        {
            string path = OptionLast(args);
            string[] options = OptionTrim(args);
            ArgvParser parser = new ArgvParser(options);

            if (!GlobalParametersLoad(parser))
            {
                return;
            }

            Vuzit.OptionList list = new Vuzit.OptionList();

            // TODO: Use GetArg function?
            if (parser["s"] != null || parser["secure"] != null)
            {
                list.Add("secure", true);
            }
            else
            {
                list.Add("secure", false);
            }

            if (parser["p"] != null || parser["download-pdf"] != null)
            {
                list.Add("download_pdf", true);
            }

            if (parser["d"] != null || parser["download-document"] != null)
            {
                list.Add("download_document", true);
            }

            Vuzit.Document document = Vuzit.Document.Upload(path, list);
            Console.WriteLine("UPLOADED: {0}", document.Id);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Executes the page sub-command.  
        /// </summary>
        static void PageCommand(string[] args)
        {
            string id = OptionLast(args);
            string[] options = OptionTrim(args);
            ArgvParser parser = new ArgvParser(options);

            if (!GlobalParametersLoad(parser))
            {
                return;
            }

            Vuzit.OptionList list = new Vuzit.OptionList();
            if (parser.GetArg("i", "included") != null)
            {
                list.Add("included_pages", parser.GetArg("i", "included"));
            }
            if (parser.GetArg("l", "limit") != null)
            {
                list.Add("limit", parser.GetArg("l", "limit"));
            }
            if (parser.GetArg("o", "offset") != null)
            {
                list.Add("offset", parser.GetArg("o", "offset"));
            }

            Vuzit.Page[] pages = null;
            try
            {
                pages = Vuzit.Page.FindAll(id, list);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Load failed: " + ex.Message);
                return;
            }

            Console.WriteLine("{0} pages found", pages.Length);
            Console.WriteLine("");

            foreach (Vuzit.Page page in pages)
            {
                Console.WriteLine("Page: " + page.Number);
                Console.WriteLine(page.Text);
                Console.WriteLine("");
            }
        }