Beispiel #1
0
        public override void Run(bool runChildren)
        {
            var data = (IData)this.GetUpperInterface <IData>();

            if (data == null)
            {
                ReportManage.ErrUpperNotFound <IData>(this);
            }

            var currentRow = data.GetCurrentDataRow();
            var attribute  = Attribute.Convert(this);

            SetText(GetText());
            if (currentRow.DataDic.TryGetValue(attribute, out List <string> list) == false)
            {
                base.Run(runChildren);
            }
            else
            {
                if (list.Any() == false)
                {
                    base.Run(runChildren);
                }
            }
        }
        /// <summary>
        /// このクラスでの実行すること。
        /// </summary>
        /// <param name="runChildren"></param>
        public override void Run(bool runChildren)
        {
            System.Text.RegularExpressions.Regex r  = new System.Text.RegularExpressions.Regex("<input [^>]*>");
            System.Text.RegularExpressions.Regex r2 = new System.Text.RegularExpressions.Regex(@"(\w)*\s*=\s*" + "\"([^\"]*)\"");

            var page = (IInputParameter)this.GetUpperInterface <IInputParameter>();

            if (page == null)
            {
                ReportManage.ErrUpperNotFound <IInputParameter>(this);
                return;
            }

            List <KeyValue> list = new List <KeyValue>();

            foreach (System.Text.RegularExpressions.Match item in r.Matches(GetText()))
            {
                var dic = GetParameter(item.Value);
                if (dic.ContainsKey("type") && dic["type"] == "hidden")
                {
                    if (dic.ContainsKey("name") && dic.ContainsKey("value"))
                    {
                        page.AddParameter(dic["name"], dic["value"]);
                        list.Add(new KeyValue()
                        {
                            Key = dic["name"], Value = dic["value"]
                        });
                    }
                }
            }
            base.Run(runChildren);
        }
Beispiel #3
0
        public override void Run(bool runChildren)
        {
            var g = this.GetUpperRawler <GroupBy>();

            if (g == null)
            {
                ReportManage.ErrUpperNotFound <GroupBy>(this);
                return;
            }
            RunChildrenForArray(runChildren, g.GetCurrentKeyValue().Value);
        }
Beispiel #4
0
        public override void Run(bool runChildren)
        {
            var g = this.GetUpperRawler <GroupBy>();

            if (g == null)
            {
                ReportManage.ErrUpperNotFound <GroupBy>(this);
                return;
            }
            SetText(g.GetCurrentKeyValue().Key);
            base.Run(runChildren);
        }
Beispiel #5
0
        public override void Run(bool runChildren)
        {
            var d = this.GetUpperRawler <Data>();

            if (d == null)
            {
                ReportManage.ErrUpperNotFound <Data>(this);
            }
            else
            {
            }
            base.Run(runChildren);
        }
Beispiel #6
0
        /// <summary>
        /// DataWriteの共通呼び出し
        /// </summary>
        /// <param name="rawler"></param>
        /// <param name="attribute"></param>
        /// <param name="value"></param>
        /// <param name="type"></param>
        /// <param name="attributeType"></param>
        public static void DataWrite(RawlerBase rawler, string attribute, string value, DataWriteType type, DataAttributeType attributeType)
        {
            var d = (IData)rawler.GetUpperInterface <IData>();

            if (d != null)
            {
                d.DataWrite(attribute, value, type, attributeType);
            }
            else
            {
                ReportManage.ErrUpperNotFound <IData>(rawler);
            }
        }
Beispiel #7
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 #8
0
        public override void Run(bool runChildren)
        {
            var file = this.GetAncestorRawler().Where(n => n is FileReadLines);

            if (file.Count() > 0)
            {
                SetText(file.First().Text);
            }
            else
            {
                ReportManage.ErrUpperNotFound <FileReadLines>(this);
            }
            base.Run(runChildren);
        }
