Example #1
0
        public ExportSettingsModel GetExportSettings(int implementationGuideId, ExportFormats format)
        {
            IGSettingsManager igSettings       = new IGSettingsManager(this.tdb, implementationGuideId);
            string            settingsProperty = "ExportSettings_" + format.ToString();

            if (format == ExportFormats.Microsoft_Word_DOCX)
            {
                var legacyExportSettings = this.GetLegacyMSWordExportSettings(igSettings, settingsProperty);

                if (legacyExportSettings != null)
                {
                    return(legacyExportSettings);
                }
            }

            string exportSettingsJson = igSettings.GetSetting(settingsProperty);

            if (!string.IsNullOrEmpty(exportSettingsJson))
            {
                var settings = JsonConvert.DeserializeObject <ExportSettingsModel>(exportSettingsJson);
                settings.ImplementationGuideId = implementationGuideId;
                settings.ExportFormat          = format;
                return(settings);
            }

            return(new ExportSettingsModel()
            {
                ImplementationGuideId = implementationGuideId,
                ExportFormat = format,
                SelectAll = true
            });
        }
Example #2
0
        public byte[] Export(DB.IObjectRepository tdb, SimpleSchema schema, ExportFormats format, IGSettingsManager igSettings, List <string> categories, List <DB.Template> templates, bool includeVocabulary, bool returnJson = true)
        {
            var uri = HttpContext.Current != null && HttpContext.Current.Request != null ? HttpContext.Current.Request.Url : new Uri(AppSettings.DefaultBaseUrl);

            switch (format)
            {
            case ExportFormats.FHIR_Bundle:
                ImplementationGuideExporter      exporter = new ImplementationGuideExporter(tdb, schema, uri.Scheme, uri.Authority);
                fhir_dstu2.Hl7.Fhir.Model.Bundle bundle   = exporter.GetImplementationGuides(include: "ImplementationGuide:resource", implementationGuideId: igSettings.ImplementationGuideId);
                return(ConvertToBytes(fhir_dstu2.Hl7.Fhir.Serialization.FhirSerializer.SerializeResourceToXml(bundle)));

            case ExportFormats.Native_XML:
                NativeExporter proprietaryExporter = new NativeExporter(tdb, templates, igSettings, true, categories);

                if (returnJson)
                {
                    return(ConvertToBytes(proprietaryExporter.GenerateJSONExport()));
                }
                else
                {
                    return(ConvertToBytes(proprietaryExporter.GenerateXMLExport()));
                }

            case ExportFormats.Templates_DSTU_XML:
                DecorExporter decorExporter = new DecorExporter(templates, tdb, igSettings.ImplementationGuideId);
                return(ConvertToBytes(decorExporter.GenerateXML()));

            default:
                throw new Exception("Invalid export format for the specified implementation guide type");
            }
        }
Example #3
0
        public string Export(DB.IObjectRepository tdb, SimpleSchema schema, ExportFormats format, IGSettingsManager igSettings, List <string> categories, List <DB.Template> templates, bool includeVocabulary, bool returnJson = true)
        {
            switch (format)
            {
            case ExportFormats.FHIR:
                string export = FHIRExporter.GenerateExport(tdb, templates, igSettings, categories, includeVocabulary);

                if (returnJson)
                {
                    fhir_dstu1.Hl7.Fhir.Model.Bundle bundle = fhir_dstu1.Hl7.Fhir.Serialization.FhirParser.ParseBundleFromXml(export);
                    export = fhir_dstu1.Hl7.Fhir.Serialization.FhirSerializer.SerializeBundleToJson(bundle);
                }

                return(export);

            case ExportFormats.Proprietary:
                NativeExporter proprietaryExporter = new NativeExporter(tdb, templates, igSettings, true, categories);
                return(proprietaryExporter.GenerateXMLExport());

            case ExportFormats.TemplatesDSTU:
                DecorExporter decorExporter = new DecorExporter(templates, tdb, igSettings.ImplementationGuideId);
                return(decorExporter.GenerateXML());

            case ExportFormats.Snapshot:

            default:
                throw new Exception("Invalid export format for the specified implementation guide type");
            }
        }
Example #4
0
        public ExportViewModel(QDocument source, ExportFormats format)
        {
            _source = source;
            _format = format;

            Save  = new SimpleCommand(Save_Executed);
            Print = new SimpleCommand(Print_Executed);

            BuildDocument();
        }
Example #5
0
 /// <summary>
 /// Clears all data in public attributes
 /// </summary>
 /// <param name="defaultReconstructionType">
 /// The initially selected reconstruction type
 /// </param>
 /// <param name="defaultExportFormat">
 /// The initially selected export format
 /// </param>
 /// <param name="defaultGhostLevel">
 /// </param>
 public void Clear(ReconstructionTypes defaultReconstructionType, GhostLevels defaultGhostLevel, ExportFormats defaultExportFormat)
 {
     FieldNames.Clear();
     TimeSteps.Clear();
     ReconstructionType = defaultReconstructionType;
     GhostLevel         = defaultGhostLevel;
     ExportFormat       = defaultExportFormat;
     BasePaths          = null;
     SessionGuid        = Guid.Empty;
     SuperSampling      = 0;
     NumberOfProcesses  = 1;
 }
