예제 #1
0
    public void SetData(StatisticsInfo data)
    {
        Data = data;
        Data.CalcScore ();

        RefreshStatistics ();
    }
예제 #2
0
        private static StatisticsInfo CreateMultipleAnswerStatisticsInfo(RawData data, QuestionVM question, List <VariableVM> variables)
        {
            //for debug
            //data.Records.Add(new RawRecord());
            //data.Records.Add(new RawRecord());
            List <CategoryInfo> categoryInfos = CreateMultipleAnswerCategoryInfos(data, question, variables);

            if (categoryInfos.Count == 0)
            {
                return(null);
            }
            int rowCount      = data.Records.Count;
            int emptyRowCount = CalcEmptyRowCount(data, variables);
            int validRowCount = rowCount - emptyRowCount;

            CalcMultiAnswerPercent(categoryInfos, validRowCount, rowCount);

            StatisticsInfo statisticsInfo = new StatisticsInfo();

            statisticsInfo.Scale                    = question.Response.Scale;
            statisticsInfo.QuestionId               = question.Id;
            statisticsInfo.StatisticsType           = StatisticsTypes.ChoicesMultipleAnswer;
            statisticsInfo.CategoryInfos            = categoryInfos;
            statisticsInfo.SummaryInfo.ValidCases   = validRowCount;
            statisticsInfo.SummaryInfo.InvalidCases = emptyRowCount;
            return(statisticsInfo);
        }
        public void ChangeTo(StatisticsInfo info)
        {
            Bps.SuspendUpdate();
            Pps.SuspendUpdate();

            Bps.Add(Tuple.Create(startTime, info.Bps));
            Pps.Add(Tuple.Create(startTime, info.Pps));
            startTime++;

            if (Bps.Count > MaxPoints)
            {
                Bps.RemoveAt(0);
                Pps.RemoveAt(0);
            }

            Bps.ResumeUpdate();
            Pps.ResumeUpdate();

            foreach (var key in info.TransportLayer.Keys)
            {
                TransportLayer.UpdateOrAdd(key, info.TransportLayer[key]);
            }
            foreach (var key in info.ApplicationLayer.Keys)
            {
                ApplicationLayer.UpdateOrAdd(key, info.ApplicationLayer[key]);
            }
            foreach (var key in info.NetworkLayer.Keys)
            {
                NetworkLayer.UpdateOrAdd(key, info.NetworkLayer[key]);
            }
        }
예제 #4
0
 private void BindStatistics(StatisticsInfo statistics)
 {
     ManagerHelper.GetCurrentManager();
     if (statistics.OrderNumbWaitConsignment > 0)
     {
         this.ltrWaitSendOrdersNumber.NavigateUrl = "javascript:ShowSecondMenuLeft('微订单','sales/manageorder.aspx','" + Globals.ApplicationPath + "/Admin/sales/ManageOrder.aspx?orderStatus=2')";
         this.ltrWaitSendOrdersNumber.Text        = statistics.OrderNumbWaitConsignment.ToString() + "条";
     }
     else
     {
         this.ltrWaitSendOrdersNumber.Text = "<font style=\"color:#2d2d2d\">0条</font>";
     }
     if (statistics.GroupBuyNumWaitRefund > 0)
     {
         this.WaitForRefund.NavigateUrl = "javascript:ShowSecondMenuLeft('微营销','promotion/groupbuys.aspx','" + Globals.ApplicationPath + "/Admin/promotion/groupbuys.aspx?state=5')";
         this.WaitForRefund.Text        = statistics.GroupBuyNumWaitRefund.ToString() + "个";
     }
     else
     {
         this.WaitForRefund.Text = "<font style=\"color:#2d2d2d\">0个</font>";
     }
     this.lblTodayOrderAmout.Text       = (statistics.OrderProfitToday > 0M) ? ("¥" + Globals.FormatMoney(statistics.OrderProfitToday)) : string.Empty;
     this.ltrTodayAddMemberNumber.Text  = (statistics.UserNewAddToday > 0) ? statistics.UserNewAddToday.ToString() : string.Empty;
     this.lblTodayFinishOrder.Text      = (statistics.TodayFinishOrder > 0) ? statistics.TodayFinishOrder.ToString() : string.Empty;
     this.lblYesterdayFinishOrder.Text  = (statistics.YesterdayFinishOrder > 0) ? statistics.YesterdayFinishOrder.ToString() : string.Empty;
     this.lblOrderPriceYesterDay.Text   = (statistics.OrderPriceYesterday > 0M) ? ("¥" + statistics.OrderPriceYesterday.ToString("F2")) : string.Empty;
     this.lblUserNewAddYesterToday.Text = (statistics.UserNewAddYesterToday > 0) ? (statistics.UserNewAddYesterToday.ToString() + "位") : string.Empty;
     this.lblTotalMembers.Text          = (statistics.TotalMembers > 0) ? (statistics.TotalMembers.ToString() + "位") : string.Empty;
     this.lblTotalProducts.Text         = (statistics.TotalProducts > 0) ? (statistics.TotalProducts.ToString() + "条") : string.Empty;
     this.lblOrderPriceMonth.Text       = (statistics.OrderPriceMonth > 0M) ? ("¥" + statistics.OrderPriceMonth.ToString("F2")) : string.Empty;
 }
        private void ReadStatistics(object sender, EventArgs e)
        {
            double tbps = 0;
            double tpps = 0;
            int    cnt  = 0;

            foreach (var des in Ssource.MonitoringList)
            {
                var            devName = des.Name;
                StatisticsInfo info    = Ssource.Statistics[devName];
                helpers[devName].ChangeTo(info);

                tbps += info.Bps;
                tpps += info.Pps;
                cnt++;
            }
            AdjustChart();

            tbps /= cnt;
            tpps /= cnt;

            TotalBPS = tbps;
            TotalPPS = tpps;
            Window.FormatBpsSpeed(tbps);
            Window.FormatPpsSpeed(tpps);
        }
