Esempio n. 1
0
        ///<summary>Inserts one Pref into the database.  Provides option to use the existing priKey.</summary>
        public static long Insert(Pref pref, bool useExistingPK)
        {
            if (!useExistingPK && PrefC.RandomKeys)
            {
                pref.PrefNum = ReplicationServers.GetKey("preference", "PrefNum");
            }
            string command = "INSERT INTO preference (";

            if (useExistingPK || PrefC.RandomKeys)
            {
                command += "PrefNum,";
            }
            command += "PrefName,ValueString,Comments) VALUES(";
            if (useExistingPK || PrefC.RandomKeys)
            {
                command += POut.Long(pref.PrefNum) + ",";
            }
            command +=
                "'" + POut.String(pref.PrefName) + "',"
                + "'" + POut.String(pref.ValueString) + "',"
                + "'" + POut.String(pref.Comments) + "')";
            if (useExistingPK || PrefC.RandomKeys)
            {
                Db.NonQ(command);
            }
            else
            {
                pref.PrefNum = Db.NonQ(command, true);
            }
            return(pref.PrefNum);
        }
Esempio n. 2
0
    public static string LoadPreference(Pref pref, string defaultValue)
    {
        string returnStr = UnityEngine.PlayerPrefs.GetString(pref.ToString(), defaultValue);

        Debug.Log("Preference Loaded " + returnStr);
        return(returnStr);
    }
Esempio n. 3
0
 ///<summary>Inserts one Pref into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(Pref pref,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         pref.PrefNum=ReplicationServers.GetKey("preference","PrefNum");
     }
     string command="INSERT INTO preference (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="PrefNum,";
     }
     command+="PrefName,ValueString,Comments) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(pref.PrefNum)+",";
     }
     command+=
          "'"+POut.String(pref.PrefName)+"',"
         +"'"+POut.String(pref.ValueString)+"',"
         +"'"+POut.String(pref.Comments)+"')";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         pref.PrefNum=Db.NonQ(command,true);
     }
     return pref.PrefNum;
 }
Esempio n. 4
0
 ///<summary>Inserts one Pref into the database.  Returns the new priKey.</summary>
 public static long Insert(Pref pref)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         pref.PrefNum = DbHelper.GetNextOracleKey("preference", "PrefNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(pref, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     pref.PrefNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(pref, false));
     }
 }
    public static string GetAllKeyAndValues()
    {
        Pref[] prefs = keys.ToArray();
        //ArrayList valuesList = new ArrayList();

        string str = "";

        for (int i = 0; i < prefs.Length; i++)
        {
            Pref     p    = prefs[i];
            string   key  = p.key;
            PrefType type = p.type;
            object   v    = p.v;

            /*
             * if(type == PrefType.INT){
             *      valuesList.Add(PlayerPrefs.GetInt(key));
             * }else if(type == PrefType.FLOAT){
             *      valuesList.Add(PlayerPrefs.GetFloat(key));
             * }else if(type == PrefType.STRING){
             *
             * }else{
             *      Debug.LogWarning("noKeyType: "+key);
             * }
             */
            str += (int)type + "," + key + "," + v.ToString() + "\n";
        }
        return(str);
    }
Esempio n. 6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            LoginActionBar();
            _logging = Pref.getLogging(this);
            //if (TableViewer.dBHelper == null)
            //{
            //	//prevent not null
            //	//aSQLiteManager.database = new Database(_dbPath, _cont);
            //}
            SetContentView(Resource.Layout.filter_wizard);
            Bundle extras = Intent.Extras;

            if (extras != null)
            {
                //_table = extras.GetString("TABLE");
                FieldNames        = extras.GetStringArrayList("FieldNames");
                FieldDisplayNames = extras.GetStringArrayList("FieldDisplayNames");
                _sql = toDisplaySQL(extras.GetString("FILTER"));
                if (_sql == null)
                {
                    _sql = "";
                }
                // we are editing an existing filter
            }
            setUpUI();
        }
Esempio n. 7
0
 ///<summary>Inserts one Pref into the database.  Returns the new priKey.</summary>
 internal static long Insert(Pref pref)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         pref.PrefNum=DbHelper.GetNextOracleKey("preference","PrefNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(pref,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     pref.PrefNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(pref,false);
     }
 }
