public override string Transform(string value, IRowSource row)
        {
            List <String> patterns = new List <String>();
            DateTime      dt;

            if (!String.IsNullOrWhiteSpace(Options.InputFormat))
            {
                var bits = Options.InputFormat.Split('|');
                foreach (String pattern in bits)
                {
                    if (!String.IsNullOrWhiteSpace(pattern))
                    {
                        if (DateTime.TryParseExact(value, pattern.Trim(), CultureInfo.InvariantCulture, DateTimeStyles.None, out dt))
                        {
                            return(DateUtils.DateToBLDate(dt));
                        }
                    }
                }
            }

            if (Options.AutoDetectFormat)
            {
                if (DateTime.TryParse(value, out dt))
                {
                    return(DateUtils.DateToBLDate(dt));
                }
            }

            return("0");
        }
示例#2
0
 public SkylineViewContext(ColumnDescriptor parentColumn, IRowSource rowSource)
     : base(
         parentColumn.DataSchema,
         new[] { new RowSourceInfo(rowSource, GetDefaultViewInfo(parentColumn)) })
 {
     ApplicationIcon = Resources.Skyline;
 }
示例#3
0
 public Record(IRowSource rowSource, IEnumerable <string> fields)
 {
     foreach (string field in fields)
     {
         Add(field, rowSource.GetFieldData(field));
     }
 }
示例#4
0
        public bool Validate(IRowSource Value)
        {
            //格過驗證。
            if (_skip_validate)
            {
                return(true);
            }

            List <DuplicateInfo> dups = _key_sets.GetDuplicate(Value);

            if (dups.Count <= 0)
            {
                return(true);
            }
            else
            {
                DuplicateInfo dup = dups[0];
                _previous_result = dup;

                string serverValue = dup.Record[_check_field.InternalName].Trim();
                string sourceValue = Value.GetFieldData(_check_field.FieldName).Trim();

                return(serverValue == sourceValue);
            }
        }
示例#5
0
 public void AddRecord(IRowSource rowSource, IEnumerable <string> fields)
 {
     foreach (ConditionKeySet each in _key_set_list.Values)
     {
         each.AddRecord(rowSource, fields);
     }
 }
示例#6
0
        private static bool IsValid(List <string> fields, Record record, IRowSource rowSource)
        {
            Dictionary <string, string> teachers = new Dictionary <string, string>();

            teachers.Add("授課教師一", string.Empty);
            teachers.Add("授課教師二", string.Empty);
            teachers.Add("授課教師三", string.Empty);

            foreach (string each in new string[] { "授課教師一", "授課教師二", "授課教師三" })
            {
                teachers[each] = record[_field_map[each]];
            }

            foreach (string each in fields)
            {
                teachers[each] = rowSource.GetFieldData(each);
            }

            Dictionary <string, string> dup = new Dictionary <string, string>();

            foreach (string each in teachers.Values)
            {
                if (dup.ContainsKey(each))
                {
                    return(false);
                }

                if (!string.IsNullOrEmpty(each))
                {
                    dup.Add(each, each);
                }
            }

            return(true);
        }
        public bool Validate(IRowSource Value)
        {
            //格過驗證。
            if (_skip_validate)
            {
                return(true);
            }

            int            rowIndex = -1;
            SheetRowSource sheetRow = Value as SheetRowSource;

            if (sheetRow != null)
            {
                rowIndex = sheetRow.CurrentRowIndex;
            }

            DuplicateInfo dup = _key_sets.GetDuplicateBy(_primary_condition, Value);

            if (dup != null)
            {
                Record record = dup.Record;
                record.SourceRowIndex = rowIndex;

                foreach (ImportCondition each in _check_conditions)
                {
                    foreach (ImportField eachField in each.Fields)
                    {
                        record[eachField.InternalName] = Value.GetFieldData(eachField.FieldName);
                    }
                }
            }
            return(true);
        }
示例#8
0
 public override string Transform(string value, IRowSource row)
 {
     if (!string.IsNullOrEmpty(value)) {
         return value.ToLower();
     }
     return value;
 }
        public override string Transform(string value, IRowSource row)
        {
            if (this.Regex != null)
            {
                var m = this.Regex.Match(value);
                if (m.Success)
                {
                    var placeHolderValues = new String[PlaceholderCount];
                    for (int i = 0; i < PlaceholderCount; ++i)
                    {
                        if (i < m.Groups.Count)
                        {
                            placeHolderValues[i] = m.Groups[i].Value;
                        }
                        else
                        {
                            placeHolderValues[i] = "";
                        }
                    }
                    return(String.Format(Options.OutputFormat, placeHolderValues));
                }
            }

            if (Options.DefaultIfNotMatch)
            {
                return(Options.DefaultValue);
            }

            return(value);
        }