예제 #6
0
        protected void CheckStatistics()
        {
            StatisticsInfo s      = StatisticsService.GetStatistics();
            bool           update = false;

            int totalPosts = PostService.GetPostCount(-1, -1, -1, (int)PostStatus.Published, 0);

            if (totalPosts != s.PostCount)
            {
                s.PostCount = totalPosts;
                update      = true;
            }

            int totalComments = CommentService.GetCommentCount(true);

            if (totalComments != s.CommentCount)
            {
                s.CommentCount = totalComments;
                update         = true;
            }
            int totalTags = TagService.GetTagList().Count;

            if (totalTags != s.TagCount)
            {
                s.TagCount = totalTags;
                update     = true;
            }
            if (update == true)
            {
                StatisticsService.UpdateStatistics();
            }
        }
예제 #7
0
        public StatisticsInfo GetStatistics()
        {
            DbCommand      sqlStringCommand = this.database.GetSqlStringCommand("SELECT  (SELECT COUNT(OrderId) FROM Hishop_Orders WHERE OrderStatus = 2 OR (OrderStatus = 1 AND Gateway = 'hishop.plugins.payment.podrequest')) AS orderNumbWaitConsignment, (select count(GroupBuyId) from Hishop_GroupBuy where Status = 5) as groupBuyNumWaitRefund,  isnull((select sum(OrderTotal)-isnull(sum(RefundAmount),0) from hishop_orders where (OrderStatus<>1 AND OrderStatus<>4 AND OrderStatus<>9)   and OrderDate>='" + DataHelper.GetSafeDateTimeFormat(DateTime.Now.Date) + "'),0) as orderPriceToday, isnull((select sum(OrderProfit) from Hishop_Orders where  (OrderStatus<>1 AND OrderStatus<>4 AND OrderStatus<>9)  and OrderDate>='" + DataHelper.GetSafeDateTimeFormat(DateTime.Now.Date) + "'),0) as orderProfitToday, (select count(*) from aspnet_Members where CreateDate>='" + DataHelper.GetSafeDateTimeFormat(DateTime.Now.Date) + "' ) as userNewAddToday,(select count(*) from Hishop_Orders where datediff(dd,getdate(),OrderDate)=0 and (OrderStatus<>1 AND OrderStatus<>4 AND OrderStatus<>9)) as todayFinishOrder,(select count(*) from Hishop_Orders where datediff(dd,getdate()-1,OrderDate)=0 and (OrderStatus<>1 AND OrderStatus<>4 AND OrderStatus<>9)) as yesterdayFinishOrder, isnull((select sum(OrderTotal)-isnull(sum(RefundAmount),0) from hishop_orders where (OrderStatus<>1 AND OrderStatus<>4 AND OrderStatus<>9)   and datediff(dd,getdate()-1,OrderDate)=0),0) as orderPriceYesterDay,(select count(*) from aspnet_Members where datediff(dd,getdate()-1,CreateDate)=0) as userNewAddYesterToday,(select count(*) from aspnet_Members) as TotalMembers,(select count(*) from Hishop_Products where SaleStatus!=0) as TotalProducts,(select count(*) from aspnet_Members where datediff(dd,getdate(),VipCardDate)=0 and VipCardNumber IS NOT NULL) as TodayVipCardNumber,(select count(*) from aspnet_Members where datediff(dd,getdate()-1,VipCardDate)=0 and VipCardNumber IS NOT NULL) as YesterTodayVipCardNumber, isnull((select sum(OrderTotal)-isnull(sum(RefundAmount),0) from hishop_orders where (OrderStatus<>1 AND OrderStatus<>4 AND OrderStatus<>9)   and datediff(dd,OrderDate,getdate())<=30),0) as orderPriceMonth");
            StatisticsInfo info             = new StatisticsInfo();

            using (IDataReader reader = this.database.ExecuteReader(sqlStringCommand))
            {
                if (reader.Read())
                {
                    info.OrderNumbWaitConsignment = (int)reader["orderNumbWaitConsignment"];
                    info.OrderPriceToday          = (decimal)reader["orderProfitToday"];
                    info.OrderProfitToday         = (decimal)reader["orderPriceToday"];
                    info.UserNewAddToday          = (int)reader["userNewAddToday"];
                    info.TodayFinishOrder         = (int)reader["todayFinishOrder"];
                    info.YesterdayFinishOrder     = (int)reader["yesterdayFinishOrder"];
                    info.UserNewAddYesterToday    = (int)reader["userNewAddYesterToday"];
                    info.TotalMembers             = (int)reader["TotalMembers"];
                    info.TotalProducts            = (int)reader["TotalProducts"];
                    info.TodayVipCardNumber       = (int)reader["TodayVipCardNumber"];
                    info.YesterTodayVipCardNumber = (int)reader["YesterTodayVipCardNumber"];
                    info.OrderPriceMonth          = (decimal)reader["OrderPriceMonth"];
                    info.GroupBuyNumWaitRefund    = (int)reader["groupBuyNumWaitRefund"];
                    info.OrderPriceYesterday      = (decimal)reader["orderPriceYesterDay"];
                }
            }
            return(info);
        }
예제 #8
0
        public static CategoryInfoCollection[] Create(StatisticsInfo statisticsInfo)
        {
            CategoryInfoCollection totalCollection = new CategoryInfoCollection()
            {
                Scale = statisticsInfo.Scale
            };
            CategoryInfoCollection normalCollection = new CategoryInfoCollection()
            {
                Scale = statisticsInfo.Scale
            };
            CategoryInfoCollection missingCollection = new CategoryInfoCollection()
            {
                Scale = statisticsInfo.Scale
            };

            foreach (CategoryInfo categoryInfo in statisticsInfo.CategoryInfos)
            {
                if (categoryInfo.IsTypeNormalValue)
                {
                    normalCollection.Add(categoryInfo);
                }
                else if (categoryInfo.IsTypeMissingValue)
                {
                    missingCollection.Add(categoryInfo);
                }
                totalCollection.Add(categoryInfo);
            }
            return(new CategoryInfoCollection[] { totalCollection, normalCollection, missingCollection });
        }
