Пример #1
0
        public PoseMatchingPage(Patient.MotionItem mi, Patient.UserInfo ui)
        {
            InitializeComponent();

            motion = mi;
            Console.WriteLine(motion.Repetition);
            userInfo = ui;

            readFromFile();
            first_pose   = (BodyWrapper)savedPose[0];
            last_pose    = (BodyWrapper)savedPose[savedPose.Count - 1];
            current_pose = first_pose;


            Console.WriteLine("# of poses found : " + savedPose.Count);
            _sensor = KinectSensor.GetDefault();

            if (_sensor != null)
            {
                _sensor.Open();

                _reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.Infrared | FrameSourceTypes.Body);
                _reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived;

                _matching = new PoseMatching
                {
                    CheckHead     = false,
                    CheckLegLeft  = false,
                    CheckLegRight = false,
                    CheckArmLeft  = true,
                    CheckArmRight = true,
                    CheckSpine    = false
                };
            }
        }
Пример #2
0
        private void RenderBody(BodyWrapper body, ECameraType cameraType)
        {
            BodyDrawing bodyDrawing = BodyHelper.Instance.BodyDrawings.Where(x => x.TrackingId == body.TrackingId).FirstOrDefault();
            bool        isNewBody   = false;

            if (bodyDrawing == null)
            {
                bodyDrawing = new BodyDrawing(body, cameraType);
                BodyHelper.Instance.BodyDrawings.Add(bodyDrawing);
                isNewBody = true;
            }
            else
            {
                bodyDrawing.Update(body, cameraType);
            }

            if (_canvasCleared || isNewBody)
            {
                List <Ellipse> ellipses = bodyDrawing.JointEllipses.Select(x => x.Value).ToList();
                foreach (Ellipse ellipse in ellipses)
                {
                    canvasSkeleton.Children.Add(ellipse);
                }

                List <Line> lines = bodyDrawing.BoneLines.Select(x => x.Value).ToList();
                foreach (Line line in lines)
                {
                    canvasSkeleton.Children.Add(line);
                }

                _canvasCleared = false;
            }
        }
Пример #3
0
    public void UpdateBody(BodyWrapper body, FrameView frameView)
    {
        if (!Initialized)
        {
            return;
        }

        Mirrored = frameView.MirroredView;

        for (int i = 0; i < controller.JointCount(); i++)
        {
            Vector2 position = body.Map2D[controller.GetJointType(i)].ToVector2();

            if (float.IsInfinity(position.x))
            {
                position.x = 0f;
            }

            if (float.IsInfinity(position.y))
            {
                position.y = 0f;
            }

            frameView.SetPositionOnFrame(ref position);

            controller.SetJointPosition(i, smoothJoints ? Vector3.Lerp(controller.GetJointPosition(i), position, smoothness) : (Vector3)position);
        }

        UpdateLines();
    }
Пример #4
0
    void RefreshFrame(BodyWrapper body)
    {
        if (body != null)
        {
            if (faceFrameReader != null)
            {
                if (!faceFrameSource.IsTrackingIdValid)
                {
                    faceFrameSource.TrackingId = body.TrackingId;
                }

                using (var faceFrame = faceFrameReader.AcquireLatestFrame())
                {
                    if (faceFrame != null)
                    {
                        face = faceFrame.Face();

                        if (face != null)
                        {
                            if (!detailedFace.gameObject.activeSelf)
                            {
                                detailedFace.gameObject.SetActive(true);
                            }

                            detailedFace.UpdateFace(face, frameView, visualization, KinectSensor.CoordinateMapper);
                        }
                        else if (detailedFace.gameObject.activeSelf)
                        {
                            detailedFace.gameObject.SetActive(false);
                        }
                    }
                }
            }
        }
    }
Пример #5
0
        private void processFile(string file)
        {
            String      json_file = File.ReadAllText(file);
            BodyWrapper bw2       = JsonConvert.DeserializeObject <BodyWrapper>(json_file);

            savedPose.Add(bw2);
        }
Пример #6
0
    void OnVideoFrameArrived(Texture2D image, Visualization visualization, ColorFrameResolution resolution, BodyWrapper body, Face face)
    {
        frameView.FrameTexture = image;

        this.body = body;

        RefreshFrame(body);
    }
Пример #7
0
        private void Capture_Click(object sender, RoutedEventArgs e)
        {
            if (_mode == ViewMode.Capture && _currentBody != null)
            {
                _capturedBody = _currentBody.ToBodyWrapper();

                _mode = ViewMode.Compare;
            }
        }
        void Reader_MultiSourceFrameArrived(object sender, MultiSourceFrameArrivedEventArgs e)
        {
            if (_recorder.IsRecording)
            {
                var reference = e.FrameReference.AcquireFrame();

                VitruviusFrame recordingFrame = new VitruviusFrame();

                // Infrared

                /*using (var frame = reference.InfraredFrameReference.AcquireFrame())
                 * {
                 *  if (frame != null)
                 *  {
                 *      _bitmapGenerator.Update(frame);
                 *
                 *      recordingFrame.Image = _bitmapGenerator.Pixels;
                 *
                 *      viewer.Image = _bitmapGenerator.Bitmap;
                 *  }
                 * }*/

                using (var frame = reference.DepthFrameReference.AcquireFrame())
                {
                    if (frame != null)
                    {
                        bitmap.Update(frame);

                        recordingFrame.Image = bitmap.Pixels;

                        viewer.Image = bitmap.Bitmap;
                    }
                }

                // Body
                using (var frame = reference.BodyFrameReference.AcquireFrame())
                {
                    if (frame != null)
                    {
                        var body = frame.Bodies().Closest();

                        if (body != null)
                        {
                            recordingFrame.Body = BodyWrapper.Create(body, _sensor.CoordinateMapper, Visualization.Depth);

                            viewer.DrawBody(body);
                        }
                    }
                }

                _recorder.AddFrame(recordingFrame);
            }
        }
        void Reader_MultiSourceFrameArrived(object sender, MultiSourceFrameArrivedEventArgs e)
        {
            var reference = e.FrameReference.AcquireFrame();

            // Color
            using (var frame = reference.ColorFrameReference.AcquireFrame())
            {
                if (frame != null)
                {
                    viewer.Image = frame.ToBitmap();
                }
            }

            // Body
            using (var frame = reference.BodyFrameReference.AcquireFrame())
            {
                if (frame != null)
                {
                    _currentBody = frame.Bodies().Closest();



                    if (_currentBody != null)
                    {
                        var recording_brush = Brushes.Green;
                        var stopped_brush   = Brushes.Red;

                        var    current_brush = _mode == RecordingMode.Started ? recording_brush : stopped_brush;
                        double radius        = 15;

                        viewer.Clear();
                        viewer.DrawBody(_currentBody, radius, current_brush, radius, current_brush);

                        if (_mode == RecordingMode.Started)
                        {
                            BodyWrapper pose = new BodyWrapper();
                            pose.Set(_currentBody, viewer.CoordinateMapper, Visualization.Color);
                            string pose_json = JsonConvert.SerializeObject(pose);
                            savedPose.Add(pose_json);
                        }
                    }
                    else
                    {
                        viewer.Clear();
                    }
                }
            }
        }
