Пример #1
0
 /// <summary>
 /// ���캯����
 /// </summary>
 /// <param name="page">page<see cref="Page"/>��</param>
 public ExportData(Page page)
 {
     if (page == null)
         throw new ArgumentNullException("page");
     this.page = page;
     this.exportFileType = ExportFileType.csv;
 }
Пример #2
0
        public ExportOption(ExportFileType exportFileType, string friendlyName, string extension)
        {
            ExportFileType = exportFileType;
            FriendlyName = friendlyName;
            Extension = extension;

            _string = string.Format("{0}|{1}", FriendlyName, "*." + Extension);
        }
Пример #3
0
        public static string GetFileExtensionAsString(ExportFileType fileExtension)
        {
            switch (fileExtension)
            {
            case ExportFileType.CSV:
                return("CSV");

            case ExportFileType.XML:
                return("XML");

            case ExportFileType.JSON:
                return("JSON");

            case ExportFileType.TXT:
                return("TXT");

            default:
                return(string.Empty);
            }
        }
Пример #4
0
        public static void Export(string filePath, ExportFileType fileType, ObservableCollection <PingInfo> collection)
        {
            switch (fileType)
            {
            case ExportFileType.CSV:
                CreateCSV(collection, filePath);
                break;

            case ExportFileType.XML:
                CreateXML(collection, filePath);
                break;

            case ExportFileType.JSON:
                CreateJSON(collection, filePath);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(fileType), fileType, null);
            }
        }
Пример #5
0
        private void Browse_Click(object sender, EventArgs e)
        {
            using (var dlg = new SaveFileDialog())
            {
                dlg.Title            = LocalizationManager.GetString("DialogBoxes.ExportDlg.SaveFileDialog.Title", "Choose File Location");
                dlg.OverwritePrompt  = false;
                dlg.InitialDirectory = m_defaultDirectory;
                dlg.FileName         = Path.GetFileName(m_lblFileName.Text);
                dlg.Filter           = string.Format("{0} ({1})|{1}|{2} ({3})|{3}|{4} ({5})|{5}",
                                                     LocalizationManager.GetString("DialogBoxes.ExportDlg.ExcelFileTypeLabel", "Excel files"), "*" + ProjectExporter.kExcelFileExtension,
                                                     LocalizationManager.GetString("DialogBoxes.ExportDlg.TabDelimitedFileTypeLabel", "Tab-delimited files"), "*" + ProjectExporter.kTabDelimitedFileExtension,
                                                     LocalizationManager.GetString("DialogBoxes.FileDlg.AllFilesLabel", "All Files"), "*.*");
                dlg.DefaultExt = ProjectExporter.kExcelFileExtension;
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    switch (dlg.FilterIndex)
                    {
                    //1-indexed
                    case 2:                             //.txt
                        m_selectedFileType = ExportFileType.TabSeparated;
                        break;

                    default:
                        m_selectedFileType = ExportFileType.Excel;
                        break;
                    }

                    m_defaultDirectory = Path.GetDirectoryName(dlg.FileName);
                    m_lblFileName.Text = dlg.FileName;

                    string expectedFileExtension = ProjectExporter.GetFileExtension(m_selectedFileType);
                    if (!m_lblFileName.Text.EndsWith(expectedFileExtension))
                    {
                        m_lblFileName.Text += expectedFileExtension;
                    }

                    UpdateDisplay();
                }
            }
        }