Esempio n. 8
0
        private void PreferencesButton_Click(object sender, EventArgs e)
        {
            Pref PrefForm = new Pref();

            // Show the settings form
            PrefForm.Show();
        }
Esempio n. 9
0
        /// <summary>
        /// Recommended.  Required for GridPrefs to work.
        /// </summary>
        /// <param name="columns">sequence of appearance, with Col options
        /// </param>
        public void ConfigureColumns(IEnumerable <Col> columns)
        {
            //this.Grid.Columns.Clear();

            this.Grid.UpdateLayout();

            if (this.Grid.Columns.Count == 0)
            {
                return;
            }

            int position = 0;

            bool prefExisted = GridPref != null;

            if (!prefExisted)
            {
                GridPref = new Pref();
            }

            SortedSet <int> indices = new SortedSet <int>(Enumerable.Range(0, this.Grid.Columns.Count));

            //Dictionary<string, double> colWidths = new Dictionary<string, double>();

            foreach (Col col in columns)
            {
                ColumnBase cb = this.Grid.Columns[col.Field];
                indices.Remove(cb.Index);
                cb.Visible = true;
                cb.Title   = col.Caption ?? col.Field;

                if (!string.IsNullOrWhiteSpace(col.Tooltip))
                {
                    decoration.MapColumnTooltip[col.Field] = col.Tooltip;
                }

                SuitableDefaults(cb);

                SetColumnFormat(cb, col.Format);

                if (!prefExisted)
                {
                    cb.VisiblePosition = position++;
                    cb.Width           = BetterFittedWidth(cb) ?? cb.Width;
                    GridPref.ColumnPrefs[cb.FieldName] = new ColumnPref(cb.Width, cb.VisiblePosition);
                }
            }

            // now remaining indices are unspecified columns:  hide.
            foreach (int i in indices)
            {
                ColumnBase cb = this.Grid.Columns[i];
                cb.Visible = false;
            }

            if (prefExisted)
            {
                EnforceColumnPrefs();
            }
        }
Esempio n. 10
0
		/// <summary>converts a Pref to a Prefm object</summary>
		 public static Prefm ConvertToM(Pref pref){
			Prefm prefm=new Prefm();
			prefm.PrefNum=pref.PrefNum;
			prefm.PrefmName=pref.PrefName;
			prefm.ValueString=pref.ValueString;
			return prefm;
		 }
Esempio n. 11
0
        /// <summary>Returns a Prefm object when provided with the PrefName. Note that the CustomerNum field of the return object is not populated. </summary>
        public static Prefm GetPrefm(String PrefName)
        {
            Pref  pref  = Prefs.GetPref(PrefName);
            Prefm prefm = ConvertToM(pref);

            return(prefm);
        }
Esempio n. 12
0
        ///<summary></summary>
        public static void Update(Pref pref)
        {
            string command = "UPDATE preference SET "
                             + "valuestring = '" + POut.PString(pref.ValueString) + "'"
                             + " WHERE prefname = '" + POut.PString(pref.PrefName) + "'";

            General.NonQ(command);
        }
Esempio n. 13
0
        /// <summary>converts a Pref to a Prefm object</summary>
        public static Prefm ConvertToM(Pref pref)
        {
            Prefm prefm = new Prefm();

            prefm.PrefNum     = pref.PrefNum;
            prefm.PrefmName   = pref.PrefName;
            prefm.ValueString = pref.ValueString;
            return(prefm);
        }
Esempio n. 14
0
    private void AddPref(string pref, string prefType)
    {
        Pref newPref = new Pref
        {
            pref    = pref,
            varType = prefType
        };

        _prefList.Add(newPref);
    }
    protected Transform InstantiateAndSetParentObject(Transform refInstantiate, Transform SetParent)
    {
        Transform Pref;

        Pref = Instantiate(refInstantiate);
        Pref.SetParent(SetParent);
        Pref.localScale = new Vector3(1, 1, 1);//изменяем размер так как он почему то меняется при создании обьекта

        return(Pref);
    }
