Exemple #1
0
        /// <summary>
        /// [File:key]でファイル名のみを取得するなどの方法を提供。
        /// </summary>
        /// <param name="val"></param>
        /// <param name="rawler"></param>
        /// <returns></returns>
        public static string HeaderConvert(string val, RawlerBase rawler)
        {
            var d = val.Split(':');

            if (d.Length == 1)
            {
                return(string.Empty);
            }
            else
            {
                var    h = d.First();
                string v = string.Empty;
                v = KeyValueStore.GetValueByKey(rawler, d[1]);
                try
                {
                    switch (h)
                    {
                    case "File":
                        v = System.IO.Path.GetFileNameWithoutExtension(v);
                        break;

                    case "Directory":
                        v = System.IO.Path.GetDirectoryName(v);
                        break;

                    case "FullFile":
                        v = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(v), System.IO.Path.GetFileNameWithoutExtension(v));
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception ex)
                {
                    ReportManage.ErrReport(rawler, "値:" + val + "で" + ex.Message);
                }
                if (v == null)
                {
                    ReportManage.ErrReport(rawler, "値:" + h + "は、存在しない識別子です。" + val);
                }
                return(v);
            }
        }
Exemple #2
0
            public override string GetText(RawlerBase rawler)
            {
                string v = string.Empty;

                v = KeyValueStore.GetValueByKey(rawler, Key);
                try
                {
                    switch (Header)
                    {
                    case "File":
                        v = System.IO.Path.GetFileNameWithoutExtension(v);
                        break;

                    case "Directory":
                        v = System.IO.Path.GetDirectoryName(v);
                        break;

                    case "FullFile":
                        v = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(v), System.IO.Path.GetFileNameWithoutExtension(v));
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception ex)
                {
                    ReportManage.ErrReport(rawler, "値:" + Header + "で" + ex.Message);
                }
                if (v == null)
                {
                    ReportManage.ErrReport(rawler, "値:" + Header + "は、存在しない識別子です。" + v);
                }

                return(v);
            }
Exemple #3
0
 /// <summary>
 /// このクラスでの実行すること。
 /// </summary>
 /// <param name="runChildren"></param>
 public override void Run(bool runChildren)
 {
     if (keyValueStore == null)
     {
         keyValueStore = this.GetUpperRawler <KeyValueStore>();
     }
     if (keyValueStore != null)
     {
         if (string.IsNullOrEmpty(Value))
         {
             keyValueStore.SetKeyValue(Key, GetText());
         }
         else
         {
             keyValueStore.SetKeyValue(Key, Value);
         }
     }
     else
     {
         ReportManage.ErrUpperNotFound <KeyValueStore>(this);
     }
     SetText(GetText());
     base.Run(runChildren);
 }
Exemple #4
0
 public override string GetText(RawlerBase rawler)
 {
     return(KeyValueStore.GetValueByKey(rawler, Key));
 }