public override void Prepare(ImportOption Option)
 {
     mOption        = Option;
     _InsertRecList = new List <SHUpdateRecordRecord>();
     _UpdateRecList = new List <SHUpdateRecordRecord>();
     _DeleteRecList = new List <SHUpdateRecordRecord>();
 }
 public override void Prepare(ImportOption Option)
 {
     mOption      = Option;
     _UDTTransfer = new DAO.UDTTransfer();
     //_StudRecList = Student.SelectAll();
     _ImportStudIDList = new List <string>();
 }
Esempio n. 3
0
 public override void Prepare(ImportOption Option)
 {
     _Option        = Option;
     _InsertRecList = new List <DAO.ResultScoreRecord>();
     _UpdateRecList = new List <DAO.ResultScoreRecord>();
     _LogHelper     = new LogHelper();
 }
Esempio n. 4
0
        /// <summary>
        /// Creates the appropriate HSSFWorkbook / XSSFWorkbook from
        /// the given InputStream. The Stream is wraped inside a PushbackInputStream.
        /// </summary>
        /// <param name="inputStream">Input Stream of .xls or .xlsx file</param>
        /// <param name="importOption">Customize the elements that are processed on the next import</param>
        /// <returns>IWorkbook depending on the input HSSFWorkbook or XSSFWorkbook is returned.</returns>
        public static IWorkbook Create(Stream inputStream, ImportOption importOption)
        {
            SetImportOption(importOption);
            IWorkbook workbook = Create(inputStream, true);

            return(workbook);
        }
Esempio n. 5
0
 public override void Prepare(ImportOption Option)
 {
     // 畫面初始化後需要載入
     _Option        = Option;
     _InsertRecList = new List <SiblingRecord>();
     _UpdateRecList = new List <SiblingRecord>();
 }
        public override void Prepare(ImportOption Option)
        {
            _Option = Option;

            _InsertRecList = new List <DAO.StudentFitnessRecord>();
            _UpdateRecList = new List <DAO.StudentFitnessRecord>();
        }
 public override void Prepare(ImportOption Option)
 {
     _Option = Option;
     _InsertRecList = new List<DAO.ResultScoreRecord>();
     _UpdateRecList = new List<DAO.ResultScoreRecord>();
     _LogHelper = new LogHelper();
 }
Esempio n. 8
0
            public ImportEventArgs(ConfigAndGestures confAndGest, ImportOption gestImpOpt, ImportOption confImpOpt)
            {
                Success = true;

                ConfigAndGestures = confAndGest;
                GesturesImportOption = gestImpOpt;
                ConfigImportOption = confImpOpt;
            }
        public override void Prepare(ImportOption Option)
        {
            
            _Option = Option;

            _InsertRecList = new List<DAO.StudentFitnessRecord>();
            _UpdateRecList = new List<DAO.StudentFitnessRecord>();
        }
Esempio n. 10
0
            public ImportEventArgs(ConfigAndGestures confAndGest, ImportOption gestImpOpt, ImportOption confImpOpt)
            {
                Success = true;

                ConfigAndGestures    = confAndGest;
                GesturesImportOption = gestImpOpt;
                ConfigImportOption   = confImpOpt;
            }
Esempio n. 11
0
        public override void Prepare(ImportOption Option)
        {
            mOption = Option;
            //取得社團基本資料
            Importbot.ClubDic = Importbot.GetCLUBDic();

            Importbot.CadreIDDic = Importbot.GetCadreDic();
        }
Esempio n. 12
0
        /// <summary>
        /// 準備資料
        /// </summary>
        public override void Prepare(ImportOption Option)
        {
            mOption = Option;

            Importbot.ClubDic = Importbot.GetCLUBDic();

            Importbot.TeacherNameDic = Importbot.GetTeacherDic();
        }
 private ExcelData GetExcelData <T>(ImportOption importOption)
     where T : class, new()
 {
     return(_excelImportProvider.Convert <T>(
                importOption.FileUrl
                , importOption.SheetIndex
                , importOption.HeaderRowIndex
                , importOption.DataRowStartIndex));
 }
Esempio n. 14
0
        DataTable Import(string localeSetting, IEnumerable <string> paths, ImportOption options, bool dryRun)
        {
            // Convert spreadsheets to a single DataTable
            var importData = ConvertToDataTable(paths);

            // Validate and, if dryRun = false, import the DataTable
            var result = LoadDataTable(localeSetting, importData, options, dryRun);

            return(result);
        }
Esempio n. 15
0
        private void check_importConfig_CheckedChanged(object sender, EventArgs e)
        {
            if (!check_importConfig.Checked)
            {
                _configImportOption = ImportOption.None;
            }
            else
            {
                _configImportOption = ImportOption.Merge;
            }

            Validate();
        }
Esempio n. 16
0
 public Naps2ScanJob AddInputFiles(IEnumerable <InputFile> paths)
 {
     if (Args.TryGetValue(Keys.Main.Import, out var option))
     {
         (option as ImportOption).AddFiles(paths);
     }
     else
     {
         option = new ImportOption(paths);
         Args.Add(option);
     }
     return(this);
 }