Пример #10
0
 public void SaveSkeletonFrame(BodyFrameWrapper bfw)
 {
     if (jList == null)
     {
         jList       = new List <JointRow>();
         trackedBody = bfw.TrackedBodies[0];
     }
     foreach (var bw in bfw.TrackedBodies)
     {
         foreach (var jw in bw.Joints)
         {
             var jr = new JointRow(jw, bfw.RelativeTimeString, this.frameCounter, bw.TrackingId, jw.TrackingState);
             jList.Add(jr);
         }
     }
     this.frameCounter++;
 }
Пример #11
0
    protected override void OnBodyFrameReceived(BodyFrame frame)
    {
        Body body = frame.Bodies().Closest();

        if (body != null && this.body == null)
        {
            this.body = new BodyWrapper();
        }
        else if (body == null && this.body != null)
        {
            this.body = null;
        }

        if (this.body != null)
        {
            this.body.Set(body, KinectSensor.CoordinateMapper, visualization);
        }
    }
Пример #12
0
    protected override void OnBodyFrameReceived(BodyFrame frame)
    {
        IdentifyAllBodies(frame);

        Body body = null;

        if (playerBody >= 0)
        {
            body = allBodies[playerBody];
        }

        /*
         * Body body = frame.Bodies().Closest();
         * if (body != null)
         * {
         *  float distance = body.Joints[JointType.Head].Position.Z;
         *  Debug.Log("Dist: " + distance.ToString());   // Exagera un poquito, cuando mi cabeza a 2mts justo, dice que estoy a 2.250156
         *  if (distance > maxHeadDistance)
         *  {
         *      Debug.Log("NULL: " + distance.ToString());   // Exagera un poquito, cuando mi cabeza a 2mts justo, dice que estoy a 2.250156
         *      body = null;
         *  }
         * }
         */

        if (body != null && this.body == null)
        {
            this.body = new BodyWrapper();
        }
        else if (body == null && this.body != null)
        {
            this.body = null;
        }

        if (this.body != null)
        {
            this.body.Set(body, KinectSensor.CoordinateMapper, visualization);
        }
    }
Пример #13
0
    void RefreshCursorPosition(BodyWrapper body)
    {
        cursorPosition = isPlaying ? body.Map2D[JointType.HandLeft].ToVector2() : body.Joints[JointType.HandLeft].Position.ToPoint(Visualization.Color);

        Vector2 handTipPos = isPlaying ? body.Map2D[JointType.HandTipLeft].ToVector2() : body.Joints[JointType.HandTipLeft].Position.ToPoint(Visualization.Color);

        cursor.up = new Vector3(handTipPos.x - cursorPosition.x, cursorPosition.y - handTipPos.y, 0);

        frameView.SetPositionOnFrame(ref cursorPosition);

        float x = (cursorPosition.x + cameraSize.x * 0.5f) / cameraSize.x;
        float y = (cursorPosition.y + cameraSize.y * 0.5f) / cameraSize.y;

        cursorPosition.Set(x * areaSize.x - areaSize.x * 0.5f + areaCenter.x, y * areaSize.y - areaSize.y * 0.5f + areaCenter.y);
        cursorPosition  = Vector3.Lerp(cursor.position, cursorPosition, 0.35f);
        cursor.position = cursorPosition;

        for (int i = 0; i < buttons.Length; i++)
        {
            buttons[i].ValidateButton(cursorPosition, cursorState);
        }

        prevCursorPosition = cursorPosition;
    }