Example #6
0
        public async Task <string> ExportAsync(string inputId, ExportFormats exportToFormat, string callbackUrl = null)
        {
            var url = "web-api/operation/export";

            var request = new ExportOperationRequest
            {
                InputId        = inputId,
                ExportToFormat = exportToFormat.ToString(),
                CallbackUrl    = callbackUrl
            };

            var result = await PostOperationAsync(url, request);

            return(result);
        }
Example #7
0
 public void ExportData(Action <Stream> exportMethod, ExportFormats format, string path = null)
 {
     try
     {
         using (FileStream stream = new FileStream(path ?? Path.Combine(Application.StartupPath, $"data.{format.ToString().ToLower()}"), FileMode.OpenOrCreate))
         {
             exportMethod?.Invoke(stream);
             stream.Close();
         }
     }
     catch (Exception e)
     {
         _logger.Log(e.Message);
     }
 }
Example #8
0
        public static string EnumToString(ExportFormats formatenum)
        {
            if (formatenum == ExportFormats.Audio) return "Audio";
               if (formatenum == ExportFormats.Avi) return "AVI";
               if (formatenum == ExportFormats.AviHardware) return "AVI Hardware";
               if (formatenum == ExportFormats.AviHardwareHD) return "AVI Hardware HD";
               if (formatenum == ExportFormats.AviiRiverClix2) return "AVI iRiver Clix 2";
               if (formatenum == ExportFormats.AviMeizuM6) return "AVI Meizu M6";
               if (formatenum == ExportFormats.AviDVNTSC) return "AVI DV NTSC";
               if (formatenum == ExportFormats.AviDVPAL) return "AVI DV PAL";
               if (formatenum == ExportFormats.Flv) return "FLV";
               if (formatenum == ExportFormats.Mkv) return "MKV";
               if (formatenum == ExportFormats.Mp4) return "MP4";
               if (formatenum == ExportFormats.ThreeGP) return "3GP";
               if (formatenum == ExportFormats.Mov) return "MOV";
               if (formatenum == ExportFormats.Mp4Archos5G) return "MP4 Archos 5G";
               if (formatenum == ExportFormats.Mp4ToshibaG900) return "MP4 Toshiba G900";
               if (formatenum == ExportFormats.Mp4BlackBerry8100) return "MP4 BlackBerry 8100";
               if (formatenum == ExportFormats.Mp4BlackBerry8800) return "MP4 BlackBerry 8800";
               if (formatenum == ExportFormats.Mp4BlackBerry8830) return "MP4 BlackBerry 8830";
               if (formatenum == ExportFormats.Mp4SonyEricssonK610) return "MP4 SonyEricsson K610";
               if (formatenum == ExportFormats.Mp4SonyEricssonK800) return "MP4 SonyEricsson K800";
               if (formatenum == ExportFormats.Mp4MotorolaK1) return "MP4 Motorola K1";
               if (formatenum == ExportFormats.Mp4Nokia5700) return "MP4 Nokia 5700";
               if (formatenum == ExportFormats.Mp4iPod50G) return "MP4 iPod 5.0G";
               if (formatenum == ExportFormats.Mp4iPod55G) return "MP4 iPod 5.5G";
               if (formatenum == ExportFormats.Mp4iPhone) return "MP4 iPhone or Touch";
               if (formatenum == ExportFormats.Mp4AppleTV) return "MP4 Apple TV";
               if (formatenum == ExportFormats.Mp4Prada) return "MP4 Prada";
               if (formatenum == ExportFormats.Mp4PS3) return "MP4 PS3 or XBOX360";
               if (formatenum == ExportFormats.Mp4PSPAVC) return "MP4 PSP AVC";
               if (formatenum == ExportFormats.Mp4PSPAVCTV) return "MP4 PSP AVC TV";
               if (formatenum == ExportFormats.Mp4PSPASP) return "MP4 PSP ASP";
               if (formatenum == ExportFormats.Mpeg2PS) return "MPEG2 PS";
               if (formatenum == ExportFormats.Mpeg1PS) return "MPEG1 PS";
               if (formatenum == ExportFormats.Mpeg2NTSC) return "MPEG2 NTSC";
               if (formatenum == ExportFormats.Mpeg2PAL) return "MPEG2 PAL";
               if (formatenum == ExportFormats.PmpAvc) return "PMP AVC";
               if (formatenum == ExportFormats.M2TS) return "M2TS";
               if (formatenum == ExportFormats.TS) return "TS";
               if (formatenum == ExportFormats.DpgNintendoDS) return "DPG Nintendo DS";
               if (formatenum == ExportFormats.BluRay) return "BluRay";
               if (formatenum == ExportFormats.Custom) return "Custom";

               return null;
        }
