Beispiel #1
0
        void AddLabelButton_Click(object sender, EventArgs e)
        {
            try
            {
                LabelPrinting newLabel;
                LabelingView  labeling;


                newLabel = new LabelPrinting( );
                labeling = new LabelingView( );

                labeling.SetLabel(newLabel,
                                  new long[] { DicomTag.PatientName, DicomTag.PatientSex, DicomTag.PatientAge, DicomTag.PatientBirthDate, DicomTag.ReferringPhysicianName });

                if (labeling.ShowDialog( ) == DialogResult.OK)
                {
                    AddLabel(newLabel);

                    UpdateUpDownButtonState( );

                    OnChanged( );
                }
            }
            catch (Exception exception)
            {
                Messager.ShowError(this, exception);
            }
        }
Beispiel #2
0
        public void PrintsErrorForUnknownThingToPrint()
        {
            var printer   = new Mock <ILabelPrinter>(MockBehavior.Strict);
            var github    = new Mock <IGithubPRApi>(MockBehavior.Strict);
            var processor = new LabelPrinting("fooCorp", github.Object, printer.Object);

            var result = processor.ProcessCommand("print label for asdfasdfasdf");

            Assert.AreEqual("Sorry, I don't know how to print \"asdfasdfasdf\"", result.Responses.Single().Message);
        }
Beispiel #3
0
        public void TestPrintLabelFromFullGithubReference()
        {
            var printer   = new Mock <ILabelPrinter>(MockBehavior.Strict);
            var github    = new Mock <IGithubPRApi>(MockBehavior.Strict);
            var processor = new LabelPrinting("fooCorp", github.Object, printer.Object);

            printer.Setup(x => x.PrintLabel("#3: test pull request", new List <string> {
                "https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png", "example image", "https://api.qrserver.com/v1/create-qr-code/?data=https://github.com/barCorp/barRepo/pull/3"
            })).Returns("Printing ...");

            github.Setup(x => x.PullRequest("barCorp", "barRepo", 3)).ReturnsAsync(new { title = "test pull request", user = new { avatar_url = "example image" } });

            var result = processor.ProcessCommand("print label for barCorp/barRepo#3");

            Assert.AreEqual("Printing ...", result.Responses.Single().Message);
        }
Beispiel #4
0
        public static async Task MainAsync(Configuration configuration, CancellationToken cancel)
        {
            var persistence      = new JsonFileKeyValueStore(new FileInfo(configuration.Get("db-file-location")));
            var gamesPersistence = new JsonFileKeyValueStore(new FileInfo(configuration.Get("games-db-location")));

            var slackApi = new SlackApi(configuration.Get("slack-api-key"));

            var slackRtm = await(ReconnectingSlackRealTimeMessaging.CreateAsync(
                                     async() => await slackApi.StartRtm()));
            var aliasList = GetAliasList(slackRtm.InstanceInfo.Users);

            var commandParser = new SlackCommandParser("scbot", slackRtm.InstanceInfo.BotId);

            var webClient = new WebClient();

            var features = new FeatureMessageProcessor(commandParser,
                                                       NoteProcessor.Create(commandParser, persistence),
                                                       //ZendeskTicketTracker.Create(commandParser, persistence, configuration),
                                                       RecordReplayTraceManagement.Create(commandParser),
                                                       SeatingPlans.Create(commandParser, webClient),
                                                       Webcams.Create(commandParser, configuration),
                                                       Silly.Create(commandParser, webClient),
                                                       Installers.Create(commandParser, webClient),
                                                       Polls.Create(commandParser),
                                                       RollBuildNumbers.Create(commandParser, configuration),
                                                       ReviewFactory.Create(commandParser, webClient, configuration),
                                                       LabelPrinting.Create(commandParser, webClient, configuration),
                                                       Jira.Create(commandParser),
                                                       CompareTeamEmails.Create(commandParser, configuration),
                                                       GamesProcessor.Create(commandParser, gamesPersistence, aliasList)
                                                       );

            var pasteBin = new HasteServerPasteBin(webClient, configuration.Get("haste-server-url"));

            var newChannelNotificationsChannel = configuration.GetWithDefault("new-channels-notification-channel", null);
            var newChannelProcessor            = GetNewChannelProcessor(newChannelNotificationsChannel);

            var bot = new Bot(
                new ErrorReportingMessageProcessor(
                    new ConcattingMessageProcessor(features),
                    pasteBin),
                newChannelProcessor);

            var handler = new SlackMessageHandler(bot, slackRtm.InstanceInfo.BotId);

            MainLoop(slackRtm, handler, slackApi, cancel);
        }
Beispiel #5
0
        public void TestPrintLabel()
        {
            var webClient = new Mock <IWebClient>(MockBehavior.Strict);
            var processor = new LabelPrinting("fooCorp",
                                              new GithubPRApi(webClient.Object, "githubToken"),
                                              new LabelPrinter("http://my_printer.com:9000", webClient.Object));

            webClient.Setup(x => x.DownloadString("https://api.github.com/repos/fooCorp/fooRepo/pulls/3",
                                                  new[] { "Authorization: token githubToken" }))
            .ReturnsAsync(@"{ title: 'test pull request', body: 'test pull request body', user: { avatar_url: 'example image' } }");

            webClient.Setup(x => x.PostString("http://my_printer.com:9000", @"{""title"":""#3: test pull request"",""images"":[""https://assets-cdn.github.com/images/modules/logos_page/GitHub-Mark.png"",""example image"",""https://api.qrserver.com/v1/create-qr-code/?data=https://github.com/fooCorp/fooRepo/pull/3""]}", new[] { "content-type:application/json" })).ReturnsAsync("Printing ...");

            var result = processor.ProcessCommand("print label for fooRepo#3");

            Assert.AreEqual("Printing ...", result.Responses.Single().Message);
        }
Beispiel #6
0
        private void Init(LabelPrinting label, long[] supportedTags)
        {
            __Label = label;
            __Tags  = supportedTags;

            __IsExpanded = false;

            ImageTextBox.Text  = string.Empty;
            CustomTextBox.Text = string.Empty;

            ClientRequestedTextRadioButton.Checked = false;
            ImageRadioButton.Checked  = false;
            CustomRadioButton.Checked = false;

            switch (label.PrintLabelType)
            {
            case LabelType.ClientText:
            {
                ClientRequestedTextRadioButton.Checked = true;
            }
            break;

            case LabelType.Image:
            {
                ImageRadioButton.Checked = true;
                ImageTextBox.Text        = label.PrintLabelData;
            }
            break;

            case LabelType.CustomData:
            {
                CustomRadioButton.Checked = true;
                CustomTextBox.Text        = label.PrintLabelData;
            }
            break;
            }

            FillListBox(supportedTags);

            InsertDicomTagButton.Enabled = DicomTagsListBox.SelectedIndex != -1;

            Collapse( );
        }
Beispiel #7
0
        private void AddLabel(LabelPrinting newLabel)
        {
            LabelsListBox.Items.Add(newLabel);

            __Configuration.Labels.Add(newLabel);
        }
Beispiel #8
0
        public void SetLabel(LabelPrinting label, long[] supportedTags)
        {
            Init(label, supportedTags);

            RegisterEvents( );
        }