Esempio n. 17
0
        private void check_importGestures_CheckedChanged(object sender, EventArgs e)
        {
            combo_importGesturesOption.Enabled = check_importGestures.Checked;
            if (!check_importGestures.Checked)
            {
                _gesturesImportOption = ImportOption.None;
            }
            else
            {
                _gesturesImportOption = combo_importGesturesOption.SelectedIndex == 0 ? ImportOption.Merge : ImportOption.Replace;
            }

            Validate();
        }
        /// <summary>
        /// 匯入前準備
        /// </summary>
        /// <param name="Option"></param>
        public override void Prepare(ImportOption Option)
        {
            _Option           = Option;
            _HighConcernDict  = UDTTransfer.GetHighConcernDictAll();
            _StudentNumIDDict = UDTTransfer.GetStudentNumIDDictAll();
            // 取得學生資料
            List <string>        studentIDList = _StudentNumIDDict.Values.ToList();
            List <StudentRecord> recList       = Student.SelectByIDs(studentIDList);

            foreach (StudentRecord rec in recList)
            {
                _StudentRecDict.Add(rec.ID, rec);
            }
        }
Esempio n. 19
0
        public virtual void Import(IImportRecord record, ContentItem destination, ImportOption options)
        {
            var security = N2.Context.Current.Resolve <ISecurityManager>();

            using (security.Disable())     // TODO restrict to Admin User
            {
                ResetIDs(record.ReadItems);
                if ((options & ImportOption.AllItems) == ImportOption.AllItems)
                {
                    record.RootItem.AddTo(destination);
                    if (_persister != null)
                    {
                        _persister.SaveRecursive(record.RootItem);
                    }
                }
                else if ((options & ImportOption.Children) == ImportOption.Children)
                {
                    RemoveReferences(record.ReadItems, record.RootItem);
                    while (record.RootItem.Children.Count > 0)
                    {
                        ContentItem child = record.RootItem.Children[0];
                        child.AddTo(destination);
                        if (_persister != null)
                        {
                            _persister.SaveRecursive(child);
                        }
                    }
                }
                else
                {
                    logger.ErrorFormat("Option {0} isn't supported", options);
                    throw new NotImplementedException("This option isn't implemented, sorry.");
                }
                if ((options & ImportOption.Attachments) == ImportOption.Attachments)
                {
                    foreach (Attachment a in record.Attachments)
                    {
                        try
                        {
                            a.Import(_fs);
                        }
                        catch (Exception ex)
                        {
                            logger.Warn(ex);
                            record.FailedAttachments.Add(a);
                        }
                    }
                }
            }
        }
Esempio n. 20
0
        // 指定したオプションに基づく方法でファイル読み込みを試みる
        static string[] LoadAsset(this ImportOption option,
                                  string path, Delimiter delimiter)
        {
            // リソースをオプションに対応する方法で読み込む
            var resource = Import(option, path);

            // セルごとに切り分ける
            var split = Regex.Split(resource, delimiter.split);

            // セルのデータを整形する
            var table = split.Select(cell => _exclude.Replace(cell, string.Empty));

            // 余計な空データを取り除いたデータ列を返す
            return(table.Where(cell => !string.IsNullOrEmpty(cell)).ToArray());
        }
Esempio n. 21
0
        DataTable LoadDataTable(string localeSetting, DataTable importData, ImportOption options, bool dryRun)
        {
            var importResult = new DataTable
            {
                Columns =
                {
                    new DataColumn("Index",         typeof(int)),
                    new DataColumn("Status",        typeof(string)),
                    new DataColumn("Name",          typeof(string)),
                    new DataColumn("Value",         typeof(string)),
                    new DataColumn("LocaleSetting", typeof(string)),
                    new DataColumn("StoreId",       typeof(int)),
                },
            };

            using (var connection = DB.dbConn())
            {
                connection.Open();

                var index = 0;
                foreach (DataRow row in importData.Rows)
                {
                    var name  = row.Field <string>("A");
                    var value = row.Field <string>("B");

                    int storeId;
                    if (!int.TryParse(row.Field <string>("C"), out storeId))
                    {
                        storeId = AppLogic.StoreID();
                    }

                    var status = LoadLine(name, value, localeSetting, storeId, options, dryRun, connection);

                    importResult.Rows.Add(
                        index,
                        status,
                        name,
                        value,
                        localeSetting,
                        storeId);

                    index++;
                }
            }

            return(importResult);
        }
        public async Task <ExcelData> ValidateAsync <Template>(ImportOption importOption)
            where Template : class, new()
        {
            ExcelData excelData = this.GetExcelData <Template>(importOption);

            AndFilter andFilter = new AndFilter {
                Filters = FiltersFactory.CreateFilters <Template>()
            };

            FilterContext filterContext = new FilterContext {
                TypeFilter = TypeFilterInfoFactory.CreateInstance <Template>()
            };

            excelData.ExcelDataRows = andFilter.Filter(excelData.ExcelDataRows, filterContext, importOption);

            return(await Task.FromResult(excelData));
        }
 /// <summary>
 /// 获取Excel数据
 /// </summary>
 /// <typeparam name="TExcelTemplate"></typeparam>
 /// <param name="importOption"></param>
 /// <returns></returns>
 private ExcelData GetExcelData <TExcelTemplate>(ImportOption importOption)
     where TExcelTemplate : class, new()
 {
     return(importOption.ExcelImportProvider == null?
            this._excelImportProvider.Convert <TExcelTemplate>(
                stream : importOption.Stream,
                sheetIndex : importOption.SheetIndex,
                headerIndex : importOption.DataHeaderIndex,
                rowIndex : importOption.DataRowsIndex
                ) :
                importOption.ExcelImportProvider.Convert <TExcelTemplate>(
                    stream: importOption.Stream,
                    sheetIndex: importOption.SheetIndex,
                    headerIndex: importOption.DataHeaderIndex,
                    rowIndex: importOption.DataRowsIndex
                    ));
 }
