예제 #1
0
    public void read_dates(string file, ref int lock_day, ref Dictionary <int, int> allready_passed_dates)
    {
        try
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(file);
            XmlNode game_xn = doc.SelectSingleNode("game");

            XML_Element lock_xe   = new XML_Element((XmlElement)game_xn.SelectSingleNode("lock_date"));
            int         lock_date = lock_xe.f_int("date");

            XML_Element used_day_xe = new XML_Element((XmlElement)game_xn.SelectSingleNode("used_date"));
            List <int>  used_days   = used_day_xe.f_int_vector("dates");

            if (lock_day == 0)
            {
                lock_day = lock_date;
            }

            lock_day = lock_day < lock_date ? lock_day : lock_date;
            for (int i = 0; i < used_days.Count(); i++)
            {
                allready_passed_dates[used_days[i]] = used_days[i];
            }
        }
        catch
        {//
        }
    }
예제 #2
0
    public bool test_leagle_file(string file)
    {
        bool file_exist = false;
        int  today      = get_day_str(0);

        XmlDocument doc = new XmlDocument();

        try
        {
            doc.Load(file);
            file_exist = true;
            //print("------------------file ok");
        }
        catch
        {// 不存在就创建一个
            XmlDeclaration dec = doc.CreateXmlDeclaration("1.0", "utf-8", null);
            doc.AppendChild(dec);
            //创建一个根节点(一级)
            XmlElement root = doc.CreateElement("game");
            doc.AppendChild(root);
            //创建节点(二级)
            XmlElement lock_node = doc.CreateElement("lock_date");
            XmlElement day_node  = doc.CreateElement("used_date");


            lock_node.SetAttribute("date", get_day_str(-10).ToString());
            day_node.SetAttribute("dates", get_day_str(0).ToString());

            root.AppendChild(lock_node);
            root.AppendChild(day_node);
            // 如果文件夹不存在  创建文件夹
            Directory.CreateDirectory(file.Substring(0, file.LastIndexOf('/') + 1));
            doc.Save(file);

            file_exist = false;
            //print("------------------file error and create a new one");
        }

        XmlNode game_xn = doc.SelectSingleNode("game");

        XML_Element lock_xe   = new XML_Element((XmlElement)game_xn.SelectSingleNode("lock_date"));
        int         lock_date = lock_xe.f_int("date");

        XML_Element used_day_xe = new XML_Element((XmlElement)game_xn.SelectSingleNode("used_date"));
        List <int>  used_days   = used_day_xe.f_int_vector("dates");

        bool today_is_leagle = true;

        for (int i = 0; i < used_days.Count(); i++)
        {
            if (today < used_days[i])
            {// 这个日期比  当前日期要大   说明甲方改系统时间了
                today_is_leagle = false;
            }
        }
        if (today < lock_date)
        {
            //print("------------------1:today<锁码日期,    ");

            //return true;
        }
        if (today_is_leagle == true)
        {
            //print("------------------  2:today的日期是没有修改过的    ");

            //return true;
        }
        if (file_exist == true)
        {
            //print("------------------  3:文件是存在的");

            //return true;
        }

        // true 的条件   1:today小于锁码日期,    2:today的日期是没有修改过的    3:文件是存在的
        if (today < lock_date && today_is_leagle == true && file_exist == true)
        {
            //print("------------------1:today<锁码日期,    2:today的日期是没有修改过的    3:文件是存在的");

            return(true);
        }
        else
        {
            //print("------------------ error");
            return(false);
        }
    }