Ejemplo n.º 1
0
        //-------------------------------------------------------------------------
        public TurretDataTable()
        {
            TbDataTurret.TurretType        turret_type;
            Dictionary <int, EbData>       mapData    = EbDataMgr.Instance.getMapData <TbDataTurret>();
            Dictionary <int, TbDataTurret> mapTurrets = new Dictionary <int, TbDataTurret>();

            foreach (var it in mapData)
            {
                turret_type = ((TbDataTurret)it.Value).mTurretType;

                if (turret_type == TbDataTurret.TurretType.None)
                {
                    continue;
                }
                if (!mDictTurretData.ContainsKey(turret_type))
                {
                    mDictTurretData.Add(turret_type, new Dictionary <int, TbDataTurret>());
                }
                if (!mDictTurretData[turret_type].ContainsKey(((TbDataTurret)it.Value).TurretRate))
                {
                    mDictTurretData[turret_type].Add(((TbDataTurret)it.Value).TurretRate, (TbDataTurret)it.Value);
                }
                else
                {
                    EbLog.Warning("TbDataTurret configure has same value " + it.Value.Id);
                }
            }
        }
Ejemplo n.º 2
0
        private async Task <(bool, bool, string)> UpdateLastSyncInfo(EbMobileSolutionData solutionData, LastSyncInfo syncInfo, string appVersion)
        {
            string msg = null;
            bool   leaveLastSyncTsCheck = false, incorrectDate = false, maintenanceMode = false;

            if (solutionData.MetaData != null)
            {
                if (solutionData.MetaData.TryGetValue(AppConst.maintenance_msg, out object val) && val != null)
                {
                    msg             = val.ToString();
                    maintenanceMode = true;
                }
                else if (solutionData.MetaData.TryGetValue(AppConst.session_expired, out object val2) && bool.TryParse(val2.ToString(), out bool b) && b)
                {
                    msg             = AppConst.session_expired;
                    maintenanceMode = true;
                }
                else if (solutionData.MetaData.TryGetValue(AppConst.leave_ts_check, out object val3) && bool.TryParse(val3.ToString(), out bool st) && st)
                {
                    EbLog.Warning("Last sync ts check avoided");
                    leaveLastSyncTsCheck = true;
                }

                if (solutionData.MetaData.TryGetValue(AppConst.app_version, out object val4) && val4 != null)
                {
                    syncInfo.LatestAppVersion = val4.ToString();
                }
                else
                {
                    syncInfo.LatestAppVersion = null;
                }
            }
            else
            {
                syncInfo.LatestAppVersion = null;
            }

            if (!(solutionData.last_sync_ts > DateTime.Now.Subtract(new TimeSpan(0, 2, 0)) &&
                  solutionData.last_sync_ts < DateTime.Now.Add(new TimeSpan(0, 3, 0))) && !leaveLastSyncTsCheck)
            {
                incorrectDate = true;
                EbLog.Warning("Device date time is incorrect. Server time: " + solutionData.last_sync_ts);
                if (msg == null)
                {
                    msg = "Device date time is incorrect";
                }
            }

            if (msg != null)
            {
                EbLog.Warning(msg);
            }

            syncInfo.PullSuccess = false;
            syncInfo.IsLoggedOut = false;
            syncInfo.SolnId      = App.Settings.Sid;
            await Store.SetJSONAsync(AppConst.LAST_SYNC_INFO, syncInfo);

            return(incorrectDate, maintenanceMode, msg);
        }
        protected override void SetValues()
        {
            this.SetValuesFormContext();

            List <EbCTCMapper> ebCTCMappers = this.context.UseLinkSettings ? context.ContextToControlMap : context.ContextToFabControlMap;

            if (ebCTCMappers == null)
            {
                EbLog.Warning($"column to control map empty in context visualization in page '{this.Page.DisplayName}'");
                return;
            }
            ;

            foreach (var map in ebCTCMappers)
            {
                object value = contextRow[map.ColumnName];

                if (this.Form.ControlDictionary.TryGetValue(map.ControlName, out EbMobileControl ctrl))
                {
                    if (ctrl is INonPersistControl || ctrl is ILinesEnabled)
                    {
                        continue;
                    }
                    else
                    {
                        ctrl.SetValue(value);
                    }
                }
            }
            base.SetValues();
        }
Ejemplo n.º 4
0
        //---------------------------------------------------------------------
        protected BaseEntity buildEntity(int fish_vib_id)
        {
            if (mEntityParticleSystem == null)
            {
                EbLog.Warning("BaseGenerator::There are no BaseEntityFactory.");
                return(null);
            }

            return(mEntityParticleSystem.buildEntity(mBaseGeneratorId, fish_vib_id, getNextFishId()));
        }
