Beispiel #1
0
        public IntoAST(string textfile)
        {
            maintodo = new List <IChildMainFile>();

            /*  Clean string    */
            // Newline to spaces
            string cleaned = textfile.Replace("\n", " ");

            // Tabs to spaces
            cleaned = cleaned.Replace("\t", " ");
            // Split by spaces
            string[] parts = cleaned.Split(new char[] { ' ' });
            // Remove empty parts (aka "")
            parts = parts.ToList().FindAll(p => p != null && (p != "")).ToArray();

            // Save context
            string context = "mainfile";

            // For every part
            for (int i = 0; i < parts.Length;)
            {
                // Identify next statement
                IdentifyResponse ir = Identify(context, "", parts, i);

                // Go to next statement
                i = ir.next;

                // Add to main todo
                maintodo.Add(ir.IChild as IChildMainFile);
            }
        }
        private void Handshake(NetworkStream stream, FrameReader reader)
        {
            // Initiate the V2 protocol
            stream.Write(MagicV2, 0, MagicV2.Length);
            _identifyResponse = Identify(stream, reader);
            if (_identifyResponse.AuthRequired)
            {
                Dispose();
                throw new NotSupportedException("Authorization is not supported");
            }

            SendCommandToStream(stream, new Subscribe(_options.Topic, _options.Channel));
        }
        private async Task PerformHandshake()
        {
            await WriteProtocolCommand(new ProtocolVersion())
            .ConfigureAwait(false);

            if (this.options is NsqConsumerOptions consumerOptions)
            {
                await WriteProtocolCommand(new IdentifyCommand(consumerOptions.MsgTimeout))
                .ConfigureAwait(false);
            }
            else
            {
                await WriteProtocolCommand(new IdentifyCommand())
                .ConfigureAwait(false);
            }

            Frame frame = await this.reader.ReadNext().ConfigureAwait(false);

            if (frame is ErrorFrame errorFrame)
            {
                throw new NsqException("Error during handshake: " + errorFrame.Message);
            }
            else if (frame is ResponseFrame responseFrame)
            {
                this.identify = IdentifyResponse.ParseWithFrame(responseFrame);

                if (this.identify.AuthRequired)
                {
                    throw new NsqException("Authentication is not supported");
                }
            }
            else
            {
                throw new NsqException("Unexpected response during handshake");
            }
        }
 public abstract void OnIdentificationFailure(IdentifyResponse identifyResponse);
Beispiel #5
0
        public async Task <IdentifyResponse> IdentifyChild(FPCaptureRs vm)
        {
            IdentifyResponse returnModel = new IdentifyResponse();
            IdentifyRequest  request     = new IdentifyRequest();

            request.Id = Guid.NewGuid();
            request.FingerprintRecord                              = new DsdAfis.Core.FingerBiometrics.FingerprintRecord();
            request.FingerprintRecord.Id                           = 0;
            request.FingerprintRecord.Active                       = false;
            request.FingerprintRecord.DateTime                     = DateTime.Now;
            request.FingerprintRecord.FingerprintSet               = new DsdAfis.Core.FingerBiometrics.FingerprintSet();
            request.FingerprintRecord.FingerprintSet.Dpi           = 500;
            request.FingerprintRecord.FingerprintSet.ImageEncoding = "WSQ";
            request.FingerprintRecord.FingerprintSet.ImageHeight   = 512;
            request.FingerprintRecord.FingerprintSet.ImageWidth    = 512;
            List <Fingerprint> fingers     = new List <Fingerprint>();
            Fingerprint        blankFinger = null;

            fingers.Add(blankFinger);
            foreach (Finger f in vm.Fingers)
            {
                if (f.Sequence > 0)
                {
                    Fingerprint finger = new Fingerprint();
                    switch (f.Name)
                    {
                    case "1":
                        finger.Code = FingerCode.RightThumb;
                        break;

                    case "6":
                        finger.Code = FingerCode.LeftThumb;
                        break;
                    }
                    finger.EncodedImage = f.Print;
                    fingers.Add(finger);
                }
                else
                {
                    fingers.Add(null);
                }
            }
            request.FingerprintRecord.FingerprintSet.Fingerprints = fingers.ToArray();

            using (var client = new HttpClient())
            {
                //Passing service base url
                client.BaseAddress = new Uri(ConfigurationManager.AppSettings["WebApiUrl"]);

                client.DefaultRequestHeaders.Clear();
                //Define request data format
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                HttpResponseMessage response = await client.PostAsync(
                    "api/afis/identify", new StringContent(request.Json, Encoding.UTF8, "application/json"));

                if (response.IsSuccessStatusCode)
                {
                    return(MessageBase.Deserialize <IdentifyResponse>(response.Content.ReadAsStringAsync().Result));
                }
                else
                {
                    return(returnModel);
                }
            }
        }