Example #9
0
        public async Task ExportDataAsync(Action <Stream> exportMethod, ExportFormats format, string path = null)
        {
            try
            {
                if (path == null)
                {
                    path = XtraInputBox.Show($"File location: {Application.StartupPath}", "File Name", "file name") ?? "data";
                }

                using (FileStream stream = new FileStream(Path.Combine(Application.StartupPath, $"{path}.{format.ToString().ToLower()}"), FileMode.OpenOrCreate))
                {
                    await Task.Run(() => exportMethod?.Invoke(stream));

                    stream.Close();
                }
            }
            catch (Exception e)
            {
                _logger.Log(e.Message);
            }
        }
Example #10
0
        public string Export(DB.IObjectRepository tdb, SimpleSchema schema, ExportFormats format, IGSettingsManager igSettings, List <string> categories, List <DB.Template> templates, bool includeVocabulary, bool returnJson = true)
        {
            string requestScheme    = HttpContext.Current != null && HttpContext.Current.Request != null ? HttpContext.Current.Request.Url.Scheme : null;
            string requestAuthority = HttpContext.Current != null && HttpContext.Current.Request != null ? HttpContext.Current.Request.Url.Authority : null;

            switch (format)
            {
            case ExportFormats.FHIR:
                throw new NotImplementedException();

            case ExportFormats.Proprietary:
                NativeExporter nativeExporter = new NativeExporter(tdb, templates, igSettings, true, categories);
                return(nativeExporter.GenerateXMLExport());

            case ExportFormats.TemplatesDSTU:
                DecorExporter decorExporter = new DecorExporter(templates, tdb, igSettings.ImplementationGuideId);
                return(decorExporter.GenerateXML());

            default:
                throw new Exception("Invalid export format for the specified implementation guide type");
            }
        }
Example #11
0
        public static Action <Stream> GetExportHandler(GridView view, ExportFormats format)
        {
            switch (format)
            {
            case ExportFormats.PDF:
                return(view.ExportToPdf);

            case ExportFormats.XLS:
                return(view.ExportToXls);

            case ExportFormats.XLSX:
                return(view.ExportToXlsx);

            case ExportFormats.RTF:
                return(view.ExportToRtf);

            case ExportFormats.CSV:
                return(view.ExportToCsv);

            default:
                return(view.ExportToDocx);
            }
        }
Example #12
0
        public static int GetValidModW(ExportFormats format)
        {
            if (Formats.GetDefaults(format).IsEditable)
               {
               if (Formats.GetDefaults(format).Resolution_IsEditable)
                   return Formats.GetSettings(format, "ModW", Formats.GetDefaults(format).ModW);
               else
                   return Formats.GetDefaults(format).ModW;
               }

               return 16;
        }
Example #13
0
 public static string GetValidAPreset(ExportFormats format)
 {
     if (format == ExportFormats.Avi ||
        format == ExportFormats.AviHardware ||
        format == ExportFormats.AviHardwareHD ||
        format == ExportFormats.AviiRiverClix2 ||
        format == ExportFormats.Mp4ToshibaG900 ||
        format == ExportFormats.Audio ||
        format == ExportFormats.AviMeizuM6)
        return "MP3 CBR 128k";
        else if (format == ExportFormats.Flv ||
        format == ExportFormats.Mp4SonyEricssonK800 ||
        format == ExportFormats.Mp4SonyEricssonK610)
        return "MP3 CBR 96k";
        else if (format == ExportFormats.AviDVNTSC ||
        format == ExportFormats.AviDVPAL)
        return "PCM 16bit";
        else if (format == ExportFormats.Mpeg2NTSC ||
        format == ExportFormats.Mpeg2PAL ||
        format == ExportFormats.Mpeg2PS ||
        format == ExportFormats.M2TS ||
        format == ExportFormats.TS ||
        format == ExportFormats.BluRay)
        return "AC3 384k";
        else if (format == ExportFormats.Mpeg1PS)
        return "MP2 192k";
        else if (format == ExportFormats.DpgNintendoDS)
        return "MP2 128k";
        else if (format == ExportFormats.Mp4Nokia5700)
        return "AAC-LC ABR 96k";
        else if (format == ExportFormats.Mp4BlackBerry8830)
        return "AAC-HE CBR 64k";
        else if (format == ExportFormats.Mp4Archos5G ||
        format == ExportFormats.Mp4BlackBerry8100 ||
        format == ExportFormats.Mp4BlackBerry8800 ||
        format == ExportFormats.Mp4MotorolaK1 ||
        format == ExportFormats.Mp4Prada ||
        format == ExportFormats.PmpAvc)
        return "AAC-LC ABR 128k";
        else
        return "AAC-LC VBR 0.45";
 }
