Ejemplo n.º 1
0
 public ActionResult ViewDiary()
 {
     string jsonStr = Request.Params["postjson"];
     QueryCondition obj = JsonConvert.DeserializeObject<QueryCondition>(jsonStr);
     List<int> nData = new List<int>();
     nData= visitop.GetDiaryNumericData(obj.PID, obj.StartDate, obj.EndDate, obj.query1);
     List<DiaryDataPoint> qData = visitop.GetDiaryQualitativeData(obj.PID, obj.StartDate, obj.EndDate, obj.query2);
     for (int i = 0; i < nData.Count;i++ )
     {
         DiaryDataPoint nqdata = new DiaryDataPoint();
         nqdata.data = nData[i].ToString();
         nqdata.kind = i.ToString();
         qData.Add(nqdata);
     }
     string sJSON = JsonHelper.JsonSerializer(qData);
     return this.Json(sJSON);
 }
Ejemplo n.º 2
0
        public List<DiaryDataPoint> Count(List<string> HData)
        {
            List<DiaryDataPoint> Result = new List<DiaryDataPoint>();
            List<string> kinds =new List<string>();
            List<int> kindscount = new List<int>();
            for (int i = 0; i < HData.Count;i++ )
            {
                if (i == 0)
                {
                    kinds.Add(HData[0]);
                    kindscount.Add(1);
                }
                else
                {
                    bool flag=false;
                    for (int j = 0; j < kinds.Count; j++)
                    {
                        if (HData[i]==kinds[j])
                        {
                            kindscount[j]++;
                            flag=true;
                            break;

                        }

                    }
                    if(!flag)
                    {
                        kinds.Add(HData[i]);
                        kindscount.Add(1);
                    }
                }

            }
            for (int n = 0; n < kinds.Count; n++)
            {
                DiaryDataPoint dp = new DiaryDataPoint();
                dp.data = kindscount[n].ToString();
                dp.kind = kinds[n];
                Result.Add(dp);
            }
                return Result;
        }
Ejemplo n.º 3
0
        public List <DiaryDataPoint> Count(List <string> HData)
        {
            List <DiaryDataPoint> Result     = new List <DiaryDataPoint>();
            List <string>         kinds      = new List <string>();
            List <int>            kindscount = new List <int>();

            for (int i = 0; i < HData.Count; i++)
            {
                if (i == 0)
                {
                    kinds.Add(HData[0]);
                    kindscount.Add(1);
                }
                else
                {
                    bool flag = false;
                    for (int j = 0; j < kinds.Count; j++)
                    {
                        if (HData[i] == kinds[j])
                        {
                            kindscount[j]++;
                            flag = true;
                            break;
                        }
                    }
                    if (!flag)
                    {
                        kinds.Add(HData[i]);
                        kindscount.Add(1);
                    }
                }
            }
            for (int n = 0; n < kinds.Count; n++)
            {
                DiaryDataPoint dp = new DiaryDataPoint();
                dp.data = kindscount[n].ToString();
                dp.kind = kinds[n];
                Result.Add(dp);
            }
            return(Result);
        }
Ejemplo n.º 4
0
        public List <DiaryDataPoint> Count(List <string> HData)
        {
            List <DiaryDataPoint> Result     = new List <DiaryDataPoint>();
            List <string>         kinds      = new List <string>();
            List <int>            kindscount = new List <int>();
            List <diaryData>      dd         = new List <diaryData>();

            for (int i = 0; i < HData.Count; i++)
            {
                var str = HData[i];
                if (str != null && str != string.Empty)
                {
                    str = System.Text.RegularExpressions.Regex.Replace(str, @"[^\d.\d]", "");//[2,0,0,0]去除符号只剩2000
                    var c      = str.ToArray();
                    var length = c.Count();
                    if (i == 0)
                    {
                        if (length == 1)
                        {
                            kinds.Add(str);
                            kindscount.Add(1);
                        }
                        else
                        {
                            for (int a = 0; a < length; a++)
                            {
                                int num = c[a] - '0';//将ASCII装成正常数字
                                if (num != 0)
                                {
                                    kinds.Add(a.ToString());
                                    kindscount.Add(1);
                                }
                            }
                        }
                    }
                    else
                    {
                        for (int a = 0; a < length; a++)
                        {
                            if (length == 1)
                            {
                                bool flag = false;
                                for (int j = 0; j < kinds.Count; j++)
                                {
                                    if (str == kinds[j])
                                    {
                                        kindscount[j]++;
                                        flag = true;
                                        break;
                                    }
                                }
                                if (!flag)
                                {
                                    kinds.Add(str);
                                    kindscount.Add(1);
                                }
                            }
                            else
                            {
                                int num = c[a] - '0';
                                if (num != 0)
                                {
                                    bool flag = false;
                                    for (int j = 0; j < kinds.Count; j++)
                                    {
                                        if (a.ToString() == kinds[j])
                                        {
                                            kindscount[j]++;
                                            flag = true;
                                            break;
                                        }
                                    }
                                    if (!flag)
                                    {
                                        kinds.Add(a.ToString());
                                        kindscount.Add(1);
                                    }
                                }
                            }
                        }
                    }



                    //只能处理json字符串,不可以处理int数据,留着下次用哈
                    //JArray aaa = (JArray)JsonConvert.DeserializeObject(HData[i]);
                    //for (i = 0; i < aaa.Count; i++)
                    //{
                    //    aaa[i].Value<int>();
                    //}
                }
            }
            for (int n = 0; n < kinds.Count; n++)
            {
                DiaryDataPoint dp = new DiaryDataPoint();
                dp.data = kindscount[n];
                dp.kind = kinds[n];
                Result.Add(dp);
            }
            Result = reportcontent(Result, HData.Count);
            return(Result);
        }