Пример #14
0
        public static void UpdatePipeline(long?layoutId, long?pipelineId)
        {
            //Get instance of PipelineOperations Class
            PipelineOperations pipelineOperations = new PipelineOperations(layoutId);

            API.Pipeline.Pipeline pipeline = new API.Pipeline.Pipeline();

            pipeline.DisplayValue = "Qualification";

            PickListValue pickList = new PickListValue();

            pickList.Id = 34770616801;

            pickList.DisplayValue = "Adfasfsad112";

            pickList.SequenceNumber = 1;

            pipeline.Maps = new List <PickListValue>()
            {
                pickList
            };

            BodyWrapper bodyWrapper = new BodyWrapper();

            bodyWrapper.Pipeline = new List <Pipeline>()
            {
                pipeline
            };

            //Call UpdatePipeline method that takes BodyWrapper instance as parameter
            APIResponse <ActionHandler> response = pipelineOperations.UpdatePipeline(pipelineId, bodyWrapper);

            if (response != null)
            {
                //Get the status code from response
                Console.WriteLine("Status Code: " + response.StatusCode);

                //Check if expected response is received
                if (response.IsExpected)
                {
                    //Get object from response
                    ActionHandler actionHandler = response.Object;

                    if (actionHandler is ActionWrapper)
                    {
                        //Get the received ActionWrapper instance
                        ActionWrapper actionWrapper = (ActionWrapper)actionHandler;

                        //Get the list of obtained ActionResponse instances
                        List <ActionResponse> actionResponses = actionWrapper.Pipeline;

                        foreach (ActionResponse actionResponse in actionResponses)
                        {
                            //Check if the request is successful
                            if (actionResponse is SuccessResponse)
                            {
                                //Get the received SuccessResponse instance
                                SuccessResponse successResponse = (SuccessResponse)actionResponse;

                                //Get the Status
                                Console.WriteLine("Status: " + successResponse.Status.Value);

                                //Get the Code
                                Console.WriteLine("Code: " + successResponse.Code.Value);

                                Console.WriteLine("Details: ");

                                //Get the details map
                                foreach (KeyValuePair <string, object> entry in successResponse.Details)
                                {
                                    //Get each value in the map
                                    Console.WriteLine(entry.Key + " : " + JsonConvert.SerializeObject(entry.Value));
                                }

                                //Get the Message
                                Console.WriteLine("Message: " + successResponse.Message.Value);
                            }
                            //Check if the request returned an exception
                            else if (actionResponse is APIException)
                            {
                                //Get the received APIException instance
                                APIException exception = (APIException)actionResponse;

                                //Get the Status
                                Console.WriteLine("Status: " + exception.Status.Value);

                                //Get the Code
                                Console.WriteLine("Code: " + exception.Code.Value);

                                Console.WriteLine("Details: ");

                                //Get the details map
                                foreach (KeyValuePair <string, object> entry in exception.Details)
                                {
                                    //Get each value in the map
                                    Console.WriteLine(entry.Key + " : " + JsonConvert.SerializeObject(entry.Value));
                                }

                                //Get the Message
                                Console.WriteLine("Message: " + exception.Message.Value);
                            }
                        }
                    }
                    //Check if the request returned an exception
                    else if (actionHandler is APIException)
                    {
                        //Get the received APIException instance
                        APIException exception = (APIException)actionHandler;

                        //Get the Status
                        Console.WriteLine("Status: " + exception.Status.Value);

                        //Get the Code
                        Console.WriteLine("Code: " + exception.Code.Value);

                        Console.WriteLine("Details: ");

                        //Get the details map
                        foreach (KeyValuePair <string, object> entry in exception.Details)
                        {
                            //Get each value in the map
                            Console.WriteLine(entry.Key + " : " + JsonConvert.SerializeObject(entry.Value));
                        }

                        //Get the Message
                        Console.WriteLine("Message: " + exception.Message.Value);
                    }
                }
                else
                { //If response is not as expected
                    //Get model object from response
                    Model responseObject = response.Model;

                    //Get the response object's class
                    Type type = responseObject.GetType();

                    //Get all declared fields of the response class
                    Console.WriteLine("Type is: {0}", type.Name);

                    PropertyInfo[] props = type.GetProperties();

                    Console.WriteLine("Properties (N = {0}):", props.Length);

                    foreach (var prop in props)
                    {
                        if (prop.GetIndexParameters().Length == 0)
                        {
                            Console.WriteLine("{0} ({1}) in {2}", prop.Name, prop.PropertyType.Name, prop.GetValue(responseObject));
                        }
                        else
                        {
                            Console.WriteLine("{0} ({1}) in <Indexed>", prop.Name, prop.PropertyType.Name);
                        }
                    }
                }
            }
        }
Пример #15
0
 private void refreshBody()
 {
     bw = (BodyWrapper)savedPose[counter];
     bw.SetMap2D(viewer2.CoordinateMapper, Visualization.Color);
 }