Example #14
0
        public static string GetSplitting(ExportFormats format)
        {
            if (Formats.GetDefaults(format).IsEditable)
               {
               if (Formats.GetDefaults(format).Splitting != "None")
                   return Formats.GetSettings(format, "Splitting", Formats.GetDefaults(format).Splitting);
               else
                   return "Disabled";
               }
               else if (format == ExportFormats.BluRay)
               return Settings.GetFormatPreset(format, "split");

               return "Disabled";
        }
Example #15
0
        public static bool GetMultiplexing(ExportFormats format)
        {
            if (Formats.GetDefaults(format).IsEditable)
               {
               if (Formats.GetDefaults(format).DontMuxStreams_IsEditable)
                   return Formats.GetSettings(format, "DontMuxStreams", Formats.GetDefaults(format).DontMuxStreams);
               else
                   return Formats.GetDefaults(format).DontMuxStreams;
               }
               else if (format == ExportFormats.BluRay)
               return Convert.ToBoolean(Settings.GetFormatPreset(Format.ExportFormats.BluRay, "dont_mux_streams"));

               return false; //DontMuxStreams = false
        }
        /// <summary>
        /// Сформировать документ требуемого формата
        /// </summary>
        public override IFlowDocumentWrapper BuildDocument(SIDocument doc, ExportFormats format)
        {
            var document = new FlowDocument {
                ColumnWidth = double.PositiveInfinity
            };

            switch (format)
            {
            case ExportFormats.Dinabank:
            {
                var paragraph = new Paragraph();

                paragraph.AppendText(doc.Package.Name);
                AppendInfo(doc, paragraph, doc.Package);
                paragraph.AppendLine();

                doc.Package.Rounds.ForEach(round =>
                    {
                        paragraph.AppendLine();
                        paragraph.AppendLine(round.Name);

                        AppendInfo(doc, paragraph, round);

                        for (int i = 0; i < round.Themes.Count; i++)
                        {
                            var theme = round.Themes[i];
                            paragraph.AppendLine();
                            paragraph.AppendFormat("Тема {0}. {1}", i + 1, theme.Name?.ToUpper().EndWithPoint());
                            AppendInfo(doc, paragraph, theme);
                            paragraph.AppendLine();
                            paragraph.AppendLine();

                            theme.Questions.ForEach(quest =>
                            {
                                paragraph.AppendFormat("{0}. ", quest.Price);
                                paragraph.AppendLine(quest.Scenario.ToString().EndWithPoint());
                                paragraph.AppendFormat(STR_Definition, Resources.Answer, string.Join(", ", quest.Right.ToArray()).GrowFirstLetter().EndWithPoint());
                                AppendInfo(doc, paragraph, quest);
                                paragraph.AppendLine();
                            });
                        }
                    });

                document.Blocks.Add(paragraph);
            }
            break;

            case ExportFormats.TvSI:
            {
                var paragraph = new Paragraph();

                doc.Package.Rounds.ForEach(round => round.Themes.ForEach(theme => theme.Questions.ForEach(quest =>
                    {
                        paragraph.AppendFormat("\\{0}\\", theme.Name).AppendLine();
                        paragraph.AppendFormat("\\{0}", quest.Scenario);
                        if (quest.Info.Comments.Text.Length > 0)
                        {
                            paragraph.AppendFormat(". {0}: {1}", Resources.Comments, quest.Info.Comments.Text);
                        }

                        paragraph.Append('\\').AppendLine().Append('\\');
                        paragraph.Append(string.Join(", ", quest.Right.ToArray()));
                        if (quest.Info.Sources.Count > 0)
                        {
                            paragraph.Append('\\').AppendLine().Append('\\');
                            paragraph.Append(string.Join(", ", doc.GetRealSources(quest.Info.Sources)));
                        }

                        paragraph.Append('\\').AppendLine().AppendLine();
                    })));

                document.Blocks.Add(paragraph);
            }
            break;

            case ExportFormats.Sns:
            {
                var paragraph = new Paragraph();

                paragraph.AppendLine(doc.Package.Name);
                int i = 0;
                doc.Package.Rounds.ForEach(round =>
                    {
                        paragraph.AppendLine();
                        paragraph.AppendLine(round.Name);
                        paragraph.AppendLine();
                        paragraph.AppendLine(Resources.YourThemes);
                        round.Themes.ForEach(theme =>
                        {
                            paragraph.AppendFormat(STR_ExtendedDefinition, Resources.Theme, theme.Name.ToUpper(), ++i);
                            paragraph.AppendLine();
                        });
                        round.Themes.ForEach(theme =>
                        {
                            paragraph.AppendLine();
                            paragraph.AppendFormat(STR_Definition, Resources.Theme, theme.Name.ToUpper());
                            paragraph.AppendLine();
                            if (theme.Info.Comments.Text.Length > 0)
                            {
                                paragraph.AppendFormat(STR_ExtendedDefinition, Resources.Author, string.Join(", ", doc.GetRealAuthors(theme.Info.Authors)), theme.Info.Comments.Text);
                            }
                            else
                            {
                                paragraph.AppendFormat(STR_Definition, Resources.Author, string.Join(", ", doc.GetRealAuthors(theme.Info.Authors)));
                            }
                            paragraph.AppendLine();
                            theme.Questions.ForEach(quest =>
                            {
                                paragraph.AppendLine();
                                paragraph.Append(quest.Price.ToString());
                                paragraph.AppendLine(".");
                                paragraph.AppendLine(quest.Scenario.ToString().Replace(Environment.NewLine, "//").EndWithPoint());
                                paragraph.AppendLine();
                                paragraph.AppendFormat(STR_Definition, Resources.Answer, string.Join(", ", quest.Right.ToArray()).GrowFirstLetter().EndWithPoint());
                                paragraph.AppendLine();
                                paragraph.AppendFormat(STR_Definition, Resources.Comment, (quest.Info.Comments.Text.Length > 0 ? quest.Info.Comments.Text.GrowFirstLetter() : Resources.No.ToLower()).EndWithPoint());
                                paragraph.AppendLine();
                                paragraph.AppendFormat(STR_Definition, Resources.Source, (quest.Info.Sources.Count > 0 ? string.Join(", ", quest.Info.Sources.ToArray()).GrowFirstLetter() : Resources.No.ToLower()).EndWithPoint());
                                paragraph.AppendLine();
                            });
                        });
                    });

                document.Blocks.Add(paragraph);
            }
            break;

            case ExportFormats.Db:
            {
                var text = new StringBuilder();
                text.AppendLine(string.Format("{0}:", Resources.Championship));
                text.AppendLine(doc.Package.Name.EndWithPoint().GrowFirstLetter().Trim());
                text.AppendLine();
                var info         = new StringBuilder();
                int authorsCount = doc.Package.Info.Authors.Count;
                if (authorsCount > 0 && !(authorsCount == 1 && doc.Package.Info.Authors[0] == Resources.Empty))
                {
                    info.AppendLine(string.Join(Environment.NewLine, doc.GetRealAuthors(doc.Package.Info.Authors)).Trim());
                    info.AppendLine();
                }

                if (doc.Package.Info.Sources.Count > 0)
                {
                    info.AppendLine(string.Join(Environment.NewLine, doc.GetRealSources(doc.Package.Info.Sources)).Trim());
                    info.AppendLine();
                }

                if (doc.Package.Info.Comments.Text.Length > 0)
                {
                    info.AppendLine(doc.Package.Info.Comments.Text.GrowFirstLetter().EndWithPoint().Trim());
                    info.AppendLine();
                }

                if (info.Length > 0)
                {
                    text.AppendLine("Инфо:");
                    text.Append(info);
                }

                int r = 1;
                foreach (var round in doc.Package.Rounds)
                {
                    text.AppendLine(string.Format("{0}:", Resources.Tour));
                    text.Append(round.Name.GrowFirstLetter().Trim());
                    if (round.Type == RoundTypes.Final)
                    {
                        text.Append(string.Format(" ({0})", Resources.Final));
                    }

                    text.AppendLine();
                    text.AppendLine();

                    if (round.Info.Authors.Count > 0)
                    {
                        text.AppendLine(string.Format("{0}:", Resources.BaseAuthors));
                        text.AppendLine(string.Join(Environment.NewLine, doc.GetRealAuthors(round.Info.Authors)).Trim());
                        text.AppendLine();
                    }

                    if (round.Info.Sources.Count > 0)
                    {
                        text.AppendLine(string.Format("{0}:", Resources.BaseSources));
                        text.AppendLine(string.Join(Environment.NewLine, doc.GetRealSources(round.Info.Sources)).Trim());
                        text.AppendLine();
                    }

                    if (round.Info.Comments.Text.Length > 0)
                    {
                        text.AppendLine(string.Format("{0}:", Resources.Comments));
                        text.AppendLine(round.Info.Comments.Text.GrowFirstLetter().EndWithPoint().Trim());
                        text.AppendLine();
                    }

                    int i = 1;
                    foreach (var theme in round.Themes)
                    {
                        text.AppendLine(string.Format("{0} {1}:", Resources.Question, i));
                        text.AppendLine(theme.Name.EndWithPoint().GrowFirstLetter().Trim());

                        if (theme.Info.Comments.Text.Length > 0)
                        {
                            text.Append("   (");
                            text.Append(theme.Info.Comments.Text.GrowFirstLetter().Trim());
                            text.AppendLine(")");
                        }

                        int L = theme.Questions.Count;

                        for (int j = 0; j < L; j++)
                        {
                            text.Append("   ");
                            if (j < 5)
                            {
                                text.Append((j + 1).ToString());
                            }
                            else
                            {
                                text.Append("Резерв");
                            }
                            text.AppendLine(string.Format(". {0}", theme.Questions[j].Scenario.ToString().EndWithPoint().GrowFirstLetter().Trim()));
                        }

                        text.AppendLine();
                        text.AppendLine(string.Format("{0}:", Resources.Answer));

                        for (int j = 0; j < L; j++)
                        {
                            var qLine = new StringBuilder("   ");
                            if (j < 5)
                            {
                                qLine.Append((j + 1).ToString());
                            }
                            else
                            {
                                qLine.Append("Резерв");
                            }

                            qLine.Append(string.Format(". {0}", theme.Questions[j].Right[0].ClearPoints().GrowFirstLetter().Trim()));
                            int A = theme.Questions[j].Right.Count;
                            if (A > 1)
                            {
                                qLine.Append(string.Format(" {0}: ", Resources.Accept));
                                for (int k = 1; k < A; k++)
                                {
                                    qLine.Append(theme.Questions[j].Right[k].ClearPoints().GrowFirstLetter());
                                    if (k < A - 1)
                                    {
                                        qLine.Append(", ");
                                    }
                                }
                            }

                            if (theme.Questions[j].Info.Comments.Text.Length > 0)
                            {
                                qLine.Append(string.Format(" ({0})", theme.Questions[j].Info.Comments.Text.ClearPoints().GrowFirstLetter().Trim()));
                            }
                            text.AppendLine(qLine.ToString().EndWithPoint());
                        }

                        bool qHasSource(Question quest) => quest.Info.Sources.Count > 0 && quest.Info.Sources[0].Length > 3;

                        if (theme.Questions.Any(qHasSource))
                        {
                            text.AppendLine();
                            text.AppendLine(string.Format("{0}:", Resources.BaseSources));

                            for (int j = 0; j < L; j++)
                            {
                                if (qHasSource(theme.Questions[j]))
                                {
                                    if (j < 5)
                                    {
                                        text.Append(string.Format("   {0}. ", j + 1));
                                    }
                                    else
                                    {
                                        text.Append("   Резерв.");
                                    }
                                    text.AppendLine(string.Join(", ", doc.GetRealSources(theme.Questions[j].Info.Sources)).EndWithPoint().Trim());
                                }
                            }
                        }

                        text.AppendLine();

                        var authors = new List <string>(doc.GetRealAuthors(theme.Info.Authors));

                        foreach (var quest in theme.Questions)
                        {
                            authors.AddRange(doc.GetRealAuthors(quest.Info.Authors));
                        }

                        if (authors.Count == 0)
                        {
                            authors.AddRange(doc.GetRealAuthors(round.Info.Authors));
                        }

                        if (authors.Count == 0)
                        {
                            authors.AddRange(doc.GetRealAuthors(doc.Package.Info.Authors));
                        }

                        authorsCount = authors.Count;
                        if (authorsCount > 0 && !(authorsCount == 1 && authors[0] == Resources.Empty))
                        {
                            text.AppendLine(string.Format("{0}:", Resources.BaseAuthors));
                            text.AppendLine(string.Join(", ", authors.ToArray()).Trim());
                            text.AppendLine();
                        }

                        if (theme.Info.Sources.Count > 0)
                        {
                            text.AppendLine(string.Format("{0}:", Resources.BaseSources));
                            text.AppendLine(string.Join(Environment.NewLine, doc.GetRealSources(theme.Info.Sources)).Trim());
                            text.AppendLine();
                        }

                        i++;
                    }

                    r++;
                }

                int    counter = 0, iold = 0;
                string fileStr = text.Replace('«', '\"').Replace('»', '\"').Replace('–', '-').Replace('—', '-').Replace("…", "...").ToString();
                int    fl      = fileStr.Length;
                var    fileRes = new StringBuilder();
                for (int i = 0; i < fl; i++)
                {
                    if (fileStr[i] == '\r')
                    {
                        counter = 0;
                        fileRes.Append(fileStr.Substring(iold, i - iold + 2));
                        i++;
                        iold = i + 1;
                    }
                    else
                    {
                        counter++;
                        if (counter == 73)
                        {
                            while (!char.IsWhiteSpace(fileStr, i) && i > 0 && i > iold)
                            {
                                i--;
                            }

                            if (i == iold || i == iold + 5 && char.IsDigit(fileStr[iold + 3]) && fileStr[iold + 4] == '.')
                            {
                                i = iold + 72;
                                while (!char.IsWhiteSpace(fileStr, i) && i < fl)
                                {
                                    i++;
                                }
                            }

                            fileRes.AppendLine(fileStr.Substring(iold, i - iold));
                            if (fileStr[i] == '\r')
                            {
                                i++;
                                iold = i + 1;
                            }
                            else
                            {
                                iold = i + (char.IsWhiteSpace(fileStr, i) ? 1 : 0);
                            }

                            counter = 0;
                        }
                    }
                }

                var paragraph = new Paragraph();
                foreach (var line in fileRes.ToString().Split(new string[] { "\r\n", "\r", "\n" }, StringSplitOptions.None))
                {
                    if (paragraph.Inlines.Count > 0)
                    {
                        paragraph.AppendLine();
                    }

                    if (line.Length > 0)
                    {
                        paragraph.AppendText(line);
                    }
                }

                document.Blocks.Add(paragraph);
            }

            break;
            }

            document.PageWidth  = 21.0 / 2.54 * 96;
            document.PageHeight = 29.7 / 2.54 * 96;

            return(new FlowDocumentWrapper(document));
        }