Esempio n. 24
0
	    public virtual void Import(IImportRecord record, ContentItem destination, ImportOption options)
	    {
	        var security = N2.Context.Current.Resolve<ISecurityManager>();
	        using (security.Disable()) // TODO restrict to Admin User
	        {
	            ResetIDs(record.ReadItems);
	            if ((options & ImportOption.AllItems) == ImportOption.AllItems)
	            {
	                record.RootItem.AddTo(destination);
	                if (_persister != null)
	                    _persister.SaveRecursive(record.RootItem);
	            }
	            else if ((options & ImportOption.Children) == ImportOption.Children)
	            {
	                RemoveReferences(record.ReadItems, record.RootItem);
	                while (record.RootItem.Children.Count > 0)
	                {
	                    ContentItem child = record.RootItem.Children[0];
	                    child.AddTo(destination);
	                    if (_persister != null)
	                        _persister.SaveRecursive(child);
	                }
	            }
	            else
	            {
	                logger.ErrorFormat("Option {0} isn't supported", options);
	                throw new NotImplementedException("This option isn't implemented, sorry.");
	            }
	            if ((options & ImportOption.Attachments) == ImportOption.Attachments)
	            {
	                foreach (Attachment a in record.Attachments)
	                {
	                    try
	                    {
	                        a.Import(_fs);
	                    }
	                    catch (Exception ex)
	                    {
	                        logger.Warn(ex);
	                        record.FailedAttachments.Add(a);
	                    }
	                }
	            }
	        }
	    }
Esempio n. 25
0
        public Task <DataTable> ToTableAsync <T>(string fileUrl
                                                 , int sheetIndex     = 0
                                                 , int headerRowIndex = 0
                                                 , int dataRowIndex   = 1
                                                 , int dataRowCount   = -1)
            where T : class, new()
        {
            if (string.IsNullOrWhiteSpace(fileUrl))
            {
                throw new ArgumentNullException("fieUrl");
            }

            DataTable dt           = new DataTable();
            var       importOption = new ImportOption()
            {
                FileUrl           = fileUrl,
                DataRowStartIndex = dataRowIndex,
                HeaderRowIndex    = headerRowIndex,
                SheetIndex        = sheetIndex
            };

            var excelData = GetExcelData <T>(importOption);

            excelData.Header.Cells.ForEach(x =>
            {
                dt.Columns.Add(x.ColName);
            });

            var count = excelData.Data.Count;

            if (dataRowCount > -1)
            {
                count = dataRowCount;
            }

            for (int i = 0; i < count && i < excelData.Data.Count; i++)
            {
                var     excelRow = excelData.Data[i];
                DataRow dataRow  = dt.NewRow();
                dataRow.ItemArray = excelRow.DataCols.Select(c => c.ColValue).ToArray();
                dt.Rows.Add(dataRow);
            }

            return(Task.FromResult(dt));
        }
Esempio n. 26
0
        protected void btnReload_Click(object sender, EventArgs e)
        {
            String ShowLocaleSetting = Localization.CheckLocaleSettingForProperCase(CommonLogic.QueryStringCanBeDangerousContent("ShowLocaleSetting"));

            resetError("", false);

            ImportOption option = ImportOption.Default;

            if (chkReloadLeaveModified.Checked)
            {
                option = option | ImportOption.LeaveModified;
            }
            if (chkReloadReplaceExisting.Checked)
            {
                option = option | ImportOption.OverWrite;
            }

            Response.Redirect(AppLogic.AdminLinkUrl("importstringresourcefile2.aspx") + "?master=true&showlocalesetting=" + ShowLocaleSetting + "&option=" + ((int)option).ToString());
        }
        /// <summary>
        /// 匯入前準備
        /// </summary>
        /// <param name="Option"></param>
        public override void Prepare(ImportOption Option)
        {
            mHelper = new AccessHelper();
            mOption = Option;
            mCourseNameIDs = new Dictionary<string, string>();
            mTask = Task.Factory.StartNew
            (() =>
            {
                QueryHelper Helper = new QueryHelper();

                DataTable Table = Helper.Select("select uid,course_name,school_year,semester,month from $shinmin.retake.course");

                foreach (DataRow Row in Table.Rows)
                {
                    string CourseID = Row.Field<string>("uid");
                    string CourseName = Row.Field<string>("course_name");
                    string SchoolYear = Row.Field<string>("school_year");
                    string Semester = Row.Field<string>("semester");
                    string Month = Row.Field<string>("month");
                    string CourseKey = CourseName + "," + SchoolYear + "," + Semester + "," + Month;

                    if (!mCourseNameIDs.ContainsKey(CourseKey))
                        mCourseNameIDs.Add(CourseKey, CourseID);
                }

                Table = Helper.Select("select id,teacher_name,nickname from teacher");

                foreach (DataRow Row in Table.Rows)
                {
                    string TeacherID = Row.Field<string>("id");
                    string TeacherName = Row.Field<string>("teacher_name");
                    string TeacherNickname = Row.Field<string>("nickname");
                    string TeacherKey = string.IsNullOrWhiteSpace(TeacherNickname) ? TeacherName : TeacherName + "(" + TeacherNickname + ")";

                    if (!mTeacherNameIDs.ContainsKey(TeacherKey))
                        mTeacherNameIDs.Add(TeacherKey, TeacherID);
                }
            }
            );
        }