예제 #9
0
        public static StatisticsInfo CreateDummyChoicesMultiAnswerStatisticsInfo(CodebookVariable codebookVariable)
        {
            Debug.Assert(codebookVariable.IsTypeChoicesMultipleAnswer);
            Debug.Assert(codebookVariable.Question != null);

            QuestionVM question = codebookVariable.Question;
            ObservableCollection <CodeVM> codes     = question.Response.Codes;
            List <VariableVM>             variables = codebookVariable.Variables;

            List <CategoryInfo> categoryInfos = new List <CategoryInfo>();

            for (int i = 0; i < variables.Count; i++)
            {
                if (i >= codes.Count)
                {
                    break;
                }
                VariableVM variable = variables[i];
                CodeVM     code     = codes[i];

                CategoryInfo categoryInfo = new CategoryInfo();
                categoryInfo.VariableTitle = variable.Title;
                categoryInfo.CodeValue     = code.Value;
                categoryInfo.CategoryTitle = code.Label;
                categoryInfos.Add(categoryInfo);
            }

            StatisticsInfo statisticsInfo = new StatisticsInfo();

            statisticsInfo.QuestionId     = question.Id;
            statisticsInfo.StatisticsType = StatisticsTypes.ChoicesMultipleAnswer;
            statisticsInfo.CategoryInfos  = categoryInfos;
            return(statisticsInfo);
        }
예제 #10
0
파일: Main.cs 프로젝트: wuchao288/wexin
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!base.IsPostBack)
     {
         StatisticsInfo statistics = SalesHelper.GetStatistics();
         this.BindStatistics(statistics);
     }
 }
예제 #11
0
        private void UpdateQueryStatisticsInfo()
        {
            QueryStatistics statistics    = Builder.QueryStatistics;
            StringBuilder   stringBuilder = new StringBuilder();

            StatisticsInfo.DumpQueryStatisticsInfo(stringBuilder, statistics);

            tbStatistics.Text = stringBuilder.ToString();
        }
 public void BuildStatisticsTest_Count()
 {
     StatisticsInfo filter = new StatisticsInfo()
     {
         TableName          = "UserInfo",
         StatisticsRelation = StatisticsRelationEnum.Count
     };
     string sql = _provider.BuildStatistics(filter);
 }
예제 #13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!base.IsPostBack)
     {
         base.Response.Redirect("index/default.aspx");
         base.Response.End();
         StatisticsInfo statistics = SalesHelper.GetStatistics();
         this.BindStatistics(statistics);
     }
 }
 public void BuildStatisticsTest_Max()
 {
     StatisticsInfo filter = new StatisticsInfo()
     {
         FieldName          = "UserId",
         TableName          = "UserInfo",
         StatisticsRelation = StatisticsRelationEnum.Max
     };
     string sql = _provider.BuildStatistics(filter);
 }
예제 #15
0
        public bool UpdateStatistics(StatisticsInfo statistics)
        {
            string cmdText =string.Format( "update [{0}sites] set PostCount=@PostCount,CommentCount=@CommentCount,VisitCount=@VisitCount,TagCount=@TagCount",ConfigHelper.Tableprefix);
            OleDbParameter[] prams = {
                                            OleDbHelper.MakeInParam("@PostCount", OleDbType.Integer,4,statistics.PostCount),
                                            OleDbHelper.MakeInParam("@CommentCount", OleDbType.Integer,4,statistics.CommentCount),
                                            OleDbHelper.MakeInParam("@VisitCount", OleDbType.Integer,4,statistics.VisitCount),
                                            OleDbHelper.MakeInParam("@TagCount", OleDbType.Integer,4,statistics.TagCount),
                                        };

            return OleDbHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams) == 1;
        }
        public void BuildWhereWithOrderTest()
        {
            //筛选出用户Id大于平均值的,并且密保问题不为空的用户
            StatisticsInfo statisticsFilter = new StatisticsInfo()
            {
                TableName          = "UserInfo",
                FieldName          = "UserId",
                StatisticsRelation = StatisticsRelationEnum.Avg
            };

            string avgSql = _provider.BuildStatistics(statisticsFilter);

            var normalList = new List <NormalFilterInfo>()
            {
                new NormalFilterInfo()
                {
                    FieldName           = "UserId",
                    FieldType           = FieldTypeEnum.Number,
                    ConnectRelation     = ConnectRelationEnum.And,
                    NormalWhereRelation = NormalWhereRelationEnum.MoreThan,
                    WhereValue          = avgSql
                },
                new NormalFilterInfo()
                {
                    FieldName           = "PwdQuestion",
                    FieldType           = FieldTypeEnum.Text,
                    ConnectRelation     = ConnectRelationEnum.And,
                    NormalWhereRelation = NormalWhereRelationEnum.IsNotNull,
                }
            };

            List <OrderInfo> orderList = new List <OrderInfo>()
            {
                new OrderInfo()
                {
                    FieldName = "UserId",
                    OrderMode = OrderModeEnum.Asc
                },
                new OrderInfo()
                {
                    FieldName = "Email",
                    OrderMode = OrderModeEnum.Desc
                },
            };

            FilterInfo filterInfo = new FilterInfo();

            filterInfo.NormalFilterInfoList = normalList;
            filterInfo.OrderInfoList        = orderList;


            string sql = _provider.BuildWhere(filterInfo);
        }
예제 #17
0
 /// <summary>
 /// 初始化
 /// </summary>
 private static void LoadStatistics()
 {
     if (_statistics == null)
     {
         lock (lockHelper)
         {
             if (_statistics == null)
             {
                 _statistics = dao.GetStatistics();
             }
         }
     }
 }
예제 #18
0
 /// <summary>
 /// 初始化
 /// </summary>
 private static void LoadStatistics()
 {
     if (_statistics == null)
     {
         lock (lockHelper)
         {
             if (_statistics == null)
             {
                 _statistics = DatabaseProvider.Instance.GetStatistics();
             }
         }
     }
 }