Пример #16
0
        /// <summary>
        /// This method is used to update single Contact Role with ID and print the response.
        /// </summary>
        /// <param name="contactRoleId">The ID of the ContactRole to be updated</param>
        public static void UpdateContactRole(long contactRoleId)
        {
            //ID of the ContactRole to be updated
            //long contactRoleId = 5255085067923;

            //Get instance of ContactRolesOperations Class
            ContactRolesOperations contactRolesOperations = new ContactRolesOperations();

            //Get instance of BodyWrapper Class that will contain the request body
            BodyWrapper bodyWrapper = new BodyWrapper();

            //List of ContactRole instances
            List <ContactRole> contactRolesList = new List <ContactRole>();

            //Get instance of ContactRole Class
            ContactRole cr1 = new ContactRole();

            //Set name to the ContactRole instance
            cr1.Name = "contactRoleUpdate1";

            //Set sequence number to the ContactRole instance
            cr1.SequenceNumber = 2;

            //Add ContactRole instance to the list
            contactRolesList.Add(cr1);

            //Set the list to contactRoles in BodyWrapper instance
            bodyWrapper.ContactRoles = contactRolesList;

            //Call UpdateContactRole method that takes contactRoleId  and BodyWrapper instance as parameters
            APIResponse <ActionHandler> response = contactRolesOperations.UpdateContactRole(contactRoleId, bodyWrapper);

            if (response != null)
            {
                //Get the status code from response
                Console.WriteLine("Status Code: " + response.StatusCode);

                //Check if expected response is received
                if (response.IsExpected)
                {
                    //Get object from response
                    ActionHandler actionHandler = response.Object;

                    if (actionHandler is ActionWrapper)
                    {
                        //Get the received ActionWrapper instance
                        ActionWrapper actionWrapper = (ActionWrapper)actionHandler;

                        //Get the list of obtained ActionResponse instances
                        List <ActionResponse> actionResponses = actionWrapper.ContactRoles;

                        foreach (ActionResponse actionResponse in actionResponses)
                        {
                            //Check if the request is successful
                            if (actionResponse is SuccessResponse)
                            {
                                //Get the received SuccessResponse instance
                                SuccessResponse successResponse = (SuccessResponse)actionResponse;

                                //Get the Status
                                Console.WriteLine("Status: " + successResponse.Status.Value);

                                //Get the Code
                                Console.WriteLine("Code: " + successResponse.Code.Value);

                                Console.WriteLine("Details: ");

                                //Get the details map
                                foreach (KeyValuePair <string, object> entry in successResponse.Details)
                                {
                                    //Get each value in the map
                                    Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value));
                                }

                                //Get the Message
                                Console.WriteLine("Message: " + successResponse.Message.Value);
                            }
                            //Check if the request returned an exception
                            else if (actionResponse is APIException)
                            {
                                //Get the received APIException instance
                                APIException exception = (APIException)actionResponse;

                                //Get the Status
                                Console.WriteLine("Status: " + exception.Status.Value);

                                //Get the Code
                                Console.WriteLine("Code: " + exception.Code.Value);

                                Console.WriteLine("Details: ");

                                //Get the details map
                                foreach (KeyValuePair <string, object> entry in exception.Details)
                                {
                                    //Get each value in the map
                                    Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value));
                                }

                                //Get the Message
                                Console.WriteLine("Message: " + exception.Message.Value);
                            }
                        }
                    }
                    //Check if the request returned an exception
                    else if (actionHandler is APIException)
                    {
                        //Get the received APIException instance
                        APIException exception = (APIException)actionHandler;

                        //Get the Status
                        Console.WriteLine("Status: " + exception.Status.Value);

                        //Get the Code
                        Console.WriteLine("Code: " + exception.Code.Value);

                        Console.WriteLine("Details: ");

                        //Get the details map
                        foreach (KeyValuePair <string, object> entry in exception.Details)
                        {
                            //Get each value in the map
                            Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value));
                        }

                        //Get the Message
                        Console.WriteLine("Message: " + exception.Message.Value);
                    }
                }
                else
                { //If response is not as expected
                    //Get model object from response
                    Model responseObject = response.Model;

                    //Get the response object's class
                    Type type = responseObject.GetType();

                    //Get all declared fields of the response class
                    Console.WriteLine("Type is: {0}", type.Name);

                    PropertyInfo[] props = type.GetProperties();

                    Console.WriteLine("Properties (N = {0}):", props.Length);

                    foreach (var prop in props)
                    {
                        if (prop.GetIndexParameters().Length == 0)
                        {
                            Console.WriteLine("{0} ({1}) in {2}", prop.Name, prop.PropertyType.Name, prop.GetValue(responseObject));
                        }
                        else
                        {
                            Console.WriteLine("{0} ({1}) in <Indexed>", prop.Name, prop.PropertyType.Name);
                        }
                    }
                }
            }
        }
