public void ExportThread(object in_instance) { // Do all of our exporting here switch (WorksheetExportType) { case ExportType.CSV: { Google2u.ExportCsv(this, _CSVPath, MyWorkbook.ExportOptions); Google2u.Instance.InstanceData.Commands.Add(GFCommand.AssetDatabaseRefresh); break; } case ExportType.JSON: { Google2u.ExportJson(this, _JSONPath, MyWorkbook.ExportOptions); Google2u.Instance.InstanceData.Commands.Add(GFCommand.AssetDatabaseRefresh); } break; case ExportType.NGUI: { if (MyWorkbook.ExportOptions.NGUILegacyExport) { Google2u.ExportNGUILegacy(this, _NGUIPath, MyWorkbook.ExportOptions); } else { Google2u.ExportNGUI(this, _NGUIPath, MyWorkbook.ExportOptions); } Google2u.Instance.InstanceData.Commands.Add(GFCommand.AssetDatabaseRefresh); } break; case ExportType.StaticDatabase: { var respath = Path.Combine(_StaticDbPath, WorksheetName).Replace('\\', '/'); Google2u.ExportStaticDB(this, respath, WorksheetName, MyWorkbook.ExportOptions); Google2u.Instance.InstanceData.Commands.Add(GFCommand.AssetDatabaseRefresh); } break; case ExportType.XML: { Google2u.ExportXML(this, _XMLPath, MyWorkbook.ExportOptions); Google2u.Instance.InstanceData.Commands.Add(GFCommand.AssetDatabaseRefresh); } break; case ExportType.ObjectDatabase: { var respath = Path.Combine(_ObjdbResourcesPath, WorksheetName).Replace('\\', '/'); var edpath = Path.Combine(_ObjdbEditorPath, WorksheetName).Replace('\\', '/'); Google2u.ExportObjectDb(this, respath, edpath, _PlaymakerPath, MyWorkbook.ExportOptions); } break; default: return; } }
public void DoExport() { switch (WorksheetExportType) { default: return; case ExportType.CSV: _CSVPath = Google2uGUIUtil.GetString("g2ucsvDirectory", Google2u.Google2uGenPath("CSV")); break; case ExportType.JSON: _JSONPath = Google2uGUIUtil.GetString("g2ujsonDirectory", Google2u.Google2uGenPath("JSON")); break; case ExportType.NGUI: _NGUIPath = Google2uGUIUtil.GetString("g2unguiDirectory", Google2u.Google2uGenPath("NGUI")); break; case ExportType.StaticDatabase: _StaticDbPath = Google2uGUIUtil.GetString("g2uStaticDBResourcesDirectory", Google2u.Google2uGenPath("STATICDBRESOURCES")); break; case ExportType.XML: _XMLPath = Google2uGUIUtil.GetString("g2uxmlDirectory", Google2u.Google2uGenPath("XML")); break; case ExportType.ObjectDatabase: _ObjdbResourcesPath = Google2uGUIUtil.GetString("g2uobjDBResourcesDirectory", Google2u.Google2uGenPath("OBJDBRESOURCES")); _ObjdbEditorPath = Google2uGUIUtil.GetString("g2uobjDBEditorDirectory", Google2u.Google2uGenPath("OBJDBEDITOR")); _PlaymakerPath = Google2uGUIUtil.GetString("g2uplaymakerDirectory", Google2u.Google2uGenPath("PLAYMAKER")); break; } if (_ExportThread == null || _ExportThread.IsAlive == false) { _ExportThread = new Thread(ExportThread) { Name = "ExportThread" }; _ExportThread.Start(this); } }
public void DoExport() { _JSONPath = Google2uGUIUtil.GetString("g2ujsonDirectory", Google2u.Google2uGenPath("JSON")); _CSVPath = Google2uGUIUtil.GetString("g2ucsvDirectory", Google2u.Google2uGenPath("CSV")); _XMLPath = Google2uGUIUtil.GetString("g2uxmlDirectory", Google2u.Google2uGenPath("XML")); _NGUIPath = Google2uGUIUtil.GetString("g2unguiDirectory", Google2u.Google2uGenPath("NGUI")); _StaticDbPath = Google2uGUIUtil.GetString("g2uStaticDBResourcesDirectory", Google2u.Google2uGenPath("STATICDBRESOURCES")); _ObjdbResourcesPath = Google2uGUIUtil.GetString("g2uobjDBResourcesDirectory", Google2u.Google2uGenPath("OBJDBRESOURCES")); _ObjdbEditorPath = Google2uGUIUtil.GetString("g2uobjDBEditorDirectory", Google2u.Google2uGenPath("OBJDBEDITOR")); _PlaymakerPath = Google2uGUIUtil.GetString("g2uplaymakerDirectory", Google2u.Google2uGenPath("PLAYMAKER")); if (_ExportThread == null || _ExportThread.IsAlive == false) { _ExportThread = new Thread(ExportThread) { Name = "ExportThread" }; _ExportThread.Start(this); } }
private void Init() { var lastChecked = Convert.ToDateTime(Google2uGUIUtil.GetString("Google2uLastCheckedForUpdate", Convert.ToString(DateTime.MinValue))); if ((DateTime.Now - lastChecked).Days >= 1) { Google2uGUIUtil.SetString("Google2uLastCheckedForUpdate", Convert.ToString(DateTime.Now)); var t = new Thread(CheckForUpdate); t.Start(); } ShowDocsAtStartup = Google2uGUIUtil.GetBool("ShowDocsAtStartup", ShowDocsAtStartup); if (ShowDocsAtStartup) Google2uDocs.ShowWindow(MyGUILayout, LocalizationInfo); ServicePointManager.ServerCertificateValidationCallback = Validator; OAuthToken = Google2uGUIUtil.GetString("OAuthToken", OAuthToken); RefreshToken = Google2uGUIUtil.GetString("RefreshToken", RefreshToken); RefreshTimeout = DateTime.ParseExact(Google2uGUIUtil.GetString("RefreshTimeout", RefreshTimeout.ToString("O")), "O", CultureInfo.InvariantCulture); if (InstanceData.Service == null && !string.IsNullOrEmpty(OAuthToken)) { SetupParameters(); _authParameters.AccessToken = OAuthToken; var requestFactory = new GOAuth2RequestFactory("structuredcontent", "Google2Unity", _authParameters); InstanceData.Service = new SpreadsheetsService("Google2Unity") {RequestFactory = requestFactory}; Thread.Sleep(100); if (!InstanceData.Commands.Contains(GFCommand.RetrieveWorkbooks)) InstanceData.Commands.Add(GFCommand.RetrieveWorkbooks); } // Close lingering editor windows var ed = GetWindow<Google2uEditor>(); if (ed != null) ed.Close(); if (ObjDbExport == null) ObjDbExport = new List<Google2uObjDbExport>(); Instance = this; }
private void Init() { var lastChecked = Convert.ToDateTime(Google2uGUIUtil.GetString("Google2uLastCheckedForUpdate", Convert.ToString(DateTime.MinValue))); if ((DateTime.Now - lastChecked).Days >= 1) { Google2uGUIUtil.SetString("Google2uLastCheckedForUpdate", Convert.ToString(DateTime.Now)); var t = new Thread(CheckForUpdate); t.Start(); } ShowDocsAtStartup = Google2uGUIUtil.GetBool("ShowDocsAtStartup", ShowDocsAtStartup); if (ShowDocsAtStartup) { Google2uDocs.ShowWindow(MyGUILayout, LocalizationInfo); } ServicePointManager.ServerCertificateValidationCallback = Validator; OAuthToken = Google2uGUIUtil.GetString("OAuthToken", OAuthToken); RefreshToken = Google2uGUIUtil.GetString("RefreshToken", RefreshToken); RefreshTimeout = DateTime.ParseExact(Google2uGUIUtil.GetString("RefreshTimeout", RefreshTimeout.ToString("O")), "O", CultureInfo.InvariantCulture); if (InstanceData.Service == null && !string.IsNullOrEmpty(OAuthToken)) { SetupParameters(); _authParameters.AccessToken = OAuthToken; var requestFactory = new GOAuth2RequestFactory("structuredcontent", "Google2Unity", _authParameters); InstanceData.Service = new SpreadsheetsService("Google2Unity") { RequestFactory = requestFactory }; Thread.Sleep(100); if (!InstanceData.Commands.Contains(GFCommand.RetrieveWorkbooks)) { InstanceData.Commands.Add(GFCommand.RetrieveWorkbooks); } } // Close lingering editor windows var ed = GetWindow <Google2uEditor>(); if (ed != null) { ed.Close(); } if (ObjDbExport == null) { ObjDbExport = new List <Google2uObjDbExport>(); } Instance = this; }
public void DoDataValidation(object in_dataValidationParams) { var dataValidationParams = in_dataValidationParams as DataValidationParams; if (dataValidationParams == null) { return; } var worksheet = dataValidationParams.Worksheet; var exportOptions = dataValidationParams.Options; for (var i = 1; i < worksheet.Rows[0].Count; ++i) { if (string.IsNullOrEmpty(worksheet.Rows[0][i].CellValueString) || worksheet.Rows[0][i].CellValueString.Equals("void", StringComparison.InvariantCultureIgnoreCase) || worksheet.Rows[0][i].CellValueString.Equals("ignore", StringComparison.InvariantCultureIgnoreCase)) { FirstBlankCol = i; break; } } if (worksheet.UseTypeRow == false) { worksheet.IsDataValid = true; } else { var lastCheckedRow = worksheet.Rows.Count; var lastCheckedCol = worksheet.Rows[0].Count; worksheet.IsDataValid = true; for (var i = 0; i <= worksheet.Rows.Count - 1; ++i) { if (string.IsNullOrEmpty(worksheet.Rows[i][0].CellValueString)) { var doBreak = false; switch (WorksheetExportType) { case ExportType.CSV: if (exportOptions.CSVCullRows) { doBreak = true; } break; case ExportType.JSON: if (exportOptions.JSONCullRows) { doBreak = true; } break; case ExportType.ObjectDatabase: if (exportOptions.ObjectDBCullRows) { doBreak = true; } break; case ExportType.StaticDatabase: if (exportOptions.StaticDBCullRows) { doBreak = true; } break; } if (doBreak) { lastCheckedRow = i; } continue; } worksheet.Rows[i][0].SetTypeFromValue(); if (worksheet.Rows[i][0].MyType == SupportedType.Void) { continue; } for (var j = 0; j <= worksheet.Rows[i].Count - 1; ++j) { var cell = worksheet.Rows[i][j]; cell.SkipValidation = false; if (j > lastCheckedCol) { cell.SkipValidation = true; continue; } CellType t; if (i == 0 && j == 0) { t = CellType.Null; } else if (i == 1 && j == 0) { t = CellType.Null; } else if (i == 0) { t = CellType.ColumnHeader; } else if (i == 1 && j > 1) { t = CellType.Type; } else if (j == 0) { t = CellType.RowHeader; } else { t = CellType.Value; } if (i >= lastCheckedRow) { worksheet.Validating = false; worksheet.IsDataValid = true; cell.SkipValidation = true; continue; } switch (WorksheetExportType) { case ExportType.ObjectDatabase: { if (exportOptions.ObjectDBCullColumns && (string.IsNullOrEmpty(worksheet.Rows[0][j].CellValueString) || worksheet.Rows[0][j].CellValueString.Equals("void", StringComparison.InvariantCultureIgnoreCase) || worksheet.Rows[0][j].CellValueString.Equals("ignore", StringComparison.InvariantCultureIgnoreCase))) { cell.SkipValidation = true; lastCheckedCol = j; continue; } } break; case ExportType.StaticDatabase: { if (exportOptions.StaticDBCullColumns && (string.IsNullOrEmpty(worksheet.Rows[0][j].CellValueString) || worksheet.Rows[0][j].CellValueString.Equals("void", StringComparison.InvariantCultureIgnoreCase) || worksheet.Rows[0][j].CellValueString.Equals("ignore", StringComparison.InvariantCultureIgnoreCase))) { cell.SkipValidation = true; lastCheckedCol = j; continue; } } break; case ExportType.CSV: { if (exportOptions.CSVCullColumns && (string.IsNullOrEmpty(worksheet.Rows[0][j].CellValueString) || worksheet.Rows[0][j].CellValueString.Equals("void", StringComparison.InvariantCultureIgnoreCase) || worksheet.Rows[0][j].CellValueString.Equals("ignore", StringComparison.InvariantCultureIgnoreCase))) { cell.SkipValidation = true; lastCheckedCol = j; continue; } } break; case ExportType.JSON: { if (exportOptions.JSONCullColumns && (string.IsNullOrEmpty(worksheet.Rows[0][j].CellValueString) || worksheet.Rows[0][j].CellValueString.Equals("void", StringComparison.InvariantCultureIgnoreCase) || worksheet.Rows[0][j].CellValueString.Equals("ignore", StringComparison.InvariantCultureIgnoreCase))) { cell.SkipValidation = true; lastCheckedCol = j; continue; } if (exportOptions.JSONIgnoreIDColumn && j == 0) { cell.SkipValidation = true; continue; } } break; case ExportType.NGUI: { if (exportOptions.NGUICullColumns && (string.IsNullOrEmpty(worksheet.Rows[0][j].CellValueString) || worksheet.Rows[0][j].CellValueString.Equals("void", StringComparison.InvariantCultureIgnoreCase) || worksheet.Rows[0][j].CellValueString.Equals("ignore", StringComparison.InvariantCultureIgnoreCase))) { cell.SkipValidation = true; lastCheckedCol = j; continue; } } break; case ExportType.XML: { if (exportOptions.XMLCullColumns && (string.IsNullOrEmpty(worksheet.Rows[0][j].CellValueString) || worksheet.Rows[0][j].CellValueString.Equals("void", StringComparison.InvariantCultureIgnoreCase) || worksheet.Rows[0][j].CellValueString.Equals("ignore", StringComparison.InvariantCultureIgnoreCase))) { cell.SkipValidation = true; lastCheckedCol = j; continue; } } break; default: cell.SkipValidation = true; continue; } try { if (!cell.DoDataValidation(t, worksheet.Rows, worksheet.MyWorkbook)) { if (_SetInvalidCellActive) { worksheet.ActiveCell = cell; _SetInvalidCellActive = false; } worksheet.IsDataValid = false; } } catch (Exception ex) { Debug.Log(ex.Message); worksheet.Validating = false; } } } } if (!validWorksheetName(WorksheetName)) { IsDataValid = false; Google2u.PushNotification("Worksheet name is invalid: " + WorksheetName); } worksheet.Validating = false; }
public static void QueryCells(object in_worksheet) { var worksheet = in_worksheet as Google2uWorksheet; if (worksheet == null) { return; } uint lastRow = 0; uint lastCol = 0; var cleanupFeed = worksheet.MyService.Query(worksheet.MyCleanupQuery) as CellFeed; if (cleanupFeed == null) { return; } // for loops are faster in Mono, do not convert to foreach { CellEntry c; for (var i = 0; i < cleanupFeed.Entries.Count; ++i) { c = cleanupFeed.Entries[i] as CellEntry; if (c.Row > lastRow) { lastRow = c.Row; } if (c.Column > lastCol) { lastCol = c.Column; } } } worksheet.MyCellQuery.MaximumColumn = lastCol; worksheet.MyCellQuery.MaximumRow = lastRow; if (lastCol < 2 || lastRow < 2) { Google2u.PushNotification("There are not enough cells in the worksheet " + worksheet.WorksheetName + " it will not be processed"); worksheet.WorksheetQueryStatus = QueryStatus.Idle; worksheet.UpdateValidation = true; return; } try { worksheet.MyCellFeed = worksheet.MyService.Query(worksheet.MyCellQuery) as CellFeed; } catch (Exception ex) { Google2u.PushNotification("Unable to Query " + worksheet.WorksheetName + ". If this problem persists, there is probably something wrong with the spreadsheet." + ex.Message); } if (worksheet.MyCellFeed != null) { worksheet.LastUpdateCount = worksheet.MyCellFeed.Entries.Count; if (worksheet.MyCellFeed == null) { return; } var tmpCells = new List <Google2uRow>(); // for loops are faster in Mono, do not convert to foreach CellEntry c; for (var i = 0; i < worksheet.MyCellFeed.Entries.Count; ++i) { c = worksheet.MyCellFeed.Entries[i] as CellEntry; if (c == null) { continue; } while (tmpCells.Count < c.Row) { tmpCells.Add(new List <Google2uCell>()); } var r = tmpCells[tmpCells.Count - 1]; r.Cells.Add(new Google2uCell(c)); } worksheet.UseTypeRow = true; if (tmpCells.Count > 1) { var row = tmpCells[1]; for (var i = 1; i < row.Count; i++) { if (row[i].GetTypeFromValue() == SupportedType.Unrecognized) { worksheet.UseTypeRow = false; } } } if (worksheet.ColOptions == null) { worksheet.ColOptions = new List <ColumnOption>(); } for (var i = 0; i < lastCol; ++i) { worksheet.ColOptions.Add(new ColumnOption(60)); } if (worksheet.RowOptions == null) { worksheet.RowOptions = new List <RowOption>(); } for (var i = 0; i < lastRow; ++i) { worksheet.RowOptions.Add(new RowOption(24)); } worksheet.Rows = tmpCells; } worksheet.WorksheetQueryStatus = QueryStatus.Idle; worksheet.UpdateCellTypes = true; worksheet.UpdateValidation = true; }
public static void UpdateQuery(object in_worksheet) { var worksheet = in_worksheet as Google2uWorksheet; if (worksheet == null) { return; } uint lastRow = 0; uint lastCol = 0; var cleanupFeed = worksheet.MyService.Query(worksheet.MyCleanupQuery) as CellFeed; if (cleanupFeed == null) { return; } // for loops are faster in Mono, do not convert to foreach { CellEntry c; for (var i = 0; i < cleanupFeed.Entries.Count; ++i) { c = cleanupFeed.Entries[i] as CellEntry; if (c.Row > lastRow) { lastRow = c.Row; } if (c.Column > lastCol) { lastCol = c.Column; } } } worksheet.MyCellQuery.MaximumColumn = lastCol; worksheet.MyCellQuery.MaximumRow = lastRow; CellFeed updateFeed = null; try { updateFeed = worksheet.MyService.Query(worksheet.MyCellQuery) as CellFeed; } catch (Exception) { Google2u.PushNotification("Unable to Update " + worksheet.WorksheetName + ". If this problem persists, there is probably something wrong with the spreadsheet."); } if (updateFeed == null) { return; } CellEntry updatedEntry = null; // compare the update feed with the cells var bDoFullUpdate = updateFeed.Entries.Count != worksheet.LastUpdateCount; worksheet.LastUpdateCount = updateFeed.Entries.Count; if (!bDoFullUpdate) { // for loops are faster in Mono, do not convert to foreach CellEntry wsEntry; CellEntry fEntry; for (var i = 0; i < worksheet.MyCellFeed.Entries.Count; ++i) { wsEntry = worksheet.MyCellFeed.Entries[i] as CellEntry; if (wsEntry == null) { continue; } for (var j = 0; j < updateFeed.Entries.Count; ++j) { fEntry = updateFeed.Entries[j] as CellEntry; if (fEntry == null) { continue; } if (fEntry.Row != wsEntry.Row || fEntry.Column != wsEntry.Column || fEntry.Value == wsEntry.Value) { continue; } if (updatedEntry == null) { updatedEntry = fEntry; } else { bDoFullUpdate = true; } break; } if (bDoFullUpdate) { break; } } } if (bDoFullUpdate) { // Do a full re-query worksheet.WorksheetQueryStatus = QueryStatus.Uninitialized; return; } if (updatedEntry != null) { var myCell = worksheet.RowsDisplay[(int)updatedEntry.Row - 1][(int)updatedEntry.Column - 1]; myCell.MyCell = updatedEntry; worksheet.UpdateCellTypes = true; } worksheet.WorksheetQueryStatus = QueryStatus.Idle; worksheet.UpdateCellTypes = true; worksheet.UpdateValidation = true; }