Example #17
0
        private void ExportItems(ExportFormats fmt)
        {
            var selectedPwEntries = m_host.MainWindow.GetSelectedEntries();

            // Just double-check in case we end up in this condition somehow
            if (selectedPwEntries == null || selectedPwEntries.Length == 0)
            {
                MessageService.ShowInfo("No entries selected for export");
                return;
            }

            Stream         stream;
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            if (fmt == ExportFormats.Text)
            {
                saveFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
            }
            else
            {
                saveFileDialog.Filter = "csv files(*.csv)| *.csv | All files(*.*) | *.*";
            }

            saveFileDialog.FilterIndex      = 1;
            saveFileDialog.RestoreDirectory = true;

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                if ((stream = saveFileDialog.OpenFile()) != null)
                {
                    using (var streamWriter = new StreamWriter(stream))
                    {
                        var path = ((FileStream)streamWriter.BaseStream).Name;
                        if (fmt == ExportFormats.Text)
                        {
                            foreach (PwEntry entry in selectedPwEntries)
                            {
                                var simplified  = GetExportRecordFromEntry(entry);
                                var textPattern = $@"Title: {simplified.Title}
Username: {simplified.Username}
Password: {simplified.Password}
Url: {simplified.Url}
Notes: {simplified.Notes}
----------------------------------------------------------
";

                                streamWriter.WriteLine(textPattern);
                            }
                        }
                        else
                        {
                            // Assume CSV since we currently have just two options
                            using (CsvWriter csvWriter = new CsvWriter(streamWriter, CultureInfo.InvariantCulture))
                            {
                                var records = new List <BasicExportEntry>();

                                foreach (PwEntry entry in selectedPwEntries)
                                {
                                    records.Add(GetExportRecordFromEntry(entry));
                                }

                                csvWriter.WriteRecords(records);
                            }
                        }
                        MessageService.ShowInfo(String.Format("Export to {0} completed.", path));
                    }
                }
            }
        }
