[3] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using Google.GData.Client;
|
---|
| 6 | using Google.GData.Extensions;
|
---|
| 7 | using Google.GData.Spreadsheets;
|
---|
| 8 | using LoggingTool.interfaces;
|
---|
| 9 | using LoggingTool.models;
|
---|
| 10 | using System.IO;
|
---|
| 11 | using UDKTCPLink;
|
---|
| 12 | using LoggingTool.network;
|
---|
| 13 | using System.Threading;
|
---|
| 14 |
|
---|
| 15 | namespace LoggingTool
|
---|
| 16 | {
|
---|
| 17 | class TestSpreadsheetOutput
|
---|
| 18 | {
|
---|
| 19 |
|
---|
| 20 | /*static void Main(string[] args)
|
---|
| 21 | {
|
---|
| 22 | //new SpreadsheetLogicTest();
|
---|
| 23 | Console.ReadKey();
|
---|
| 24 | }*/
|
---|
| 25 | }
|
---|
| 26 | class SpreadsheetOutputTest
|
---|
| 27 | {
|
---|
| 28 | private ILoggerOutput output;
|
---|
| 29 |
|
---|
| 30 | public SpreadsheetOutputTest()
|
---|
| 31 | {
|
---|
| 32 | output = new TeamUpSpeadsheetOutput("cpsgamingstreet@gmail.com", "wachtwoord2009", "GDataTest");
|
---|
| 33 | LoggerMessage questionnaireMessage = new TeamUpSpreadsheetMessage(TeamUpSpreadsheetMessage.QUESTIONNAIRE, new List<String>() {"1", "11.8940", "1", "20", "0", "1", "2", "3", "4", "5", "6", "7", "8"});
|
---|
| 34 | LoggerMessage eventMessage = new TeamUpSpreadsheetMessage(TeamUpSpreadsheetMessage.EVENT, new List<String>() {"1", "11.8940", "1337"});
|
---|
| 35 | output.send(questionnaireMessage);
|
---|
| 36 | output.send(eventMessage);
|
---|
| 37 | }
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | /* class SpreadsheetLogicTest
|
---|
| 41 | {
|
---|
| 42 | private ILoggerLogic logic;
|
---|
| 43 | private ILoggerOutput output;
|
---|
| 44 | private ILoggerInput input;
|
---|
| 45 |
|
---|
| 46 | public SpreadsheetLogicTest()
|
---|
| 47 | {
|
---|
| 48 |
|
---|
| 49 | Console.WriteLine("Setting up Logic");
|
---|
| 50 | logic = new TeamUpLogic();
|
---|
| 51 | Console.WriteLine("Setting up Output");
|
---|
| 52 | output = new TeamUpSpeadsheetOutput("cpsgamingstreet@gmail.com", "wachtwoord2009", "GDataTest");
|
---|
| 53 | Console.WriteLine("Setting up Input");
|
---|
| 54 | input = new TeamUpInput(logic);
|
---|
| 55 |
|
---|
| 56 | Console.WriteLine("Setting up Server");
|
---|
| 57 | TeamUpServer server = new TeamUpServer();
|
---|
| 58 | Console.WriteLine("Setting Protocol");
|
---|
| 59 | server.Protocol = new TeamUpProtocol(server);
|
---|
| 60 | Console.WriteLine("Activating Server");
|
---|
| 61 | server.Activate(input);
|
---|
| 62 | while (true)
|
---|
| 63 | Thread.Sleep(1000);
|
---|
| 64 |
|
---|
| 65 |
|
---|
| 66 | /*
|
---|
| 67 | //Create some filestreams for testing purposes
|
---|
| 68 | FileStream fQ = new FileStream("D:\\jkraaijeveld\\Desktop\\questionnaires.log", FileMode.Open);
|
---|
| 69 | FileStream fE = new FileStream("D:\\jkraaijeveld\\Desktop\\events.log", FileMode.Open);
|
---|
| 70 | StreamReader sQ = new StreamReader(fQ);
|
---|
| 71 | StreamReader sE = new StreamReader(fE);
|
---|
| 72 |
|
---|
| 73 | //Read everything in both of the files
|
---|
| 74 | while (!sQ.EndOfStream)
|
---|
| 75 | {
|
---|
| 76 | logic.addInput(sQ.ReadLine());
|
---|
| 77 | }
|
---|
| 78 | while (!sE.EndOfStream)
|
---|
| 79 | {
|
---|
| 80 | logic.addInput(sE.ReadLine());
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | //Create all the models
|
---|
| 84 | logic.createModels();
|
---|
| 85 | //Write them
|
---|
| 86 | List<LoggerMessage> messages = logic.formatModels();
|
---|
| 87 | foreach (LoggerMessage message in messages)
|
---|
| 88 | {
|
---|
| 89 | output.send(message);
|
---|
| 90 | }
|
---|
| 91 | }
|
---|
| 92 | }*/
|
---|
| 93 |
|
---|
| 94 |
|
---|
| 95 |
|
---|
| 96 |
|
---|
| 97 |
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 |
|
---|
| 101 |
|
---|
| 102 | /*static void Main(string[] args)
|
---|
| 103 | {
|
---|
| 104 | //Login to google docs
|
---|
| 105 | SpreadsheetsService service = new SpreadsheetsService("testLogger");
|
---|
| 106 |
|
---|
| 107 | //Retrieve all spreadsheets in the account
|
---|
| 108 | SpreadsheetQuery query = new SpreadsheetQuery();
|
---|
| 109 | SpreadsheetFeed feed = service.Query(query);
|
---|
| 110 |
|
---|
| 111 | Console.WriteLine("All spreadsheets:");
|
---|
| 112 | SpreadsheetEntry testEntry = new SpreadsheetEntry();
|
---|
| 113 | foreach (SpreadsheetEntry entry in feed.Entries)
|
---|
| 114 | {
|
---|
| 115 | Console.WriteLine(entry.Title.Text);
|
---|
| 116 | if(entry.Title.Text.Equals("GDataTest"))
|
---|
| 117 | {
|
---|
| 118 | testEntry = entry;
|
---|
| 119 | }
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | //Get the first worksheet
|
---|
| 123 | AtomLink link = testEntry.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null);
|
---|
| 124 | WorksheetQuery workSheetQuery = new WorksheetQuery(link.HRef.ToString());
|
---|
| 125 | WorksheetFeed workSheetFeed = service.Query(workSheetQuery);
|
---|
| 126 | WorksheetEntry worksheet = (WorksheetEntry)workSheetFeed.Entries.First();
|
---|
| 127 |
|
---|
| 128 | writeRow(service, worksheet);
|
---|
| 129 |
|
---|
| 130 | //Prompt user for cell to update
|
---|
| 131 | Console.Write("Row of cell to update? ");
|
---|
| 132 | string row = Console.ReadLine();
|
---|
| 133 | Console.Write("Column of cell to update? ");
|
---|
| 134 | string col = Console.ReadLine();
|
---|
| 135 |
|
---|
| 136 | //Get the proper cell
|
---|
| 137 | AtomLink cellFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.CellRel, null);
|
---|
| 138 | CellQuery cellQuery = new CellQuery(cellFeedLink.HRef.ToString());
|
---|
| 139 | cellQuery.MinimumRow = cellQuery.MaximumRow = uint.Parse(row);
|
---|
| 140 | cellQuery.MinimumColumn = cellQuery.MaximumColumn = uint.Parse(col);
|
---|
| 141 | CellFeed cellFeed = service.Query(cellQuery);
|
---|
| 142 | CellEntry cell = (CellEntry)cellFeed.Entries.First();
|
---|
| 143 |
|
---|
| 144 | Console.Write("Enter a new Value: ");
|
---|
| 145 | cell.Cell.InputValue = Console.ReadLine();
|
---|
| 146 | AtomEntry updatedCell = cell.Update();
|
---|
| 147 |
|
---|
| 148 |
|
---|
| 149 | Console.ReadKey();
|
---|
| 150 |
|
---|
| 151 | }
|
---|
| 152 |
|
---|
| 153 | public static void writeRow(SpreadsheetsService service, WorksheetEntry worksheet)
|
---|
| 154 | {
|
---|
| 155 | String[] testArray = new String[] { "Testing", "inserting", "row", "into", "spreadsheet" };
|
---|
| 156 |
|
---|
| 157 |
|
---|
| 158 | AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null);
|
---|
| 159 |
|
---|
| 160 | ListQuery query = new ListQuery(listFeedLink.HRef.ToString());
|
---|
| 161 | ListFeed feed = service.Query(query);
|
---|
| 162 |
|
---|
| 163 | ListEntry firstRow = feed.Entries[0] as ListEntry;
|
---|
| 164 | ListEntry newRow = new ListEntry();
|
---|
| 165 |
|
---|
| 166 |
|
---|
| 167 | for (int i = 0; i < testArray.Length; i++)
|
---|
| 168 | {
|
---|
| 169 |
|
---|
| 170 | ListEntry.Custom element = firstRow.Elements[i];
|
---|
| 171 | ListEntry.Custom curElement = new ListEntry.Custom();
|
---|
| 172 | curElement.LocalName = element.LocalName;
|
---|
| 173 | curElement.Value = testArray[i];
|
---|
| 174 |
|
---|
| 175 | newRow.Elements.Add(curElement);
|
---|
| 176 | }
|
---|
| 177 |
|
---|
| 178 | Console.WriteLine("Row is inserted when you press a key.");
|
---|
| 179 | Console.ReadKey();
|
---|
| 180 |
|
---|
| 181 | ListEntry insertedRow = feed.Insert(newRow) as ListEntry;
|
---|
| 182 |
|
---|
| 183 |
|
---|
| 184 | }
|
---|
| 185 | }*/
|
---|
| 186 | }
|
---|