Ejemplo n.º 1
0
        public void DoWorkItemUser()
        {
            var jiraService = new JiraService();
            var itemService = new ItemService();
            var jsonProject = JsonConvert.DeserializeObject(jiraService.GetSelfResults(Self));

            Payload = new WorkerPayload()
            {
                ProjectData = jsonProject
            };
            itemService.Save(jsonProject, int.Parse(ForignKeyId));
            ev.Set();
        }
Ejemplo n.º 2
0
        private void Phase2(SmallProject sp)
        {
            var jiraService = new JiraService();

            ManualResetEvent[] events  = Enumerable.Range(1, 10).Select(e => new ManualResetEvent(true)).ToArray();
            ImportWorker[]     workers = new ImportWorker[10];
            Thread[]           threads = new Thread[10];

            // Get All Issues for project.
            //var itemDataJson = jiraService.GetIssueList(sp.ProjectID);
            var     itemDataJson  = jiraService.GetIssueList(sp.Key);
            dynamic obj           = JsonConvert.DeserializeObject(itemDataJson);
            int     current       = 0;
            int     total         = obj.issues.Count;
            var     countToAssign = total > MaxPool ? MaxPool : total;

            // if there are no issues, just skip through.
            if (obj.issues.Count > 0)
            {
                for (int i = 0; i < total; i++)
                {
                    dynamic jsonProject = JsonConvert.DeserializeObject(jiraService.GetSelfResults(obj.issues[i].self.Value));
                    var     itemService = new ItemService();
                    itemService.Save(jsonProject, int.Parse(sp.ProjectID));
                }



                //List<object> jsonProjects = new List<object>();

                //// Return specific details for each issue
                //for (int i = 0; i < countToAssign; i++) {
                //    StartIssueWorker(events, workers, threads, i, obj.issues[i].id.Value, sp.ProjectID, obj.issues[i].self.Value);
                //    current++;
                //}

                //while (current < total) {
                //    int index = WaitHandle.WaitAny(events);
                //    jsonProjects.Add(workers[index].Payload);
                //    StartIssueWorker(events, workers, threads, index, obj.issues[index].id.Value, sp.ProjectID, obj.issues[index].self.Value);
                //    current++;
                //}
                //WaitHandle.WaitAll(events);
                //for (var i = 0; i < workers.Length; i++) {
                //    if (workers[i] != null && workers[i].Payload != null) {
                //        jsonProjects.Add(workers[i].Payload);
                //    }
                //}
            }
        }