예제 #19
0
        public bool UpdateStatistics(StatisticsInfo statistics)
        {
            string cmdText = string.Format("update [{0}sites] set PostCount=@PostCount,CommentCount=@CommentCount,VisitCount=@VisitCount,TagCount=@TagCount", ConfigHelper.Tableprefix);

            OleDbParameter[] prams =
            {
                OleDbHelper.MakeInParam("@PostCount",    OleDbType.Integer, 4, statistics.PostCount),
                OleDbHelper.MakeInParam("@CommentCount", OleDbType.Integer, 4, statistics.CommentCount),
                OleDbHelper.MakeInParam("@VisitCount",   OleDbType.Integer, 4, statistics.VisitCount),
                OleDbHelper.MakeInParam("@TagCount",     OleDbType.Integer, 4, statistics.TagCount),
            };

            return(OleDbHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams) == 1);
        }
예제 #20
0
        /// <summary>
        /// 更新统计数据
        /// </summary>
        /// <param name="statistics"></param>
        /// <returns></returns>
        public bool UpdateStatistics(StatisticsInfo statistics)
        {
            string cmdText = string.Format("update [{0}sites] set PostCount=@PostCount,CommentCount=@CommentCount,VisitCount=@VisitCount,TagCount=@TagCount", ConfigHelper.Tableprefix);

            using (var conn = new DapperHelper().OpenConnection())
            {
                return(conn.Execute(cmdText, new
                {
                    PostCount = statistics.PostCount,
                    CommentCount = statistics.CommentCount,
                    VisitCount = statistics.VisitCount,
                    TagCount = statistics.TagCount
                }) > 0);
            }
        }
예제 #21
0
        public static ObservableCollection <StatisticsInfoRowVM> CreateNumberRows(StatisticsInfo statisticsInfo)
        {
            ObservableCollection <StatisticsInfoRowVM> rows = new ObservableCollection <StatisticsInfoRowVM>();
            SummaryInfo summaryInfo = statisticsInfo.SummaryInfo;

            rows.Add(CreateNumberRow(Resources.ValidFrequency, summaryInfo.ValidCasesString));
            rows.Add(CreateNumberRow(Resources.InvalidFrequency, summaryInfo.InvalidCasesString));
            rows.Add(CreateNumberRow(Resources.SampleFrequency, summaryInfo.TotalCasesString));
            rows.Add(CreateNumberRow(Resources.Mean, summaryInfo.MeanString));
            rows.Add(CreateNumberRow(Resources.Median, summaryInfo.MedianString));
            rows.Add(CreateNumberRow(Resources.StandardDeviation, summaryInfo.StandardDeviationString));
            rows.Add(CreateNumberRow(Resources.Minimum, summaryInfo.MinimumString));
            rows.Add(CreateNumberRow(Resources.Maximum, summaryInfo.MaximumString));
            return(rows);
        }
예제 #22
0
 private void BindBusinessInformation(StatisticsInfo statisticsInfo)
 {
     this.ltrWaitSendOrdersNumber.Text = statisticsInfo.OrderNumbWaitConsignment.ToString();
     this.hpkZiXun.Text                        = statisticsInfo.ProductConsultations.ToString();
     this.hpkMessages.Text                     = statisticsInfo.Messages.ToString();
     this.hpkLiuYan.Text                       = statisticsInfo.LeaveComments.ToString();
     this.lblTodayOrderAmout.Text              = Globals.FormatMoney(statisticsInfo.OrderPriceToday);
     this.lblTodaySalesProfile.Text            = Globals.FormatMoney(statisticsInfo.OrderProfitToday);
     this.ltrTodayAddMemberNumber.Text         = statisticsInfo.UserNewAddToday.ToString();
     this.lblMembersBalanceTotal.Text          = Globals.FormatMoney(statisticsInfo.Balance);
     this.lblProductCountTotal.Text            = (statisticsInfo.ProductAlert > 0) ? ("<a href='" + Globals.ApplicationPath + "/Shopadmin/product/myproductonsales.aspx?isAlert=True'>" + statisticsInfo.ProductAlert.ToString() + "</a>") : "0";
     this.ltrWaitSendPurchaseOrdersNumber.Text = statisticsInfo.PurchaseOrderNumbWaitConsignment.ToString();
     this.hpkLiuYan.NavigateUrl                = Globals.ApplicationPath + "/Shopadmin/comment/ManageMyLeaveComments.aspx?MessageStatus=3";
     this.hpkZiXun.NavigateUrl                 = Globals.ApplicationPath + "/Shopadmin/comment/MyProductConsultations.aspx";
     this.hpkMessages.NavigateUrl              = Globals.ApplicationPath + "/Shopadmin/comment/MyReceivedMessages.aspx?IsRead=0";
 }
예제 #23
0
        private static StatisticsInfo CreateSimpleStatisticsInfo(RawData data, VariableVM variable, Action <List <object>, StatisticsInfo> initializer)
        {
            RawVariable rawVariable = data.GetVariable(variable.Title);

            if (rawVariable == null)
            {
                return(null);
            }
            List <object>  values         = data.GetColumnValues(rawVariable.Index);
            StatisticsInfo statisticsInfo = new StatisticsInfo();

            statisticsInfo.Scale      = variable.Response.Scale;
            statisticsInfo.VariableId = variable.Id;
            initializer(values, statisticsInfo);
            return(statisticsInfo);
        }