Пример #6
0
 public Exporter(ExportFileType exportFileType)
 {
     switch (exportFileType)
     {
         case ExportFileType.PlainText:
             _exporter = new PlainTextExporter();
             break;
         case ExportFileType.Markdown:
             _exporter = new MarkdownExporter();
             break;
         case ExportFileType.BbCode:
             _exporter = new BbCodeExporter();
             break;
         case ExportFileType.Csv:
             _exporter = new DelimeterSeperatedValueExporter(DelimeterSeperatedValueExporter.Delimter.Comma);
             break;
         case ExportFileType.Tsv:
             _exporter = new DelimeterSeperatedValueExporter(DelimeterSeperatedValueExporter.Delimter.Tab);
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
Пример #7
0
        public void GenerateActorFiles(string directoryPath, ExportFileType fileType)
        {
            if (!IncludeVoiceActors)
            {
                return;
            }

            switch (fileType)
            {
            case ExportFileType.TabSeparated:
                foreach (var actor in Project.VoiceActorList.Actors.Where(a => Project.CharacterGroupList.HasVoiceActorAssigned(a.Id)))
                {
                    GenerateTabSeparatedFile(Path.Combine(directoryPath, actor.Name), GetExportData().Where(t => t.Item1 == actor.Id).Select(t => t.Item3));
                }
                break;

            default:
                foreach (var actor in Project.VoiceActorList.Actors.Where(a => Project.CharacterGroupList.HasVoiceActorAssigned(a.Id)))
                {
                    GenerateExcelFile(Path.Combine(directoryPath, actor.Name), GetExportData().Where(t => t.Item1 == actor.Id).Select(t => t.Item3));
                }
                break;
            }
        }
Пример #8
0
        public Exporter(ExportFileType exportFileType)
        {
            switch (exportFileType)
            {
            case ExportFileType.PlainText:
                _exporter = new PlainTextExporter();
                break;

            case ExportFileType.Markdown:
                _exporter = new MarkdownExporter();
                break;

            case ExportFileType.BbCode:
                _exporter = new BbCodeExporter();
                break;

            case ExportFileType.Csv:
                _exporter = new DelimeterSeperatedValueExporter(DelimeterSeperatedValueExporter.Delimter.Comma);
                break;

            case ExportFileType.Tsv:
                _exporter = new DelimeterSeperatedValueExporter(DelimeterSeperatedValueExporter.Delimter.Tab);
                break;

            case ExportFileType.Ckan:
                _exporter = new CfanExporter(true);
                break;

            case ExportFileType.CkanFavourite:
                _exporter = new CfanExporter(false);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #9
0
 /// <summary>
 /// 导出数据类型。
 /// </summary>
 /// <param name="fileType"></param>
 /// <returns></returns>
 protected override System.IO.StringWriter Download(ExportFileType fileType)
 {
     if (this.gView == null)
         return this.ExportDataSourceData(this.dtSource, fileType);
     else
         return this.Export(this.gView, fileType, this.dtSource);
 }
Пример #10
0
 public void CreateBatchDetailExportFile(int batchDetailID, int xbrlDocumentID, string language, ExportFileType fileFormatType, bool replaceExistingFile)
 {
     FilingProcessorManager.TheMgr.CreateBatchDetailExportFile(batchDetailID, xbrlDocumentID, language, fileFormatType, replaceExistingFile);
 }
        private string BuildActivityFileName(int activityId, ExportFileType fileType)
        {
            string fileName = String.Format("Activity{0}.{1}", activityId, fileType.ToString().ToLower());

            return(Path.Combine(OutputPath, fileName));
        }
Пример #12
0
        /// <summary>
        /// 将内容导出成特定格式的文件
        /// </summary>
        /// <param name="contents">需要导出的内容</param>
        /// <param name="fileName">导出的文件名</param>
        /// <param name="fileType">导出的文件类型,默认为导出Excel文件</param>
        /// <param name="encoding">输出流HTTP字符集</param>
        public static void ExportToExcel(string contents, string fileName, ExportFileType fileType, Encoding encoding)
        {
            if (HttpContext.Current.Response == null) return;

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Buffer = true;
            HttpContext.Current.Response.Charset = encoding.ToString();
            HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName));

            //设置输出流HTTP字符集
            HttpContext.Current.Response.ContentEncoding = encoding;
            //设置输出文件类型 
            switch (fileType)
            {
                case ExportFileType.Excel:
                    HttpContext.Current.Response.ContentType = CONST_REPONSEHEADER_EXCEL;
                    break;
                case ExportFileType.Word:
                    HttpContext.Current.Response.ContentType = CONST_REPONSEHEADER_WORD;
                    break;
                case ExportFileType.PDF:
                    HttpContext.Current.Response.ContentType = CONST_REPONSEHEADER_PDF;
                    break;
                case ExportFileType.XML:
                    HttpContext.Current.Response.ContentType = CONST_REPONSEHEADER_XML;
                    break;
                case ExportFileType.ZIP:
                    HttpContext.Current.Response.ContentType = CONST_REPONSEHEADER_ZIP;
                    break;
                case ExportFileType.Txt:
                    HttpContext.Current.Response.ContentType = CONST_REPONSEHEADER_TEXT;
                    break;
                case ExportFileType.CSV:
                    HttpContext.Current.Response.ContentType = CONST_REPONSEHEADER_CSV;
                    break;
                default:
                    HttpContext.Current.Response.ContentType = CONST_REPONSEHEADER_EXCEL;
                    break;
            }

            HttpContext.Current.Response.Write(contents);

            HttpContext.Current.Response.Flush();
            HttpContext.Current.Response.End();
        }
Пример #13
0
        public byte[] Export(System.Data.DataTable source, Dictionary <string, string> titleMap, ExportFileType type, bool isZip)
        {
            using (var package = new ExcelPackage())
            {
                var worksheet = package.Workbook.Worksheets.Add("sheet1");
                if (titleMap != null)
                {
                    titleMap.Keys.Each((key, i) =>
                    {
                        worksheet.Cells[1, i + 1].Value = titleMap[key];

                        for (int j = 0; j < source.Rows.Count; j++)
                        {
                            try
                            {
                                worksheet.Cells[2 + j, i + 1].Value = source.Rows[j][key];
                            }
                            catch
                            { }
                        }
                    });
                }
                else
                {
                    for (int i = 0; i < source.Columns.Count; i++)
                    {
                        worksheet.Cells[1, i + 1].Value = source.Columns[i].ColumnName;

                        for (int j = 0; j < source.Rows.Count; j++)
                        {
                            worksheet.Cells[2 + j, i + 1].Value = source.Rows[j][i];
                        }
                    }
                }

                worksheet.Cells.AutoFitColumns();
                return(package.GetAsByteArray());
            }
        }
Пример #14
0
 public bool CreateBatchExportFiles(int marketID, int batchID, string language, ExportFileType fileFormatType, bool replaceExistingFiles, out string error)
 {
     return FilingDispatcherManager.TheMgr.CreateBatchExportFiles(marketID, batchID, language, fileFormatType, replaceExistingFiles, out error);
 }
Пример #15
0
        bool bAppend = true;    // 本次输出是否追加在以前存在的文件末尾

        // 准备输出
        public int Begin(
            IWin32Window owner,
            string strOutputFileName,
            out string strError)
        {
            strError = "";

            this.m_owner = owner;

            if (string.IsNullOrEmpty(strOutputFileName) == true)
            {
                strError = "输出文件名不能为空";
                return -1;
            }

            string strExt = Path.GetExtension(strOutputFileName);
            if (string.Compare(strExt, ".xml", true) == 0)
                this.FileType = ExportFileType.XmlFile;
            else if (string.Compare(strExt, ".dp2bak", true) == 0)
                this.FileType = ExportFileType.BackupFile;
            else if (string.Compare(strExt, ".iso", true) == 0
                || string.Compare(strExt, ".marc", true) == 0)
                this.FileType = ExportFileType.ISO2709File;
            else
            {
                strError = "无法根据文件扩展名 '" + strExt + "' 判断输出文件的格式";
                return -1;
            }

            this.bAppend = true;

            if (String.IsNullOrEmpty(strOutputFileName) == false)
            {
                // 探测输出文件是否已经存在
                FileInfo fi = new FileInfo(strOutputFileName);
                bAppend = true;
                if (fi.Exists == true && fi.Length > 0)
                {
                    if (FileType == ExportFileType.BackupFile
                        || FileType == ExportFileType.ISO2709File)
                    {
                        DialogResult result = MessageBox.Show(owner,
                            "文件 '" + strOutputFileName + "' 已存在,是否追加?\r\n\r\n--------------------\r\n注:(是)追加  (否)覆盖  (取消)中断处理",
                            "导出数据",
                            MessageBoxButtons.YesNoCancel,
                            MessageBoxIcon.Question,
                            MessageBoxDefaultButton.Button1);
                        if (result == DialogResult.Yes)
                        {
                            bAppend = true;
                        }
                        if (result == DialogResult.No)
                        {
                            bAppend = false;
                        }
                        if (result == DialogResult.Cancel)
                        {
                            strError = "放弃处理...";
                            return -1;
                        }
                    }
                    else if (FileType == ExportFileType.XmlFile)
                    {
                        DialogResult result = MessageBox.Show(owner,
                            "文件 '" + strOutputFileName + "' 已存在,是否覆盖?\r\n\r\n--------------------\r\n注:(是)覆盖  (否)中断处理",
                            "导出数据",
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question,
                            MessageBoxDefaultButton.Button2);
                        if (result != DialogResult.Yes)
                        {
                            strError = "放弃处理...";
                            return -1;
                        }
                    }
                }

                // 打开文件
                if (FileType == ExportFileType.BackupFile
                    || FileType == ExportFileType.ISO2709File)
                {
                    outputfile = File.Open(
                        strOutputFileName,
                        FileMode.OpenOrCreate,	// 原来是Open,后来修改为OpenOrCreate。这样对临时文件被系统管理员手动意外删除(但是xml文件中仍然记载了任务)的情况能够适应。否则会抛出FileNotFoundException异常
                        FileAccess.Write,
                        FileShare.ReadWrite);
                }
                else if (FileType == ExportFileType.XmlFile)
                {
                    outputfile = File.Create(
                        strOutputFileName);

                    writer = new XmlTextWriter(outputfile, Encoding.UTF8);
                    writer.Formatting = Formatting.Indented;
                    writer.Indentation = 4;
                }

            }

            if ((FileType == ExportFileType.BackupFile
                || FileType == ExportFileType.ISO2709File)
                && outputfile != null)
            {
                if (bAppend == true)
                    outputfile.Seek(0, SeekOrigin.End);	// 具有追加的能力
                else
                    outputfile.SetLength(0);
            }

            if (FileType == ExportFileType.XmlFile
&& writer != null)
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("dprms", "collection", DpNs.dprms);
                //writer.WriteStartElement("collection");
                //writer.WriteAttributeString("xmlns:marc",
                //	"http://www.loc.gov/MARC21/slim");
            }

            return 0;
        }
Пример #16
0
        public bool CreateBatchExportFiles(int marketID, int batchID, string language, ExportFileType fileFormatType, bool replaceExistingFiles, out string error)
        {
            error = null;

            string processorServerKey = GetProcessor(marketID);

            if (string.IsNullOrEmpty(processorServerKey))
            {
                error = string.Format("Loader not found for Market Id: {0}", marketID);
                return(false);
            }

            if (registeredProcessors != null && registeredProcessors.ContainsKey(processorServerKey))
            {
                IFilingProcessorRemotable processor;
                string errors = string.Empty;

                if (TryGetProcessorRemotable(processorServerKey, out processor, out errors))
                {
                    try
                    {
                        processor.CreateBatchExportFiles(batchID, language, fileFormatType, replaceExistingFiles);
                        this.WriteLogEntry(string.Format("CreateBatchDetailExportFile completed. Target Service: {0} Market Id: {1}", processorServerKey, marketID.ToString()), EventLogEntryType.Information);
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        WriteLogEntry("Exception thrown in call to CreateBatchExportFiles: " + ex.Message, EventLogEntryType.Warning);
                        return(false);
                    }
                }
                else
                {
                    WriteLogEntry("CreateBatchExportFiles() " + this.myServerKey + ", from the Dispatcher Failed: " + errors, EventLogEntryType.Warning);
                    return(false);
                }
            }
            else
            {
                error = string.Format("No registered loader");
                return(false);
            }
        }
Пример #17
0
        private void TestTransitionListOutput(SrmDocument importDoc, string outputName, string expectedName, ExportFileType fileType)
        {
            // Write out a transition list
            string csvPath = TestContext.GetTestPath(outputName);
            string csvExpectedPath = TestFilesDir.GetTestPath(expectedName);
            // Open Export Method dialog, and set method to scheduled or standard.
            var exportMethodDlg =
                ShowDialog<ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(fileType));
            if (fileType == ExportFileType.IsolationList)
            {
                RunUI(() =>
                {
                    exportMethodDlg.InstrumentType = ExportInstrumentType.AGILENT_TOF;
                    exportMethodDlg.ExportStrategy = ExportStrategy.Single;
                    exportMethodDlg.OptimizeType = ExportOptimize.CE;
                    exportMethodDlg.MethodType = ExportMethodType.Standard;
                });
            }
            else
            {
                RunUI(() =>
                {
                    exportMethodDlg.InstrumentType = ExportInstrumentType.THERMO; // Choose one that exercises CE regression
                });
            }
            OkDialog(exportMethodDlg, () => exportMethodDlg.OkDialog(csvPath));

            // Check for expected output.
            var csvOut = File.ReadAllText(csvPath);
            var csvExpected = File.ReadAllText(csvExpectedPath);
            AssertEx.Contains(csvExpected, csvOut);
        }
Пример #18
0
 /// <summary>
 /// 导出数据。
 /// </summary> 
 protected virtual StringWriter Export(GridView gView, ExportFileType fileType, DataTable dtSource)
 {
     StringWriter sw = new StringWriter();
     if (gView != null)
     {
         string split = (fileType == ExportFileType.txt ? "\t" : ",");
         Dictionary<string, string> dataInfo;
         sw.WriteLine("<table border=\"1\">");
         this.ExportHeader(gView.Columns, split, ref sw, out dataInfo);
         this.ExportSourceData(dtSource, dataInfo, split, ref sw);
         sw.WriteLine("</table>");
     }
     return sw;
 }
Пример #19
0
 /// <summary>
 /// �������ݡ�
 /// </summary>
 protected StringWriter ExportDataSourceData(DataTable dtSource, ExportFileType fileType)
 {
     StringWriter sw = new StringWriter();
     if (dtSource != null)
     {
         string split = (fileType == ExportFileType.txt ? "\t" : ",");
         string strRowData = string.Empty;
         //������
         foreach (DataColumn col in dtSource.Columns)
         {
             if (string.IsNullOrEmpty(strRowData))
                 strRowData = col.ColumnName;
             else
                 strRowData += string.Format("{0}{1}", split, col.ColumnName);
         }
         sw.WriteLine(strRowData.Replace("\r\n", " "));
         //������
         foreach (DataRow dr in dtSource.Rows)
         {
             strRowData = string.Empty;
             foreach (DataColumn col in dtSource.Columns)
             {
                 if (string.IsNullOrEmpty(strRowData))
                     strRowData = this.CellDataFormat(dr[col].ToString().Replace(",", "��"));
                 else
                     strRowData += string.Format("{0}{1}", split, this.CellDataFormat(dr[col].ToString().Replace(",", "��")));
             }
             sw.WriteLine(this.RemoveHtmlTag(strRowData.Replace("\r\n", " ")));
         }
     }
     return sw;
 }
Пример #20
0
 /// <summary>
 /// ��������ʵ�֡�
 /// </summary>
 /// <param name="fileType"></param>
 /// <returns></returns>
 protected virtual StringWriter Download(ExportFileType fileType)
 {
     if (this.gridView != null)
         return this.Export(this.gridView, fileType);
     return null;
 }
Пример #21
0
        /// <summary>
        /// �������ݡ�
        /// </summary>
        /// <returns></returns>
        public virtual StringWriter Export(DataGridView gView, ExportFileType fileType)
        {
            StringWriter sw = new StringWriter();
            if (gView != null)
            {
                string split = (fileType == ExportFileType.txt ? "\t" : ",");
                DataControlFieldExCollection columns = gView.Columns;
                sw.WriteLine(this.RemoveHtmlTag(this.ExportHeader(columns, split)));

                DataGridViewRowCollection rows = gView.Rows;
                foreach (DataGridViewRow row in rows)
                    sw.WriteLine(this.RemoveHtmlTag(this.ExportItem(row, columns, split)));
            }
            return sw;
        }
Пример #22
0
 public ExportFilePressedEventArgs(ExportFileType fileType, string fileName)
 {
     FileType = fileType;
     FileName = fileName;
 }
