Beispiel #1
0
 internal void MarkAsMatchedBySetup()          // this supports the `mock.VerifyAll()` machinery
 {
     if (this.verificationState == VerificationState.Invoked)
     {
         this.verificationState = VerificationState.InvokedAndMatchedBySetup;
     }
 }
Beispiel #2
0
 internal void MarkAsVerifiedIfMatchedByVerifiableSetup()          // this supports the `mock.Verify()` machinery
 {
     if (this.verificationState == VerificationState.InvokedAndMatchedByVerifiableSetup)
     {
         this.verificationState = VerificationState.Verified;
     }
 }
        public static string VerificationToString(VerificationState state)
        {
            switch (state)
            {
            case VerificationState.NotVerified:
                return("Oczekujący");

            case VerificationState.Accepted:
                return("Zaakceptowany");

            case VerificationState.Rejected:
                return("Odrzucony");

            default:
                return("Brak");
            }
        }
Beispiel #4
0
        // -------------------------------------------------------------
        //	validate means verify
        private string                                  Validate(string jsonCmd)
        {
            string          jsonResult;
            JObject         cmdObject = JObject.Parse(jsonCmd);
            PaddleProductID prodID    = cmdObject.Value <PaddleProductID>(kPaddleCmdKey_SKU);
            PaddleProduct   product   = Paddle_GetProduct(prodID);

            if (!product.Activated)
            {
                VerificationState state;

                if (product.TrialDaysRemaining > 0)
                {
                    state = VerificationState.Verified;
                }
                else
                {
                    state = VerificationState.NoActivation;
                }

                CJsonResult jResult = new CJsonResult {
                    successB = state == VerificationState.Verified,
                    resultI  = Convert.ToInt32(state)
                };

                jsonResult = CreateJsonResult(jResult);
            }
            else
            {
                DateTime lastSuccessDateT   = product.LastSuccessfulVerifiedDate;
                TimeSpan spanSinceSuccessT  = DateTime.Now - lastSuccessDateT;
                double   hoursSinceSuccessT = spanSinceSuccessT.TotalHours;

                // Verify the activation only if it's been a while.
                if (hoursSinceSuccessT < 1)
                {
                    CJsonResult jResult = new CJsonResult {
                        successB = true,
                        resultI  = Convert.ToInt32(VerificationState.Verified)
                    };

                    // No need to verify. The product is activated. All's well.
                    jsonResult = CreateJsonResult(jResult);
                }
                else
                {
                    ScTask task = new ScTask();

                    product.VerifyActivation(
                        (PaddleSDK.Product.VerificationState in_state, string resultStr) =>
                    {
                        VerificationState state = (VerificationState)in_state;
                        bool destroyB           = false;

                        switch (state)
                        {
                        case VerificationState.Unverified: {
                            // The activation is no longer valid. Destroy it, let the user know and continue with
                            // the trial.
                            destroyB = true;
                        } break;

                        case VerificationState.UnableToVerify: {
                            // Verify that the last successful verify date is valid.
                            // And then implement a cooldown strategy.

                            // Ensure that the last successful verified date appears valid.
                            // As `compare:` "detects sub-second differences" the dates should not be the same.
                            // Equally we can't have verified the activation in the future.
                            //	future dates have a negative time span since now:
                            if (hoursSinceSuccessT < 0)
                            {
                                // The last successfully verified date does not seem valid. If the time difference
                                // is less than 24 hours, a timezone change is possible. Other than that, tampering
                                // seems likely.
                                //
                                // In doubt, destroy the activation and ask the user to reactivate.
                                destroyB = true;
                            }

                            // Implement a cooldown period: if the user has not gone online within the period,
                            // then destroy the activation and ask them to go online to re-activate.
                            double daysSinceSuccessT = spanSinceSuccessT.TotalDays;

                            if (daysSinceSuccessT >= 30)
                            {
                                destroyB = true;
                            }
                            else
                            {
                                // The grace period continues, so the user can continue to use the core functionality.
                                state = VerificationState.Verified;
                            }
                        } break;
                        }

                        if (destroyB)
                        {
                            product.DestroyActivation();
                            state = VerificationState.Unverified;
                        }

                        CJsonResult jResult = new CJsonResult {
                            successB = state == VerificationState.Verified,
                            resultI  = Convert.ToInt32(state),
                            errStr   = resultStr
                        };

                        task.set_result(CreateJsonResult(jResult));
                    });

                    jsonResult = task.await_result();
                }
            }

            return(jsonResult);
        }
