Пример #1
0
        public NoteMessage GetMeetingNotes(Guid meetingId, AuthRestModel user)
        {
            var instanceConnectionString = _applicationSetting.CreateConnectionString(_applicationSetting.Server,
                                                                                      _applicationSetting.Catalogue, user.InstanceId, _applicationSetting.GetInstancePassword(user.InstanceId));

            return(_noteRepository.GetNoteCollection(meetingId, user.InstanceId, instanceConnectionString));
        }
Пример #2
0
        public ActionResult Invoice(Guid m, string i)
        {
            var instanceConnectionString = _applicationSetting.CreateConnectionString(_applicationSetting.Server,
                                                                                      _applicationSetting.Catalogue, i, _applicationSetting.GetInstancePassword(i));
            var masterConnectionString = _applicationSetting.CreateConnectionString();

            var meetingRequest = _getMeetingRepository.Get(m, i, instanceConnectionString);


            var meeting = !meetingRequest.Condition ? new Minutz.Models.Entities.Meeting() : meetingRequest.Meeting;


            if (string.IsNullOrEmpty(meeting.Outcome))
            {
                meeting.Outcome = "Outcome not set.";
            }
            if (string.IsNullOrEmpty(meeting.Location))
            {
                meeting.Location = "Location not set.";
            }
            if (string.IsNullOrEmpty(meeting.Purpose))
            {
                meeting.Purpose = "Purpose not set.";
            }
            if (string.IsNullOrEmpty(meeting.Time))
            {
                meeting.Time = "0:00";
            }


            var agendaCollection = _agendaRepository.GetMeetingAgendaCollection(m, i, instanceConnectionString);
            var agendaItems      = new List <JsReportAgenda>();

            if (agendaCollection.Condition)
            {
                foreach (var meetingAgenda in agendaCollection.AgendaCollection)
                {
                    if (string.IsNullOrEmpty(meetingAgenda.AgendaText))
                    {
                        meetingAgenda.AgendaText = string.Empty;
                    }
                    agendaItems.Add(new JsReportAgenda
                    {
                        agendaHeading = meetingAgenda.AgendaHeading,
                        agendaText    = meetingAgenda.AgendaText.Replace("<p>", "").Replace("</p>", "")
                                        .Replace("<b>", "").Replace("</b>", "").Replace("&nbsp;", "&")
                    });
                }
            }
            var noteRequest = _noteRepository.GetNoteCollection(m, i, instanceConnectionString);
            var notes       = new List <JsReportNote>();

            if (noteRequest.Condition)
            {
                foreach (var meetingNote in noteRequest.NoteCollection)
                {
                    notes.Add(new JsReportNote
                    {
                        noteText = meetingNote.NoteText.Replace("<p>", "").Replace("</p>", "")
                                   .Replace("<b>", "").Replace("</b>", "").Replace("&nbsp;", "&")
                    });
                }
            }

            var attendees = new List <JsReportAttendee>();

            try
            {
                var attendeeResult = _minutzAttendeeRepository.GetAttendees(m, i, instanceConnectionString, masterConnectionString);
                if (attendeeResult.Condition)
                {
                    foreach (var attendee in attendeeResult.Attendees)
                    {
                        attendees.Add(new JsReportAttendee
                        {
                            name = attendee.Name,
                            role = attendee.Role
                        });
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }



            var client = new HttpClient();
            var url    = "https://minutz.jsreportonline.net/api/report";

            var data = new JsReportObject
            {
                name     = meeting.Name,
                location = meeting.Location,
                time     = meeting.Time,
                outcome  = meeting.Outcome.Replace("<p>", "").Replace("</p>", "")
                           .Replace("<b>", "").Replace("</b>", "").Replace("&nbsp;", "&"),
                purpose = meeting.Purpose.Replace("<p>", "").Replace("</p>", "")
                          .Replace("<b>", "").Replace("</b>", "").Replace("&nbsp;", "&"),
                agenda    = agendaItems,
                notes     = notes,
                attendees = attendees
            };

            var model = new SendData
            {
                options = new options {
                    timeout = 60000
                },
                data     = data,
                template = new template {
                    shortid = "SJKYFyoYM"
                }
            };
            var token   = CreateAuthHeader();
            var payload = model.ToStringContent();

            client.DefaultRequestHeaders.Add("Authorization", token);
            var reportRequest = client.PostAsync(url, payload).Result;
            var report        = reportRequest.Content.ReadAsByteArrayAsync().Result;

            return(new FileContentResult(report, "application/pdf"));
        }