本文整理汇总了C#中Google.GData.Spreadsheets.SpreadsheetsService.Batch方法的典型用法代码示例。如果您正苦于以下问题:C# SpreadsheetsService.Batch方法的具体用法?C# SpreadsheetsService.Batch怎么用?C# SpreadsheetsService.Batch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Google.GData.Spreadsheets.SpreadsheetsService
的用法示例。
在下文中一共展示了SpreadsheetsService.Batch方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateEntryCellsMap
private static Dictionary<string, CellEntry> CreateEntryCellsMap(SpreadsheetsService service, CellFeed cellFeed,
List<ExcelCell> cells)
{
Dictionary<string, CellEntry> res = new Dictionary<string, CellEntry>();
CellFeed batchRequest = new CellFeed(new Uri(cellFeed.Self), service);
foreach (ExcelCell cell in cells) {
if (cell.GetEntry() == null) {
CellEntry batchEntry = new CellEntry(cell.Row, cell.Column, cell.GetBatchID());
batchEntry.Id = new AtomId(string.Format("{0}/{1}", cellFeed.Self, cell.GetBatchID()));
batchEntry.BatchData = new GDataBatchEntryData(cell.GetBatchID(), GDataBatchOperationType.query);
batchRequest.Entries.Add(batchEntry);
}
else {
if (!res.ContainsKey(cell.GetBatchID())) {
res.Add(cell.GetBatchID(), cell.GetEntry());
}
}
}
if (batchRequest.Entries.Count > 0) {
CellFeed queryBatchResponse = (CellFeed) service.Batch(batchRequest, new Uri(cellFeed.Batch));
foreach (CellEntry entry in queryBatchResponse.Entries) {
res.Add(entry.BatchData.Id, entry);
}
}
return res;
}
示例2: SheetSync
/// <summary>
/// Updates the online spreadsheet according the maps file
/// </summary>
///
public static void SheetSync(bool ForceSync)
{
Bot.SteamFriends.SetPersonaName("[" + ImpMaster.Maplist.Count.ToString() + "] " + Bot.DisplayName);
if ((GroupChatHandler.OnlineSync.StartsWith("true", StringComparison.OrdinalIgnoreCase) && !SyncRunning) || ForceSync)
{
SyncRunning = true;
//Log.Interface ("Beginning Sync");
OAuth2Parameters parameters = new OAuth2Parameters();
parameters.ClientId = GroupChatHandler.CLIENT_ID;
parameters.ClientSecret = GroupChatHandler.CLIENT_SECRET;
parameters.RedirectUri = GroupChatHandler.REDIRECT_URI;
parameters.Scope = GroupChatHandler.SCOPE;
parameters.AccessType = "offline";
parameters.RefreshToken = GroupChatHandler.GoogleAPI;
OAuthUtil.RefreshAccessToken(parameters);
string accessToken = parameters.AccessToken;
GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, GroupChatHandler.IntegrationName, parameters);
SpreadsheetsService service = new SpreadsheetsService(GroupChatHandler.IntegrationName);
service.RequestFactory = requestFactory;
SpreadsheetQuery query = new SpreadsheetQuery(SpreadSheetURI);
SpreadsheetFeed feed = service.Query(query);
SpreadsheetEntry spreadsheet = (SpreadsheetEntry)feed.Entries[0];
WorksheetFeed wsFeed = spreadsheet.Worksheets;
WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[0];
worksheet.Cols = 5;
worksheet.Rows = Convert.ToUInt32(ImpMaster.Maplist.Count + 1);
worksheet.Update();
CellQuery cellQuery = new CellQuery(worksheet.CellFeedLink);
cellQuery.ReturnEmpty = ReturnEmptyCells.yes;
CellFeed cellFeed = service.Query(cellQuery);
CellFeed batchRequest = new CellFeed(cellQuery.Uri, service);
int Entries = 1;
foreach (var item in ImpMaster.Maplist)
{
Entries = Entries + 1;
foreach (CellEntry cell in cellFeed.Entries)
{
if (cell.Title.Text == "A" + Entries.ToString())
{
cell.InputValue = item.Key;
}
if (cell.Title.Text == "B" + Entries.ToString())
{
cell.InputValue = item.Value.Item1;
}
if (cell.Title.Text == "C" + Entries.ToString())
{
cell.InputValue = item.Value.Item2.ToString();
}
if (cell.Title.Text == "D" + Entries.ToString())
{
cell.InputValue = item.Value.Item3.ToString();
}
if (cell.Title.Text == "E" + Entries.ToString())
{
cell.InputValue = item.Value.Item4.ToString();
}
}
}
cellFeed.Publish();
CellFeed batchResponse = (CellFeed)service.Batch(batchRequest, new Uri(cellFeed.Batch));
// Log.Interface("Completed Sync");
SyncRunning = false;
}
else if (GroupChatHandler.OnlineSync.StartsWith("true", StringComparison.OrdinalIgnoreCase))
{
GroupChatHandler.SpreadsheetSync = true;
}
}