Пример #17
0
        /**
         * <h3> Get Records </h3>
         * This method is used to get records from the module through a COQL query.
         * @throws Exception
         */
        public static void GetRecords()
        {
            //Get instance of QueryOperations Class
            QueryOperations queryOperations = new QueryOperations();

            //Get instance of BodyWrapper Class that will contain the request body
            BodyWrapper bodyWrapper = new BodyWrapper();

            string selectQuery = "select Last_Name from Leads where Last_Name is not null limit 200";

            bodyWrapper.SelectQuery = selectQuery;

            //Call getRecords method that takes BodyWrapper instance as parameter
            APIResponse <ResponseHandler> response = queryOperations.GetRecords(bodyWrapper);

            if (response != null)
            {
                //Get the status code from response
                Console.WriteLine("Status Code: " + response.StatusCode);

                //Check if expected response is received
                if (response.IsExpected)
                {
                    //Get the object from response
                    ResponseHandler responseHandler = response.Object;

                    if (responseHandler is ResponseWrapper)
                    {
                        //Get the received ResponseWrapper instance
                        ResponseWrapper responseWrapper = (ResponseWrapper)responseHandler;

                        //Get the obtained Record instances
                        List <API.Record.Record> records = responseWrapper.Data;

                        foreach (API.Record.Record record in records)
                        {
                            //Get the ID of each Record
                            Console.WriteLine("Record ID: " + record.Id);

                            //Get the createdBy User instance of each Record
                            API.Users.User createdBy = record.CreatedBy;

                            //Check if createdBy is not null
                            if (createdBy != null)
                            {
                                //Get the ID of the createdBy User
                                Console.WriteLine("Record Created By User-ID: " + createdBy.Id);

                                //Get the name of the createdBy User
                                Console.WriteLine("Record Created By User-Name: " + createdBy.Name);

                                //Get the Email of the createdBy User
                                Console.WriteLine("Record Created By User-Email: " + createdBy.Email);
                            }

                            //Get the CreatedTime of each Record
                            Console.WriteLine("Record CreatedTime: " + record.CreatedTime);

                            //Get the modifiedBy User instance of each Record
                            API.Users.User modifiedBy = record.ModifiedBy;

                            //Check if modifiedBy is not null
                            if (modifiedBy != null)
                            {
                                //Get the ID of the modifiedBy User
                                Console.WriteLine("Record Modified By User-ID: " + modifiedBy.Id);

                                //Get the name of the modifiedBy User
                                Console.WriteLine("Record Modified By User-Name: " + modifiedBy.Name);

                                //Get the Email of the modifiedBy User
                                Console.WriteLine("Record Modified By User-Email: " + modifiedBy.Email);
                            }

                            //Get the ModifiedTime of each Record
                            Console.WriteLine("Record ModifiedTime: " + record.ModifiedTime);

                            //To get particular field value
                            Console.WriteLine("Record Field Value: " + record.GetKeyValue("Last_Name"));                            // FieldApiName

                            Console.WriteLine("Record KeyValues: ");

                            //Get the KeyValue map
                            foreach (KeyValuePair <string, object> entry in record.GetKeyValues())
                            {
                                string keyName = entry.Key;

                                object value = entry.Value;

                                if (value is IList)
                                {
                                    Console.WriteLine("Record KeyName : " + keyName);

                                    IList dataList = (IList)value;

                                    foreach (object data in dataList)
                                    {
                                        if (data is IDictionary)
                                        {
                                            Console.WriteLine("Record KeyName : " + keyName + " - Value : ");

                                            foreach (KeyValuePair <string, object> entry1 in (Dictionary <string, object>)data)
                                            {
                                                Console.WriteLine(entry1.Key + " : " + JsonConvert.SerializeObject(entry1.Value));
                                            }
                                        }
                                        else
                                        {
                                            Console.WriteLine(JsonConvert.SerializeObject(data));
                                        }
                                    }
                                }
                                else if (value is IDictionary)
                                {
                                    Console.WriteLine("Record KeyName : " + keyName + " - Value : ");

                                    foreach (KeyValuePair <string, object> entry1 in (Dictionary <string, object>)value)
                                    {
                                        Console.WriteLine(entry1.Key + " : " + JsonConvert.SerializeObject(entry1.Value));
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("Record KeyName : " + keyName + " - Value : " + JsonConvert.SerializeObject(value));
                                }
                            }
                        }

                        //Get the Object obtained Info instance
                        API.Record.Info info = responseWrapper.Info;

                        //Check if info is not null
                        if (info != null)
                        {
                            if (info.Count != null)
                            {
                                //Get the Count of the Info
                                Console.WriteLine("Record Info Count: " + info.Count.ToString());
                            }

                            if (info.MoreRecords != null)
                            {
                                //Get the MoreRecords of the Info
                                Console.WriteLine("Record Info MoreRecords: " + info.MoreRecords.ToString());
                            }
                        }
                    }
                    //Check if the request returned an exception
                    else if (responseHandler is APIException)
                    {
                        //Get the received APIException instance
                        APIException exception = (APIException)responseHandler;

                        //Get the Status
                        Console.WriteLine("Status: " + exception.Status.Value);

                        //Get the Code
                        Console.WriteLine("Code: " + exception.Code.Value);

                        Console.WriteLine("Details: ");

                        //Get the details map
                        foreach (KeyValuePair <string, object> entry in exception.Details)
                        {
                            //Get each value in the map
                            Console.WriteLine(entry.Key + " : " + entry.Value);
                        }

                        //Get the Message
                        Console.WriteLine("Message: " + exception.Message.Value);
                    }
                }
                else
                {                //If response is not as expected
                    //Get model object from response
                    Model responseObject = response.Model;

                    //Get the response object's class
                    Type type = responseObject.GetType();

                    //Get all declared fields of the response class
                    Console.WriteLine("Type is: {0}", type.Name);

                    PropertyInfo[] props = type.GetProperties();

                    Console.WriteLine("Properties (N = {0}):", props.Length);

                    foreach (var prop in props)
                    {
                        if (prop.GetIndexParameters().Length == 0)
                        {
                            Console.WriteLine("{0} ({1}) : {2}", prop.Name, prop.PropertyType.Name, prop.GetValue(responseObject));
                        }
                        else
                        {
                            Console.WriteLine("{0} ({1}) : <Indexed>", prop.Name, prop.PropertyType.Name);
                        }
                    }
                }
            }
        }
Пример #18
0
        /// <summary>
        /// This method is used to update Organization Taxes and print the response.
        /// </summary>
        public static void UpdateTaxes()
        {
            //Get instance of TaxesOperations Class
            TaxesOperations taxesOperations = new TaxesOperations();

            //Get instance of BodyWrapper Class that will contain the request body
            BodyWrapper request = new BodyWrapper();

            //List of Tax instances
            List <Com.Zoho.Crm.API.Taxes.Tax> taxList = new List <Com.Zoho.Crm.API.Taxes.Tax>();

            //Get instance of Tax Class
            Com.Zoho.Crm.API.Taxes.Tax tax1 = new Com.Zoho.Crm.API.Taxes.Tax();

            tax1.Id = 3477061012455;

            tax1.Name = "MyTax112";

            tax1.SequenceNumber = 1;

            tax1.Value = 15.0;

            taxList.Add(tax1);

            tax1 = new Com.Zoho.Crm.API.Taxes.Tax();

            tax1.Id = 3477061012456;

            tax1.Value = 25.0;

            taxList.Add(tax1);

            tax1 = new Com.Zoho.Crm.API.Taxes.Tax();

            tax1.Id = 34770615682037;

            tax1.SequenceNumber = 2;

            taxList.Add(tax1);

            request.Taxes = taxList;

            //Call UpdateTaxes method that takes BodyWrapper instance as parameter
            APIResponse <ActionHandler> response = taxesOperations.UpdateTaxes(request);

            if (response != null)
            {
                //Get the status code from response
                Console.WriteLine("Status Code: " + response.StatusCode);

                //Check if expected response is received
                if (response.IsExpected)
                {
                    //Get object from response
                    ActionHandler actionHandler = response.Object;

                    if (actionHandler is ActionWrapper)
                    {
                        //Get the received ActionWrapper instance
                        ActionWrapper actionWrapper = (ActionWrapper)actionHandler;

                        //Get the list of obtained ActionResponse instances
                        List <ActionResponse> actionResponses = actionWrapper.Taxes;

                        foreach (ActionResponse actionResponse in actionResponses)
                        {
                            //Check if the request is successful
                            if (actionResponse is SuccessResponse)
                            {
                                //Get the received SuccessResponse instance
                                SuccessResponse successResponse = (SuccessResponse)actionResponse;

                                //Get the Status
                                Console.WriteLine("Status: " + successResponse.Status.Value);

                                //Get the Code
                                Console.WriteLine("Code: " + successResponse.Code.Value);

                                Console.WriteLine("Details: ");

                                //Get the details map
                                foreach (KeyValuePair <string, object> entry in successResponse.Details)
                                {
                                    //Get each value in the map
                                    Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value));
                                }

                                //Get the Message
                                Console.WriteLine("Message: " + successResponse.Message.Value);
                            }
                            //Check if the request returned an exception
                            else if (actionResponse is APIException)
                            {
                                //Get the received APIException instance
                                APIException exception = (APIException)actionResponse;

                                //Get the Status
                                Console.WriteLine("Status: " + exception.Status.Value);

                                //Get the Code
                                Console.WriteLine("Code: " + exception.Code.Value);

                                Console.WriteLine("Details: ");

                                //Get the details map
                                foreach (KeyValuePair <string, object> entry in exception.Details)
                                {
                                    //Get each value in the map
                                    Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value));
                                }

                                //Get the Message
                                Console.WriteLine("Message: " + exception.Message.Value);
                            }
                        }
                    }
                    //Check if the request returned an exception
                    else if (actionHandler is APIException)
                    {
                        //Get the received APIException instance
                        APIException exception = (APIException)actionHandler;

                        //Get the Status
                        Console.WriteLine("Status: " + exception.Status.Value);

                        //Get the Code
                        Console.WriteLine("Code: " + exception.Code.Value);

                        Console.WriteLine("Details: ");

                        //Get the details map
                        foreach (KeyValuePair <string, object> entry in exception.Details)
                        {
                            //Get each value in the map
                            Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value));
                        }

                        //Get the Message
                        Console.WriteLine("Message: " + exception.Message.Value);
                    }
                }
                else
                { //If response is not as expected
                    //Get model object from response
                    Model responseObject = response.Model;

                    //Get the response object's class
                    Type type = responseObject.GetType();

                    //Get all declared fields of the response class
                    Console.WriteLine("Type is: {0}", type.Name);

                    PropertyInfo[] props = type.GetProperties();

                    Console.WriteLine("Properties (N = {0}):", props.Length);

                    foreach (var prop in props)
                    {
                        if (prop.GetIndexParameters().Length == 0)
                        {
                            Console.WriteLine("{0} ({1}) : {2}", prop.Name, prop.PropertyType.Name, prop.GetValue(responseObject));
                        }
                        else
                        {
                            Console.WriteLine("{0} ({1}) : <Indexed>", prop.Name, prop.PropertyType.Name);
                        }
                    }
                }
            }
        }
