Beispiel #1
0
        /// <summary>
        /// Kiểm tra trong một ngày sử dụng bao nhiêu lần
        /// </summary>
        public static int CheckDateTimesCurrent()
        {
            try
            {
                DataSet ds     = new DataSet();
                int     _times = 0;
                if (File.Exists(_pathDateTimesCurrent))
                {
                    ds.ReadXml(_pathDateTimesCurrent);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        DateTime _date = Convert.ToDateTime(LibraryDev.Decrypt(_key, ds.Tables[0].Rows[0]["col1"] + string.Empty));
                        _times = Convert.ToInt32(LibraryDev.Decrypt(_key, ds.Tables[0].Rows[0]["col2"] + string.Empty));

                        //Nếu ngày hiện tại lớn hơn ngày log, cập nhật ngày mới
                        if (DateTime.Now.Date > _date)
                        {
                            _date  = DateTime.Now.Date;
                            _times = 1;
                        }
                        else
                        {
                            _times = _times + 1;
                        }

                        ds.Tables[0].Rows[0]["col1"] = LibraryDev.Encrypt(LibraryDev._key, _date + string.Empty);
                        ds.Tables[0].Rows[0]["col2"] = LibraryDev.Encrypt(LibraryDev._key, _times + string.Empty);
                        ds.Tables[0].WriteXml(_pathDateTimesCurrent);
                    }
                }
                else
                {
                    //Tạo xml mới ngày hiện tại
                    ds.Tables.Add("DSkinWin");
                    ds.Tables[0].Columns.Add("col1", typeof(String)); //Ngày
                    ds.Tables[0].Columns.Add("col2", typeof(String)); //Số lần mở

                    DataRow r = ds.Tables[0].NewRow();
                    r["col1"] = LibraryDev.Encrypt(LibraryDev._key, DateTime.Now.Date + string.Empty);
                    r["col2"] = LibraryDev.Encrypt(LibraryDev._key, "1");
                    _times    = 1;
                    ds.Tables[0].Rows.Add(r);

                    ds.Tables[0].WriteXml(_pathDateTimesCurrent);
                }

                return(_times);
            }
            catch (Exception)
            {
                return(0);
            }
        }
Beispiel #2
0
        public static void Active(DataSet ds, string path, string _address)
        {
            ds.Tables[0].Rows[0]["col6"] = LibraryDev.Encrypt(LibraryDev._key, "active");
            ds.Tables[0].WriteXml(path);
            System.IO.Directory.CreateDirectory(LibraryDev._pathFolderSuccess);

            ds.Tables[0].Columns.Add("col7", typeof(String));//Active
            ds.Tables[0].Columns.Add("col8", typeof(String));
            ds.Tables[0].Rows[0]["col7"] = _address;
            ds.Tables[0].Rows[0]["col8"] = LibraryDev.Encrypt(LibraryDev._key, _address);
            ds.Tables[0].WriteXml(LibraryDev._pathSuccess);
        }