{"action":"created","comment":{"url":"https://api.github.com/repos/DynamoDS/Dynamo/pulls/comments/91033155","pull_request_review_id":11534476,"id":91033155,"diff_hunk":"@@ -0,0 +1,479 @@\n+﻿using CefSharp;\n+using Dynamo.DynamoPackagesUI.ViewModels;\n+using Dynamo.Models;\n+using Dynamo.PackageManager;\n+using Dynamo.UI;\n+using Dynamo.Utilities;\n+using Dynamo.ViewModels;\n+using Dynamo.Wpf.Interfaces;\n+using Dynamo.Wpf.Properties;\n+using Greg.Requests;\n+using Greg.Responses;\n+using Greg.Utility;\n+using Newtonsoft.Json;\n+using RestSharp;\n+using System;\n+using System.Collections.Generic;\n+using System.Diagnostics;\n+using System.IO;\n+using System.Linq;\n+using System.Text;\n+using System.Threading.Tasks;\n+using System.Windows;\n+\n+namespace Dynamo.DynamoPackagesUI.Utilities\n+{\n+    /// <summary>\n+    /// CEF calss to assist exploring packages, authors and logged in user packages.\n+    /// </summary>\n+    internal class PackageManagerCommands : CefCommands\n+    {\n+        public PackageManagerCommands(IBrandingResourceProvider resourceProvider, PackageLoader loader, DynamoModel model) : \n+            base(resourceProvider, loader, model)\n+        {\n+        }\n+\n+        public List<string> PackagesToInstall { get; set; }\n+\n+\n+        private dynamic _downloadRequest;\n+        public dynamic DownloadRequest\n+        {\n+            get { return _downloadRequest; }\n+            set\n+            {\n+                if (value is Newtonsoft.Json.Linq.JObject)\n+                    _downloadRequest = value;\n+                else\n+                    _downloadRequest = JsonConvert.DeserializeObject<dynamic>(value.ToString());\n+            }\n+        }\n+\n+        private dynamic _pkgRequest;\n+        public dynamic PkgRequest\n+        {\n+            get { return _pkgRequest; }\n+            set\n+            {\n+                if (value is Newtonsoft.Json.Linq.JObject)\n+                    _pkgRequest = value;\n+                else\n+                    _pkgRequest = JsonConvert.DeserializeObject<dynamic>(value);\n+            }\n+        }\n+\n+        private string PackageInstallPath { get; set; }\n+\n+        /// <summary>\n+        /// Install Dynamo Package\n+        /// </summary>\n+        /// <param name=\"downloadPath\"></param>\n+        private void InstallPackage(string downloadPath)\n+        {\n+            var firstOrDefault = Loader.LocalPackages.FirstOrDefault(pkg => pkg.ID == DownloadRequest.asset_id.ToString());\n+            if (firstOrDefault != null)\n+            {\n+                var dynModel = Model;\n+                try\n+                {\n+                    firstOrDefault.UninstallCore(dynModel.CustomNodeManager, Loader, dynModel.PreferenceSettings);\n+                }\n+                catch\n+                {\n+                    MessageBox.Show(String.Format(Resources.MessageFailToUninstallPackage,\n+                        ResourceProvider.ProductName,\n+                        DownloadRequest.asset_name.ToString()),\n+                        Resources.UninstallFailureMessageBoxTitle,\n+                        MessageBoxButton.OK, MessageBoxImage.Error);\n+                }\n+            }\n+\n+            var settings = Model.PreferenceSettings;\n+            PackageDownloadHandle packageDownloadHandle = new PackageDownloadHandle();\n+            packageDownloadHandle.Name = DownloadRequest.asset_name;\n+            packageDownloadHandle.Done(downloadPath);\n+\n+            //string installedPkgPath = string.Empty;\n+            Package dynPkg = null;\n+            if (packageDownloadHandle.Extract(Model, this.PackageInstallPath, out dynPkg))\n+            {\n+                var p = Package.FromDirectory(dynPkg.RootDirectory, Model.Logger);\n+                p.ID = DownloadRequest.asset_id;\n+                Application.Current.Dispatcher.Invoke((Action)(() =>\n+                {\n+                    Loader.Load(p);\n+                }));\n+                packageDownloadHandle.DownloadState = PackageDownloadHandle.State.Installed;\n+                this.PackageInstallPath = string.Empty;\n+            }\n+        }\n+\n+        /// <summary>\n+        /// Download and Install Dynamo Package\n+        /// </summary>\n+        /// <param name=\"pkg\"></param>\n+        public void DownloadAndInstall(string pkg)\n+        {\n+            string[] temp = pkg.Split(',');\n+            PackageManagerRequest req = new PackageManagerRequest(string.Format(\"assets/{0}\", temp[0]), Method.GET);\n+            ResponseWithContentBody<dynamic> response = Client.ExecuteAndDeserializeDynamoRequest(req);\n+            DownloadRequest = response.content;\n+\n+            PackageManagerRequest fileReq = new PackageManagerRequest(string.Format(\"files/download?file_ids={0}&asset_id={1}\", temp[1], temp[0]), Method.GET, true);\n+            Response res = Client.ExecuteDynamoRequest(fileReq);\n+            var pathToPackage = Client.GetFileFromResponse(res);\n+            InstallPackage(pathToPackage);\n+        }\n+\n+        public string GetCustomPathForInstall()","path":"src/DynamoPackagesUI/Utilities/PackageManagerCommands.cs","position":128,"original_position":128,"commit_id":"c1213d5c7dd948676c830361f61a4619308b4a21","original_commit_id":"c1213d5c7dd948676c830361f61a4619308b4a21","user":{"login":"sharadkjaiswal","id":1754137,"avatar_url":"https://avatars.githubusercontent.com/u/1754137?v=3","gravatar_id":"","url":"https://api.github.com/users/sharadkjaiswal","html_url":"https://github.com/sharadkjaiswal","followers_url":"https://api.github.com/users/sharadkjaiswal/followers","following_url":"https://api.github.com/users/sharadkjaiswal/following{/other_user}","gists_url":"https://api.github.com/users/sharadkjaiswal/gists{/gist_id}","starred_url":"https://api.github.com/users/sharadkjaiswal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sharadkjaiswal/subscriptions","organizations_url":"https://api.github.com/users/sharadkjaiswal/orgs","repos_url":"https://api.github.com/users/sharadkjaiswal/repos","events_url":"https://api.github.com/users/sharadkjaiswal/events{/privacy}","received_events_url":"https://api.github.com/users/sharadkjaiswal/received_events","type":"User","site_admin":false},"body":"This method gets and sets PackageInstallPath, which is not obvious from this method name. Ideally Get methods should not modify the state of this object.","created_at":"2016-12-06T08:49:34Z","updated_at":"2016-12-06T09:01:33Z","html_url":"https://github.com/DynamoDS/Dynamo/pull/7376#discussion_r91033155","pull_request_url":"https://api.github.com/repos/DynamoDS/Dynamo/pulls/7376","_links":{"self":{"href":"https://api.github.com/repos/DynamoDS/Dynamo/pulls/comments/91033155"},"html":{"href":"https://github.com/DynamoDS/Dynamo/pull/7376#discussion_r91033155"},"pull_request":{"href":"https://api.github.com/repos/DynamoDS/Dynamo/pulls/7376"}}},"pull_request":{"url":"https://api.github.com/repos/DynamoDS/Dynamo/pulls/7376","id":95469417,"html_url":"https://github.com/DynamoDS/Dynamo/pull/7376","diff_url":"https://github.com/DynamoDS/Dynamo/pull/7376.diff","patch_url":"https://github.com/DynamoDS/Dynamo/pull/7376.patch","issue_url":"https://api.github.com/repos/DynamoDS/Dynamo/issues/7376","number":7376,"state":"open","locked":false,"title":"Explore Packages using CEF and New UI","user":{"login":"jitnev","id":17825191,"avatar_url":"https://avatars.githubusercontent.com/u/17825191?v=3","gravatar_id":"","url":"https://api.github.com/users/jitnev","html_url":"https://github.com/jitnev","followers_url":"https://api.github.com/users/jitnev/followers","following_url":"https://api.github.com/users/jitnev/following{/other_user}","gists_url":"https://api.github.com/users/jitnev/gists{/gist_id}","starred_url":"https://api.github.com/users/jitnev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jitnev/subscriptions","organizations_url":"https://api.github.com/users/jitnev/orgs","repos_url":"https://api.github.com/users/jitnev/repos","events_url":"https://api.github.com/users/jitnev/events{/privacy}","received_events_url":"https://api.github.com/users/jitnev/received_events","type":"User","site_admin":false},"body":"### Purpose\r\n\r\nDynamoPackagesUI project is updated to include functionality for exploring the packages and authors\r\n\r\n-To integrate studio code (C#) with new web UI code, from C# code we have to register object with Chromium browser instance.\r\n-Once C# object is registered, from Chromium Browser we can call any public C# functions from JavaScript code\r\n\r\n### Declarations\r\n\r\nUser can do below things from Explore Packages, Explore Authors tabs,\r\n-Install\\Uninstall Packages\r\n-Install Packages to a folder\r\n-Open Root Folder\r\n-Dependency Installation\r\n-Mark for Uninstall\r\n\r\n### Reviewers\r\n\r\n@sharadkjaiswal\r\n\r\n### FYIs\r\n\r\n@Dewb @ramramps\r\n","created_at":"2016-11-28T10:09:48Z","updated_at":"2016-12-06T09:01:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"36d484654c5f162674090d249fc2d4bb8e4af74f","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/DynamoDS/Dynamo/pulls/7376/commits","review_comments_url":"https://api.github.com/repos/DynamoDS/Dynamo/pulls/7376/comments","review_comment_url":"https://api.github.com/repos/DynamoDS/Dynamo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DynamoDS/Dynamo/issues/7376/comments","statuses_url":"https://api.github.com/repos/DynamoDS/Dynamo/statuses/c1213d5c7dd948676c830361f61a4619308b4a21","head":{"label":"jitnev:ExplorePackagesNew","ref":"ExplorePackagesNew","sha":"c1213d5c7dd948676c830361f61a4619308b4a21","user":{"login":"jitnev","id":17825191,"avatar_url":"https://avatars.githubusercontent.com/u/17825191?v=3","gravatar_id":"","url":"https://api.github.com/users/jitnev","html_url":"https://github.com/jitnev","followers_url":"https://api.github.com/users/jitnev/followers","following_url":"https://api.github.com/users/jitnev/following{/other_user}","gists_url":"https://api.github.com/users/jitnev/gists{/gist_id}","starred_url":"https://api.github.com/users/jitnev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jitnev/subscriptions","organizations_url":"https://api.github.com/users/jitnev/orgs","repos_url":"https://api.github.com/users/jitnev/repos","events_url":"https://api.github.com/users/jitnev/events{/privacy}","received_events_url":"https://api.github.com/users/jitnev/received_events","type":"User","site_admin":false},"repo":{"id":64501228,"name":"Dynamo","full_name":"jitnev/Dynamo","owner":{"login":"jitnev","id":17825191,"avatar_url":"https://avatars.githubusercontent.com/u/17825191?v=3","gravatar_id":"","url":"https://api.github.com/users/jitnev","html_url":"https://github.com/jitnev","followers_url":"https://api.github.com/users/jitnev/followers","following_url":"https://api.github.com/users/jitnev/following{/other_user}","gists_url":"https://api.github.com/users/jitnev/gists{/gist_id}","starred_url":"https://api.github.com/users/jitnev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jitnev/subscriptions","organizations_url":"https://api.github.com/users/jitnev/orgs","repos_url":"https://api.github.com/users/jitnev/repos","events_url":"https://api.github.com/users/jitnev/events{/privacy}","received_events_url":"https://api.github.com/users/jitnev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jitnev/Dynamo","description":"Visual Programming","fork":true,"url":"https://api.github.com/repos/jitnev/Dynamo","forks_url":"https://api.github.com/repos/jitnev/Dynamo/forks","keys_url":"https://api.github.com/repos/jitnev/Dynamo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jitnev/Dynamo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jitnev/Dynamo/teams","hooks_url":"https://api.github.com/repos/jitnev/Dynamo/hooks","issue_events_url":"https://api.github.com/repos/jitnev/Dynamo/issues/events{/number}","events_url":"https://api.github.com/repos/jitnev/Dynamo/events","assignees_url":"https://api.github.com/repos/jitnev/Dynamo/assignees{/user}","branches_url":"https://api.github.com/repos/jitnev/Dynamo/branches{/branch}","tags_url":"https://api.github.com/repos/jitnev/Dynamo/tags","blobs_url":"https://api.github.com/repos/jitnev/Dynamo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jitnev/Dynamo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jitnev/Dynamo/git/refs{/sha}","trees_url":"https://api.github.com/repos/jitnev/Dynamo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jitnev/Dynamo/statuses/{sha}","languages_url":"https://api.github.com/repos/jitnev/Dynamo/languages","stargazers_url":"https://api.github.com/repos/jitnev/Dynamo/stargazers","contributors_url":"https://api.github.com/repos/jitnev/Dynamo/contributors","subscribers_url":"https://api.github.com/repos/jitnev/Dynamo/subscribers","subscription_url":"https://api.github.com/repos/jitnev/Dynamo/subscription","commits_url":"https://api.github.com/repos/jitnev/Dynamo/commits{/sha}","git_commits_url":"https://api.github.com/repos/jitnev/Dynamo/git/commits{/sha}","comments_url":"https://api.github.com/repos/jitnev/Dynamo/comments{/number}","issue_comment_url":"https://api.github.com/repos/jitnev/Dynamo/issues/comments{/number}","contents_url":"https://api.github.com/repos/jitnev/Dynamo/contents/{+path}","compare_url":"https://api.github.com/repos/jitnev/Dynamo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jitnev/Dynamo/merges","archive_url":"https://api.github.com/repos/jitnev/Dynamo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jitnev/Dynamo/downloads","issues_url":"https://api.github.com/repos/jitnev/Dynamo/issues{/number}","pulls_url":"https://api.github.com/repos/jitnev/Dynamo/pulls{/number}","milestones_url":"https://api.github.com/repos/jitnev/Dynamo/milestones{/number}","notifications_url":"https://api.github.com/repos/jitnev/Dynamo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jitnev/Dynamo/labels{/name}","releases_url":"https://api.github.com/repos/jitnev/Dynamo/releases{/id}","deployments_url":"https://api.github.com/repos/jitnev/Dynamo/deployments","created_at":"2016-07-29T18:12:02Z","updated_at":"2016-07-29T18:12:20Z","pushed_at":"2016-12-06T04:52:50Z","git_url":"git://github.com/jitnev/Dynamo.git","ssh_url":"git@github.com:jitnev/Dynamo.git","clone_url":"https://github.com/jitnev/Dynamo.git","svn_url":"https://github.com/jitnev/Dynamo","homepage":"http://dynamobim.org","size":948026,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"DynamoDS:master","ref":"master","sha":"234c5df1c6a1afdfdf5dcb2ae365830bc00c4efd","user":{"login":"DynamoDS","id":6528209,"avatar_url":"https://avatars.githubusercontent.com/u/6528209?v=3","gravatar_id":"","url":"https://api.github.com/users/DynamoDS","html_url":"https://github.com/DynamoDS","followers_url":"https://api.github.com/users/DynamoDS/followers","following_url":"https://api.github.com/users/DynamoDS/following{/other_user}","gists_url":"https://api.github.com/users/DynamoDS/gists{/gist_id}","starred_url":"https://api.github.com/users/DynamoDS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DynamoDS/subscriptions","organizations_url":"https://api.github.com/users/DynamoDS/orgs","repos_url":"https://api.github.com/users/DynamoDS/repos","events_url":"https://api.github.com/users/DynamoDS/events{/privacy}","received_events_url":"https://api.github.com/users/DynamoDS/received_events","type":"Organization","site_admin":false},"repo":{"id":3395179,"name":"Dynamo","full_name":"DynamoDS/Dynamo","owner":{"login":"DynamoDS","id":6528209,"avatar_url":"https://avatars.githubusercontent.com/u/6528209?v=3","gravatar_id":"","url":"https://api.github.com/users/DynamoDS","html_url":"https://github.com/DynamoDS","followers_url":"https://api.github.com/users/DynamoDS/followers","following_url":"https://api.github.com/users/DynamoDS/following{/other_user}","gists_url":"https://api.github.com/users/DynamoDS/gists{/gist_id}","starred_url":"https://api.github.com/users/DynamoDS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DynamoDS/subscriptions","organizations_url":"https://api.github.com/users/DynamoDS/orgs","repos_url":"https://api.github.com/users/DynamoDS/repos","events_url":"https://api.github.com/users/DynamoDS/events{/privacy}","received_events_url":"https://api.github.com/users/DynamoDS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DynamoDS/Dynamo","description":"Visual Programming","fork":false,"url":"https://api.github.com/repos/DynamoDS/Dynamo","forks_url":"https://api.github.com/repos/DynamoDS/Dynamo/forks","keys_url":"https://api.github.com/repos/DynamoDS/Dynamo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DynamoDS/Dynamo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DynamoDS/Dynamo/teams","hooks_url":"https://api.github.com/repos/DynamoDS/Dynamo/hooks","issue_events_url":"https://api.github.com/repos/DynamoDS/Dynamo/issues/events{/number}","events_url":"https://api.github.com/repos/DynamoDS/Dynamo/events","assignees_url":"https://api.github.com/repos/DynamoDS/Dynamo/assignees{/user}","branches_url":"https://api.github.com/repos/DynamoDS/Dynamo/branches{/branch}","tags_url":"https://api.github.com/repos/DynamoDS/Dynamo/tags","blobs_url":"https://api.github.com/repos/DynamoDS/Dynamo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DynamoDS/Dynamo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DynamoDS/Dynamo/git/refs{/sha}","trees_url":"https://api.github.com/repos/DynamoDS/Dynamo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DynamoDS/Dynamo/statuses/{sha}","languages_url":"https://api.github.com/repos/DynamoDS/Dynamo/languages","stargazers_url":"https://api.github.com/repos/DynamoDS/Dynamo/stargazers","contributors_url":"https://api.github.com/repos/DynamoDS/Dynamo/contributors","subscribers_url":"https://api.github.com/repos/DynamoDS/Dynamo/subscribers","subscription_url":"https://api.github.com/repos/DynamoDS/Dynamo/subscription","commits_url":"https://api.github.com/repos/DynamoDS/Dynamo/commits{/sha}","git_commits_url":"https://api.github.com/repos/DynamoDS/Dynamo/git/commits{/sha}","comments_url":"https://api.github.com/repos/DynamoDS/Dynamo/comments{/number}","issue_comment_url":"https://api.github.com/repos/DynamoDS/Dynamo/issues/comments{/number}","contents_url":"https://api.github.com/repos/DynamoDS/Dynamo/contents/{+path}","compare_url":"https://api.github.com/repos/DynamoDS/Dynamo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DynamoDS/Dynamo/merges","archive_url":"https://api.github.com/repos/DynamoDS/Dynamo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DynamoDS/Dynamo/downloads","issues_url":"https://api.github.com/repos/DynamoDS/Dynamo/issues{/number}","pulls_url":"https://api.github.com/repos/DynamoDS/Dynamo/pulls{/number}","milestones_url":"https://api.github.com/repos/DynamoDS/Dynamo/milestones{/number}","notifications_url":"https://api.github.com/repos/DynamoDS/Dynamo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DynamoDS/Dynamo/labels{/name}","releases_url":"https://api.github.com/repos/DynamoDS/Dynamo/releases{/id}","deployments_url":"https://api.github.com/repos/DynamoDS/Dynamo/deployments","created_at":"2012-02-09T07:35:33Z","updated_at":"2016-12-04T10:55:19Z","pushed_at":"2016-12-06T08:15:40Z","git_url":"git://github.com/DynamoDS/Dynamo.git","ssh_url":"git@github.com:DynamoDS/Dynamo.git","clone_url":"https://github.com/DynamoDS/Dynamo.git","svn_url":"https://github.com/DynamoDS/Dynamo","homepage":"http://dynamobim.org","size":1217282,"stargazers_count":403,"watchers_count":403,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":270,"mirror_url":null,"open_issues_count":687,"forks":270,"open_issues":687,"watchers":403,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DynamoDS/Dynamo/pulls/7376"},"html":{"href":"https://github.com/DynamoDS/Dynamo/pull/7376"},"issue":{"href":"https://api.github.com/repos/DynamoDS/Dynamo/issues/7376"},"comments":{"href":"https://api.github.com/repos/DynamoDS/Dynamo/issues/7376/comments"},"review_comments":{"href":"https://api.github.com/repos/DynamoDS/Dynamo/pulls/7376/comments"},"review_comment":{"href":"https://api.github.com/repos/DynamoDS/Dynamo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DynamoDS/Dynamo/pulls/7376/commits"},"statuses":{"href":"https://api.github.com/repos/DynamoDS/Dynamo/statuses/c1213d5c7dd948676c830361f61a4619308b4a21"}}}}
{"actor":{"display_login":"sharadkjaiswal"}}