Пример #19
0
        public static void SendMailMethod(long?recordId, string moduleAPIName)
        {
            //Get instance of SendMailOperations Class
            SendMailOperations sendMailOperations = new SendMailOperations();

            Mail mail = new Mail();

            UserAddress from = new UserAddress();

            from.UserName = "******";

            from.Email = "*****@*****.**";

            mail.From = from;

            UserAddress to = new UserAddress();

            to.UserName = "******";

            to.Email = "*****@*****.**";

            mail.To = new List <UserAddress>()
            {
                to
            };

            mail.Subject = "Mail subject";

            mail.Content = "<br><a href=\"{ConsentForm.en_US}\" id=\"ConsentForm\" class=\"en_US\" target=\"_blank\">Consent form link</a><br><br><br><br><br><h3><span style=\"background-color: rgb(254, 255, 102)\">REGARDS,</span></h3><div><span style=\"background-color: rgb(254, 255, 102)\">AZ</span></div><div><span style=\"background-color: rgb(254, 255, 102)\">ADMIN</span></div> <div></div>";

            mail.ConsentEmail = false;

            mail.MailFormat = "html";

            InventoryTemplate template = new InventoryTemplate();

            template.Id = 347706179;

            mail.Template = template;

            BodyWrapper wrapper = new BodyWrapper();

            wrapper.Data = new List <Mail>()
            {
                mail
            };

            //Call SendMail method
            APIResponse <ActionHandler> response = sendMailOperations.SendMail(recordId, moduleAPIName, wrapper);

            if (response != null)
            {
                //Get the status code from response
                Console.WriteLine("Status Code: " + response.StatusCode);

                //Check if expected response is received
                if (response.IsExpected)
                {
                    //Get object from response
                    ActionHandler actionHandler = response.Object;

                    if (actionHandler is ActionWrapper)
                    {
                        //Get the received ActionWrapper instance
                        ActionWrapper actionWrapper = (ActionWrapper)actionHandler;

                        //Get the list of obtained ActionResponse instances
                        List <ActionResponse> actionResponses = actionWrapper.Data;

                        foreach (ActionResponse actionResponse in actionResponses)
                        {
                            //Check if the request is successful
                            if (actionResponse is SuccessResponse)
                            {
                                //Get the received SuccessResponse instance
                                SuccessResponse successResponse = (SuccessResponse)actionResponse;

                                //Get the Status
                                Console.WriteLine("Status: " + successResponse.Status.Value);

                                //Get the Code
                                Console.WriteLine("Code: " + successResponse.Code.Value);

                                Console.WriteLine("Details: ");

                                //Get the details map
                                foreach (KeyValuePair <string, object> entry in successResponse.Details)
                                {
                                    //Get each value in the map
                                    Console.WriteLine(entry.Key + " : " + JsonConvert.SerializeObject(entry.Value));
                                }

                                //Get the Message
                                Console.WriteLine("Message: " + successResponse.Message.Value);
                            }
                            //Check if the request returned an exception
                            else if (actionResponse is APIException)
                            {
                                //Get the received APIException instance
                                APIException exception = (APIException)actionResponse;

                                //Get the Status
                                Console.WriteLine("Status: " + exception.Status.Value);

                                //Get the Code
                                Console.WriteLine("Code: " + exception.Code.Value);

                                Console.WriteLine("Details: ");

                                //Get the details map
                                foreach (KeyValuePair <string, object> entry in exception.Details)
                                {
                                    //Get each value in the map
                                    Console.WriteLine(entry.Key + " : " + JsonConvert.SerializeObject(entry.Value));
                                }

                                //Get the Message
                                Console.WriteLine("Message: " + exception.Message.Value);
                            }
                        }
                    }
                    //Check if the request returned an exception
                    else if (actionHandler is APIException)
                    {
                        //Get the received APIException instance
                        APIException exception = (APIException)actionHandler;

                        //Get the Status
                        Console.WriteLine("Status: " + exception.Status.Value);

                        //Get the Code
                        Console.WriteLine("Code: " + exception.Code.Value);

                        Console.WriteLine("Details: ");

                        //Get the details map
                        foreach (KeyValuePair <string, object> entry in exception.Details)
                        {
                            //Get each value in the map
                            Console.WriteLine(entry.Key + " : " + JsonConvert.SerializeObject(entry.Value));
                        }

                        //Get the Message
                        Console.WriteLine("Message: " + exception.Message.Value);
                    }
                }
                else
                { //If response is not as expected
                    //Get model object from response
                    Model responseObject = response.Model;

                    //Get the response object's class
                    Type type = responseObject.GetType();

                    //Get all declared fields of the response class
                    Console.WriteLine("Type is: {0}", type.Name);

                    PropertyInfo[] props = type.GetProperties();

                    Console.WriteLine("Properties (N = {0}):", props.Length);

                    foreach (var prop in props)
                    {
                        if (prop.GetIndexParameters().Length == 0)
                        {
                            Console.WriteLine("{0} ({1}) in {2}", prop.Name, prop.PropertyType.Name, prop.GetValue(responseObject));
                        }
                        else
                        {
                            Console.WriteLine("{0} ({1}) in <Indexed>", prop.Name, prop.PropertyType.Name);
                        }
                    }
                }
            }
        }