예제 #24
0
파일: Statistics.cs 프로젝트: 89sos98/m-p-s
        /// <summary>
        /// 转换实体
        /// </summary>
        /// <param name="read">OleDbDataReader</param>
        /// <returns>TermInfo</returns>
        private static List<StatisticsInfo> DataReaderToList(OleDbDataReader read)
        {
            List<StatisticsInfo> list = new List<StatisticsInfo>();
            while (read.Read())
            {
                StatisticsInfo _site = new StatisticsInfo();

                _site.PostCount = Convert.ToInt32(read["PostCount"]);
                _site.CommentCount = Convert.ToInt32(read["CommentCount"]);
                _site.VisitCount = Convert.ToInt32(read["VisitCount"]);
                _site.TagCount = Convert.ToInt32(read["TagCount"]);

                list.Add(_site);
            }
            read.Close();
            return list;
        }
예제 #25
0
    /// <summary>
    /// 更新访问次数
    /// </summary>
    protected void UpdateViewCount()
    {
        string cookie = "isview";
        int    isview = StringHelper.StrToInt(PageUtils.GetCookie(cookie), 0);

        //未访问或按刷新统计
        if (isview == 0 || SettingManager.GetSetting().SiteTotalType == 1)
        {
            StatisticsInfo stat = StatisticsManager.GetStatistics();
            stat.VisitCount += 1;
            StatisticsManager.UpdateStatistics();
        }
        //未访问
        if (isview == 0 && SettingManager.GetSetting().SiteTotalType == 2)
        {
            PageUtils.SetCookie(cookie, "1", 1440);
        }
    }
예제 #26
0
        public bool UpdateStatistics(StatisticsInfo statistics)
        {
            string cmdText = @"update Loachs_Sites set 
                                PostCount=@PostCount,
                                CommentCount=@CommentCount,
                                VisitCount=@VisitCount,
                                TagCount=@TagCount";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@PostCount",    DbType.Int32, 4, statistics.PostCount),
                SqliteHelper.MakeInParam("@CommentCount", DbType.Int32, 4, statistics.CommentCount),
                SqliteHelper.MakeInParam("@VisitCount",   DbType.Int32, 4, statistics.VisitCount),
                SqliteHelper.MakeInParam("@TagCount",     DbType.Int32, 4, statistics.TagCount),
            };

            return(SqliteHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams) == 1);
        }
예제 #27
0
        /// <summary>
        /// 转换实体
        /// </summary>
        /// <param name="read">OleDbDataReader</param>
        /// <returns>TermInfo</returns>
        private static List <StatisticsInfo> DataReaderToList(SqlDataReader read)
        {
            List <StatisticsInfo> list = new List <StatisticsInfo>();

            while (read.Read())
            {
                StatisticsInfo _site = new StatisticsInfo();

                _site.PostCount    = Convert.ToInt32(read["PostCount"]);
                _site.CommentCount = Convert.ToInt32(read["CommentCount"]);
                _site.VisitCount   = Convert.ToInt32(read["VisitCount"]);
                _site.TagCount     = Convert.ToInt32(read["TagCount"]);

                list.Add(_site);
            }
            read.Close();
            return(list);
        }
예제 #28
0
        public bool UpdateStatistics(StatisticsInfo statistics)
        {
            string cmdText = @"update [loachs_sites] set 
                                PostCount=@PostCount,
                                CommentCount=@CommentCount,
                                VisitCount=@VisitCount,
                                TagCount=@TagCount";

            SqlParameter[] prams =
            {
                MSSQLHelper.MakeInParam("@PostCount",    SqlDbType.Int, 4, statistics.PostCount),
                MSSQLHelper.MakeInParam("@CommentCount", SqlDbType.Int, 4, statistics.CommentCount),
                MSSQLHelper.MakeInParam("@VisitCount",   SqlDbType.Int, 4, statistics.VisitCount),
                MSSQLHelper.MakeInParam("@TagCount",     SqlDbType.Int, 4, statistics.TagCount),
            };

            return(MSSQLHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams) == 1);
        }
예제 #29
0
        /// <summary>
        /// 转换实体
        /// </summary>
        /// <param name="read">OleDbDataReader</param>
        /// <returns>TermInfo</returns>
        private static List<StatisticsInfo> DataReaderToListSite(OleDbDataReader read)
        {
            var list = new List<StatisticsInfo>();
            while (read.Read())
            {
                var site = new StatisticsInfo
                               {
                                   PostCount = Convert.ToInt32(read["PostCount"]),
                                   CommentCount = Convert.ToInt32(read["CommentCount"]),
                                   VisitCount = Convert.ToInt32(read["VisitCount"]),
                                   TagCount = Convert.ToInt32(read["TagCount"])
                               };

                list.Add(site);
            }
            read.Close();
            return list;
        }
예제 #30
0
 public StatisticsInfoVM(StatisticsInfo statisticsInfo)
 {
     this.statisticsInfo = statisticsInfo;
     statisticsInfo.ApplyScale();
     this.rows = new ObservableCollection <StatisticsInfoRowVM>();
     if (statisticsInfo.IsTypeNumber)
     {
         rows = CreateNumberRows(statisticsInfo);
     }
     else if (statisticsInfo.IsTypeChoicesSingleAnswer || statisticsInfo.IsTypeDateTime)
     {
         rows = CreateSingleAnswerOrDateTimeRows(statisticsInfo);
     }
     else if (statisticsInfo.IsTypeChoicesMultipleAnswer)
     {
         rows = CreateMultipleAnswerRows(statisticsInfo);
     }
 }
예제 #31
0
 public bool InsertStatistics(StatisticsInfo statisticsInfo)
 {
     using (db = dbFactory.Open())
     {
         try
         {
             var flag = db.Insert <StatisticsInfo>(statisticsInfo);
             if (flag >= 0)
             {
                 return(true);
             }
         }
         catch (Exception)
         {
         }
         return(false);
     }
 }
