/// <summary>
        /// Connect to google-spreadsheet with the specified account and password
        /// then query cells and call the given callback.
        /// </summary>
        private void DoCellQuery(OnEachCell onCell)
        {
            // first we need to connect to the google-spreadsheet to get all the first row of the cells
            // which are used for the properties of data class.
            var client = new DatabaseClient("", "");

            if (string.IsNullOrEmpty(machine.SpreadSheetName))
            {
                return;
            }
            if (string.IsNullOrEmpty(machine.WorkSheetName))
            {
                return;
            }

            string error = string.Empty;
            var    db    = client.GetDatabase(machine.SpreadSheetName, ref error);

            if (db == null)
            {
                string message = string.Empty;
                if (string.IsNullOrEmpty(error))
                {
                    message = @"Unknown error.";
                }
                else
                {
                    message = string.Format(@"{0}", error);
                }

                message += "\n\nOn the other hand, see 'GoogleDataSettings.asset' file and check the oAuth2 setting is correctly done.";
                EditorUtility.DisplayDialog("Error", message, "OK");
                return;
            }

            // retrieves all cells
            var worksheet = ((Database)db).GetWorksheetEntry(machine.WorkSheetName);

            // Fetch the cell feed of the worksheet.
            CellQuery cellQuery = new CellQuery(worksheet.CellFeedLink);
            var       cellFeed  = client.SpreadsheetService.Query(cellQuery);

            // Iterate through each cell, printing its value.
            foreach (CellEntry cell in cellFeed.Entries)
            {
                if (onCell != null)
                {
                    onCell(cell);
                }
            }
        }
        /// <summary>
        /// Connect to google-spreadsheet with the specified account and password
        /// then query cells and call the given callback.
        /// </summary>
        private void DoCellQuery(OnEachCell onCell)
        {
            // first we need to connect to the google-spreadsheet to get all the first row of the cells
            // which are used for the properties of data class.
            var client = new DatabaseClient("", "");

            if (string.IsNullOrEmpty(machine.SpreadSheetName))
            {
                return;
            }
            if (string.IsNullOrEmpty(machine.WorkSheetName))
            {
                return;
            }

            var db = client.GetDatabase(machine.SpreadSheetName);

            if (db == null)
            {
                string message = string.Format(@"The given spreadsheet '{0}' or worksheet '{1}' does not exist. Note that the name is case sensitive.",
                                               machine.SpreadSheetName, machine.WorkSheetName);
                EditorUtility.DisplayDialog("Error", message, "OK");
                return;
            }

            // retrieves all cells
            var worksheet = ((Database)db).GetWorksheetEntry(machine.WorkSheetName);

            // Fetch the cell feed of the worksheet.
            CellQuery cellQuery = new CellQuery(worksheet.CellFeedLink);
            var       cellFeed  = client.SpreadsheetService.Query(cellQuery);

            // Iterate through each cell, printing its value.
            foreach (CellEntry cell in cellFeed.Entries)
            {
                if (onCell != null)
                {
                    onCell(cell);
                }
            }
        }
Beispiel #3
0
    /// <summary>
    /// Connect to google-spreadsheet with the specified account and password
    /// then query cells and call the given callback.
    /// </summary>
    private void DoCellQuery(OnEachCell onCell)
    {
        // first we need to connect to the google-spreadsheet to get all the first row of the cells
        // which are used for the properties of data class.
        var client = new DatabaseClient(GoogleDataSettings.Instance.Account,
                                        GoogleDataSettings.Instance.Password);

        if (string.IsNullOrEmpty(machine.SpreadSheetName))
        {
            return;
        }
        if (string.IsNullOrEmpty(machine.WorkSheetName))
        {
            return;
        }

        var db = client.GetDatabase(machine.SpreadSheetName);

        if (db == null)
        {
            Debug.LogError("The given spreadsheet does not exist.");
            return;
        }

        // retrieves all cells
        var worksheet = ((Database)db).GetWorksheetEntry(machine.WorkSheetName);

        // Fetch the cell feed of the worksheet.
        CellQuery cellQuery = new CellQuery(worksheet.CellFeedLink);
        var       cellFeed  = client.SpreadsheetService.Query(cellQuery);

        // Iterate through each cell, printing its value.
        foreach (CellEntry cell in cellFeed.Entries)
        {
            if (onCell != null)
            {
                onCell(cell);
            }
        }
    }
    /// <summary>
    /// Connect to google-spreadsheet with the specified account and password then query cells and
    /// call the given callback.
    /// </summary>
    private void DoCellQuery(OnEachCell onCell)
    {
        // first we need to connect to the google-spreadsheet to get all the first row of the cells
        // which are used for the properties of data class.
        var client = new DatabaseClient("", "");

        if (string.IsNullOrEmpty(machine.SpreadSheetName))
            return;
        if (string.IsNullOrEmpty(machine.WorkSheetName))
            return;

        var db = client.GetDatabase(machine.SpreadSheetName);
        if (db == null) {
            Debug.LogError("The given spreadsheet does not exist.");
            return;
        }

        // retrieves all cells
        var worksheet = ((Database)db).GetWorksheetEntry(machine.WorkSheetName);

        // Fetch the cell feed of the worksheet.
        CellQuery cellQuery = new CellQuery(worksheet.CellFeedLink);
        var cellFeed = client.SpreadsheetService.Query(cellQuery);

        // Iterate through each cell, printing its value.
        foreach (CellEntry cell in cellFeed.Entries) {
            if (onCell != null)
                onCell(cell);
        }
    }