Esempio n. 28
0
 public virtual void Import(IImportRecord record, ContentItem destination, ImportOption options)
 {
     ResetIDs(record.ReadItems);
     if ((options & ImportOption.AllItems) == ImportOption.AllItems)
     {
         record.RootItem.AddTo(destination);
         persister.SaveRecursive(record.RootItem);
     }
     else if ((options & ImportOption.Children) == ImportOption.Children)
     {
         RemoveReferences(record.ReadItems, record.RootItem);
         while (record.RootItem.Children.Count > 0)
         {
             ContentItem child = record.RootItem.Children[0];
             child.AddTo(destination);
             persister.SaveRecursive(child);
         }
     }
     else
     {
         logger.ErrorFormat("Option {0} isn't supported", options);
         throw new NotImplementedException("This option isn't implemented, sorry.");
     }
     if ((options & ImportOption.Attachments) == ImportOption.Attachments)
     {
         foreach (Attachment a in record.Attachments)
         {
             try
             {
                 a.Import(fs);
             }
             catch (Exception ex)
             {
                 logger.Warn(ex);
                 record.FailedAttachments.Add(a);
             }
         }
     }
 }
Esempio n. 29
0
		public virtual void Import(IImportRecord record, ContentItem destination, ImportOption options)
		{
			ResetIDs(record.ReadItems);
			if ((options & ImportOption.AllItems) == ImportOption.AllItems)
			{
				record.RootItem.AddTo(destination);
				persister.Save(record.RootItem);
			}
			else if ((options & ImportOption.Children) == ImportOption.Children)
			{
				RemoveReferences(record.ReadItems, record.RootItem);
				while (record.RootItem.Children.Count > 0)
				{
					ContentItem child = record.RootItem.Children[0];
					child.AddTo(destination);
					persister.Save(child);
				}
			}
			else
			{
				logger.ErrorFormat("Option {0} isn't supported", options);
				throw new NotImplementedException("This option isn't implemented, sorry.");
			}
			if ((options & ImportOption.Attachments) == ImportOption.Attachments)
			{
				foreach(Attachment a in record.Attachments)
				{
                    try
                    {
                        a.Import(fs);
                    }
                    catch (Exception ex)
                    {
                        logger.Warn(ex);
                        record.FailedAttachments.Add(a);
                    }
				}
			}
		}
        //public DataTable ToTable(string fileUrl, int sheetIndex = 0, int headerRowIndex = 0, int dataRowStartIndex = 1, int dataRowCount = -1)
        //{
        //    IWorkbook workbook;
        //    using (FileStream stream = new FileStream(fileUrl, FileMode.Open, FileAccess.Read))
        //    {
        //        workbook = new HSSFWorkbook(stream);
        //    }

        //    ISheet sheet = workbook.GetSheetAt(sheetIndex);
        //    DataTable dt = new DataTable(sheet.SheetName);

        //    // 处理表头
        //    IRow headerRow = sheet.GetRow(headerRowIndex);
        //    foreach (ICell headerCell in headerRow)
        //    {
        //        dt.Columns.Add(headerCell.ToString());
        //    }

        //    //默认转换所有数据
        //    var dataRowStopIndex = sheet.PhysicalNumberOfRows - 1;

        //    //只转换指定数量数据
        //    if (dataRowCount > -1)
        //    {
        //        dataRowStopIndex = dataRowStartIndex + dataRowCount;
        //    }

        //    //转换
        //    for (int i = dataRowStartIndex; i < dataRowStopIndex; i++)
        //    {
        //        var row = sheet.GetRow(i);
        //        if (row != null)
        //        {
        //            DataRow dataRow = dt.NewRow();
        //            dataRow.ItemArray = row.Cells.Select(c => c.ToString()).ToArray();
        //            dt.Rows.Add(dataRow);
        //        }
        //    }

        //    return dt;
        //}

        /// <summary>
        /// 导入
        /// </summary>
        /// <typeparam name="T">模板类</typeparam>
        /// <param name="fileUrl">Excel文件绝对地址</param>
        /// <returns></returns>
        public Task <List <ExcelDataRow> > ValidateAsync <T>(ImportOption importOption) where T : class, new()
        {
            var excelData = GetExcelData <T>(importOption);

            if (importOption.MappingDictionary != null)
            {
                excelData.Data = MappingHeaderDictionary(excelData.Data, importOption.MappingDictionary);
            }

            AndFilter andFilter = new AndFilter()
            {
                filters = FiltersFactory.CreateFilters <T>(excelData.Header)
            };

            FilterContext context = new FilterContext()
            {
                TypeFilterInfo = TypeFilterInfoFactory.CreateInstance(typeof(T), excelData.Header)
            };

            excelData.Data = andFilter.Filter(excelData.Data, context, importOption);

            return(Task.FromResult(excelData.Data));
        }