Esempio n. 16
0
        ///<summary>Updates one Pref in the database.</summary>
        public static void Update(Pref pref)
        {
            string command = "UPDATE preference SET "
                             + "PrefName   = '" + POut.String(pref.PrefName) + "', "
                             + "ValueString= '" + POut.String(pref.ValueString) + "', "
                             + "Comments   = '" + POut.String(pref.Comments) + "' "
                             + "WHERE PrefNum = " + POut.Long(pref.PrefNum);

            Db.NonQ(command);
        }
Esempio n. 17
0
        private void ToothFormatRanges()
        {
            PrefB.HList = new Hashtable();
            Pref pref = new Pref();

            pref.PrefName    = "UseInternationalToothNumbers";
            pref.ValueString = "0";
            PrefB.HList.Add(pref.PrefName, pref);
            //for display----------------------------------------------------------------
            string inputrange = "1,2,3,4,5,7,8,9,11,12,15,16,17,18,21,22,23";
            string result     = Tooth.FormatRangeForDisplay(inputrange);
            string desired    = "1-5,7-9,11,12,15,16,17,18,21-23";

            if (result != desired)
            {
                textResults.Text += "ToothFormatRangeForDisplay failed.  Desired: " + desired + " Result: " + result + "\r\n";
            }
            inputrange = "2,4,5,7,8,9,11,12,13,14,15,16,17,18,19,20,21,22,23,25";
            result     = Tooth.FormatRangeForDisplay(inputrange);
            desired    = "2,4,5,7-9,11-16,17-23,25";
            if (result != desired)
            {
                textResults.Text += "ToothFormatRangeForDisplay failed.  Desired: " + desired + " Result: " + result + "\r\n";
            }
            inputrange = "4,5,2, 7,8,9,11 ,13,12,14,15,16,17,18 ,20, 21,22,23,19,25";
            result     = Tooth.FormatRangeForDisplay(inputrange);
            desired    = "2,4,5,7-9,11-16,17-23,25";
            if (result != desired)
            {
                textResults.Text += "ToothFormatRangeForDisplay failed.  Desired: " + desired + " Result: " + result + "\r\n";
            }
            //for database------------------------------------------------------------------
            inputrange = "1-5,7-9,11,12,15,16,17,18,21-23";
            result     = Tooth.FormatRangeForDb(inputrange);
            desired    = "1,2,3,4,5,7,8,9,11,12,15,16,17,18,21,22,23";
            if (result != desired)
            {
                textResults.Text += "ToothFormatRangeForDb failed.  Desired: " + desired + " Result: " + result + "\r\n";
            }
            inputrange = "2,4,5,7-9,11-16,17-23,25";
            result     = Tooth.FormatRangeForDb(inputrange);
            desired    = "2,4,5,7,8,9,11,12,13,14,15,16,17,18,19,20,21,22,23,25";
            if (result != desired)
            {
                textResults.Text += "ToothFormatRangeForDb failed.  Desired: " + desired + " Result: " + result + "\r\n";
            }
            inputrange = "4,2,5,7-9 ,11-16,25 ,  17-23";
            result     = Tooth.FormatRangeForDb(inputrange);
            desired    = "2,4,5,7,8,9,11,12,13,14,15,16,17,18,19,20,21,22,23,25";
            if (result != desired)
            {
                textResults.Text += "ToothFormatRangeForDb failed.  Desired: " + desired + " Result: " + result + "\r\n";
            }
            //we still haven't tested really bad input.
        }