示例#10
0
 public NodeActivity(IEnvironment pEnv, IRowSource pValSource, string pLocation, string[] pParams, string[] pCols)
 {
     _environment = pEnv;
     _valSource   = pValSource;
     _location    = pLocation;
     _params      = pParams;
     _cols        = pCols;
 }
示例#11
0
 public RowSourceInfo(Type rowType, IRowSource rows, IEnumerable <ViewInfo> views)
 {
     RowType     = rowType;
     _rows       = rows;
     Views       = ImmutableList.ValueOf(views);
     DisplayName = rowType.Name;
     Name        = rowType.FullName;
 }
 public override string Transform(string value, IRowSource row)
 {
     if (!string.IsNullOrEmpty(value))
     {
         return(value.ToLower());
     }
     return(value);
 }
示例#13
0
 public BindDataRefenceAsActivity(IDataReference pReference, IRowSource pRowSource, string pFilterName, IObjectSource pFilterDataSource, string[] pColSource, string[] pColDest)
 {
     reference        = pReference;
     colSource        = pColSource;
     colDest          = pColDest;
     rowSource        = pRowSource;
     filterName       = pFilterName;
     filterDataSource = pFilterDataSource;
 }
示例#14
0
 public RowSourceInfo(Type rowType, IRowSource rows, IEnumerable <ViewInfo> views, string fullName,
                      string displayName)
 {
     RowType     = rowType;
     _rows       = rows;
     Views       = ImmutableList.ValueOf(views);
     Name        = fullName;
     DisplayName = displayName;
 }
        public String transform(String value, IRowSource row)
        {
            String transformed = value;

            foreach (ValueTransformer t in _pipeline)
            {
                transformed = t.Transform(transformed, row);
            }
            return(transformed);
        }
示例#16
0
 protected void SetViewFrom(BindingListSource sourceBindingList, IRowSource newRowSource,
                            BindingListSource targetBindingList)
 {
     targetBindingList.SetView(sourceBindingList.ViewInfo, newRowSource);
     targetBindingList.RowFilter = sourceBindingList.RowFilter;
     if (sourceBindingList.SortDescriptions != null)
     {
         targetBindingList.ApplySort(sourceBindingList.SortDescriptions);
     }
 }
示例#17
0
        internal string GetKeyByFieldName(IRowSource rowSource)
        {
            StringBuilder builder = new StringBuilder();

            foreach (ImportField each in Fields)
            {
                builder.Append(rowSource.GetFieldData(each.FieldName) + ":");
            }

            return(builder.ToString());
        }
示例#18
0
        private void AddRecordByFieldName(IRowSource rowSource, IEnumerable <string> fields)
        {
            Record record = new Record(rowSource, fields);

            string key = _condition.GetKeyByFieldName(rowSource);

            if (!_records.ContainsKey(key))
            {
                _records.Add(key, record);
            }
        }
示例#19
0
        internal bool IsEmptyKey(IRowSource rowSource)
        {
            StringBuilder builder = new StringBuilder();

            foreach (ImportField each in Fields)
            {
                builder.Append(rowSource.GetFieldData(each.FieldName));
            }

            return(string.IsNullOrEmpty(builder.ToString().Trim()));
        }
        public bool Validate(IRowSource Value)
        {
            //略過驗證。
            if (_skip_validate)
            {
                return(true);
            }

            List <DuplicateInfo> dups = _key_sets.GetDuplicate(Value);

            return(dups.Count > 0);
        }
示例#21
0
        public string GetCourseID(IRowSource rowSource)
        {
            DuplicateInfo dup = _key_set_list.GetDuplicateBy(_condition, rowSource);

            if (dup != null)
            {
                return(dup.Record["CourseID"]);
            }
            else
            {
                return(string.Empty);
            }
        }
        public bool Validate(IRowSource Value)
        {
            //格過驗證。
            if (_skip_validate)
            {
                return(true);
            }

            List <DuplicateInfo> conds = _key_sets.GetDuplicate(Value);

            _prevous_result = conds;

            return(conds.Count <= 0);
        }
示例#23
0
        public List <DuplicateInfo> GetDuplicate(IRowSource rowSource)
        {
            List <DuplicateInfo> duplicates = new List <DuplicateInfo>();

            foreach (ConditionKeySet each in _key_set_list.Values)
            {
                if (each.Contains(rowSource))
                {
                    duplicates.Add(new DuplicateInfo(each.Condition, each.GetRecord(rowSource)));
                }
            }

            return(duplicates);
        }
示例#24
0
 /// <summary>
 /// 使用 FieldName。
 /// </summary>
 public void AddRecord(IRowSource rowSource, IEnumerable <string> fields)
 {
     if (_exclude_empty_key)
     {
         if (!_condition.IsEmptyKey(rowSource))
         {
             AddRecordByFieldName(rowSource, fields);
         }
     }
     else
     {
         AddRecordByFieldName(rowSource, fields);
     }
 }
