Ejemplo n.º 1
0
        public IList <Camera> GetCamerasBy(int customerId)
        {
            List <Camera> cameraList = new List <Camera>();

            var httpServiceApi = new DataServiceApi();
            var request        = new RestRequest($"customer/videolist.json?customerId={customerId}", Method.GET);
            var cameraPartOne  = httpServiceApi.Execute <CameraPartOne>(request);

            var cameraPartTwoJson = HkAction.playList();
            var dto = JsonConvert.DeserializeObject <CameraPartTwo>(cameraPartTwoJson);

            if (dto != null)
            {
                foreach (var videoInfo in cameraPartOne.video)
                {
                    var cameraPartTwo = dto.cameras.FirstOrDefault(camera => camera.deviceSerial == videoInfo.videoSequence && camera.cameraNo.ToString() == videoInfo.videoChannel);
                    if (cameraPartTwo != null)
                    {
                        Camera camera = new Camera()
                        {
                            Id     = cameraPartTwo.cameraId,
                            Name   = videoInfo.videoName,
                            Status = cameraPartTwo.status
                        };
                        cameraList.Add(camera);
                    }
                }
            }
            return(cameraList);
        }
        public IList <TopPowerDTO> GetTopPowerSummary(string customerId, DateTime dateTime)
        {
            DataServiceApi httpServiceApi  = new DataServiceApi();
            var            request         = new RestRequest($"customer/topfive/power.json?customerId={customerId}&time={dateTime.ToString("yyyy-MM")}", Method.GET);
            var            topPowerDTOList = httpServiceApi.Execute <List <TopPowerDTO> >(request);

            return(topPowerDTOList);
        }
        public AlarmSummaryDTO GetAlarmSummary(string customerId)
        {
            DataServiceApi httpServiceApi  = new DataServiceApi();
            var            request         = new RestRequest($"customer/month/group/alarm.json?customerId={customerId}", Method.GET);
            var            alarmSummaryDTO = httpServiceApi.Execute <AlarmSummaryDTO>(request);

            return(alarmSummaryDTO);
        }
        public PowerSummaryDTO GetPowerSummary(string customerId)
        {
            DataServiceApi httpServiceApi  = new DataServiceApi();
            var            request         = new RestRequest($"customer/group/power.json?customerId={customerId}", Method.GET);
            var            powerSummaryDTO = httpServiceApi.Execute <PowerSummaryDTO>(request);

            return(powerSummaryDTO);
        }
        public TransformerCapacityDTO GetTransformerCapacity(string customerId)
        {
            DataServiceApi httpServiceApi = new DataServiceApi();
            var            request        = new RestRequest($"data/customer/apparent.json?customerId={customerId}", Method.GET);
            var            capacity       = httpServiceApi.Execute <TransformerCapacityDTO>(request);

            return(capacity);
        }
        public IEnumerable <HistoryDataDTO> GetHistoryDataList(string equipmentId, string parameterId, TimeType timeType, string date)
        {
            DataServiceApi httpServiceApi  = new DataServiceApi();
            var            request         = new RestRequest($"data/his/line.json?typeId={parameterId}&timeType={Convert.ToInt32(timeType)}&time={date}&equipmentId={equipmentId}", Method.GET);
            var            historyDataList = httpServiceApi.Execute <List <HistoryDataDTO> >(request);

            return(historyDataList);
        }
        public IList <PowerFactorDTO> GetPowerFactorInfo(string deviceId, DateTime dateTime)
        {
            DataServiceApi httpServiceApi = new DataServiceApi();
            var            request        = new RestRequest($"data/load/powerfactor/list.json?equipmentId={deviceId}&time={dateTime.ToString("yyyy-MM-dd")}", Method.GET);
            var            capacity       = httpServiceApi.Execute <List <PowerFactorDTO> >(request);

            return(capacity);
        }
Ejemplo n.º 8
0
        public IEnumerable <DeviceParameterInfoDTO> GetDeviceParameterList(string deviceId)
        {
            DataServiceApi httpServiceApi      = new DataServiceApi();
            var            request             = new RestRequest($"data/equipment/point.json?equipmentId={deviceId}", Method.GET);
            var            deviceParameterList = httpServiceApi.Execute <List <DeviceParameterInfoDTO> >(request);

            return(deviceParameterList);
        }