Ejemplo n.º 5
0
        //---------------------------------------------------------------------
        public void addParticleSystem(string file_name, List <string> server_param, int fish_begin_id)
        {
            EntityParticleSystemData lord_data = mParticleSystemDataPrototype.cloneParticleSystemData(file_name);

            if (lord_data == null)
            {
                EbLog.Warning("ParticleSystem::Add::Error::" + file_name);
                return;
            }

            mParticleSystemKeeper.addParticleSystem(
                new EntityParticleSystem().create(this, mEntityFactory, lord_data, fish_begin_id, server_param, mRouteObjectMgr));
        }
Ejemplo n.º 6
0
        //---------------------------------------------------------------------
        public BaseEntity buildEntity(int generator_id, int fish_vib_id, int fish_id)
        {
            if (mBaseEntityFactory == null)
            {
                EbLog.Warning("BaseGenerator::There are no BaseEntityFactory.");
                return(null);
            }

            BaseEntity entity = mBaseEntityFactory.buildBaseEntity(fish_vib_id, fish_id);

            addBaseEntity(generator_id, entity);

            return(entity);
        }
Ejemplo n.º 7
0
 //---------------------------------------------------------------------
 // Interface: IPhotonPeerListener.DebugReturn
 public void DebugReturn(DebugLevel level, string message)
 {
     if (level == DebugLevel.INFO)
     {
         EbLog.Note(message);
     }
     else if (level == DebugLevel.WARNING)
     {
         EbLog.Warning(message);
     }
     else if (level == DebugLevel.ERROR)
     {
         EbLog.Error(message);
     }
 }
Ejemplo n.º 8
0
        //---------------------------------------------------------------------
        void debug_log()
        {
            string            str             = "mColliderQuadTree::";
            TagColliderObject collider_object = null;

            foreach (var it in mColliderQuadTree)
            {
                if (it.QuadNodeObject == null)
                {
                    continue;
                }
                collider_object = (TagColliderObject)it.QuadNodeObject;
                str            += collider_object.getBulletColliders().Count + "::";
            }
            EbLog.Warning(str);
        }
        private async void OnClick(object sender, EventArgs e)
        {
            if (isTapped)
            {
                return;
            }

            try
            {
                isTapped = true;

                EbMobilePage page = EbPageHelper.GetPage(LinkRefId);

                if (page != null)
                {
                    EbPageRenderer renderer = await EbPageHelper.GetRenderer(page);

                    if (renderer.IsReady)
                    {
                        EbLog.Info(renderer.Message);
                        await App.Navigation.NavigateMasterAsync(renderer.Renderer);
                    }
                    else
                    {
                        EbLog.Error("unable to create renderer, [DataLink] " + renderer.Message);
                    }
                }
                else
                {
                    EbLog.Warning("page not found in [DataLink], Check permission");
                }
            }
            catch (Exception ex)
            {
                EbLog.Info("[EbMobileDashboard] click navigation error");
                EbLog.Error(ex.Message);
            }

            isTapped = false;
        }
Ejemplo n.º 10
0
 public override void SetValue(object value)
 {
     try
     {
         if (value != null)
         {
             if (this.EbDateType == EbDateType.Time)
             {
                 timePicker.Time = TimeSpan.Parse(value.ToString());
             }
             else
             {
                 datePicker.Date = Convert.ToDateTime(value);
             }
         }
     }
     catch (Exception ex)
     {
         EbLog.Error(ex.Message);
         EbLog.Warning(ex.StackTrace);
     }
 }
Ejemplo n.º 11
0
 void assert(bool is_ok, string error, string ok)
 {
     EbLog.Warning((test_count++) + " :: " + (is_ok ? ok : error));
 }
Ejemplo n.º 12
0
 //---------------------------------------------------------------------
 public void Log_Warn(string str)
 {
     EbLog.Warning(str);
 }
Ejemplo n.º 13
0
        private async Task <bool> GetLatestAutoId(List <AppData> Applications)
        {
            List <EbMobileAutoIdData> autoIdData = new List <EbMobileAutoIdData>();

            try
            {
                foreach (AppData app in Applications)
                {
                    foreach (MobilePagesWraper mobPageWrap in app.MobilePages)
                    {
                        EbMobilePage page = mobPageWrap.GetPage();
                        if (page.Container is EbMobileForm form)
                        {
                            EbMobileAutoId autoId = (EbMobileAutoId)form.ChildControls.Find(e => e is EbMobileAutoId);
                            if (autoId != null && !string.IsNullOrWhiteSpace(form.TableName))
                            {
                                string query = autoId.PrefixExpr?.GetCode();
                                if (!string.IsNullOrWhiteSpace(query) && page.NetworkMode == NetworkMode.Offline)
                                {
                                    EbDataTable dt = App.DataDB.DoQuery(query);
                                    if (dt.Rows.Count > 0)
                                    {
                                        autoIdData.Add(new EbMobileAutoIdData()
                                        {
                                            Table  = form.TableName,
                                            Column = autoId.Name,
                                            Prefix = dt.Rows[0][0]?.ToString()
                                        });
                                    }
                                }
                            }
                        }
                    }
                }
                if (autoIdData.Count > 0)
                {
                    RestRequest request = new RestRequest(ApiConstants.PULL_LATEST_AUTOID, Method.POST);
                    RestClient  client  = new RestClient(App.Settings.RootUrl)
                    {
                        Timeout = ApiConstants.TIMEOUT_IMPORT
                    };
                    request.AddParameter("data", JsonConvert.SerializeObject(autoIdData));
                    request.AddHeader(AppConst.BTOKEN, App.Settings.BToken);
                    request.AddHeader(AppConst.RTOKEN, App.Settings.RToken);
                    IRestResponse response = await client.ExecuteAsync(request);

                    if (response.IsSuccessful)
                    {
                        EbDataSet ds = new EbDataSet();
                        EbMobileAutoIdDataResponse resp = JsonConvert.DeserializeObject <EbMobileAutoIdDataResponse>(response.Content);
                        ds.Tables.Add(resp.OfflineData);
                        DBService.Current.ImportData(ds);
                        EbLog.Info("GetLatestAutoId success");
                        return(true);
                    }
                    else
                    {
                        EbLog.Warning("GetLatestAutoId failed");
                    }
                }
            }
            catch (Exception ex)
            {
                EbLog.Error("Error in GetLatestAutoId: " + ex.Message);
            }
            return(autoIdData.Count > 0 ? false : true);
        }