Пример #23
0
        private void TestTransitionListOutput(SrmDocument importDoc, string outputName, string expectedName, ExportFileType fileType)
        {
            // Write out a transition list
            string csvPath         = TestContext.GetTestPath(outputName);
            string csvExpectedPath = TestFilesDir.GetTestPath(expectedName);
            // Open Export Method dialog, and set method to scheduled or standard.
            var exportMethodDlg =
                ShowDialog <ExportMethodDlg>(() => SkylineWindow.ShowExportMethodDialog(fileType));

            if (fileType == ExportFileType.IsolationList)
            {
                RunUI(() =>
                {
                    exportMethodDlg.InstrumentType = ExportInstrumentType.AGILENT_TOF;
                    exportMethodDlg.ExportStrategy = ExportStrategy.Single;
                    exportMethodDlg.OptimizeType   = ExportOptimize.CE;
                    exportMethodDlg.MethodType     = ExportMethodType.Standard;
                });
            }
            else
            {
                RunUI(() =>
                {
                    exportMethodDlg.InstrumentType = ExportInstrumentType.THERMO; // Choose one that exercises CE regression
                });
            }
            OkDialog(exportMethodDlg, () => exportMethodDlg.OkDialog(csvPath));

            // Check for expected output.
            var csvOut      = File.ReadAllText(csvPath);
            var csvExpected = File.ReadAllText(csvExpectedPath);

            AssertEx.Contains(csvExpected, csvOut);
        }
Пример #24
0
        public bool CreateBatchExportFiles(int marketID, int batchID, string language, ExportFileType fileFormatType, bool replaceExistingFiles, out string error)
        {
            error = null;

            string processorServerKey = GetProcessor(marketID);

            if (string.IsNullOrEmpty(processorServerKey))
            {
                error = string.Format("Loader not found for Market Id: {0}", marketID);
                return false;
            }

            if (registeredProcessors != null && registeredProcessors.ContainsKey(processorServerKey))
            {
                IFilingProcessorRemotable processor;
                string errors = string.Empty;

                if (TryGetProcessorRemotable(processorServerKey, out processor, out errors))
                {
                    try
                    {

                        processor.CreateBatchExportFiles(batchID, language, fileFormatType, replaceExistingFiles);
                        this.WriteLogEntry(string.Format("CreateBatchDetailExportFile completed. Target Service: {0} Market Id: {1}", processorServerKey, marketID.ToString()), EventLogEntryType.Information);
                        return true;

                    }
                    catch (Exception ex)
                    {
                        WriteLogEntry("Exception thrown in call to CreateBatchExportFiles: " + ex.Message, EventLogEntryType.Warning);
                        return false;
                    }
                }
                else
                {
                    WriteLogEntry("CreateBatchExportFiles() " + this.myServerKey + ", from the Dispatcher Failed: " + errors, EventLogEntryType.Warning);
                    return false;
                }

            }
            else
            {
                error = string.Format("No registered loader");
                return false;
            }
        }
Пример #25
0
 public ExportFilePressedEventArgs(ExportFileType fileType, string fileName)
 {
     FileType = fileType;
     FileName = fileName;
 }
Пример #26
0
        private void RecalcMethodCount(ExportDlgProperties exportProperties,
            string instrument, ExportFileType fileType, SrmDocument document)
        {
            AbstractMassListExporter exporter = null;
            try
            {
                exporter = exportProperties.ExportFile(instrument, fileType, null, document, null);
            }
            catch (IOException)
            {
            }
            catch(ADOException)
            {
            }

            int? methodCount = null;
            if (exporter != null)
                methodCount = exporter.MemoryOutput.Count;
            // Switch back to the UI thread to update the form
            try
            {
                if (IsHandleCreated)
                    Invoke(new Action<int?>(UpdateMethodCount), methodCount);
            }
            // ReSharper disable EmptyGeneralCatchClause
            catch (Exception)
            // ReSharper restore EmptyGeneralCatchClause
            {
                // If disposed, then no need to update the UI
            }
        }
Пример #27
0
 public bool CreateBatchDetailExportFile(int marketID, int batchDetailID, int xbrlDocumentID, string language, ExportFileType fileFormatType, bool replaceExistingFile, out string error)
 {
     return(FilingDispatcherManager.TheMgr.CreateBatchDetailExportFile(marketID, batchDetailID, xbrlDocumentID, language, fileFormatType, replaceExistingFile, out error));
 }
Пример #28
0
 public byte[] Export(System.Data.DataTable source, Dictionary <string, string> titleMap, ExportFileType type)
 {
     return(Export(source, titleMap, ExportFileType.Excel, false));
 }
Пример #29
0
 public bool CreateBatchExportFiles(int marketID, int batchID, string language, ExportFileType fileFormatType, bool replaceExistingFiles, out string error)
 {
     return(FilingDispatcherManager.TheMgr.CreateBatchExportFiles(marketID, batchID, language, fileFormatType, replaceExistingFiles, out error));
 }
Пример #30
0
 public byte[] Export <T>(IEnumerable <T> source, Dictionary <string, string> titleMap, ExportFileType type)
 {
     return(Export <T>(source, titleMap, ExportFileType.Excel, false));
 }
Пример #31
0
 public DialogResult ShowExportMethodDialog(ExportFileType fileType)
 {
     using (ExportMethodDlg dlg = new ExportMethodDlg(DocumentUI, fileType))
     {
         return dlg.ShowDialog(this);
     }
 }
        public override void LoadParametersV2(XElement xElement)
        {
            ProcessMS1 = GetBoolVal(xElement, "Process_MS", ProcessMS1);
            ProcessMS2 = GetBoolVal(xElement, "ProcessMSMS", ProcessMS2);

            ExportFileType        = (Globals.ExporterType)GetEnum(xElement, "ExportFileType", ExportFileType.GetType(), ExportFileType);
            ScanBasedWorkflowName = GetStringValue(xElement, "ScanBasedWorkflowType", ScanBasedWorkflowName);
            DeconvolutionType     = (Globals.DeconvolutionType)GetEnum(xElement, "DeconvolutionType", DeconvolutionType.GetType(), DeconvolutionType);

            UseRAPIDDeconvolution = GetBoolVal(xElement, "UseRAPIDDeconvolution", UseRAPIDDeconvolution);

            IsRefittingPerformed = GetBoolVal(xElement, "ReplaceRAPIDScoreWithHornFitScore", IsRefittingPerformed);

            ExportPeakData = GetBoolVal(xElement, "WritePeaksToTextFile", ExportPeakData);
        }
Пример #33
0
 public void CreateBatchDetailExportFile(int batchDetailID, int xbrlDocumentID, string language, ExportFileType fileFormatType, bool replaceExistingFile)
 {
     FilingProcessorManager.TheMgr.CreateBatchDetailExportFile(batchDetailID, xbrlDocumentID, language, fileFormatType,replaceExistingFile);
 }
Пример #34
0
 public bool CreateBatchExportFiles(int batchMarketID, string language, ExportFileType fileFormatType, bool replaceExistingFiles)
 {
     bool retVal = false;
     IFilingDatabase filingProcessorDB = this.filingProcessor as IFilingDatabase;
     if (filingProcessorDB != null)
     {
         filingProcessorDB.CreateBatchExportFiles(batchMarketID, language, fileFormatType, replaceExistingFiles);
         retVal = true;
     }
     else
     {
         WriteLogEntry("Create Batch Detail Export File Failed! Filing Processor does not implement IFilingDatabase", EventLogEntryType.Error);
         retVal = false;
     }
     return retVal;
 }
Пример #35
0
 public void CreateBatchExportFiles(int batchMarketID, string language, ExportFileType fileFormatType, bool replaceExistingFiles)
 {
     FilingProcessorManager.TheMgr.CreateBatchExportFiles(batchMarketID, language, fileFormatType, replaceExistingFiles);
 }
Пример #36
0
 public void CreateBatchExportFiles(int batchMarketID, string language, ExportFileType fileFormatType, bool replaceExistingFiles)
 {
     FilingProcessorManager.TheMgr.CreateBatchExportFiles(batchMarketID, language, fileFormatType, replaceExistingFiles);
 }
Пример #37
0
 public Export(ExportFileType exportFileType, ReportType reportType)
 {
     this.exportFileType = exportFileType;
     this.reportType = reportType;
 }
Пример #38
0
 public Export(ExportFileType exportFileType, ReportType reportType)
 {
     this.exportFileType = exportFileType;
     this.reportType     = reportType;
 }