Esempio n. 31
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            String ShowLocaleSetting = Localization.CheckLocaleSettingForProperCase(CommonLogic.QueryStringCanBeDangerousContent("ShowLocaleSetting"));
            String SpreadsheetName   = "Strings_" + Localization.ToThreadCultureShortDateString(System.DateTime.Now).Replace(" ", "").Replace("/", "").Replace(":", "").Replace(".", "");
            bool   DataUpdated       = false;

            resetError("", false);

            ImportOption option = ImportOption.Default;

            if (chkLeaveModified.Checked)
            {
                option = option | ImportOption.LeaveModified;
            }
            if (chkReplaceExisting.Checked)
            {
                option = option | ImportOption.OverWrite;
            }

            // handle file upload:
            try
            {
                String TargetFile = CommonLogic.SafeMapPath("../images" + "/" + SpreadsheetName + ".xls");
                fuMain.SaveAs(TargetFile);
                DataUpdated = true;
            }
            catch (Exception ex)
            {
                resetError(String.Format(AppLogic.GetString("admin.importstringresourcefile1.UploadError", SkinID, LocaleSetting), ex.ToString()), true);
            }

            if (DataUpdated)
            {
                resetError("<a href=\"" + AppLogic.AdminLinkUrl("importstringresourcefile2.aspx") + "?spreadsheetname=" + SpreadsheetName + "&showlocalesetting=" + ShowLocaleSetting + "&option=" + ((int)option).ToString() + "\"><strong>" + AppLogic.GetString("admin.importstringresourcefile1.UploadSuccessful", SkinID, LocaleSetting) + "</strong></a>\n", false);
            }
        }
Esempio n. 32
0
        public List <ExcelDataRow> Filter(List <ExcelDataRow> excelDataRows, FilterContext context, ImportOption importOption)
        {
            foreach (var r in excelDataRows)
            {
                if (!r.IsValid && importOption.ValidateMode == ValidateModeEnum.StopOnFirstFailure)
                {
                    continue;
                }

                r.DataCols.ForEach(c =>
                {
                    var attrs = c.GetFilterAttrs <RegexAttribute>(context.TypeFilterInfo);

                    if (attrs != null && attrs.Count > 0)
                    {
                        attrs.ForEach(a =>
                        {
                            r.SetNotValid(Regex.IsMatch(c.ColValue, a.Regex), c, a.ErrorMsg);
                        });
                    }
                });
            }

            return(excelDataRows);
        }
Esempio n. 33
0
        /// <summary>
        /// Sets the import option when opening the next workbook.
        /// Works only for XSSF. For HSSF workbooks this option is ignored.
        /// </summary>
        /// <param name="importOption">Customize the elements that are processed on the next import</param>
        public static void SetImportOption(ImportOption importOption)
        {
            if (ImportOption.SheetContentOnly == importOption)
            {
                // Add
                XSSFRelation.AddRelation(XSSFRelation.WORKSHEET);
                XSSFRelation.AddRelation(XSSFRelation.SHARED_STRINGS);

                // Remove
                XSSFRelation.RemoveRelation(XSSFRelation.WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.MACROS_WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.TEMPLATE_WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.MACRO_TEMPLATE_WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.MACRO_ADDIN_WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.CHARTSHEET);
                XSSFRelation.RemoveRelation(XSSFRelation.STYLES);
                XSSFRelation.RemoveRelation(XSSFRelation.DRAWINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.CHART);
                XSSFRelation.RemoveRelation(XSSFRelation.VML_DRAWINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.CUSTOM_XML_MAPPINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.TABLE);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGES);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_EMF);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_WMF);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_PICT);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_JPEG);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_PNG);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_DIB);
                XSSFRelation.RemoveRelation(XSSFRelation.SHEET_COMMENTS);
                XSSFRelation.RemoveRelation(XSSFRelation.SHEET_HYPERLINKS);
                XSSFRelation.RemoveRelation(XSSFRelation.OLEEMBEDDINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.PACKEMBEDDINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.VBA_MACROS);
                XSSFRelation.RemoveRelation(XSSFRelation.ACTIVEX_CONTROLS);
                XSSFRelation.RemoveRelation(XSSFRelation.ACTIVEX_BINS);
                XSSFRelation.RemoveRelation(XSSFRelation.THEME);
                XSSFRelation.RemoveRelation(XSSFRelation.CALC_CHAIN);
                XSSFRelation.RemoveRelation(XSSFRelation.PRINTER_SETTINGS);
            }
            else if (ImportOption.TextOnly == importOption)
            {
                // Add
                XSSFRelation.AddRelation(XSSFRelation.WORKSHEET);
                XSSFRelation.AddRelation(XSSFRelation.SHARED_STRINGS);
                XSSFRelation.AddRelation(XSSFRelation.SHEET_COMMENTS);

                // Remove
                XSSFRelation.RemoveRelation(XSSFRelation.WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.MACROS_WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.TEMPLATE_WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.MACRO_TEMPLATE_WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.MACRO_ADDIN_WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.CHARTSHEET);
                XSSFRelation.RemoveRelation(XSSFRelation.STYLES);
                XSSFRelation.RemoveRelation(XSSFRelation.DRAWINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.CHART);
                XSSFRelation.RemoveRelation(XSSFRelation.VML_DRAWINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.CUSTOM_XML_MAPPINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.TABLE);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGES);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_EMF);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_WMF);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_PICT);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_JPEG);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_PNG);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_DIB);
                XSSFRelation.RemoveRelation(XSSFRelation.SHEET_HYPERLINKS);
                XSSFRelation.RemoveRelation(XSSFRelation.OLEEMBEDDINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.PACKEMBEDDINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.VBA_MACROS);
                XSSFRelation.RemoveRelation(XSSFRelation.ACTIVEX_CONTROLS);
                XSSFRelation.RemoveRelation(XSSFRelation.ACTIVEX_BINS);
                XSSFRelation.RemoveRelation(XSSFRelation.THEME);
                XSSFRelation.RemoveRelation(XSSFRelation.CALC_CHAIN);
                XSSFRelation.RemoveRelation(XSSFRelation.PRINTER_SETTINGS);
            }
            else
            {
                // NONE/All
                XSSFRelation.AddRelation(XSSFRelation.WORKBOOK);
                XSSFRelation.AddRelation(XSSFRelation.MACROS_WORKBOOK);
                XSSFRelation.AddRelation(XSSFRelation.TEMPLATE_WORKBOOK);
                XSSFRelation.AddRelation(XSSFRelation.MACRO_TEMPLATE_WORKBOOK);
                XSSFRelation.AddRelation(XSSFRelation.MACRO_ADDIN_WORKBOOK);
                XSSFRelation.AddRelation(XSSFRelation.WORKSHEET);
                XSSFRelation.AddRelation(XSSFRelation.CHARTSHEET);
                XSSFRelation.AddRelation(XSSFRelation.SHARED_STRINGS);
                XSSFRelation.AddRelation(XSSFRelation.STYLES);
                XSSFRelation.AddRelation(XSSFRelation.DRAWINGS);
                XSSFRelation.AddRelation(XSSFRelation.CHART);
                XSSFRelation.AddRelation(XSSFRelation.VML_DRAWINGS);
                XSSFRelation.AddRelation(XSSFRelation.CUSTOM_XML_MAPPINGS);
                XSSFRelation.AddRelation(XSSFRelation.TABLE);
                XSSFRelation.AddRelation(XSSFRelation.IMAGES);
                XSSFRelation.AddRelation(XSSFRelation.IMAGE_EMF);
                XSSFRelation.AddRelation(XSSFRelation.IMAGE_WMF);
                XSSFRelation.AddRelation(XSSFRelation.IMAGE_PICT);
                XSSFRelation.AddRelation(XSSFRelation.IMAGE_JPEG);
                XSSFRelation.AddRelation(XSSFRelation.IMAGE_PNG);
                XSSFRelation.AddRelation(XSSFRelation.IMAGE_DIB);
                XSSFRelation.AddRelation(XSSFRelation.SHEET_COMMENTS);
                XSSFRelation.AddRelation(XSSFRelation.SHEET_HYPERLINKS);
                XSSFRelation.AddRelation(XSSFRelation.OLEEMBEDDINGS);
                XSSFRelation.AddRelation(XSSFRelation.PACKEMBEDDINGS);
                XSSFRelation.AddRelation(XSSFRelation.VBA_MACROS);
                XSSFRelation.AddRelation(XSSFRelation.ACTIVEX_CONTROLS);
                XSSFRelation.AddRelation(XSSFRelation.ACTIVEX_BINS);
                XSSFRelation.AddRelation(XSSFRelation.THEME);
                XSSFRelation.AddRelation(XSSFRelation.CALC_CHAIN);
                XSSFRelation.AddRelation(XSSFRelation.PRINTER_SETTINGS);
            }
        }
