public static string check_mamaro(string param1, string param2, string param3, string param4, string param5, string param6, string param7) { GCP_MYSQL gc = new GCP_MYSQL(); string Query = ""; int QAcou = 0; int QAcou1 = 0; string result = ""; DateTime start = Convert.ToDateTime(param1.Trim()); DateTime end = Convert.ToDateTime(param2.Trim()); if (param7 == "") { param7 = "300"; } try { if (start != null && end != null) { state_group sg = new state_group(); QA_group qaa = new QA_group(); state_list = new List <state_group>(); lock_state_list = new List <state_group>(); QA_list = new List <QA_group>(); string room_id = param6; //mamaro QA Query = "select * from nursing_room_QA where nursing_room_id='" + room_id + "' and insert_time between '" + start.ToString("yyyy-MM-dd HH:mm:ss") + "' and '" + end.ToString("yyyy-MM-dd HH:mm:ss") + "';"; DataView ict = gc.select_cmd(Query); QAcou = ict.Count; if (ict.Count > 0) { for (int i = 0; i < ict.Count; i++) { qaa = new QA_group(); qaa.answer_datetime = Convert.ToDateTime(ict.Table.Rows[i]["insert_time"].ToString()); qaa.baby_m = ict.Table.Rows[i]["Q1_baby_month"].ToString(); qaa.baby_y = ict.Table.Rows[i]["Q1_baby_year"].ToString(); qaa.lan = ict.Table.Rows[i]["language"].ToString(); qaa.parent = ict.Table.Rows[i]["Q1_parent"].ToString(); qaa.Q2_choice = ict.Table.Rows[i]["Q2_choice"].ToString(); qaa.Q3_choice = ict.Table.Rows[i]["Q3_choice"].ToString(); qaa.Q4_choice = ict.Table.Rows[i]["Q4_choice"].ToString(); qaa.Q5_choice = ict.Table.Rows[i]["Q5_choice"].ToString(); QA_list.Add(qaa); } } QA_group_1 qaa_1 = new QA_group_1(); QA_list_1 = new List <QA_group_1>(); //mamaro new QA Query = "select * from nursing_room_QA1 where nursing_room_id='" + room_id + "' and insert_time between '" + start.ToString("yyyy-MM-dd HH:mm:ss") + "' and '" + end.ToString("yyyy-MM-dd HH:mm:ss") + "';"; ict = gc.select_cmd(Query); QAcou1 = ict.Count; if (ict.Count > 0) { for (int i = 0; i < ict.Count; i++) { qaa_1 = new QA_group_1(); qaa_1.answer_datetime = Convert.ToDateTime(ict.Table.Rows[i]["insert_time"].ToString()); qaa_1.baby_y_m = ict.Table.Rows[i]["Q1_baby_year_month"].ToString(); qaa_1.lan = ict.Table.Rows[i]["language"].ToString(); qaa_1.parent = ict.Table.Rows[i]["Q1_parent"].ToString(); qaa_1.Q2_choice = ict.Table.Rows[i]["Q2_choice"].ToString(); qaa_1.Q3_choice = ict.Table.Rows[i]["Q3_choice"].ToString(); qaa_1.Q4_choice = ict.Table.Rows[i]["Q4_choice"].ToString(); qaa_1.Q5_choice = ict.Table.Rows[i]["Q5_choice"].ToString(); qaa_1.Q6_choice = ict.Table.Rows[i]["Q6_choice"].ToString(); QA_list_1.Add(qaa_1); } } //state time Query = "select * from nursing_room_state_time where nursing_room_id='" + room_id + "' and update_time between '" + start.ToString("yyyy-MM-dd HH:mm:ss") + "' and '" + end.ToString("yyyy-MM-dd HH:mm:ss") + "' order by update_time asc;"; ict = gc.select_cmd(Query); if (ict.Count > 0) { for (int i = 0; i < ict.Count; i++) { sg = new state_group(); sg.state = Convert.ToInt32(ict.Table.Rows[i]["state"].ToString()); sg.update = Convert.ToDateTime(ict.Table.Rows[i]["update_time"].ToString()); state_list.Add(sg); } } List <state_group> check_list = new List <state_group>(); for (int i = 0; i < state_list.Count; i++) { if (state_list[i].state == 1) { sg = new state_group(); sg.state = state_list[i].state; sg.update = state_list[i].update; check_list.Add(sg); int index = i + 1; while (index < state_list.Count) { if (state_list[index].state == 0) { sg = new state_group(); sg.state = state_list[index].state; sg.update = state_list[index].update; check_list.Add(sg); break; } index += 1; } } } //lock state time Query = "select * from nursing_room_lock_state_time where nursing_room_id='" + room_id + "' and update_time between '" + start.ToString("yyyy-MM-dd HH:mm:ss") + "' and '" + end.ToString("yyyy-MM-dd HH:mm:ss") + "' order by update_time asc;;"; ict = gc.select_cmd(Query); if (ict.Count > 0) { if (room_id == "9") { for (int i = 0; i < ict.Count; i++) { sg = new state_group(); if (Convert.ToDateTime(ict.Table.Rows[i]["update_time"].ToString()).Year <= 2017 && Convert.ToDateTime(ict.Table.Rows[i]["update_time"].ToString()).Month <= 11 && Convert.ToDateTime(ict.Table.Rows[i]["update_time"].ToString()).Day <= 26) { if (Convert.ToInt32(ict.Table.Rows[i]["lock_state"].ToString()) == 0) { sg.state = 1; } else { sg.state = 0; } } else { sg.state = Convert.ToInt32(ict.Table.Rows[i]["lock_state"].ToString()); } sg.update = Convert.ToDateTime(ict.Table.Rows[i]["update_time"].ToString()); lock_state_list.Add(sg); } } else { for (int i = 0; i < ict.Count; i++) { sg = new state_group(); sg.state = Convert.ToInt32(ict.Table.Rows[i]["lock_state"].ToString()); sg.update = Convert.ToDateTime(ict.Table.Rows[i]["update_time"].ToString()); lock_state_list.Add(sg); } } } List <state_group> check_list1 = new List <state_group>(); for (int i = 0; i < lock_state_list.Count; i++) { if (lock_state_list[i].state == 0) { sg = new state_group(); sg.state = lock_state_list[i].state; sg.update = lock_state_list[i].update; check_list1.Add(sg); int index = i + 1; while (index < lock_state_list.Count) { if (lock_state_list[index].state == 1) { sg = new state_group(); sg.state = lock_state_list[index].state; sg.update = lock_state_list[index].update; check_list1.Add(sg); break; } index += 1; } } } //Chart1.Series.Clear(); //每次使用此function前先清除圖表 //Series series1 = new Series("use time(second)", 1200); //初始畫線條(名稱,最大值) //series1.Color = Color.Blue; //設定線條顏色 //series1.Font = new System.Drawing.Font("新細明體", 10); //設定字型 //series1.ChartType = SeriesChartType.Line; //設定線條種類 //Chart1.ChartAreas[0].AxisY.Minimum = 0;//設定Y軸最小值 //Chart1.ChartAreas[0].AxisY.Maximum = 1200;//設定Y軸最大值 ////chart1.ChartAreas[0].AxisY.Enabled= AxisEnabled.False; //隱藏Y 軸標示 ////chart1.ChartAreas[0].AxisY.MajorGrid.Enabled= true; //隱藏Y軸標線 //series1.IsValueShownAsLabel = true; //是否把數值顯示在線上 string monstr = "var MONTHS = ["; monstr += "];"; string monstt = ""; string arrva = ""; double avg = 0, coun = 0, hcou = 0, havg = 0; double compute_day = -1; DateTime first_d, second_d; for (int i = 0; i < check_list.Count; i++) { compute_day = -1; if (check_list[i].state == 1) { first_d = Convert.ToDateTime(check_list[i].update); int index = i + 1; while (index < check_list.Count) { if (check_list[index].state == 0) { second_d = Convert.ToDateTime(check_list[index].update); compute_day = (second_d - first_d).TotalSeconds; break; } index += 1; } if (compute_day > -1) { //monstt+=check_list[i].update.ToString("yyyyMMddHHmmss")+","; //arrva +=compute_day+ ","; if (compute_day < 1801) { coun += 1; avg += compute_day; monstt += check_list[i].update.ToString("yyyyMMddHHmmss") + ","; arrva += compute_day + ","; } if (compute_day >= Convert.ToInt32(param7) && compute_day < 1801) { hcou += 1; havg += compute_day; } //series1.Points.AddXY(i.ToString(), compute_day); //listBox3.Items.Add("Start time: " + check_list[i].update.ToString("yyyy-MM-dd HH:mm:ss") + " ~"); //listBox3.Items.Add("End time: " + check_list[index].update.ToString("yyyy-MM-dd HH:mm:ss")); //listBox3.Items.Add("Total sec: " + compute_day); } else { //DateTime todate = DateTime.Now; //double compute_day1 = (todate - first_d).TotalSeconds; //listBox3.Items.Add("Start time: " + check_list[i].update.ToString("yyyy-MM-dd HH:mm:ss") + " ~"); //listBox3.Items.Add("End time: NO"); //listBox3.Items.Add("Total sec: NO"); } } } if (monstt != "") { monstt = monstt.Substring(0, monstt.Length - 1); } if (arrva != "") { arrva = arrva.Substring(0, arrva.Length - 1); } //Chart1.Series.Add(series1);//將線畫在圖上 //for (int i = 0; i < check_list.Count; i++) //{ // listBox1.Items.Add(check_list[i].state); // listBox2.Items.Add(check_list[i].update.ToString("yyyy-MM-dd HH:mm:ss")); //} string res = @"<fieldset> <legend>State Time</legend><br/> <script type='text/javascript'> var config = { type: 'line', data: { labels: [" + monstt + @"], datasets: [{ label: 'Use time dataset', fill: false, backgroundColor: 'rgb(" + param3 + @", " + param4 + @", " + param5 + @")', borderColor: 'rgb(" + param3 + @", " + param4 + @", " + param5 + @")', data: [" + arrva + @" ], }] }, options: { responsive: true, title: { display: true, text: 'Use Time Line Chart' }, tooltips: { mode: 'index', intersect: false, }, hover: { mode: 'nearest', intersect: true }, scales: { xAxes: [{ display: true, scaleLabel: { display: true, labelString: 'DateTime' } }], yAxes: [{ display: true, scaleLabel: { display: true, labelString: 'Time(second)' } }] } } }; var ctx = document.getElementById('canvas').getContext('2d'); window.myLine = new Chart(ctx, config); </script> <canvas id='canvas'></canvas> <br/> <h2>Total users:</h2> <br/> <h2>" + coun.ToString() + @"</h2> <br/> <h2>AVG use time (second):</h2> <br/> <h2>" + (avg /= coun).ToString() + @"</h2> <br/> <h2>Long users(after " + param7 + @" second):</h2> <br/> <h2>" + hcou.ToString() + @"</h2> <br/> <h2>Long users AVG use time(after " + param7 + @" second)(second):</h2> <br/> <h2>" + (havg /= hcou).ToString() + @"</h2> </fieldset> "; monstr = "var MONTHS = ["; monstr += "];"; monstt = ""; arrva = ""; avg = 0; coun = 0; hcou = 0; havg = 0; compute_day = -1; for (int i = 0; i < check_list1.Count; i++) { compute_day = -1; if (check_list1[i].state == 0) { first_d = Convert.ToDateTime(check_list1[i].update); int index = i + 1; while (index < check_list1.Count) { if (check_list1[index].state == 1) { second_d = Convert.ToDateTime(check_list1[index].update); compute_day = (second_d - first_d).TotalSeconds; break; } index += 1; } if (compute_day > -1) { //monstt += check_list1[i].update.ToString("yyyyMMddHHmmss") + ","; //arrva += compute_day + ","; if (compute_day < 1801) { coun += 1; avg += compute_day; monstt += check_list1[i].update.ToString("yyyyMMddHHmmss") + ","; arrva += compute_day + ","; } if (compute_day >= Convert.ToInt32(param7) && compute_day < 1801) { hcou += 1; havg += compute_day; } //series1.Points.AddXY(i.ToString(), compute_day); //listBox3.Items.Add("Start time: " + check_list[i].update.ToString("yyyy-MM-dd HH:mm:ss") + " ~"); //listBox3.Items.Add("End time: " + check_list[index].update.ToString("yyyy-MM-dd HH:mm:ss")); //listBox3.Items.Add("Total sec: " + compute_day); } else { //DateTime todate = DateTime.Now; //double compute_day1 = (todate - first_d).TotalSeconds; //listBox3.Items.Add("Start time: " + check_list[i].update.ToString("yyyy-MM-dd HH:mm:ss") + " ~"); //listBox3.Items.Add("End time: NO"); //listBox3.Items.Add("Total sec: NO"); } } } if (monstt != "") { monstt = monstt.Substring(0, monstt.Length - 1); } if (arrva != "") { arrva = arrva.Substring(0, arrva.Length - 1); } res += @"<fieldset> <legend>Lock State Time</legend><br/> <script type='text/javascript'> var config1 = { type: 'line', data: { labels: [" + monstt + @"], datasets: [{ label: 'Lock Use time dataset', fill: false, backgroundColor: 'rgb(" + param3 + @", " + param4 + @", " + param5 + @")', borderColor: 'rgb(" + param3 + @", " + param4 + @", " + param5 + @")', data: [" + arrva + @" ], }] }, options: { responsive: true, title: { display: true, text: 'Lock Use Time Line Chart' }, tooltips: { mode: 'index', intersect: false, }, hover: { mode: 'nearest', intersect: true }, scales: { xAxes: [{ display: true, scaleLabel: { display: true, labelString: 'DateTime' } }], yAxes: [{ display: true, scaleLabel: { display: true, labelString: 'Time(second)' } }] } } }; var ctx1 = document.getElementById('canvas1').getContext('2d'); window.myLine = new Chart(ctx1, config1); </script> <canvas id='canvas1'></canvas> <br/> <h2>Total users:</h2> <br/> <h2>" + coun.ToString() + @"</h2> <br/> <h2>AVG use time (second):</h2> <br/> <h2>" + (avg /= coun).ToString() + @"</h2> <br/> <h2>Long users(after " + param7 + @" second):</h2> <br/> <h2>" + hcou.ToString() + @"</h2> <br/> <h2>Long users AVG use time(after " + param7 + @" second)(second):</h2> <br/> <h2>" + (havg /= hcou).ToString() + @"</h2> <br/> <br/> <h2>QA count:</h2> <br/> <h2>" + QAcou.ToString() + @"</h2> <br/> <h2>new QA count:</h2> <br/> <h2>" + QAcou1.ToString() + @"</h2> <br/> </fieldset> "; res += @"<fieldset><legend style='font-size: large; font-weight: bold'>QA detail</legend>"; res += @"<div id='dvData'> <table> <tr> <td>日時</td> <td>言語 (language)</td> <td>お子さまのご年齢は</td> <td>あなたは</td> <td>mamaroがどこにあったら便利? ( 複数選択可 )</td> <td>mamaroをどこで知った? ( 複数選択可 )</td> <td>mamaroに 「もっとこんな機能が欲しい。こんなのがあったら嬉しい。」というものはありますか?</td> <td>授乳室は個室派?わいわい派?</td> </tr>"; //QA detail for (int i = 0; i < QA_list.Count; i++) { res += @"<tr> <td>" + QA_list[i].answer_datetime.ToString("yyyy-MM-dd HH:mm:ss") + @"</td> <td>" + QA_list[i].lan + @"</td> <td>" + QA_list[i].baby_y + @"歳 " + QA_list[i].baby_m + @"ヶ月</td> <td>" + QA_list[i].parent + @"</td> <td>" + QA_list[i].Q2_choice.Replace(",", ".") + @"</td> <td>" + QA_list[i].Q3_choice.Replace(",", ".") + @"</td> <td>" + QA_list[i].Q4_choice.Replace(",", ".") + @"</td> <td>" + QA_list[i].Q5_choice.Replace(",", ".") + @"</td> </tr> "; } res += @"</table> </div>"; res += @"</fieldset><hr/>"; //new QA res += @"<fieldset><legend style='font-size: large; font-weight: bold'>new QA detail</legend>"; res += @"<div id='dvData_new'> <table> <tr> <td>日時</td> <td>言語 (language)</td> <td>お子さまのご年齢は</td> <td>お子さまとの関係</td> <td>mamaroのご利用は何回目ですが?</td> <td>mamaroをどのようにして知りましたか?</td> <td>mamaroの空室状況をBabymapというアプリで調べることができるのを知っていましたか?</td> <td>mamaroで" + '"' + @"気に入っているポイント" + '"' + @"を教えてください。(複数選択可)</td> <td>mamaroの満足度を教えてください。</td> </tr>"; //QA detail for (int i = 0; i < QA_list_1.Count; i++) { res += @"<tr> <td>" + QA_list_1[i].answer_datetime.ToString("yyyy-MM-dd HH:mm:ss") + @"</td> <td>" + QA_list_1[i].lan + @"</td> <td>" + QA_list_1[i].baby_y_m + @"</td> <td>" + QA_list_1[i].parent + @"</td> <td>" + QA_list_1[i].Q2_choice.Replace(",", ".") + @"</td> <td>" + QA_list_1[i].Q3_choice.Replace(",", ".") + @"</td> <td>" + QA_list_1[i].Q4_choice.Replace(",", ".") + @"</td> <td>" + QA_list_1[i].Q5_choice.Replace(",", ".") + @"</td> <td>" + QA_list_1[i].Q6_choice.Replace(",", ".") + @"</td> </tr> "; } res += @"</table> </div>"; res += @"</fieldset><hr/>"; // res += @"<script type='text/javascript'> // //</script>"; result = res; //result = "fail"; } } catch (Exception ex) { //result = "fail"; //return result; throw ex; } return(result); }
public static string check_mamaro(string param1, string param2, string param3, string param4, string param5) { //test //int comid = 26; //List<int> comlist = new List<int>(); //comlist.Add(comid); //comlist.Add(Convert.ToInt32( param6)); string[] liness = param3.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); List <string> res_list = new List <string>(); GCP_MYSQL gc = new GCP_MYSQL(); string Query = ""; int QAcou = 0; int QAcou1 = 0; string result = ""; DateTime start = Convert.ToDateTime(param1.Trim()); DateTime end = Convert.ToDateTime(param2.Trim()); if (param4 == "") { param4 = "30"; } try { if (start != null && end != null) { string label = ""; string res = ""; string res1 = ""; for (int kk = 0; kk < liness.Length; kk++) { state_group sg = new state_group(); QA_group qaa = new QA_group(); state_list = new List <state_group>(); lock_state_list = new List <state_group>(); QA_list = new List <QA_group>(); string room_id = liness[kk]; //mamaro name string mamaname = ""; Query = "select * from nursing_room where id='" + room_id + "';"; DataView ict = gc.select_cmd(Query); if (ict.Count > 0) { mamaname = ict.Table.Rows[0]["name"].ToString(); } //mamaro QA Query = "select * from nursing_room_QA where nursing_room_id='" + room_id + "' and insert_time between '" + start.ToString("yyyy-MM-dd HH:mm:ss") + "' and '" + end.ToString("yyyy-MM-dd HH:mm:ss") + "';"; ict = gc.select_cmd(Query); QAcou = ict.Count; if (ict.Count > 0) { for (int i = 0; i < ict.Count; i++) { qaa = new QA_group(); qaa.answer_datetime = Convert.ToDateTime(ict.Table.Rows[i]["insert_time"].ToString()); qaa.baby_m = ict.Table.Rows[i]["Q1_baby_month"].ToString(); qaa.baby_y = ict.Table.Rows[i]["Q1_baby_year"].ToString(); qaa.lan = ict.Table.Rows[i]["language"].ToString(); qaa.parent = ict.Table.Rows[i]["Q1_parent"].ToString(); qaa.Q2_choice = ict.Table.Rows[i]["Q2_choice"].ToString(); qaa.Q3_choice = ict.Table.Rows[i]["Q3_choice"].ToString(); qaa.Q4_choice = ict.Table.Rows[i]["Q4_choice"].ToString(); qaa.Q5_choice = ict.Table.Rows[i]["Q5_choice"].ToString(); QA_list.Add(qaa); } } QA_group_1 qaa_1 = new QA_group_1(); QA_list_1 = new List <QA_group_1>(); //mamaro new QA Query = "select * from nursing_room_QA1 where nursing_room_id='" + room_id + "' and insert_time between '" + start.ToString("yyyy-MM-dd HH:mm:ss") + "' and '" + end.ToString("yyyy-MM-dd HH:mm:ss") + "';"; ict = gc.select_cmd(Query); QAcou1 = ict.Count; if (ict.Count > 0) { for (int i = 0; i < ict.Count; i++) { qaa_1 = new QA_group_1(); qaa_1.answer_datetime = Convert.ToDateTime(ict.Table.Rows[i]["insert_time"].ToString()); qaa_1.baby_y_m = ict.Table.Rows[i]["Q1_baby_year_month"].ToString(); qaa_1.lan = ict.Table.Rows[i]["language"].ToString(); qaa_1.parent = ict.Table.Rows[i]["Q1_parent"].ToString(); qaa_1.Q2_choice = ict.Table.Rows[i]["Q2_choice"].ToString(); qaa_1.Q3_choice = ict.Table.Rows[i]["Q3_choice"].ToString(); qaa_1.Q4_choice = ict.Table.Rows[i]["Q4_choice"].ToString(); qaa_1.Q5_choice = ict.Table.Rows[i]["Q5_choice"].ToString(); qaa_1.Q6_choice = ict.Table.Rows[i]["Q6_choice"].ToString(); QA_list_1.Add(qaa_1); } } //lock state time Query = "select * from nursing_room_lock_state_time where nursing_room_id='" + room_id + "' and update_time between '" + start.ToString("yyyy-MM-dd HH:mm:ss") + "' and '" + end.ToString("yyyy-MM-dd HH:mm:ss") + "' order by update_time asc;;"; ict = gc.select_cmd(Query); if (ict.Count > 0) { if (room_id == "9") { for (int i = 0; i < ict.Count; i++) { sg = new state_group(); if (Convert.ToDateTime(ict.Table.Rows[i]["update_time"].ToString()).Year <= 2017 && Convert.ToDateTime(ict.Table.Rows[i]["update_time"].ToString()).Month <= 11 && Convert.ToDateTime(ict.Table.Rows[i]["update_time"].ToString()).Day <= 26) { if (Convert.ToInt32(ict.Table.Rows[i]["lock_state"].ToString()) == 0) { sg.state = 1; } else { sg.state = 0; } } else { sg.state = Convert.ToInt32(ict.Table.Rows[i]["lock_state"].ToString()); } sg.update = Convert.ToDateTime(ict.Table.Rows[i]["update_time"].ToString()); lock_state_list.Add(sg); } } else { for (int i = 0; i < ict.Count; i++) { sg = new state_group(); sg.state = Convert.ToInt32(ict.Table.Rows[i]["lock_state"].ToString()); sg.update = Convert.ToDateTime(ict.Table.Rows[i]["update_time"].ToString()); lock_state_list.Add(sg); } } } List <state_group> check_list1 = new List <state_group>(); for (int i = 0; i < lock_state_list.Count; i++) { if (lock_state_list[i].state == 0) { sg = new state_group(); sg.state = lock_state_list[i].state; sg.update = lock_state_list[i].update; check_list1.Add(sg); int index = i + 1; while (index < lock_state_list.Count) { if (lock_state_list[index].state == 1) { sg = new state_group(); sg.state = lock_state_list[index].state; sg.update = lock_state_list[index].update; check_list1.Add(sg); break; } index += 1; } } } //Chart1.Series.Clear(); //每次使用此function前先清除圖表 //Series series1 = new Series("use time(second)", 1200); //初始畫線條(名稱,最大值) //series1.Color = Color.Blue; //設定線條顏色 //series1.Font = new System.Drawing.Font("新細明體", 10); //設定字型 //series1.ChartType = SeriesChartType.Line; //設定線條種類 //Chart1.ChartAreas[0].AxisY.Minimum = 0;//設定Y軸最小值 //Chart1.ChartAreas[0].AxisY.Maximum = 1200;//設定Y軸最大值 ////chart1.ChartAreas[0].AxisY.Enabled= AxisEnabled.False; //隱藏Y 軸標示 ////chart1.ChartAreas[0].AxisY.MajorGrid.Enabled= true; //隱藏Y軸標線 //series1.IsValueShownAsLabel = true; //是否把數值顯示在線上 string monstr = "var MONTHS = ["; monstr += "];"; string monstt = ""; string arrva = ""; double avg = 0, coun = 0, hcou = 0, havg = 0; double compute_day = -1; DateTime first_d, second_d; List <int> count_list = new List <int>(); usercou_list = new List <user_group>(); user_group ug = new user_group(); int basesec = Convert.ToInt32(param4); int coun_start = 0; int coun_end = basesec; int couuuu = 0; //Chart1.Series.Add(series1);//將線畫在圖上 //for (int i = 0; i < check_list.Count; i++) //{ // listBox1.Items.Add(check_list[i].state); // listBox2.Items.Add(check_list[i].update.ToString("yyyy-MM-dd HH:mm:ss")); //} Random rnd = new Random(Guid.NewGuid().GetHashCode()); int r = rnd.Next(256); rnd = new Random(Guid.NewGuid().GetHashCode()); int g = rnd.Next(256); rnd = new Random(Guid.NewGuid().GetHashCode()); int b = rnd.Next(256); monstr = "var MONTHS = ["; monstr += "];"; monstt = ""; arrva = ""; avg = 0; coun = 0; hcou = 0; havg = 0; compute_day = -1; count_list = new List <int>(); for (int i = 0; i < check_list1.Count; i++) { compute_day = -1; if (check_list1[i].state == 0) { first_d = Convert.ToDateTime(check_list1[i].update); int index = i + 1; while (index < check_list1.Count) { if (check_list1[index].state == 1) { second_d = Convert.ToDateTime(check_list1[index].update); compute_day = (second_d - first_d).TotalSeconds; break; } index += 1; } if (compute_day > -1) { //monstt += check_list1[i].update.ToString("yyyyMMddHHmmss") + ","; //arrva += compute_day + ","; if (compute_day < 1801) { coun += 1; avg += compute_day; //monstt += check_list1[i].update.ToString("yyyyMMddHHmmss") + ","; //arrva += compute_day + ","; count_list.Add(Convert.ToInt32(compute_day)); } if (compute_day >= Convert.ToInt32(param4) && compute_day < 1801) { hcou += 1; havg += compute_day; } //series1.Points.AddXY(i.ToString(), compute_day); //listBox3.Items.Add("Start time: " + check_list[i].update.ToString("yyyy-MM-dd HH:mm:ss") + " ~"); //listBox3.Items.Add("End time: " + check_list[index].update.ToString("yyyy-MM-dd HH:mm:ss")); //listBox3.Items.Add("Total sec: " + compute_day); } else { //DateTime todate = DateTime.Now; //double compute_day1 = (todate - first_d).TotalSeconds; //listBox3.Items.Add("Start time: " + check_list[i].update.ToString("yyyy-MM-dd HH:mm:ss") + " ~"); //listBox3.Items.Add("End time: NO"); //listBox3.Items.Add("Total sec: NO"); } } } usercou_list = new List <user_group>(); ug = new user_group(); basesec = Convert.ToInt32(param4); coun_start = 0; coun_end = basesec; couuuu = 0; for (int i = 0; i < Convert.ToInt32(param5); i += basesec) { couuuu = 0; ug = new user_group(); ug.sec = i; for (int ii = 0; ii < count_list.Count; ii++) { if (count_list[ii] > i) { couuuu += 1; } //if (count_list[ii] > i && count_list[ii] < (i + basesec)) //{ // couuuu += 1; //} } ug.total = couuuu; usercou_list.Add(ug); } for (int i = 0; i < usercou_list.Count; i++) { //monstt += usercou_list[i].sec.ToString() + ","; if (usercou_list[i].sec % 60 == 0) { monstt += (usercou_list[i].sec / 60).ToString() + ","; } else { monstt += " ,"; } arrva += usercou_list[i].total.ToString() + ","; } if (monstt != "") { monstt = monstt.Substring(0, monstt.Length - 1); } if (arrva != "") { arrva = arrva.Substring(0, arrva.Length - 1); } rnd = new Random(Guid.NewGuid().GetHashCode()); r = rnd.Next(256); rnd = new Random(Guid.NewGuid().GetHashCode()); g = rnd.Next(256); rnd = new Random(Guid.NewGuid().GetHashCode()); b = rnd.Next(256); res1 += @"{ label: '" + mamaname + @"', fill: false, backgroundColor: 'rgb(" + r + @", " + g + @", " + b + @")', borderColor: 'rgb(" + r + @", " + g + @", " + b + @")', data: [" + arrva + @" ], },"; res = @"{ label: '" + mamaname + @"', fill: false, backgroundColor: 'rgb(" + r + @", " + g + @", " + b + @")', borderColor: 'rgb(" + r + @", " + g + @", " + b + @")', data: [" + arrva + @" ], },"; label = monstt; string ress = @"<fieldset> <legend>" + mamaname + @"</legend><br/> <script type='text/javascript'> var config" + kk + @" = { type: 'line', data: { labels: [" + label + @"], datasets: [" + res + @"] }, options: { responsive: true, title: { display: true, text: '" + mamaname + @"' }, tooltips: { mode: 'index', intersect: false, }, hover: { mode: 'nearest', intersect: true }, scales: { xAxes: [{ display: true, scaleLabel: { display: true, labelString: '滞在時間(分)' } }], yAxes: [{ display: true, scaleLabel: { display: true, labelString: '利用人数(人)' } }] }, animation: { onComplete: function () { var ctx = this.chart.ctx; ctx.font = Chart.helpers.fontString(Chart.defaults.global.defaultFontFamily, 'normal', Chart.defaults.global.defaultFontFamily); ctx.fillStyle = 'black'; ctx.textAlign = 'center'; ctx.textBaseline = 'bottom'; this.data.datasets.forEach(function (dataset) { for (var i = 0; i < dataset.data.length; i++) { for(var key in dataset._meta) { var model = dataset._meta[key].data[i]._model; ctx.fillText(dataset.data[i], model.x, model.y - 5); } } }); done" + kk + @"(); } } } }; var ctx" + kk + @" = document.getElementById('canvas" + kk + @"').getContext('2d'); window.myLine = new Chart(ctx" + kk + @", config" + kk + @"); function done" + kk + @"(){ var url_base64 = document.getElementById('canvas" + kk + @"').toDataURL('image/png'); link" + kk + @".href = url_base64; } </script> <canvas id='canvas" + kk + @"'></canvas> <br/> <a id='link" + kk + @"' download='" + mamaname + @".png'>Save as Image</a> <br/> </fieldset> "; res_list.Add(ress); // res += @"<script type='text/javascript'> // //</script>"; //result = res; //result = "fail"; } result = @"<fieldset> <legend>ALL mamaro</legend><br/> <script type='text/javascript'> var config = { type: 'line', data: { labels: [" + label + @"], datasets: [" + res1 + @"] }, options: { responsive: true, title: { display: true, text: 'ALL mamaro' }, tooltips: { mode: 'index', intersect: false, }, hover: { mode: 'nearest', intersect: true }, scales: { xAxes: [{ display: true, scaleLabel: { display: true, labelString: '滞在時間(分)' } }], yAxes: [{ display: true, scaleLabel: { display: true, labelString: '利用人数(人)' } }] }, animation: { onComplete: done } } }; var ctx = document.getElementById('canvas').getContext('2d'); window.myLine = new Chart(ctx, config); function done(){ var url_base64 = document.getElementById('canvas').toDataURL('image/png'); link.href = url_base64; } </script> <canvas id='canvas'></canvas> <br/> <a id='link' download='allmamaro.png'>Save as Image</a> <br/><br/> </fieldset> "; for (int hh = 0; hh < res_list.Count; hh++) { result += res_list[hh]; } } } catch (Exception ex) { //result = "fail"; //return result; throw ex; } return(result); }
public static string check_mamaro(string param1, string param2) { GCP_MYSQL gc = new GCP_MYSQL(); string Query = ""; int QAcou = 0; int QAcou1 = 0; string result = ""; DateTime start = Convert.ToDateTime(param1.Trim()); DateTime end = Convert.ToDateTime(param2.Trim()); state_detail_list = new List <state_detail>(); QA_list = new List <QA_group>(); QA_list_1 = new List <QA_group_1>(); string res = @"<br/><h2>年月日:</h2>"; res += @"<br/><h2>" + start.Year + "年" + start.Month + "月" + start.Day + "日 ~ " + end.Year + "年" + end.Month + "月" + end.Day + "日" + @"</h2><br /><br />"; try { if (start != null && end != null) { Query = "select id,name"; Query += " from nursing_room;"; DataView ict_place = gc.select_cmd(Query); if (ict_place.Count > 0) { for (int ih = 0; ih < ict_place.Count; ih++) { QA_group qaa = new QA_group(); string room_id = ict_place.Table.Rows[ih]["id"].ToString(); //mamaro QA Query = "select * from nursing_room_QA where nursing_room_id='" + room_id + "' and insert_time between '" + start.ToString("yyyy-MM-dd HH:mm:ss") + "' and '" + end.ToString("yyyy-MM-dd HH:mm:ss") + "';"; DataView ict = gc.select_cmd(Query); QAcou = ict.Count; if (ict.Count > 0) { for (int i = 0; i < ict.Count; i++) { qaa = new QA_group(); qaa.roomid = room_id; qaa.answer_datetime = Convert.ToDateTime(ict.Table.Rows[i]["insert_time"].ToString()); qaa.baby_m = ict.Table.Rows[i]["Q1_baby_month"].ToString(); qaa.baby_y = ict.Table.Rows[i]["Q1_baby_year"].ToString(); qaa.lan = ict.Table.Rows[i]["language"].ToString(); qaa.parent = ict.Table.Rows[i]["Q1_parent"].ToString(); qaa.Q2_choice = ict.Table.Rows[i]["Q2_choice"].ToString(); qaa.Q3_choice = ict.Table.Rows[i]["Q3_choice"].ToString(); qaa.Q4_choice = ict.Table.Rows[i]["Q4_choice"].ToString(); qaa.Q5_choice = ict.Table.Rows[i]["Q5_choice"].ToString(); QA_list.Add(qaa); } } QA_group_1 qaa_1 = new QA_group_1(); //mamaro new QA Query = "select * from nursing_room_QA1 where nursing_room_id='" + room_id + "' and insert_time between '" + start.ToString("yyyy-MM-dd HH:mm:ss") + "' and '" + end.ToString("yyyy-MM-dd HH:mm:ss") + "';"; ict = gc.select_cmd(Query); QAcou1 = ict.Count; if (ict.Count > 0) { for (int i = 0; i < ict.Count; i++) { qaa_1 = new QA_group_1(); qaa_1.roomid = room_id; qaa_1.answer_datetime = Convert.ToDateTime(ict.Table.Rows[i]["insert_time"].ToString()); qaa_1.baby_y_m = ict.Table.Rows[i]["Q1_baby_year_month"].ToString(); qaa_1.lan = ict.Table.Rows[i]["language"].ToString(); qaa_1.parent = ict.Table.Rows[i]["Q1_parent"].ToString(); qaa_1.Q2_choice = ict.Table.Rows[i]["Q2_choice"].ToString(); qaa_1.Q3_choice = ict.Table.Rows[i]["Q3_choice"].ToString(); qaa_1.Q4_choice = ict.Table.Rows[i]["Q4_choice"].ToString(); qaa_1.Q5_choice = ict.Table.Rows[i]["Q5_choice"].ToString(); qaa_1.Q6_choice = ict.Table.Rows[i]["Q6_choice"].ToString(); QA_list_1.Add(qaa_1); } } //result = "fail"; } } res = ""; if (QA_list.Count > 0) { res += @"<fieldset><legend style='font-size: large; font-weight: bold'>QA detail</legend>"; res += @"<div id='dvData'> <table> <tr> <td>日時</td> <td>言語 (language)</td> <td>お子さまのご年齢は</td> <td>あなたは</td> <td>mamaroがどこにあったら便利? ( 複数選択可 )</td> <td>mamaroをどこで知った? ( 複数選択可 )</td> <td>mamaroに 「もっとこんな機能が欲しい。こんなのがあったら嬉しい。」というものはありますか?</td> <td>授乳室は個室派?わいわい派?</td> <td>mamaro id</td> </tr>"; //QA detail for (int i = 0; i < QA_list.Count; i++) { res += @"<tr> <td>" + QA_list[i].answer_datetime.ToString("yyyy-MM-dd HH:mm:ss") + @"</td> <td>" + QA_list[i].lan + @"</td> <td>" + QA_list[i].baby_y + @"歳 " + QA_list[i].baby_m + @"ヶ月</td> <td>" + QA_list[i].parent + @"</td> <td>" + QA_list[i].Q2_choice.Replace(",", ".") + @"</td> <td>" + QA_list[i].Q3_choice.Replace(",", ".") + @"</td> <td>" + QA_list[i].Q4_choice.Replace(",", ".") + @"</td> <td>" + QA_list[i].Q5_choice.Replace(",", ".") + @"</td> <td>" + QA_list[i].roomid.Replace(",", ".") + @"</td> </tr> "; } res += @"</table> </div>"; res += @"</fieldset><hr/>"; } if (QA_list_1.Count > 0) { //new QA res += @"<fieldset><legend style='font-size: large; font-weight: bold'>new QA detail</legend>"; res += @"<div id='dvData_new'> <table> <tr> <td>日時</td> <td>言語 (language)</td> <td>お子さまのご年齢は</td> <td>お子さまとの関係</td> <td>mamaroのご利用は何回目ですが?</td> <td>mamaroをどのようにして知りましたか?</td> <td>mamaroの空室状況をBabymapというアプリで調べることができるのを知っていましたか?</td> <td>mamaroで" + '"' + @"気に入っているポイント" + '"' + @"を教えてください。(複数選択可)</td> <td>mamaroの満足度を教えてください。</td> <td>mamaro id</td> </tr>"; //QA detail for (int i = 0; i < QA_list_1.Count; i++) { res += @"<tr> <td>" + QA_list_1[i].answer_datetime.ToString("yyyy-MM-dd HH:mm:ss") + @"</td> <td>" + QA_list_1[i].lan + @"</td> <td>" + QA_list_1[i].baby_y_m + @"</td> <td>" + QA_list_1[i].parent + @"</td> <td>" + QA_list_1[i].Q2_choice.Replace(",", ".") + @"</td> <td>" + QA_list_1[i].Q3_choice.Replace(",", ".") + @"</td> <td>" + QA_list_1[i].Q4_choice.Replace(",", ".") + @"</td> <td>" + QA_list_1[i].Q5_choice.Replace(",", ".") + @"</td> <td>" + QA_list_1[i].Q6_choice.Replace(",", ".") + @"</td> <td>" + QA_list_1[i].roomid.Replace(",", ".") + @"</td> </tr> "; } res += @"</table> </div>"; res += @"</fieldset><hr/>"; } result += res; if (result == "") { result = "なし"; } } } catch (Exception ex) { //result = "fail"; //return result; throw ex; } return(result); }