Пример #1
0
 public async override Task Run (IJubenRunningControler runningMen,  Action completed, string logTitle)
 {
    await base.Run(runningMen,  null,logTitle);
     try
     {
         runningMen.RecordLog(string.Format("{4}{3}\t{0}{1}{2}", this.Key, this.OperatorType.GetDisplay(), this.Value, this.ToString(),logTitle ),
             LogLevel.Debug);
         var value = runningMen.GetValue(Key);
         if (Check(value))
         {
             runningMen.RecordLog(string.Format("条件满足,跳出剧集;{0}{1}{2}", this.Key, this.OperatorType.GetDisplay(), value),LogLevel.Info);
             runningMen.JumpToNextJuji();
         } else
         {
             runningMen.RecordLog(string.Format("条件不符,不能跳出当前剧集;{0}{1}{2}", this.Key, this.OperatorType.GetDisplay(), value), LogLevel.Info);
         }
             
     } catch(Exception e)
     {
         runningMen.RecordLog( string.Format("{1}异常,{0}, {2}", Key, this.ToString(), e), LogLevel.Error); 
         throw;
     }
     
     completed();
 }
Пример #2
0
        public async  override Task Run (IJubenRunningControler runningMen,  Action completed, string logTitle)
        {
           await base.Run(runningMen, null,logTitle );
            
            try
            {
                var doc = runningMen.GetHtmlDocument();
           
               //var ex = (System.Runtime.InteropServices.Expando.IExpando)doc;
               //var proName =  string.Format("TakeValue_{0}", this.GetHashCode());
               //var piform = ex.AddProperty(proName);
               //piform.SetValue(browser.Document , this, null);
               //var fullScript = string.Format(@"function TakeData{2}() {{ {1}  }} document.{0}.Value = TakeData{2}();", proName, Script, runningMen.GetHashCode());
               //browser.CallScript(fullScript);

               var proName = string.Format("TakeValue_{0}", this.GetHashCode());
               var script = string.Format(@"function TakeData{2}() {{ {1}  }} 
document.{0} = TakeData{2}();", proName, Script, runningMen.GetHashCode());
                 
                runningMen.RecordLog(logTitle +  this.ToString() + "\t" + script , LogLevel.Debug);
                runningMen.CallScript(script);
               var value = doc.GetType().InvokeMember(proName, BindingFlags.GetProperty, null, doc, new object[] { });
                if(IsSummarize)
                {
                    var oldValue = runningMen.GetValue(Key);
                    int oldCount = string.IsNullOrEmpty(runningMen.GetValue(Key))?0: Convert.ToInt32(oldValue);
                    oldCount += Convert.ToInt32(value);
                    runningMen.SetValue(Key, oldCount.ToString());
                }else
                    runningMen.SetValue(Key, value == null ?"" : value.ToString());
 
                    runningMen.RecordLog( string.Format( "提取到[{0}]={1}",Key,value), LogLevel.Info);
               
            } catch(Exception e)
            {
                runningMen.RecordLog(string.Format("提取[{0}]异常:{1}", Key, e), LogLevel.Error); 
                throw;
            }

           completed();
 
        }