Esempio n. 34
0
        private void check_importConfig_CheckedChanged(object sender, EventArgs e)
        {
            if (!check_importConfig.Checked)
            {
                _configImportOption = ImportOption.None;
            }
            else
            {
                _configImportOption = ImportOption.Merge;
            }

            Validate();
        }
Esempio n. 35
0
 public List <ExcelDataRow> Filter(List <ExcelDataRow> dataRows, FilterContext filterContext, ImportOption importOption)
 {
     foreach (var dr in dataRows)
     {
         if (!dr.IsValid && importOption.ImportMode == ImportMode.ErrorAfterStop)
         {
             continue;
         }
         dr.excelDataColList.ForEach(edc =>
         {
             var attr = edc.GetAttribute <DateTimeAttribute>(filterContext.TypeFilter);
             if (attr != null)
             {
                 edc.SetNotValid(dr, edc.CellString.IsDateTime(), attr.ErrorMsg);
             }
         });
     }
     return(dataRows);
 }
Esempio n. 36
0
        private void combo_importGesturesOption_SelectedIndexChanged(object sender, EventArgs e)
        {
            _gesturesImportOption = combo_importGesturesOption.SelectedIndex == 0 ? ImportOption.Merge : ImportOption.Replace;

        }
Esempio n. 37
0
        private void check_importGestures_CheckedChanged(object sender, EventArgs e)
        {
            combo_importGesturesOption.Enabled = check_importGestures.Checked;
            if (!check_importGestures.Checked)
            {
                _gesturesImportOption = ImportOption.None;
            }
            else
            {
                _gesturesImportOption = combo_importGesturesOption.SelectedIndex == 0 ? ImportOption.Merge : ImportOption.Replace;
            }

            Validate();
        }
        /// <summary>
        /// 匯入前準備
        /// </summary>
        /// <param name="Option"></param>
        public override void Prepare(ImportOption Option)
        {
            mOption = Option;

            Initial();
        }
 public override void Prepare(ImportOption Option)
 {
     mOption = Option;
     _UDTTransfer = new DAO.UDTTransfer();
     //_StudRecList = Student.SelectAll();
     _ImportStudIDList = new List<string>();
 }
 public override void Prepare(ImportOption Option)
 {
     mOption = Option;
     _UDTTransfer = new DAO.UDTTransfer();
 }
 public override void Prepare(ImportOption Option)
 {
     mOption = Option;
     _InsertRecList = new List<SHUpdateRecordRecord>();
     _UpdateRecList = new List<SHUpdateRecordRecord>();
     _DeleteRecList = new List<SHUpdateRecordRecord>();
 }
