Beispiel #1
0
        public override void Run(bool runChildren)
        {
            currentDataRow = new DataRowObject();
            SetText(GetText());
            base.Run(runChildren);

            if (MustAttributes.IsNullOrEmpty() == false)
            {
                var must = MustAttributes.Split(',');
                if (currentDataRow.Attributes.Intersect(must).Count() == must.Count())
                {
                    Data.AddDataRow(this, currentDataRow);
                }
            }
            else
            {
                Data.AddDataRow(this, currentDataRow);
            }
            if (currentDataRow.IsDataNull())
            {
                if (EmptyTree != null)
                {
                    EmptyTree.SetParent(this);
                    EmptyTree.Run();
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// AddDataRowの共通呼び出し。
        /// </summary>
        /// <param name="rawler"></param>
        /// <param name="datarow"></param>
        public static void AddDataRow(RawlerBase rawler, DataRowObject datarow)
        {
            var r = (IDataRows)rawler.GetUpperInterface <IDataRows>();

            if (r != null)
            {
                r.AddDataRow(datarow);
            }
            else
            {
                ReportManage.ErrUpperNotFound <IDataRows>(rawler);
            }
        }
Beispiel #3
0
 public void ChangeCurrentDataRow(string key)
 {
     if (dataDic.ContainsKey(key))
     {
         currentDataRow = dataDic[key];
     }
     else
     {
         currentDataRow = new DataRowObject();
         currentDataRow.AddData("Key", key);
         dataDic.Add(key, currentDataRow);
         dataList.Add(currentDataRow);
     }
 }
Beispiel #4
0
 public void NextDataRow(DataRowObject cDataRow)
 {
     ReportManage.Report(this, "NextDataRow");
     if (Commited != null)
     {
         Commited(this, new EventDataRow(cDataRow));
     }
     if (FileSaveMode == FileSaveMode.Sequential)
     {
         File?.SequentialWriteLine(CreateSaveOneLine(cDataRow, SaveFileType));
     }
     else
     {
         dataList.Add(cDataRow);
     }
     currentDataRow = new DataRowObject();
 }
Beispiel #5
0
        public string CreateSaveOneLine(DataRowObject row, FileType ftype)
        {
            string line = string.Empty;

            switch (ftype)
            {
            case FileType.Tsv:
                line = CreateTsvLine(row);
                break;

            case FileType.Json:
                line = Newtonsoft.Json.Linq.JObject.FromObject(row).ToString(Newtonsoft.Json.Formatting.None);
                break;

            case FileType.LTsv:
                line = row.ToLtsv();
                break;

            default:
                break;
            }
            return(line);
        }
Beispiel #6
0
        private string CreateTsvLine(DataRowObject row)
        {
            StringBuilder sb = new StringBuilder();

            foreach (var item2 in order)
            {
                if (row.DataDic.ContainsKey(item2))
                {
                    var item = row.DataDic[item2];
                    if (item.First() != null)
                    {
                        var line = item.Select(n => n.ReadLines(true).Select(m => m.Replace("\t", " ").Trim()).JoinText(" ")).JoinText(",");
                        sb.Append(line);
                    }
                }
                sb.Append("\t");
            }
            var kList = row.DataDic.Keys.Except(order);

            if (kList.Any())
            {
                foreach (var item in kList)
                {
                    var r = row.DataDic[item].Select(n => n.ReadLines(true).Select(m => m.Replace("\t", " ").Trim()).JoinText(" ")).JoinText(",");
                    if (item.Length > 0 & r.Length > 0)
                    {
                        sb.Append(item + ":" + r);
                    }
                    else
                    {
                        sb.Append(r);
                    }
                    sb.Append("\t");
                }
            }
            return(sb.ToString());
        }
Beispiel #7
0
        public override void Run(bool runChildren)
        {
            FileInit();
            base.Run(runChildren);
            if (fileSaveMode == FileSaveMode.Completed)
            {
                if (File != null)
                {
                    File.WriteLines(CreateSaveLines(SaveFileType));
                }
            }
            if (FileSaveMode == FileSaveMode.Sequential)
            {
                File.Close();
            }

            if (EndDataClear)
            {
                dataDic.Clear();
                dataList.Clear();
                currentDataRow = new DataRowObject();
                dataList.Add(currentDataRow);
            }
        }
Beispiel #8
0
 /// <summary>
 /// DataRowに関するEventArgs
 /// /// </summary>
 /// <param name="row"></param>
 public EventDataRow(DataRowObject row)
     : base()
 {
     DataRow = row;
 }
Beispiel #9
0
 public virtual void AddDataRow(DataRowObject datarow)
 {
     currentDataRow.UpDate(datarow);
     NextDataRow();
 }
Beispiel #10
0
 public void AddDataRow(DataRowObject datarow)
 {
     list.Enqueue(datarow);
 }
Beispiel #11
0
 public void UpDate(DataRowObject row)
 {
     dataTypeDic = row.dataTypeDic;
     dataDic     = row.dataDic;
 }