示例#25
0
        private static bool IsValid(List <string> fields, IRowSource rowSource)
        {
            Dictionary <string, string> dup = new Dictionary <string, string>();

            foreach (string each in fields)
            {
                if (dup.ContainsKey(rowSource.GetFieldData(each)))
                {
                    return(false);
                }

                dup.Add(rowSource.GetFieldData(each), each);
            }

            return(true);
        }
示例#26
0
        public bool Validate(IRowSource Value)
        {
            //格過驗證。
            if (_skip_validate)
            {
                return(true);
            }

            List <DuplicateInfo> dups = _key_sets.GetDuplicate(Value);

            _prevous_result = dups;

            _key_sets.AddRecord(Value, _selected_fields);

            return(dups.Count <= 0);
        }
示例#27
0
        public DuplicateInfo GetDuplicateBy(ImportCondition cond, IRowSource rowSource)
        {
            if (!_key_set_list.ContainsKey(cond))
            {
                return(null);
            }

            ConditionKeySet keyset = _key_set_list[cond];

            if (keyset.Contains(rowSource))
            {
                return(new DuplicateInfo(keyset.Condition, keyset.GetRecord(rowSource)));
            }
            else
            {
                return(null);
            }
        }
示例#28
0
        private static string GetProcessKind(IProcess process)
        {
            if (process.GetType().GetInterfaces().Any(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(IExecutableWithResult <>)))
            {
                return("jobWithResult");
            }

            return(process switch
            {
                IEtlFlow _ => "flow",
                IEtlTask _ => "task",
                IRowSource _ => "source",
                IRowSink _ => "sink",
                IMutator _ => "mutator",
                IScope _ => "scope",
                IProducer _ => "producer",
                IExecutable _ => "job",
                _ => "unknown",
            });
示例#29
0
 public void SetViewContext(IViewContext viewContext, ViewInfo viewInfo)
 {
     ViewContext = viewContext;
     if (null == viewInfo)
     {
         BindingListView.ViewInfo = null;
     }
     else
     {
         IRowSource rowSource   = null;
         bool       viewChanged = true;
         if (null != ViewInfo)
         {
             if (ViewInfo.RowSourceName == viewInfo.RowSourceName)
             {
                 rowSource = RowSource;
                 if (ViewInfo.Name == viewInfo.Name)
                 {
                     viewChanged = false;
                 }
             }
         }
         rowSource = rowSource ?? viewContext.GetRowSource(viewInfo);
         BindingListView.SetViewAndRows(viewInfo, rowSource);
         if (viewChanged)
         {
             BindingListView.ClearTransformStack();
         }
         if (ViewContext != null && viewInfo.ViewGroup != null)
         {
             var viewLayoutList = ViewContext.GetViewLayoutList(viewInfo.ViewGroup.Id.ViewName(viewInfo.Name));
             if (null != viewLayoutList)
             {
                 var defaultLayout = viewLayoutList.FindLayout(viewLayoutList.DefaultLayoutName);
                 if (defaultLayout != null)
                 {
                     ApplyLayout(defaultLayout);
                 }
             }
         }
     }
     OnListChanged(new ListChangedEventArgs(ListChangedType.Reset, -1));
 }
示例#30
0
        public bool Validate(IRowSource Value)
        {
            if (!_activate_validator)
            {
                return(true);
            }

            if (_import_mode == ImportMode.Insert)
            {
                return(IsValid(_teacher_fields, Value));
            }
            else
            {
                if (_course_teachers.Contains(Value))
                {
                    return(IsValid(_teacher_fields, _course_teachers.GetRecord(Value), Value));
                }
                else
                {
                    return(IsValid(_teacher_fields, Value));
                }
            }
        }
示例#31
0
 public void Dispose()
 {
     reference        = null;
     rowSource        = null;
     filterDataSource = null;
 }
示例#32
0
        public override string Transform(string value, IRowSource row)
        {
            if (this.Regex != null) {
                var m = this.Regex.Match(value);
                if (m.Success) {
                    var placeHolderValues = new String[PlaceholderCount];
                    for (int i = 0; i < PlaceholderCount; ++i) {

                        if (i < m.Groups.Count) {
                            placeHolderValues[i] = m.Groups[i].Value;
                        } else {
                            placeHolderValues[i] = "";
                        }
                    }
                    return String.Format(Options.OutputFormat, placeHolderValues);
                }
            }

            if (Options.DefaultIfNotMatch) {
                return Options.DefaultValue;
            }

            return value;
        }
示例#33
0
 public String transform(String value, IRowSource row)
 {
     String transformed = value;
     foreach (ValueTransformer t in _pipeline) {
         transformed = t.Transform(transformed, row);
     }
     return transformed;
 }
示例#34
0
 public abstract String Transform(String value, IRowSource row);