public int insert(ProvinceDailyData pdd)
        {
            int    line = 0;
            string sql  = "insert into ProvinceDailyData values (@province,@date,@confirmed,@suspect,@death)";
            List <MySqlParameter> plst = new List <MySqlParameter>();

            plst.Add(new MySqlParameter("@province", pdd.province));
            plst.Add(new MySqlParameter("@date", pdd.date));
            plst.Add(new MySqlParameter("@confirmed", pdd.confirmed));
            plst.Add(new MySqlParameter("@suspect", pdd.suspect));
            plst.Add(new MySqlParameter("@death", pdd.death));
            line = MySQLHelper.ExecuteSql(sql, plst.ToArray());
            return(line);
        }
        public List <ProvinceDailyData> selectALL()
        {
            List <ProvinceDailyData> pddlst = new List <ProvinceDailyData>();
            string          sql             = "select province,casedate,confirmed,suspect,death from ProvinceDailyData";
            MySqlDataReader reader          = MySQLHelper.ExecuteReader(sql);

            while (reader.Read())
            {
                ProvinceDailyData pdd = new ProvinceDailyData(reader.GetString("province"), reader.GetString("casedate"), reader.GetInt32("confirmed"), reader.GetInt32("suspect"), reader.GetInt32("death"));
                pddlst.Add(pdd);
            }
            reader.Close();

            return(pddlst);
        }
Esempio n. 3
0
        public bool update(ProvinceDailyData pdd)
        {
            ProvinceDailyData existPdd = pdddao.selecctByProvince_Date(pdd.province, pdd.date);

            if (existPdd == null)
            {
                return(false);
            }
            int line = pdddao.update(pdd);

            if (line == 1)
            {
                return(true);
            }
            return(false);
        }
        public int update(ProvinceDailyData pdd)
        {
            int line = 0;

            string sql = "update ProvinceDailyData set confirmed=@confirmed,suspect=@suspect,death=@death where province=@province and casedate=@date";

            List <MySqlParameter> plst = new List <MySqlParameter>();

            plst.Add(new MySqlParameter("@province", pdd.province));
            plst.Add(new MySqlParameter("@date", pdd.date));
            plst.Add(new MySqlParameter("@confirmed", pdd.confirmed));
            plst.Add(new MySqlParameter("@suspect", pdd.suspect));
            plst.Add(new MySqlParameter("@death", pdd.death));
            line = MySQLHelper.ExecuteSql(sql, plst.ToArray());

            return(line);
        }
        public List <ProvinceDailyData> selectByProvince(string province)
        {
            List <ProvinceDailyData> pddlst = new List <ProvinceDailyData>();
            string sql = "select province,casedate,confirmed,suspect,death from ProvinceDailyData where province=@province";
            List <MySqlParameter> plst = new List <MySqlParameter>();

            plst.Add(new MySqlParameter("@province", province));
            MySqlDataReader reader = MySQLHelper.ExecuteReader(sql, plst.ToArray());

            while (reader.Read())
            {
                ProvinceDailyData pdd = new ProvinceDailyData(reader.GetString("province"), reader.GetString("casedate"), reader.GetInt32("confirmed"), reader.GetInt32("suspect"), reader.GetInt32("death"));
                pddlst.Add(pdd);
            }
            reader.Close();

            return(pddlst);
        }
Esempio n. 6
0
        public bool ProcessPlagueData(string jstr)
        {
            bool          res       = false;
            JObject       jnlst     = JObject.Parse(jstr);
            List <string> existDate = new List <string>();

            ProvinceSumData psd = new ProvinceSumData("", 0, 0, 0);

            IProvinceDailyDataBLL pddbll = new ProvinceDailyDataBLL();
            IProvinceSumDataBLL   psdbll = new ProvinceSumDataBLL();

            foreach (JObject pdinfo in jnlst["results"])//province daily info
            {
                //province
                string province = (string)pdinfo["provinceName"];
                //date
                System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
                double          time      = (double)pdinfo["updateTime"];
                DateTime        dt        = startTime.AddMilliseconds(time);
                string          date      = dt.ToString("yyyy-MM-dd");
                if (existDate.Contains(date))
                {
                    continue;
                }
                existDate.Add(date);

                int confirmed = 0, suspect = 0, death = 0;

                JObject judge = JObject.Parse("{\"error\": null}");

                if (pdinfo.Property("confirmedCount") != null && pdinfo.Property("confirmedCount").ToString() != "" && !pdinfo["confirmedCount"].Equals(judge["error"]))
                {
                    confirmed = (int)pdinfo["confirmedCount"];
                }
                if (pdinfo.Property("suspectedCount") != null && pdinfo.Property("suspectedCount").ToString() != "" && !pdinfo["suspectedCount"].Equals(judge["error"]))
                {
                    suspect = (int)pdinfo["suspectedCount"];
                }
                if (pdinfo.Property("deadCount") != null && pdinfo.Property("deadCount").ToString() != "" && !pdinfo["deadCount"].Equals(judge["error"]))
                {
                    death = (int)pdinfo["deadCount"];
                }



                //Console.WriteLine(province+" "+date+" "+confirmed+" "+suspect+" "+death);
                //Console.ReadLine();
                //构建ProvinceDailyData类
                ProvinceDailyData pdd = new ProvinceDailyData(province, date, confirmed, suspect, death);
                //插入数据库
                if (pddbll.insert(pdd) == false)
                {
                    res = pddbll.update(pdd);
                    if (res == false)
                    {
                        return(res);
                    }
                }

                //更新psd的值
                psd.province  = province;
                psd.confirmed = Math.Max(psd.confirmed, pdd.confirmed);
                psd.suspect   = Math.Max(psd.suspect, pdd.suspect);
                psd.death     = Math.Max(psd.death, pdd.death);
            }

            Console.WriteLine("psd " + psd.province + " " + psd.confirmed + " " + psd.suspect + " " + psd.death);
            Console.ReadLine();
            if (psdbll.insert(psd) == false)
            {
                res = psdbll.update(psd);
                if (res == false)
                {
                    return(res);
                }
            }

            return(res);
        }