Beispiel #9
0
        /// <summary>
        /// 指定したキーが上流のKeyValueStoreにあるかを調べる
        /// </summary>
        /// <param name="rawler"></param>
        /// <param name="keys"></param>
        /// <returns></returns>
        public static bool ContainsKey(RawlerBase rawler, params string[] keys)
        {
            var r = rawler.GetUpperRawler <KeyValueStore>();

            if (r != null)
            {
                return(keys.All((n) => r.dic.ContainsKey(n)));
            }
            else
            {
                ReportManage.ErrUpperNotFound <KeyValueStore>(rawler);
            }
            return(false);
        }
Beispiel #10
0
        public override void Run(bool runChildren)
        {
            var loop = this.GetUpperRawler <Loop>();

            if (loop != null)
            {
                loop.Break();
            }
            else
            {
                ReportManage.ErrUpperNotFound <Loop>(this);
            }
            base.Run(runChildren);
        }
Beispiel #11
0
 public override void Run(bool runChildren)
 {
     if (hash == null)
     {
         hash = this.GetUpperRawler <HashSet>();
         if (hash == null)
         {
             ReportManage.ErrUpperNotFound <HashSet>(this);
             return;
         }
     }
     hash.AddHash(GetText());
     base.Run(runChildren);
 }
Beispiel #12
0
 public override void Run(bool runChildren)
 {
     SetText(GetText());
     if (hash == null)
     {
         hash = this.GetUpperRawler <HashSet>();
         if (hash == null)
         {
             ReportManage.ErrUpperNotFound <HashSet>(this);
             return;
         }
     }
     if (hash.CheckContains(GetText()) == Result)
     {
         base.Run(runChildren);
     }
 }
Beispiel #13
0
        /// <summary>
        /// このクラスでの実行すること。
        /// </summary>
        /// <param name="runChildren"></param>
        public override void Run(bool runChildren)
        {
            var page = (IInputParameter)this.GetUpperInterface <IInputParameter>();

            if (page == null)
            {
                ReportManage.ErrUpperNotFound <IInputParameter>(this);
                return;
            }
            string key = this.Key;

            if (KeyTree != null)
            {
                key = RawlerBase.GetText(this.Parent.Text, KeyTree, this.Parent);
            }
            else
            {
                key = key.Convert(this);
            }

            if (Value == null)
            {
                if (AddType == AddInputParameterType.replece)
                {
                    page.ReplaceParameter(key, GetText());
                }
                else
                {
                    page.AddParameter(key, GetText());
                }
            }
            else
            {
                if (AddType == AddInputParameterType.replece)
                {
                    page.ReplaceParameter(key, Value.Convert(this));
                }
                else
                {
                    page.AddParameter(key, Value.Convert(this));
                }
            }

            base.Run(runChildren);
        }
Beispiel #14
0
        public HttpClient GetWebClient()
        {
            HttpClient client = this.GetUpperRawler <HttpClient>();

            if (client == null)
            {
                ReportManage.ErrUpperNotFound <HttpClient>(this);
                ReportManage.ErrReport(this, "新しいHttpClientを作成します");
                client = new HttpClient();
            }

            if (useReferer)
            {
                if (pastUrl == string.Empty)
                {
                    var pages = this.GetUpperRawler <Page>();

                    client.Referer = pages?.GetCurrentUrl();
                }
                else
                {
                    client.Referer = pastUrl;
                }
                if (referer != null && referer.Length > 0)
                {
                    client.Referer = referer;
                }
            }
            else
            {
                client.Referer = string.Empty;
            }
            var enc = GetEncoding();

            if (enc != null)
            {
                client.Encoding = encoding;
            }

            client.HttpHeaders = HttpHeaders;

            return(client);
        }
Beispiel #15
0
        public override void Run(bool runChildren)
        {
            var page = this.GetUpperRawler <Page>();

            if (page == null)
            {
                ReportManage.ErrUpperNotFound <Page>(this);
            }
            var val = GetText();

            if (Value != null)
            {
                val = Value.Convert(this);
            }
            if (page != null)
            {
                page.AddHttpHeader(this.Key.Convert(this), val);
            }
            base.Run(runChildren);
        }
