Esempio n. 1
0
        /// <summary>
        /// Receive project specifications
        /// </summary>
        /// <param name="projectId"></param>
        /// <returns></returns>
        public GetProjectDetailsResult GetProjectDetails(string projectId)
        {
            var r = new GetProjectDetailsResult();
            // ReSharper disable once CollectionNeverQueried.Local
            List <string[]> resourceBinding = new List <string[]>();

            try
            {
                if (GetProjectDetailsProvider == null)
                {
                    GetProjectDetailsProvider = new GetProjectDetailsProvider();
                }
                var json = GetProjectDetailsProvider.Get(Url, _proxy, KeyPublic, KeySecret, projectId).Replace("\"results\":[", "\"resultsArray\":[");
                var n    = json.IndexOf("\"resource_binding\":{\"", StringComparison.Ordinal);

                if (n > -1)
                {
                    var nn  = json.IndexOf("}", n, StringComparison.Ordinal);
                    var str = json.Substring(n, nn - n + 2);
                    json = json.Replace(str, "");
                    var ss = str.Substring(19, str.Length - 2 - 19).Split(',');
                    resourceBinding.AddRange(from s in ss
                                             select s.Split(':')
                                             into item
                                             where item.Length == 2
                                             select new[]
                    {
                        item[0].Substring(1, item[0].Length - 2), item[1].Substring(2, item[1].Length - 4)
                    });
                }
                r = JsonConvert.DeserializeObject <GetProjectDetailsResult>(json);
                if (r.Status.Code == 0)
                {
                    r.Result.ResourceBinding = resourceBinding;
                }
            }
            catch (Exception err)
            {
                r.Status.Code = -1;
                r.Status.Msg  = err.Message;
            }
            return(r);
        }
        /// <summary>
        /// Receive project specifications 
        /// </summary>
        /// <param name="projectId"></param>
        /// <returns></returns>
        public GetProjectDetailsResult GetProjectDetails(string projectId)
        {
            var r = new GetProjectDetailsResult();
            // ReSharper disable once CollectionNeverQueried.Local
            List<string[]> resourceBinding = new List<string[]>();
            try
            {
                if (GetProjectDetailsProvider == null)
                    GetProjectDetailsProvider = new GetProjectDetailsProvider();
                var json = GetProjectDetailsProvider.Get(Url, _proxy, KeyPublic, KeySecret, projectId).Replace("\"results\":[", "\"resultsArray\":[");
                var n = json.IndexOf("\"resource_binding\":{\"", StringComparison.Ordinal);

                if (n > -1)
                {
                    var nn = json.IndexOf("}", n, StringComparison.Ordinal);
                    var str = json.Substring(n, nn - n + 2);
                    json = json.Replace(str, "");
                    var ss = str.Substring(19, str.Length - 2-19).Split(',');
                    resourceBinding.AddRange(from s in ss
                        select s.Split(':')
                        into item
                        where item.Length == 2
                        select new[]
                        {
                            item[0].Substring(1, item[0].Length - 2), item[1].Substring(2, item[1].Length - 4)
                        });
                }
                r = JsonConvert.DeserializeObject<GetProjectDetailsResult>(json);
                if (r.Status.Code == 0)
                {
                    r.Result.ResourceBinding = resourceBinding;
                }

            }
            catch (Exception err)
            {
                r.Status.Code = -1;
                r.Status.Msg = err.Message;
            }
            return r;
        }