Ejemplo n.º 1
0
        private bool APICount()
        {
            int    apiCount    = ConfigSugar.GetAppInt("APICount");
            string path        = this.Server.MapPath("APICount");
            string fileName    = "apicount.ini";
            string filePath    = Path.Combine(path, fileName);
            string fileContent = System.IO.File.ReadAllText(filePath);

            if (string.IsNullOrEmpty(fileContent))
            {
                fileContent = DateTime.Now.ToString("yyyy-MM-dd") + "|0";
            }
            string[] fileStrs = fileContent.Split('|');
            int      count    = 0;

            if (DateTime.Now.ToString("yyyy-MM-dd") == fileStrs[0])
            {
                count = Convert.ToInt32(fileStrs[1]);
            }
            if (count > apiCount)
            {
                return(false);
            }
            else
            {
                count++;
                fileContent = DateTime.Now.ToString("yyyy-MM-dd") + "|" + count.ToString();
                System.IO.File.WriteAllText(filePath, fileContent);
                return(true);
            }
        }