Example #18
0
        public byte[] Export(
            DB.IObjectRepository tdb,
            SimpleSchema schema,
            ExportFormats format,
            IGSettingsManager igSettings,
            List <string> categories,
            List <DB.Template> templates,
            bool includeVocabulary,
            bool returnJson = true)
        {
            var templateIds = templates.Select(y => y.Id);

            switch (format)
            {
            case ExportFormats.Microsoft_Word_DOCX:
                ImplementationGuide ig = tdb.ImplementationGuides.Single(y => y.Id == igSettings.ImplementationGuideId);
                MSWord.ImplementationGuideGenerator docxGenerator = new MSWord.ImplementationGuideGenerator(tdb, igSettings.ImplementationGuideId, templateIds);

                // TODO: Re-factor ITypeExporter to accept ExportSettings
                MSWord.ExportSettings exportConfig = new MSWord.ExportSettings();
                exportConfig.Use(c =>
                {
                    c.GenerateTemplateConstraintTable = true;
                    c.GenerateTemplateContextTable    = true;
                    c.GenerateDocTemplateListTable    = true;
                    c.GenerateDocContainmentTable     = true;
                    c.AlphaHierarchicalOrder          = true;
                    c.DefaultValueSetMaxMembers       = 100;
                    c.GenerateValueSetAppendix        = true;
                    c.IncludeXmlSamples     = true;
                    c.IncludeChangeList     = true;
                    c.IncludeTemplateStatus = true;
                    c.IncludeNotes          = false;
                    c.SelectedCategories    = categories;
                });

                docxGenerator.BuildImplementationGuide(exportConfig, ig.ImplementationGuideType.GetPlugin());
                return(docxGenerator.GetDocument());

            case ExportFormats.FHIR_Bundle:
                throw new NotImplementedException();

            case ExportFormats.Native_XML:
                NativeExporter nativeExporter = new NativeExporter(tdb, templates, igSettings, true, categories);

                if (returnJson)
                {
                    return(System.Text.Encoding.UTF8.GetBytes(nativeExporter.GenerateJSONExport()));
                }
                else
                {
                    return(System.Text.Encoding.UTF8.GetBytes(nativeExporter.GenerateXMLExport()));
                }

            case ExportFormats.Templates_DSTU_XML:
                DecorExporter decorExporter = new DecorExporter(templates, tdb, igSettings.ImplementationGuideId);
                return(System.Text.Encoding.UTF8.GetBytes(decorExporter.GenerateXML()));

            default:
                throw new Exception("Invalid export format for the specified implementation guide type");
            }
        }
