Exemplo n.º 1
0
        public void DoWorkProject()
        {
            var jiraService    = new JiraService();
            var projectService = new ProjectService();
            var jsonProject    = JsonConvert.DeserializeObject(jiraService.GetProjectDetails(ObjectId));

            Payload = new WorkerPayload()
            {
                ProjectData = jsonProject
            };
            projectService.Save(jsonProject);
            ev.Set();
        }
Exemplo n.º 2
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();
        }
Exemplo n.º 3
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);
                //    }
                //}
            }
        }
Exemplo n.º 4
0
        private IEnumerable <object> Phase1()
        {
            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];

            var     projectDataJson = jiraService.GetLatestProjectDataJSON();
            dynamic obj             = JsonConvert.DeserializeObject(projectDataJson);
            int     total           = obj.Count;
            int     current         = 0;
            var     countToAssign   = total > MaxPool ? MaxPool : total;

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

            for (int i = 0; i < countToAssign; i++)
            {
                StartProjectWorker(events, workers, threads, i, obj[current].id.Value);
                current++;
            }

            while (current < total)
            {
                int index = WaitHandle.WaitAny(events);
                jsonProjects.Add(workers[index].Payload);
                StartProjectWorker(events, workers, threads, index, obj[current].id.Value);
                current++;
            }

            WaitHandle.WaitAll(events);
            for (var i = 0; i < workers.Length; i++)
            {
                if (workers[i] != null && workers[i].Payload != null)
                {
                    dynamic pj = workers[i].Payload.ProjectData;
                    jsonProjects.Add(new SmallProject()
                    {
                        Key = pj.key.Value, ProjectID = pj.id.Value
                    });
                }
            }
            // Getting project list to start phase 2, to capture issue, user and work log information.
            return(jsonProjects);
        }
Exemplo n.º 5
0
        private int MaxPool         = Utilities.MaxPool; // For threading, set a max pool amount. In case there are a lot of items.

        public ImportServices()
        {
            jser = new JiraService();
            pser = new ProjectService();
        }