Ejemplo n.º 9
0
        public User AuthenticateUser(string username, string password)
        {
            DataServiceApi httpServiceApi = new DataServiceApi();
            var            request        = new RestRequest($"login.json?username={username}&password={password}", Method.GET);
            var            loginInfo      = httpServiceApi.Execute <LoginInfoDTO>(request);

            return(new User(id: loginInfo.userId.ToString(), username: username, email: "", roles: new string[] { loginInfo.userType }));
        }
        public IList <DevicePowerInfoDTO> GetDevicePowerInfo(string deviceId, DateTime dateTime)
        {
            DataServiceApi httpServiceApi      = new DataServiceApi();
            var            request             = new RestRequest($"data/equipment/power/list.json?equipmentId={deviceId}&time={dateTime.ToString("yyyy-MM")}", Method.GET);
            var            devicePowerInfoList = httpServiceApi.Execute <List <DevicePowerInfoDTO> >(request);

            return(devicePowerInfoList);
        }
Ejemplo n.º 11
0
        public IList <WiringDiagramConfigDTO> GetWiringDiagramConfig(string customerId)
        {
            DataServiceApi httpServiceApi      = new DataServiceApi();
            var            request             = new RestRequest($"customer/circuit/pic.json?customerId={customerId}", Method.GET);
            var            wiringDiagramConfig = httpServiceApi.Execute <List <WiringDiagramConfigDTO> >(request);

            return(wiringDiagramConfig);
        }
Ejemplo n.º 12
0
        public IList <CustomerIncrementsDTO> GetCustomerIncrementsInfo()
        {
            List <CustomerIncrementsDTO> customerIncrements = new List <CustomerIncrementsDTO>();

            DataServiceApi httpServiceApi = new DataServiceApi();
            var            request        = new RestRequest($"customer/statistics/count_per_month.json", Method.GET);

            customerIncrements = httpServiceApi.Execute <List <CustomerIncrementsDTO> >(request);

            return(customerIncrements);
        }
Ejemplo n.º 13
0
        public IList <InspectionStatisticsDTO> GetInspectionStatisticsInfo()
        {
            List <InspectionStatisticsDTO> inspectionStatistics = new List <InspectionStatisticsDTO>();

            DataServiceApi httpServiceApi = new DataServiceApi();
            var            request        = new RestRequest($"customer/statistics/complete_inspection_count.json?count=5", Method.GET);

            inspectionStatistics = httpServiceApi.Execute <List <InspectionStatisticsDTO> >(request);

            return(inspectionStatistics);
        }
Ejemplo n.º 14
0
        public IList <CustomerIndustryCategoryDTO> GetCustomerIndustryCategoryInfo()
        {
            List <CustomerIndustryCategoryDTO> customerIndustryCategory = new List <CustomerIndustryCategoryDTO>();

            DataServiceApi httpServiceApi = new DataServiceApi();
            var            request        = new RestRequest($"customer/statistics/type_ratio.json", Method.GET);

            customerIndustryCategory = httpServiceApi.Execute <List <CustomerIndustryCategoryDTO> >(request);

            return(customerIndustryCategory);
        }
Ejemplo n.º 15
0
        public IList <AlarmStatisticsDTO> GetAlarmStatisticsInfo()
        {
            List <AlarmStatisticsDTO> alarmStatistics = new List <AlarmStatisticsDTO>();

            DataServiceApi httpServiceApi = new DataServiceApi();
            var            request        = new RestRequest($"data/alarm_type_ratio.json", Method.GET);

            alarmStatistics = httpServiceApi.Execute <List <AlarmStatisticsDTO> >(request);

            return(alarmStatistics);
        }
        private void DeleteAlarm(object obj)
        {
            var            info           = obj as AlarmInfo;
            DataServiceApi httpServiceApi = new DataServiceApi();
            var            request        = new RestRequest($"data/eliminate/alarm.json", Method.GET);

            request.AddParameter("id", info.AlarmId);
            bool result = httpServiceApi.Execute(request);

            if (result)
            {
                AlarmList.Remove(info);
            }
        }