Пример #39
0
        bool bAppend = true;                 // 本次输出是否追加在以前存在的文件末尾

        // 准备输出
        public int Begin(
            IWin32Window owner,
            string strOutputFileName,
            out string strError)
        {
            strError = "";

            this.m_owner = owner;

            if (string.IsNullOrEmpty(strOutputFileName) == true)
            {
                strError = "输出文件名不能为空";
                return(-1);
            }

            string strExt = Path.GetExtension(strOutputFileName);

            if (string.Compare(strExt, ".xml", true) == 0)
            {
                this.FileType = ExportFileType.XmlFile;
            }
            else if (string.Compare(strExt, ".dp2bak", true) == 0)
            {
                this.FileType = ExportFileType.BackupFile;
            }
            else if (string.Compare(strExt, ".iso", true) == 0 ||
                     string.Compare(strExt, ".marc", true) == 0)
            {
                this.FileType = ExportFileType.ISO2709File;
            }
            else
            {
                strError = "无法根据文件扩展名 '" + strExt + "' 判断输出文件的格式";
                return(-1);
            }

            this.bAppend = true;

            if (String.IsNullOrEmpty(strOutputFileName) == false)
            {
                // 探测输出文件是否已经存在
                FileInfo fi = new FileInfo(strOutputFileName);
                bAppend = true;
                if (fi.Exists == true && fi.Length > 0)
                {
                    if (FileType == ExportFileType.BackupFile ||
                        FileType == ExportFileType.ISO2709File)
                    {
                        if (owner != null)
                        {
                            DialogResult result = MessageBox.Show(owner,
                                                                  "文件 '" + strOutputFileName + "' 已存在,是否追加?\r\n\r\n--------------------\r\n注:(是)追加  (否)覆盖  (取消)中断处理",
                                                                  "导出数据",
                                                                  MessageBoxButtons.YesNoCancel,
                                                                  MessageBoxIcon.Question,
                                                                  MessageBoxDefaultButton.Button1);
                            if (result == DialogResult.Yes)
                            {
                                bAppend = true;
                            }
                            if (result == DialogResult.No)
                            {
                                bAppend = false;
                            }
                            if (result == DialogResult.Cancel)
                            {
                                strError = "放弃处理...";
                                return(-1);
                            }
                        }
                        else
                        {
                            bAppend = true;
                        }
                    }
                    else if (FileType == ExportFileType.XmlFile)
                    {
                        if (owner != null)
                        {
                            DialogResult result = MessageBox.Show(owner,
                                                                  "文件 '" + strOutputFileName + "' 已存在,是否覆盖?\r\n\r\n--------------------\r\n注:(是)覆盖  (否)中断处理",
                                                                  "导出数据",
                                                                  MessageBoxButtons.YesNo,
                                                                  MessageBoxIcon.Question,
                                                                  MessageBoxDefaultButton.Button2);
                            if (result != DialogResult.Yes)
                            {
                                strError = "放弃处理...";
                                return(-1);
                            }
                        }
                        else
                        {
                            bAppend = false;
                        }
                    }
                }

                // 打开文件
                if (FileType == ExportFileType.BackupFile ||
                    FileType == ExportFileType.ISO2709File)
                {
                    outputfile = File.Open(
                        strOutputFileName,
                        FileMode.OpenOrCreate,  // 原来是Open,后来修改为OpenOrCreate。这样对临时文件被系统管理员手动意外删除(但是xml文件中仍然记载了任务)的情况能够适应。否则会抛出FileNotFoundException异常
                        FileAccess.Write,
                        FileShare.ReadWrite);
                }
                else if (FileType == ExportFileType.XmlFile)
                {
                    outputfile = File.Create(
                        strOutputFileName);

                    writer             = new XmlTextWriter(outputfile, Encoding.UTF8);
                    writer.Formatting  = Formatting.Indented;
                    writer.Indentation = 4;
                }
            }

            if ((FileType == ExportFileType.BackupFile ||
                 FileType == ExportFileType.ISO2709File) &&
                outputfile != null)
            {
                if (bAppend == true)
                {
                    outputfile.Seek(0, SeekOrigin.End); // 具有追加的能力
                }
                else
                {
                    outputfile.SetLength(0);
                }
            }

            if (FileType == ExportFileType.XmlFile &&
                writer != null)
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("dprms", "collection", DpNs.dprms);
                //writer.WriteStartElement("collection");
                //writer.WriteAttributeString("xmlns:marc",
                //	"http://www.loc.gov/MARC21/slim");
            }

            return(0);
        }