Esempio n. 42
0
 /// <summary>
 /// Creates the appropriate HSSFWorkbook / XSSFWorkbook from
 /// the given InputStream. The Stream is wraped inside a PushbackInputStream.
 /// </summary>
 /// <param name="inputStream">Input Stream of .xls or .xlsx file</param>
 /// <param name="importOption">Customize the elements that are processed on the next import</param>
 /// <returns>IWorkbook depending on the input HSSFWorkbook or XSSFWorkbook is returned.</returns>
 public static IWorkbook Create(Stream inputStream, ImportOption importOption)
 {
     SetImportOption(importOption);
     var workbook = Create(inputStream);
     return workbook;
 }
Esempio n. 43
0
        /// <summary>
        /// Sets the import option when opening the next workbook.
        /// Works only for XSSF. For HSSF workbooks this option is ignored.
        /// </summary>
        /// <param name="importOption">Customize the elements that are processed on the next import</param>
        public static void SetImportOption(ImportOption importOption)
        {
            if (ImportOption.SheetContentOnly == importOption)
            {
                // Add
                XSSFRelation.AddRelation(XSSFRelation.WORKSHEET);
                XSSFRelation.AddRelation(XSSFRelation.SHARED_STRINGS);

                // Remove
                XSSFRelation.RemoveRelation(XSSFRelation.WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.MACROS_WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.TEMPLATE_WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.MACRO_TEMPLATE_WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.MACRO_ADDIN_WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.CHARTSHEET);
                XSSFRelation.RemoveRelation(XSSFRelation.STYLES);
                XSSFRelation.RemoveRelation(XSSFRelation.DRAWINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.CHART);
                XSSFRelation.RemoveRelation(XSSFRelation.VML_DRAWINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.CUSTOM_XML_MAPPINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.TABLE);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGES);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_EMF);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_WMF);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_PICT);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_JPEG);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_PNG);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_DIB);
                XSSFRelation.RemoveRelation(XSSFRelation.SHEET_COMMENTS);
                XSSFRelation.RemoveRelation(XSSFRelation.SHEET_HYPERLINKS);
                XSSFRelation.RemoveRelation(XSSFRelation.OLEEMBEDDINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.PACKEMBEDDINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.VBA_MACROS);
                XSSFRelation.RemoveRelation(XSSFRelation.ACTIVEX_CONTROLS);
                XSSFRelation.RemoveRelation(XSSFRelation.ACTIVEX_BINS);
                XSSFRelation.RemoveRelation(XSSFRelation.THEME);
                XSSFRelation.RemoveRelation(XSSFRelation.CALC_CHAIN);
                XSSFRelation.RemoveRelation(XSSFRelation.PRINTER_SETTINGS);
            }
            else if (ImportOption.TextOnly == importOption)
            {
                // Add
                XSSFRelation.AddRelation(XSSFRelation.WORKSHEET);
                XSSFRelation.AddRelation(XSSFRelation.SHARED_STRINGS);
                XSSFRelation.AddRelation(XSSFRelation.SHEET_COMMENTS);

                // Remove
                XSSFRelation.RemoveRelation(XSSFRelation.WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.MACROS_WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.TEMPLATE_WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.MACRO_TEMPLATE_WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.MACRO_ADDIN_WORKBOOK);
                XSSFRelation.RemoveRelation(XSSFRelation.CHARTSHEET);
                XSSFRelation.RemoveRelation(XSSFRelation.STYLES);
                XSSFRelation.RemoveRelation(XSSFRelation.DRAWINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.CHART);
                XSSFRelation.RemoveRelation(XSSFRelation.VML_DRAWINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.CUSTOM_XML_MAPPINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.TABLE);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGES);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_EMF);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_WMF);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_PICT);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_JPEG);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_PNG);
                XSSFRelation.RemoveRelation(XSSFRelation.IMAGE_DIB);
                XSSFRelation.RemoveRelation(XSSFRelation.SHEET_HYPERLINKS);
                XSSFRelation.RemoveRelation(XSSFRelation.OLEEMBEDDINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.PACKEMBEDDINGS);
                XSSFRelation.RemoveRelation(XSSFRelation.VBA_MACROS);
                XSSFRelation.RemoveRelation(XSSFRelation.ACTIVEX_CONTROLS);
                XSSFRelation.RemoveRelation(XSSFRelation.ACTIVEX_BINS);
                XSSFRelation.RemoveRelation(XSSFRelation.THEME);
                XSSFRelation.RemoveRelation(XSSFRelation.CALC_CHAIN);
                XSSFRelation.RemoveRelation(XSSFRelation.PRINTER_SETTINGS);
            }
            else
            {
                // NONE/All
                XSSFRelation.AddRelation(XSSFRelation.WORKBOOK);
                XSSFRelation.AddRelation(XSSFRelation.MACROS_WORKBOOK);
                XSSFRelation.AddRelation(XSSFRelation.TEMPLATE_WORKBOOK);
                XSSFRelation.AddRelation(XSSFRelation.MACRO_TEMPLATE_WORKBOOK);
                XSSFRelation.AddRelation(XSSFRelation.MACRO_ADDIN_WORKBOOK);
                XSSFRelation.AddRelation(XSSFRelation.WORKSHEET);
                XSSFRelation.AddRelation(XSSFRelation.CHARTSHEET);
                XSSFRelation.AddRelation(XSSFRelation.SHARED_STRINGS);
                XSSFRelation.AddRelation(XSSFRelation.STYLES);
                XSSFRelation.AddRelation(XSSFRelation.DRAWINGS);
                XSSFRelation.AddRelation(XSSFRelation.CHART);
                XSSFRelation.AddRelation(XSSFRelation.VML_DRAWINGS);
                XSSFRelation.AddRelation(XSSFRelation.CUSTOM_XML_MAPPINGS);
                XSSFRelation.AddRelation(XSSFRelation.TABLE);
                XSSFRelation.AddRelation(XSSFRelation.IMAGES);
                XSSFRelation.AddRelation(XSSFRelation.IMAGE_EMF);
                XSSFRelation.AddRelation(XSSFRelation.IMAGE_WMF);
                XSSFRelation.AddRelation(XSSFRelation.IMAGE_PICT);
                XSSFRelation.AddRelation(XSSFRelation.IMAGE_JPEG);
                XSSFRelation.AddRelation(XSSFRelation.IMAGE_PNG);
                XSSFRelation.AddRelation(XSSFRelation.IMAGE_DIB);
                XSSFRelation.AddRelation(XSSFRelation.SHEET_COMMENTS);
                XSSFRelation.AddRelation(XSSFRelation.SHEET_HYPERLINKS);
                XSSFRelation.AddRelation(XSSFRelation.OLEEMBEDDINGS);
                XSSFRelation.AddRelation(XSSFRelation.PACKEMBEDDINGS);
                XSSFRelation.AddRelation(XSSFRelation.VBA_MACROS);
                XSSFRelation.AddRelation(XSSFRelation.ACTIVEX_CONTROLS);
                XSSFRelation.AddRelation(XSSFRelation.ACTIVEX_BINS);
                XSSFRelation.AddRelation(XSSFRelation.THEME);
                XSSFRelation.AddRelation(XSSFRelation.CALC_CHAIN);
                XSSFRelation.AddRelation(XSSFRelation.PRINTER_SETTINGS);
            }
        }
 public override void Prepare(ImportOption Option)
 {
     _mOption = Option;
 }
 public override void Prepare(ImportOption Option)
 {
     mOption = Option;
 }
 public List <ExcelDataRow> Filter(List <ExcelDataRow> dataRows, FilterContext filterContext, ImportOption importOption)
 {
     foreach (var dr in dataRows)
     {
         if (!dr.IsValid && importOption.ImportMode == Core.ExcelImportExport.Enums.ImportMode.ErrorAfterStop)
         {
             continue;
         }
         dr.excelDataColList.ForEach(edc =>
         {
             DBFieldDumplicateAttribute dBFieldDumplicate = edc.GetAttribute <DBFieldDumplicateAttribute>(filterContext.TypeFilter);
             if (dBFieldDumplicate != null)
             {
                 Type validateClass = dBFieldDumplicate.ValidateClass;
                 if (!validateClass.IsSubclassOf(typeof(Entity)))
                 {
                     throw new NotSupportedException(nameof(validateClass));
                 }
                 MethodInfo method   = typeof(Extend).GetMethod(nameof(Extend.DBCheck)).MakeGenericMethod(validateClass);
                 string selectResult = (string)method.Invoke(null, new object[] { dBFieldDumplicate, dBFieldDumplicate.ValidateProperty, edc.CellString });
                 edc.SetNotValid(dr, string.IsNullOrWhiteSpace(selectResult), dBFieldDumplicate.ErrorMsg);
             }
         });
     }
     return(dataRows);
 }
