コード例 #1
0
ファイル: Dispatch.cs プロジェクト: cnfixit/NovelSpider
 /// <summary>
 /// 初始化存储UI
 /// </summary>
 private void InitStorageUI()
 {
     try
     {
         string   path  = Constant.STORAGE_RULE_PATH;
         string[] files = Directory.GetFiles(path, "*.dll");
         this.StorageTabControl.TabPages.Clear();
         foreach (string s in files)
         {
             string    methodname = Function.GetTargetMethodName(s);
             IStorager ist        = Function.GetStoragerPluginInterface(s);
             if (!string.IsNullOrEmpty(methodname) && ist != null)
             {
                 TabPage tp = new TabPage(methodname);
                 tp.Tag = ist;//保存接口备用
                 this.StorageTabControl.TabPages.Add(tp);
                 ist.InitUI(tp);
             }
             else
             {
                 continue;
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
コード例 #2
0
 public Manager(ILogger <Manager> logger, IConfiguration configuration, IDownloader downloader, ISerializer serializer, IStorager storager)
 {
     _logger          = logger;
     _configuration   = configuration;
     this._downloader = downloader;
     this._serializer = serializer;
     this._storager   = storager;
 }
コード例 #3
0
ファイル: Dispatch.cs プロジェクト: cnfixit/NovelSpider
 private void btnOK_Click(object sender, EventArgs e)
 {
     foreach (ListViewItem lvi in LVjob.Items)
     {
         this._Jobs.Add(lvi.Tag as JobItem);
     }
     this._iStorager = this.StorageTabControl.SelectedTab.Tag as IStorager;
 }
コード例 #4
0
ファイル: Function.cs プロジェクト: cnfixit/NovelSpider
        /// <summary>
        /// 获取指定动态库IStorager实例
        /// </summary>
        /// <param name="filepath"></param>
        /// <returns></returns>
        public static IStorager GetStoragerPluginInterface(string filepath)
        {
            if (!File.Exists(filepath))
            {
                return(null);
            }

            Type      type     = null;
            IStorager ist      = null;
            string    fullname = string.Empty;

            try
            {
                Assembly ass = Assembly.LoadFile(filepath);
                Type[]   tps = ass.GetTypes();


                foreach (Type t in tps)
                {
                    if (t.IsSubclassOf(typeof(Storager)))
                    {
                        fullname = t.FullName;
                        type     = t;
                        break;
                    }
                }

                if (!string.IsNullOrEmpty(fullname))
                {
                    ist = ass.CreateInstance(fullname) as Storager;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(ist);
        }
コード例 #5
0
        private void StartToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                Log.PrintLog("开始调度");
                Dispatch dispatch = new Dispatch();
                if (dispatch.ShowDialog() == DialogResult.OK)
                {
                    foreach (JobItem job in dispatch.Jobs)
                    {
                        ICollector ic = Function.GetCollectorPluginInterface(job.AssemblyPath);
                        ist = dispatch.iStorager;//保存存储接口

                        if (ic == null)
                        {
                            throw new Exception("Invalid PluginInterface.");
                        }

                        ic.NovelListHasGot      += new NovelListGotEventHandler(ip_NovelListHasGot);
                        ic.NovelInfoHasGot      += new NovelInfoGotEventHandler(ip_NovelInfoHasGot);
                        ic.VolumeListHasGot     += new VolumeListEventHandler(ip_VolumeListHasGot);
                        ic.ChapterListHasGot    += new ChapterListGotEventHandler(ip_ChapterListHasGot);
                        ic.ChapterHasGot        += new ChapterGotEventHandler(ip_ChapterHasGot);
                        ic.ProcedureHasFinished += new ProcedureFinishEventHandler(ip_ProcedureHasFinished);

                        ic.Run(job.TargetSite);
                        this.StartToolStripMenuItem.Enabled = false;
                    }
                }
                Log.PrintLog("结束调度");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #6
0
 public ThisAppStorage(IStorager storager) : base(storager)
 {
 }