Пример #40
0
        // return:
        //		-1	error
        //		0	正常结束
        //		1	希望跳过后来的OnEnd()
        int DoExportFile(
            string[] dbpaths,
            string strOutputFileName,
            ExportFileType exportType,
            Encoding targetEncoding,
            out string strError)
        {
            strError = "";
            int nRet = 0;

            string strDeleteStyle = "";
            if (this.checkBox_export_fastMode.Checked == true)
                strDeleteStyle = "fastmode";

            string strInfo = "";    // 汇总信息,在完成后显示

            FileStream outputfile = null;	// Backup和Xml格式输出都需要这个
            XmlTextWriter writer = null;   // Xml格式输出时需要这个

            bool bAppend = true;

            Debug.Assert(dbpaths != null, "");

            if (dbpaths.Length == 0)
            {
                strError = "尚未指定源库...";
                goto ERROR1;
            }

            if (String.IsNullOrEmpty(strOutputFileName) == false)
            {
                // 探测输出文件是否已经存在
                FileInfo fi = new FileInfo(strOutputFileName);
                bAppend = true;
                if (fi.Exists == true && fi.Length > 0)
                {
                    if (exportType == ExportFileType.BackupFile
                        || exportType == ExportFileType.ISO2709File)
                    {
                        DialogResult result = MessageBox.Show(this,
                            "文件 '" + strOutputFileName + "' 已存在,是否追加?\r\n\r\n--------------------\r\n注:(是)追加  (否)覆盖  (取消)中断处理",
                            "dp2batch",
                            MessageBoxButtons.YesNoCancel,
                            MessageBoxIcon.Question,
                            MessageBoxDefaultButton.Button1);
                        if (result == DialogResult.Yes)
                        {
                            bAppend = true;
                        }
                        if (result == DialogResult.No)
                        {
                            bAppend = false;
                        }
                        if (result == DialogResult.Cancel)
                        {
                            strError = "放弃处理...";
                            goto ERROR1;
                        }
                    }
                    else if (exportType == ExportFileType.XmlFile)
                    {
                        DialogResult result = MessageBox.Show(this,
                            "文件 '" + strOutputFileName + "' 已存在,是否覆盖?\r\n\r\n--------------------\r\n注:(是)覆盖  (否)中断处理",
                            "dp2batch",
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question,
                            MessageBoxDefaultButton.Button2);
                        if (result != DialogResult.Yes)
                        {
                            strError = "放弃处理...";
                            goto ERROR1;
                        }
                    }


                }

                // 打开文件
                if (exportType == ExportFileType.BackupFile
                    || exportType == ExportFileType.ISO2709File)
                {
                    outputfile = File.Open(
                        strOutputFileName,
                        FileMode.OpenOrCreate,	// 原来是Open,后来修改为OpenOrCreate。这样对临时文件被系统管理员手动意外删除(但是xml文件中仍然记载了任务)的情况能够适应。否则会抛出FileNotFoundException异常
                        FileAccess.Write,
                        FileShare.ReadWrite);
                }
                else if (exportType == ExportFileType.XmlFile)
                {
                    outputfile = File.Create(
                        strOutputFileName);

                    writer = new XmlTextWriter(outputfile, Encoding.UTF8);
                    writer.Formatting = Formatting.Indented;
                    writer.Indentation = 4;
                }
            }

            if ((exportType == ExportFileType.BackupFile
                || exportType == ExportFileType.ISO2709File)
                && outputfile != null)
            {
                if (bAppend == true)
                    outputfile.Seek(0, SeekOrigin.End);	// 具有追加的能力
                else
                    outputfile.SetLength(0);
            }

            WriteLog("开始输出");

            try
            {

                // string[] dbpaths = textBox_dbPath.Text.Split(new char[] { ';' });

                for (int f = 0; f < dbpaths.Length; f++)
                {
                    string strOneDbPath = dbpaths[f];

                    ResPath respath = new ResPath(strOneDbPath);

                    channel = this.Channels.GetChannel(respath.Url);

                    string strDbName = respath.Path;
                    if (String.IsNullOrEmpty(strInfo) == false)
                        strInfo += "\r\n";
                    strInfo += "" + strDbName;

                    // 实际处理的首尾号
                    string strRealStartNo = "";
                    string strRealEndNo = "";

                    /*
                    DialogResult result;
                    if (checkBox_export_delete.Checked == true)
                    {
                        result = MessageBox.Show(this,
                            "确实要删除 '" + respath.Path + "' 内指定范围的记录?\r\n\r\n---------\r\n(是)删除 (否)放弃批处理",
                            "dp2batch",
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question,
                            MessageBoxDefaultButton.Button2);
                        if (result != DialogResult.Yes)
                            continue;
                    }
                     * 
                     * */


                    //channel = this.Channels.GetChannel(respath.Url);

                    //string strDbName = respath.Path;

                    // 如果为多库输出
                    if (dbpaths.Length > 0)
                    {
                        // 如果为全选
                        if (this.radioButton_all.Checked == true)
                        {
                            // 恢复为最大范围
                            this.textBox_startNo.Text = "1";
                            this.textBox_endNo.Text = "9999999999";
                        }

                        // 校验起止号
                        if (checkBox_verifyNumber.Checked == true)
                        {
                            nRet = VerifyRange(channel,
                                strDbName,
                                out strError);
                            if (nRet == -1)
                                MessageBox.Show(this, strError);

                            if (nRet == 0)
                            {
                                // 库中无记录
                                AutoCloseMessageBox.Show(this, "数据库 " + strDbName + " 中无记录。");
                                strInfo += "(无记录)";
                                WriteLog("发现数据库 " + strDbName + " 中无记录");
                                continue;
                            }
                        }
                        else
                        {
                            if (this.textBox_startNo.Text == "")
                            {
                                strError = "尚未指定起始号";
                                goto ERROR1;
                            }
                            if (this.textBox_endNo.Text == "")
                            {
                                strError = "尚未指定结束号";
                                goto ERROR1;
                            }
                        }
                    }

                    string strOutputStartNo = "";
                    string strOutputEndNo = "";
                    // 虽然界面不让校验起止号,但是也要校验,为了设置好进度条
                    if (checkBox_verifyNumber.Checked == false)
                    {
                        // 校验起止号
                        // return:
                        //      0   不存在记录
                        //      1   存在记录
                        nRet = VerifyRange(channel,
                            strDbName,
                            this.textBox_startNo.Text,
                            this.textBox_endNo.Text,
                            out strOutputStartNo,
                            out strOutputEndNo,
                            out strError);
                    }

                    //try
                    //{

                    Int64 nStart = 0;
                    Int64 nEnd = 0;
                    Int64 nCur = 0;
                    bool bAsc = true;

                    bAsc = GetDirection(
                        this.textBox_startNo.Text,
                        this.textBox_endNo.Text,
                        out nStart,
                        out nEnd);

                    // 探测到的号码
                    long nOutputEnd = 0;
                    long nOutputStart = 0;
                    if (checkBox_verifyNumber.Checked == false)
                    {
                        GetDirection(
                            strOutputStartNo,
                            strOutputEndNo,
                            out nOutputStart,
                            out nOutputEnd);
                    }

                    // 设置进度条范围
                    if (checkBox_verifyNumber.Checked == true)
                    {

                        Int64 nMax = nEnd - nStart;
                        if (nMax < 0)
                            nMax *= -1;
                        nMax++;

                        /*
                        ProgressRatio = nMax / 10000;
                        if (ProgressRatio < 1.0)
                            ProgressRatio = 1.0;

                        progressBar_main.Minimum = 0;
                        progressBar_main.Maximum = (int)(nMax / ProgressRatio);
                        progressBar_main.Value = 0;
                         * */
                        stop.SetProgressRange(0, nMax);
                    }
                    else
                    {
                        Int64 nMax = nOutputEnd - nOutputStart;
                        if (nMax < 0)
                            nMax *= -1;
                        nMax++;
                        stop.SetProgressRange(0, nMax);
                    }


                    bool bFirst = true;	// 是否为第一次取记录

                    string strID = this.textBox_startNo.Text;

                    stop.OnStop += new StopEventHandler(this.DoStop);
                    stop.Initial("正在导出数据");
                    stop.BeginLoop();

                    EnableControls(false);

                    if (exportType == ExportFileType.XmlFile
                        && writer != null)
                    {
                        writer.WriteStartDocument();
                        writer.WriteStartElement("dprms", "collection", DpNs.dprms);
                        //writer.WriteStartElement("collection");
                        //writer.WriteAttributeString("xmlns:marc",
                        //	"http://www.loc.gov/MARC21/slim");

                    }

                    WriteLog("开始输出数据库 '" + strDbName + "' 内的数据记录");

                    m_nRecordCount = 0;
                    // 循环
                    for (; ; )
                    {
                        Application.DoEvents();	// 出让界面控制权

                        if (stop.State != 0)
                        {
                            WriteLog("打开对话框 '确实要中断当前批处理操作?'");
                            DialogResult result = MessageBox.Show(this,
                                "确实要中断当前批处理操作?",
                                "dp2batch",
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button2);
                            WriteLog("关闭对话框 '确实要中断当前批处理操作?'");
                            if (result == DialogResult.Yes)
                            {
                                strError = "用户中断";
                                goto ERROR1;
                            }
                            else
                            {
                                stop.Continue();
                            }
                        }

                        string strDirectionComment = "";
                        string strStyle = "";
                        if (outputfile != null)
                            strStyle = "data,content,timestamp,outputpath";
                        else
                            strStyle = "timestamp,outputpath";	// 优化

                        if (bFirst == true)
                        {
                            strStyle += "";
                        }
                        else
                        {
                            if (bAsc == true)
                            {
                                strStyle += ",next";
                                strDirectionComment = "的后一条记录";
                            }
                            else
                            {
                                strStyle += ",prev";
                                strDirectionComment = "的前一条记录";
                            }
                        }


                        string strPath = strDbName + "/" + strID;
                        string strXmlBody = "";
                        string strMetaData = "";
                        byte[] baOutputTimeStamp = null;
                        string strOutputPath = "";

                        bool bFoundRecord = false;

                        bool bNeedRetry = true;

                    REDO_GETRES:
                        // 获得资源
                        // return:
                        //		-1	出错。具体出错原因在this.ErrorCode中。this.ErrorInfo中有出错信息。
                        //		0	成功
                        long lRet = channel.GetRes(strPath,
                            strStyle,
                            out strXmlBody,
                            out strMetaData,
                            out baOutputTimeStamp,
                            out strOutputPath,
                            out strError);


                        if (lRet == -1)
                        {
                            if (channel.ErrorCode == ChannelErrorCode.NotFound)
                            {
                                if (bFirst == true)
                                {
                                    if (checkBox_forceLoop.Checked == true)
                                    {
                                        string strText = "记录 " + strID + strDirectionComment + " 不存在。\r\n\r\n按 确认 继续。";
                                        WriteLog("打开对话框 '" + strText.Replace("\r\n", "\\n") + "'");
                                        AutoCloseMessageBox.Show(this, strText);
                                        WriteLog("关闭对话框 '" + strText.Replace("\r\n", "\\n") + "'");

                                        bFirst = false;
                                        goto CONTINUE;
                                    }
                                    else
                                    {
                                        // 如果不要强制循环,此时也不能结束,否则会让用户以为数据库里面根本没有数据
                                        string strText = "您为数据库 " + strDbName + " 指定的首记录 " + strID + strDirectionComment + " 不存在。\r\n\r\n(注:为避免出现此提示,可在操作前勾选“校准首尾ID”)\r\n\r\n按 确认 继续向后找...";
                                        WriteLog("打开对话框 '" + strText.Replace("\r\n", "\\n") + "'");
                                        AutoCloseMessageBox.Show(this, strText);
                                        WriteLog("关闭对话框 '" + strText.Replace("\r\n", "\\n") + "'");

                                        bFirst = false;
                                        goto CONTINUE;
                                    }
                                }
                                else
                                {
                                    Debug.Assert(bFirst == false, "");

                                    if (bFirst == true)
                                    {
                                        strError = "记录 " + strID + strDirectionComment + " 不存在。处理结束。";
                                    }
                                    else
                                    {
                                        if (bAsc == true)
                                            strError = "记录 " + strID + " 是最末一条记录。处理结束。";
                                        else
                                            strError = "记录 " + strID + " 是最前一条记录。处理结束。";
                                    }

                                    if (dbpaths.Length > 1)
                                        break;  // 多库情况,继续其它库循环
                                    else
                                    {
                                        bNeedRetry = false; // 单库情况,也没有必要出现重试对话框

                                        WriteLog("打开对话框 '" + strError.Replace("\r\n", "\\n") + "'");
                                        MessageBox.Show(this, strError);
                                        WriteLog("关闭对话框 '" + strError.Replace("\r\n", "\\n") + "'");
                                        break;
                                    }
                                }

                            }
                            else if (channel.ErrorCode == ChannelErrorCode.EmptyRecord)
                            {
                                bFirst = false;
                                bFoundRecord = false;
                                // 把id解析出来
                                strID = ResPath.GetRecordId(strOutputPath);
                                goto CONTINUE;

                            }

                            // 允许重试
                            if (bNeedRetry == true)
                            {
                                string strText = "获取记录 '" + strPath + "' (style='" + strStyle + "')时出现错误: " + strError + "\r\n\r\n重试,还是中断当前批处理操作?\r\n(Retry 重试;Cancel 中断批处理)";
                                WriteLog("打开对话框 '" + strText.Replace("\r\n", "\\n") + "'");
                                DialogResult redo_result = MessageBox.Show(this,
                                    strText,
                                    "dp2batch",
                                    MessageBoxButtons.RetryCancel,
                                    MessageBoxIcon.Question,
                                    MessageBoxDefaultButton.Button1);
                                WriteLog("关闭对话框 '" + strText.Replace("\r\n", "\\n") + "'");
                                if (redo_result == DialogResult.Cancel)
                                    goto ERROR1;
                                goto
                                    REDO_GETRES;
                            }
                            else
                            {
                                goto ERROR1;
                            }
                        }

                        // 2008/11/9 
                        if (String.IsNullOrEmpty(strXmlBody) == true)
                        {
                            bFirst = false;
                            bFoundRecord = false;
                            // 把id解析出来
                            strID = ResPath.GetRecordId(strOutputPath);
                            goto CONTINUE;
                        }

                        bFirst = false;

                        bFoundRecord = true;

                        // 把id解析出来
                        strID = ResPath.GetRecordId(strOutputPath);
                        stop.SetMessage("已导出记录 " + strOutputPath + "  " + m_nRecordCount.ToString());

                        if (String.IsNullOrEmpty(strRealStartNo) == true)
                        {
                            strRealStartNo = strID;
                        }

                        strRealEndNo = strID;

                    CONTINUE:

                        // 是否超过循环范围
                        try
                        {
                            nCur = Convert.ToInt64(strID);
                        }
                        catch
                        {
                            // ???
                            nCur = 0;
                        }

                        if (checkBox_verifyNumber.Checked == false)
                        {
                            // 如果当前记录号码突破预计的头部和尾部
                            if (nCur > nOutputEnd
                                || nCur < nOutputStart)
                            {
                                if (nCur > nOutputEnd)
                                    nOutputEnd = nCur;

                                if (nCur < nOutputStart)
                                    nOutputStart = nCur;

                                // 重新计算和设置进度条
                                long nMax = nOutputEnd - nOutputStart;
                                if (nMax < 0)
                                    nMax *= -1;
                                nMax++;

                                stop.SetProgressRange(0, nMax);
                            }
                        }

                        if (bAsc == true && nCur > nEnd)
                            break;
                        if (bAsc == false && nCur < nEnd)
                            break;

                        string strMarc = "";

                        // 将Xml转换为MARC
                        if (exportType == ExportFileType.ISO2709File
                            && bFoundRecord == true)    // 2008/11/13 
                        {
                            nRet = GetMarc(strXmlBody,
                                out strMarc,
                                out strError);
                            if (nRet == -1)
                            {
                                strError = "记录 " + strOutputPath + " 在将XML格式转换为MARC时出错: " + strError;
                                goto ERROR1;
                            }
                        }

                        if (this.MarcFilter != null)
                        {
                            // 触发filter中的Record相关动作
                            // TODO: 有可能strMarc为空哟,需要测试一下
                            nRet = MarcFilter.DoRecord(
                                null,
                                strMarc,
                                m_nRecordCount,
                                out strError);
                            if (nRet == -1)
                                goto ERROR1;
                        }

                        // 触发Script的Outputing()代码
                        if (bFoundRecord == true && this.AssemblyMain != null)
                        {
                            // 这些变量要先初始化,因为filter代码可能用到这些Batch成员.
                            batchObj.XmlRecord = strXmlBody;

                            batchObj.MarcSyntax = this.CurMarcSyntax;

                            batchObj.MarcRecord = strMarc;	// MARC记录体
                            batchObj.MarcRecordChanged = false;	// 为本轮Script运行准备初始状态

                            batchObj.SearchPanel.ServerUrl = channel.Url;
                            batchObj.ServerUrl = channel.Url;
                            batchObj.RecPath = strOutputPath;	// 记录路径
                            batchObj.RecIndex = m_nRecordCount;	// 当前记录在一批中的序号
                            batchObj.TimeStamp = baOutputTimeStamp;


                            BatchEventArgs args = new BatchEventArgs();

                            batchObj.Outputing(this, args);
                            /*
                            if (args.Continue == ContinueType.SkipMiddle)
                                goto CONTINUEDBS;
                            if (args.Continue == ContinueType.SkipBeginMiddle)
                                goto CONTINUEDBS;
                            */
                            if (args.Continue == ContinueType.SkipAll)
                                goto CONTINUEDBS;

                            // 观察用于输出的MARC记录是否被改变
                            if (batchObj.MarcRecordChanged == true)
                                strMarc = batchObj.MarcRecord;

                            // 观察XML记录是否被改变
                            if (batchObj.XmlRecordChanged == true)
                                strXmlBody = batchObj.XmlRecord;

                        }


                        if (bFoundRecord == true
                            && outputfile != null)
                        {
                            if (exportType == ExportFileType.BackupFile)
                            {
                                // 写磁盘
                                nRet = WriteRecordToBackupFile(
                                    outputfile,
                                    strDbName,
                                    strID,
                                    strMetaData,
                                    strXmlBody,
                                    baOutputTimeStamp,
                                    out strError);
                                if (nRet == -1)
                                {
                                    // 询问是否继续
                                    goto ERROR1;
                                }
                            }
                            else if (exportType == ExportFileType.ISO2709File)
                            {
                                // 写磁盘
                                nRet = WriteRecordToISO2709File(
                                    outputfile,
                                    strDbName,
                                    strID,
                                    strMarc,
                                    baOutputTimeStamp,
                                    targetEncoding,
                                    this.OutputCrLf,
                                    this.AddG01,
                                    this.Remove998,
                                    out strError);
                                if (nRet == -1)
                                {
                                    // 询问是否继续
                                    goto ERROR1;
                                }
                            }
                            else if (exportType == ExportFileType.XmlFile)
                            {
                                XmlDocument dom = new XmlDocument();

                                try
                                {
                                    dom.LoadXml(strXmlBody);

                                    ResPath respathtemp = new ResPath();
                                    respathtemp.Url = channel.Url;
                                    respathtemp.Path = strOutputPath;


                                    // DomUtil.SetAttr(dom.DocumentElement, "xmlns:dprms", DpNs.dprms);
                                    // 给根元素设置几个参数
                                    DomUtil.SetAttr(dom.DocumentElement, "path", DpNs.dprms, respathtemp.FullPath);
                                    DomUtil.SetAttr(dom.DocumentElement, "timestamp", DpNs.dprms, ByteArray.GetHexTimeStampString(baOutputTimeStamp));

                                    // DomUtil.SetAttr(dom.DocumentElement, "xmlns:marc", null);
                                    dom.DocumentElement.WriteTo(writer);
                                }
                                catch (Exception ex)
                                {
                                    strError = ExceptionUtil.GetAutoText(ex);
                                    // 询问是否继续
                                    goto ERROR1;
                                }

                            }
                        }

                        // 删除
                        if (checkBox_export_delete.Checked == true)
                        {

                            byte[] baOutputTimeStamp1 = null;
                            strPath = strOutputPath;	// 得到实际的路径
                            lRet = channel.DoDeleteRes(
                                strPath,
                                baOutputTimeStamp,
                                strDeleteStyle,
                                out baOutputTimeStamp1,
                                out strError);
                            if (lRet == -1)
                            {
                                // 询问是否继续
                                goto ERROR1;
                            }
                            stop.SetMessage("已删除记录" + strPath + "  " + m_nRecordCount.ToString());
                        }

                        if (bFoundRecord == true)
                            m_nRecordCount++;


                        if (bAsc == true)
                        {
                            //progressBar_main.Value = (int)((nCur - nStart + 1) / ProgressRatio);
                            stop.SetProgressValue(nCur - nStart + 1);
                        }
                        else
                        {
                            // ?
                            // progressBar_main.Value = (int)((nStart - nCur + 1) / ProgressRatio);
                            stop.SetProgressValue(nStart - nCur + 1);
                        }


                        // 对已经作过的进行判断
                        if (bAsc == true && nCur >= nEnd)
                            break;
                        if (bAsc == false && nCur <= nEnd)
                            break;


                    } // end of for one database

                    stop.EndLoop();
                    stop.OnStop -= new StopEventHandler(this.DoStop);
                    stop.Initial("");

                    EnableControls(true);

                //}

            CONTINUEDBS:
                    strInfo += " : " + m_nRecordCount.ToString() + "条 (ID " + strRealStartNo + "-" + strRealEndNo + ")";

                }   // end of dbpaths loop


            }   // end of try
            finally
            {
                if (writer != null)
                {
                    writer.WriteEndElement();
                    writer.WriteEndDocument();
                    writer.Close();
                    writer = null;
                }

                if (outputfile != null)
                {
                    outputfile.Close();
                    outputfile = null;
                }
            }

            // END1:
            channel = null;

            if (checkBox_export_delete.Checked == true)
                strError = "数据导出和删除完成。\r\n---\r\n" + strInfo;
            else
                strError = "数据导出完成。\r\n---\r\n" + strInfo;

            WriteLog("结束输出");

            return 0;
        ERROR1:
            stop.EndLoop();
            stop.OnStop -= new StopEventHandler(this.DoStop);
            stop.Initial("");

            EnableControls(true);
            channel = null;
            return -1;
        }