예제 #32
0
        public IActionResult Get()
        {
            var vmResult = new StatisticsInfo();

            vmResult.AlbumAmount = _context.Albums.Count();
            vmResult.PhotoAmount = _context.Photos.Count();

            // Top 5 albums
            var rst = (from alm in _context.AlbumPhotos
                       group alm by alm.AlbumID into almpts
                       select new
            {
                AlbumID = almpts.Key,
                PhotoCount = almpts.Count()
            }
                       into almptcnts
                       orderby almptcnts.PhotoCount descending
                       select almptcnts).Take(5);

            foreach (var relem in rst)
            {
                vmResult.PhotoAmountInTop5Album.Add(relem.AlbumID, relem.PhotoCount);
            }

            // Top 5 tags
            var rst2 = (from tag in _context.PhotoTags
                        group tag by tag.TagString into tagcnts
                        select new
            {
                TagString = tagcnts.Key,
                PhotoCount = tagcnts.Count()
            }
                        into tagstrcnts
                        orderby tagstrcnts.PhotoCount descending
                        select tagstrcnts).Take(5);

            foreach (var relem2 in rst2)
            {
                vmResult.PhotoAmountInTop5Tag.Add(relem2.TagString, relem2.PhotoCount);
            }

            return(new ObjectResult(vmResult));
        }
예제 #33
0
 protected void Page_Load(object sender, EventArgs e)
 {
     this.grdOrders.RowDataBound         += new GridViewRowEventHandler(this.grdOrders_RowDataBound);
     this.grdPurchaseOrders.RowDataBound += new GridViewRowEventHandler(this.grdPurchaseOrders_RowDataBound);
     this.btnClosePurchaseOrder.Click    += new EventHandler(this.btnClosePurchaseOrder_Click);
     if (!base.IsPostBack)
     {
         int num;
         if (int.TryParse(base.Request.QueryString["Status"], out num))
         {
             this.hidStatus.Value = num.ToString();
         }
         this.BindLabels();
         StatisticsInfo statistics = SubsiteSalesHelper.GetStatistics();
         this.BindBusinessInformation(statistics);
         this.BindPurchaseOrders();
         this.BindOrders();
     }
 }
