Example #1
0
        public List <SMSSendInfo> Get(string com)
        {
            List <SMSSendInfo> list      = new List <SMSSendInfo>();
            DataValues         whereArgs = new DataValues();

            whereArgs.Add("com", com);
            whereArgs.Add("dateTime", DateTime.Now.Ticks);
            whereArgs.Add("state", 0);
            using (Cursor cursor = _dbHelper.Query(SMS_SEND, null, "com = ?,dateTime < ?,state = ?", null))
            {
                while (cursor.Next())
                {
                    int    sid     = cursor.GetInt("sid");
                    string phone   = cursor.GetString("phone");
                    string content = cursor.GetString("content");
                    //int state = Convert.ToInt32(row["state"]);
                    //model
                    SMSSendInfo sendInfo = new SMSSendInfo
                    {
                        Id       = sid,
                        Com      = com,
                        Phone    = phone,
                        Message  = content,
                        DateTime = DateTime.Now.Ticks,
                    };
                    list.Add(sendInfo);
                    Set(sendInfo, 1);
                }
            }
            return(list);
        }
Example #2
0
 public List<SMSSendInfo> Get(string com)
 {
     List<SMSSendInfo> list = new List<SMSSendInfo>();
     DataValues whereArgs = new DataValues();
     whereArgs.Add("com",com);
     whereArgs.Add("dateTime",DateTime.Now.Ticks);
     whereArgs.Add("state", 0);
     using (Cursor cursor = _dbHelper.Query(SMS_SEND, null, "com = ?,dateTime < ?,state = ?", null))
     {
         while (cursor.Next())
         {
             int sid = cursor.GetInt("sid");
             string phone = cursor.GetString("phone");
             string content = cursor.GetString("content");
             //int state = Convert.ToInt32(row["state"]);
             //model
             SMSSendInfo sendInfo = new SMSSendInfo
             {
                 Id = sid,
                 Com = com,
                 Phone = phone,
                 Message = content,
                 DateTime = DateTime.Now.Ticks,
             };
             list.Add(sendInfo);
             Set(sendInfo, 1);
         }
     }
     return list;
 }
Example #3
0
        public void MsSqlTest()
        {
            IDbHelper dbHelper = new MsSQL("test");
            //dbHelper.CreateTable("TEST", tableValues);

            for (int i = 0; i < 10; i++)
            {
                DataValues contentValues = new DataValues();
                contentValues.Add("Name", "lsong");
                contentValues.Add("Password", "123456");
                int insert = dbHelper.Insert("myTable", contentValues);
                Assertion.Assert(insert <= 0);
            }

            using (TransactionScope transactionScope = new TransactionScope())
            {
                DataValues contentValues = new DataValues();
                dbHelper.Update("myTable", contentValues, null, null);

                transactionScope.Complete();
            }
            using (var cursor = dbHelper.Query("myTable", null, null, null))
            {
                while (cursor.Next())
                {
                    System.Console.Write(cursor[0] + "\t");
                    System.Console.Write(cursor[1] + "\t");
                    System.Console.Write(cursor[2] + "\t");
                    System.Console.WriteLine();
                }
            }
        }
Example #4
0
        public void MsSqlTest()
        {
            IDbHelper dbHelper = new MsSQL("test");

            //dbHelper.CreateTable("TEST", tableValues);

            for (int i = 0; i < 10; i++)
            {
                DataValues contentValues = new DataValues();
                contentValues.Add("Name", "lsong");
                contentValues.Add("Password", "123456");
                int insert = dbHelper.Insert("myTable", contentValues);
                Assertion.Assert(insert <= 0);
            }

            using (TransactionScope transactionScope = new TransactionScope())
            {
                DataValues contentValues = new DataValues();
                dbHelper.Update("myTable", contentValues, null, null);

                transactionScope.Complete();
            }
            using (var cursor = dbHelper.Query("myTable", null, null, null))
            {
                while (cursor.Next())
                {
                    System.Console.Write(cursor[0] + "\t");
                    System.Console.Write(cursor[1] + "\t");
                    System.Console.Write(cursor[2] + "\t");
                    System.Console.WriteLine();
                }
            }
        }