Ejemplo n.º 17
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var            uri         = value as string;
            DataServiceApi dataServcie = new DataServiceApi();
            var            request     = new RestRequest(uri);
            var            data        = dataServcie.Download(request);
            ImageSource    imageSource;
            var            source = new System.Windows.Media.Imaging.BitmapImage();

            source.BeginInit();
            source.StreamSource = new System.IO.MemoryStream(data.ToArray());
            source.EndInit();

            // use public setter
            return(imageSource = source);
        }
        private void DeleteAllAlarm()
        {
            DataServiceApi httpServiceApi = new DataServiceApi();
            var            alarms         = AlarmList.ToList();

            foreach (var item in alarms)
            {
                var request = new RestRequest($"data/eliminate/alarm.json", Method.GET);
                request.AddParameter("id", item.AlarmId);
                bool result = httpServiceApi.Execute(request);
                if (result)
                {
                    AlarmList.Remove(item);
                }
            }
        }
Ejemplo n.º 19
0
        public IList <Customer> GetCustomersBy(int agentId)
        {
            var httpServiceApi  = new DataServiceApi();
            var request         = new RestRequest($"customer/list.json", Method.GET);
            var customerDtoList = httpServiceApi.Execute <List <CustomerDTO> >(request);


            IList <Customer> customerList = new List <Customer>();

            foreach (var customerDto in customerDtoList)
            {
                Customer customer = new Customer()
                {
                    Id   = customerDto.customerId,
                    Name = customerDto.customerName
                };
                customerList.Add(customer);
            }

            return(customerList);
        }
Ejemplo n.º 20
0
 public CustomerEquipmentTableDTO GetCustomerEquipmentTable(string customerId)
 {
     lock (_lockObject)
     {
         CustomerEquipmentTableDTO equipmentTable = null;
         if (localCacheStoreDic.ContainsKey(customerId))
         {
             equipmentTable = localCacheStoreDic[customerId] as CustomerEquipmentTableDTO;
         }
         else
         {
             DataServiceApi httpServiceApi = new DataServiceApi();
             var            request        = new RestRequest($"customer/equipmentlist.json?customerId={customerId}", Method.GET);
             equipmentTable = httpServiceApi.Execute <CustomerEquipmentTableDTO>(request);
             if (equipmentTable != null)
             {
                 localCacheStoreDic.Add(customerId, equipmentTable);
             }
         }
         return(equipmentTable);
     }
 }
Ejemplo n.º 21
0
        public IList <Customer> GetCustomersBy(string agentId)
        {
            IList <Customer> customerList = null;

            if (localCacheStoreDic.ContainsKey(agentId))
            {
                customerList = localCacheStoreDic[agentId] as IList <Customer>;
            }
            else
            {
                var httpServiceApi      = new DataServiceApi();
                var request             = new RestRequest($"customer/list_by_region.json", Method.GET);
                var customerInfoWrapper = httpServiceApi.Execute <CustomerInfoWrapper>(request);

                customerList = new List <Customer>();
                foreach (var regionDto in customerInfoWrapper.root.subRegionList)
                {
                    foreach (var subregionDto in regionDto.subRegionList)
                    {
                        foreach (var agentDto in subregionDto.agentList)
                        {
                            foreach (var customerDto in agentDto.customerList)
                            {
                                Customer customer = new Customer()
                                {
                                    Id                  = customerDto.customerId,
                                    Name                = customerDto.customerName,
                                    Latitude            = customerDto.latitude,
                                    Longitude           = customerDto.longitude,
                                    CompanyProfile      = customerDto.customerIntroduce,
                                    Contacts            = customerDto.customerLinkman,
                                    ContactsPhone       = customerDto.customerPhone,
                                    CompanyAddress      = customerDto.customerAddress,
                                    IndustryType        = string.Empty,
                                    ContractExpiresDate = DateTime.Parse(customerDto.contractTime),
                                    InitiationDate      = DateTime.Parse(customerDto.inTime),
                                    MeteringPoint       = customerDto.meteringPoint,
                                    InstalledCapacity   = customerDto.installedCapacity,
                                    OperatingCapacity   = customerDto.operatingCapacity,
                                    TransformerNumber   = customerDto.transformerNumber,
                                    Province            = regionDto.regionName,
                                    City                = subregionDto.regionName,
                                    Agency              = agentDto.agentName
                                };
                                if (string.IsNullOrEmpty(customerDto.customerPic))
                                {
                                    customer.CustomerPic = "pack://application:,,,/Smart365Operation.Modules.Monitoring;component/Resources/Images/image_default.png";
                                }
                                else
                                {
                                    customer.CustomerPic = DataServiceApi.BaseUrl + "/" + customerDto.customerPic;
                                }
                                customerList.Add(customer);
                            }
                        }
                    }
                }
                localCacheStoreDic.Add(agentId, customerList);
            }
            return(customerList);
        }