Beispiel #5
0
        static void bfr_FrameArrived(object sender, BodyFrameArrivedEventArgs e)
        {
            bool dataReceived = false;

            using (BodyFrame bodyFrame = e.FrameReference.AcquireFrame())
            {
                if (bodyFrame != null)
                {
                    if (bodies == null)
                    {
                        bodies = new Body[bodyFrame.BodyCount];
                    }

                    // The first time GetAndRefreshBodyData is called, Kinect will allocate each Body in the array.
                    // As long as those body objects are not disposed and not set to null in the array,
                    // those body objects will be re-used.
                    bodyFrame.GetAndRefreshBodyData(bodies);
                    dataReceived = true;
                }
            }

            if (dataReceived)
            {
                foreach (Body body in bodies)
                {
                    if (body.IsTracked)
                    {
                        IReadOnlyDictionary <JointType, Joint> joints = body.Joints;
                        Dictionary <string, float>             person = new Dictionary <string, float>();

                        person.Add("neck", BoneLength(joints, JointType.Neck, JointType.Head));
                        person.Add("left_shin", BoneLength(joints, JointType.AnkleLeft, JointType.KneeLeft));
                        person.Add("right_shin", BoneLength(joints, JointType.AnkleRight, JointType.KneeRight));
                        person.Add("left_thigh", BoneLength(joints, JointType.KneeLeft, JointType.HipLeft));
                        person.Add("right_thigh", BoneLength(joints, JointType.KneeRight, JointType.HipRight));
                        person.Add("forearm_left", BoneLength(joints, JointType.HandLeft, JointType.ElbowLeft));
                        person.Add("forearm_right", BoneLength(joints, JointType.HandRight, JointType.ElbowRight));
                        person.Add("upperarm_left", BoneLength(joints, JointType.ShoulderLeft, JointType.ElbowLeft));
                        person.Add("upperarm_right", BoneLength(joints, JointType.ShoulderRight, JointType.ElbowRight));
                        person.Add("spine_lower", BoneLength(joints, JointType.SpineBase, JointType.SpineMid));
                        person.Add("spine_upper", BoneLength(joints, JointType.SpineShoulder, JointType.SpineMid));
                        person.Add("shoulder_width", BoneLength(joints, JointType.ShoulderLeft, JointType.ShoulderRight));
                        person.Add("hip_width", BoneLength(joints, JointType.HipLeft, JointType.HipRight));

                        float height = person["left_shin"] + person["left_thigh"] + person["spine_lower"] + person["spine_upper"] + person["neck"];
                        person.Add("height", height);

                        string[] limbs = { "left_thigh", "right_thigh", "left_shin", "right_shin", "spine_upper", "spine_lower", "forearm_left", "forearm_right", "upperarm_left", "upperarm_right", "neck", "shoulder_width", "hip_width", "height" };

                        if (body.HandLeftState == HandState.Closed && body.HandRightState == HandState.Open && verificationState == VerificationState.Verifying)
                        {
                            enrolmentModeCounter++;

                            if (enrolmentModeCounter >= 10)
                            {
                                Console.WriteLine("Starting enrolment;");
                                verificationState = VerificationState.StartEnrolment;
                                enrolmentData.Clear();
                            }
                        }
                        else
                        {
                            enrolmentModeCounter = 0;
                        }

                        if (body.HandLeftState == HandState.Open && body.HandRightState == HandState.Closed && verificationState == VerificationState.CollectingData)
                        {
                            Dictionary <string, float> model = new Dictionary <string, float>();

                            if (enrolmentData.Count >= 50)
                            {
                                Console.WriteLine("Enrolment complete.");
                                verificationState = VerificationState.Verifying;

                                model.Clear();

                                //  add up the values for all parts
                                foreach (var datapoint in enrolmentData)
                                {
                                    bool voidReading = false;

                                    foreach (var part in datapoint.Keys)
                                    {
                                        if (datapoint[part] == -1)
                                        {
                                            voidReading = true;
                                            break;
                                        }
                                    }

                                    if (voidReading)
                                    {
                                        continue;
                                    }

                                    foreach (var part in person.Keys)
                                    {
                                        if (model.ContainsKey(part))
                                        {
                                            model[part] += datapoint[part];
                                        }
                                        else
                                        {
                                            model.Add(part, datapoint[part]);
                                        }
                                    }
                                }

                                //  calculate the average
                                //  the +1 is because the last reading was still present in person

                                foreach (string limb in limbs)
                                {
                                    //  Convert from meters to cm
                                    model[limb] = model[limb] * 100;
                                    model[limb] = model[limb] / enrolmentData.Count;
                                }

                                //  Save the averaged data
                                SaveData(model, name);
                            }
                            else
                            {
                                Console.WriteLine("Saving data at {0}", DateTime.Now.ToFileTime());
                                //SaveData(person, name);
                                enrolmentData.Add(person);
                            }
                        }

                        switch (verificationState)
                        {
                        case VerificationState.StartEnrolment:
                            Console.WriteLine("Please enter your name:");
                            name = Console.ReadLine();
                            Console.WriteLine("{0} entered", name);
                            verificationState = VerificationState.CollectingData;
                            break;

                        case VerificationState.Verifying:
                            VerifySkeleton(person, limbs);
                            break;
                        }

                        //Console.WriteLine("{0},{1},{2}", person["neck"], person["shin_left"], person["shin_right"]);
                    }
                }
            }
        }