Example #19
0
 public PagesLoader(ExportFormats formatToExport)
 {
     this.formatToExport = formatToExport;
 }
Example #20
0
        public static string[] GetACodecsList(ExportFormats format)
        {
            switch (format)
               {
               case ExportFormats.Audio:
                   return new string[] { "PCM", "FLAC", "AC3", "MP3", "MP2", "AAC", "QAAC" };

               case ExportFormats.Mpeg1PS:
               case ExportFormats.DpgNintendoDS:
                   return new string[] { "MP2" };

               case ExportFormats.BluRay:
                   return new string[] { "PCM", "AC3" };

               case ExportFormats.PmpAvc:
                   return new string[] { "MP3", "AAC" };
               }

               if (Formats.GetDefaults(format).IsEditable)
               {
               if (Formats.GetDefaults(format).ACodecs_IsEditable)
               {
                   return Formats.GetSettings(format, "ACodecs", Formats.GetDefaults(format).ACodecs);
               }

               return Formats.GetDefaults(format).ACodecs;
               }

               return new string[] { "PCM", "FLAC", "AC3", "MP3", "MP2", "AAC", "QAAC" };
        }
Example #21
0
        public void SaveExportSettings([FromBody] ExportSettingsModel model, [FromUri] int implementationGuideId, [FromUri] ExportFormats format)
        {
            if (!CheckPoint.Instance.GrantEditImplementationGuide(implementationGuideId))
            {
                throw new UnauthorizedAccessException("You do not have permissions to save default settings for this implementation guide.");
            }

            IGSettingsManager igSettings       = new IGSettingsManager(this.tdb, implementationGuideId);
            string            settingsJson     = JsonConvert.SerializeObject(model);
            string            settingsProperty = "ExportSettings_" + format.ToString();

            igSettings.SaveSetting(settingsProperty, settingsJson);
        }
