示例#1
0
        static void Main(string[] args)
        {
            string sheetName, dataPath;

            if (args.Length == 2)
            {
                if (args[1] == "1")
                {
                    sheetName = "TestSheet";
                    dataPath  = TestFolderPath;
                }
                else
                {
                    Console.WriteLine("Incorrect number of arguments.\nusage: incidentSpreadsheet\ntesting usage: incidentSpreadsheet 1");
                    return;
                }
            }
            else if (args.Length > 3)
            {
                //bad
                Console.WriteLine("Incorrect number of arguments.\nusage: incidentSpreadsheet\ntesting usage: incidentSpreadsheet 1");
                return;
            }
            else
            {
                sheetName = "GoogleSheet";
                dataPath  = LogFolderPath;
            }
            sheetName = "TestSheet";
            dataPath  = TestFolderPath;

            // Populate the incidents
            Console.WriteLine("Grabbing incident information...");
            Incidents incidents = new Incidents();

            incidents.PopulateIncidents(dataPath);

            service = CreateService("*****@*****.**", "C:/Users/SLUGIS/Documents/DaneITDevelopment/IncidentSpreadsheet/IncidentSpreadsheet/SLUGIS-7c7a36e70ba8.p12");

            Console.WriteLine("Executing...");
            // Create Append Request
            SpreadsheetsResource.ValuesResource.AppendRequest appendRequest = GetAppendRequest(sheetName, incidents);

            Console.WriteLine("Incidents to be added: {0}", incidents.GetIncidents().Count);

            // Execute
            appendRequest.Execute();
        }
示例#2
0
        private static SpreadsheetsResource.ValuesResource.AppendRequest GetAppendRequest(string sheetName, Incidents incidents)
        {
            SpreadsheetsResource.ValuesResource.AppendRequest request;
            string range = sheetName + "!A:A";

            request = service.Spreadsheets.Values.Append(incidents.GenerateDataBlock(), spreadsheetID, range);
            request.InsertDataOption = SpreadsheetsResource.ValuesResource.AppendRequest.InsertDataOptionEnum.INSERTROWS;
            request.ValueInputOption = SpreadsheetsResource.ValuesResource.AppendRequest.ValueInputOptionEnum.RAW;

            return(request);
        }