Esempio n. 18
0
 ///<summary>Returns the ValueString of a pref or null if that pref is not found in the database.</summary>
 private string GetHiddenPrefString(PrefName pref)
 {
     try {
         Pref hiddenPref = Prefs.GetOne(pref);
         return(hiddenPref.ValueString);
     }
     catch (Exception ex) {
         ex.DoNothing();
         return(null);
     }
 }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            ((SharedEnviroment)ApplicationContext).Logging = Pref.getLogging(this);
            ((SharedEnviroment)ApplicationContext).TAG     = "NamaadMobile.RefreshData";
            SetActionBarTitle(((SharedEnviroment)ApplicationContext).ActionName);

            SetContentView(Resource.Layout.refresh_data);

            listView   = FindViewById <ListView>(Resource.Id.listView);
            btnRef     = (Button)FindViewById(Resource.Id.btnRef);
            btnChkAll  = (Button)FindViewById(Resource.Id.btnChkAll);
            viewStatus = FindViewById(Resource.Id.status);
            viewForm   = FindViewById(Resource.Id.form);

            tableDesc = new List <RefreshDataEntity>();
            string strSQL = "Select * From WebTableCode Where OrgID= " + ((SharedEnviroment)ApplicationContext).OrgID + " And SystemCode= " + ((SharedEnviroment)ApplicationContext).SystemCode + " And TableCode>1000";

            try
            {
                using (dbHelper = new NmdMobileDBAdapter(this))
                {
                    dbHelper.OpenOrCreateDatabase(dbHelper.DBNamaad);
                    using (SqliteDataReader reader = dbHelper.ExecuteReader(strSQL))
                    {
                        while (reader.Read())
                        {
                            RefreshDataEntity refDataEnt = new RefreshDataEntity
                            {
                                TableDesc  = reader["TableDesc"].ToString(),
                                TableCode  = (int)reader["TableCode"],
                                OrgID      = (short)reader["OrgID"],
                                SystemCode = (int)reader["SystemCode"],
                                TableName  = reader["TableName"].ToString()
                            };
                            tableDesc.Add(refDataEnt);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ExceptionHandler.toastMsg(this, e.Message);
                ExceptionHandler.logDActivity(e.ToString(), ((SharedEnviroment)ApplicationContext).Logging, ((SharedEnviroment)ApplicationContext).TAG);
            }

            listView.Adapter = new ArrayAdapter <RefreshDataEntity>
                                   (this, Android.Resource.Layout.SimpleListItemMultipleChoice, tableDesc);

            listView.ItemsCanFocus     = false;
            listView.ChoiceMode        = ChoiceMode.Multiple;
            listView.TextFilterEnabled = true;
        }
Esempio n. 20
0
    public static IEnumerator LoadFromFile__(string path)
    {
        Debug.LogWarning("LoadFromFile: " + path);
        WWW wwwFile = new WWW(path);

        yield return(wwwFile);

        if (wwwFile.error != null)
        {
            Debug.LogWarning("www Error: " + path);
            yield return(null);
        }
        else
        {
            //Debug.Log(wwwFile.text);
        }
        string str = wwwFile.text;

        string[] splitStr = str.Split('\n');

        keys = new List <Pref>();
        for (int i = 0; i < splitStr.Length; i++)
        {
            string[] prefLine = splitStr[i].Split(',');
            if (prefLine.Length > 2)
            {
                int      index = int.Parse(prefLine[0]);
                PrefType type  = (PrefType)(Enum.GetValues(typeof(PrefType)).GetValue(index));
                string   key   = prefLine[1];
                object   v     = prefLine[2];
                Pref     p     = new Pref(key, type, v);

                keys.Add(p);

                if (type == PrefType.INT)
                {
                    PlayerPrefs.SetInt(key, System.Convert.ToInt32(v));
                }
                else if (type == PrefType.FLOAT)
                {
                    PlayerPrefs.SetFloat(key, System.Convert.ToSingle(v));
                }
                else if (type == PrefType.STRING)
                {
                    PlayerPrefs.SetString(key, (string)v);
                }
                else
                {
                    Debug.LogWarning("noKeyType: " + key);
                }
            }
        }
    }
Esempio n. 21
0
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<Pref> TableToList(DataTable table){
			List<Pref> retVal=new List<Pref>();
			Pref pref;
			for(int i=0;i<table.Rows.Count;i++) {
				pref=new Pref();
				pref.PrefNum    = PIn.Long  (table.Rows[i]["PrefNum"].ToString());
				pref.PrefName   = PIn.String(table.Rows[i]["PrefName"].ToString());
				pref.ValueString= PIn.String(table.Rows[i]["ValueString"].ToString());
				pref.Comments   = PIn.String(table.Rows[i]["Comments"].ToString());
				retVal.Add(pref);
			}
			return retVal;
		}
Esempio n. 22
0
    static public void Load()
    {
        if (!File.Exists(Application.persistentDataPath + "\\Userpref.txt"))
        {
            Debug.LogWarning("未找到存檔!重新建立中");
            data = new Pref();
            Save();
        }
        string json = File.ReadAllText(Application.persistentDataPath + "\\Userpref.txt");
        var    n    = JsonUtility.FromJson <Pref>(json);

        data = n;
        Debug.Log("讀取存檔完成! Path=" + Application.persistentDataPath + "\\Userpref.txt");
    }
Esempio n. 23
0
        ///<summary>Updates one Pref in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.  Returns true if an update occurred.</summary>
        public static bool Update(Pref pref, Pref oldPref)
        {
            string command = "";

            if (pref.PrefName != oldPref.PrefName)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "PrefName = '" + POut.String(pref.PrefName) + "'";
            }
            if (pref.ValueString != oldPref.ValueString)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "ValueString = " + DbHelper.ParamChar + "paramValueString";
            }
            if (pref.Comments != oldPref.Comments)
            {
                if (command != "")
                {
                    command += ",";
                }
                command += "Comments = " + DbHelper.ParamChar + "paramComments";
            }
            if (command == "")
            {
                return(false);
            }
            if (pref.ValueString == null)
            {
                pref.ValueString = "";
            }
            OdSqlParameter paramValueString = new OdSqlParameter("paramValueString", OdDbType.Text, POut.StringParam(pref.ValueString));

            if (pref.Comments == null)
            {
                pref.Comments = "";
            }
            OdSqlParameter paramComments = new OdSqlParameter("paramComments", OdDbType.Text, POut.StringParam(pref.Comments));

            command = "UPDATE preference SET " + command
                      + " WHERE PrefNum = " + POut.Long(pref.PrefNum);
            Db.NonQ(command, paramValueString, paramComments);
            return(true);
        }
