Exemplo n.º 1
0
        public static void Initialize(string path)
        {
            PagesInfo newPages = new PagesInfo();

            using (StreamReader stream = new StreamReader(path))
            {
                DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(PagesInfo), new DataContractJsonSerializerSettings()
                {
                    DateTimeFormat = new DateTimeFormat("dd.MM.yyyy")
                });
                StringBuilder needToSerialize = new StringBuilder(stream.ReadToEnd());
                for (int i = 0; i < needToSerialize.Length; ++i)
                {
                    if (needToSerialize[i] == '\\')
                    {
                        needToSerialize = needToSerialize.Insert(i, '\\');
                        ++i;
                    }
                }
                byte[]       bytes   = Encoding.UTF8.GetBytes(needToSerialize.ToString());
                MemoryStream mStream = new MemoryStream(bytes);
                newPages = (PagesInfo)ser.ReadObject(mStream);
                mStream.Dispose();
            }
            PagesInfo = newPages;
            ParseConfigurationFile();
        }
Exemplo n.º 2
0
        public async Task OnGetAsync(
            DateTime?fromDate,
            DateTime?toDate,
            Guid[] themes,
            string?filterName,
            bool?combineThemes,
            int?pageNo)
        {
            CombineThemes = combineThemes ?? false;

            Filters = new RecordsFilter
            {
                PageSize      = _pageSize,
                FromDate      = fromDate == null ? null : DateOnly.FromDateTime(fromDate.Value),
                ToDate        = toDate == null ? null : DateOnly.FromDateTime(toDate.Value),
                FilterName    = filterName?.Trim(),
                PageNo        = (pageNo ?? 1) - 1,
                CombineThemes = CombineThemes
            };

            if (themes != null && themes.Length > 0)
            {
                Filters.AddThemeId(themes);
                SelectedThemes = themes;
            }

            var recordsCount = await _searchRecordsService.GetRecordsCount(Filters);

            Pages   = PagesInfo.GetPagesInfo(recordsCount, Filters.PageNo + 1, _pageSize, 10);
            Records = await _searchRecordsService.GetRecordsList(Filters);

            AllScopes = await _scopesSvc.GetScopes();
        }
Exemplo n.º 3
0
        public async Task <ActionResult <ImagesPageDto> > GetImagesPage([FromQuery] int?pageSize, [FromQuery] int?pageNo)
        {
            try
            {
                pageSize ??= 20;
                pageNo ??= 1;
                var count = await _imagesService.GetImagesCount();

                pageSize = pageSize > 100 ? 100 : pageSize;

                var pagesInfo = PagesInfo.GetPagesInfo(count, pageNo.Value, pageSize.Value);
                var images    = await _imagesService.FetchImageSet(pagesInfo.StartIndex, pagesInfo.PageSize);

                var dto = new ImagesPageDto
                {
                    PagesInfo = pagesInfo,
                    Images    = images.Select(i => new ImageListItemDto
                    {
                        Id              = i.Id,
                        Name            = i.Name,
                        Width           = i.Width,
                        Height          = i.Height,
                        SizeKb          = i.GetSizeKbString(),
                        Base64Thumbnail = i.GetBase64Thumbnail()
                    }).ToList()
                };

                return(Ok(dto));
            }
            catch (ArgumentException exc)
            {
                return(BadRequest(exc.Message));
            }
        }
        public ActionResult GetPartOfUsers(int?page, int?count, SortInfo sort)
        {
            PagesInfo pi       = GetPagesInfo(page, count);
            SortInfo  sortInfo = GetSortInfo();

            return(PartialView(_adminBusiness.GetPageOfUsers(pi.CurrentPage, pi.CurrentCountUsersInPage, sortInfo)));
        }