Пример #20
0
 void RefreshFrame(BodyWrapper body)
 {
     kinectUI.UpdateCursor(body, vitruviusVideo.videoPlayer.IsPlaying);
 }
Пример #21
0
    void RefreshFrame(BodyWrapper body)
    {
        stickman.gameObject.SetActive(body != null);
        frameViewArc.gameObject.SetActive(body != null);
        modelArc.gameObject.SetActive(body != null);

        if (body != null)
        {
            if (model.updateModel)
            {
                Avateering.Update(model, body);
            }

            stickman.UpdateBody(body, frameView);

            Joint   startJoint;
            Joint   centerJoint;
            Joint   endJoint;
            Vector2 centerJointPosition;
            Vector2 startJointDir;
            Vector2 endJointDir;

            #region JointPeaks

            for (int i = 0; i < jointPeaks.Length; i++)
            {
                startJoint  = body.Joints[jointPeaks[i].start];
                centerJoint = body.Joints[jointPeaks[i].center];
                endJoint    = body.Joints[jointPeaks[i].end];

                centerJointPosition = stickman.controller.GetJointPosition(jointPeaks[i].center);
                startJointDir       = ((Vector2)stickman.controller.GetJointPosition(jointPeaks[i].start) - centerJointPosition).normalized;
                endJointDir         = ((Vector2)stickman.controller.GetJointPosition(jointPeaks[i].end) - centerJointPosition).normalized;

                jointPeaks[i].arc.Angle = Vector2.Angle(startJointDir, endJointDir);

                jointPeaks[i].arc.transform.position = centerJointPosition;
                jointPeaks[i].arc.transform.up       = Quaternion.Euler(0, 0, jointPeaks[i].arc.Angle) *
                                                       (Vector2.Dot(Quaternion.Euler(0, 0, 90) * startJointDir, endJointDir) > 0 ? startJointDir : endJointDir);

                jointPeaks[i].jointAngle = (float)centerJoint.Angle(startJoint, endJoint);
            }

            #endregion

            startJoint  = body.Joints[model.start];
            centerJoint = body.Joints[model.center];
            endJoint    = body.Joints[model.end];

            #region FrameView Arc

            if (vitruviusVideo.videoPlayer.IsPlaying)
            {
                startJointDir       = body.Map2D[model.start].ToVector2();
                centerJointPosition = body.Map2D[model.center].ToVector2();
                endJointDir         = body.Map2D[model.end].ToVector2();
            }
            else
            {
                startJointDir       = startJoint.Position.ToPoint(visualization, KinectSensor.CoordinateMapper);
                centerJointPosition = centerJoint.Position.ToPoint(visualization, KinectSensor.CoordinateMapper);
                endJointDir         = endJoint.Position.ToPoint(visualization, KinectSensor.CoordinateMapper);
            }

            frameView.SetPositionOnFrame(ref startJointDir);
            frameView.SetPositionOnFrame(ref centerJointPosition);
            frameView.SetPositionOnFrame(ref endJointDir);

            startJointDir = (startJointDir - centerJointPosition).normalized;
            endJointDir   = (endJointDir - centerJointPosition).normalized;

            frameViewArc.Angle = Vector2.Angle(startJointDir, endJointDir);

            frameViewArc.transform.position = centerJointPosition;
            frameViewArc.transform.up       = Quaternion.Euler(0, 0, frameViewArc.Angle) *
                                              (Vector2.Dot(Quaternion.Euler(0, 0, 90) * startJointDir, endJointDir) > 0 ? startJointDir : endJointDir);

            #endregion

            #region Model Arc

            Vector3 arcPosition = model.GetBone(model.center).Transform.position;
            arcPosition.z -= 2;

            centerJointPosition = centerJoint.Position.ToVector3();
            startJointDir       = ((Vector2)startJoint.Position.ToVector3() - centerJointPosition).normalized;
            endJointDir         = ((Vector2)endJoint.Position.ToVector3() - centerJointPosition).normalized;

            modelArc.Angle = Vector2.Angle(startJointDir, endJointDir);

            modelArc.transform.position = arcPosition;
            modelArc.transform.up       = Quaternion.Euler(0, 0, modelArc.Angle) *
                                          (Vector2.Dot(Quaternion.Euler(0, 0, 90) * startJointDir, endJointDir) > 0 ? startJointDir : endJointDir);

            #endregion
        }
    }