Esempio n. 24
0
        public void LocalPreferences_isCorrect(Pref pref, bool status)
        {
            // When
            if (pref == Pref.Main)
            {
                IsOnboardingCompleted = status;
            }
            else
            {
                IsOnboardingCountriesCompleted = status;
            }

            // Then
            Assert.Equal(pref == Pref.Main ? IsOnboardingCompleted : IsOnboardingCountriesCompleted, status);
        }
Esempio n. 25
0
 ///<summary>Inserts one Pref into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(Pref pref)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(pref, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             pref.PrefNum = DbHelper.GetNextOracleKey("preference", "PrefNum");                  //Cacheless method
         }
         return(InsertNoCache(pref, true));
     }
 }
Esempio n. 26
0
    // load from File to PlayerPrefs
    public static void LoadFromFile()
    {
        string path = Application.dataPath + fileName;

        Debug.LogWarning("LoadFromFile: " + path);
        try {
            using (System.IO.StreamReader sr = new StreamReader(path, Encoding.UTF8)) {
                string str = sr.ReadToEnd();
                Debug.LogWarning(str);
                string[] splitStr = str.Split('\n');

//				keys = new List<Pref> ();
                for (int i = 0; i < splitStr.Length; i++)
                {
                    string[] prefLine = splitStr [i].Split(',');
                    if (prefLine.Length > 2)
                    {
                        int      index = int.Parse(prefLine [0]);
                        PrefType type  = (PrefType)(Enum.GetValues(typeof(PrefType)).GetValue(index));
                        string   key   = prefLine [1];
                        object   v     = prefLine [2];
                        Pref     p     = new Pref(key, type, v);

//						keys.Add (p);

                        if (type == PrefType.INT)
                        {
                            PlayerPrefs.SetInt(key, System.Convert.ToInt32(v));
                        }
                        else if (type == PrefType.FLOAT)
                        {
                            PlayerPrefs.SetFloat(key, System.Convert.ToSingle(v));
                        }
                        else if (type == PrefType.STRING)
                        {
                            PlayerPrefs.SetString(key, (string)v);
                        }
                        else
                        {
                            Debug.LogWarning("noKeyType: " + key);
                        }
                    }
                }
            }
        } catch {
            Debug.LogWarning("No File");
        }
    }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.ws_man);
            _logging = Pref.getLogging(this);
            SetActionBarTitle(GetString(Resource.String.RefreshData));
            btnCreate = (Button)FindViewById(Resource.Id.btnCreate);
            listView  = FindViewById <ListView>(Resource.Id.listView);
            btnChkAll = (Button)FindViewById(Resource.Id.btnChkAll);
            btnRef    = (Button)FindViewById(Resource.Id.btnRef);

            Bundle extras = Intent.Extras;

            if (extras != null)
            {
                FieldNames        = extras.GetStringArrayList("FieldNames");
                FieldDisplayNames = extras.GetStringArrayList("FieldDisplayNames");
                _tableDisplayName = extras.GetString("TableDisplayName");
                sourceType        = extras.GetInt("type");
                _table            = extras.GetString("Table");
                _tvQ = extras.GetString("sql");

                if (bundle != null)
                {
                    listRec = (JavaList <IParcelable>)bundle.GetParcelableArrayList("listRec");
                }
                listView.ItemsCanFocus     = false;
                listView.ChoiceMode        = ChoiceMode.Multiple;
                listView.TextFilterEnabled = true;
                notATable = string.IsNullOrEmpty(_table);
                if ((notATable && string.IsNullOrEmpty(_tvQ)) || string.IsNullOrEmpty(_tableDisplayName) || FieldNames == null || FieldDisplayNames == null)
                {
                    InvalidateUI(btnChkAll, btnRef);
                }
                else
                {
                    adapter                    = new ArrayAdapter <IParcelable>(this, Android.Resource.Layout.SimpleListItemMultipleChoice, listRec);
                    listView.Adapter           = adapter;
                    listView.ItemsCanFocus     = false;
                    listView.ChoiceMode        = ChoiceMode.Multiple;
                    listView.TextFilterEnabled = true;
                }
            }
            else
            {
                InvalidateUI(btnChkAll, btnRef);
            }
        }
