Example #1
0
        private void SetDataTableRow(DataTable dt)
        {
            Dictionary <string, string> whereDic = new Dictionary <string, string>();

            if (cmbBoxResult.SelectedIndex > 0)
            {
                if (cmbBoxResult.SelectedIndex == 1)
                {
                    whereDic.Add("Result", "1");
                }
                else if (cmbBoxResult.SelectedIndex == 2)
                {
                    whereDic.Add("Result", "0");
                }
            }
            if (cmbBoxUpload.SelectedIndex > 0)
            {
                if (cmbBoxUpload.SelectedIndex == 1)
                {
                    whereDic.Add("Upload", "1");
                }
                else if (cmbBoxUpload.SelectedIndex == 2)
                {
                    whereDic.Add("Upload", "0");
                }
            }
            FilterTime time = FilterTime.NoFilter;

            if (radioBtnDay.Checked)
            {
                time = FilterTime.Day;
            }
            else if (radioBtnWeek.Checked)
            {
                time = FilterTime.Week;
            }
            else if (radioBtnMonth.Checked)
            {
                time = FilterTime.Month;
            }
            int max = (_allQty / _pageSize) + (_allQty % _pageSize > 0 ? 1 : 0);

            UpDownPage.Maximum = max > 0 ? max : 1;
            lblAllPage.Text    = "页 / 共 " + UpDownPage.Maximum.ToString() + " 页";
            _obdTest.DbLocal.GetRecordsFilterTime(dt, whereDic, time, decimal.ToInt32(UpDownPage.Value), _pageSize);
        }
Example #2
0
        private void GetQty()
        {
            FilterTime time = FilterTime.Day;

            if (radioBtnDay.Checked)
            {
                time = FilterTime.Day;
            }
            else if (radioBtnWeek.Checked)
            {
                time = FilterTime.Week;
            }
            else if (radioBtnMonth.Checked)
            {
                time = FilterTime.Month;
            }
            Dictionary <string, string> whereDic = new Dictionary <string, string>();

            string[] columns = { "VIN" };
            object   result  = _obdTest.DbLocal.GetRecordsCount("OBDData", columns, whereDic, time);

            ShowResult(lblAllQty, result, ref _allQty);

            whereDic = new Dictionary <string, string> {
                { "Result", "1" }
            };
            result = _obdTest.DbLocal.GetRecordsCount("OBDData", columns, whereDic, time);
            ShowResult(lblPassedQty, result, ref _passedQty);
            lblPassedRate.Text = (_passedQty * 100.0 / (float)_allQty).ToString("F2") + "%";

            whereDic = new Dictionary <string, string> {
                { "Upload", "1" }
            };
            result = _obdTest.DbLocal.GetRecordsCount("OBDData", columns, whereDic, time);
            ShowResult(lblUploadedQty, result, ref _uploadedQty);
            lblUploadedRate.Text = (_uploadedQty * 100.0 / (float)_allQty).ToString("F2") + "%";
        }
Example #3
0
        /// <summary>
        /// Module拦截器执行
        /// </summary>
        /// <param name="moduleType"></param>
        /// <param name="filterType">BeforeRequestFilterAttribute、AfterRequestFilterAttribute</param>
        /// <param name="filterContext"></param>
        /// <param name="filterTime"></param>
        public static object ModuleInvoke(Type moduleType, Type filterType, NancyContext filterContext, FilterTime filterTime)
        {
            // 获取Module的拦截器标签,并执行标签的Execute方法
            var attributeList = moduleType.GetCustomAttributes(filterType, true);

            foreach (var attribute in attributeList)
            {
                var attributeType = attribute.GetType();
                var methodInfo    = attributeType.GetMethod(Execute);
                if (methodInfo != null)
                {
                    object result = methodInfo.Invoke(attribute, new object[] { filterContext, filterType, filterTime });

                    if (result != null)
                    {
                        return(result);
                    }
                }
            }
            return(null);
        }
Example #4
0
 /// <summary>
 /// ModuleFilter拦截入口点
 /// </summary>
 /// <param name="filterContext"></param>
 /// <param name="filterType"></param>
 /// <param name="filterTime"></param>
 public abstract object Execute(NancyContext filterContext, Type filterType, FilterTime filterTime);
Example #5
0
        public object GetRecordsCount(string strTable, string[] columns, Dictionary <string, string> whereDic, FilterTime time)
        {
            string strSQL = "select count(distinct ";

            foreach (string col in columns)
            {
                strSQL += col + ", ";
            }
            strSQL  = strSQL.Substring(0, strSQL.Length - 2);
            strSQL += ") from " + strTable + " where ";
            foreach (string key in whereDic.Keys)
            {
                strSQL += key + " = '" + whereDic[key] + "' and ";
            }
            string strTimeStart = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd");

            switch (time)
            {
            case FilterTime.Week:
                strTimeStart = DateTime.Now.AddDays(-6).ToLocalTime().ToString("yyyy-MM-dd");
                break;

            case FilterTime.Month:
                strTimeStart = DateTime.Now.AddDays(-29).ToLocalTime().ToString("yyyy-MM-dd");
                break;
            }
            string strTimeEnd = DateTime.Now.AddDays(1).ToLocalTime().ToString("yyyy-MM-dd");

            strSQL += "WriteTime > '" + strTimeStart + "' and WriteTime < '" + strTimeEnd + "'";
            return(QueryOne(strSQL));
        }
Example #6
0
        public void GetRecordsFilterTime(DataTable dt, Dictionary <string, string> whereDic, FilterTime time, int pageNum, int pageSize)
        {
            string strSQL    = "select distinct ";
            int    lenBefore = strSQL.Length;

            for (int i = 0; i < dt.Columns.Count; i++)
            {
                strSQL += dt.Columns[i] + ", ";
            }
            if (strSQL.Length == lenBefore)
            {
                strSQL += "*";
            }
            else
            {
                strSQL = strSQL.Substring(0, strSQL.Length - 2);
            }
            strSQL += " from " + dt.TableName + " where ";
            foreach (string key in whereDic.Keys)
            {
                strSQL += key + " = '" + whereDic[key] + "' and ";
            }
            string strTimeStart = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd");

            switch (time)
            {
            case FilterTime.Week:
                strTimeStart = DateTime.Now.AddDays(-6).ToLocalTime().ToString("yyyy-MM-dd");
                break;

            case FilterTime.Month:
                strTimeStart = DateTime.Now.AddDays(-29).ToLocalTime().ToString("yyyy-MM-dd");
                break;
            }
            string strTimeEnd = DateTime.Now.AddDays(1).ToLocalTime().ToString("yyyy-MM-dd");

            strSQL += "WriteTime > '" + strTimeStart + "' and WriteTime < '" + strTimeEnd + "' order by WriteTime ";
            if (_param.DataBaseType == DataBaseType.SQLServer)
            {
                strSQL += "offset " + ((pageNum - 1) * pageSize).ToString() + " rows fetch next " + pageSize.ToString() + " rows only";
            }
            else
            {
                strSQL += "limit " + pageSize.ToString() + " offset " + ((pageNum - 1) * pageSize).ToString();
            }
            Query(strSQL, dt);
        }