コード例 #1
0
        void Connection_Update(object sender, FlowLib.Events.FmdcEventArgs e)
        {
            switch (e.Action)
            {
            case Actions.TransferStarted:
                Transfer trans = e.Data as Transfer;
                if (trans != null)
                {
                    // Here we bind transfer to our data collector
                    stats = new GeneralProtocolDataCollector(trans);
                    if (trans.Protocol == null)
                    {
                        trans.Protocol = new FlowLib.Protocols.AdcProtocol(trans);
                        trans.Listen();
                        transferManager.AddTransfer(trans);
                    }

                    trans.Protocol.ChangeDownloadItem += new FmdcEventHandler(Protocol_ChangeDownloadItem);
                    trans.Protocol.RequestTransfer    += new FmdcEventHandler(Protocol_RequestTransfer);
                    trans.ProtocolChange += new FmdcEventHandler(trans_ProtocolChange);
                    e.Handled             = true;
                }
                break;
            }
        }
コード例 #2
0
 protected void DoUPnPExternalRecieveAccess_Update(object sender, FmdcEventArgs e)
 {
     switch (e.Action)
     {
     case Actions.TransferStarted:
         Transfer trans = e.Data as Transfer;
         if (trans != null)
         {
             if (trans.Protocol == null)
             {
                 trans.Protocol = new FlowLib.Protocols.TransferNmdcProtocol(trans);
                 trans.Listen();
                 transferManager.AddTransfer(trans);
             }
             trans.Protocol.RequestTransfer += new FmdcEventHandler(DoUPnPExternalRecieveAccess_RequestTransfer);
             e.Handled = true;
         }
         break;
     }
 }
コード例 #3
0
        private void HubOutgoingConnectionRequest(object sender, OutgoingConnectionRequestEventArgs e)
        {
            var hubConnection = (HubConnection)sender;

            var ea = new ConnectionRequestEventArgs
            {
                UserNickname  = "",
                Address       = e.Message.SenderAddress,
                HubConnection = hubConnection
            };

            OnConnectionRequest(ea);

            if (ea.Cancel)
            {
                return;
            }

            TransferConnection transfer;

            try
            {
                transfer = new TransferConnection(e.Message.SenderAddress)
                {
                    AllowedToConnect = true,
                    Source           = new Source {
                        HubAddress = hubConnection.RemoteAddressString
                    }
                };

                if (Settings.NetworkInterface != null)
                {
                    transfer.LocalAddress = new IPEndPoint(Settings.NetworkInterface, 0);
                }
            }
            catch (Exception x)
            {
                Logger.Error("Unable to create outgoing transfer thread {0}", x.Message);
                return;
            }

            TransferManager.AddTransfer(transfer);
            transfer.FirstMessages = new[]
            {
                new MyNickMessage {
                    Nickname = hubConnection.Settings.Nickname
                }.Raw,
                new LockMessage {
                    ExtendedProtocol = true
                }.Raw
            };
            transfer.StartAsync();
        }
コード例 #4
0
        public IActionResult CreateTransfer([FromBody] TransferForm form)
        {
            var error = new Error();


            var transferId = _transferManager.AddTransfer(form.MapToCore(), ref error);

            if (error.ErrorCode != ErrorCode.OKAY)
            {
                return(BadRequest(error.Message));
            }

            return(Ok(transferId));
        }
コード例 #5
0
        private void TcpConnectionListenerIncomingConnection(object sender, IncomingConnectionEventArgs e)
        {
            if (e.Socket.Connected)
            {
                var connLimit = Settings.ConnectionsLimit;

                if (connLimit != 0 && TransferManager.TransfersCount >= connLimit)
                {
                    Logger.Warn("Connection limit {0} reached, dropping incoming connection", connLimit);
                    return;
                }

                e.Handled = true;
                var transfer = new TransferConnection(e.Socket);
                TransferManager.AddTransfer(transfer);
                transfer.StartAsync();
            }
            else
            {
                Logger.Warn("We have disconnected incoming socket");
            }
        }
コード例 #6
0
ファイル: TransferController.cs プロジェクト: huzhijin/U8API
        public HttpResponseMessage AddTransfer(string token, string json)
        {
            string        errMsg = "";
            ReturnMessage msg    = new ReturnMessage();

            try
            {
                ReceiveLog receive = new ReceiveLog();
                receive.uuid          = Guid.NewGuid();
                receive.receiveData   = json;
                receive.interfaceCode = "Transfer";
                receive.interfaceDesc = "人事调动单新增";
                receive.op            = "add";

                vouMag = (VoucherManager)HttpContext.Current.Application.Get(token);
                if (vouMag == null)
                {
                    msg.Success = false;
                    msg.Msg     = "参数token无效或已过期";
                    msg.Code    = 500;
                }
                else
                {
                    ReceiveLogManager logManager = new ReceiveLogManager(vouMag.UFDataConnstringForNet);
                    logManager.AddReceiveLog(receive, ref errMsg);
                    TransferManager  transferManager = new TransferManager(vouMag.UFDataConnstringForNet);
                    TransferRegister transfer        = (TransferRegister)JsonConvert.DeserializeObject(json, typeof(TransferRegister));
                    int i = transferManager.AddTransfer(transfer, ref errMsg);
                    if (i >= 1)
                    {
                        //msg.Success = true;
                        //dynamic c = new { code = transferManager.ccode };
                        //msg.Data = JsonConvert.SerializeObject(c);
                        //msg.Code = 200;
                        //msg.Msg = "新增成功";
                        int q = transferManager.auditTransfer(transferManager.ccode, transfer, ref errMsg);
                        if (q >= 1)
                        {
                            msg.Success = true;
                            msg.Code    = 200;
                            dynamic c = new { code = transferManager.ccode };
                            msg.Data = JsonConvert.SerializeObject(c);
                            msg.Msg  = "审核成功";
                        }
                        else
                        {
                            msg.Success = false;
                            msg.Code    = 500;
                            msg.Msg     = "审核失败:" + errMsg;
                        }
                    }
                    else
                    {
                        msg.Success = false;
                        msg.Code    = 500;
                        msg.Msg     = "新增失败" + errMsg;
                    }
                    receive = logManager.getReturnDesc(receive, msg);
                    logManager.UpdateReceiveLog(receive, ref errMsg);
                }
                HttpContext.Current.Application.Remove(vouMag.GetGUID);
                string str = msg.ToJson();
                return(new HttpResponseMessage {
                    Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json")
                });
            }
            catch (Exception ex)
            {
                msg.Success = false;
                msg.Code    = 500;
                msg.Msg     = ex.Message.ToString();
                string str = msg.ToJson();
                return(new HttpResponseMessage {
                    Content = new StringContent(str, Encoding.GetEncoding("UTF-8"), "application/json")
                });
            }
        }