Esempio n. 47
0
        public virtual void Import(IImportRecord record, ContentItem destination, ImportOption options)
        {
            ResetIDs(record.ReadItems);
            if ((options & ImportOption.AllItems) == ImportOption.AllItems)
            {
                record.RootItem.AddTo(destination);
	            try
	            {
		            persister.SaveRecursive(record.RootItem);
	            }
	            catch (Exception ex)
	            {
		            logger.Warn(ex);
					if (record.RootItem != null)
						record.FailedContentItems.Add(new Tuple<ContentItem, Exception>(record.RootItem, ex));
	            }
            }
            else if ((options & ImportOption.Children) == ImportOption.Children)
            {
                RemoveReferences(record.ReadItems, record.RootItem);
                while (record.RootItem.Children.Count > 0)
                {
	                ContentItem child = null;
	                bool added = false;
	                try
	                {
		                child = record.RootItem.Children[0];
		                child.AddTo(destination);
		                added = true;
		                persister.SaveRecursive(child);
	                }
	                catch (Exception ex)
	                {
						logger.Warn(ex);
						if (child != null)
							record.FailedContentItems.Add(new Tuple<ContentItem, Exception>(child, ex));

						// ROLL BACK: Undo child.AddTo if SaveRecursive failed. That way the import can still continue successfully.
		                if (added && destination != null && child != null)
			                destination.Children.Remove(child); 
	                }
                }
            }
            else
            {
                logger.ErrorFormat("Option {0} isn't supported", options);
                throw new NotImplementedException("This option isn't implemented, sorry.");
            }
            if ((options & ImportOption.Attachments) == ImportOption.Attachments)
            {
                foreach(Attachment a in record.Attachments)
                {
                    try
                    {
                        a.Import(fs);
                    }
                    catch (Exception ex)
                    {
                        logger.Warn(ex);
                        record.FailedAttachments.Add(a);
                    }
                }
            }
        }