Ejemplo n.º 14
0
        public async Task <EbMobileSolutionData> GetSolutionDataAsync(Loader loader)
        {
            if (App.Settings.SyncInProgress)
            {
                EbLog.Info(App.Settings.Sid + ": Sync in progress...");
                return(null);
            }
            App.Settings.SyncInProgress = true;
            EbLog.BackupLogFiles();
            EbMobileSolutionData solutionData = null;
            bool flag = false;

            try
            {
                loader.Message = "Sync started...";
                EbLog.Info("Sync started...");

                LocalDBServie service  = new LocalDBServie();
                SyncResponse  response = await service.PushDataToCloud(loader);

                if (response.Status)
                {
                    loader.Message = string.Empty;
                }
                else
                {
                    loader.Message = response.Message + " \n";
                }

                loader.Message += "Fetching data from server...";
                EbLog.Info("Fetching data from server...");

                RestClient client = new RestClient(App.Settings.RootUrl)
                {
                    Timeout = ApiConstants.TIMEOUT_IMPORT
                };
                RestRequest request = new RestRequest(ApiConstants.GET_SOLUTION_DATAv2, Method.POST);

                request.AddHeader(AppConst.BTOKEN, App.Settings.BToken);
                request.AddHeader(AppConst.RTOKEN, App.Settings.RToken);
                Dictionary <string, object> metaDict = new Dictionary <string, object>();
                metaDict.Add(AppConst.draft_ids, GetErrorDraftIds());
                INativeHelper helper = DependencyService.Get <INativeHelper>();
                metaDict.Add(AppConst.app_version, helper.AppVersion);
                metaDict.Add(AppConst.device_id, helper.DeviceId);
                request.AddParameter(AppConst.metadata, JsonConvert.SerializeObject(metaDict));

                IRestResponse resp = await client.ExecuteAsync(request);

                if (resp.IsSuccessful)
                {
                    loader.Message = "Processing pulled data...";

                    LastSyncInfo syncInfo = App.Settings.SyncInfo;
                    if (syncInfo == null)
                    {
                        syncInfo = new LastSyncInfo();
                    }
                    solutionData = JsonConvert.DeserializeObject <EbMobileSolutionData>(resp.Content);

                    (bool incorrectDate, bool maintenanceMode, string msg) = await UpdateLastSyncInfo(solutionData, syncInfo, helper.AppVersion);

                    if (!maintenanceMode)
                    {
                        await ImportSolutionData(solutionData);

                        loader.Message = "Importing latest document ids...";
                        EbLog.Info("Importing latest document ids...");
                        if (await GetLatestAutoId(solutionData.Applications))
                        {
                            if (!incorrectDate)
                            {
                                syncInfo.LastSyncTs        = solutionData.last_sync_ts;
                                syncInfo.LastOfflineSaveTs = solutionData.last_sync_ts;
                            }
                            else
                            {
                                Utils.Toast(msg);
                            }

                            syncInfo.PullSuccess = true;
                            await Store.SetJSONAsync(AppConst.LAST_SYNC_INFO, syncInfo);

                            flag = true;
                        }
                        else
                        {
                            Utils.Toast("Failed to import latest doc ids");
                        }
                    }
                    else
                    {
                        Utils.Toast(msg);
                        syncInfo.PullSuccess = true;
                        await Store.SetJSONAsync(AppConst.LAST_SYNC_INFO, syncInfo);
                    }
                }
                else
                {
                    Utils.Toast(response.Message ?? "Sync failed");
                    EbLog.Warning(response.Message ?? "Sync failed");
                }
            }
            catch (Exception ex)
            {
                EbLog.Error("Error on [GetSolutionData] request" + ex.Message);
                Utils.Toast(ex.Message);
            }
            loader.IsVisible            = false;
            App.Settings.SyncInProgress = false;
            return(flag ? solutionData : null);
        }