Esempio n. 28
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <Pref> TableToList(DataTable table)
        {
            List <Pref> retVal = new List <Pref>();
            Pref        pref;

            foreach (DataRow row in table.Rows)
            {
                pref             = new Pref();
                pref.PrefNum     = PIn.Long(row["PrefNum"].ToString());
                pref.PrefName    = PIn.String(row["PrefName"].ToString());
                pref.ValueString = PIn.String(row["ValueString"].ToString());
                pref.Comments    = PIn.String(row["Comments"].ToString());
                retVal.Add(pref);
            }
            return(retVal);
        }
Esempio n. 29
0
 ///<summary>Returns true if Update(Pref,Pref) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(Pref pref, Pref oldPref)
 {
     if (pref.PrefName != oldPref.PrefName)
     {
         return(true);
     }
     if (pref.ValueString != oldPref.ValueString)
     {
         return(true);
     }
     if (pref.Comments != oldPref.Comments)
     {
         return(true);
     }
     return(false);
 }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            ((SharedEnviroment)ApplicationContext).Logging = Pref.getLogging(this);
            ((SharedEnviroment)ApplicationContext).TAG     = "NamaadMobile.BMSGenericActivity";
            SetActionBarTitle(((SharedEnviroment)ApplicationContext).ActionName);
            SetContentView(Resource.Layout.bms_generic_activity);
            _bmsMainLayout = (LinearLayout)FindViewById(Resource.Id.bmsMainLayout);
            _bmsListView   = (ListView)_bmsMainLayout.FindViewById(Resource.Id.bmsListView);
            BMSPublic bmsPublic = new BMSPublic();

            bmsPublic.AddEditableSensorToLayout(this, _bmsListView);
            bmsPublic.AddSwitchDeviceToLayout(this, _bmsListView);
            bmsPublic.AddRefreshToLayout(this, _bmsMainLayout);
            bmsPublic.AddResetToLayout(this, _bmsMainLayout);
        }
Esempio n. 31
0
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <Pref> TableToList(DataTable table)
        {
            List <Pref> retVal = new List <Pref>();
            Pref        pref;

            for (int i = 0; i < table.Rows.Count; i++)
            {
                pref             = new Pref();
                pref.PrefNum     = PIn.Long(table.Rows[i]["PrefNum"].ToString());
                pref.PrefName    = PIn.String(table.Rows[i]["PrefName"].ToString());
                pref.ValueString = PIn.String(table.Rows[i]["ValueString"].ToString());
                pref.Comments    = PIn.String(table.Rows[i]["Comments"].ToString());
                retVal.Add(pref);
            }
            return(retVal);
        }