예제 #34
0
        /// <summary>
        /// 转换实体
        /// </summary>
        /// <param name="read">OleDbDataReader</param>
        /// <returns>TermInfo</returns>
        private static List <StatisticsInfo> DataReaderToListSite(OleDbDataReader read)
        {
            var list = new List <StatisticsInfo>();

            while (read.Read())
            {
                var site = new StatisticsInfo
                {
                    PostCount    = Convert.ToInt32(read["PostCount"]),
                    CommentCount = Convert.ToInt32(read["CommentCount"]),
                    VisitCount   = Convert.ToInt32(read["VisitCount"]),
                    TagCount     = Convert.ToInt32(read["TagCount"])
                };

                list.Add(site);
            }
            read.Close();
            return(list);
        }
        //---------------------------------------------------------------------------------------//
        private StatisticsInfo[] RetrieveAll()
        {
            const string STRLOG_MethodName = "RetrieveAll";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            List<StatisticsInfo> statisticsInfoList = new List<StatisticsInfo>();

            lock (this.statisticsLock)
            {
                try
                {
                    SqlCommand sqlCommand = new SqlCommand(STRSQLCMD_RetrieveAllStatistics, this.sqlConnection);
                    sqlCommand.CommandType = CommandType.StoredProcedure;

                    try
                    {
                        this.sqlConnection.Open();

                        SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
                        while (sqlDataReader.Read() == true)
                        {
                            StatisticsInfo statisticsInfo = new StatisticsInfo();

                            //
                            // Put the data into the statistics info object
                            //
                            object sdrObject = null;
                            if ((sdrObject = sqlDataReader[STRSQL_ExperimentId]) != System.DBNull.Value)
                                statisticsInfo.experimentId = (int)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_SbName]) != System.DBNull.Value)
                                statisticsInfo.sbName = (string)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_UserGroup]) != System.DBNull.Value)
                                statisticsInfo.userGroup = (string)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_PriorityHint]) != System.DBNull.Value)
                                statisticsInfo.priorityHint = (int)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_EstimatedExecTime]) != System.DBNull.Value)
                                statisticsInfo.estimatedExecTime = (int)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_TimeSubmitted]) != System.DBNull.Value)
                                statisticsInfo.timeSubmitted = (DateTime)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_QueueLength]) != System.DBNull.Value)
                                statisticsInfo.queueLength = (int)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_EstimatedWaitTime]) != System.DBNull.Value)
                                statisticsInfo.estimatedWaitTime = (int)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_TimeStarted]) != System.DBNull.Value)
                                statisticsInfo.timeStarted = (DateTime)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_UnitId]) != System.DBNull.Value)
                                statisticsInfo.unitId = (int)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_TimeCompleted]) != System.DBNull.Value)
                                statisticsInfo.timeCompleted = (DateTime)sdrObject;
                            if ((sdrObject = sqlDataReader[STRSQL_Cancelled]) != System.DBNull.Value)
                                statisticsInfo.cancelled = (bool)sdrObject;

                            //
                            // Calculate the actual execution time
                            //
                            if (statisticsInfo.timeStarted != DateTime.MinValue)
                            {
                                TimeSpan timeSpan = statisticsInfo.timeCompleted - statisticsInfo.timeStarted;
                                statisticsInfo.actualExecTime = (int)timeSpan.TotalSeconds;
                            }

                            //
                            // Add the statistics info to the list
                            //
                            statisticsInfoList.Add(statisticsInfo);
                        }
                        sqlDataReader.Close();
                    }
                    catch (SqlException ex)
                    {
                        throw new Exception(STRERR_SqlException + ex.Message);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(STRERR_Exception + ex.Message);
                    }
                    finally
                    {
                        this.sqlConnection.Close();
                    }
                }
                catch (Exception ex)
                {
                    Logfile.WriteError(ex.Message);
                }
            }

            string logMessage = STRLOG_count + statisticsInfoList.Count.ToString();

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName, logMessage);

            return statisticsInfoList.ToArray();
        }
        //---------------------------------------------------------------------------------------//
        private string ConvertToXml(StatisticsInfo[] statisticsInfoArray)
        {
            const string STRLOG_MethodName = "ConvertToXml";

            Logfile.WriteCalled(STRLOG_ClassName, STRLOG_MethodName);

            //
            // Catch all exceptions thrown and return an empty string if an error occurred
            //
            XmlDocument xmlDocument = null;
            string xmlExperimentStatistics = string.Empty;
            try
            {
                //
                // Check that the experiment info array exists
                //
                if (statisticsInfoArray == null)
                {
                    throw new ArgumentNullException(STRERR_StatisticsInfoArrayIsNull);
                }

                //
                // Take the experiment info and put into the XML document
                //
                for (int i = 0; i < statisticsInfoArray.GetLength(0); i++)
                {
                    StatisticsInfo statisticsInfo = statisticsInfoArray[i];

                    // Load experiment statistics XML template string
                    XmlDocument xmlTemplateDocument = XmlUtilities.GetXmlDocument(STRXMLDOC_XmlTemplate);

                    //
                    // Fill in the XML template with values from the experiment statistics information
                    //
                    XmlNode xmlRootNode = XmlUtilities.GetXmlRootNode(xmlTemplateDocument, STRXML_statistics);
                    XmlNode xmlNode = XmlUtilities.GetXmlNode(xmlRootNode, STRXML_experiment);
                    XmlUtilities.SetXmlValue(xmlNode, STRXML_experimentId, statisticsInfo.experimentId);
                    XmlUtilities.SetXmlValue(xmlNode, STRXML_sbName, statisticsInfo.sbName, false);
                    XmlUtilities.SetXmlValue(xmlNode, STRXML_userGroup, statisticsInfo.userGroup, false);
                    XmlUtilities.SetXmlValue(xmlNode, STRXML_priorityHint, statisticsInfo.priorityHint);
                    XmlUtilities.SetXmlValue(xmlNode, STRXML_estimatedExecTime, statisticsInfo.estimatedExecTime);
                    XmlUtilities.SetXmlValue(xmlNode, STRXML_timeSubmitted, statisticsInfo.timeSubmitted.ToString(), false);
                    XmlUtilities.SetXmlValue(xmlNode, STRXML_queueLength, statisticsInfo.queueLength);
                    XmlUtilities.SetXmlValue(xmlNode, STRXML_estimatedWaitTime, statisticsInfo.estimatedWaitTime);
                    XmlUtilities.SetXmlValue(xmlNode, STRXML_cancelled, statisticsInfo.cancelled);

                    //
                    // Check if experiment has started before filling in these
                    //
                    if (statisticsInfo.timeStarted > DateTime.MinValue)
                    {
                        XmlUtilities.SetXmlValue(xmlNode, STRXML_timeStarted, statisticsInfo.timeStarted.ToString(), false);
                        XmlUtilities.SetXmlValue(xmlNode, STRXML_unitId, statisticsInfo.unitId);
                        if (statisticsInfo.timeCompleted > DateTime.MinValue)
                        {
                            //
                            // Check if experiment has completed/cancelled before filling in these
                            //
                            XmlUtilities.SetXmlValue(xmlNode, STRXML_actualExecTime, statisticsInfo.actualExecTime);
                            XmlUtilities.SetXmlValue(xmlNode, STRXML_timeCompleted, statisticsInfo.timeCompleted.ToString(), false);
                        }
                    }

                    if (xmlDocument == null)
                    {
                        xmlDocument = xmlTemplateDocument;
                    }
                    else
                    {
                        //
                        // Create an XML fragment from the XML template and append to the document
                        //
                        XmlDocumentFragment xmlFragment = xmlDocument.CreateDocumentFragment();
                        xmlFragment.InnerXml = xmlNode.OuterXml;
                        xmlDocument.DocumentElement.AppendChild(xmlFragment);
                    }
                }

                //
                // Check if there were any experiment statistics
                //
                if (xmlDocument == null)
                {
                    //
                    // Remove the template content
                    //
                    xmlDocument = XmlUtilities.GetXmlDocument(STRXMLDOC_XmlTemplate);
                    XmlNode xmlRootNode = XmlUtilities.GetXmlRootNode(xmlDocument, STRXML_statistics);
                    XmlNode xmlNode = XmlUtilities.GetXmlNode(xmlRootNode, STRXML_experiment);
                    xmlRootNode.RemoveChild(xmlNode);
                }

                //
                // Convert the XML document to a string
                //
                StringWriter sw = new StringWriter();
                XmlTextWriter xtw = new XmlTextWriter(sw);
                xtw.Formatting = Formatting.Indented;
                xmlDocument.WriteTo(xtw);
                xtw.Flush();
                xmlExperimentStatistics = sw.ToString();
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
            }

            Logfile.WriteCompleted(STRLOG_ClassName, STRLOG_MethodName);

            return xmlExperimentStatistics;
        }
