public JsonResult CreateTable(string tableID, string sheetName) { GoogleSheets table = new GoogleSheets(); var res = table.CreateTable(tableID, sheetName); return(Json(res, JsonRequestBehavior.AllowGet)); }
static void LoadIfNecessary() { if (allKnownEffects == null) { allKnownEffects = GoogleSheets.Get <TaleSpireEffect>(); } }
public JsonResult GetTableData(string tableID, string sheetName) { GoogleSheets table = new GoogleSheets(); GoogleDrive drive = new GoogleDrive(); string startCell = ""; string finishCell = ""; string name = ""; if (sheetName == "nullTable") { name = table.GetTableSheets(tableID)[0]; } else { name = sheetName; } var res = new { values = table.GetTable(tableID, name, startCell, finishCell), sheets = table.GetTableSheets(tableID), editable = drive.Editable(tableID) }; return(Json(res, JsonRequestBehavior.AllowGet)); }
public static void PullEnglish() { // Setup the connection to Google var sheetServiceProvider = GetServiceProvider(); var googleSheets = new GoogleSheets(sheetServiceProvider); googleSheets.SpreadSheetId = "My spread sheet id"; // We need to provide the Spreadsheet id. This can be found in the url. See docs for further info. // You should provide your String Table Collection name here var tableCollection = LocalizationEditorSettings.GetStringTableCollection("My Strings"); // We need configure what each column contains in the sheet var columnMappings = new SheetColumn[] { // Column A contains the Key new KeyColumn { Column = "A" }, // Column B contains any shared comments. These are Comment Metadata in the Shared category. new KeyCommentColumn { Column = "B" }, // Column C contains the English Locale and any comments that are just for this Locale. new LocaleColumn { Column = "C", LocaleIdentifier = "en", IncludeComments = true }, }; int mySheetId = 123456; // This it the id of the sheet in the Google Spreadsheet. it will be in the url after `gid=`. googleSheets.PullIntoStringTableCollection(mySheetId, tableCollection, columnMappings); }
/// <summary> /// Starting of the transition to a new month /// </summary> /// <returns>Result of operation</returns> internal async static Task <bool> StartTransitionAsync() { Processing = true; try { GoogleDrive drive = new GoogleDrive(); GoogleSheets sheets = new GoogleSheets(); ServiceContext serviceContext = new ServiceContext(); await serviceContext.InitContextAsync(sheets); _processIndicator = 0; _interval = 100.0 / (serviceContext.TotalHouses + 4); if (await TransitionCheck(drive)) { await Task.Run(() => CheckHeatingType(serviceContext)); await CreateFolderAndCopyFilesAsync(drive); await AddReportsToArchive(sheets, serviceContext); await CorrectFiles(sheets, serviceContext); SearchReportsCommand.ClearReportsInfo(); return(true); } else { return(false); } } finally { Processing = false; } }
/// <summary> /// Starting the archive reports search process /// </summary> /// <param name="accountId">Account to search reports</param> /// <returns>List of achive reports</returns> internal static async Task <List <ArchiveReport> > SearchAsync(string accountId) { Processing = true; try { if (Matching.IsAccountId(accountId)) { if (ArchiveReportsInfo == null) { GoogleSheets googleSheets = new GoogleSheets(); ArchiveReportsInfo = await googleSheets.GetArchiveReportsInfoAsync(); } List <ArchiveReport> reports = new List <ArchiveReport>(); foreach (var item in ArchiveReportsInfo) { if (item[1].ToString() == accountId) { reports.Add(new ArchiveReport(item)); } } return(reports); } return(null); } finally { Processing = false; } }
public JsonResult InlineEditTable(int pk, string value, string name, string tableID) { GoogleSheets table = new GoogleSheets(); string sheetName = name + Convert.ToString(pk); var res = table.InlineEditTable(tableID, sheetName, value); return(Json(res, JsonRequestBehavior.AllowGet)); }
static void LoadData() { Procs = GoogleSheets.Get <ProcDto>(Folders.InCoreData("DnD - Procs.csv"), false); foreach (ProcDto procDto in Procs) { procDto.ProcessArguments(); } }
public void Load() { allWeatherIcons.Clear(); allBackItems.Clear(); allFrontItems.Clear(); weatherSettings = GoogleSheets.Get <WeatherSceneSettingsDto>(); LoadAllKnownItems(); }
public void Save() { GoogleSheets.SaveChanges(AllKnownDecks.Where(x => x.IsDirty).ToArray()); GoogleSheets.SaveChanges(AllKnownCards.Where(x => x.IsDirty).ToArray()); GoogleSheets.SaveChanges(AllKnownFields.Where(x => x.IsDirty).ToArray()); GoogleSheets.SaveChanges(AllKnownLayerTextOptions.Where(x => x.IsDirty).ToArray()); ClearIsDirty(); }
public IEnumerable <checkedOrder> Get([FromBody] object value) { checkedOrder[] orders = JsonSerializer.Deserialize <checkedOrder[]>(value.ToString()); GoogleSheets.checkOrders(orders); return(orders); }
static void LoadData() { Functions = GoogleSheets.Get <FunctionDto>(Folders.InCoreData("DnD - Functions.csv"), false); foreach (FunctionDto functionDto in Functions) { functionDto.ProcessArguments(); } }
private static void LoadViewers() { KnownViewers = GoogleSheets.Get <DndViewer>(); foreach (DndViewer dndViewer in KnownViewers) { dndViewer.IsDirty = false; } }
/// <summary> /// Starting process of generating flyers /// </summary> /// <returns>Result of operation</returns> internal static async Task <bool> StartGenerationAsync() { Processing = true; Cancelled = false; _cts = new CancellationTokenSource(); try { GoogleSheets sheets = new GoogleSheets(); ServiceContext serviceContext = new ServiceContext(); await serviceContext.InitContextAsync(sheets); _processIndicator = 0; _interval = 100.0 / serviceContext.TotalAccounts; string folderPath = Environment.CurrentDirectory + $"\\Квитанции за {Date.GetNameCurMonth()}"; Directory.CreateDirectory(folderPath); //start generation (every house in task) Task <int>[] tasks = new Task <int> [serviceContext.TotalHouses]; for (int i = 0; i < serviceContext.TotalHouses; i++) { int num = i; tasks[i] = Task.Run(() => serviceContext.Houses[num].StartFlyersGeneration(0, _cts.Token)); } await Task.WhenAll(tasks); //extra generation if there were errors if (!_cts.IsCancellationRequested) { for (int i = 0; i < serviceContext.TotalHouses; i++) { int generatedCount = tasks[i].Result; if (generatedCount != serviceContext.TotalAccounts) { generatedCount = await Task.Run(() => serviceContext.Houses[i].StartFlyersGeneration(generatedCount, _cts.Token)); if (generatedCount != serviceContext.Houses[i].FlatCount) { throw new Exception("Генерация завершилась с ошибкой после 2 попыток, повторите операцию"); } } } return(true); } return(false); } catch (Exception e) { throw e; } finally { _cts?.Dispose(); Processing = false; } }
public static void LoadData() { dieRollEffects = new List <DieRollEffect>(); List <DieRollEffectDto> dieRollEffectDtos = GoogleSheets.Get <DieRollEffectDto>(Folders.InCoreData("DnD - DieRollEffects.csv"), false); foreach (DieRollEffectDto dieRollEffect in dieRollEffectDtos) { DieRollEffects.Add(DieRollEffect.From(dieRollEffect)); } }
void Awake() { Sheets = new GoogleSheets(m_googleSheetId, new UnityWWWProvider()); Sheets.CurrentConfigurationVariant = m_startConfig; if (m_updateOnStart) { Sheets.UpdateData((success) => { }); } }
static void LoadData() { weaponEffects = new List <ItemEffect>(); List <ItemEffectDto> weaponEffectDtos = GoogleSheets.Get <ItemEffectDto>(Folders.InCoreData("DnD - WeaponEffects.csv"), false); foreach (ItemEffectDto itemEffect in weaponEffectDtos) { WeaponEffects.Add(ItemEffect.From(itemEffect)); } }
static void PullExtension(GoogleSheetsExtension googleExtension) { // Setup the connection to Google var googleSheets = new GoogleSheets(googleExtension.SheetsServiceProvider); googleSheets.SpreadSheetId = googleExtension.SpreadsheetId; // Now update the collection. We can pass in an optional ProgressBarReporter so that we can updates in the Editor. googleSheets.PullIntoStringTableCollection(googleExtension.SheetId, googleExtension.TargetCollection as StringTableCollection, googleExtension.Columns, reporter: new ProgressBarReporter()); }
static void LoadData() { List <TrailingEffectsDto> trailingEffectsDtos = GoogleSheets.Get <TrailingEffectsDto>(Folders.InCoreData("DnD - TrailingEffects.csv"), false); trailingEffects = new List <TrailingEffect>(); foreach (TrailingEffectsDto trailingEffect in trailingEffectsDtos) { trailingEffects.Add(TrailingEffect.From(trailingEffect)); } }
public IActionResult Post([FromBody] object value) { Order order = JsonSerializer.Deserialize <Order>(value.ToString()); if (GoogleSheets.IsUnicle(order)) { GoogleSheets.WriteOrder(order); return(Ok()); } return(StatusCode(205)); }
public async Task LogServers(CommandContext ctx) { List <DiscordGuild> servers = GetServerList(); GoogleSheets sheets = new GoogleSheets(); sheets.InitSheetsApi(); sheets.UpdateData(servers); Console.WriteLine("List of servers have been written to owners Google Spreadsheet."); await Task.CompletedTask; }
public async Task <bool> GetDataFromSheetsAsync(string key) { GoogleSheets googleSheets = new GoogleSheets(); ServiceContext serviceContext = new ServiceContext(); await serviceContext.InitContextAsync(googleSheets); _cache.Set(key, serviceContext, new MemoryCacheEntryOptions { AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(10) }); return(true); }
private static async Task AddReportsToArchive(GoogleSheets sheets, ServiceContext serviceContext) { List <IList <object> > archiveReports = new List <IList <object> >(); for (int i = 0; i < serviceContext.TotalHouses; i++) { archiveReports.AddRange(serviceContext.Houses[i].GetObjects()); } UpdateInfo($"Сохранение отчета ..."); var oldReports = await sheets.GetArchiveReportsInfoAsync(); archiveReports.AddRange(oldReports); await sheets.UpdateArchiveReportsInfoAsync(archiveReports); }
private static async Task CorrectFiles(GoogleSheets sheets, ServiceContext serviceContext) { string month = Date.GetNameCurMonth(); for (int i = 0; i < serviceContext.TotalHouses; i++) { UpdateInfo($"Переход на новый месяц дома {serviceContext.Houses[i].ShortAdress} ..."); await serviceContext.Houses[i].TransitionToNewMonth(month); } await sheets.UpdateGeneralMonthAsync(new List <IList <object> > { new List <object> { month, DateTime.Now.Year } }); }
static void AddLevelDocs(StringBuilder finalReadme) { var levels = CsvData.Get <LevelDto>(FileName.SceneLevels); var levelTemplate = File.ReadAllText(FileName.LevelTemplate).Split("\r\n"); bool needToAddScenes = false; //var scenes = CsvData.Get<SceneDto>(FileName.SceneData); var scenes = GoogleSheets.Get <SceneDto>(); foreach (var level in levels) { List <SceneDto> filteredScenes = scenes.Where(x => x.LevelStr == level.Level && x.LimitToUser == "") .OrderBy(x => x.ChatShortcut) .ToList(); if (filteredScenes.Count == 0) { continue; } foreach (string line in levelTemplate) { string replacedLine = line.Replace("$LevelNumber$", level.Level) .Replace("$LevelDoc$", level.Doc) .Replace("$LevelPic$", GetPicMarkDown(level.Pic)); if (needToAddScenes) { foreach (SceneDto scene in filteredScenes) { string sceneLine = replacedLine.Replace("$Shortcut$", scene.ChatShortcut) .Replace("$Scene$", GetSceneName(scene.SceneName)) .Replace("$Category$", scene.Category); finalReadme.AppendLine(sceneLine); } needToAddScenes = false; } else { finalReadme.AppendLine(replacedLine); } if (line.StartsWith("|") && line.IndexOf("-") > 0) { needToAddScenes = true; } } } }
/// <summary> /// Gets/deserializes all objects of type T from a specified *.csv file. /// </summary> /// <typeparam name="T">The type of the objects stored in the *csv file.</typeparam> /// <param name="dataFileName">The full path to the *.csv file.</param> /// <returns>Returns a list of T found in the file.</returns> /// <exception cref="InvalidDataException"></exception> public static List <T> Get <T>(string dataFileName) where T : new() { string fileNameOnly = Path.GetFileNameWithoutExtension(dataFileName); const string DocSheetSeparator = " - "; int docSheetSeparatorPosition = fileNameOnly.IndexOf(DocSheetSeparator); if (docSheetSeparatorPosition > 0) { string docFileName = fileNameOnly.Substring(0, docSheetSeparatorPosition); string sheetName = fileNameOnly.Substring(docSheetSeparatorPosition + DocSheetSeparator.Length); return(GoogleSheets.Get <T>(docFileName, sheetName)); } throw new InvalidDataException($"DocSheetSeparator (\"{DocSheetSeparator}\") not found."); }
private void HandleCommand(string cmdText, string args, ChatMessage chatMessage) { ChatCommand command = FindCommand(cmdText); if (command == null) { return; } if (command.Command == "reload") { chatCommands = GoogleSheets.Get <ChatCommand>(); return; } // TODO: Add shows watched - allViewers.GetUserLevel(chatMessage) command.Execute(hub, chatMessage, cmdText, args, 0); return; }
public static void PushProjectLocales() { // Setup the connection to Google var sheetServiceProvider = GetServiceProvider(); var googleSheets = new GoogleSheets(sheetServiceProvider); googleSheets.SpreadSheetId = "My spread sheet id"; // We need to provide the Spreadsheet id. This can be found in the url. See docs for further info. // Prepare the data we want to push. // You should provide your String Table Collection name here var tableCollection = LocalizationEditorSettings.GetStringTableCollection("My Strings"); // CreateDefaultMapping will create a KeyColumn and a LocaleColumn for each Locale in the project. var columnMappings = ColumnMapping.CreateDefaultMapping(); int mySheetId = 123456; // This it the id of the sheet in the Google Spreadsheet. it will be in the url after `gid=`. // Now send the update. We can pass in an optional ProgressBarReporter so that we can see updates in the Editor. googleSheets.PushStringTableCollection(mySheetId, tableCollection, columnMappings, new ProgressBarReporter()); }
public static void Save(Card card) { if (card == null) { return; } SavedCardStyle savedCard = Get(card.Name); if (savedCard == null) { savedCard = new SavedCardStyle(card); AllKnownCardStyles.Add(savedCard); } else { savedCard.LoadFrom(card); } GoogleSheets.SaveChanges(savedCard); }
public static void Save(string name, string effect) { TaleSpireEffect taleSpireEffect = Get(name); if (taleSpireEffect == null) { taleSpireEffect = new TaleSpireEffect() { Name = name, Effect = effect }; allKnownEffects.Add(taleSpireEffect); } else { taleSpireEffect.Effect = effect; } GoogleSheets.SaveChanges(taleSpireEffect); }