Esempio n. 32
0
        public int CountElems_Recur(int dir = 0)
        {
            int num = 1;

            if (Pref != null && dir <= 0)
            {
                num += Pref.CountElems_Recur(-1);
            }
            if (dir >= 0)
            {
                if (Next != null)
                {
                    num += Next.CountElems_Recur(1);
                }
            }
            return(num);
        }
Esempio n. 33
0
    private void SetupPref(Pref pref)
    {
        switch (pref.varType)
        {
        case "Int":
            PlayerPrefs.SetInt(pref.pref, 0);
            break;

        case "Float":
            PlayerPrefs.SetFloat(pref.pref, 0f);
            break;

        case "String":
            PlayerPrefs.SetString(pref.pref, string.Empty);
            break;
        }
    }
Esempio n. 34
0
        public void ConfigurationJson()
        {
            PrefInteger prefInteger = new PrefInteger("integer_pref", 2);
            PrefDouble  prefDouble  = new PrefDouble("integer_pref", 4);

            Pref pref = new Pref("only_pref");

            List <Pref> prefList = new List <Pref> {
                pref, prefInteger, prefDouble
            };

            Configuration   c = new Configuration(prefInteger, prefList);
            SimplTypesScope simplTypesScope = SimplTypesScope.Get("configuration", typeof(Configuration),
                                                                  typeof(PrefInteger), typeof(PrefDouble), typeof(Pref));

            TestMethods.TestSimplObject(c, simplTypesScope, Format.Json);
        }
Esempio n. 35
0
		///<summary>Updates one Pref in the database.</summary>
		public static void Update(Pref pref){
			string command="UPDATE preference SET "
				+"PrefName   = '"+POut.String(pref.PrefName)+"', "
				+"ValueString= '"+POut.String(pref.ValueString)+"', "
				+"Comments   = '"+POut.String(pref.Comments)+"' "
				+"WHERE PrefNum = "+POut.Long(pref.PrefNum);
			Db.NonQ(command);
		}
Esempio n. 36
0
			public PrefsHolder(string prefsString, Sources source)
			{
				Source = source;
				previousPrefs = DeSerialise(prefsString);
				foreach (string key in previousPrefs.Keys)
					this[key] = new Pref(key, previousPrefs[key]);
			}
Esempio n. 37
0
			/// <summary>
			/// Adds an element with the specified key and value to this PrefsHolder.
			/// </summary>
			/// <param name="key">
			/// The string key of the element to add.
			/// </param>
			/// <param name="value">
			/// The Pref value of the element to add.
			/// </param>
			public virtual void Add(string key, Pref value)
			{
				this.Dictionary.Add(key, value);
			}
Esempio n. 38
0
			/// <summary>
			/// Determines whether this PrefsHolder contains a specific value.
			/// </summary>
			/// <param name="value">
			/// The Pref value to locate in this PrefsHolder.
			/// </param>
			/// <returns>
			/// true if this PrefsHolder contains an element with the specified value;
			/// otherwise, false.
			/// </returns>
			public virtual bool ContainsValue(Pref value)
			{
				foreach (Pref item in this.Dictionary.Values)
				{
					if (item == value)
						return true;
				}
				return false;
			}
Esempio n. 39
0
		///<summary>Updates one Pref in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.</summary>
		public static void Update(Pref pref,Pref oldPref){
			string command="";
			if(pref.PrefName != oldPref.PrefName) {
				if(command!=""){ command+=",";}
				command+="PrefName = '"+POut.String(pref.PrefName)+"'";
			}
			if(pref.ValueString != oldPref.ValueString) {
				if(command!=""){ command+=",";}
				command+="ValueString = '"+POut.String(pref.ValueString)+"'";
			}
			if(pref.Comments != oldPref.Comments) {
				if(command!=""){ command+=",";}
				command+="Comments = '"+POut.String(pref.Comments)+"'";
			}
			if(command==""){
				return;
			}
			command="UPDATE preference SET "+command
				+" WHERE PrefNum = "+POut.Long(pref.PrefNum);
			Db.NonQ(command);
		}