void Start() { if (!DataPersistance.GameStateExists()) { throw new System.InvalidProgramException("Game state don't exist!"); } CurrentGameId = DataPersistance.GetCurrentGameId(); PopupsController = GetComponent <PopupsController>(); if (GSP.GameState.ItsMyTurn()) { if (GSP.GameState.HasNotStarted()) { GameEngine.StartGame(); } } UpdateUI(); CheckTheTurn(); if (GSP.GameState.GetAvailableActions().FindAll((Action obj) => obj.Type == ActionType.EndTurn).Count == 1) { EndTurnParticleSystemVisible = true; } else { EndTurnParticleSystemVisible = false; } }
private void UpdateStrQuery() { string tmpFilter; if (_Filter.Length > 0) { tmpFilter = _Filter; } else { tmpFilter = "1=1"; } string TmpStr = DataPersistance.BuildKeyField(td); if (_OrderFld._dtlsa == null) { strQuery = string.Concat("SELECT KeyField FROM (SELECT ", TmpStr, " AS KeyField,", _OrderFld.FieldName, " FROM ", td._TableName, " WHERE (", tmpFilter, ")) AS X"); _CriteriaPos = strQuery.Length - 6; } else { strQuery = string.Concat("SELECT KeyField FROM (SELECT KeyField,", DataPersistance.GetSqlCoalesceNoFormat(_OrderFld.FieldName, DataPersistance.FormatSqlValue(string.Empty)), " AS ", _OrderFld.FieldName, " FROM (SELECT ", TmpStr, " AS KeyField,(", _OrderFld._dtlsa._SqlQuery, ") AS ", _OrderFld.FieldName, " FROM ", td._TableName, " WHERE (", tmpFilter, ")) AS X) AS X"); _CriteriaPos = strQuery.Length - 12; } IsKeyFieldEqualOrderField = TmpStr == _OrderFld.FieldName; }
public Registration(DataPersistance dp, string EngineName) { this.dp = dp; this.EngineName = EngineName; Vars = dp.GetVariables("License"); _AppName = dp.GetVariable <string>("System", "AppName", string.Empty); UserName = Vars.GetVariable <string>("UserName", string.Empty); CompanyName = Vars.GetVariable <string>("CompanyName", string.Empty); Limitation = Vars.GetVariable <int>("Limitation", 0); MonthLimitation = Vars.GetVariable <int>( "MonthLimitation", 6); _RegistrationNo = HardwareIdentification.Pack( HardwareIdentification.Value() + _AppName); ActivationCode = Vars.GetVariable <string>( EngineName + _RegistrationNo, string.Empty); if (Limitation < 0 || Limitation > 2) { Limitation = 0; } IsOldValidReg = IsValidActivationCode() && Limitation != 0; }
public static void ClearPersistanceFlag(DataPersistance dp) { foreach (TableDef td in TableDefs.Values) { td.SetIsExist(dp, false); } }
public static void SaveGameState(this GameState gameState) { string gameStateString = gameState.Stringify(); DataPersistance.SaveGameState(gameState); _gameState = DataPersistance.LoadGameState(); }
public static decimal GetSaldoAwal(DataPersistance Dp, string IdAkun) { return((decimal)Dp.Find.SumValue <SaldoAwalAkun>("SaldoAwal", "IdAkun=@0 OR IdAkun LIKE @1", 0m, new FieldParam("0", IdAkun), new FieldParam("1", IdAkun + ".%"))); }
internal static AppVariables GetVariables(DataPersistance dp, string ModuleName) { return(new AppVariables(ModuleName, dp.ListLoadEntities <AppVariable>(null, "ModuleName=@0", string.Empty, false, new FieldParam("0", ModuleName)))); }
public static void SetVariable(string UserName, string ModuleName, string VarName, object VarValue) { DataPersistance dp = BaseFramework.GetDefaultDp(); UserVariable Var = new UserVariable(); Var.UserName = UserName; Var.ModuleName = ModuleName; Var.VarName = VarName; Var.VarValue = string.Empty; if (VarValue == null) { Var.BinValue = null; } else { Type tp = VarValue.GetType(); if (tp == typeof(Bitmap) || tp == typeof(Image)) { Helper.ConvertImageToByteArray((Image)VarValue); Var.BinValue = Helper.ConvertImageToByteArray( (Image)VarValue); } else if (tp == typeof(byte[])) { Var.BinValue = (byte[])VarValue; } else { Var.VarValue = BaseUtility.ConvertToString(VarValue); } } Var.Save(); }
internal override void AddEntity(DataPersistance dp, object NewEntity) { if (!object.ReferenceEquals(dp, this.dp)) { return; } string strPK = BuildPKWhere(NewEntity); string Query = strPK.Length > 0 ? string.Concat(SqlQuery, " AND (", strPK, ")") : SqlQuery; IDataReader rdr = dp.ExecuteReader(Query); try { if (rdr.Read()) // Kalo PK data baru valid, tambahkan { object[] Values = new object[rdr.FieldCount]; rdr.GetValues(Values); ((DataTable)wrdt.Target).Rows.Add(Values); } } finally { rdr.Close(); } }
internal override void AddEntity(DataPersistance dp, object NewEntity) { if (!object.ReferenceEquals(dp, this.dp)) { return; } string strPK = BuildPKWhere(NewEntity); string Query = strPK.Length > 0 ? string.Concat(SqlQuery, " AND (", strPK, ")") : SqlQuery; if (dp.Find.IsExists(Query)) { if (IsLoadEntity) { ((List <TEntity>)wrdt.Target).Add( (TEntity)MetaData.Clone(NewEntity, true)); } else { ((List <TEntity>)wrdt.Target).Add( (TEntity)MetaData.FastClone(NewEntity)); } } }
public static void DeleteEntity(DataPersistance dp, Type EntityType, object DeletedEntity) { SortedList <int, EntityList> ListEl; if (!_List.TryGetValue(EntityType.Name, out ListEl)) { return; } int i = 0; while (i < ListEl.Count) { EntityList el = ListEl.Values[i]; if (!el.IsAlive) { ListEl.RemoveAt(i); } else { i++; el.DeleteEntity(dp, DeletedEntity); } } }
public static void LoadDataTable <TEntity>(DataPersistance dp, string ColumnList, string Condition, string OrderCondition, out DataTable dt, ref int KeyId) where TEntity : class { LoadDataTable(typeof(TEntity), dp, ColumnList, Condition, OrderCondition, out dt, ref KeyId); }
public static void LoadDataTable <TEntity>(DataPersistance dp, string SqlSelect, out DataTable dt, ref int KeyId) where TEntity : class { LoadDataTable(typeof(TEntity), dp, SqlSelect, out dt, ref KeyId); }
internal override void EditEntity(DataPersistance dp, object OldEntity, object NewEntity) { if (!object.ReferenceEquals(dp, this.dp)) { return; } string strPK = BuildPKWhere(NewEntity); string Query = strPK.Length > 0 ? string.Concat(SqlQuery, " AND (", strPK, ")") : SqlQuery; DataTable dt = (DataTable)wrdt.Target; IDataReader rdr = dp.ExecuteReader(Query); try { if (rdr.Read()) //Kalo PK Data Baru Valid { object[] Values = new object[rdr.FieldCount]; rdr.GetValues(Values); if (OldEntity == null) //Data baru tidak ada, tambahkan { dt.Rows.Add(Values); } else { // kalo data lama ada, edit strPK = BuildPKWhere(OldEntity); DataRow[] drs = dt.Select(BuildPKWhere(OldEntity)); if (drs.Length > 0) { DataRow dr = drs[0]; for (int i = 0; i < Values.Length; i++) { dr[i] = Values[i]; } } else // Data baru tidak ada, tambahkan { dt.Rows.Add(Values); } } } else // Data Baru tidak valid { // Kalo data lama ada, hapus DataRow[] drs = dt.Select(BuildPKWhere(OldEntity)); if (drs.Length > 0) { dt.Rows.Remove(drs[0]); } } } finally { rdr.Close(); } }
public static void ClearLog() { TableDef td = MetaData.GetTableDef <UserLog>(); DataPersistance Dp = td.GetDataPersistance(BaseFramework.GetDefaultDp()); Dp.ValidateTableDef <UserLog>(); Dp.ExecuteNonQuery("DELETE FROM _System_UserLog"); }
public EntityForm(Type FormType) { _Dp = BaseFramework.GetDefaultDp(FormType.Assembly); this.FormType = FormType; DoBrowseData = ShowTabular; this.ModuleName = BaseWinFramework.GetModuleName(FormType); this._DataFilter = string.Empty; }
public static string CariNoPengeluaranKas(DataPersistance Dp, string JenisDokSumber, string NoDokSumber) { return((string)Dp.Find.Value <PengeluaranKasUmum>("NoPengeluaranKas", "JenisDokSumber=@jds AND NoDokSumber=@nds", string.Empty, new FieldParam("jds", JenisDokSumber), new FieldParam("nds", NoDokSumber))); }
public static string CariNoJurnal(DataPersistance Dp, string JenisDokSumber, string NoDokSumber) { return((string)Dp.Find.Value <Jurnal>("NoJurnal", "JenisDokSumber=@jds AND NoDokSumber=@nds", string.Empty, new FieldParam("jds", JenisDokSumber), new FieldParam("nds", NoDokSumber))); }
public static void CheckAutoClearLog() { TableDef td = MetaData.GetTableDef <UserLog>(); DataPersistance Dp = td.GetDataPersistance(BaseFramework.GetDefaultDp()); Dp.ValidateTableDef <UserLog>(); Dp.ExecuteNonQuery("DELETE FROM _System_UserLog WHERE LogTime<@0", new FieldParam("0", DateTime.Today.AddMonths(-LogAge))); }
internal override void DeleteEntity(DataPersistance dp, object DeletedEntity) { if (!object.ReferenceEquals(dp, this.dp)) { return; } List <TEntity> ListEntity = (List <TEntity>)wrdt.Target; int IndexPos = -1; if (!IsLoadEntity) { foreach (TEntity Entity in ListEntity) { IndexPos++; bool IsFound = true; foreach (FieldDef fld in FieldList) { if (fld.GetValue(DeletedEntity) != fld.GetValue(Entity)) { IsFound = false; break; } } if (IsFound) { break; } } } else { foreach (TEntity Entity in ListEntity) { IndexPos++; bool IsFound = true; foreach (FieldDef fld in FieldList) { if (fld.GetValue(DeletedEntity) != fld.GetValue(Entity)) { IsFound = false; break; } } if (IsFound) { break; } } } if (IndexPos >= 0) { ListEntity.RemoveAt(IndexPos); } }
public EntityNavigator(ParentEntity Entity, DataPersistance Dp, bool CallSetDefault) { _Entity = Entity; _Entity.CurrentNavigator = this; _Entity._Original = (ParentEntity)MetaData.Clone(_Entity); _Entity.Dp = Dp; DoInit(CallSetDefault); }
public void ShowForm(DataPersistance dp, string EngineName) { reg = new Registration(dp, EngineName); labelControl12.Text = EngineName; radioGroup1.SelectedIndex = reg.Limitation; registrationBindingSource.DataSource = reg; modulesBindingSource.DataSource = reg.Modules; ShowDialog(BaseWinFramework.MdiParent); }
public static DataTable GetListRole(DataPersistance dp, string UserName) { return(dp.OpenDataTable(string.Concat("SELECT ", dp.FormatSqlValue(false, DataType.Boolean), @" AS Pilih,RoleName AS NamaPeran FROM _System_RoleUser WHERE UserName=@0 AND ProductName=@1"), new FieldParam("0", UserName), new FieldParam("1", BaseFramework.ProductName))); }
public EntityTransaction(DataPersistance dp) { this.dp = dp; IsTransactionExist = (dp.Trx != null); if (!IsTransactionExist) { dp.BeginTransaction(); } }
/// <summary> /// Tambahkan jumlah counter pengunci pada akun /// </summary> /// <param name="Dp"></param> /// <param name="IdAkun"></param> public static void TambahJmlPengunci(DataPersistance Dp, string IdAkun) { Dp.ExecuteNonQuery(string.Concat( "UPDATE Akun SET Terkunci=", Dp.FormatSqlValue(true, DataType.Boolean), ",JmlPengunci=JmlPengunci+1 WHERE IdAkun=@0"), new FieldParam("0", IdAkun)); }
public override int SaveNew(DataPersistance Dp, bool CallSaveRule, bool CallValidateError) { if (ListAkun == null && _TglJurnal < BaseGL.SetingPerusahaan .TglMulaiSistemBaru) { return(0); } return(base.SaveNew(Dp, CallSaveRule, CallValidateError)); }
public static void RegisterEngine <TEngine>() where TEngine : DataPersistance, new() { string EngineName = DataPersistance.GetEngineName <TEngine>(); if (!DictEngine.ContainsKey(EngineName)) { DictEngine.Add(EngineName, typeof(TEngine)); } }
private void OnGameItemClick(object game) { if (game.GetType() == typeof(GameInfo)) { GameInfo gameInfo = (game as GameInfo); gameInfo.PlayersNicknames.Add(PlayerNickName); gameInfo.PlayersNow = gameInfo.PlayersNow + 1; DataPersistance.SaveCurrentGameId(gameInfo.Id); StartCoroutine(NetworkController.PostGameInfo(gameInfo, PostGameInfoResponse)); } }
public SecondPage() { this.InitializeComponent(); submissionList = new List <Submission>(); userdataList = new List <UserData>(); data = new DataPersistance(); random = new Random(); LoadUserdataFromXML(); AddSubmissionsToList(); AddSubmissionsToListView(); }
//Initializes objects, generates keys and adds to listview private void Initialize() { userdataList = new List <UserData>(); serial = new SerialKey(); data = new DataPersistance(); validate = new ValidateUserData(); adminList = new List <Admin>(); usedKeysList = new List <String>(); popup = new Popup(); loginSuccesfully = false; }
public void SaveData(DataPersistance data) { var json = JsonConvert.SerializeObject(data, Formatting.Indented); if (Directory.Exists(FILE_PATH) != true) { Directory.CreateDirectory(FILE_PATH); } var fileSpec = CreateFileSpec(data.UserName); // File.WriteAllText is supposed to overwrite existing file, but appears to be appending instead. // therefore, we want to delete the existing file before writing to it. var fInfo = new FileInfo(fileSpec); if (fInfo.Exists) fInfo.Delete(); File.WriteAllText(fileSpec, json); }
public void SaveAndLoadDataTest() { var dataPersistance = new DataPersistance { Active = true, CreatedDate = DateTime.Now, UserName = "******", }; var data1 = new DataPoint { ControlName = "c1", TimeOfInteraction = DateTime.Now }; var data2 = new DataPoint { ControlName = "c2", TimeOfInteraction = DateTime.Now }; dataPersistance.Data.Add(data1); dataPersistance.Data.Add(data2); // Save the data var persistData = new PersistData(); persistData.SaveData(dataPersistance); // load the data var loadedData = persistData.LoadData("Sean"); Assert.IsTrue(dataPersistance.Equals(loadedData), "Unable to save data correctly"); }
private void ExecuteLoadData() { Debug.WriteLine("Load Data has been clicked."); var data = new PersistData(); var loadedData = new DataPersistance(); try { loadedData = data.LoadData(CurrentUser); } catch (FileNotFoundException) { MessageBox.Show(string.Format("File not found for user \"{0}\"", CurrentUser), "File not found", MessageBoxButton.OK, MessageBoxImage.Stop); } if (loadedData.Data.Count <= 0) return; ExecuteResetData(); foreach (var c in loadedData.Data) { ProcessNumberButton(c.ControlName); } ProcessGoButton(); }
private void ExecuteSaveData() { DataPersistance persistanceData = new DataPersistance { UserName = CurrentUser }; foreach (IData dta in DataList) { persistanceData.Data.Add((DataPoint) dta); } var persistData = new PersistData(); persistData.SaveData(persistanceData); }