コード例 #1
0
        public ConnectivityModel(string umdurl, ushort umdport, string name, string winurl, ushort winport, ReceiveMsgDelegate rmCB, SendMsgDelegate smCB)
        {
            this.umdurl  = umdurl;
            this.umdport = umdport;
            this.name    = name;
            this.winurl  = winurl;
            this.winport = winport;

            if (rmCB != null)
            {
                rm = rmCB;
            }
            else
            {
                rm = new ReceiveMsgDelegate(MsgProcessor.ReceiveMessage);
            }

            if (smCB != null)
            {
                sm = smCB;
            }
            else
            {
                sm = new SendMsgDelegate(MsgProcessor.SendMessage);
            }

            InitConnections();
        }
コード例 #2
0
 public UMBackgroundWorker(ProgressChanged <O> pc, ReceiveMsgDelegate rcvMsg, SendMsgDelegate sm = null, ProcessMsgDelegateRXRaw pm = null)
 {
     this.pc     = pc;
     this.rcvMsg = rcvMsg;
     this.sm     = sm;
     this.pm     = pm;
 }
コード例 #3
0
 public void ReInit(ref SendMsgDelegate sm)
 {
     if (sm == null)
     {
         SendMsgDelegate msgSend = new SendMsgDelegate(SendMessage);
         sm = msgSend;
     }
     smsg = new SendMessages(sm);
 }
コード例 #4
0
 public ViewModelBase(SocketSettings srvSet, string name)
 {
     if (srvSet != null)
     {
         this.name = name;
         InitConnections(srvSet);
         sm     = new SendMsgDelegate(SendMessage);
         socSet = srvSet;
     }
 }
コード例 #5
0
 public ClientToServerConnection(SocketSettings socSet, ref SendMsgDelegate sm, ReceiveMsgDelegate rm)
 {
     Logger.Info($"{name} Client Connectng to server Connection: ws://{url}:{port}");
     this.url       = socSet.url;
     this.port      = socSet.port;
     this.name      = socSet.name;
     this.socSet    = socSet;
     this.rm        = rm;
     sm             = new SendMsgDelegate(SendCommandToServer);
     Logger.AppName = socSet.name;
 }
コード例 #6
0
        public FrmMain()
        {
            InitializeComponent();

            FrmClient1 objFrmClient1 = new FrmClient1();
            FrmClient2 objFrmClient2 = new FrmClient2();

            //5关联事件关联的处理方法
            //SendMsgEvent += objFrmClient1.ReceiveMsg;
            //SendMsgEvent += objFrmClient2.ReceiveMsg;
            SendMsgEvent += new SendMsgDelegate(objFrmClient1.ReceiveMsg);
            SendMsgEvent += new SendMsgDelegate(objFrmClient2.ReceiveMsg);

            objFrmClient1.Show();
            objFrmClient2.Show();
        }
コード例 #7
0
        public void Init(SocketSettings sockSet, ref SendMsgDelegate sm, ReceiveMsgDelegate rm = null)
        {
            Url          = sockSet.url;
            Port         = sockSet.port;
            name         = sockSet.name;
            this.sockSet = sockSet;
            Logger.Info($"Client Socket Connection Init: {name}");

            if (rm == null)
            {
                rm = new ReceiveMsgDelegate(MsgProcessor.ReceiveMessage);
            }

            srvr = new ClientToServerConnection(sockSet, ref sm, rm);
            smsg = new SendMessages(sm);
        }
コード例 #8
0
        // static UMBackgroundWorker<IMDMMessage>.ProgressChanged<IMDMMessage> main = null;
        public ConnectionVM(SocketSettings srvSet = null, ReceiveMsgDelegate rmsg = null, SendMsgDelegate smsg = null)// :base(main, "ConnectionVM")
        {
            if (srvSet != null)
            {
                srv = srvSet;
            }

            if (rmsg != null)
            {
                rm = rmsg;
            }

            if (smsg != null)
            {
                sm = smsg;
            }

            connectivityModel = new ConnectivityModel(srv.url, srv.port, srv.name, srv.clienturl, srv.clientport, rm, sm);
        }
コード例 #9
0
 public ManifestDetails(SendMsgDelegate SendMessage, ReceiveMsgDelegate ReceiveMessage, ProcessMsgDelegateRXRaw pm)
 {
     sm = SendMessage;
     rm = ReceiveMessage;
 }
コード例 #10
0
ファイル: Worker.cs プロジェクト: zackcheng7/ScopusFetcher
        private void downloadStep()
        {
            DataTable       worksheet  = Utils.GetDataTableFromExcel(inputFilePath, param.WSName);
            string          searchFunc = (searchType == SearchType.EID) ? "EID" : "REFEID";
            SendMsgDelegate dg         = new SendMsgDelegate(sendMsg);

            crawler.OpenPage();

            int successCount = 0;
            int failCount    = 0;

            try
            {
                foreach (DataRow row in worksheet.Rows)
                {
                    string EID  = row[param.EIDColumnName].ToString();
                    string code = row[param.CodeColumnName].ToString();

                    string downloadFileNameSuffix = (searchType == SearchType.EID) ? "_reference" : "_citation";
                    string downloadFileName       = $"{code}{downloadFileNameSuffix}";

                    MainForm.Mainform.Invoke(dg, $"開始下載檔案: EID '{EID}', 編號 '{code}'");

                    crawler.Query($"{searchFunc}({EID})");
                    crawler.Wait();

                    bool success = crawler.ClickAll();

                    if (!success)
                    {
                        goto Failed;
                    }

                    if (searchType == SearchType.EID)
                    {
                        crawler.CheckRef();
                        success = crawler.ClickAll();

                        if (!success)
                        {
                            goto Failed;
                        }
                    }

                    crawler.DownloadCSV(downloadFileName);
                    successCount += 1;
                    MainForm.Mainform.Invoke(dg, $"下載檔案 {downloadFileName}.csv 完成");

End:
                    crawler.ReturnSearchPage();
                    crawler.Wait();
                    continue;

Failed:
                    failCount += 1;
                    MainForm.Mainform.Invoke(dg, $"下載檔案 {downloadFileName}.csv 失敗");
                    goto End;
                }
            }
            catch (Exception ex)
            {
                MainForm.Mainform.Invoke(dg, $"錯誤: {ex.Message}");
                Close();
                return;
            }

            MainForm.Mainform.Invoke(dg, $"全部下載完成: 共 {successCount} 份檔案, {failCount} 份無法下載");
            Close();
        }
コード例 #11
0
 public MsgProcessor(SendMsgDelegate sm, isaReceiveMessageCallback cb) //, isaSendMessageCallback sm)
 {
     ReceivedMsg += cb.ReceiveMessage;
     SendMsg     += new TxMsg(sm);
 }
コード例 #12
0
ファイル: bot.cs プロジェクト: Yashikvlada/tcpip_ex1_sockets
 public Bot(SendMsgDelegate sendMsg)
 {
     _phrases = new List <string>();
     _sendMsg = sendMsg;
 }
コード例 #13
0
 public SendMessages(SendMsgDelegate smd)
 {
     cbSendMsg = smd;
 }
コード例 #14
0
 public ClientSocketConnection(SocketSettings sockSet, ref SendMsgDelegate sm, ReceiveMsgDelegate rm = null)
 {
     Init(sockSet, ref sm, rm);
 }