Exemplo n.º 5
0
        public async Task OnGetAsync(int?pageNo)
        {
            var imagesCount = await _imagesService.GetImagesCount();

            Pager  = PagesInfo.GetPagesInfo(imagesCount, pageNo ?? 1, _pageSize);
            Images = await _imagesService.FetchImageSet(Pager.StartIndex, Pager.PageSize);
        }
        public async Task <ActionResult <RecordsPageDto> > GetRecordsList(
            [FromQuery] DateTime?from,
            [FromQuery] DateTime?to,
            [FromQuery] string?name,
            [FromQuery] bool?combinedThemes,
            [FromQuery] Guid[]?themeId,
            [FromQuery] int?pageSize,
            [FromQuery] int?pageNo)
        {
            try
            {
                pageSize ??= 20;
                pageSize = pageSize > 100 ? 100 : pageSize;
                pageNo ??= 0;

                var filters = new RecordsFilter
                {
                    CombineThemes = combinedThemes ?? false,
                    PageSize      = pageSize.Value,
                    PageNo        = pageNo.Value,
                    FromDate      = from.HasValue ? DateOnly.FromDateTime(from.Value) : null,
                    ToDate        = to.HasValue ? DateOnly.FromDateTime(to.Value) : null,
                    FilterName    = name
                };

                if (themeId != null && themeId.Length > 0)
                {
                    filters.AddThemeId(themeId);
                }

                var records = await _recordsSearchService.GetRecordsList(filters);

                int allCount = await _recordsSearchService.GetRecordsCount(filters);

                var pagesInfo = PagesInfo.GetPagesInfo(allCount, pageNo.Value, pageSize.Value);

                var dto = new RecordsPageDto
                {
                    PagesInfo = pagesInfo,
                    Records   = records.Select(r => new RecordListItemDto
                    {
                        Date          = r.Date,
                        CreatedDate   = r.CreateDate,
                        ModifiedDate  = r.ModifyDate,
                        DisplayedName = r.GetRecordNameDisplay(),
                        DisplayedText = r.GetRecordTextShort(),
                        RecordId      = r.Id
                    }).ToList()
                };

                return(Ok(dto));
            }
            catch (ArgumentException exc)
            {
                return(BadRequest(exc.Message));
            }
        }
Exemplo n.º 7
0
        public async Task <ActionResult <RecordsPageDto> > GetRecordsList(
            [FromQuery] string?searchText,
            [FromQuery] int?pageSize,
            [FromQuery] int?pageNo)
        {
            try
            {
                pageSize ??= 20;
                pageSize = pageSize > 100 ? 100 : pageSize;
                pageNo ??= 0;

                var filters = new RecordsTextFilter
                {
                    SearchText = searchText,
                    PageNo     = pageNo.Value,
                    PageSize   = pageSize.Value
                };

                var records = await _recordsSearchService.GetRecordsList(filters);

                int allCount = await _recordsSearchService.GetRecordsCount(filters.SearchText);

                var pagesInfo = PagesInfo.GetPagesInfo(allCount, pageNo.Value, pageSize.Value);

                var dto = new RecordsPageDto
                {
                    PagesInfo = pagesInfo,
                    Records   = records.Select(r => new RecordListItemDto
                    {
                        Date          = r.Date,
                        CreatedDate   = r.CreateDate,
                        ModifiedDate  = r.ModifyDate,
                        DisplayedName = r.GetRecordNameDisplay(),
                        DisplayedText = r.GetRecordTextShort(),
                        RecordId      = r.Id
                    }).ToList()
                };

                return(Ok(dto));
            }
            catch (ArgumentException exc)
            {
                return(BadRequest(exc.Message));
            }
        }
Exemplo n.º 8
0
 public Message(string id, bool isNote, bool isDeleted, bool isSent, bool isReceived, bool isArchived,
                bool isSpam, string receiverID, string senderID, int sendDate, int readDate,
                string subject, string body, bool hasAttachments, PagesInfo pagesInfo)
 {
     this.ID             = id;
     this.IsNote         = isNote;
     this.IsDeleted      = isDeleted;
     this.IsSent         = isSent;
     this.IsReceived     = isReceived;
     this.IsArchived     = isArchived;
     this.IsSpam         = isSpam;
     this.ReceiverID     = receiverID;
     this.SenderID       = senderID;
     this.SendDate       = sendDate;
     this.ReadDate       = readDate;
     this.Subject        = subject;
     this.Body           = body;
     this.HasAttachments = hasAttachments;
     this.PagesInfo      = pagesInfo;
 }
        public PagesInfo GetPagesInfo(int?page, int?count)
        {
            if (page == null)
            {
                if (HttpContext.Session["page"] != null)
                {
                    page = (int)HttpContext.Session["page"];
                }
                else
                {
                    page = 1;
                }
            }
            if (count == null)
            {
                if (HttpContext.Session["count"] != null)
                {
                    count = (int)HttpContext.Session["count"];
                }
                else
                {
                    count = new PagesInfo().CountUsers[0];
                }
            }

            int totalPages = _adminBusiness.GetTotalPages((int)count);

            if (totalPages < page)
            {
                page = totalPages;
            }

            HttpContext.Session.Add("page", page);
            HttpContext.Session.Add("count", count);

            return(new PagesInfo {
                CurrentPage = (int)page, CurrentCountUsersInPage = (int)count, TotalPages = totalPages
            });
        }