Beispiel #16
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);
 }
Beispiel #17
0
        public override void Run(bool runChildren)
        {
            var pages = this.GetAncestorRawler().Where(n => n is Page);

            if (pages.Count() > 0)
            {
                var html = Html.Convert(this);
                if (string.IsNullOrEmpty(html))
                {
                    html = GetText();
                }
                var targetName = TargetName.Convert(this);
                if (string.IsNullOrEmpty(targetName) == false)
                {
                    if (pages.Where(n => n.Name == targetName).Any())
                    {
                        pages.Where(n => n.Name == targetName).First().SetText(html);
                    }
                    else
                    {
                        ReportManage.ErrReport(this, "TargetName「" + targetName + "」が見つかりません");
                    }
                }
                else
                {
                    pages.First().SetText(html);
                }
                SetText(html);
            }
            else
            {
                ReportManage.ErrUpperNotFound <Page>(this);
            }

            base.Run(runChildren);
        }
        /// <summary>
        /// このクラスでの実行すること。
        /// </summary>
        /// <param name="runChildren"></param>
        public override void Run(bool runChildren)
        {
            System.Text.RegularExpressions.Regex r  = new System.Text.RegularExpressions.Regex("<input [^>]*>");
            System.Text.RegularExpressions.Regex r2 = new System.Text.RegularExpressions.Regex(@"(\w)*\s*=\s*" + "\"([^\"]*)\"");

            var page = (IInputParameter)this.GetUpperInterface <IInputParameter>();

            if (page == null)
            {
                ReportManage.ErrUpperNotFound <IInputParameter>(this);
                return;
            }

            foreach (System.Text.RegularExpressions.Match item in r.Matches(GetText()))
            {
                var dic = GetParameter(item.Value);
                if (dic.ContainsKey("type") && dic["type"] == "radio")
                {
                    if (dic.ContainsKey("name") && dic.ContainsKey("value") && dic.ContainsKey("checked"))
                    {
                        page.AddParameter(dic["name"], dic["value"]);
                    }
                }
                else if (dic.ContainsKey("type") && dic["type"] == "submit")
                {
                }
                else if (dic.ContainsKey("type") && dic["type"] == "text")
                {
                    if (dic.ContainsKey("name") && dic.ContainsKey("value"))
                    {
                        page.AddParameter(dic["name"], dic["value"]);
                    }
                }
                else if (dic.ContainsKey("type") && dic["type"] == "hidden")
                {
                    if (dic.ContainsKey("name") && dic.ContainsKey("value"))
                    {
                        page.AddParameter(dic["name"], dic["value"]);
                    }
                }
                else
                {
                    //if (dic.ContainsKey("name") && dic.ContainsKey("value"))
                    //{
                    //    page.AddParameter(dic["name"], dic["value"]);
                    //}
                }
            }
            foreach (var item in GetText().ToHtml().GetTag("select"))
            {
                var para    = GetParameter(item.Parameter);
                var seleted = item.Inner.ToHtml().GetTag("option").Where(n => n.Parameter.Contains("selected"));
                if (para.ContainsKey("name"))
                {
                    string val = string.Empty;
                    if (seleted != null && seleted.Any())
                    {
                        val = GetParameter(seleted.First().Parameter).GetValueOrDefault("value", string.Empty);
                    }
                    else
                    {
                        if (para.ContainsKey("value"))
                        {
                            val = para["value"];
                        }
                    }
                    page.AddParameter(para["name"], val);
                }
            }
            foreach (var item in GetText().ToHtml().GetTag("textarea"))
            {
                var para = GetParameter(item.Parameter);
                if (para.ContainsKey("name"))
                {
                    string val = string.Empty;
                    if (para.ContainsKey("value"))
                    {
                        val = para["value"];
                    }
                    page.AddParameter(para["name"], val);
                }
            }

            base.Run(runChildren);
        }