private async void SaveSolution_Clicked(object sender, EventArgs e) { string surl = SolutionName.Text?.Trim(); if (string.IsNullOrEmpty(surl)) { return; } try { if (!Utils.HasInternet) { Utils.Alert_NoInternet(); return; } string domain = App.Settings.Vendor.GetDomain(); if (surl.Split(CharConstants.DOT).Length == 1) { surl += $".{domain}"; } if (viewModel.IsSolutionExist(surl)) { await viewModel.RedirectToExistingSolution(surl, isMasterPage); return; } EbLayout.ShowLoader(); response = await viewModel.Validate(surl); if (response.IsValid) { EbLayout.HideLoader(); SolutionLogoPrompt.Source = ImageSource.FromStream(() => new MemoryStream(response.Logo)); SolutionLabel.Text = surl.Split(CharConstants.DOT)[0]; ShowSIDConfirmBox(); SoluUrl = surl; } else { EbLayout.HideLoader(); Utils.Toast("Invalid solution URL"); } } catch (Exception ex) { EbLog.Error(ex.Message); } }
private void DropTable(string tableName) { try { App.DataDB.DoNonQuery($"DROP TABLE IF EXISTS {tableName};"); } catch (Exception ex) { EbLog.Error($"Failed to drop Table {tableName} : " + ex.Message); } }
//--------------------------------------------------------------------- internal EbTable _getTable(string table_name) { EbTable table; mMapTable.TryGetValue(table_name, out table); if (table == null) { EbLog.Error("EbDb.getTable() Error! not exist table,table_name=" + table_name); } return(table); }
//--------------------------------------------------------------------- public EntityDef getEntityDef(string entity_type) { EntityDef entity_def = null; mMapEntityDef.TryGetValue(entity_type, out entity_def); if (entity_def == null) { EbLog.Error("EntityMgr.getEntityDef() Error! 不存在entity_type=" + entity_type); } return(entity_def); }
public void UpdateDraftAsSynced(int id, int draftId) { try { App.DataDB.DoNonQuery($"UPDATE {this.TableName} SET eb_synced = {(int)DataSyncStatus.Synced} WHERE id = {id} AND eb_syncrecord_id = {draftId} AND eb_synced = {(int)DataSyncStatus.Error}"); } catch (Exception ex) { EbLog.Error("UpdateDraftAsSynced: " + ex.Message); } }
//--------------------------------------------------------------------- public EbPropSet getPropSet(int id) { EbPropSet prop_set; mMapPropSet.TryGetValue(id, out prop_set); if (prop_set == null) { EbLog.Error("EbTable.getPropSet() Error! not exist prop_set,id=" + id); } return(prop_set); }
//--------------------------------------------------------------------- public byte[] GetTableAsBytes(string table_name) { EbTableBuffer table = null; mMapTable.TryGetValue(table_name, out table); if (table == null) { EbLog.Error("EbDb.getTable() Error! not exist table,table_name=" + table_name); } return(table.GetTableData()); }
//------------------------------------------------------------------------- public void freeStillSprite(StillSprite still_sprite) { #if UNITY_EDITOR if (still_sprite != null && still_sprite.GetType().ToString() == "FishStillSprite") { EbLog.Error("freeStillSprite::error"); } #endif mStillSpritePool.freeStillSprite(still_sprite); }
//--------------------------------------------------------------------- public void update(float elapsed_tm) { try { mEntityMgr.update(elapsed_tm); } catch (Exception ec) { EbLog.Error("EcEngine.update() Exception: " + ec); } }
//------------------------------------------------------------------------- public void launchAutoPatcher(AutoPatcherConfig cfg) { // 设置自动更新参数配置,并检查参数有效性 AutoPatcherConfig.RemoteVersionInfoUrl = cfg.RemoteVersionInfoUrl; if (string.IsNullOrEmpty(AutoPatcherConfig.RemoteVersionInfoUrl)) { EbLog.Error("ClientAutoPatcher.launchAutoPatcher() AutoPatcherConfig.ServerUrlPrefix is Null!"); } // 启动自动更新 StepGetRemoteVersionInfo = true; }
//--------------------------------------------------------------------- public EntityAffectorData buildAffectorData(JsonItem json_item) { if (mDicAffectorFactory.ContainsKey(json_item.mTypeName)) { return(mDicAffectorFactory[json_item.mTypeName].buildAffectorData(json_item)); } else { EbLog.Error(@"BaseFishLordMgr::buildAffectorData::error::there are no " + json_item.mTypeName + " factory"); return(null); } }
//--------------------------------------------------------------------- public void onRpcMethod(ushort method_id, byte[] data) { RpcSlotBase rpc_slot = null; mMapRpcSlot.TryGetValue(method_id, out rpc_slot); if (rpc_slot == null) { EbLog.Error("RpcCallee._onRpcMethod() not found method_id. method_id = " + method_id); return; } rpc_slot.onRpcMethod(data); }
//------------------------------------------------------------------------- public void freeFishStillSprite(FishStillSprite still_sprite) { #if UNITY_EDITOR if (still_sprite != null && still_sprite.GetType().ToString() == "StillSprite") { EbLog.Error("freeFishStillSprite::error"); } #endif still_sprite.setISpriteFishNull(); still_sprite.detachChildren(); mFishSpritePool.freeStillSprite(still_sprite); }
//------------------------------------------------------------------------- float _getFishInitLayer(int fish_vib_id) { try { return(layerAddOffset(mFishLayerBegin) + mFishIdLayerMap[fish_vib_id].Layer * mEachTypeFishLayerGap);//这个函数以后可以修改,以后可能根据vib配置的数值来初始化。 } catch (Exception e) { EbLog.Error("getFishInitLayer error with fish_vib_id " + fish_vib_id); throw (e); } }
private void Render() { try { FormViewContainer.Children.Clear(); EbFormHelper.AddAllControlViews(FormViewContainer, Controls, FormMode, NetWorkType, Context, "form", false); } catch (Exception ex) { EbLog.Error(ex.Message); } }
//------------------------------------------------------------------------- async void c2sPlayerRequest(PlayerRequest player_request) { IRpcSession s = EntityMgr.LastRpcSession; ClientInfo client_info = CoApp.getClientInfo(s); if (client_info == null) { return; } Task <MethodData> task = await Task.Factory.StartNew <Task <MethodData> >(async() => { MethodData method_data = new MethodData(); method_data.method_id = MethodType.c2sPlayerRequest; method_data.param1 = EbTool.protobufSerialize <PlayerRequest>(player_request); MethodData r = null; try { var grain_playerproxy = GrainClient.GrainFactory.GetGrain <ICellPlayer>(new Guid(client_info.et_player_guid)); r = await grain_playerproxy.c2sRequest(method_data); } catch (Exception ex) { EbLog.Error(ex.ToString()); } return(r); }); if (task.Status == TaskStatus.Faulted || task.Result == null) { if (task.Exception != null) { EbLog.Error(task.Exception.ToString()); } return; } MethodData result = task.Result; if (result.method_id == MethodType.None) { return; } lock (CoApp.RpcLock) { var player_response = EbTool.protobufDeserialize <PlayerResponse>(result.param1); CoApp.rpcBySession(s, (ushort)MethodType.s2cPlayerResponse, player_response); } }
public static void EvaluateValueExpr(View view, string script) { try { Instance.context.SetCurrentView(view); Instance.evaluator.Execute(script); } catch (Exception ex) { EbLog.Error("list hide expr failure, " + ex.Message); } }
private void OpenSettings() { try { ILocationHelper locService = DependencyService.Get <ILocationHelper>(); locService.OpenSettings(); } catch (Exception ex) { EbLog.Error("failed to open location settings in [GoogleMap] view, " + ex.Message); } }
public static bool EvaluateHideExpr(string script) { try { return(Instance.evaluator.Execute <bool>(script)); } catch (Exception ex) { EbLog.Error("list hide expr failure, " + ex.Message); return(false); } }
private void ClearLog_Clicked(object sender, EventArgs e) { try { File.WriteAllText($"{nativeHelper.NativeRoot}/{logPath}", string.Empty); Utils.Toast("Log file cleared :)"); } catch (Exception ex) { EbLog.Error("Failed to clear logs, " + ex.Message); } }
public async virtual Task OnControlAction(EbDataRow row) { if (string.IsNullOrEmpty(this.LinkRefId)) { return; } EbMobilePage page = EbPageHelper.GetPage(this.LinkRefId) ?? EbPageHelper.GetExternalPage(this.LinkRefId); if (page != null) { EbMobileContainer container = page.Container; if (container is EbMobileForm) { if (this.FormMode == WebFormDVModes.New_Mode) { await App.Navigation.NavigateMasterAsync(new FormRender(page, this.LinkFormParameters, row)); } else { try { var map = this.FormId; if (map == null) { EbLog.Info("form id should be set"); throw new Exception("Form rendering exited! due to null value for 'FormId'"); } else { int id = Convert.ToInt32(row[map.ColumnName]); if (id <= 0) { EbLog.Info("id has ivalid value" + id); throw new Exception("Form rendering exited! due to invalid id"); } await App.Navigation.NavigateMasterAsync(new FormRender(page, id)); } } catch (Exception ex) { EbLog.Error(ex.Message); } } } else if (container is EbMobileVisualization) { await App.Navigation.NavigateMasterAsync(new ListRender(page, row)); } } }
//--------------------------------------------------------------------- public RpcSession createRpcSession(string name, bool as_default = false) { if (mMapRpcSession.ContainsKey(name)) { EbLog.Error("EntityMgr.createRpcSession() Failed! Exist Name=" + name); return null; } var rpc_session = mRpcSessionFactory.createRpcSession(this); if (as_default) mDefaultRpcSession = rpc_session; mMapRpcSession[name] = rpc_session; return rpc_session; }
public static bool EvaluateLinkExpr(EbDataRow row, string script) { try { SetDataRow(row); return(Instance.evaluator.Execute <bool>(script)); } catch (Exception ex) { EbLog.Error("list hide expr failure, " + ex.Message); } return(true); }
//--------------------------------------------------------------------- public PropDef getPropDef(string key) { PropDef prop_def; mMapPropDef.TryGetValue(key, out prop_def); if (prop_def == null) { EbLog.Error("EbTable.getPropDef() Error! TableName=" + Name + " Key=" + key); } return(prop_def); }
//--------------------------------------------------------------------- void _loadTable(string table_name) { string str_query_select = string.Format("SELECT * FROM {0};", table_name); try { Dictionary <int, List <DataInfo> > map_data = Sqlite.getTableData(str_query_select); if (map_data.Count <= 0) { return; } EbTableBuffer table = new EbTableBuffer(table_name); foreach (var i in map_data) { //int data_id = i.Key; //table.WriteInt(data_id); List <DataInfo> list_data_info = i.Value; foreach (var data_info in list_data_info) { object data_value = data_info.data_value; string data_name = data_info.data_name; switch (data_info.data_type) { case 1: table.WriteInt((int)data_value); break; case 2: table.WriteFloat((float)(double)data_value); break; case 3: table.WriteString((string)data_value); break; } } } table.WriteEnd(); mMapTable[table.TableName] = table; } catch (Exception e) { EbLog.Error(str_query_select + "_______" + e.ToString()); } }
private async Task SaveToLocalDB(MobileFormData data, FormSaveResponse response, int rowId) { try { LastSyncInfo syncInfo = App.Settings.SyncInfo; if (syncInfo.LastOfflineSaveTs > DateTime.Now) { response.Message = "Sync required. Device date time is incorrect."; } else { List <DbParameter> dbParameters = new List <DbParameter>(); string query = data.GetQuery(dbParameters, rowId); int rowAffected = App.DataDB.DoNonQuery(query, dbParameters.ToArray()); int lastRowId = (rowId != 0) ? rowId : Convert.ToInt32(App.DataDB.DoScalar($"SELECT MAX(id) FROM {TableName}")); response.PushResponse = new PushResponse() { RowId = lastRowId }; if (HasFileSelect && rowAffected > 0) { if (lastRowId > 0) { await WriteFilesToLocal(lastRowId); } } response.Status = rowAffected > 0; if (response.Status) { response.Message = "Data stored locally :)"; App.Settings.SyncInfo.LastOfflineSaveTs = DateTime.Now; await Store.SetJSONAsync(AppConst.LAST_SYNC_INFO, App.Settings.SyncInfo); } else { throw new Exception("Failed to store data locally"); } } } catch (Exception ex) { response.Message = "Failed to store data locally"; EbLog.Error("Exception at [EbMobileForm] while [SaveToLocalDB] method : " + ex.Message); } }
//------------------------------------------------------------------------- bool _checkResponse <TResponse>(WWW www, Action <UCenterResponseStatus, TResponse, UCenterError> handler) { if (www != null) { if (www.isDone) { UCenterResponse <TResponse> response = null; if (string.IsNullOrEmpty(www.error)) { try { response = EbTool.jsonDeserialize <UCenterResponse <TResponse> >(www.text); } catch (Exception ex) { EbLog.Error("ClientUCenterSDK.update() UCenterResponse Error"); EbLog.Error(ex.ToString()); } } else { EbLog.Error(www.url); EbLog.Error(www.error); } www = null; if (handler != null) { if (response != null) { handler(response.Status, response.Result, response.Error); } else { var error = new UCenterError(); error.ErrorCode = UCenterErrorCode.ServiceUnavailable; error.Message = ""; handler(UCenterResponseStatus.Error, default(TResponse), error); } handler = null; } return(true); } } return(false); }
//--------------------------------------------------------------------- public EntityAffector buildAffector(EntityAffectorData affector_data) { string type_name = affector_data.GetType().ToString(); if (mDicAffectorFactory.ContainsKey(type_name)) { return(mDicAffectorFactory[type_name].buildAffector(affector_data)); } else { EbLog.Error(@"BaseFishLordMgr::buildAffector::error::there are no " + type_name + " factory"); return(null); } }
private async void OpenLog_Clicked(object sender, EventArgs e) { try { await Launcher.OpenAsync(new OpenFileRequest { File = new ReadOnlyFile($"{nativeHelper.NativeRoot}/{logPath}") }); } catch (Exception ex) { EbLog.Error("Failed to open logs file, " + ex.Message); } }
private void QrScannerCallback(string payload) { SolutionQrMeta meta = null; try { meta = JsonConvert.DeserializeObject <SolutionQrMeta>(payload); } catch (Exception ex) { EbLog.Info("failed to parse qr payload in new solution page"); EbLog.Error(ex.Message); return; } if (meta == null) { return; } Device.BeginInvokeOnMainThread(async() => { try { if (string.IsNullOrEmpty(meta.Sid) || viewModel.IsSolutionExist(meta.Sid)) { Utils.Toast($"{meta.Sid} exist"); return; } EbLayout.ShowLoader(); response = await viewModel.Validate(meta.Sid); if (response.IsValid) { await viewModel.AddSolution(meta.Sid, response); await App.Navigation.NavigateToLogin(isMasterPage); } else { Utils.Toast("invalid qr code meta"); } EbLayout.HideLoader(); } catch (Exception) { EbLayout.HideLoader(); } }); }