Beispiel #1
0
        //[RestAuthenticationAttribute]
        public GetIrrigationMotorDataResponse GetIrrigationMotorData(GetIrrigationMotorDataRequest request)
        {
            request.DecodeAuthToken();
            BLUser userData = new BLUser();

            userData = CachingLayer.GetCacheObjectByType(request.SID, userData.GetType());
            GetIrrigationMotorDataResponse response = null;

            if (userData != null)
            {
                using (var dashboardUtils = new BLDashboards())
                {
                    response = new GetIrrigationMotorDataResponse()
                    {
                        IrrigationMotorData = dashboardUtils.Widget_IrrigationMotor4NAR(
                            userData.CompanyId,
                            request.DateFrom,
                            request.DateTo,
                            request.DateFrom,
                            request.DateTo,
                            request.VehicleID),
                        VolumeUnit = userData.Company.VolumeUnitText
                    };
                }
            }
            return(response);
        }
Beispiel #2
0
        //[RestAuthenticationAttribute]
        public GetIdleTimeCurrentStatusResponse GetIdleTimeCurrentStatus(GetIdleTimeCurrentStatusRequest request)
        {
            request.DecodeAuthToken();
            BLUser userData = new BLUser();

            userData = CachingLayer.GetCacheObjectByType(request.SID, userData.GetType());
            GetIdleTimeCurrentStatusResponse response = null;

            if (userData != null)
            {
                using (var dashboardUtils = new BLDashboards())
                {
                    request.VehicleGroup = request.VehicleGroup > 0 ? request.VehicleGroup : userData.VehicleNodeId;
                    WIDGET_IdleTimeCurrentStatusResult result = dashboardUtils.Widget_IdleTimeCurrentStatus(userData.CompanyId, request.VehicleGroup, request.VehicleID, request.VehicleType);
                    response = new GetIdleTimeCurrentStatusResponse()
                    {
                        NowSecondsData   = result.IDLE_TIME_CURRENT_SECS.GetValueOrDefault(0),
                        TodaySecondsData = result.IDLE_TIME_TODAY_SECS.GetValueOrDefault(0),
                        WeekSecondsData  = result.IDLE_TIME_THIS_WEEK_SECS.GetValueOrDefault(0),
                        MonthSecondsData = result.IDLE_TIME_THIS_MONTH_SECS.GetValueOrDefault(0)
                    };
                }
            }
            return(response);
        }
 public SolarTimeController(
     SolarCalculator solarCalculator,
     LocationProvider locationProvider,
     CachingLayer cachingLayer)
 {
     _solarCalculator  = solarCalculator;
     _locationProvider = locationProvider;
     _cachingLayer     = cachingLayer;
 }
Beispiel #4
0
        private string GetAuthorizationToken(GATRequest p_Data, Guid p_Guid)
        {
            if (!CachingLayer.IPThrottle(p_Data.IPAddress))
            {
                throw new AccessViolationException("Throtteling was defined");
            }
            var target = new CipherEngine();
            //long p_SIDRandomNumber = new Random().Next(int.MinValue, int.MaxValue);
            string p_DataToEncrypt = string.Join(",", p_Guid, p_Data.CallingPage, ConfigurationManager.AppSettings["AppID"], p_Data.IPAddress, /* p_SIDRandomNumber,*/ DateTime.UtcNow.Ticks);
            string SIDKey          = target.Encrypt(p_DataToEncrypt);

            CachingLayer.Insert(SIDKey, p_Guid.ToString());
            return(SIDKey);
        }
Beispiel #5
0
        //[RestAuthenticationAttribute]
        public IEnumerable <VehicleCommonInfo> GetUserVehiclesInfo(GetUserVehiclesInfoRequest request)
        {
            BLUser userData = new BLUser();

            request.DecodeAuthToken();
            IEnumerable <VehicleCommonInfo> vehicleInfoList = null;

            //userData = GlobalData.GetSessionProperty(request.SID, userData.GetType());
            userData = CachingLayer.GetCacheObjectByType(request.SID, userData.GetType());
            if (userData != null)
            {
                vehicleInfoList = userData.GetOnlineVehiclesInfo(false, string.Empty).Tables[0].DataTableToList <VehicleCommonInfo>();
            }
            return(vehicleInfoList);
        }
Beispiel #6
0
        public void ExtendCacheLifetime([FromBody] CommonRequest request)
        {
            request.DecodeAuthToken();
            List <dynamic> temp = null;

            if (CachingLayer.Exists(request.SID))
            {
                CachingLayer.Get <List <dynamic> >(request.SID, out temp);
                if (temp != null)
                {
                    CachingLayer.Clear(request.SID);
                    CachingLayer.Add <List <dynamic> >(temp, request.SID);
                }
            }
        }
Beispiel #7
0
        //[RestAuthenticationAttribute]
        public IEnumerable <VehicleType> GetVehicleTypes(GetVehicleTypesRequest request)
        {
            request.DecodeAuthToken();
            BLUser userData = new BLUser();

            userData = CachingLayer.GetCacheObjectByType(request.SID, userData.GetType());
            IEnumerable <VehicleType> vehicleTypeList = null;

            if (userData != null)
            {
                BLUtils utils = new BLUtils();
                vehicleTypeList = utils.GetVehicleTypes(userData.CompanyId).DataTableToList <VehicleType>();
            }
            return(vehicleTypeList);
        }
Beispiel #8
0
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            var           result  = false;
            CommonRequest request = ((CommonRequest)actionContext.ActionArguments["request"]);

            if (request != null && !string.IsNullOrEmpty(request.T))
            {
                result = CachingLayer.Authorize(request.T);
            }

            if (!result)
            {
                var response = new HttpResponseMessage(HttpStatusCode.Unauthorized);
                actionContext.Response = response;
            }
        }
Beispiel #9
0
        //[RestAuthenticationAttribute]
        public IEnumerable <GroupsDataInfo> GetGroupsData(GetUserGroupsDataRequest request)
        {
            BLUser userData = new BLUser();

            request.DecodeAuthToken();
            userData = CachingLayer.GetCacheObjectByType(request.SID, userData.GetType());
            VehicleTreeDS.VEHICLE_GROUPSRow temp           = userData.GetVehicleGroupsDS().VEHICLE_GROUPS.FindByVTR_NODE_ID(userData.VehicleNodeId);
            List <GroupsDataInfo>           groupsDataInfo = temp.Table.DataTableToList <GroupsDataInfo>().ToList();

            /*groupsDataInfo.Add(new GroupsDataInfo()
             * {
             *  VTR_COMPANY_ID=temp.VTR_COMPANY_ID,
             *  VTR_NODE_ID=temp.VTR_NODE_ID,
             *  VTR_NODE_NAME=temp.VTR_NODE_NAME
             * });*/

            return(groupsDataInfo);
        }
Beispiel #10
0
        //[RestAuthenticationAttribute]/*only with DB connection*/
        public IEnumerable <VehicleMapInfo> GetMapData(GetMapDataRequest request)
        {
            request.DecodeAuthToken();
            BLUser userData = new BLUser();

            //userData = GlobalData.GetSessionProperty(request.SID, userData.GetType());
            userData = CachingLayer.GetCacheObjectByType(request.SID, userData.GetType());
            IEnumerable <VehicleMapInfo> vehicleMapInfo = null;

            if (userData != null)
            {
                vehicleMapInfo = MapsDAL.GetVehicleList(-180, -90, 180, 90, userData.CompanyId, request.VehicleIDs, -1).DataTableToList <VehicleMapInfo>();
                GoogleObject     GObj   = new GoogleObject();
                GetMapDataFacade facade = new GetMapDataFacade();
                facade.createMapDataObject(ref GObj, vehicleMapInfo.ToList());
            }
            return(vehicleMapInfo);
        }
Beispiel #11
0
        //[RestAuthenticationAttribute]
        public List <WIDGET_OverspeedDistributionByAmountCEMEXResult> GetOverSpeedingDistributionByAmount(GetOverSpeedingDistributionByAmountRequest request)
        {
            request.DecodeAuthToken();
            BLUser userData = new BLUser();

            userData = CachingLayer.GetCacheObjectByType(request.SID, userData.GetType());
            List <WIDGET_OverspeedDistributionByAmountCEMEXResult> overspeedDistributionByAmountData = new List <WIDGET_OverspeedDistributionByAmountCEMEXResult>();

            if (userData != null)
            {
                using (var dashboardUtils = new BLDashboards())
                {
                    int _vehicleGroupID = request.VehicleGroupID > 0?request.VehicleGroupID:userData.VehicleNodeId;
                    overspeedDistributionByAmountData = dashboardUtils.Widget_OverspeedDistributionByAmountCEMEX(userData.CompanyId, request.DateFrom, request.DateTo, request.DateFrom, request.DateTo, _vehicleGroupID, request.VehicleTypeID);
                }
            }
            return(overspeedDistributionByAmountData);
        }
Beispiel #12
0
        public LoginResponse Login([FromBody] LoginRequest request)
        {
            LoginResponse response = new LoginResponse();

            response.IsAuthorised = false;
            try
            {
                BLUser user = new BLUser(request.Username, request.Password, request.CompanyName, Request.RequestUri.AbsolutePath);
                if (user != null)
                {
                    request.DecodeAuthToken();
                    CachingLayer.Insert <BLUser>(user, request.SID);
                    response.IsAuthorised = true;
                }
            }
            catch (ArgumentException ex) { }
            return(response);
        }