Пример #1
0
        // TODO: get rid of this. this is only for testing.
        public static void Process(string comment, YouTrackProxy proxy, string issueId)
        {
            var renderedComments = new List <String>();
            var guids            = new List <Guid>();
            var sb = new StringBuilder();

            for (int i = 0; i < comment.Length; ++i)
            {
                if (comment.Substring(i).StartsWith("[{"))
                {
                    int end = comment.Substring(i).IndexOf("}]");
                    if (end != -1)
                    {
                        string toRasterize = comment.Substring(i + 2, end - 2);
                        renderedComments.Add(toRasterize);
                        Guid g = Guid.NewGuid();
                        sb.Append('!').Append(g.ToString()).Append(".png!");
                        guids.Add(g);
                        i = end + 2;
                        continue;
                    }
                }
                sb.Append(comment[i]);
            }

            // well okay now render all that stuff
            var tempPath      = Path.GetTempPath();
            var filesToDelete = new List <string>();

            for (int i = 0; i < renderedComments.Count; ++i)
            {
                using (var bmp = RenderFreeformText(776, 1024, renderedComments[i]))
                {
                    string whereToPut = Path.Combine(tempPath, guids[i].ToString() + ".png");
                    bmp.Save(whereToPut, ImageFormat.Png);
                    filesToDelete.Add(whereToPut);

                    // now send it
                    proxy.AttachFile(issueId, whereToPut);
                }
            }

            proxy.SubmitComment(issueId, sb.ToString());
        }