Exemplo n.º 1
0
        /// <summary>
        /// 将上次选中的软件和平台默认存储到cookie中
        /// </summary>
        protected void SetRequestCookie(int p_softid, int plat)
        {
            Soft        soft          = GetSoft(p_softid);
            List <Soft> selectedSofts = new List <Soft>();

            selectedSofts.Add(soft);
            List <MobileOption> selectedPlatforms = new List <MobileOption>();

            selectedPlatforms.Add((MobileOption)plat);
            UtilityHelp.SetDefaultSoftsToCookie(selectedSofts, selectedPlatforms);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 验证当前选择的软件及其它参数是否在权限范围内
        /// </summary>
        /// <param name="selSoftIds">当前选择的软件列表,如果为空选择Cookie里指定的软件,否则选择有权限列表中第一个软件</param>
        /// <param name="selPlatforms">当前选择的平台列表,如果为空选择Cookie里指定的平台,否则选择有权限列表中第一个软件的第一个支持的平台</param>
        /// <param name="period"></param>
        /// <param name="beginTime"></param>
        /// <param name="endTime"></param>
        /// <param name="reportType"></param>
        protected void CheckParams(List <int> selSoftIds, List <MobileOption> selPlatforms, net91com.Stat.Core.PeriodOptions period, DateTime beginTime, DateTime endTime, ReportType reportType)
        {
            //如果用户一个产品权限都没有,则抛出无权限异常
            if (AvailableSofts.Count == 0)
            {
                throw new NotRightException();
            }
            List <int>          selectedSoftIds   = selSoftIds == null ? new List <int>() : selSoftIds;
            List <MobileOption> selectedPlatforms = selPlatforms == null ? new List <MobileOption>() : selPlatforms;

            //如果没有选择任何产品,使用Cookie指定的
            if (selectedSoftIds.Count == 0)
            {
                selectedSoftIds = UtilityHelp.GetDefaultSoftsFromCookie(out selectedPlatforms);
            }
            List <Soft> selectedSofts = (from a in AvailableSofts
                                         join b in selectedSoftIds
                                         on a.ID equals b
                                         select a).ToList();

            //如果客户端第一次请求或选择的软件都没有权限,使用第一个有权限的软件和第一个可以支持的平台
            if (selectedSofts.Count == 0)
            {
                selectedSofts.Add(AvailableSofts[0]);
            }
            if (selectedPlatforms.Count == 0)
            {
                selectedPlatforms.Add(selectedSofts[0].Platforms[0]);
            }
            //设置默认的软件和平台到Cookie
            UtilityHelp.SetDefaultSoftsToCookie(selectedSofts, selectedPlatforms);
            //设置相关属性
            SelectedSofts     = selectedSofts;
            SelectedPlatforms = selectedPlatforms;
            Period            = period;
            DateTime maxTime = UtilityService.GetInstance().GetMaxTimeCache(net91com.Stat.Core.PeriodOptions.Daily, reportType, CacheTimeOption.TenMinutes);

            EndTime   = endTime == DateTime.MinValue || endTime > maxTime ? maxTime : endTime;
            BeginTime = beginTime == DateTime.MinValue ? EndTime.AddDays(-30) : (beginTime > EndTime ? EndTime : beginTime);
            if (Period == net91com.Stat.Core.PeriodOptions.Hours && EndTime.Subtract(BeginTime).Days > 10)
            {
                BeginTime = EndTime.AddDays(-10);
            }
        }