Пример #1
0
        /// <summary>
        /// get the promote status of specific promote job id
        /// </summary>
        /// <param name="promoteJobId"></param>
        /// <returns>PromoteStatusViewModel</returns>
        public PromoteStatusViewModel GetPromoteStatus(string promoteJobId)
        {
            PromoteStatusViewModel vm = null;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(_apiurl);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", _login);

                HttpResponseMessage response = client.GetAsync("_apis/work/processAdmin/processes/status/" + promoteJobId).Result;

                if (response.IsSuccessStatusCode)
                {
                    vm = response.Content.ReadAsAsync <PromoteStatusViewModel>().Result;
                }

                response.Dispose();

                return(vm);
            }
        }
Пример #2
0
        private static int ImportSingle(string zipFile)
        {
            if (!File.Exists(zipFile))
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Error: Invlaid argument, zip file not found");
                return(0);
            }

            Processes process = new Processes(_appConfig);

            Console.ForegroundColor = ConsoleColor.White;
            Console.Write("importing process '" + zipFile + "': ");

            ImportViewModel importVm = process.ImportSingleProcessRESTCall(zipFile);

            if (!importVm.Success)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Error: " + importVm.Message);
                Console.WriteLine("");

                foreach (var item in importVm.validationResults)
                {
                    Console.WriteLine("Line " + item.line + " : " + item.description);
                }
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Success");

                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("checking promote status...");

                PromoteStatusViewModel promoteStatusVm = new PromoteStatusViewModel()
                {
                    complete = 0
                };

                do
                {
                    //check the status of the promote job
                    promoteStatusVm = process.GetPromoteStatus(importVm.PromoteJobId);

                    Console.Write(".");

                    if (promoteStatusVm == null)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Error: promote json package is empty");
                        break;
                    }

                    Thread.Sleep(10000);
                }while (promoteStatusVm.complete == 0);

                Thread.Sleep(10000);

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Success");

                Console.ForegroundColor = ConsoleColor.White;
                Console.Write("adding a buffer to promote process (this may take a couple minutes): ");

                Thread.Sleep(120000);

                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Success");
            }

            process = null;

            return(1);
        }