Пример #22
0
        /// <summary>
        /// This method is used to upload a file and print the response.
        /// </summary>
        public static void UploadFiles()
        {
            //Get instance of RecordOperations Class
            FileOperations fileOperations = new FileOperations();

            //Get instance of FileBodyWrapper Class that will contain the request body
            BodyWrapper bodyWrapper = new BodyWrapper();

            //Get instance of StreamWrapper class that takes absolute path of the file to be attached as parameter
            StreamWrapper streamWrapper = new StreamWrapper("/Users/Desktop/py.html");

            //Get instance of StreamWrapper class that takes absolute path of the file to be attached as parameter
            StreamWrapper streamWrapper1 = new StreamWrapper("/Users/Desktop/download.png");

            //Get instance of StreamWrapper class that takes absolute path of the file to be attached as parameter
            StreamWrapper streamWrapper2 = new StreamWrapper("/Users/Desktop/samplecode.txt");

            //Set file to the FileBodyWrapper instance
            bodyWrapper.File = new List <StreamWrapper>()
            {
                streamWrapper, streamWrapper1, streamWrapper2
            };

            //Get instance of ParameterMap Class
            ParameterMap paramInstance = new ParameterMap();

            //Call uploadFile method that takes BodyWrapper instance as parameter.
            APIResponse <ActionHandler> response = fileOperations.UploadFiles(bodyWrapper, paramInstance);

            if (response != null)
            {
                //Get the status code from response
                Console.WriteLine("Status Code: " + response.StatusCode);

                //Check if expected response is received
                if (response.IsExpected)
                {
                    //Get object from response
                    ActionHandler actionHandler = response.Object;

                    if (actionHandler is ActionWrapper)
                    {
                        //Get the received ActionWrapper instance
                        ActionWrapper actionWrapper = (ActionWrapper)actionHandler;

                        //Get the list of obtained action responses
                        List <ActionResponse> actionResponses = actionWrapper.Data;

                        foreach (ActionResponse actionResponse in actionResponses)
                        {
                            //Check if the request is successful
                            if (actionResponse is SuccessResponse)
                            {
                                //Get the received SuccessResponse instance
                                SuccessResponse successResponse = (SuccessResponse)actionResponse;

                                //Get the Status
                                Console.WriteLine("Status: " + successResponse.Status.Value);

                                //Get the Code
                                Console.WriteLine("Code: " + successResponse.Code.Value);

                                Console.WriteLine("Details: ");

                                //Get the details map
                                foreach (KeyValuePair <string, object> entry in successResponse.Details)
                                {
                                    //Get each value in the map
                                    Console.WriteLine(entry.Key + " : " + JsonConvert.SerializeObject(entry.Value));
                                }

                                //Get the Message
                                Console.WriteLine("Message: " + successResponse.Message.Value);
                            }
                            //Check if the request returned an exception
                            else if (actionResponse is APIException)
                            {
                                //Get the received APIException instance
                                APIException exception = (APIException)actionResponse;

                                //Get the Status
                                Console.WriteLine("Status: " + exception.Status.Value);

                                //Get the Code
                                Console.WriteLine("Code: " + exception.Code.Value);

                                Console.WriteLine("Details: ");

                                //Get the details map
                                foreach (KeyValuePair <string, object> entry in exception.Details)
                                {
                                    //Get each value in the map
                                    Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value));
                                }

                                //Get the Message
                                Console.WriteLine("Message: " + exception.Message.Value);
                            }
                        }
                    }
                    //Check if the request returned an exception
                    else if (actionHandler is APIException)
                    {
                        //Get the received APIException instance
                        APIException exception = (APIException)actionHandler;

                        //Get the Status
                        Console.WriteLine("Status: " + exception.Status.Value);

                        //Get the Code
                        Console.WriteLine("Code: " + exception.Code.Value);

                        Console.WriteLine("Details: ");

                        //Get the details map
                        foreach (KeyValuePair <string, object> entry in exception.Details)
                        {
                            //Get each value in the map
                            Console.WriteLine(entry.Key + ": " + JsonConvert.SerializeObject(entry.Value));
                        }

                        //Get the Message
                        Console.WriteLine("Message: " + exception.Message.Value);
                    }
                }
                else
                { //If response is not as expected
                    //Get model object from response
                    Model responseObject = response.Model;

                    //Get the response object's class
                    Type type = responseObject.GetType();

                    //Get all declared fields of the response class
                    Console.WriteLine("Type is: {0}", type.Name);

                    PropertyInfo[] props = type.GetProperties();

                    Console.WriteLine("Properties (N = {0}):", props.Length);

                    foreach (var prop in props)
                    {
                        if (prop.GetIndexParameters().Length == 0)
                        {
                            Console.WriteLine("{0} ({1}) : {2}", prop.Name, prop.PropertyType.Name, prop.GetValue(responseObject));
                        }
                        else
                        {
                            Console.WriteLine("{0} ({1}) : <Indexed>", prop.Name, prop.PropertyType.Name);
                        }
                    }
                }
            }
        }
Пример #23
0
    public void UpdateCursor(BodyWrapper body, bool isPlaying = false)
    {
        this.isPlaying = isPlaying;

        if (body != null && body.HandRightState != HandState.NotTracked)
        {
            if (!cursor.gameObject.activeSelf)
            {
                cursor.gameObject.SetActive(true);
            }

            HandState handState = body.HandRightState;

            if (handState != prevHandState)
            {
                if (handState == HandState.Open)
                {
                    renderer.sprite = cursorOpenState;
                }
                else if (handState == HandState.Closed)
                {
                    renderer.sprite = cursorClosedState;
                }

                prevHandState = handState;
            }

            switch (handState)
            {
            case HandState.Open:

                if (cursorState == CursorState.Pressing)
                {
                    cursorState = CursorState.Up;
                }
                else if (cursorState == CursorState.Up)
                {
                    cursorState = CursorState.None;
                }

                break;

            case HandState.Closed:

                if (cursorState == CursorState.None)
                {
                    cursorState = CursorState.Down;
                }
                else if (cursorState == CursorState.Down)
                {
                    cursorState = CursorState.Pressing;
                }

                break;
            }

            RefreshCursorPosition(body);
        }
        else
        {
            if (cursor.gameObject.activeSelf)
            {
                cursor.gameObject.SetActive(false);
            }
        }
    }