Exemplo n.º 10
0
        /// <summary>
        /// 获取监控设备列表
        /// </summary>
        /// <param name="CameraInfoList">摄像头基本信息</param>
        /// <param name="CameraGroupList">组基本信息</param>
        /// <param name="nodeRelationList">所属分组关系信息</param>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr GetAllCameras(Cgw.Common.PlatformType platformType, Common.PageParam pageParam, out List <Cgw.Common.Camera> cameraList, out List <Cgw.Common.CameraGroup> groupList, out List <Cgw.Common.NodeRelation> nodeRelationList, out PagesInfo pageInfo, Cgw.Common.PlatformLicenseInfo licenseInfo = null)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.GetAllCameras");

            cameraList       = new List <Cgw.Common.Camera>();
            groupList        = new List <Common.CameraGroup>();
            nodeRelationList = new List <Common.NodeRelation>();
            pageInfo         = new PagesInfo();

            CgwMonitorManageServiceReference.Camera[]       cameraListTemp       = null;
            CgwMonitorManageServiceReference.CameraGroup[]  groupListTemp        = null;
            CgwMonitorManageServiceReference.NodeRelation[] nodeRelationListTemp = null;
            CgwMonitorManageServiceReference.PageInfo       pagesInfoTemp        = null;

            CgwMonitorManageServiceReference.PlatformLicenseInfo info = new CgwMonitorManageServiceReference.PlatformLicenseInfo();
            if (licenseInfo != null)
            {
                info.IsEltePlatform    = licenseInfo.IsEltePlatform;
                info.IsMonitorPlatform = licenseInfo.IsMonitorPlatform;
            }

            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();

            try
            {
                //if (client.State == CommunicationState.Opened)
                if (serviceControl.MonitorServiceRun())
                {
                    CgwMonitorManageServiceReference.PlatformType platformTypeTemp = (CgwMonitorManageServiceReference.PlatformType)platformType;
                    CgwMonitorManageServiceReference.PagesParam   pageParamTemp    = new CgwMonitorManageServiceReference.PagesParam();
                    pageParamTemp.CurrentPage   = pageParam.CurrentPage;
                    pageParamTemp.NumberPerPage = pageParam.NumberPerPage;

                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.GetAllCameras(out cameraListTemp, out groupListTemp, out nodeRelationListTemp, out pagesInfoTemp, platformTypeTemp, pageParamTemp, info);
                    client.Close();

                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.GetAllCameras failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                    else
                    {
                        if (pagesInfoTemp != null)
                        {
                            pageInfo.CurrentPage  = pagesInfoTemp.CurrentPage;
                            pageInfo.TotalPages   = pagesInfoTemp.TotalPages;
                            pageInfo.TotalRecords = pagesInfoTemp.TotalRecords;
                        }

                        if (cameraListTemp != null)
                        {
                            foreach (CgwMonitorManageServiceReference.Camera ca in cameraListTemp)
                            {
                                Common.Camera temp = new Common.Camera(ca.No, ca.Name, (Common.CameraStatus)ca.Status);
                                cameraList.Add(temp);
                            }
                        }

                        if (groupListTemp != null)
                        {
                            foreach (CgwMonitorManageServiceReference.CameraGroup cg in groupListTemp)
                            {
                                Common.CameraGroup temp = new Common.CameraGroup(cg.No, cg.Name);
                                groupList.Add(temp);
                            }
                        }

                        if (nodeRelationList != null && nodeRelationListTemp != null)
                        {
                            foreach (CgwMonitorManageServiceReference.NodeRelation no in nodeRelationListTemp)
                            {
                                Common.NodeRelation temp = new Common.NodeRelation(no.No, new List <String>(no.Path), (Common.NodeType)no.Type);
                                nodeRelationList.Add(temp);
                            }
                        }

                        //增加顶层分组
                        if (string.IsNullOrEmpty(monitorPlatformCameraGroupName))
                        {
                            monitorPlatformCameraGroupName = "MonitorPlatform";
                        }
                        if (string.IsNullOrEmpty(eLTEPlatformCameraGroupName))
                        {
                            eLTEPlatformCameraGroupName = "eLTEPlatform";
                        }

                        //查询第一页数据时增加顶层分组信息
                        if (pageParam.CurrentPage == 1)
                        {
                            //if (licenseInfo != null && licenseInfo.IsEltePlatform)
                            if (licenseInfo != null)
                            {
                                groupList.Add(new Common.CameraGroup(eLTEPlatformCameraGroupName, eLTEPlatformCameraGroupName));
                            }
                            //if (licenseInfo != null && licenseInfo.IsMonitorPlatform)
                            if (licenseInfo != null)
                            {
                                groupList.Add(new Common.CameraGroup(monitorPlatformCameraGroupName, monitorPlatformCameraGroupName));
                            }
                        }

                        if (nodeRelationList.Count > 0)
                        {
                            List <Common.NodeRelation> nodeRelationTemp = new List <Common.NodeRelation>(nodeRelationList);
                            nodeRelationList.Clear();

                            foreach (Common.NodeRelation no in nodeRelationTemp)
                            {
                                List <String> path = new List <String>(no.Path);
                                if (path.Count > 1)
                                {
                                    //按照从底到顶排序
                                    path.Reverse();
                                }
                                if (no.No.IndexOf("eLTE") > -1)
                                {
                                    path.Add(eLTEPlatformCameraGroupName);
                                }
                                else
                                {
                                    path.Add(monitorPlatformCameraGroupName);
                                }

                                if (path.Count > 1)
                                {
                                    //按照从顶到底排序
                                    path.Reverse();
                                }
                                Common.NodeRelation temp = new Common.NodeRelation(no.No, path, (Common.NodeType)no.Type);
                                nodeRelationList.Add(temp);
                            }
                        }

                        if (pageParam.CurrentPage == 1)
                        {
                            //if (licenseInfo != null && licenseInfo.IsEltePlatform)
                            if (licenseInfo != null)
                            {
                                Common.NodeRelation tempELTE = new Common.NodeRelation(eLTEPlatformCameraGroupName, new List <String>(), Common.NodeType.GROUP);
                                nodeRelationList.Add(tempELTE);
                            }
                            //if (licenseInfo != null && licenseInfo.IsMonitorPlatform)
                            if (licenseInfo != null)
                            {
                                Common.NodeRelation tempMonitor = new Common.NodeRelation(monitorPlatformCameraGroupName, new List <String>(), Common.NodeType.GROUP);
                                nodeRelationList.Add(tempMonitor);
                            }
                        }
                    }
                }
                else
                {
                    err.ErrNo = Cgw.SmcError.CgwError.GET_ALL_CAMERAS_FAILED;
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.GetAllCameras failed. Exception is {0} ", ex.ToString());
            }
            return(err);
        }