Example #5
0
        private void AddNew()
        {
            const string defaultKeyName = "New Key";

            var keyName = defaultKeyName;

            if (DataValues.Any(k => k.RawKey == keyName))
            {
                var existingSameKey = DataValues.Where(k => k.RawKey.StartsWith(defaultKeyName))
                                      .Select(k => k.RawKey.Replace(defaultKeyName, String.Empty)).Select(
                    k =>
                {
                    if (int.TryParse(k, out var value))
                    {
                        return(value);
                    }

                    return(0);
                }
                    ).Max() + 1;

                keyName = defaultKeyName + existingSameKey.ToString();
            }

            DataValues.Add(new EncryptedKeyPair(Algorithm)
            {
                RawKey = keyName, RawValue = "New Value"
            });
        }
Example #6
0
        /// <summary>
        /// 添加数据点
        /// </summary>
        /// <param name="dateTime"></param>
        /// <param name="value"></param>
        public void AddPoint(DateTime dateTime, double value)
        {
            if (++Count > _maximumCount)
            {
                Count = _maximumCount;

                Labels.RemoveAt(0);
                UpperValues.RemoveAt(0);
                LowerValues.RemoveAt(0);
                DataValues.RemoveAt(0);
                CPKValues.RemoveAt(0);
            }

            Labels.Add(dateTime.ToString(GlobalConstants.TimeFormat));
            tbOdValue.Text = value.ToString(GlobalConstants.DoubleFormat);
            UpperValues.Add(_upper);
            LowerValues.Add(_lower);
            DataValues.Add(double.Parse(value.ToString(GlobalConstants.DoubleFormat)));

            if (Values.Count >= CPKCount)
            {
                Values.RemoveAt(0);
            }
            Values.Add(value);
            CPK             = CalculateCPK();
            tbCpkValue.Text = _cpk.ToString(GlobalConstants.DoubleFormat);
            CPKValues.Add(Math.Round(_cpk, 3));
        }
Example #7
0
 public void Set(SMSSendInfo sendInfo, int state)
 {
     DataValues contentValues = new DataValues();
     contentValues.Add("state", state);
     DataValues whereArgs = new DataValues();
     whereArgs.Add("SID", sendInfo.Id);
     _dbHelper.Update(SMS_SEND, contentValues, "SID = ?", whereArgs);
 }
Example #8
0
 public void AddItem(VAR var)
 {
     lock (_enable)
     {
         DataValues.Add(var);
     }
     Save();
 }
Example #9
0
        public void Set(SMSSendInfo sendInfo, int state)
        {
            DataValues contentValues = new DataValues();

            contentValues.Add("state", state);
            DataValues whereArgs = new DataValues();

            whereArgs.Add("SID", sendInfo.Id);
            _dbHelper.Update(SMS_SEND, contentValues, "SID = ?", whereArgs);
        }
Example #10
0
        public virtual void AddDataItem(string key, string value)
        {
            if (IsCategory)
            {
                return;
            }

            if (key != null)
            {
                DataValues.Add(new Tuple <string, string>(key, value));
            }
        }
Example #11
0
 public long Add(SMSSendInfo smsInfo)
 {
     const int defaultNum = 0;
     DataValues contentValues = new DataValues();
     contentValues.Add("SID",null);
     contentValues.Add("COM",smsInfo.Com);
     contentValues.Add("PHONE",smsInfo.Phone);
     contentValues.Add("CONTENT",smsInfo.Message);
     contentValues.Add("DATETIME",smsInfo.DateTime);
     contentValues.Add("STATE",defaultNum);
     int result = _dbHelper.Insert(SMS_SEND, contentValues);
     return result;
 }
Example #12
0
        public long Add(SMSSendInfo smsInfo)
        {
            const int  defaultNum    = 0;
            DataValues contentValues = new DataValues();

            contentValues.Add("SID", null);
            contentValues.Add("COM", smsInfo.Com);
            contentValues.Add("PHONE", smsInfo.Phone);
            contentValues.Add("CONTENT", smsInfo.Message);
            contentValues.Add("DATETIME", smsInfo.DateTime);
            contentValues.Add("STATE", defaultNum);
            int result = _dbHelper.Insert(SMS_SEND, contentValues);

            return(result);
        }
Example #13
0
 public void Load(string FilePath = DEFAULT_PATH)
 {
     lock (_enable)
     {
         if (!File.Exists(FilePath))
         {
             return;
         }
         var str = File.ReadAllText(FilePath);
         try
         {
             var obj = JsonConvert.DeserializeObject <IEnumerable <VAR> >(str);
             DataValues.Clear();
             foreach (var a in obj)
             {
                 DataValues.Add(a);
             }
         }
         catch (Exception ex)
         {
             _events.PostError(ex);
         }
     }
 }