Пример #41
0
        // This function needs so many variables, we might as well just pass the whole CommandArgs object
        private void ExportInstrumentFile(ExportFileType type, CommandArgs args)
        {
            if (string.IsNullOrEmpty(args.ExportPath))
            {
                _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_);
                return;
            }

            if (Equals(type, ExportFileType.Method))
            {
                if (string.IsNullOrEmpty(args.TemplateFile))
                {
                    _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Error__A_template_file_is_required_to_export_a_method_);
                    return;
                }
                if (Equals(args.MethodInstrumentType, ExportInstrumentType.AGILENT6400)
                        ? !Directory.Exists(args.TemplateFile)
                        : !File.Exists(args.TemplateFile))
                {
                    _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Error__The_template_file__0__does_not_exist_, args.TemplateFile);
                    return;
                }
                if (Equals(args.MethodInstrumentType, ExportInstrumentType.AGILENT6400) &&
                    !AgilentMethodExporter.IsAgilentMethodPath(args.TemplateFile))
                {
                    _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Error__The_folder__0__does_not_appear_to_contain_an_Agilent_QQQ_method_template___The_folder_is_expected_to_have_a__m_extension__and_contain_the_file_qqqacqmethod_xsd_, args.TemplateFile);
                    return;
                }
            }

            if (!args.ExportStrategySet)
            {
                _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Warning__No_export_strategy_specified__from__single____protein__or__buckets____Defaulting_to__single__);
                args.ExportStrategy = ExportStrategy.Single;
            }

            if (args.AddEnergyRamp && !Equals(args.TransListInstrumentType, ExportInstrumentType.THERMO))
            {
                _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Warning__The_add_energy_ramp_parameter_is_only_applicable_for_Thermo_transition_lists__This_parameter_will_be_ignored_);
            }

            string instrument = Equals(type, ExportFileType.List)
                                    ? args.TransListInstrumentType
                                    : args.MethodInstrumentType;
            if (!CheckInstrument(instrument, _doc))
            {
                _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Warning__The_vendor__0__does_not_match_the_vendor_in_either_the_CE_or_DP_prediction_setting___Continuing_exporting_a_transition_list_anyway___, instrument);
            }

            int maxInstrumentTrans = _doc.Settings.TransitionSettings.Instrument.MaxTransitions ??
                                     TransitionInstrument.MAX_TRANSITION_MAX;

            if ((args.MaxTransitionsPerInjection < AbstractMassListExporter.MAX_TRANS_PER_INJ_MIN ||
                 args.MaxTransitionsPerInjection > maxInstrumentTrans) &&
                (Equals(args.ExportStrategy, ExportStrategy.Buckets) ||
                 Equals(args.ExportStrategy, ExportStrategy.Protein)))
            {
                _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Warning__Max_transitions_per_injection_must_be_set_to_some_value_between__0__and__1__for_export_strategies__protein__and__buckets__and_for_scheduled_methods__You_specified__3___Defaulting_to__2__, AbstractMassListExporter.MAX_TRANS_PER_INJ_MIN, maxInstrumentTrans,AbstractMassListExporter.MAX_TRANS_PER_INJ_DEFAULT, args.MaxTransitionsPerInjection);

                args.MaxTransitionsPerInjection = AbstractMassListExporter.MAX_TRANS_PER_INJ_DEFAULT;
            }

            /*
             * Consider: for transition lists, AB Sciex and Agilent require the
             * dwell time parameter, and Waters requires the run length parameter.
             * These are guaranteed to be set and within-bounds at this point, but
             * not necessarily by the user because there is a default.
             *
             * Should we warn the user that they didn't set these parameters?
             * Should we warn the user if they set parameters that will not be used
             * with the given instrument?
             *
             * This would require a pretty big matrix of conditionals, and there is
             * documentation after all...
             */

            if(Equals(type, ExportFileType.Method))
            {
                string extension = Path.GetExtension(args.TemplateFile);
                if(!Equals(ExportInstrumentType.MethodExtension(args.MethodInstrumentType),extension))
                {
                    _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Error__The_template_extension__0__does_not_match_the_expected_extension_for_the_instrument__1___No_method_will_be_exported_, extension,args.MethodInstrumentType);
                    return;
                }
            }

            var prediction = _doc.Settings.TransitionSettings.Prediction;
            double optimizeStepSize = 0;
            int optimizeStepCount = 0;

            if (Equals(args.ExportOptimizeType, ExportOptimize.CE))
            {
                var regression = prediction.CollisionEnergy;
                optimizeStepSize = regression.StepSize;
                optimizeStepCount = regression.StepCount;
            }
            else if (Equals(args.ExportOptimizeType, ExportOptimize.DP))
            {
                var regression = prediction.DeclusteringPotential;
                optimizeStepSize = regression.StepSize;
                optimizeStepCount = regression.StepCount;
            }

            //Now is a good time to make this conversion
            _exportProperties = args.ExportCommandProperties;
            _exportProperties.OptimizeStepSize = optimizeStepSize;
            _exportProperties.OptimizeStepCount = optimizeStepCount;

            _exportProperties.FullScans = _doc.Settings.TransitionSettings.FullScan.IsEnabledMsMs;

            _exportProperties.Ms1Scan = _doc.Settings.TransitionSettings.FullScan.IsEnabledMs &&
                            _doc.Settings.TransitionSettings.FullScan.IsEnabledMsMs;

            _exportProperties.InclusionList = _doc.Settings.TransitionSettings.FullScan.IsEnabledMs &&
                                              !_doc.Settings.TransitionSettings.FullScan.IsEnabledMsMs;

            _exportProperties.MsAnalyzer =
                TransitionFullScan.MassAnalyzerToString(
                    _doc.Settings.TransitionSettings.FullScan.PrecursorMassAnalyzer);
            _exportProperties.MsMsAnalyzer =
                TransitionFullScan.MassAnalyzerToString(
                    _doc.Settings.TransitionSettings.FullScan.ProductMassAnalyzer);

            _exportProperties.MsAnalyzer =
                TransitionFullScan.MassAnalyzerToString(
                    _doc.Settings.TransitionSettings.FullScan.PrecursorMassAnalyzer);
            _exportProperties.MsMsAnalyzer =
                TransitionFullScan.MassAnalyzerToString(
                    _doc.Settings.TransitionSettings.FullScan.ProductMassAnalyzer);

            if(!Equals(args.ExportMethodType, ExportMethodType.Standard))
            {
                if (Equals(args.ExportMethodType, ExportMethodType.Triggered))
                {
                    bool canTrigger = true;
                    if (!ExportInstrumentType.CanTriggerInstrumentType(instrument))
                    {
                        canTrigger = false;
                        if (Equals(args.MethodInstrumentType, ExportInstrumentType.THERMO_TSQ))
                        {
                            _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Error__the__0__instrument_lacks_support_for_direct_method_export_for_triggered_acquisition_, instrument);
                            _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_You_must_export_a__0__transition_list_and_manually_import_it_into_a_method_file_using_vendor_software_, ExportInstrumentType.THERMO);
                        }
                        else
                        {
                            _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Error__the_instrument_type__0__does_not_support_triggered_acquisition_, instrument);
                        }
                    }
                    else if (!_doc.Settings.HasResults && !_doc.Settings.HasLibraries)
                    {
                        canTrigger = false;
                        _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Error__triggered_acquistion_requires_a_spectral_library_or_imported_results_in_order_to_rank_transitions_);
                    }
                    else if (!ExportInstrumentType.CanTrigger(instrument, _doc, _exportProperties.SchedulingReplicateNum))
                    {
                        canTrigger = false;
                        _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Error__The_current_document_contains_peptides_without_enough_information_to_rank_transitions_for_triggered_acquisition_);
                    }
                    if (!canTrigger)
                    {
                        _out.WriteLine(Equals(type, ExportFileType.List)
                                               ? Resources.CommandLine_ExportInstrumentFile_No_list_will_be_exported_
                                               : Resources.CommandLine_ExportInstrumentFile_No_method_will_be_exported_);
                        return;
                    }
                    _exportProperties.PrimaryTransitionCount = args.PrimaryTransitionCount;
                }

                if (!ExportInstrumentType.CanSchedule(instrument, _doc))
                {
                    var predictionPep = _doc.Settings.PeptideSettings.Prediction;
                    if (!ExportInstrumentType.CanScheduleInstrumentType(instrument, _doc))
                    {
                        _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Error__the_specified_instrument__0__is_not_compatible_with_scheduled_methods_,
                                       instrument);
                    }
                    else if (predictionPep.RetentionTime == null)
                    {
                        if (predictionPep.UseMeasuredRTs)
                        {
                            _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Error__to_export_a_scheduled_method__you_must_first_choose_a_retention_time_predictor_in_Peptide_Settings___Prediction__or_import_results_for_all_peptides_in_the_document_);
                        }
                        else
                        {
                            _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Error__to_export_a_scheduled_method__you_must_first_choose_a_retention_time_predictor_in_Peptide_Settings___Prediction_);
                        }
                    }
                    else if (!predictionPep.RetentionTime.Calculator.IsUsable)
                    {
                        _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Error__the_retention_time_prediction_calculator_is_unable_to_score___Check_the_calculator_settings_);
                    }
                    else if (!predictionPep.RetentionTime.IsUsable)
                    {
                        _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Error__the_retention_time_predictor_is_unable_to_auto_calculate_a_regression___Check_to_make_sure_the_document_contains_times_for_all_of_the_required_standard_peptides_);
                    }
                    else
                    {
                        _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Error__To_export_a_scheduled_method__you_must_first_import_results_for_all_peptides_in_the_document_);
                    }
                    _out.WriteLine(Equals(type, ExportFileType.List)
                                           ? Resources.CommandLine_ExportInstrumentFile_No_list_will_be_exported_
                                           : Resources.CommandLine_ExportInstrumentFile_No_method_will_be_exported_);
                    return;
                }

                if (Equals(args.ExportSchedulingAlgorithm, ExportSchedulingAlgorithm.Average))
                {
                    _exportProperties.SchedulingReplicateNum = null;
                }
                else
                {
                    if(args.SchedulingReplicate.Equals("LAST")) // Not L10N
                    {
                        _exportProperties.SchedulingReplicateNum = _doc.Settings.MeasuredResults.Chromatograms.Count - 1;
                    }
                    else
                    {
                        //check whether the given replicate exists
                        if (!_doc.Settings.MeasuredResults.ContainsChromatogram(args.SchedulingReplicate))
                        {
                            _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Error__the_specified_replicate__0__does_not_exist_in_the_document_,
                                           args.SchedulingReplicate);
                            _out.WriteLine(Equals(type, ExportFileType.List)
                                                   ? Resources.CommandLine_ExportInstrumentFile_No_list_will_be_exported_
                                                   : Resources.CommandLine_ExportInstrumentFile_No_method_will_be_exported_);
                            return;
                        }

                        _exportProperties.SchedulingReplicateNum =
                            _doc.Settings.MeasuredResults.Chromatograms.IndexOf(
                                rep => rep.Name.Equals(args.SchedulingReplicate));
                    }
                }
            }

            try
            {
                _exportProperties.ExportFile(instrument, type, args.ExportPath, _doc, args.TemplateFile);
            }
            catch (IOException x)
            {
                _out.WriteLine(Resources.CommandLine_ExportInstrumentFile_Error__The_file__0__could_not_be_saved___Check_that_the_specified_file_directory_exists_and_is_writeable_, args.ExportPath);
                _out.WriteLine(x.Message);
                return;
            }

            _out.WriteLine(Equals(type, ExportFileType.List)
                               ? Resources.CommandLine_ExportInstrumentFile_List__0__exported_successfully_
                               : Resources.CommandLine_ExportInstrumentFile_Method__0__exported_successfully_,
                           Path.GetFileName(args.ExportPath));
        }
 /// <summary>
 /// 导出数据。
 /// </summary>
 /// <param name="type"></param>
 protected virtual void ExportCommand(ExportFileType type)
 {
     lock (this)
     {
         ExportData export = new ExportData(this);
         export.ExportFileType = type;
         export.DownloadFileName = this.DownloadFileName;
         export.Download();
     }
 }
