コード例 #1
0
 /// <remarks/>
 public void getProjectRoleActorsAsync(string in0, RemoteProjectRole in1, RemoteProject in2, object userState) {
     if ((this.getProjectRoleActorsOperationCompleted == null)) {
         this.getProjectRoleActorsOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetProjectRoleActorsOperationCompleted);
     }
     this.InvokeAsync("getProjectRoleActors", new object[] {
                 in0,
                 in1,
                 in2}, this.getProjectRoleActorsOperationCompleted, userState);
 }
コード例 #2
0
ファイル: JiraSearch.cs プロジェクト: robspages/JiraSharp
 public List <RemoteIssue> searchIssues(RemoteProject Project, String searchTerm, int limit)
 {
     RemoteIssue[] issuesArray = jiraSoapService.getIssuesFromJqlSearch(UserToken, searchTerm, limit);
     return(new List <RemoteIssue>(issuesArray));
 }
コード例 #3
0
 public RemoteProjectRoleActors getProjectRoleActors(string in0, RemoteProjectRole in1, RemoteProject in2) {
     object[] results = this.Invoke("getProjectRoleActors", new object[] {
                 in0,
                 in1,
                 in2});
     return ((RemoteProjectRoleActors)(results[0]));
 }
コード例 #4
0
        public static Task <string> BuildReport(List <RemoteProject> projectInfo, RemoteProject core)
        {
            return(Task.Run(() =>
            {
                JsonRelease release = new JsonRelease();

                if (!Directory.Exists("Report"))
                {
                    Directory.CreateDirectory("Report");
                }
                var dir = Directory.GetCurrentDirectory().ParentDirectory().ParentDirectory();
                string report = File.ReadAllText(dir + "/Report/report.html");

                if (File.Exists("Report/report.html"))
                {
                    File.Delete("Report/report.html");
                }
                StreamWriter writer = new StreamWriter("Report/report.html");

                report = report.Replace("{release_cycle}", RedmineVersion);
                release.ReleaseCycle = RedmineVersion;
                Application.Current.Dispatcher.Invoke(() =>
                {
                    var w = new ReportArgsWindow();
                    w.ShowDialog();
                    report = report.Replace("{title}", w.ReportArgs.Title);
                    release.ReleaseTitle = w.ReportArgs.Title;

                    report = report.Replace("{general_feeling}", w.ReportArgs.Feeling);
                    release.ReleaseGeneralFeeling = w.ReportArgs.Feeling;

                    if (w.ReportArgs.Notes != null)
                    {
                        report = report.Replace("{notes}", w.ReportArgs.Notes.Replace(Environment.NewLine, "<br/>"));
                    }
                    release.ReleaseNotes = w.ReportArgs.Notes;

                    report = report.Replace("{server_version}", w.ReportArgs.ServerVersion);
                    release.ServerVersion = w.ReportArgs.ServerVersion;
                });

                release.TicketsDesign = designTickets.Count;
                report = report.Replace("{bugs}",
                                        issues.Count(iss => iss.Tracker != null && iss.Tracker.Id == 1).ToString());
                release.BugsResolved = issues.Count(iss => iss.Tracker != null && iss.Tracker.Id == 1);

                report = report.Replace("{features}",
                                        issues.Count(iss => iss.Tracker != null && iss.Tracker.Id == 2).ToString());
                release.FeaturesAdded = issues.Count(iss => iss.Tracker != null && iss.Tracker.Id == 2);

                report = report.Replace("{refactors}",
                                        issues.Count(iss => iss.Tracker != null && iss.Tracker.Id == 9).ToString());
                release.TicketsForRefactoring = issues.Count(iss => iss.Tracker != null && iss.Tracker.Id == 9);


                report = report.Replace("{rejected_tickets}", _rejectedIssues.Count.ToString());
                release.TicketsRejected = _rejectedIssues.Count;


                report = report.Replace("{support_tickets}", _supportIssuesCount.ToString());
                release.SupportTicketsHandled = _supportIssuesCount;

                var aliasBuilder = new StringBuilder();

                var issuesSorted = issues.Where(i => i.CustomFields.Any(
                                                    cf => cf.Name == "Package")).GroupBy(i => i.CustomFields.First(
                                                                                             cf => cf.Name == "Package").Values.Join("<br/>")).ToList();

                release.ReleaseIssuesPerProject = new List <JsonProjectIssues>();

                string project;

                foreach (var iss in issuesSorted)
                {
                    JsonProjectIssues pi = new JsonProjectIssues();
                    pi.ProjectInfo = new List <JsonIssuesInfo>();
                    project = iss.Key;

                    pi.ProjectName = project;
                    aliasBuilder.Append(String.Format(@"<tr><td>{0}</td><td><table id=""box-table-a"">
				            <thead>
					            <tr>
						            <th>Changelog</th>
						            <th>ID</th>
					            </tr>
				            </thead>
				            <tbody>"                , project));

                    foreach (var issue in iss.ToList())
                    {
                        var prinf = new JsonIssuesInfo();
                        var changelog = "";
                        try
                        {
                            changelog =
                                issue.CustomFields.First(cf => cf.Name == "Change log message").Values[0].ToString();
                        }
                        catch
                        {
                        }
                        prinf.ChangelogName = changelog;
                        prinf.TicketId = issue.Id;
                        prinf.Title = issue.Subject;
                        prinf.Tracker = issue.Tracker.Name;
                        pi.ProjectInfo.Add(prinf);
                        Regex regex = new Regex(@"#([0-9])\w+");
                        var match = regex.Matches(changelog);
                        if (match.Count > 0)
                        {
                            foreach (var m in match)
                            {
                                changelog = changelog.Replace(m.ToString(),
                                                              "<a target='_blank' href='http://redmine.dotbydot.eu/issues/" +
                                                              m.ToString().Replace("#", "") + "'>" + m.ToString() + "</a>");
                            }
                        }

                        aliasBuilder.Append(String.Format(@"<tr><td title=""{0}"">(<strong>{1}</strong>) {2}</td><td>{3}</td></tr>",
                                                          issue.Subject,
                                                          issue.Tracker.Name,
                                                          changelog,
                                                          "<a target='_blank' href=\"http://redmine.dotbydot.eu/issues/" + issue.Id + "\">" +
                                                          issue.Id + "</a>"
                                                          ));
                    }
                    aliasBuilder.Append("</tbody></table></td></tr>");
                    release.ReleaseIssuesPerProject.Add(pi);
                }
                report = report.Replace("{tickets}", aliasBuilder.ToString());

                release.ReleaseRejectedIssues = new List <JsonRejectedIssuesInfo>();
                aliasBuilder = new StringBuilder();
                if (rejectedIssues.Count > 0)
                {
                    foreach (var issue in rejectedIssues)
                    {
                        JsonRejectedIssuesInfo pi = new JsonRejectedIssuesInfo();
                        var changelog = "";
                        try
                        {
                            changelog =
                                issue.CustomFields.First(cf => cf.Name == "Reason for Rejecting").Values[0].ToString();
                        }
                        catch
                        {
                        }
                        pi.Reason = changelog;
                        pi.TicketId = issue.Id;
                        pi.Title = issue.Subject;
                        Regex regex = new Regex(@"#([0-9])\w+");
                        var match = regex.Matches(changelog);
                        if (match.Count > 0)
                        {
                            foreach (var m in match)
                            {
                                changelog = changelog.Replace(m.ToString(),
                                                              "<a target='_blank' href='http://redmine.dotbydot.eu/issues/" +
                                                              m.ToString().Replace("#", "") + "'>" + m.ToString() + "</a>");
                            }
                        }

                        aliasBuilder.Append(
                            String.Format(@"<tr><td>(<strong>{0}</strong>) {1}</td><td>{2}</td><td>{3}</td></tr>",
                                          issue.Tracker.Name,
                                          issue.Subject,
                                          changelog,
                                          "<a target='_blank' href=\"http://redmine.dotbydot.eu/issues/" + issue.Id + "\">" +
                                          issue.Id + "</a>"
                                          ));
                        release.ReleaseRejectedIssues.Add(pi);
                    }


                    report = report.Replace("{rejected-tickets}", aliasBuilder.ToString());
                }
                report = report.Replace("{core_version}", core.Version);
                release.CoreClientVersion = core.Version;
                release.UserPluginsVersions = new List <string>();
                //if (projectInfo.Any(p => p.Update))
                //{
                //    aliasBuilder.Clear();
                //    var updated = projectInfo.Where(p => p.Update).ToList();
                //    List<string> plversions = new List<string>();
                //    updated.ForEach(p =>
                //    {
                //        plversions.Add(string.Format("{0} {1}", p.Name, p.SuggestedVersion));
                //        aliasBuilder.Append(string.Format("<li>{0} {1}</li>", p.Name, p.SuggestedVersion));
                //    });
                //    release.UserPluginsVersions = plversions;
                //    report = report.Replace("{plugin_versions}", aliasBuilder.ToString());
                //}
                //writer.Write(report);
                //writer.Close();
                var json = JsonSerializer.SerializeToString(release);
                using (var sw = new StreamWriter("Report/report.json"))
                {
                    sw.Write(json);
                }
                foreach (var file in Directory.GetFiles(dir + "/Report"))
                {
                    if (file.EndsWith(".html"))
                    {
                        continue;
                    }
                    try
                    {
                        File.Copy(file, "Report/" + Path.GetFileName(file), true);
                    }
                    catch
                    {
                    }
                }
                return json;
            }));
        }
コード例 #5
0
ファイル: JiraSearch.cs プロジェクト: robspages/JiraSharp
 public List <RemoteIssue> GetIssuesForFilter(RemoteProject Project, String filterID)
 {
     RemoteIssue[] issuesArray = jiraSoapService.getIssuesFromFilter(UserToken, filterID);
     return(new List <RemoteIssue>(issuesArray));
 }
コード例 #6
0
 /// <remarks/>
 public void removeActorsFromProjectRoleAsync(string in0, string[] in1, RemoteProjectRole in2, RemoteProject in3, string in4) {
     this.removeActorsFromProjectRoleAsync(in0, in1, in2, in3, in4, null);
 }
コード例 #7
0
 /// <remarks/>
 public void updateProjectAsync(string in0, RemoteProject in1) {
     this.updateProjectAsync(in0, in1, null);
 }
コード例 #8
0
 public RemoteProject CreateProjectFromObject(string in0, RemoteProject in1)
 {
     return(_client.createProjectFromObject(in0, in1));
 }
コード例 #9
0
 public RemoteProjectRoleActors GetProjectRoleActors(string in0, RemoteProjectRole in1, RemoteProject in2)
 {
     return(_client.getProjectRoleActors(in0, in1, in2));
 }
コード例 #10
0
 /// <remarks/>
 public System.IAsyncResult BegincreateProjectFromObject(string in0, RemoteProject in1, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("createProjectFromObject", new object[] {
                 in0,
                 in1}, callback, asyncState);
 }
コード例 #11
0
 public void AddActorsToProjectRole(string in0, string[] in1, RemoteProjectRole in2, RemoteProject in3, string in4)
 {
     _client.addActorsToProjectRole(in0, in1, in2, in3, in4);
 }
コード例 #12
0
 /// <remarks/>
 public System.IAsyncResult BeginremoveActorsFromProjectRole(string in0, string[] in1, RemoteProjectRole in2, RemoteProject in3, string in4, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("removeActorsFromProjectRole", new object[] {
                 in0,
                 in1,
                 in2,
                 in3,
                 in4}, callback, asyncState);
 }
コード例 #13
0
 /// <remarks/>
 public System.IAsyncResult BeginremoveAllRoleActorsByProject(string in0, RemoteProject in1, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("removeAllRoleActorsByProject", new object[] {
                 in0,
                 in1}, callback, asyncState);
 }
コード例 #14
0
 /// <remarks/>
 public System.IAsyncResult BegingetProjectRoleActors(string in0, RemoteProjectRole in1, RemoteProject in2, System.AsyncCallback callback, object asyncState) {
     return this.BeginInvoke("getProjectRoleActors", new object[] {
                 in0,
                 in1,
                 in2}, callback, asyncState);
 }
コード例 #15
0
 /// <remarks/>
 public void removeAllRoleActorsByProjectAsync(string in0, RemoteProject in1) {
     this.removeAllRoleActorsByProjectAsync(in0, in1, null);
 }
コード例 #16
0
 public void RemoveActorsFromProjectRole(string in0, string[] in1, RemoteProjectRole in2, RemoteProject in3, string in4)
 {
     _client.removeActorsFromProjectRole(in0, in1, in2, in3, in4);
 }
コード例 #17
0
 /// <remarks/>
 public void addActorsToProjectRoleAsync(string in0, string[] in1, RemoteProjectRole in2, RemoteProject in3, string in4) {
     this.addActorsToProjectRoleAsync(in0, in1, in2, in3, in4, null);
 }
コード例 #18
0
 public void RemoveAllRoleActorsByProject(string in0, RemoteProject in1)
 {
     _client.removeAllRoleActorsByProject(in0, in1);
 }
コード例 #19
0
 /// <remarks/>
 public void createProjectFromObjectAsync(string in0, RemoteProject in1) {
     this.createProjectFromObjectAsync(in0, in1, null);
 }
コード例 #20
0
 public RemoteProject UpdateProject(string in0, RemoteProject in1)
 {
     return(_client.updateProject(in0, in1));
 }
コード例 #21
0
        /// <summary>
        /// Deletes the remote project and all of its related resources on Azure
        /// </summary>
        /// <param name="project"></param>
        /// <returns></returns>
        public async Task Delete(RemoteProject project)
        {
            await InitClient();

            await azure.ResourceGroups.DeleteByNameAsync(project.ResourceGroup);
        }
コード例 #22
0
        public static ContainerDeploymentTemplate CreateDeploymentTemplate(RemoteProject project, ImageCredentials image)
        {
            // see: https://docs.microsoft.com/en-us/azure/container-instances/container-instances-volume-azure-files
            var template = new ContainerDeploymentTemplate()
            {
                Schema         = "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                ContentVersion = "1.0.0.0",
                Variables      = new ContainerDeploymentTemplate.VariablesModel()
                {
                    ContainerImage = image.Name,
                    ContainerName  = project.AppId
                },
                Resources = new List <ContainerDeploymentTemplate.ResourceModel>()
                {
                    new ContainerDeploymentTemplate.ResourceModel()
                    {
                        Name       = project.AppId,
                        Type       = "Microsoft.ContainerInstance/containerGroups",
                        ApiVersion = "2019-12-01",
                        Location   = "[resourceGroup().location]",
                        Properties = new ContainerDeploymentTemplate.PropertiesModel()
                        {
                            Containers = new List <ContainerDeploymentTemplate.ContainerModel>()
                            {
                                new ContainerDeploymentTemplate.ContainerModel()
                                {
                                    Name       = "[variables('containerName')]",
                                    Properties = new ContainerDeploymentTemplate.ContainerPropertiesModel()
                                    {
                                        Image     = "[variables('containerImage')]",
                                        Resources = new ContainerDeploymentTemplate.ContainerResourcesModel()
                                        {
                                            Requests = new ContainerDeploymentTemplate.ContainerResourceRequestsModel()
                                            {
                                                Cpu        = 1,
                                                MemoryInGb = 1.5
                                            }
                                        },
                                        Ports = new List <ContainerDeploymentTemplate.PortModel>()
                                        {
                                            new ContainerDeploymentTemplate.PortModel()
                                            {
                                                Port     = 80,
                                                Protocol = "tcp"
                                            }
                                        },
                                        VolumeMounts = new List <ContainerDeploymentTemplate.ContainerVolumeMountModel>()
                                        {
                                            new ContainerDeploymentTemplate.ContainerVolumeMountModel()
                                            {
                                                Name      = $"vol{project.AppId}",
                                                MountPath = "/mnt/data"
                                            }
                                        },
                                        EnvironmentVariables = new List <ContainerDeploymentTemplate.ContainerEnvironmentVariableModel>()
                                        {
                                            new ContainerDeploymentTemplate.ContainerEnvironmentVariableModel()
                                            {
                                                Name  = "IS_REMOTE_ENV",
                                                Value = "true"
                                            },
                                            new ContainerDeploymentTemplate.ContainerEnvironmentVariableModel()
                                            {
                                                Name  = "SEED_DATA",
                                                Value = project.SeedData ? "true" : "false"
                                            },
                                            new ContainerDeploymentTemplate.ContainerEnvironmentVariableModel()
                                            {
                                                Name  = "AZURE_FILE_SHARE_NAME",
                                                Value = project.AzureFileShare
                                            },
                                            new ContainerDeploymentTemplate.ContainerEnvironmentVariableModel()
                                            {
                                                Name  = "AZURE_STORAGE_CONNECTION_STRING",
                                                Value = project.StorageConnectionString
                                            },
                                            new ContainerDeploymentTemplate.ContainerEnvironmentVariableModel()
                                            {
                                                Name  = "AZURE_FILE_CSDL_DIR",
                                                Value = "schema"
                                            },
                                            new ContainerDeploymentTemplate.ContainerEnvironmentVariableModel()
                                            {
                                                Name  = "AZURE_FILE_CSDL_FILE",
                                                Value = "Project.csdl"
                                            }
                                        }
                                    }
                                }
                            },
                            OsType    = "Linux",
                            IpAddress = new ContainerDeploymentTemplate.IpAddressModel()
                            {
                                Type  = "Public",
                                Ports = new List <ContainerDeploymentTemplate.PortModel>()
                                {
                                    new ContainerDeploymentTemplate.PortModel()
                                    {
                                        Protocol = "tcp",
                                        Port     = 80
                                    }
                                },
                                DnsNameLabel = project.AppId
                            },
                            Volumes = new List <ContainerDeploymentTemplate.VolumeModel>()
                            {
                                new ContainerDeploymentTemplate.VolumeModel()
                                {
                                    Name      = $"vol{project.AppId}",
                                    AzureFile = new ContainerDeploymentTemplate.AzureFileModel()
                                    {
                                        ShareName          = project.AzureFileShare,
                                        StorageAccountKey  = project.StorageAccountKey,
                                        StorageAccountName = project.StorageAccountName
                                    }
                                }
                            },
                            ImageRegistryCredentials = new List <ContainerDeploymentTemplate.ImageRegistryCredentialsModel>()
                            {
                                new ContainerDeploymentTemplate.ImageRegistryCredentialsModel()
                                {
                                    Server   = image.Server,
                                    Username = image.Username,
                                    Password = image.Password
                                }
                            }
                        }
                    }
                }
            };

            return(template);
        }
コード例 #23
0
 /// <summary>
 /// Createa a new Project instance using a remote project.
 /// </summary>
 /// <param name="remoteProject">Remote project.</param>
 public Project(RemoteProject remoteProject)
     : base(remoteProject)
 {
     _remoteProject = remoteProject;
 }
        private void processSpiraAccount(Pop3Client clientPOP3, AccountDetails account, ApplicationSystem appServer)
        {
            const string METHOD = CLASS + "processSpiraAccount()";

            this._eventLog.EntryLog(METHOD);

            //Create the application client and connect to our project and get users..
            SoapServiceClient clientAppl = (SoapServiceClient)this.CreateApplicationClient(appServer, account);

            //Get users in the project..
            List <RemoteProjectUser> spiraUsers = clientAppl.Project_RetrieveUserMembership();

            //Get the known message IDs..
            List <string> seenUIDs = this.readMessageIDsForAccount(account.AccountID.Value);

            //Get new emails from the client.
            List <Message> newMsgs = this.popGetNewMessages(clientPOP3, account, seenUIDs);

            //Get all projects..
            List <RemoteProject> spiraProjs = clientAppl.Project_Retrieve();

            //Loop through each email.
            foreach (Message msg in newMsgs)
            {
                this._eventLog.WriteTrace(METHOD, "Starting on message " + msg.MessageLogID + "...");

                //Make sure we have a from address, otherwise skip (Delivery Returned messages have no FROM address)
                //First see if the message should be skipped. (Keywords, Headers, or Email Addresses)
                if (msg.Headers != null &&
                    msg.Headers.From != null &&
                    !String.IsNullOrWhiteSpace(msg.Headers.From.Address) &&
                    msg.Headers.From.Address.ToLowerInvariant().Trim() != account.AccountEmail.ToLowerInvariant().Trim())
                {
                    string filterMsg;
                    if (this.doesMessageClearFilters(msg, out filterMsg))
                    {
                        //First see if there's a header we can get the artifact ID from..
                        ArtifactTypeEnum artType = ArtifactTypeEnum.None;
                        int artId = -1;
                        if (msg.Headers.UnknownHeaders[Common.MESSAGEHEADER_SPIRA_ARTIFACT] != null && rgxArtifactToken.IsMatch(msg.Headers.UnknownHeaders[Common.MESSAGEHEADER_SPIRA_ARTIFACT]))
                        {
                            //Get the art type and the id..
                            Match matches = rgxArtifactToken.Match(msg.Headers.UnknownHeaders[Common.MESSAGEHEADER_SPIRA_ARTIFACT]);
                            this.retrieveArtTypeAndId(matches.Groups["type"].Value, matches.Groups["id"].Value, out artType, out artId);
                        }

                        if (artId == -1 || artType == ArtifactTypeEnum.None)
                        {
                            if (rgxArtifactToken.IsMatch(msg.Headers.Subject))
                            {
                                //Get the art type and the id..
                                Match matches = rgxArtifactToken.Match(msg.Headers.Subject);
                                this.retrieveArtTypeAndId(matches.Groups["type"].Value, matches.Groups["id"].Value, out artType, out artId);
                            }
                        }

                        //Change projects, if necessary, and if we're able to..
                        try
                        {
                            int projNum = clientAppl.System_GetProjectIdForArtifact((int)artType, artId);
                            if (projNum != 0)
                            {
                                bool succNewProject = clientAppl.Connection_ConnectToProject(projNum);

                                if (!succNewProject)
                                {
                                    //Couldn't connect to the project this item belongs to. Throw an error.
                                    this._eventLog.WriteMessage("Message " + msg.MessageLogID + " contains information for a project [PR:" + projNum.ToString() + "] that the client could not connect to. Skipping.", System.Diagnostics.EventLogEntryType.Information);
                                    artType = ArtifactTypeEnum.Skip;
                                    artId   = 0;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            this._eventLog.WriteMessage(METHOD, ex, "Message " + msg.MessageLogID + " - while trying to retrieve project number from artifact. Skipping.");
                        }

                        //If we have a match, find the user..
                        if (artId > 0 && artType != ArtifactTypeEnum.None)
                        {
                            //Detect if more than one user is found..
                            int userCnt = spiraUsers.Where(su => su.EmailAddress.ToLowerInvariant() == msg.Headers.From.MailAddress.Address.ToLowerInvariant()).Count();
                            if (userCnt == 1)
                            {
                                RemoteProjectUser selUser = spiraUsers.Where(su => su.EmailAddress.ToLowerInvariant() == msg.Headers.From.MailAddress.Address.ToLowerInvariant()).Single();

                                //See if the item exists in the server..
                                RemoteArtifact remArt = null;
                                try
                                {
                                    switch (artType)
                                    {
                                    case ArtifactTypeEnum.Requirement:
                                        remArt = clientAppl.Requirement_RetrieveById(artId);
                                        break;

                                    case ArtifactTypeEnum.Test_Case:
                                        remArt = clientAppl.TestCase_RetrieveById(artId);
                                        break;

                                    case ArtifactTypeEnum.Incident:
                                        remArt = clientAppl.Incident_RetrieveById(artId);
                                        break;

                                    case ArtifactTypeEnum.Release:
                                        remArt = clientAppl.Release_RetrieveById(artId);
                                        break;

                                    case ArtifactTypeEnum.Task:
                                        remArt = clientAppl.Task_RetrieveById(artId);
                                        break;

                                    case ArtifactTypeEnum.Test_Set:
                                        remArt = clientAppl.TestSet_RetrieveById(artId);
                                        break;
                                    }

                                    if (remArt == null)
                                    {
                                        throw new Exception("Artifact did not exist: " + artType.ToString() + " #" + artId.ToString());
                                    }
                                }
                                catch (Exception ex)
                                {
                                    this._eventLog.WriteMessage(METHOD, ex, "For message " + msg.MessageLogID + ", referenced artifact did not exist.");
                                    continue;
                                }

                                try
                                {
                                    //The artifact exists, let's add a comment..
                                    RemoteComment comment = new RemoteComment();
                                    comment.ArtifactId   = artId;
                                    comment.CreationDate = DateTime.UtcNow;
                                    comment.UserId       = selUser.UserId;
                                    comment.Text         = this.getTextFromMessage(msg, true, true);

                                    switch (artType)
                                    {
                                    case ArtifactTypeEnum.Requirement:
                                        comment = clientAppl.Requirement_CreateComment(comment);
                                        break;

                                    case ArtifactTypeEnum.Test_Case:
                                        comment = clientAppl.TestCase_CreateComment(comment);
                                        break;

                                    case ArtifactTypeEnum.Incident:
                                        comment = clientAppl.Incident_AddComments(new List <RemoteComment>()
                                        {
                                            comment
                                        }).FirstOrDefault();
                                        break;

                                    case ArtifactTypeEnum.Release:
                                        comment = clientAppl.Release_CreateComment(comment);
                                        break;

                                    case ArtifactTypeEnum.Task:
                                        comment = clientAppl.Task_CreateComment(comment);
                                        break;

                                    case ArtifactTypeEnum.Test_Set:
                                        comment = clientAppl.TestSet_CreateComment(comment);
                                        break;
                                    }

                                    if (comment != null && comment.CommentId.HasValue)
                                    {
                                        //Now check for attachments
                                        try
                                        {
                                            foreach (MessagePart attach in msg.FindAllAttachments().Where(aa => aa.IsMultiPart == false && aa.IsText == false))
                                            {
                                                //Add the file..
                                                RemoteLinkedArtifact artifactLink = new RemoteLinkedArtifact();
                                                artifactLink.ArtifactId     = comment.ArtifactId;
                                                artifactLink.ArtifactTypeId = (int)artType;
                                                RemoteDocument newDoc = new RemoteDocument();
                                                newDoc.AttachedArtifacts = new List <RemoteLinkedArtifact>()
                                                {
                                                    artifactLink
                                                };
                                                newDoc.AttachmentTypeId = 1;
                                                newDoc.AuthorId         = selUser.UserId;
                                                newDoc.FilenameOrUrl    = attach.FileName;
                                                newDoc.UploadDate       = DateTime.UtcNow;

                                                //Check for string overrun and add extension if necessary.
                                                if (newDoc.FilenameOrUrl.Length > 250)
                                                {
                                                    newDoc.FilenameOrUrl = newDoc.FilenameOrUrl.Substring(0, 250);
                                                }
                                                if (string.IsNullOrWhiteSpace(Path.GetExtension(newDoc.FilenameOrUrl)) && attach.ContentType != null)
                                                {
                                                    string tempFileExtension = Utils.GetExtensionFromMimeType(attach.ContentType.MediaType);
                                                    if (!string.IsNullOrWhiteSpace(tempFileExtension))
                                                    {
                                                        newDoc.FilenameOrUrl += "." + tempFileExtension;
                                                    }
                                                }

                                                //Call the function to upload the file to Spira
                                                newDoc = clientAppl.Document_AddFile(newDoc, attach.Body);

                                                //Log it.
                                                this._eventLog.WriteMessage("Attachment #" + newDoc.AttachmentId.ToSafeString() + " created from file '" + attach.FileName + "' for Artifact " + artType + " #:" + comment.ArtifactId + " from message " + msg.MessageLogID + ".", System.Diagnostics.EventLogEntryType.Information);
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            //Log and continue
                                            this._eventLog.WriteMessage(METHOD, ex, "Saving attachment for message " + msg.MessageLogID);
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    this._eventLog.WriteMessage(METHOD, ex, "While trying to save message '" + msg.MessageLogID + "' as a new comment.");
                                    continue;
                                }

                                //If we get this far, mark the message as processed.
                                try
                                {
                                    //Add it to our list..
                                    seenUIDs.Add(msg.MessageUID);

                                    if (account.RemoveFromServer)
                                    {
                                        clientPOP3.DeleteMessage(msg.MessageIndex);
                                    }
                                }
                                catch (Exception ex)
                                {
                                    this._eventLog.WriteMessage(METHOD, ex, "Trying to delete message " + msg.MessageLogID + " from server.");
                                }
                            }
                            else
                            {
                                string msgLog = "";
                                if (userCnt == 0)
                                {
                                    msgLog = "Message " + msg.MessageLogID + " was sent from a user not a mamber of the specified project. Not importing unknown users.";
                                }
                                else if (userCnt > 1)
                                {
                                    msgLog = "Message " + msg.MessageLogID + " was sent from a user that did not have a unique email address. Cannot import to avoid selecting the wrong user.";
                                }

                                this._eventLog.WriteMessage(msgLog, System.Diagnostics.EventLogEntryType.Information);
                            }
                        }
                        else
                        {
                            if (artType != ArtifactTypeEnum.Skip)
                            {
                                int userCnt = spiraUsers.Where(su => su.EmailAddress.ToLowerInvariant() == msg.Headers.From.MailAddress.Address.ToLowerInvariant()).Count();
                                if (userCnt == 1)
                                {
                                    RemoteProjectUser selUser = spiraUsers.Where(su => su.EmailAddress.ToLowerInvariant() == msg.Headers.From.MailAddress.Address.ToLowerInvariant()).Single();

                                    //Create a new Incident..
                                    RemoteIncident newIncident = new RemoteIncident();
                                    newIncident.CreationDate = DateTime.Now;
                                    newIncident.Description  = this.getTextFromMessage(msg, true, false);
                                    newIncident.Name         = msg.Headers.Subject;
                                    newIncident.OpenerId     = selUser.UserId;

                                    //Check regex other projects
                                    if (account.UseRegexToMatch)
                                    {
                                        Regex regProj1 = new Regex(@"\[PR[\:\-\s](\d*?)\]", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
                                        if (regProj1.IsMatch(newIncident.Description) || regProj1.IsMatch(newIncident.Name))
                                        {
                                            //Someone used the PR tag in the email body, we'll use it, if possible.
                                            string matchNum = "";
                                            if (regProj1.IsMatch(newIncident.Name))
                                            {
                                                matchNum = regProj1.Matches(newIncident.Name)[0].Groups[1].Value;
                                            }
                                            else if (regProj1.IsMatch(newIncident.Description))
                                            {
                                                matchNum = regProj1.Matches(newIncident.Description)[0].Groups[1].Value;
                                            }
                                            else
                                            {
                                                this._eventLog.WriteMessage("ERROR: At least one RegEx returned IsMatch, but none contained match.", System.Diagnostics.EventLogEntryType.Information);
                                                continue;
                                            }

                                            int projNum = 0;
                                            if (int.TryParse(matchNum, out projNum))
                                            {
                                                //We had a number, let's see if it's a valid product.
                                                RemoteProject proj = spiraProjs.FirstOrDefault(prd => prd.ProjectId == projNum);
                                                if (proj != null)
                                                {
                                                    //Connect to project..
                                                    if (clientAppl.Connection_ConnectToProject(proj.ProjectId.Value))
                                                    {
                                                        newIncident.ProjectId = proj.ProjectId.Value;
                                                        this._eventLog.WriteMessage("Message " + msg.MessageLogID + " changed to Project '" + proj.Name + "' due to having [PR:xx] tag.", System.Diagnostics.EventLogEntryType.Information);
                                                    }
                                                    else
                                                    {
                                                        this._eventLog.WriteMessage("Message " + msg.MessageLogID + " contained project token for project '" + proj.Name + "', but email import has no access to that project. Using default.", System.Diagnostics.EventLogEntryType.Information);
                                                    }
                                                }
                                                else
                                                {
                                                    this._eventLog.WriteMessage("Message '" + msg.MessageLogID + "' contained token for project " + projNum.ToString() + " but project was inaccessible. Using default.", System.Diagnostics.EventLogEntryType.Information);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            foreach (RemoteProject prod in spiraProjs)
                                            {
                                                Regex regProd3 = new Regex(@"\b" + prod.Name + @"\b", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase);
                                                if (regProd3.IsMatch(newIncident.Description) || regProd3.IsMatch(newIncident.Name))
                                                {
                                                    newIncident.ProjectId = prod.ProjectId.Value;
                                                    this._eventLog.WriteMessage("Message " + msg.MessageLogID + " changed to Product '" + prod.Name + "' due to having Product name '" + prod.Name + "'", System.Diagnostics.EventLogEntryType.Information);
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    //Now save the Incident..
                                    try
                                    {
                                        newIncident = clientAppl.Incident_Create(newIncident);

                                        if (newIncident.IncidentId.HasValue)
                                        {
                                            //Now check for attachments
                                            try
                                            {
                                                foreach (MessagePart attach in msg.FindAllAttachments().Where(aa => aa.IsMultiPart == false && aa.IsText == false))
                                                {
                                                    //Add the file..
                                                    RemoteLinkedArtifact artifactLink = new RemoteLinkedArtifact();
                                                    artifactLink.ArtifactId     = newIncident.IncidentId.Value;
                                                    artifactLink.ArtifactTypeId = 3; /* Incident */
                                                    RemoteDocument newDoc = new RemoteDocument();
                                                    newDoc.AttachedArtifacts = new List <RemoteLinkedArtifact>()
                                                    {
                                                        artifactLink
                                                    };
                                                    newDoc.AttachmentTypeId = 1;
                                                    newDoc.AuthorId         = selUser.UserId;
                                                    newDoc.FilenameOrUrl    = attach.FileName;
                                                    newDoc.UploadDate       = DateTime.UtcNow;

                                                    //Check for string overrun and add extension if necessary.
                                                    if (newDoc.FilenameOrUrl.Length > 250)
                                                    {
                                                        newDoc.FilenameOrUrl = newDoc.FilenameOrUrl.Substring(0, 250);
                                                    }
                                                    if (string.IsNullOrWhiteSpace(Path.GetExtension(newDoc.FilenameOrUrl)) && attach.ContentType != null)
                                                    {
                                                        string tempFileExtension = Utils.GetExtensionFromMimeType(attach.ContentType.MediaType);
                                                        if (!string.IsNullOrWhiteSpace(tempFileExtension))
                                                        {
                                                            newDoc.FilenameOrUrl += "." + tempFileExtension;
                                                        }
                                                    }

                                                    //Call the function to upload the file to Spira
                                                    newDoc = clientAppl.Document_AddFile(newDoc, attach.Body);

                                                    //Log it.
                                                    this._eventLog.WriteMessage("Attachment #" + newDoc.AttachmentId.ToSafeString() + " created from file '" + attach.FileName + "' for Incident IN:" + newIncident.IncidentId.Value + " from message " + msg.MessageLogID + ".", System.Diagnostics.EventLogEntryType.Information);
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                //Log and continue
                                                this._eventLog.WriteMessage(METHOD, ex, "Saving attachment for message " + msg.MessageLogID);
                                            }
                                        }

                                        //If we get this far, mark the message as processed.
                                        try
                                        {
                                            //Add it to our list..
                                            seenUIDs.Add(msg.MessageUID);

                                            if (account.RemoveFromServer)
                                            {
                                                clientPOP3.DeleteMessage(msg.MessageIndex);
                                            }
                                        }
                                        catch (Exception ex)
                                        {
                                            this._eventLog.WriteMessage(METHOD, ex, "Trying to delete message " + msg.MessageLogID + " from server.");
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        this._eventLog.WriteMessage(METHOD, ex, "While trying to save message '" + msg.MessageLogID + "' as an incident.");
                                    }
                                }
                                else
                                {
                                    string msgLog = "";
                                    if (userCnt == 0)
                                    {
                                        msgLog = "Message " + msg.MessageLogID + " was sent from a user not a mamber of the specified project. Not importing unknown users.";
                                    }
                                    else if (userCnt > 1)
                                    {
                                        msgLog = "Message " + msg.MessageLogID + " was sent from a user that did not have a unique email address. Cannot import to avoid selecting the wrong user.";
                                    }

                                    this._eventLog.WriteMessage(msgLog, System.Diagnostics.EventLogEntryType.Information);
                                }
                            }
                            else
                            {
                            }
                        }
                    }
                    else
                    {
                        //Log it..
                        this._eventLog.WriteMessage("Message " + msg.MessageLogID + " on the server did not pass filters:" + Environment.NewLine + "Subject: " + msg.Headers.Subject + Environment.NewLine + "Reasons: " + Environment.NewLine + filterMsg, System.Diagnostics.EventLogEntryType.Warning);
                    }
                }
                else
                {
                    //Log it..
                    this._eventLog.WriteMessage("Message " + msg.MessageLogID + " had no From address or was from the import account --" + Environment.NewLine + "Subject: " + msg.Headers.Subject + Environment.NewLine + "Msg UID: " + msg.Headers.MessageId + Environment.NewLine + "For reason: From Email address same as importing account, or was null.", System.Diagnostics.EventLogEntryType.Warning);
                }
            }
            //Save the seen message IDs..
            this.saveMessageIDsForAccount(account.AccountID.Value, seenUIDs);

            //Disconnect client and POP3..
            try
            {
                clientPOP3.Disconnect();
                clientAppl.Connection_Disconnect();
            }
            catch (Exception ex)
            {
                this._eventLog.WriteMessage(METHOD, ex, "Trying to close connections.");
            }
        }
コード例 #25
0
ファイル: JiraSearch.cs プロジェクト: robspages/JiraSharp
        public RemoteIssue searchIssues(RemoteProject Project, String searchTerm)
        {
            List <RemoteIssue> issues = searchIssues(Project, searchTerm, 1);

            return(issues[0]);
        }
コード例 #26
0
 public JiraProject(RemoteProject proj)
 {
     this.Key  = proj.key;
     this.Name = proj.name;
     this.Id   = proj.id;
 }
コード例 #27
0
        static void Main(string[] args)
        {
            _options = new Settings();
            if (Parser.Default.ParseArguments(args, _options))
            {
                //Make sure that the Spira string is a URL.
                Uri    serverUrl   = null;
                string servicePath = _options.SpiraServer +
                                     ((_options.SpiraServer.EndsWith("/") ? "" : "/")) +
                                     "Services/v5_0/SoapService.svc";
                if (!Uri.TryCreate(servicePath, UriKind.Absolute, out serverUrl))
                {
                    //Throw error: URL given not a URL.
                    return;
                }

                //See if we have a mappings file specified, if so, make sure it exists
                List <ArtifactMapping> artifactMappings = null;
                string customPropertyField = null;
                if (!String.IsNullOrWhiteSpace(_options.SpiraMappingsFile))
                {
                    if (!File.Exists(_options.SpiraMappingsFile))
                    {
                        //Throw error: Bad path.
                        ConsoleLog(LogLevelEnum.Normal, "Cannot access the mapping file, please check the location and try again!");
                        Environment.Exit(-1);
                    }
                    artifactMappings = new List <ArtifactMapping>();

                    //Read in the lines, the first column should contain:
                    //Filename,ArtifactTypeId,Custom_03
                    //where the number in the third column is the name of the custom property that the IDs will be using
                    using (StreamReader streamReader = File.OpenText(_options.SpiraMappingsFile))
                    {
                        string   firstLine = streamReader.ReadLine();
                        string[] headings  = firstLine.Split(',');

                        //See if we have a match on the custom property number
                        if (headings.Length > 2 && !String.IsNullOrWhiteSpace(headings[2]))
                        {
                            customPropertyField = headings[2].Trim();

                            //Now read in the rows of mappings
                            while (!streamReader.EndOfStream)
                            {
                                string          mappingLine     = streamReader.ReadLine();
                                ArtifactMapping artifactMapping = new ArtifactMapping();
                                string[]        components      = mappingLine.Split(',');
                                artifactMapping.Filename       = components[0];
                                artifactMapping.ArtifactTypeId = Int32.Parse(components[1]);
                                artifactMapping.ExternalKey    = components[2];
                                artifactMappings.Add(artifactMapping);
                            }
                            streamReader.Close();
                        }
                    }
                }

                //Make sure the path given is a real path..
                try
                {
                    Directory.GetCreationTime(_options.ImportPath);
                }
                catch
                {
                    //Throw error: Bad path.
                    ConsoleLog(LogLevelEnum.Normal, "Cannot access the import path, please check the location and try again!");
                    Environment.Exit(-1);
                }

                //Tell user we're operating.
                ConsoleLog(LogLevelEnum.Normal, "Importing files in " + _options.ImportPath);

                //Now run through connecting procedures.
                ConsoleLog(LogLevelEnum.Verbose, "Connecting to Spira server...");
                SoapServiceClient client = CreateClient_Spira5(serverUrl);
                client.Open();

                if (client.Connection_Authenticate2(_options.SpiraLogin, _options.SpiraPass, "DocumentImporter"))
                {
                    ConsoleLog(LogLevelEnum.Verbose, "Selecting Spira project...");
                    var           Projects = client.Project_Retrieve();
                    RemoteProject proj     = Projects.FirstOrDefault(p => p.ProjectId == _options.SpiraProject);

                    if (proj != null)
                    {
                        //Connect to the project.
                        if (client.Connection_ConnectToProject((int)_options.SpiraProject))
                        {
                            ConsoleLog(LogLevelEnum.Normal, "Uploading files...");

                            //Now let's get a list of all the files..
                            SearchOption  opt   = ((_options.PathRecursive) ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
                            List <string> files = Directory.EnumerateFiles(_options.ImportPath, _options.ImportFilter, opt).ToList();

                            //Loop through each file and upload it.
                            ConsoleLog(LogLevelEnum.Verbose, "Files:");
                            foreach (string file in files)
                            {
                                string conLog = Path.GetFileName(file);
                                try
                                {
                                    //Get the file details..
                                    FileInfo fileInf = new FileInfo(file);
                                    string   size    = "";
                                    if (fileInf.Length >= 1000000000)
                                    {
                                        size = (fileInf.Length / 1000000000).ToString() + "Gb";
                                    }
                                    else if (fileInf.Length >= 1000000)
                                    {
                                        size = (fileInf.Length / 1000000).ToString() + "Mb";
                                    }
                                    else if (fileInf.Length >= 1000)
                                    {
                                        size = (fileInf.Length / 1000).ToString() + "Kb";
                                    }
                                    else
                                    {
                                        size = fileInf.Length.ToString() + "b";
                                    }
                                    conLog += " (" + size + ")";

                                    //Generate the RemoteDocument object.
                                    RemoteDocument newFile = new RemoteDocument();
                                    newFile.AttachmentTypeId = 1;
                                    newFile.FilenameOrUrl    = Path.GetFileName(file);
                                    newFile.Size             = (int)fileInf.Length;
                                    newFile.UploadDate       = DateTime.UtcNow;

                                    //Now we see if have mapped artifact
                                    ArtifactMapping mappedArtifact = artifactMappings.FirstOrDefault(m => m.Filename.ToLowerInvariant() == newFile.FilenameOrUrl.ToLowerInvariant());
                                    if (mappedArtifact != null && !String.IsNullOrEmpty(customPropertyField))
                                    {
                                        //We have to lookup the artifact, currently only incidents are supported
                                        if (mappedArtifact.ArtifactTypeId == 3)
                                        {
                                            //Retrieve the incident
                                            RemoteSort sort = new RemoteSort();
                                            sort.PropertyName  = "IncidentId";
                                            sort.SortAscending = true;
                                            List <RemoteFilter> filters = new List <RemoteFilter>();
                                            RemoteFilter        filter  = new RemoteFilter();
                                            filter.PropertyName = customPropertyField;
                                            filter.StringValue  = mappedArtifact.ExternalKey;
                                            filters.Add(filter);
                                            RemoteIncident remoteIncident = client.Incident_Retrieve(filters, sort, 1, 1).FirstOrDefault();

                                            if (remoteIncident != null)
                                            {
                                                RemoteLinkedArtifact remoteLinkedArtifact = new SpiraService.RemoteLinkedArtifact();
                                                remoteLinkedArtifact.ArtifactTypeId = mappedArtifact.ArtifactTypeId;
                                                remoteLinkedArtifact.ArtifactId     = remoteIncident.IncidentId.Value;
                                                newFile.AttachedArtifacts           = new List <RemoteLinkedArtifact>();
                                                newFile.AttachedArtifacts.Add(remoteLinkedArtifact);
                                            }
                                        }
                                        else
                                        {
                                            ConsoleLog(LogLevelEnum.Normal, "Warning: Only incident mapped artifacts currently supported, so ignoring the mapped artifacts of type: " + mappedArtifact.ArtifactTypeId);
                                        }
                                    }

                                    //Read the file contents. (Into memory! Beware, large files!)
                                    byte[] fileContents = null;
                                    fileContents = File.ReadAllBytes(file);

                                    ConsoleLog(LogLevelEnum.Verbose, conLog);
                                    if (fileContents != null && fileContents.Length > 1)
                                    {
                                        newFile.AttachmentId = client.Document_AddFile(newFile, fileContents).AttachmentId.Value;
                                    }
                                    else
                                    {
                                        throw new FileEmptyException();
                                    }
                                }
                                catch (Exception ex)
                                {
                                    conLog += " - Error. (" + ex.GetType().ToString() + ")";
                                    ConsoleLog(LogLevelEnum.Normal, conLog);
                                }
                            }
                        }
                        else
                        {
                            ConsoleLog(LogLevelEnum.Normal, "Cannot connect to project. Verify your Project Role.");
                            Environment.Exit(-1);
                        }
                    }
                    else
                    {
                        ConsoleLog(LogLevelEnum.Normal, "Cannot connect to project. Project #" + _options.SpiraProject.ToString() + " does not exist.");
                        Environment.Exit(-1);
                    }
                }
                else
                {
                    ConsoleLog(LogLevelEnum.Normal, "Cannot log in. Check username and password.");
                    Environment.Exit(-1);
                }
            }
            else
            {
                Environment.Exit(-1);
            }
        }
コード例 #28
0
 /// <summary>
 /// Creates a new Project instance using a remote project.
 /// </summary>
 /// <param name="jira">Instance of the Jira client.</param>
 /// <param name="remoteProject">Remote project.</param>
 public Project(Jira jira, RemoteProject remoteProject)
     : base(remoteProject)
 {
     _jira          = jira;
     _remoteProject = remoteProject;
 }
コード例 #29
0
 /// <remarks/>
 public void getProjectRoleActorsAsync(string in0, RemoteProjectRole in1, RemoteProject in2) {
     this.getProjectRoleActorsAsync(in0, in1, in2, null);
 }
コード例 #30
0
 public RemoteProjectRoleActors GetProjectRoleActors(string in0, RemoteProjectRole in1, RemoteProject in2)
 {
     throw new NotImplementedException();
 }
コード例 #31
0
 public void removeAllRoleActorsByProject(string in0, RemoteProject in1) {
     this.Invoke("removeAllRoleActorsByProject", new object[] {
                 in0,
                 in1});
 }
コード例 #32
0
 public void RemoveAllRoleActorsByProject(string in0, RemoteProject in1)
 {
     throw new NotImplementedException();
 }
コード例 #33
0
 public void addActorsToProjectRole(string in0, string[] in1, RemoteProjectRole in2, RemoteProject in3, string in4) {
     this.Invoke("addActorsToProjectRole", new object[] {
                 in0,
                 in1,
                 in2,
                 in3,
                 in4});
 }
コード例 #34
0
 public RemoteProject UpdateProject(string in0, RemoteProject in1)
 {
     throw new NotImplementedException();
 }
コード例 #35
0
 public void removeActorsFromProjectRole(string in0, string[] in1, RemoteProjectRole in2, RemoteProject in3, string in4) {
     this.Invoke("removeActorsFromProjectRole", new object[] {
                 in0,
                 in1,
                 in2,
                 in3,
                 in4});
 }
コード例 #36
0
 public void AddActorsToProjectRole(string in0, string[] in1, RemoteProjectRole in2, RemoteProject in3, string in4)
 {
     throw new NotImplementedException();
 }
コード例 #37
0
 /// <remarks/>
 public void removeActorsFromProjectRoleAsync(string in0, string[] in1, RemoteProjectRole in2, RemoteProject in3, string in4, object userState) {
     if ((this.removeActorsFromProjectRoleOperationCompleted == null)) {
         this.removeActorsFromProjectRoleOperationCompleted = new System.Threading.SendOrPostCallback(this.OnremoveActorsFromProjectRoleOperationCompleted);
     }
     this.InvokeAsync("removeActorsFromProjectRole", new object[] {
                 in0,
                 in1,
                 in2,
                 in3,
                 in4}, this.removeActorsFromProjectRoleOperationCompleted, userState);
 }
コード例 #38
0
 public RemoteProject CreateProjectFromObject(string in0, RemoteProject in1)
 {
     throw new NotImplementedException();
 }
コード例 #39
0
 public RemoteProject updateProject(string in0, RemoteProject in1) {
     object[] results = this.Invoke("updateProject", new object[] {
                 in0,
                 in1});
     return ((RemoteProject)(results[0]));
 }
コード例 #40
0
ファイル: JiraSearch.cs プロジェクト: robspages/JiraSharp
        public RemoteIssue GetIssueBySummary(RemoteProject Project, String summary, int limit)
        {
            String searchTerm = String.Format("project = \"{0}\" and summary = \"{1}\"", Project.key, summary);

            return(searchIssues(Project, searchTerm));
        }
コード例 #41
0
 /// <remarks/>
 public void updateProjectAsync(string in0, RemoteProject in1, object userState) {
     if ((this.updateProjectOperationCompleted == null)) {
         this.updateProjectOperationCompleted = new System.Threading.SendOrPostCallback(this.OnupdateProjectOperationCompleted);
     }
     this.InvokeAsync("updateProject", new object[] {
                 in0,
                 in1}, this.updateProjectOperationCompleted, userState);
 }
コード例 #42
0
ファイル: JiraSearch.cs プロジェクト: robspages/JiraSharp
        public List <RemoteIssue> GetIssuesByUser(RemoteProject Project, String userName, int limit)
        {
            String searchTerm = String.Format("project = \"{0}\" and (reporter = \"{1}\" OR assignee = \"{1}\")", Project.key, userName);

            return(searchIssues(Project, searchTerm, limit));
        }
コード例 #43
0
        /// <summary>
        /// Creates a remote service based on the specified schema and deploys it on Azure
        /// </summary>
        /// <param name="appId"></param>
        /// <param name="schema"></param>
        /// <returns></returns>
        public async Task <RemoteDeployment> Create(string appId, string schemaPath, ProjectRunArgs projectRunArgs)
        {
            await InitClient();

            SchemaValidator.ValidateSchema(schemaPath);

            var project = new RemoteProject();

            project.AppId           = appId;
            project.SubScriptionId  = azure.SubscriptionId;
            project.TenantId        = tenantId;
            project.SeedData        = projectRunArgs.SeedData;
            project.LocalSchemaPath = schemaPath;

            var deployment = new RemoteDeployment();

            deployment.Project        = project;
            deployment.StartedAt      = DateTimeOffset.Now;
            deployment.DeploymentName = $"dep{appId}";

            var rgName             = $"rg{appId}";
            var storageAccountName = $"st{appId}";
            var shareName          = $"share{appId}";

            project.ResourceGroup      = rgName;
            project.StorageAccountName = storageAccountName;
            project.AzureFileShare     = shareName;


            var region = Region.USCentral;

            project.Region = region.Name;

            await azure.ResourceGroups.Define(rgName).WithRegion(region).CreateAsync();

            // create storage account
            var storage = await azure.StorageAccounts.Define(storageAccountName).WithRegion(region)
                          .WithExistingResourceGroup(rgName)
                          .WithAccessFromAllNetworks()
                          .CreateAsync();

            var stKey = storage.GetKeys().First().Value;

            project.StorageAccountKey = stKey;

            var storageConnString = $"DefaultEndpointsProtocol=https;AccountName={storage.Name};AccountKey={stKey}";
            var shareClient       = new ShareClient(storageConnString, shareName);
            await shareClient.CreateAsync();

            // upload CSDL
            await UploadSchema(shareClient, schemaPath, RemoteCsdlFileDir, RemoteCsdlFileName);

            var template     = TemplateHelper.CreateDeploymentTemplate(project, image);
            var templateJson = JsonSerializer.Serialize(template);
            await azure.Deployments.Define(deployment.DeploymentName)
            .WithExistingResourceGroup(rgName)
            .WithTemplate(templateJson)
            .WithParameters("{}")
            .WithMode(Microsoft.Azure.Management.ResourceManager.Fluent.Models.DeploymentMode.Incremental)
            .CreateAsync();

            deployment.FinishedAt = DateTimeOffset.Now;

            return(deployment);
        }
コード例 #44
0
ファイル: JiraSearch.cs プロジェクト: robspages/JiraSharp
 public List <RemoteIssue> GetIssuesForProject(RemoteProject Project, int limit)
 {
     return(searchIssues(Project, String.Format("project = \"{0}\"", Project.key), limit));
 }
コード例 #45
0
        /// <summary>
        /// Determine the project ids of the given project codes by contacting the JIRA soap service.
        /// Then do an initial query for issues with these given ids
        /// </summary>
        private void DoInit()
        {
            try
            {
                Monitor.Enter(_lock);

                // Pre cleaning...
                _hasInit = true;                // by the time this is done, we will have init...
                _projectStatuses.Clear();
                _projectIds.Clear();

                lock ( _items )
                {
                    _items.Clear();
                }

                // Check to make sure the config is valid...
                _config.Load();

                if (!_config.IsValid())
                {
                    Log("Configuration for JIRA is not valid, see the plugin settings page");

                    // we failed to init
                    _hasInit = false;
                    return;
                }

                Log("Initializing repository: " + _config.BaseUrl);

                // init the service connection
                _service = new JIRAServerFacade(_config.BaseUrl, _config.Username, _config.Password);

                // Identify the available resolutions for an issue
                foreach (RemoteStatus status in _service.getStatuses())
                {
                    _projectStatuses.Add(int.Parse(status.id));

                    Log("Init Status: {0} => {1}", status.name, status.id);
                }

                // We want all issues that have a status that isn't 5 or 6 (resolved/closed)
                // we need to do it this way because JIRA doesn't support logical operators
                // for exclusion: see JRA-1560
                List <int> reqStatuses = new List <int>(_projectStatuses);
                reqStatuses.Remove(JIRAIssueItem.STATUS_RESOLVED);
                reqStatuses.Remove(JIRAIssueItem.STATUS_CLOSED);

                // Identify the project id's that we're interested in
                foreach (string projectKey in _config.Projects)
                {
                    RemoteProject project   = _service.getProjectByKey(projectKey);
                    long          projectId = long.Parse(project.id);

                    // Use the rss client to discover the issues for this project that are open
                    List <JIRAIssueItem> issues = ConvertFromRemoteIssues(
                        _service.GetAllIssuesWithStatus(
                            new List <long>(new long[] { projectId }),
                            reqStatuses));

                    // Store this project and it's issues
                    _projectIds.Add(projectId);

                    lock ( _items )
                    {
                        _items.AddRange(issues.ToArray());
                    }

                    Log("Init Project: {0} [{1}=>{2}] with: {3} issues.",
                        project.name, project.key, project.id, issues.Count);
                }
            }
            catch (System.Web.Services.Protocols.SoapException e)
            {
                Log("Failure (re-)initializating JIRA plugin...\n{0}", e);
            }
            finally
            {
                Monitor.Exit(_lock);
            }
        }
コード例 #46
0
 /* public JSClient()
  * { }
  */
 public void init(string userName, string userPass, string projectCode)
 {
     UserToken = jiraSoapService.login(userName, userPass);
     Project   = jiraSoapService.getProjectByKey(UserToken, projectCode);
     JUser     = jiraSoapService.getUser(UserToken, userName);
 }