예제 #37
0
        /// <summary>
        /// Gets the <see cref="T:Ferda.Modules.Boxes.DataMiningCommon.Column.StatisticsInfo">statistics</see>
        /// i.e. count of distinct values, minimal result, maximal result, average result 
        /// (if result type is not cardinal average length is returned) and for cardinal values
        /// also computes variability and standard deviation.
        /// </summary>
        /// <param name="odbcConnectionString">The ODBC connection string.</param>
        /// <param name="dataMatrixName">Name of the data matrix.</param>
        /// <param name="columnSelectExpression">The column select expression.</param>
        /// <param name="columnSubType">Type of the column sub.</param>
        /// <param name="boxIdentity">The box identity.</param>
        /// <returns>
        /// <see cref="T:Ferda.Modules.Boxes.DataMiningCommon.Column.StatisticsInfo"/> 
        /// i.e. count of distinct values, minimal result, maximal result, average result 
        /// (if result type is not cardinal average length is returned) and for cardinal values
        /// also computes variability and standard deviation.
        /// </returns>
        public static StatisticsInfo GetStatistics(string odbcConnectionString, string dataMatrixName, string columnSelectExpression, ValueSubTypeEnum columnSubType, string boxIdentity)
        {
            //throws exception if odbcConnectionString is wrong
            OdbcConnection conn = Ferda.Modules.Helpers.Data.OdbcConnections.GetConnection(odbcConnectionString, boxIdentity);

            StatisticsInfo result = new StatisticsInfo();
            OdbcCommand odbcCommand = new OdbcCommand();
            odbcCommand.Connection = conn;

            bool isCardinal = false;

            try
            {
                OdbcDataAdapter myDataAdapter = new OdbcDataAdapter(
                    "SELECT DISTINCT " + SqlSecurity.ColumnQuote + columnSelectExpression + SqlSecurity.ColumnQuote + " FROM " + "`" + dataMatrixName + "`",
                    conn);
                System.Data.DataSet myDataSet = new System.Data.DataSet();
                myDataAdapter.Fill(myDataSet);
                result.ValueDistincts = Convert.ToInt64(myDataSet.Tables[0].Rows.Count);

                /* much more effective but unsupported
                 * UNDONE tohle predelat
                odbcCommand.CommandText = "SELECT COUNT(DISTINCT " + SqlSecurity.ColumnQuote + columnSelectExpression + SqlSecurity.ColumnQuote + ") FROM " + "`" + dataMatrixName + "`";
                result.ValueDistincts = Convert.ToInt64(odbcCommand.ExecuteScalar());
                 * */

                isCardinal = IsColumSubTypeCardinal(GetColumnSubTypeByDataType(GetDataType(odbcConnectionString, dataMatrixName, columnSelectExpression, boxIdentity)));
            }
            catch (Exception ex)
            {
                //throws exception if dataMatrixName or columnName is wrong
                TestColumnSelectExpression(odbcConnectionString, dataMatrixName, columnSelectExpression, boxIdentity);

                //or other reason for exception
                throw Ferda.Modules.Exceptions.BadParamsUnexpectedReasonError(ex, boxIdentity);
            }

            string selectMaxExpression = "MAX(" + SqlSecurity.ColumnQuote + columnSelectExpression + SqlSecurity.ColumnQuote + ") AS Maximum";
            string selectMinExpression = "MIN(" + SqlSecurity.ColumnQuote + columnSelectExpression + SqlSecurity.ColumnQuote + ") AS Minimum";
            string selectAvgExpression = (isCardinal)
                ? "AVG(" + SqlSecurity.ColumnQuote + columnSelectExpression + SqlSecurity.ColumnQuote + ") AS Average"
                : "AVG(LEN(" + SqlSecurity.ColumnQuote + columnSelectExpression + SqlSecurity.ColumnQuote + ")) AS Average";

            odbcCommand.CommandText = "SELECT "
                + selectMaxExpression + ","
                + selectMinExpression + ","
                + selectAvgExpression
                + " FROM " + "`" + dataMatrixName + "`";

            //System.Diagnostics.Debug.WriteLine("aggr_s:" + DateTime.Now.ToString());
            OdbcDataReader odbcDataReader = odbcCommand.ExecuteReader();
            //System.Diagnostics.Debug.WriteLine("aggr_e:" + DateTime.Now.ToString());

            if (odbcDataReader.Read())
            {
                result.ValueMax = odbcDataReader["Maximum"].ToString();
                result.ValueMin = odbcDataReader["Minimum"].ToString();
                result.ValueAverage = odbcDataReader["Average"].ToString();
            }
            odbcDataReader.Close();

            //System.Diagnostics.Debug.WriteLine("card_s:" + DateTime.Now.ToString());
            if (isCardinal)
            {
                odbcCommand.CommandText = "SELECT COUNT(1) FROM " + "`" + dataMatrixName + "`";
                long dataMatrixRowsCount = Convert.ToInt64(odbcCommand.ExecuteScalar());

                //TODO optimize this
                odbcCommand.CommandText =
                    "SELECT SUM( "
                        + "(" + SqlSecurity.ColumnQuote + columnSelectExpression + SqlSecurity.ColumnQuote + " - '" + result.ValueAverage + "')"
                        + " * (" + SqlSecurity.ColumnQuote + columnSelectExpression + SqlSecurity.ColumnQuote + " - '" + result.ValueAverage + "')"
                        + ") FROM " + "`" + dataMatrixName + "`";

                result.ValueVariability = Convert.ToDouble(odbcCommand.ExecuteScalar()) / dataMatrixRowsCount;
                result.ValueStandardDeviation = Math.Sqrt(result.ValueVariability);
            }
            //System.Diagnostics.Debug.WriteLine("card_e:" + DateTime.Now.ToString());
            return result;
        }
 public StatisticsInfo Value(string boxIdentity, DateTimeT lastReloadTime, string connectionString, string dataMatrixName, long dataMatrixRecordsCount, string columnSelectExpression, ValueSubTypeEnum columnValueSubType)
 {
     lock (this)
     {
         Dictionary<string, IComparable> cacheSetting = new Dictionary<string, IComparable>();
         cacheSetting.Add(Database.DatabaseBoxInfo.typeIdentifier + Database.DatabaseBoxInfo.OdbcConnectionStringPropertyName, connectionString);
         cacheSetting.Add(DataMatrix.DataMatrixBoxInfo.typeIdentifier + DataMatrix.DataMatrixBoxInfo.DataMatrixNamePropertyName, dataMatrixName);
         cacheSetting.Add(DataMatrix.DataMatrixBoxInfo.typeIdentifier + DataMatrix.DataMatrixBoxInfo.RecordCountPropertyName, dataMatrixRecordsCount);
         cacheSetting.Add(Column.ColumnBoxInfo.typeIdentifier + Column.ColumnBoxInfo.ColumnSelectExpressionPropertyName, columnSelectExpression);
         if (IsObsolete(lastReloadTime, cacheSetting))
         {
             value = new StatisticsInfo();
             value = Ferda.Modules.Helpers.Data.Column.GetStatistics(connectionString, dataMatrixName, columnSelectExpression, columnValueSubType, boxIdentity);
         }
         if (value == null)
             value = new StatisticsInfo();
         return value;
     }
 }