Пример #43
0
        // 准备输入
        // return:
        //      -1  出错
        //      0   正常
        //      1   用户放弃
        public int Begin(
            IWin32Window owner,
            ApplicationInfo appInfo,
            string strInputFileName,
            out string strError)
        {
            strError = "";

            this.m_owner = owner;
            this.AppInfo = appInfo;
            this.Index = -1;

            if (string.IsNullOrEmpty(strInputFileName) == true)
            {
                strError = "输入文件名不能为空";
                return -1;
            }

            if (this.Stream != null)
            {
                this.Stream.Close();
                this.Stream = null;
                this.FileName = "";
            }

            string strExt = Path.GetExtension(strInputFileName);

            if (string.Compare(strExt, ".xml", true) == 0)
                this.FileType = ExportFileType.XmlFile;
            else if (string.Compare(strExt, ".dp2bak", true) == 0)
                this.FileType = ExportFileType.BackupFile;
            else if (string.Compare(strExt, ".iso", true) == 0
                || string.Compare(strExt, ".marc", true) == 0
                || string.Compare(strExt, ".mrc", true) == 0)
                this.FileType = ExportFileType.ISO2709File;
            else
            {
                strError = "无法根据文件扩展名 '" + strExt + "' 判断输入文件的格式";
                return -1;
            }

            this.FileName = strInputFileName;


            if (this.FileType == ExportFileType.XmlFile)
            {
                this.Stream = File.Open(strInputFileName,
    FileMode.Open,
    FileAccess.Read);

                this._reader = new XmlTextReader(Stream);

                bool bRet = false;

                // 移动到根元素
                while (true)
                {
                    bRet = _reader.Read();
                    if (bRet == false)
                    {
                        strError = "没有根元素";
                        return -1;
                    }
                    if (_reader.NodeType == XmlNodeType.Element)
                        break;
                }

                // 移动到其下级第一个element
                while (true)
                {
                    bRet = _reader.Read();
                    if (bRet == false)
                    {
                        strError = "没有第一个记录元素";
                        return -1;
                    }
                    if (_reader.NodeType == XmlNodeType.Element)
                        break;
                }
            }
            else if (this.FileType == ExportFileType.BackupFile)
            {
                this.Stream = File.Open(strInputFileName,
    FileMode.Open,
    FileAccess.Read);
            }
            // ISO2709文件需要预先准备条件
            else if (this.FileType == ExportFileType.ISO2709File)
            {
                // 询问encoding和marcsyntax
                OpenMarcFileDlg dlg = new OpenMarcFileDlg();
                Font font = GuiUtil.GetDefaultFont();
                if (font != null)
                    dlg.Font = font;

                dlg.Text = "请指定要导入的 ISO2709 文件属性";
                dlg.FileName = strInputFileName;

                if (this.AppInfo != null)
                    this.AppInfo.LinkFormState(dlg, "restree_OpenMarcFileDlg_input_state");
                dlg.ShowDialog(this.m_owner);
                if (this.AppInfo != null)
                    this.AppInfo.UnlinkFormState(dlg);

                if (dlg.DialogResult != DialogResult.OK)
                {
                    strError = "用户取消";
                    return 1;
                }

                this.FileName = dlg.FileName;

                this.Stream = File.Open(this.FileName,
    FileMode.Open,
    FileAccess.Read);

                this.MarcSyntax = dlg.MarcSyntax;
                this.Encoding = dlg.Encoding;
            }

            return 0;
        }