Exemplo n.º 11
0
        public async Task <ActionResult <RecordsDetailPageDto> > GetRecordsListExpanded(
            [FromQuery] string?searchText,
            [FromQuery] int?pageSize,
            [FromQuery] int?pageNo)
        {
            try
            {
                pageSize ??= 20;
                pageSize = pageSize > 100 ? 100 : pageSize;
                pageNo ??= 0;

                pageSize ??= 20;
                pageSize = pageSize > 100 ? 100 : pageSize;
                pageNo ??= 0;

                var filters = new RecordsTextFilter
                {
                    SearchText = searchText,
                    PageNo     = pageNo.Value,
                    PageSize   = pageSize.Value
                };

                var records = await _recordsSearchService.GetRecordsList(filters);

                int allCount = await _recordsSearchService.GetRecordsCount(filters.SearchText);

                var pagesInfo = PagesInfo.GetPagesInfo(allCount, pageNo.Value, pageSize.Value);

                var dto = new RecordsDetailPageDto
                {
                    PagesInfo = pagesInfo,
                    Records   = records.Select(record => new RecordDto
                    {
                        Id           = record.Id,
                        Date         = record.Date,
                        CreatedDate  = record.CreateDate,
                        ModifiedDate = record.ModifyDate,
                        Name         = record.Name,
                        Text         = record.Text,
                        Cogitations  = record.Cogitations
                                       .Select(c => new CogitationDto
                        {
                            Id         = c.Id,
                            CreateDate = c.Date,
                            Text       = c.Text
                        })
                                       .ToArray(),
                        Themes = record.ThemesRefs
                                 .Select(rt => rt.Theme)
                                 .Select(t => new ThemeDto
                        {
                            ThemeId   = t !.Id,
                            ThemeName = t.ThemeName,
                            Actual    = t.Actual
                        })
                                 .ToArray(),
                        Images = record.ImagesRefs
                                 .Select(ri => ri.Image)
                                 .Select(i => new ImageListItemDto
                        {
                            Id              = i !.Id,
                            Name            = i.Name,
                            Width           = i.Width,
                            Height          = i.Height,
                            SizeKb          = i.GetSizeKbString(),
                            Base64Thumbnail = i.GetBase64Thumbnail()
                        })
Exemplo n.º 12
0
        public async Task <ActionResult <RecordsDetailPageDto> > GetRecordsListExpanded(
            [FromQuery] DateTime?from,
            [FromQuery] DateTime?to,
            [FromQuery] string?name,
            [FromQuery] bool?combinedThemes,
            [FromQuery] Guid[]?themeId,
            [FromQuery] int?pageSize,
            [FromQuery] int?pageNo)
        {
            try
            {
                pageSize ??= 20;
                pageSize = pageSize > 100 ? 100 : pageSize;
                pageNo ??= 0;

                var filters = new RecordsFilter
                {
                    CombineThemes = combinedThemes ?? false,
                    PageSize      = pageSize.Value,
                    PageNo        = pageNo.Value,
                    FromDate      = from.HasValue ? DateOnly.FromDateTime(from.Value) : null,
                    ToDate        = to.HasValue ? DateOnly.FromDateTime(to.Value) : null,
                    FilterName    = name
                };

                if (themeId != null && themeId.Length > 0)
                {
                    filters.AddThemeId(themeId);
                }

                var records = await _recordsSearchService.GetRecordsList(filters);

                int allCount = await _recordsSearchService.GetRecordsCount(filters);

                var pagesInfo = PagesInfo.GetPagesInfo(allCount, pageNo.Value, pageSize.Value);

                var dto = new RecordsDetailPageDto
                {
                    PagesInfo = pagesInfo,
                    Records   = records.Select(record => new RecordDto
                    {
                        Id           = record.Id,
                        Date         = record.Date,
                        CreatedDate  = record.CreateDate,
                        ModifiedDate = record.ModifyDate,
                        Name         = record.Name,
                        Text         = record.Text,
                        Cogitations  = record.Cogitations
                                       .Select(c => new CogitationDto
                        {
                            Id         = c.Id,
                            CreateDate = c.Date,
                            Text       = c.Text
                        })
                                       .ToArray(),
                        Themes = record.ThemesRefs
                                 .Select(rt => rt.Theme)
                                 .Select(t => new ThemeDto
                        {
                            ThemeId   = t !.Id,
                            ThemeName = t.ThemeName,
                            Actual    = t.Actual
                        })
                                 .ToArray(),
                        Images = record.ImagesRefs
                                 .Select(ri => ri.Image)
                                 .Select(i => new ImageListItemDto
                        {
                            Id              = i !.Id,
                            Name            = i.Name,
                            Width           = i.Width,
                            Height          = i.Height,
                            SizeKb          = i.GetSizeKbString(),
                            Base64Thumbnail = i.GetBase64Thumbnail()
                        })
Exemplo n.º 13
0
        /// <summary>
        /// 获取监控设备列表
        /// </summary>
        /// <param name="CameraInfoList">摄像头基本信息</param>
        /// <param name="CameraGroupList">组基本信息</param>
        /// <param name="nodeRelationList">所属分组关系信息</param>
        /// <returns></returns>
        public SmcErr QueryMonitorCamera(PlatformType platformType, PageParam pageParam, out List <Camera> cameraInfoList, out List <CameraGroup> cameraGroupList, out List <NodeRelation> nodeRelationList, out PagesInfo pagesInfo)
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            cameraInfoList   = null;
            cameraGroupList  = null;
            nodeRelationList = null;
            pagesInfo        = null;
            err = CheckSession();
            if (err.IsSuccess())
            {
                err = MonitorChannelBll.Instance().QueryMonitorCamera(platformType, pageParam, out cameraInfoList, out cameraGroupList, out nodeRelationList, out pagesInfo);
            }
            if (err.IsSuccess())
            {
                logEx.Info("SMC QueryMonitorCamera  Successful,Current SMC IP is : {0}", CgwConst.SmcIp);
            }
            else
            {
                logEx.Error("SMC QueryMonitorCamera failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }