public ActionResult doOtherBinDispose()
        {
            string lotID = base.Request.Form["lotIDForOtherBinDispose"];
            string otherBinDisposeCommentID = base.Request.Form["hidOtherBinDisposeCommentID"];
            string str3         = base.Request.Form["txtOtherBinDisposeComment"];
            int    newPEDispose = Convert.ToInt32(base.Request.Form["hidPEDispose"]);

            if (StringHelper.isNullOrEmpty(str3))
            {
                str3 = "Other Bin dispose.";
            }
            Lot lot = LotService.doOtherBinDispose(lotID, newPEDispose, otherBinDisposeCommentID, str3, BaseController.CurrentUserInfo);

            NotificationService.ClearNotificationsByRoleAndLotID(UserRoles.PE, lotID, NotificationTypes.LotDispose);
            NotificationService.ClearNotificationsByRoleAndLotID(UserRoles.PE, lotID, NotificationTypes.OtherBinDispose);
            if (lot.VenderConfirmed)
            {
                NotificationService.CreateOSATConfirmNotificationsWhileLotChanged(lot.VenderID, lot, "OTHERBINDISPOSE");
            }
            ResponseTypes tip         = ResponseTypes.Tip;
            TipTypes      information = TipTypes.Information;

            base.Response.Write(new HandlerResponse("0", "doOtherBinDisposeSuccessed", tip.ToString(), information.ToString(), "", "", lot.Status).GenerateJsonResponse());
            return(null);
        }
Пример #2
0
        public static string FormatAuthUrl(
            string loginUrl,
            ResponseTypes responseType,
            string clientId,
            string redirectUrl,
            DisplayTypes display = DisplayTypes.Page,
            bool immediate = false,
            string state = "",
            string scope = "")
        {
            if (string.IsNullOrEmpty(loginUrl)) throw new ArgumentNullException("loginUrl");
            if (string.IsNullOrEmpty(clientId)) throw new ArgumentNullException("clientId");
            if (string.IsNullOrEmpty(redirectUrl)) throw new ArgumentNullException("redirectUrl");
            //TODO: check ensure that redirectUrl is a valid URI

            var url =
            string.Format(
                "{0}?response_type={1}&client_id={2}&redirect_uri={3}&display={4}&immediate={5}&state={6}&scope={7}",
                loginUrl,
                responseType.ToString().ToLower(),
                clientId,
                redirectUrl,
                display.ToString().ToLower(),
                immediate,
                state,
                scope);

            return url;
        }
Пример #3
0
        public static DqliteNodeInfo[] ParseNodesResponse(ResponseTypes type, int size, Memory <byte> data)
        {
            ThrowOnFailure(type, size, data);
            if (type != ResponseTypes.ResponseNodes)
            {
                throw new InvalidOperationException($"Invalid response: expected {ResponseTypes.ResponseNodes}, actually {type}");
            }

            var span = data.Span;

            var count = span.ReadUInt64();
            var nodes = new DqliteNodeInfo[count];

            for (var i = 0UL; i < count; ++i)
            {
                nodes[i]         = new DqliteNodeInfo();
                nodes[i].Id      = span.ReadUInt64();
                nodes[i].Address = span.ReadString();
                if (span.Length > 0)
                {
                    nodes[i].Role = (DqliteNodeRoles)span.ReadUInt64();
                }
            }

            return(nodes);
        }
Пример #4
0
        /// <summary>
        /// Gets the string representation of a <see cref="ResponseTypes"/>.
        /// </summary>
        /// <param name="responseType">The <see cref="ResponseTypes"/>.</param>
        /// <returns>A <see cref="string"/> representing the <see cref="ResponseTypes"/>.</returns>
        public static string ParseResponseType(ResponseTypes responseType)
        {
            string result;

            switch (responseType)
            {
            case ResponseTypes.TokenAndIdToken:
                result = "token id_token";
                break;

            case ResponseTypes.IdToken:
                result = "id_token";
                break;

            case ResponseTypes.Token:
                result = "token";
                break;

            default:
                result = "code";
                break;
            }

            return(result);
        }
 public UpdateResponse(List <Player> players, long remainingTime, Status gameStatus)
 {
     this.type          = ResponseTypes.UPDATE;
     this.players       = players;
     this.remainingTime = remainingTime;
     this.gameStatus    = gameStatus;
 }
        /// <summary>
        /// Gets all response types that are associated with the endpoint
        /// </summary>
        /// <returns></returns>
        public IEnumerable <ResponseType> GetResponseTypes()
        {
            var responseTypes = GetChildren().OfType <ResponseType>();

            var groupedResponses = responseTypes.GroupBy(x => x.Status);

            List <ResponseType> prioritizedResponseTypes = new List <ResponseType>();

            foreach (var responseGroup in groupedResponses)
            {
                if (responseGroup.Count() > 1)
                {
                    if (ResponseTypes.Count(x => x.Status == responseGroup.Key) == 1)
                    {
                        var endpointResponse = ResponseTypes.SingleOrDefault(x => x.Status == responseGroup.Key);
                        prioritizedResponseTypes.Add(endpointResponse);
                    }
                    else
                    {
                        //This will fail, we will let it.
                        prioritizedResponseTypes.AddRange(responseGroup);
                    }
                }
                else
                {
                    prioritizedResponseTypes.Add(responseGroup.Single());
                }
            }

            return(prioritizedResponseTypes.OrderBy(x => x.SortOrder));
        }
Пример #7
0
        public ActionResult ExportData(Lot_TransformedQuery query)
        {
            int    recordCount = 0;
            string xlsName     = string.Format("Transform_{0}", DateTime.Now.ToString("yyyyMMdd_hhmmss"));

            if (StringHelper.isNullOrEmpty(query.OrderBy))
            {
                query.OrderBy   = "CreateDate";
                query.OrderDesc = true;
            }
            if (CurrentUserInfo.Role == UserRoles.Fab || CurrentUserInfo.Role == UserRoles.FabAdmin)
            {
                query.Osat   = CurrentUserInfo.BUName;
                query.Status = (int)WaferStatus.WaitVendor;
            }
            IList <Lot_Transformed> list = service.GetAllLots(query, 0xf423f, 0, out recordCount);

            if (list != null && list.Count > 0)
            {
                foreach (Lot_Transformed lot in list)
                {
                    lot.StatusText = WaferHelper.waferStatusDes(lot.Status);
                }
            }
            string        nextUrl     = Exporthelper.GetExport <Lot_Transformed>("LOTS", list, "/Export/Excels/Transform/", "/Content/Exports/ExportTransform.xml", xlsName, 0, 0);
            ResponseTypes redirect    = ResponseTypes.Redirect;
            TipTypes      information = TipTypes.Information;

            base.Response.Write(new HandlerResponse("0", "导出Excel文件", redirect.ToString(), information.ToString(), nextUrl, "", "").GenerateJsonResponse());
            return(null);
        }
Пример #8
0
        public static string FormatAuthUrl(
            string loginUrl,
            ResponseTypes responseType,
            string clientId,
            string redirectUrl,
            DisplayTypes display = DisplayTypes.Page,
            bool immediate       = false,
            string state         = "",
            string scope         = "")
        {
            if (string.IsNullOrEmpty(loginUrl))
            {
                throw new ArgumentNullException(nameof(loginUrl));
            }
            if (string.IsNullOrEmpty(clientId))
            {
                throw new ArgumentNullException(nameof(clientId));
            }
            if (string.IsNullOrEmpty(redirectUrl))
            {
                throw new ArgumentNullException(nameof(redirectUrl));
            }

            return
                ($"{loginUrl}?response_type={responseType.ToString().ToLower()}" +
                 $"&client_id={clientId}" +
                 $"&redirect_uri={redirectUrl}" +
                 $"&display={display.ToString().ToLower()}" +
                 $"&immediate={immediate}" +
                 $"&state={state}" +
                 $"&scope={scope}");
        }
Пример #9
0
        public void ResponseHandler(ResponseTypes Response, string account, string proxy)
        {
            switch (Response)
            {
            case ResponseTypes.Success:
                break;

            case ResponseTypes.Error:
                Accounts.Add(account);
                break;

            case ResponseTypes.Fail:
                break;

            case ResponseTypes.IpBan:
                if (Proxies.Count <= 0)
                {
                    flag = ThreadController.ThreadFlags.Stop;
                }
                if (Loader.GetFun <bool>("RemoveBadProxies"))
                {
                    lock (Proxies)
                        Proxies.Remove(proxy);
                }
                break;
            }
        }
Пример #10
0
        public ActionResult ExportHistory()
        {
            string                  xlsName     = string.Format("History_{0}", DateTime.Now.ToString("yyyyMMdd_hhmmss"));
            HistoryQuery            query       = HistoryQueryUtility.GetHistoryQuery(base.Request);
            int                     recordCount = 0;
            IList <VwWafer_History> list        = historyService.HistoryList(query, 0xf423f, 0, out recordCount);

            if (list != null && list.Count > 0)
            {
                foreach (VwWafer_History history in list)
                {
                    if (history.IsVendor)
                    {
                        history.DisposeText = "Confirmed";
                    }
                    else
                    {
                        history.DisposeText = WaferHelper.WaferSelectionDes(history.Dispose);
                    }
                }
            }
            string        nextUrl     = Exporthelper.GetExport <VwWafer_History>("Historys", list, "/Export/Excels/History/", "/Content/Exports/ExportHistory.xml", xlsName, 0, 0);
            ResponseTypes redirect    = ResponseTypes.Redirect;
            TipTypes      information = TipTypes.Information;

            base.Response.Write(new HandlerResponse("0", "导出Excel文件", redirect.ToString(), information.ToString(), nextUrl, "", "").GenerateJsonResponse());
            return(null);
        }
Пример #11
0
        public static string FormatAuthUrl(
            string loginUrl,
            ResponseTypes responseType,
            string clientId,
            string redirectUrl,
            DisplayTypes display = DisplayTypes.Page,
            bool immediate       = false,
            string scope         = "")
        {
            if (string.IsNullOrEmpty(loginUrl))
            {
                throw new ArgumentNullException("loginUrl");
            }
            if (string.IsNullOrEmpty(clientId))
            {
                throw new ArgumentNullException("clientId");
            }
            if (string.IsNullOrEmpty(redirectUrl))
            {
                throw new ArgumentNullException("redirectUrl");
            }

            var url =
                string.Format(
                    "{0}?response_type={1}&client_id={2}&redirect_uri={3}&display={4}&immediate={5}&scope={6}",
                    loginUrl,
                    responseType.ToString().ToLower(),
                    clientId,
                    redirectUrl,
                    display.ToString().ToLower(),
                    immediate,
                    scope);

            return(url);
        }
Пример #12
0
 public virtual object Clone()
 {
     return(new OAuthClient
     {
         ClientId = ClientId,
         ClientNames = ClientNames == null ? new List <OAuthTranslation>() : ClientNames.Select(c => (OAuthTranslation)c.Clone()).ToList(),
         ClientUris = ClientUris == null ? new List <OAuthTranslation>() : ClientUris.Select(c => (OAuthTranslation)c.Clone()).ToList(),
         LogoUris = LogoUris == null ? new List <OAuthTranslation>() : LogoUris.Select(c => (OAuthTranslation)c.Clone()).ToList(),
         PolicyUris = PolicyUris == null ? new List <OAuthTranslation>() : PolicyUris.Select(c => (OAuthTranslation)c.Clone()).ToList(),
         TosUris = TosUris == null ? new List <OAuthTranslation>() : TosUris.Select(c => (OAuthTranslation)c.Clone()).ToList(),
         CreateDateTime = CreateDateTime,
         JwksUri = JwksUri,
         RefreshTokenExpirationTimeInSeconds = RefreshTokenExpirationTimeInSeconds,
         UpdateDateTime = UpdateDateTime,
         TokenEndPointAuthMethod = TokenEndPointAuthMethod,
         TokenExpirationTimeInSeconds = TokenExpirationTimeInSeconds,
         Secrets = Secrets == null ? new List <ClientSecret>() : Secrets.Select(s => (ClientSecret)s.Clone()).ToList(),
         AllowedScopes = AllowedScopes == null ? new List <OAuthScope>() : AllowedScopes.Select(s => (OAuthScope)s.Clone()).ToList(),
         JsonWebKeys = JsonWebKeys == null ? new List <JsonWebKey>() : JsonWebKeys.Select(j => (JsonWebKey)j.Clone()).ToList(),
         GrantTypes = GrantTypes.ToList(),
         RedirectionUrls = RedirectionUrls.ToList(),
         PreferredTokenProfile = PreferredTokenProfile,
         TokenEncryptedResponseAlg = TokenEncryptedResponseAlg,
         TokenEncryptedResponseEnc = TokenEncryptedResponseEnc,
         TokenSignedResponseAlg = TokenSignedResponseAlg,
         ResponseTypes = ResponseTypes.ToList(),
         Contacts = Contacts.ToList(),
         SoftwareId = SoftwareId,
         SoftwareVersion = SoftwareVersion,
         PostLogoutRedirectUris = PostLogoutRedirectUris.ToList()
     });
 }
Пример #13
0
        private dynamic GetJSONRestResponse(string url, ResponseTypes responseType)
        {
            string stringResponse = string.Empty;

            byte[]  byteResponse = new byte[] { };
            dynamic jsonResponse = null;

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
            using (WebClient client = new WebClient())
            {
                this.AddHeaders <WebClient>(client);
                switch (responseType)
                {
                case ResponseTypes.BinaryData:
                    byteResponse = client.DownloadData(url);
                    jsonResponse = byteResponse;
                    break;

                default:
                    stringResponse = client.DownloadString(url);
                    jsonResponse   = JsonConvert.DeserializeObject(stringResponse);
                    break;
                }
            }

            return(jsonResponse);
        }
 public SendServerResponseCommand(Guid clientId, string response, ResponseTypes responseType, MessageHeader header)
 {
     _clientId = clientId;
     _response = response;
     _responseType = responseType;
     _compressionType = header.CompressionType;
     _encryptionType = header.EncryptionHeader.EncryptionType;
 }
 public RegisterResponse(Player player, long gameID, Config config)
 {
     this.type          = ResponseTypes.REGISTERED;
     this.isAdmin       = player.isAdmin;
     this.gameID        = gameID;
     this.localPlayerID = player.id;
     this.config        = config;
 }
Пример #16
0
 public BroadcastMessageCommand(Guid[] clientList, string response, ResponseTypes responseType, MessageHeader header)
 {
     _clientList      = clientList;
     _response        = response;
     _responseType    = responseType;
     _compressionType = header.CompressionType;
     _encryptionType  = header.EncryptionHeader.EncryptionType;
 }
 public SendServerResponseCommand(Guid clientId, string response, ResponseTypes responseType, MessageHeader header)
 {
     _clientId        = clientId;
     _response        = response;
     _responseType    = responseType;
     _compressionType = header.CompressionType;
     _encryptionType  = header.EncryptionHeader.EncryptionType;
 }
 public BroadcastMessageCommand(Guid[] clientList, string response, ResponseTypes responseType, MessageHeader header)
 {
     _clientList = clientList;
     _response = response;
     _responseType = responseType;
     _compressionType = header.CompressionType;
     _encryptionType = header.EncryptionHeader.EncryptionType;
 }
 /// <summary>
 /// Gets all the children of this controller and any it inherits.
 /// </summary>
 /// <returns></returns>
 public IEnumerable <INavNode> GetChildren()
 {
     return(ResponseTypes.Cast <INavNode>()
            .Union(BaseController?.GetChildren() ?? new List <INavNode>())
            .Union(ConstantHeader)
            .Union(ParameterHeader)
            .Union(GetInjectionDependencies().OfType <INavNode>())
            .Where(x => x != null)
            .ToList());
 }
Пример #20
0
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var results = new List <ValidationResult>();

            if (RequirePkce && ResponseTypes?.Contains(IdentityConstants.ResponseTypes.Code) != true)
            {
                results.Add(new ValidationResult($"Require '{IdentityConstants.ResponseTypes.Code}' response type with PKCE.", new[] { nameof(RequirePkce), nameof(ResponseTypes) }));
            }
            return(results);
        }
Пример #21
0
 public Response(IRequest request, string message, ResponseTypes responseType)
 {
     this.ResponseId   = Guid.NewGuid();
     this.Entity       = request.Entity;
     this.Message      = message;
     this.RequestId    = request.RequestId;
     this.Request      = request;
     this.ResponseType = responseType;
     this.CreatedDate  = DateTime.Now;
 }
Пример #22
0
        public static void ThrowOnFailure(ResponseTypes type, int size, Memory <byte> data)
        {
            if (type == ResponseTypes.ResponseFailure)
            {
                var span         = data.Span;
                var errorCode    = span.ReadUInt64();
                var errorMessage = span.ReadString();

                throw new DqliteException(errorCode, errorMessage);
            }
        }
Пример #23
0
 public Response(Request request, string message, ResponseTypes responseType)
 {
     Entity = request.Entity;
     Message = message;
     ResponseUniqueKey = Guid.NewGuid();
     RequestId = request.RequestId;
     RequestUniqueKey = request.RequestUniqueKey;
     Request = request;
     ResponseType = responseType;
     CreatedDate = DateTime.Now;
 }
Пример #24
0
        /// <summary>
        /// Получить отделы
        /// </summary>
        /// <param name="formatter"></param>
        /// <param name="stream"></param>
        private void GetDeps(IFormatter formatter, NetworkStream stream)
        {
            formatter.Serialize(stream, RequestTypes.GetDepartments);

            ResponseTypes response = (ResponseTypes)formatter.Deserialize(stream);

            deps = (List <DepartmentModel>)formatter.Deserialize(stream);

            cbDepartments.DataSource = deps;
            FillDepartmentsGrid();
        }
Пример #25
0
        /// <summary>
        /// Creates a new instance of the specified <see cref="IResponseMessage"/> type
        /// </summary>
        /// <typeparam name="TResponse">specifies the type of IResponseMessage to create</typeparam>
        /// <param name="responseType">specifies the selected <see cref="ResponseTypes"/> value</param>
        /// <param name="outputMessage">specifies the message to return</param>
        /// <param name="validationResult">specifies the <see cref="ValidationResult"/> to return [Optional]</param>
        /// <returns>returns a new ResponseMessage object</returns>
        public static TResponse BuildResponse <TResponse>(ResponseTypes responseType, string outputMessage, Exception innerException = null)
            where TResponse : IResponseMessage
        {
            var obj = Activator.CreateInstance <TResponse>();

            obj.ResponseType   = responseType;
            obj.OutputMessage  = outputMessage;
            obj.InnerException = innerException;

            return(obj);
        }
Пример #26
0
 /// <summary>
 /// Vrati odpoved v definovanom formate
 /// </summary>
 /// <param name="type">Typ odpovede</param>
 /// <param name="message">Sprava vysvetlujuca odpoved</param>
 /// <param name="redirectUrl">Url na ktoru sa ma redirectnut stranka</param>
 /// <param name="data">Data ktore sa odosielaju</param>
 /// <param name="behavior">JsonRequestBehavior</param>
 /// <returns>Navratova hodnota pre server</returns>
 public static JsonResult GetJsonResult(ResponseTypes type, String message, String redirectUrl, Object data, JsonRequestBehavior behavior)
 {
     if (type == ResponseTypes.RedirectToAction && String.IsNullOrWhiteSpace(redirectUrl))
     {
         throw new Exception("redirectUrl is null or empty!");
     }
     if (String.IsNullOrWhiteSpace(message) && WebConfiguration.OnResponseMessageDelegate != null)
     {
         message = WebConfiguration.OnResponseMessageDelegate(type);
     }
     return(WebUtility.Json(new { result = type, message = message, redirectUrl = redirectUrl, data = data }, behavior));
 }
Пример #27
0
        /// <summary>
        /// Получить должности
        /// </summary>
        /// <param name="formatter"></param>
        /// <param name="stream"></param>
        private void GetPositions(IFormatter formatter, NetworkStream stream)
        {
            // Отправить запрос на получение должностей
            formatter.Serialize(stream, RequestTypes.GetPositions);

            ResponseTypes response = (ResponseTypes)formatter.Deserialize(stream);

            positions = (List <PositionModel>)formatter.Deserialize(stream);

            cbPositions.DataSource = positions;
            FillPositionsGrid();
        }
            public override bool Equals(object obj)
            {
                var o = obj as GrantingMethod;

                if (o == null)
                {
                    return(false);
                }

                return(o.GrantTypes.Count() == GrantTypes.Count() && o.GrantTypes.All(g => GrantTypes.Contains(g)) &&
                       o.ResponseTypes.Count() == ResponseTypes.Count() && o.ResponseTypes.All(r => ResponseTypes.Contains(r)));
            }
Пример #29
0
        public void Add(Type serviceType, Type requestType, Type responseType)
        {
            RequestTypes.Add(requestType);
            ServiceTypes.Add(serviceType);

            var restrictTo = requestType.FirstAttribute <RestrictAttribute>()
                             ?? serviceType.FirstAttribute <RestrictAttribute>();

            var reqFilterAttrs = new[] { requestType, serviceType }
            .SelectMany(x => x.AllAttributes().OfType <IRequestFilterBase>()).ToList();
            var resFilterAttrs = (responseType != null ? new[] { responseType, serviceType } : new[] { serviceType })
                                 .SelectMany(x => x.AllAttributes().OfType <IResponseFilterBase>()).ToList();

            var authAttrs = reqFilterAttrs.OfType <AuthenticateAttribute>().ToList();
            var actions   = GetImplementedActions(serviceType, requestType);

            authAttrs.AddRange(actions.SelectMany(x => x.AllAttributes <AuthenticateAttribute>()));

            var operation = new Operation
            {
                ServiceType              = serviceType,
                RequestType              = requestType,
                ResponseType             = responseType,
                RestrictTo               = restrictTo,
                Actions                  = actions.Map(x => x.Name.ToUpper()),
                Routes                   = new List <RestPath>(),
                RequestFilterAttributes  = reqFilterAttrs,
                ResponseFilterAttributes = resFilterAttrs,
                RequiresAuthentication   = authAttrs.Count > 0,
                RequiredRoles            = authAttrs.OfType <RequiredRoleAttribute>().SelectMany(x => x.RequiredRoles).ToList(),
                RequiresAnyRole          = authAttrs.OfType <RequiresAnyRoleAttribute>().SelectMany(x => x.RequiredRoles).ToList(),
                RequiredPermissions      = authAttrs.OfType <RequiredPermissionAttribute>().SelectMany(x => x.RequiredPermissions).ToList(),
                RequiresAnyPermission    = authAttrs.OfType <RequiresAnyPermissionAttribute>().SelectMany(x => x.RequiredPermissions).ToList(),
            };

            this.OperationsMap[requestType] = operation;
            this.OperationNamesMap[operation.Name.ToLowerInvariant()] = operation;
            if (responseType != null)
            {
                ResponseTypes.Add(responseType);
            }

            //Only count non-core ServiceStack Services, i.e. defined outside of ServiceStack.dll or Swagger
            var nonCoreServicesCount = OperationsMap.Values
                                       .Count(x => x.ServiceType.Assembly != typeof(Service).Assembly &&
                                              x.ServiceType.FullName != "ServiceStack.Api.Swagger.SwaggerApiService" &&
                                              x.ServiceType.FullName != "ServiceStack.Api.Swagger.SwaggerResourcesService" &&
                                              x.ServiceType.FullName != "ServiceStack.Api.OpenApi.OpenApiService" &&
                                              x.ServiceType.Name != "__AutoQueryServices");

            LicenseUtils.AssertValidUsage(LicenseFeature.ServiceStack, QuotaType.Operations, nonCoreServicesCount);
        }
Пример #30
0
        public static bool ParseWelcomeResponse(ResponseTypes type, int size, Memory <byte> data)
        {
            ThrowOnFailure(type, size, data);
            if (type != ResponseTypes.ResponseWelcome)
            {
                throw new InvalidOperationException($"Invalid response: expected {ResponseTypes.ResponseWelcome}, actually {type}");
            }

            var span = data.Span;

            span.ReadUInt64();
            return(true);
        }
Пример #31
0
        /// <summary>
        /// Получить выплаты
        /// </summary>
        /// <param name="formatter"></param>
        /// <param name="stream"></param>
        private void GetPayoutTypes(IFormatter formatter, NetworkStream stream)
        {
            formatter.Serialize(stream, RequestTypes.GetPayoutTypes);

            ResponseTypes response = (ResponseTypes)formatter.Deserialize(stream);

            payoutTypes = (List <PayoutTypeModel>)formatter.Deserialize(stream);

            cbPayoutType.DataSource = payoutTypes;

            // Заполнить grid с типами выплат
            FillPayoutTypesGrid();
        }
Пример #32
0
 public override object Clone()
 {
     return(new OpenIdClient
     {
         ClientId = ClientId,
         ClientNames = ClientNames == null ? new List <OAuthTranslation>() : ClientNames.Select(c => (OAuthTranslation)c.Clone()).ToList(),
         ClientUris = ClientUris == null ? new List <OAuthTranslation>() : ClientUris.Select(c => (OAuthTranslation)c.Clone()).ToList(),
         LogoUris = LogoUris == null ? new List <OAuthTranslation>() : LogoUris.Select(c => (OAuthTranslation)c.Clone()).ToList(),
         PolicyUris = PolicyUris == null ? new List <OAuthTranslation>() : PolicyUris.Select(c => (OAuthTranslation)c.Clone()).ToList(),
         TosUris = TosUris == null ? new List <OAuthTranslation>() : TosUris.Select(c => (OAuthTranslation)c.Clone()).ToList(),
         CreateDateTime = CreateDateTime,
         JwksUri = JwksUri,
         RefreshTokenExpirationTimeInSeconds = RefreshTokenExpirationTimeInSeconds,
         UpdateDateTime = UpdateDateTime,
         TokenEndPointAuthMethod = TokenEndPointAuthMethod,
         TokenExpirationTimeInSeconds = TokenExpirationTimeInSeconds,
         Secrets = Secrets == null ? new List <ClientSecret>() : Secrets.Select(s => (ClientSecret)s.Clone()).ToList(),
         AllowedScopes = AllowedScopes == null ? new List <OpenIdScope>() : AllowedScopes.Select(s => (OpenIdScope)s.Clone()).ToList(),
         JsonWebKeys = JsonWebKeys == null ? new List <JsonWebKey>() : JsonWebKeys.Select(j => (JsonWebKey)j.Clone()).ToList(),
         GrantTypes = GrantTypes.ToList(),
         RedirectionUrls = RedirectionUrls.ToList(),
         PreferredTokenProfile = PreferredTokenProfile,
         TokenEncryptedResponseAlg = TokenEncryptedResponseAlg,
         TokenEncryptedResponseEnc = TokenEncryptedResponseEnc,
         TokenSignedResponseAlg = TokenSignedResponseAlg,
         ResponseTypes = ResponseTypes.ToList(),
         Contacts = Contacts.ToList(),
         SoftwareId = SoftwareId,
         SoftwareVersion = SoftwareVersion,
         ApplicationType = ApplicationType,
         DefaultAcrValues = DefaultAcrValues.ToList(),
         DefaultMaxAge = DefaultMaxAge,
         IdTokenEncryptedResponseAlg = IdTokenEncryptedResponseAlg,
         IdTokenEncryptedResponseEnc = IdTokenEncryptedResponseEnc,
         IdTokenSignedResponseAlg = IdTokenSignedResponseAlg,
         PairWiseIdentifierSalt = PairWiseIdentifierSalt,
         RequestObjectEncryptionAlg = RequestObjectEncryptionAlg,
         RequestObjectEncryptionEnc = RequestObjectEncryptionEnc,
         RequestObjectSigningAlg = RequestObjectSigningAlg,
         RequireAuthTime = RequireAuthTime,
         SectorIdentifierUri = SectorIdentifierUri,
         SubjectType = SubjectType,
         UserInfoEncryptedResponseAlg = UserInfoEncryptedResponseAlg,
         UserInfoEncryptedResponseEnc = UserInfoEncryptedResponseEnc,
         UserInfoSignedResponseAlg = UserInfoSignedResponseAlg,
         RegistrationAccessToken = RegistrationAccessToken,
         PostLogoutRedirectUris = PostLogoutRedirectUris,
         InitiateLoginUri = InitiateLoginUri
     });
 }
        /// <summary>
        /// Deserializes the response into an object of the specified type.
        /// </summary>
        public void Deserialize(Type type, string input, object objectToDeserializeInto)
        {
            if (string.IsNullOrEmpty(input))
            {
                return;
            }

            var bits = input.Split(new[] { "&" }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var nameValuePairCombined in bits)
            {
                int index = nameValuePairCombined.IndexOf('=');
                if (index < 0)
                {
                    Logging.LogMessage("Could not deserialize NameValuePair: " + nameValuePairCombined);
                    continue;
                }
                string       name  = nameValuePairCombined.Substring(0, index);
                string       value = nameValuePairCombined.Substring(index + 1);
                PropertyInfo prop  = type.GetProperty(name, BindingFlags.Public | BindingFlags.Instance);

                if (prop == null)
                {
                    // Ignore any additional NVPs that we don't have properties for instead of throwing exception
                    // This does mean we only capture the first of any errors returned into L_ERRORCODE0 etc
                    continue; // throw new InvalidOperationException(string.Format("Could not find a property on Type '{0}' named '{1}'", type.Name, name));
                }

                object convertedValue;

                if (prop.PropertyType == typeof(ResponseType))
                {
                    convertedValue = ResponseTypes.ConvertStringToPayPalResponseType(value);
                }
                else if (prop.PropertyType == typeof(CheckoutStatus))
                {
                    convertedValue = CheckoutStatuses.ConvertStringToPayPalCheckoutStatus(value);
                }
                else if (prop.PropertyType == typeof(PaymentStatus))
                {
                    convertedValue = PaymentStatuses.ConvertStringToPayPalCheckoutStatus(value);
                }
                else
                {
                    convertedValue = Convert.ChangeType(value, prop.PropertyType);
                }

                prop.SetValue(objectToDeserializeInto, convertedValue, null);
            }
        }
Пример #34
0
        public new IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var results = new List <ValidationResult>();

            if (ResponseTypes.Contains(IdentityConstants.ResponseTypes.Code) && !RequirePkce && Secrets.Count() <= 0 && ExistingSecrets.Where(s => !s.Removed).Count() <= 0)
            {
                results.Add(new ValidationResult($"The field Secrets must be between 1 and 10 if PKCE is not require.", new[] { nameof(Secrets) }));
            }
            if (!DefaultResourceScope && ResourceScopes.Count <= 0)
            {
                results.Add(new ValidationResult($"The field Resource and scopes must be between 1 and 50 if default Resource Scope is not selected.", new[] { nameof(ResourceScopes) }));
            }
            return(results);
        }
Пример #35
0
        public static ResponseHeader BuildResponseHeader(EncryptionTypes encryptionType, CompressionTypes compressionType, ResponseTypes responseType)
        {
            // first create headers
            EncryptionHeader encryptionHeader = new EncryptionHeader()
            {
                EncryptionType = encryptionType
            };

            MessageHeader messageHeader = new MessageHeader()
            {
                CompressionType = compressionType,
                EncryptionHeader = encryptionHeader
            };

            ResponseHeader responseHeader = new ResponseHeader()
            {
                ResponseType = responseType,
                MessageHeader = messageHeader
            };

            // send response header first
            return responseHeader;
        }
Пример #36
0
 internal ViscaResponse( ResponseTypes type )
 {
     ResponseType = type;
 }
Пример #37
0
 public void Unsubscribe(ResponseTypes type, ResponseHandler handler)
 {
     this.subscribed[(int)type] = false;
 }
Пример #38
0
 public void Subscribe(ResponseTypes type, ResponseHandler handler)
 {
     this.subscribed[(int)type] = true;
     this.delegates[(int)type] = handler;
 }
Пример #39
0
        public override int Decode(int sourceSensor,byte[] data, int length)
        {
            int rawDataIndex = 0;
            int numDecodedPackets=0;

            if (length != 0) // Have some data
            {
                while (rawDataIndex < length)
                {

                    if ((data[rawDataIndex] & 0x80) != 0)
                    {
                        this.packetPosition = 0;
                        this.headerSeen = true;
                        packetType = (SensorDataType)((int)((byte)(((byte)data[rawDataIndex]) << 1) >> 6));
                        switch (packetType)
                        {
                            case SensorDataType.UNCOMPRESSED_DATA_PDU:
                                bytesToRead = 5;
                                break;
                            case SensorDataType.COMPRESSED_DATA_PDU:
                                bytesToRead = 3;
                                break;
                            case SensorDataType.RESPONSE_PDU:
                                responseType = (ResponseTypes)((int)(((byte)data[rawDataIndex]) & 0x1f));
                                switch (responseType)
                                {
                                    case ResponseTypes.BP_RSP:
                                    case ResponseTypes.SENS_RSP:
                                    case ResponseTypes.SR_RSP:
                                    case ResponseTypes.ALT_RSP:
                                    case ResponseTypes.PDT_RSP:
                                    case ResponseTypes.TM_RSP:
                                    case ResponseTypes.HV_RSP:
                                    case ResponseTypes.FV_RSP:
                                        bytesToRead = 2;
                                        break;
                                    case ResponseTypes.BL_RSP:
                                    case ResponseTypes.BC_RSP:
                                        bytesToRead = 3;
                                        break;
                                    case ResponseTypes.PC_RSP:
                                        bytesToRead = 6;
                                        break;
                                    case ResponseTypes.CAL_RSP:
                                    case ResponseTypes.BTCAL_RSP:
                                        bytesToRead = 10;
                                        break;
                                    default:
                                        break;
                                }
                                break;
                            default:
                                break;
                        }
                    }

                    if ((this.headerSeen == true) && (this.packetPosition < bytesToRead))
                        this.packet[this.packetPosition] = data[rawDataIndex];

                    this.packetPosition++;
                    rawDataIndex++;

                    if ((this.packetPosition == bytesToRead)) //a full packet was received
                    {
                        WocketsAccelerationData datum = ((WocketsAccelerationData)this._Data[this.head]);
                        datum.Reset();
                        //copy raw bytes
                        for (int i = 0; (i < bytesToRead); i++)
                            datum.RawBytes[i] = this.packet[i];

                        datum.UnixTimeStamp = lastUnixTime;

                        if ( (packetType == SensorDataType.UNCOMPRESSED_DATA_PDU)||(packetType == SensorDataType.COMPRESSED_DATA_PDU))
                        {

                            short x = 0;
                            short y = 0;
                            short z = 0;

                            if (packetType == SensorDataType.UNCOMPRESSED_DATA_PDU)
                            {

                                datum._Type = SensorDataType.UNCOMPRESSED_DATA_PDU;
                                x = (short)((((short)(this.packet[0] & 0x03)) << 8) | (((short)(this.packet[1] & 0x7f)) << 1) | (((short)(this.packet[2] & 0x40)) >> 6));
                                y = (short)((((short)(this.packet[2] & 0x3f)) << 4) | (((short)(this.packet[3] & 0x78)) >> 3));
                                z = (short)((((short)(this.packet[3] & 0x07)) << 7) | ((short)(this.packet[4] & 0x7f)));
                                _UncompressedPDUCount++;
                            }
                            else
                            {

                                datum._Type = SensorDataType.COMPRESSED_DATA_PDU;
                                x = (short)(((this.packet[0] & 0x0f) << 1) | ((this.packet[1] & 0x40) >> 6));
                                x = ((((short)((this.packet[0] >> 4) & 0x01)) == 1) ? ((short)(prevx + x)) : ((short)(prevx - x)));
                                y = (short)(this.packet[1] & 0x1f);
                                y = ((((short)((this.packet[1] >> 5) & 0x01)) == 1) ? ((short)(prevy + y)) : ((short)(prevy - y)));
                                z = (short)((this.packet[2] >> 1) & 0x1f);
                                z = ((((short)((this.packet[2] >> 6) & 0x01)) == 1) ? ((short)(prevz + z)) : ((short)(prevz - z)));
                                _CompressedPDUCount++;
                            }

                            prevx = x;
                            prevy = y;
                            prevz = z;
                            datum._X = (short)x;
                            datum._Y = (short)y;
                            datum._Z = (short)z;

                             if (this.head >= (BUFFER_SIZE - 1))
                                this.head = 0;
                            else
                                this.head++;
                            numDecodedPackets++;

                            this.packetPosition = 0;
                            this.headerSeen = false;
                        }
                    }

                }
            }
            //this._Size = decodedDataIndex;
            return numDecodedPackets;
        }
Пример #40
0
        public override int Decode(int sourceSensor, CircularBuffer data,int start,int end)
        {
            int rawDataIndex = start;
            int numDecodedPackets = 0;
            //int bufferHead = this.head;

            while (rawDataIndex != end)
            {

                           //If a PDU first byte
                    if ((data._Bytes[rawDataIndex] & 0x80) != 0)
                    {
                        this.packetPosition = 0;
                        this.headerSeen = true;
                        packetType = (SensorDataType) ((int)( (byte)(((byte)data._Bytes[rawDataIndex]) << 1) >> 6));
                        this.timestamp = data._Timestamp[rawDataIndex];
                        switch (packetType)
                        {
                            case SensorDataType.UNCOMPRESSED_DATA_PDU:
                                bytesToRead = 5;
                                break;
                            case SensorDataType.COMPRESSED_DATA_PDU:
                                bytesToRead = 3;
                                break;
                            case SensorDataType.RESPONSE_PDU:
                                responseType = (ResponseTypes)((int)(((byte)data._Bytes[rawDataIndex]) & 0x1f));
                                switch (responseType)
                                {
                                    case ResponseTypes.BP_RSP:
                                    case ResponseTypes.SENS_RSP:
                                    case ResponseTypes.SR_RSP:
                                    case ResponseTypes.ALT_RSP:
                                    case ResponseTypes.PDT_RSP:
                                    case ResponseTypes.TM_RSP:
                                    case ResponseTypes.HV_RSP:
                                    case ResponseTypes.FV_RSP:
                                        bytesToRead = 2;
                                        break;
                                    case ResponseTypes.BL_RSP:
                                    case ResponseTypes.BC_RSP:
                                    case ResponseTypes.ACC_RSP:
                                    case ResponseTypes.OFT_RSP:
                                        bytesToRead = 3;
                                        break;
                                    case ResponseTypes.TCT_RSP:
                                        bytesToRead = 5;
                                        break;
                                    case ResponseTypes.AC_RSP:
                                    case ResponseTypes.PC_RSP:
                                        bytesToRead = 6;
                                        break;
                                    case ResponseTypes.CAL_RSP:
                                    case ResponseTypes.BTCAL_RSP:
                                        bytesToRead = 10;
                                        break;
                                    default:
                                        break;
                                }
                                break;
                            default:
                                break;
                        }
                    }

                    if ((this.headerSeen == true) && (this.packetPosition < bytesToRead))
                        this.packet[this.packetPosition] = data._Bytes[rawDataIndex];

                    this.packetPosition++;
                    rawDataIndex = (rawDataIndex + 1) % data._Bytes.Length;

                    if ((this.packetPosition == bytesToRead)) //a full packet was received
                    {
                        if ( (packetType == SensorDataType.UNCOMPRESSED_DATA_PDU)||(packetType == SensorDataType.COMPRESSED_DATA_PDU))
                        {

                            short x = 0;
                            short y = 0;
                            short z = 0;

                            //for each batch reinitialize the activity count sum and offset
                            if (this._ActivityCountOffset < 0)
                            {
                                acc_count = -1;
                                this._ActivityCountOffset = -1;
                            }

                            if (packetType == SensorDataType.UNCOMPRESSED_DATA_PDU)
                            {
                                x = (short)((((short)(this.packet[0] & 0x03)) << 8) | (((short)(this.packet[1] & 0x7f)) << 1) | (((short)(this.packet[2] & 0x40)) >> 6));
                                y = (short)((((short)(this.packet[2] & 0x3f)) << 4) | (((short)(this.packet[3] & 0x78)) >> 3));
                                z = (short)((((short)(this.packet[3] & 0x07)) << 7) | ((short)(this.packet[4] & 0x7f)));
                                _UncompressedPDUCount++;
                            }
                            else
                            {
                                x = (short)(((this.packet[0] & 0x0f) << 1) | ((this.packet[1] & 0x40) >> 6));
                                x = ((((short)((this.packet[0] >> 4) & 0x01)) == 1) ? ((short)(prevx + x)) : ((short)(prevx - x)));
                                y = (short)(this.packet[1] & 0x1f);
                                y = ((((short)((this.packet[1] >> 5) & 0x01)) == 1) ? ((short)(prevy + y)) : ((short)(prevy - y)));
                                z = (short)((this.packet[2] >> 1) & 0x1f);
                                z = ((((short)((this.packet[2] >> 6) & 0x01)) == 1) ? ((short)(prevz + z)) : ((short)(prevz - z)));
                                _CompressedPDUCount++;
                            }

                            prevx = x;
                            prevy = y;
                            prevz = z;
                            double ts = 0;

                            //Use the high precision timer
                            if (CurrentWockets._Controller._TMode == TransmissionMode.Continuous)
                                ts = WocketsTimer.GetUnixTime();
                            else // use date time now assuming suspension is possible
                            {
                                ts = batchCurrentTime;
                                batchCurrentTime += batchDeltaTime;
                            }
                            this.TotalSamples++;

                            //if (CurrentWockets._Configuration._MemoryMode == Wockets.Data.Configuration.MemoryConfiguration.NON_SHARED)
                           // if (CurrentWockets._Controller._Mode== MemoryMode.BluetoothToLocal)
                            //{
                                int bufferHead = this.head;
                                WocketsAccelerationData datum = ((WocketsAccelerationData)this._Data[bufferHead]);
                                datum.Reset();
                                datum.UnixTimeStamp = ts;

                                //copy raw bytes
                                for (int i = 0; (i < bytesToRead); i++)
                                    datum.RawBytes[i] = this.packet[i];
                                if (bytesToRead == 3)
                                    datum._Type = SensorDataType.COMPRESSED_DATA_PDU;
                                else
                                    datum._Type = SensorDataType.UNCOMPRESSED_DATA_PDU;
                                datum._Length = bytesToRead;
                                //datum.RawBytes[0] = (byte)(((datum.RawBytes[0])&0xc7)|(sourceSensor<<3));
                                datum._SensorID = (byte)sourceSensor;
                                datum._X = x;
                                datum._Y = y;
                                datum._Z = z;

            #if (PocketPC)
                                if ((CurrentWockets._Controller._TMode== TransmissionMode.Continuous) && (CurrentWockets._Controller._Mode == MemoryMode.BluetoothToShared))//if (CurrentWockets._Configuration._MemoryMode == Wockets.Data.Configuration.MemoryConfiguration.SHARED)
                                {
                                    this.sdata.Write(BitConverter.GetBytes(ts), 0, sizeof(double));
                                    //this.head+=sizeof(double);
                                    this.sdata.Write(BitConverter.GetBytes(x), 0, sizeof(short));
                                    //this.head+=sizeof(short);
                                    this.sdata.Write(BitConverter.GetBytes(y), 0, sizeof(short));
                                    //this.head+=sizeof(short);
                                    this.sdata.Write(BitConverter.GetBytes(z), 0, sizeof(short));
                                }
            #endif
                                if (bufferHead >= (BUFFER_SIZE - 1))
                                {
                                    bufferHead = 0;
            #if (PocketPC)
                                    if (CurrentWockets._Controller._TMode == TransmissionMode.Continuous)
                                     this.sdata.Seek(0, System.IO.SeekOrigin.Begin);
            #endif
                                }
                                else
                                    bufferHead++;
                                this.head = bufferHead;
            #if (PocketPC)
                                if (CurrentWockets._Controller._TMode == TransmissionMode.Continuous)
                                {
                                    this.shead.Seek(0, System.IO.SeekOrigin.Begin);
                                    this.shead.Write(BitConverter.GetBytes(this.head), 0, sizeof(int));

                                }
            #endif

                            numDecodedPackets++;

                        }
                        else if (packetType == SensorDataType.RESPONSE_PDU)
                        {

                            switch (responseType)
                            {
                                case ResponseTypes.BL_RSP:
                                    BL_RSP br = new BL_RSP(this._ID);
                                    for (int i = 0; (i < bytesToRead); i++)
                                        br.RawBytes[i] = this.packet[i];
                                    br._BatteryLevel = (((int)this.packet[1]) << 3) | ((this.packet[2] >> 4) & 0x07);
            #if (PocketPC)
                                    Core.WRITE_BATTERY_LEVEL(br);
            #endif
                                    FireEvent(br);
                                    break;
                                case ResponseTypes.CAL_RSP:
                                    CAL_RSP cal = new CAL_RSP(this._ID);
                                    for (int i = 0; (i < bytesToRead); i++)
                                        cal.RawBytes[i] = this.packet[i];
                                    cal._X1G = ((this.packet[1] & 0x7f) << 3) | ((this.packet[2] & 0x70) >> 4);
                                    cal._XN1G = ((this.packet[2] & 0x0f) << 6) | ((this.packet[3] & 0x7e) >> 1);
                                    cal._Y1G = ((this.packet[3] & 0x01) << 9) | ((this.packet[4] & 0x7f) << 2) | ((this.packet[5] & 0x60) >> 5);
                                    cal._YN1G = ((this.packet[5] & 0x1f) << 5) | ((this.packet[6] & 0x7c) >> 2);
                                    cal._Z1G = ((this.packet[6] & 0x03) << 8) | ((this.packet[7] & 0x7f) << 1) | ((this.packet[8] & 0x40) >> 6);
                                    cal._ZN1G = ((this.packet[8] & 0x3f) << 4) | ((this.packet[9] & 0x78) >> 3);
            #if (PocketPC)
                                    Core.WRITE_CALIBRATION(cal);
            #endif

                                   FireEvent(cal);
                                    break;
                                case ResponseTypes.BTCAL_RSP:
                                    BTCAL_RSP btcal = new BTCAL_RSP(this._ID);
                                    for (int i = 0; (i < bytesToRead); i++)
                                        btcal.RawBytes[i] = this.packet[i];
                                    btcal._CAL100 = ((this.packet[1] & 0x7f) << 3) | ((this.packet[2] & 0x70) >> 4);
                                    btcal._CAL80 = ((this.packet[2] & 0x0f) << 6) | ((this.packet[3] & 0x7e) >> 1);
                                    btcal._CAL60 = ((this.packet[3] & 0x01) << 9) | ((this.packet[4] & 0x7f) << 2) | ((this.packet[5] & 0x60) >> 5);
                                    btcal._CAL40 = ((this.packet[5] & 0x1f) << 5) | ((this.packet[6] & 0x7c) >> 2);
                                    btcal._CAL20 = ((this.packet[6] & 0x03) << 8) | ((this.packet[7] & 0x7f) << 1) | ((this.packet[8] & 0x40) >> 6);
                                    btcal._CAL10 = ((this.packet[8] & 0x3f) << 4) | ((this.packet[9] & 0x78) >> 3);
                                    FireEvent(btcal);
                                    break;
                                case ResponseTypes.SR_RSP:
                                    SR_RSP sr = new SR_RSP(this._ID);
                                    for (int i = 0; (i < bytesToRead); i++)
                                        sr.RawBytes[i] = this.packet[i];
                                    sr._SamplingRate= (this.packet[1]&0x7f);
                                    this._ExpectedSamplingRate = sr._SamplingRate;
            #if (PocketPC)
                                    Core.WRITE_SAMPLING_RATE(sr);
            #endif
                                    FireEvent(sr);
                                    break;
                                case ResponseTypes.BP_RSP:
                                    BP_RSP bp = new BP_RSP(this._ID);
                                    for (int i = 0; (i < bytesToRead); i++)
                                        bp.RawBytes[i] = this.packet[i];
                                    bp._Percent= (this.packet[1] & 0x7f);
            #if (PocketPC)
                                    Core.WRITE_BATTERY_PERCENT(bp);
            #endif
                                    FireEvent(bp);
                                    break;
                                case ResponseTypes.TM_RSP:
                                    TM_RSP tm = new TM_RSP(this._ID);
                                    for (int i = 0; (i < bytesToRead); i++)
                                        tm.RawBytes[i] = this.packet[i];
                                    tm._TransmissionMode = (TransmissionMode)((this.packet[1]>>4) & 0x07);
            #if (PocketPC)
                                    Core.WRITE_TRANSMISSION_MODE(tm);
            #endif
                                    FireEvent(tm);
                                    break;

                                case ResponseTypes.SENS_RSP:
                                    SENS_RSP sen = new SENS_RSP(this._ID);
                                    for (int i = 0; (i < bytesToRead); i++)
                                        sen.RawBytes[i] = this.packet[i];
                                    sen._Sensitivity = (Sensitivity)((this.packet[1] >> 4) & 0x07);
            #if (PocketPC)
                                    Core.WRITE_SENSITIVITY(sen);
            #endif
                                    FireEvent(sen);
                                    break;
                                case ResponseTypes.PC_RSP:
                                    PC_RSP pc = new PC_RSP(this._ID);
                                    for (int i = 0; (i < bytesToRead); i++)
                                        pc.RawBytes[i] = this.packet[i];
                                    pc._Count = ((this.packet[1] & 0x7f) << 25) | ((this.packet[2] & 0x7f) << 18) | ((this.packet[3] & 0x7f) << 11) | ((this.packet[4] & 0x7f) << 4) | ((this.packet[5] & 0x7f) >> 3);
            #if (PocketPC)
                                    Core.WRITE_PDU_COUNT(pc);
            #endif
                                    FireEvent(pc);
                                    break;
                                case ResponseTypes.PDT_RSP:
                                    PDT_RSP pdt = new PDT_RSP(this._ID);
                                    for (int i = 0; (i < bytesToRead); i++)
                                        pdt.RawBytes[i] = this.packet[i];
                                    pdt._Timeout = (this.packet[1] & 0x7f);
                                    FireEvent(pdt);
                                    break;

                                case ResponseTypes.HV_RSP:
                                    HV_RSP hv = new HV_RSP(this._ID);
                                    for (int i = 0; (i < bytesToRead); i++)
                                        hv.RawBytes[i] = this.packet[i];
                                    hv._Version = (this.packet[1] & 0x7f);
                                    FireEvent(hv);
                                    break;
                                case ResponseTypes.FV_RSP:
                                    FV_RSP fv = new FV_RSP(this._ID);
                                    for (int i = 0; (i < bytesToRead); i++)
                                        fv.RawBytes[i] = this.packet[i];
                                    fv._Version = (this.packet[1] & 0x7f);
                                    Logger.Debug(this._ID + "," + fv._Version);
                                    FireEvent(fv);
                                    break;
                                case ResponseTypes.BC_RSP:
                                    BC_RSP bc = new BC_RSP(this._ID);
                                    for (int i = 0; (i < bytesToRead); i++)
                                        bc.RawBytes[i] = this.packet[i];
                                    bc._Count = ((this.packet[1] & 0x7f) << 7) | (this.packet[2] & 0x7f);
                                    this._ExpectedBatchCount = bc._Count;
                                    //Compute the start time and delta for timestamping the data
                                    double calculated_startTime=((RFCOMMReceiver)CurrentWockets._Controller._Receivers[this._ID])._CurrentConnectionUnixTime;
                                    //attempt correcting using the sampling rate, check if the
                                    // first sample has a timestamp greater than the last timestamped
                                    // sample... if that is the case continue
                                    // if it is not the case then temporarily alter the delta value
                                    // to fit within the start time and end time for the samples
                                    // this is necessary to avoid overspreading the samples when disconnections
                                    // occur
                                    calculated_startTime -= ((1000.0 / this._ExpectedSamplingRate) * bc._Count);

                                    // Only use the ideal sampling rate to spread out the signal if
                                    // there is a huge gap with the previous transmission
                                    if ((calculated_startTime > lastDecodedSampleTime) && ((calculated_startTime - lastDecodedSampleTime) >60000))
                                    {
                                        batchCurrentTime = calculated_startTime;
                                        batchDeltaTime = 1000.0 / this._ExpectedSamplingRate;
                                    }
                                    else
                                    {
                                        batchDeltaTime = (((RFCOMMReceiver)CurrentWockets._Controller._Receivers[this._ID])._CurrentConnectionUnixTime - lastDecodedSampleTime) / bc._Count;
                                        batchCurrentTime = lastDecodedSampleTime+batchDeltaTime;
                                    }
                                    lastDecodedSampleTime = ((RFCOMMReceiver)CurrentWockets._Controller._Receivers[this._ID])._CurrentConnectionUnixTime;
                                    FireEvent(bc);
                                    break;

                                case ResponseTypes.AC_RSP:
                                    AC_RSP ac = new AC_RSP(this._ID);
                                    for (int i = 0; (i < bytesToRead); i++)
                                        ac.RawBytes[i] = this.packet[i];

                                    ac._SeqNum = ((this.packet[1] & 0x7f) << 9) | ((this.packet[2] & 0x7f) << 2) | ((this.packet[3] >> 5) & 0x03);
                                    ac._Count = ((this.packet[3] & 0x1f) << 11) | ((this.packet[4] & 0x7f)<<4) | ((this.packet[5]>>2)&0x0f);

                                    //to recover from resets
                                    if ((this._LastActivityCountIndex!=-1) && (ac._SeqNum==0) && (((this._ActivityCounts[this._LastActivityCountIndex]._SeqNum)- ac._SeqNum)>20))
                                        this._LastActivityCountIndex = -1;

                                    /*if ((this._LastActivityCountIndex==-1) //First time base it on the sampling rate
                                        || (acc_count<this._ActivityCounts[this._LastActivityCountIndex]._SeqNum))  //accidental reset

                                    {
                                        ac_unixtime=((RFCOMMReceiver)CurrentWockets._Controller._Receivers[this._ID])._CurrentConnectionUnixTime - ((this._ActivityCountOffset * 1000.0)/this._ExpectedSamplingRate) - (acc_count* 60000.0);
                                        ac_delta=60000.0;
                                        ac_refseq=0;
                                    }
                                    else if (ac_delta == 0) //First sample after ACC, handles overflow as well
                                    {
                                          ac_unixtime = this._ActivityCounts[this._LastActivityCountIndex]._TimeStamp;
                                          ac_refseq = this._ActivityCounts[this._LastActivityCountIndex]._SeqNum;
                                          ac_delta = (((RFCOMMReceiver)CurrentWockets._Controller._Receivers[this._ID])._CurrentConnectionUnixTime - ((this._ActivityCountOffset * 1000.0) / this._ExpectedSamplingRate) - this._ActivityCounts[this._LastActivityCountIndex]._TimeStamp) / (acc_count - ac_refseq);
                                    }*/

                                    ac._TimeStamp = (double)timestamps[ac._SeqNum];
                                    //Has to stay here to protect against situations when a batch is sent
                                    //with some ACs that were received and others that were not
                                    //ac._TimeStamp = ac_unixtime + (++_ACIndex * ac_delta);
                                    ++_ACIndex;
                                    //ac._TimeStamp = ac_unixtime + (((ac._SeqNum-ac_refseq)+1) * ac_delta);
            #if (PocketPC)
                                    if (_ACIndex == 10)
                                    {
                                        ((RFCOMMReceiver)CurrentWockets._Controller._Receivers[this._ID]).Write(new Wockets.Data.Commands.ACK()._Bytes);
                                        _ACIndex = 0;
                                    }
            #endif
                                    //Only insert new sequence numbers
                                    // if this is the first AC or it is not equal to the previous sequence number
                                    if ((this._ActivityCountOffset >= 0) && (acc_count >= 0))
                                    {
                                        if ((this._LastActivityCountIndex == -1) || (ac._SeqNum == (this._ActivityCounts[this._LastActivityCountIndex]._SeqNum + 1)) || ((ac._SeqNum - this._ActivityCounts[this._LastActivityCountIndex]._SeqNum + 1) > 960))
                                        {
                                            this._LastActivityCountIndex = this._ActivityCountIndex;
                                            this._ActivityCounts[this._ActivityCountIndex++] = ac;
                                            if (this._ActivityCountIndex == 960)
                                                this._ActivityCountIndex = 0;

            #if (PocketPC)
                                            Core.WRITE_ACTIVITY_COUNT(ac);
            #endif
                                        }
                                    }

                                    Logger.Warn("ACC"+this._ID+","+acc_count+","+this._ActivityCounts[this._LastActivityCountIndex]._SeqNum+"," + ac._SeqNum + "," + ac._Count);
                                    FireEvent(ac);
                                    break;

                                case ResponseTypes.TCT_RSP:
                                    TCT_RSP tct = new TCT_RSP(this._ID);
                                    for (int i = 0; (i < bytesToRead); i++)
                                        tct.RawBytes[i] = this.packet[i];
                                    tct._TCT = (((this.packet[1] & 0x7f) << 1) | ((this.packet[2] >> 6) & 0x01));
                                    tct._REPS = (((this.packet[2] & 0x3f) << 2) | ((this.packet[3] >> 5) & 0x03));
                                    tct._LAST = (((this.packet[3] & 0x1f) << 3) | ((this.packet[4] >> 4) & 0x07));
            #if (PocketPC)
                                    Core.WRITE_TCT(tct);
            #endif
                                    FireEvent(tct);
                                    break;

                                case ResponseTypes.ACC_RSP:
                                    ACC_RSP acc = new ACC_RSP(this._ID);
                                    for (int i = 0; (i < bytesToRead); i++)
                                        acc.RawBytes[i] = this.packet[i];
                                    acc._Count = ((this.packet[1] & 0x7f) << 7) | (this.packet[2] & 0x7f);
                                    ac_unixtime = 0;
                                    ac_delta = 0;
                                    _ACIndex = 0;
                                    acc_count=acc._Count;

                                    // this._ActivityCounts[this._LastActivityCountIndex]._TimeStamp;
                                    if ((this._LastActivityCountIndex == -1) //First time base it on the sampling rate
                                        || (acc_count < this._ActivityCounts[this._LastActivityCountIndex]._SeqNum))  //accidental reset
                                    {
                                        ac_unixtime = ((RFCOMMReceiver)CurrentWockets._Controller._Receivers[this._ID])._CurrentConnectionUnixTime - ((this._ActivityCountOffset * 1000.0) / this._ExpectedSamplingRate);
                                        ac_delta = 60000.0;
                                        ac_refseq = 0;
                                        timestamps = new Hashtable();
                                    }
                                    else if (ac_delta == 0) //First sample after ACC, handles overflow as well
                                    {
                                        ac_unixtime = ((RFCOMMReceiver)CurrentWockets._Controller._Receivers[this._ID])._CurrentConnectionUnixTime - ((this._ActivityCountOffset * 1000.0) / this._ExpectedSamplingRate);
                                        ac_delta = (((RFCOMMReceiver)CurrentWockets._Controller._Receivers[this._ID])._CurrentConnectionUnixTime - ((this._ActivityCountOffset * 1000.0) / this._ExpectedSamplingRate) - this._ActivityCounts[this._LastActivityCountIndex]._TimeStamp) /(acc_count - this._ActivityCounts[this._LastActivityCountIndex]._SeqNum);
                                    }

                                    for (int i = acc._Count; (i >= 0); i--)
                                    {
                                        if (timestamps.ContainsKey(i))
                                            break;
                                        else
                                            timestamps.Add(i, ac_unixtime - ((acc._Count-i)*ac_delta));
                                    }

                                    FireEvent(acc);
                                    break;
                                case ResponseTypes.OFT_RSP:
                                    OFT_RSP offset = new OFT_RSP(this._ID);
                                    for (int i = 0; (i < bytesToRead); i++)
                                        offset.RawBytes[i] = this.packet[i];
                                    offset._Offset = ((this.packet[1] & 0x7f) << 7) | (this.packet[2] & 0x7f);
                                    this._ActivityCountOffset = offset._Offset;
                                    FireEvent(offset);
                                    break;
                                default:
                                    break;
                            }

                        }

                        this.packetPosition = 0;
                        this.headerSeen = false;

                    }

            }
            return numDecodedPackets;
        }
Пример #41
0
        public string GetFromTextCommand(string command, string mustFind, bool canBeEmpty, ResponseTypes responseType, bool includeConnectionTest = true)
        {
            try
            {
                if (includeConnectionTest)
                {
                    if (!_isConnected)
                        Connect();
                    if (!_isConnected)
                        return null;
                }

                int retries = 0;
            retry:

                SendTextCommand(command, includeConnectionTest);

                string response = GetFromTextCommand(includeConnectionTest);

                if (!response.StartsWith(((int)responseType).ToString() + "-"))
                    if (retries >= MAX_RETRY_COUNT)
                        return null;
                    else
                    {
                        retries++;
                        goto retry;
                    }

                if (responseType == ResponseTypes.Multiline)
                {
                    while (!response.EndsWith(".\r\n"))
                    {
                        string newResponse = GetFromTextCommand(includeConnectionTest);

                        response += newResponse;
                    }

                    if (!response.StartsWith("202"))
                        response = "";

                    if (canBeEmpty && response.EndsWith(".\r\n"))
                        return response;

                    if (!response.Contains(mustFind))
                    {
                        if (retries >= MAX_RETRY_COUNT)
                            return null;
                        else
                        {
                            retries++;
                            goto retry;
                        }
                    }
                }

                return response;
            }
            catch { return null; }
        }
Пример #42
0
 public Response(byte numRawBytes,ResponseTypes type, byte sensorID)
     : base(numRawBytes,SensorDataType.RESPONSE_PDU,sensorID)
 {
     _Type = type;
 }
Пример #43
0
		public WebResponse(ResponseTypes type)
		{
			this.Type = type;
		}