Beispiel #6
0
 internal void MarkAsVerified() => this.verificationState = VerificationState.Verified;
Beispiel #7
0
 public SSMLValidationError(VerificationState state, string error = null)
 {
     State = state;
     Error = error;
 }
 public Account(string inLegacyAddress, string inMessageToBeSigned)
 {
     LegacyAddress            = BitcoinAddress.Create(inLegacyAddress, Network.Main);
     messageToBeSigned        = inMessageToBeSigned;
     currentVerificationState = VerificationState.unverified;
 }
Beispiel #9
0
        static void bfr_FrameArrived(object sender, BodyFrameArrivedEventArgs e)
        {
            bool dataReceived = false;

            using (BodyFrame bodyFrame = e.FrameReference.AcquireFrame())
            {
                if (bodyFrame != null)
                {
                    if (bodies == null)
                    {
                        bodies = new Body[bodyFrame.BodyCount];
                    }

                    // The first time GetAndRefreshBodyData is called, Kinect will allocate each Body in the array.
                    // As long as those body objects are not disposed and not set to null in the array,
                    // those body objects will be re-used.
                    bodyFrame.GetAndRefreshBodyData(bodies);
                    dataReceived = true;
                }
            }

            if (dataReceived)
            {
                foreach (Body body in bodies)
                {
                    if (body.IsTracked)
                    {
                        IReadOnlyDictionary<JointType, Joint> joints = body.Joints;
                        Dictionary<string, float> person = new Dictionary<string, float>();

                        person.Add("neck", BoneLength(joints, JointType.Neck, JointType.Head));
                        person.Add("left_shin", BoneLength(joints, JointType.AnkleLeft, JointType.KneeLeft));
                        person.Add("right_shin", BoneLength(joints, JointType.AnkleRight, JointType.KneeRight));
                        person.Add("left_thigh", BoneLength(joints, JointType.KneeLeft, JointType.HipLeft));
                        person.Add("right_thigh", BoneLength(joints, JointType.KneeRight, JointType.HipRight));
                        person.Add("forearm_left", BoneLength(joints, JointType.HandLeft, JointType.ElbowLeft));
                        person.Add("forearm_right", BoneLength(joints, JointType.HandRight, JointType.ElbowRight));
                        person.Add("upperarm_left", BoneLength(joints, JointType.ShoulderLeft, JointType.ElbowLeft));
                        person.Add("upperarm_right", BoneLength(joints, JointType.ShoulderRight, JointType.ElbowRight));
                        person.Add("spine_lower", BoneLength(joints, JointType.SpineBase, JointType.SpineMid));
                        person.Add("spine_upper", BoneLength(joints, JointType.SpineShoulder, JointType.SpineMid));
                        person.Add("shoulder_width", BoneLength(joints, JointType.ShoulderLeft, JointType.ShoulderRight));
                        person.Add("hip_width", BoneLength(joints, JointType.HipLeft, JointType.HipRight));

                        float height = person["left_shin"] + person["left_thigh"] + person["spine_lower"] + person["spine_upper"] + person["neck"];
                        person.Add("height", height);

                        string[] limbs = { "left_thigh", "right_thigh", "left_shin", "right_shin", "spine_upper", "spine_lower", "forearm_left", "forearm_right", "upperarm_left", "upperarm_right", "neck", "shoulder_width", "hip_width", "height" };

                        if (body.HandLeftState == HandState.Closed && body.HandRightState == HandState.Open && verificationState == VerificationState.Verifying)
                        {
                            enrolmentModeCounter++;

                            if (enrolmentModeCounter >= 10)
                            {
                                Console.WriteLine("Starting enrolment;");
                                verificationState = VerificationState.StartEnrolment;
                                enrolmentData.Clear();
                            }
                        }
                        else
                        {
                            enrolmentModeCounter = 0;
                        }

                        if (body.HandLeftState == HandState.Open && body.HandRightState == HandState.Closed && verificationState == VerificationState.CollectingData)
                        {
                            Dictionary<string, float> model = new Dictionary<string, float>();

                            if (enrolmentData.Count >= 50)
                            {
                                Console.WriteLine("Enrolment complete.");
                                verificationState = VerificationState.Verifying;

                                model.Clear();

                                //  add up the values for all parts
                                foreach (var datapoint in enrolmentData)
                                {
                                    bool voidReading = false;

                                    foreach (var part in datapoint.Keys)
                                    {
                                        if(datapoint[part] == -1)
                                        {
                                            voidReading = true;
                                            break;
                                        }
                                    }

                                    if (voidReading)
                                    {
                                        continue;
                                    }

                                    foreach (var part in person.Keys)
                                    {
                                        if (model.ContainsKey(part))
                                        {
                                            model[part] += datapoint[part];
                                        }
                                        else
                                        {
                                            model.Add(part, datapoint[part]);
                                        }
                                    }
                                }

                                //  calculate the average
                                //  the +1 is because the last reading was still present in person

                                foreach (string limb in limbs)
                                {
                                    //  Convert from meters to cm
                                    model[limb] = model[limb] * 100;
                                    model[limb] = model[limb] / enrolmentData.Count;
                                }

                                //  Save the averaged data
                                SaveData(model,name);

                            }
                            else
                            {
                                Console.WriteLine("Saving data at {0}", DateTime.Now.ToFileTime());
                                //SaveData(person, name);
                                enrolmentData.Add(person);
                            }
                        }

                        switch (verificationState)
                        {
                            case VerificationState.StartEnrolment:
                                Console.WriteLine("Please enter your name:");
                                name = Console.ReadLine();
                                Console.WriteLine("{0} entered", name);
                                verificationState = VerificationState.CollectingData;
                                break;
                            case VerificationState.Verifying:
                                VerifySkeleton(person, limbs);
                                break;
                        }

                        //Console.WriteLine("{0},{1},{2}", person["neck"], person["shin_left"], person["shin_right"]);
                    }
                }
            }
        }