Example #22
0
 public static string GetValidVPreset(ExportFormats format)
 {
     if (format == ExportFormats.Avi ||
        format == ExportFormats.AviHardware ||
        format == ExportFormats.AviHardwareHD ||
        format == ExportFormats.AviiRiverClix2 ||
        format == ExportFormats.Mp4PSPASP ||
        format == ExportFormats.Mp4Prada ||
        format == ExportFormats.Mp4BlackBerry8100 ||
        format == ExportFormats.Mp4BlackBerry8800 ||
        format == ExportFormats.Mp4BlackBerry8830 ||
        format == ExportFormats.Mp4MotorolaK1 ||
        format == ExportFormats.Mp4SonyEricssonK800 ||
        format == ExportFormats.Mp4SonyEricssonK610)
        return "XviD HQ Ultra";
        else if (format == ExportFormats.AviDVNTSC ||
        format == ExportFormats.AviDVPAL)
        return "DV Video";
        else if (format == ExportFormats.Mpeg2NTSC ||
        format == ExportFormats.Mpeg2PAL)
        return "MPEG2 HQ Ultra";
        else if (format == ExportFormats.Mpeg2PS)
        return "MPEG2 HQ Ultra";
        else if (format == ExportFormats.Mpeg1PS ||
        format == ExportFormats.DpgNintendoDS)
        return "MPEG1 HQ Ultra";
        else if (format == ExportFormats.Mp4ToshibaG900 ||
        format == ExportFormats.AviMeizuM6)
        return "MPEG4 HQ Ultra";
        else if (format == ExportFormats.Flv)
        return "FLV1 HQ Ultra";
        else if (format == ExportFormats.BluRay ||
        format == ExportFormats.M2TS ||
        format == ExportFormats.TS ||
        format == ExportFormats.Mkv ||
        format == ExportFormats.Mp4 ||
        format == ExportFormats.Mp4PSPAVC ||
        format == ExportFormats.Mp4PSPAVCTV)
        return "x264 Q21 HQ Film";
        else if (format == ExportFormats.Mp4iPod55G ||
        format == ExportFormats.Mp4iPhone ||
        format == ExportFormats.Mp4PS3)
        return "x264 Q21 HQ";
        else
        return "x264 HQ Ultra";
 }
Example #23
0
 public abstract IFlowDocumentWrapper BuildDocument(SIDocument doc, ExportFormats format);
Example #24
0
        public static string[] GetVCodecsList(ExportFormats format)
        {
            //x265 x264 x262 XviD MPEG4 MPEG2 HUFF DV FLV1 FFV1

               switch (format)
               {
               case ExportFormats.Mpeg1PS:
               case ExportFormats.DpgNintendoDS:
                   return new string[] { "MPEG1" };

               case ExportFormats.BluRay:
                   return new string[] { "MPEG2", "x264", "x262" };

               case ExportFormats.PmpAvc:
                   return new string[] { "x264", "MPEG4", "XviD" };
               }

               if (Formats.GetDefaults(format).IsEditable)
               {
               if (Formats.GetDefaults(format).VCodecs_IsEditable)
               {
                   return Formats.GetSettings(format, "VCodecs", Formats.GetDefaults(format).VCodecs);
               }

               return Formats.GetDefaults(format).VCodecs;
               }

               return new string[] { "x264", "MPEG4", "FLV1", "MJPEG", "HUFF", "FFV1", "XviD" };
        }