Пример #44
0
        private static ExportFormat GetFormat(ExportFileType exportFileType)
        {
            var export = ExportFormat.Html;
 
            switch (exportFileType)
            {
                case ExportFileType.Excel:
                case ExportFileType.Pdf:
                case ExportFileType.Word:
                    export = ExportFormat.Html;
                    break;

                case ExportFileType.ExcelML:
                    export = ExportFormat.ExcelML;
                    break;

                case ExportFileType.Csv:
                    export = ExportFormat.Csv;
                    break;
            }

            return export;
        }
Пример #45
0
 private static string GetExtension(ExportFileType exportFileType)
 {
     var attr = typeof(ExportFileType).GetField(exportFileType.ToString()).GetCustomAttributes(false).First();
     return ((ExportFileAttribute)attr).Extension;
 }
Пример #46
0
        public ExportMethodDlg(SrmDocument document, ExportFileType fileType)
        {
            InitializeComponent();

            _exportProperties = new ExportDlgProperties(this);

            _document = document;
            _fileType = fileType;

            string[] listTypes;
            if (_fileType == ExportFileType.Method)
                listTypes = ExportInstrumentType.METHOD_TYPES;
            else
            {
                if (_fileType == ExportFileType.List)
                {
                    Text = Resources.ExportMethodDlg_ExportMethodDlg_Export_Transition_List;
                    listTypes = ExportInstrumentType.TRANSITION_LIST_TYPES;
                }
                else
                {
                    Text = Resources.ExportMethodDlg_ExportMethodDlg_Export_Isolation_List;
                    listTypes = ExportInstrumentType.ISOLATION_LIST_TYPES;
                    _exportProperties.MultiplexIsolationListCalculationTime = 20;   // Default 20 seconds to search for good multiplexed window ordering.
                }

                btnBrowseTemplate.Visible = false;
                labelTemplateFile.Visible = false;
                textTemplateFile.Visible = false;
                Height -= textTemplateFile.Bottom - comboTargetType.Bottom;
            }

            comboInstrument.Items.Clear();
            foreach (string typeName in listTypes)
                comboInstrument.Items.Add(typeName);

            // Init dialog values from settings.
            ExportStrategy = Helpers.ParseEnum(Settings.Default.ExportMethodStrategy, ExportStrategy.Single);

            IgnoreProteins = Settings.Default.ExportIgnoreProteins;

            // Start with method type as Standard until after instrument type is set
            comboTargetType.Items.Add(ExportMethodType.Standard.GetLocalizedString());
            comboTargetType.Items.Add(ExportMethodType.Scheduled.GetLocalizedString());
            comboTargetType.Items.Add(ExportMethodType.Triggered.GetLocalizedString());
            MethodType = ExportMethodType.Standard;

            // Add optimizable regressions
            comboOptimizing.Items.Add(ExportOptimize.NONE);
            comboOptimizing.Items.Add(ExportOptimize.CE);
            if (document.Settings.TransitionSettings.Prediction.DeclusteringPotential != null)
                comboOptimizing.Items.Add(ExportOptimize.DP);
            comboOptimizing.SelectedIndex = 0;

            // Set instrument type based on CE regression name for the document.
            string instrumentTypeName = document.Settings.TransitionSettings.Prediction.CollisionEnergy.Name;
            if (instrumentTypeName != null)
            {
                // Look for the first instrument type with the same prefix as the CE name
                string instrumentTypePrefix = instrumentTypeName.Split(' ')[0];
                // We still have some CE regressions that begin with ABI, while all instruments
                // have been changed to AB SCIEX
                if (Equals("ABI", instrumentTypePrefix)) // Not L10N
                    instrumentTypePrefix = "AB"; // Not L10N
                int i = -1;
                if (document.Settings.TransitionSettings.FullScan.IsEnabled)
                {
                    i = listTypes.IndexOf(typeName => typeName.StartsWith(instrumentTypePrefix) &&
                        ExportInstrumentType.IsFullScanInstrumentType(typeName));
                }
                if (i == -1)
                {
                    i = listTypes.IndexOf(typeName => typeName.StartsWith(instrumentTypePrefix));
                }
                if (i != -1)
                    InstrumentType = listTypes[i];
            }
            // If nothing found based on CE regression name, just use the first instrument in the list
            if (InstrumentType == null)
                InstrumentType = listTypes[0];

            // Reset method type based on what was used last and what the chosen instrument is capable of
            ExportMethodType mType = Helpers.ParseEnum(Settings.Default.ExportMethodType, ExportMethodType.Standard);
            if (mType == ExportMethodType.Triggered && !CanTrigger)
            {
                mType = ExportMethodType.Scheduled;
            }
            if (mType != ExportMethodType.Standard && !CanSchedule)
            {
                mType = ExportMethodType.Standard;
            }
            MethodType = mType;

            DwellTime = Settings.Default.ExportMethodDwellTime;
            RunLength = Settings.Default.ExportMethodRunLength;

            UpdateMaxTransitions();

            cbEnergyRamp.Checked = Settings.Default.ExportThermoEnergyRamp;
            cbTriggerRefColumns.Checked = Settings.Default.ExportThermoTriggerRef;
            cbExportMultiQuant.Checked = Settings.Default.ExportMultiQuant;
            cbExportEdcMass.Checked = Settings.Default.ExportEdcMass;
            textPrimaryCount.Text = Settings.Default.PrimaryTransitionCount.ToString(LocalizationHelper.CurrentCulture);
            // Reposition from design layout
            panelThermoColumns.Top = labelDwellTime.Top;
            panelThermoRt.Top = panelThermoColumns.Top - (int)(panelThermoRt.Height*0.8);
            panelAbSciexTOF.Top = textDwellTime.Top + (textDwellTime.Height - panelAbSciexTOF.Height)/2;
            panelTriggered.Top = textDwellTime.Top + (textDwellTime.Height - panelTriggered.Height)/2;
            panelSciexTune.Top = labelOptimizing.Top;
            panelWaters.Top = labelDwellTime.Top - panelWaters.Height;

            foreach (string tuneType in ExportOptimize.CompensationVoltageTuneTypes)
                comboTuning.Items.Add(tuneType);
            comboTuning.SelectedIndex = 0;

            // Further repositioning - for design layout convenience we have many things to the right of the OK button.
            // Find all such items and shift them to the left, then resize the form itself.
            foreach (var controlObj in Controls)
            {
                var control = controlObj as Control;
                if ((control != null) && (control.Left > btnOk.Right))
                {
                    control.Left = cbIgnoreProteins.Left; // Align with a known-good control
                }
            }
            SetBounds(Left, Top, btnOk.Right + 2 * label4.Left, Height);
        }
Пример #47
0
        public byte[] Export <T>(IEnumerable <T> source, Dictionary <string, string> titleMap, ExportFileType type, bool isZip)
        {
            using (var package = new ExcelPackage())
            {
                var worksheet = package.Workbook.Worksheets.Add("sheet1");
                if (titleMap != null)
                {
                    titleMap.Keys.Each((key, i) =>
                    {
                        worksheet.Cells[1, i + 1].Value = titleMap[key];

                        worksheet.Cells[1, i + 1].Style.Border.BorderAround(ExcelBorderStyle.Thin, Color.Gray);
                        worksheet.Cells[1, i + 1].Style.Fill.PatternType = ExcelFillStyle.Solid;
                        worksheet.Cells[1, i + 1].Style.Fill.PatternColor.SetColor(Color.Gray);
                        worksheet.Cells[1, i + 1].Style.Fill.BackgroundColor.SetColor(Color.LightYellow);


                        for (int j = 0; j < source.Count(); j++)
                        {
                            try
                            {
                                var sour = source.Skip(j).Take(1).First();
                                worksheet.Cells[2 + j, i + 1].Value = GetValue(sour, key);
                            }
                            catch
                            {
                                throw new Exception("对象找不到名称为{0}的属性".FormatWith(key));
                            }
                        }
                    });
                }

                worksheet.Cells.AutoFitColumns();
                return(package.GetAsByteArray());
            }
        }
Пример #48
0
 public byte[] ExportBig(IDataReader reader, ExportFileType type)
 {
     return(ExportBig(reader, type, false));
 }
Пример #49
0
 public bool CreateBatchDetailExportFile(int marketID, int batchDetailID, int xbrlDocumentID, string language, ExportFileType fileFormatType, bool replaceExistingFile, out string error)
 {
     return FilingDispatcherManager.TheMgr.CreateBatchDetailExportFile(marketID, batchDetailID, xbrlDocumentID, language, fileFormatType,replaceExistingFile, out error);
 }
Пример #50
0
 public void Export(int activityId, string fileName, ExportFileType fileType)
 {
     Export(activityId, fileName, fileType, true, false);
 }
Пример #51
0
        public bool CreateBatchDetailExportFile(int batchDetailID, int xbrlDocumentID, string language, ExportFileType fileFormatType, bool replaceExistingFile)
        {
            bool            retVal            = false;
            IFilingDatabase filingProcessorDB = this.filingProcessor as IFilingDatabase;

            if (filingProcessorDB != null)
            {
                filingProcessorDB.CreateBatchDetailExportFile(batchDetailID, xbrlDocumentID, language, fileFormatType, replaceExistingFile);
                retVal = true;
            }
            else
            {
                WriteLogEntry("Create Batch Detail Export File Failed! Filing Processor does not implement IFilingDatabase", EventLogEntryType.Error);
                retVal = false;
            }
            return(retVal);
        }