Exemplo n.º 1
0
        public async void TestSetup()
        {
            m_loggingContext = new LoggingContext(Guid.NewGuid());
            var data = TestHelper.CreateApplicationEndpoint();

            m_mockEventChannel = data.EventChannel;
            m_restfulClient    = data.RestfulClient;

            ApplicationEndpoint applicationEndpoint = data.ApplicationEndpoint;
            await applicationEndpoint.InitializeAsync(m_loggingContext).ConfigureAwait(false);

            await applicationEndpoint.InitializeApplicationAsync(m_loggingContext).ConfigureAwait(false);

            IConversation conversation = null;

            applicationEndpoint.HandleIncomingAudioVideoCall += (sender, args) => conversation = args.NewInvite.RelatedConversation;

            TestHelper.RaiseEventsFromFile(m_mockEventChannel, "Event_IncomingAudioCall.json");
            TestHelper.RaiseEventsFromFile(m_mockEventChannel, "Event_ConversationConnected_WithAudio.json");
            TestHelper.RaiseEventsFromFile(m_mockEventChannel, "Event_AudioVideoConnected.json");

            m_restfulClient.HandleRequestProcessed     +=
                (sender, args) => m_transferOperationId = TestHelper.RaiseEventsOnHttpRequest(args, DataUrls.Transfer, HttpMethod.Post, "Event_TransferStarted.json", m_mockEventChannel);

            m_transfer = await conversation.AudioVideoCall.TransferAsync(new SipUri("sip:[email protected]"), null, m_loggingContext).ConfigureAwait(false);
        }
Exemplo n.º 2
0
        public void Supprimer(ITransfer transfer)
        {
            using (_monFtp = new Ftp())
            {
                _monFtp.Connect(_maConfig.Host, _maConfig.Port);
                _monFtp.Login(_maConfig.Login, _maConfig.MotDePass);

                string resteChemin = MethodesGlobales.GetCheminServerSansRacinne(transfer.GetPath(), _maConfig.GetUriChaine());

                if (string.IsNullOrEmpty(resteChemin))
                {
                    VariablesGlobales._leLog.LogCustom("Vous ne pouvez supprimer le répertoire racinne !");
                    MessageBox.Show("Vous ne pouvez supprimer le répertoire racinne !");
                }
                else
                {
                    if (transfer.EstUnDossier())
                    {
                        _monFtp.DeleteFolder(resteChemin);
                    }
                    else
                    {
                        _monFtp.DeleteFile(resteChemin);
                    }
                }

                _monFtp.Close();
            }
        }
        public void Test_Transfer_To_User_Wallet_Successful()
        {
            SortedDictionary <String, Object> receiver = new SortedDictionary <String, Object>();

            receiver.Add("name", "Adny Lee");
            receiver.Add("phoneNumber", "+2348131393827");
            receiver.Add("type", "USER");


            SortedDictionary <String, Object> param = new SortedDictionary <String, Object>();

            param.Add("amount", "100");
            param.Add("country", "NG");
            param.Add("currency", "NGN");
            param.Add("reason", "transfer reason message");
            param.Add("receiver", receiver);
            param.Add("reference", Util.generateTransactionRefrenceNo());

            String paramString = Util.mapToJsonString(param);
            String signature   = Util.calculateHMAC(paramString, PRIVATEKEY);

            connectionClient = new ConnectionClient(BASEURL, Util.getHeader(signature, MERCHANTID));
            transaction      = new Transfer(connectionClient);

            JObject response = transaction.transferToWallet(param).Result;

            walletTransferUserStatusInput = (JObject)response.GetValue("data");
            Assert.AreEqual("SUCCESSFUL", response.GetValue("message").ToString());
        }
        public void Test_Transfer_To_Bank_Successful()
        {
            SortedDictionary <String, Object> receiver = new SortedDictionary <String, Object>();

            receiver.Add("bankAccountNumber", "22222222222222");
            receiver.Add("bankCode", "058");
            receiver.Add("name", "test_20191123132233");

            SortedDictionary <String, Object> param = new SortedDictionary <String, Object>();

            param.Add("amount", "100");
            param.Add("country", "NG");
            param.Add("currency", "NGN");
            param.Add("reason", "transfer reason message");
            param.Add("receiver", receiver);
            param.Add("reference", Util.generateTransactionRefrenceNo());

            String paramString = Util.mapToJsonString(param);
            String signature   = Util.calculateHMAC(paramString, PRIVATEKEY);

            connectionClient = new ConnectionClient(BASEURL, Util.getHeader(signature, MERCHANTID));
            transaction      = new Transfer(connectionClient);

            JObject response = transaction.transferToBank(param).Result;

            bankTransferStatusInput = (JObject)response.GetValue("data");
            String message = response.GetValue("message").ToString();

            Assert.AreEqual(message, "SUCCESSFUL");
        }
Exemplo n.º 5
0
    /// <summary>Add SimpleS3 services to a service collection.</summary>
    /// <param name="collection">The service collection</param>
    public static IClientBuilder AddAmazonS3(this IServiceCollection collection)
    {
        ICoreBuilder coreBuilder = SimpleS3CoreServices.AddSimpleS3Core(collection);

        coreBuilder.UseAmazonS3();

        IHttpClientBuilder httpBuilder = coreBuilder.UseHttpClientFactory();

        httpBuilder.UseDefaultHttpPolicy();

        coreBuilder.Services.AddSingleton(x =>
        {
            //We have to call a specific constructor for dependency injection
            IObjectClient objectClient           = x.GetRequiredService <IObjectClient>();
            IBucketClient bucketClient           = x.GetRequiredService <IBucketClient>();
            IMultipartClient multipartClient     = x.GetRequiredService <IMultipartClient>();
            IMultipartTransfer multipartTransfer = x.GetRequiredService <IMultipartTransfer>();
            ITransfer transfer = x.GetRequiredService <ITransfer>();
            ISignedObjectClient?signedObjectClient = x.GetRequiredService <ISignedObjectClient>();
            return(new AmazonS3Client(objectClient, bucketClient, multipartClient, multipartTransfer, transfer, signedObjectClient));
        });

        //Add the client as the interface too
        coreBuilder.Services.AddSingleton <ISimpleClient>(x => x.GetRequiredService <AmazonS3Client>());

        return(new ClientBuilder(collection, httpBuilder, coreBuilder));
    }
Exemplo n.º 6
0
 public void RemoveDownload(ITransfer transfer)
 {
     if (transfer.Status == Status.Idle)
     {
         Transfers.Remove(transfer);
     }
 }
        private bool ValidateTransfer(ITransfer transfer)
        {
            var isValid = true;

            if (transfer.Amount <= 0 || transfer.Amount > 1_000_000_000)
            {
                _log.Warning("Processed transfer event with invalid amount", context: transfer);
            }

            if (string.IsNullOrEmpty(transfer.TransactionId))
            {
                isValid = false;
                _log.Warning("Transfer event without transaction id", context: transfer);
            }

            if (string.IsNullOrEmpty(transfer.AssetSymbol))
            {
                isValid = false;
                _log.Warning("Transfer event without asset symbol", context: transfer);
            }

            if (string.IsNullOrEmpty(transfer.SenderCustomerId))
            {
                isValid = false;
                _log.Warning("Transfer event without sender id", context: transfer);
            }

            if (string.IsNullOrEmpty(transfer.ReceiverCustomerId))
            {
                isValid = false;
                _log.Warning("Transfer event without receiver id", context: transfer);
            }

            return(isValid);
        }
Exemplo n.º 8
0
        private void ValidateTransferRules(ITransfer transferResource, List <ValidationResult> results, bool validateModelForPost)
        {
            if (transferResource == null)
            {
                return;
            }

            if (validateModelForPost)
            {
                if (string.IsNullOrWhiteSpace(transferResource.Context))
                {
                    results.Add(new ValidationResult("Context must have a value", new[] { "Context" }));
                }
            }

            if (transferResource.DateandTimeOfTransfer.HasValue && transferResource.DateandTimeOfTransfer.Value > DateTime.UtcNow)
            {
                results.Add(new ValidationResult("Date and Time Of Transfer must be less the current date/time", new[] { "DateandTimeOfTransfer" }));
            }

            if (transferResource.DateandTimeofTransferAccepted.HasValue && transferResource.DateandTimeofTransferAccepted.Value > DateTime.UtcNow)
            {
                results.Add(new ValidationResult("Date and Time of Transfer Accepted must be less the current date/time", new[] { "DateandTimeofTransferAccepted" }));
            }

            if (transferResource.ActualCallbackTime.HasValue && transferResource.ActualCallbackTime.Value > DateTime.UtcNow)
            {
                results.Add(new ValidationResult("Actual Callback Time must be less the current date/time", new[] { "ActualCallbackTime" }));
            }

            if (transferResource.LastModifiedDate.HasValue && transferResource.LastModifiedDate.Value > DateTime.UtcNow)
            {
                results.Add(new ValidationResult("Last Modified Date must be less the current date/time", new[] { "LastModifiedDate" }));
            }
        }
Exemplo n.º 9
0
        private void ListerContenuLocal(object sender, EventArgs e)
        {
            ITransfer     unTransferable = (ITransfer)trv_arboLocal.SelectedNode.Tag;
            ElementFolder unDossier      = null;

            if (unTransferable.EstUnDossier())
            {
                unDossier = (ElementFolder)unTransferable;
                lst_itranfertLocal.Items.Clear();

                foreach (ITransfer item in unDossier.ListerContenu())
                {
                    ListViewItem uneListItem = new ListViewItem();
                    uneListItem.Text = item.GetName();
                    uneListItem.Tag  = item;

                    if (item.EstUnDossier())
                    {
                        uneListItem.ImageIndex = 0;
                    }
                    else
                    {
                        uneListItem.ImageIndex = 1;
                    }

                    lst_itranfertLocal.Items.Add(uneListItem);
                }
            }
        }
Exemplo n.º 10
0
        /// <param name="bootloader"></param>
        /// <param name="pin"></param>
        public VersionFrm(IBootloader bootloader, ITransfer pin)
        {
            manager = new Manager(bootloader.Env);
            _pin    = pin;

            InitializeComponent();
            Icon = Resource.Package_32;

            editorStepGen._.WordWrap   = false;
            editorStepGen._.IsReadOnly = true;
            editorStepGen._.FontSize   = 9.25f;
            editorStepGen.setBackgroundFromString("#F4F4F4");

            editorFinalScript.colorize(TextEditor.ColorSchema.SBEScripts);
            editorFinalScript.codeCompletionInit(new Inspector(bootloader), new MSBuild.Parser(bootloader.Env, bootloader.UVariable));
            editorFinalScript.CodeCompletionEnabled = true;
            editorFinalScript._.WordWrap            = false;

            tabControlMain.Top     = -22;
            tabControlMain.Height += 22;
            tcRevNumber.SizeMode   = TabSizeMode.Fixed;
            tcReplType.SizeMode    = TabSizeMode.Fixed;
            btnPrevStep.Visible    = false;

            string spath = bootloader.Env.SolutionPath ?? Settings.WPath;

            ftbInputNum.Dialog.InitialDirectory                 = ftbOutputFile.Dialog.InitialDirectory
                                                                = ftbReplFile.Dialog.InitialDirectory
                                                                = spath.PathFormat();
        }
Exemplo n.º 11
0
        private async Task StartAgentCallAndTransferFlowAsync(ICommunication communication, string agent, string callContext)
        {
            IAudioVideoInvitation invite = await EstablishCallWithAgentAsync(communication, agent).ConfigureAwait(false);

            lock (m_syncRoot)
            {
                m_outboundAVConversations.Add(invite.RelatedConversation);
            }

            int result = Interlocked.Exchange(ref m_outboundCallTransferLock, 1);

            if (result == 0)
            {
                //Step 4: do transfer
                Logger.Instance.Information("[HuntGroupJob] Transferring call to " + agent);

                IAudioVideoCall av = invite.RelatedConversation.AudioVideoCall;

                ITransfer t = await av.TransferAsync(null, callContext, LoggingContext).ConfigureAwait(false);

                await t.WaitForTransferCompleteAsync().TimeoutAfterAsync(TimeSpan.FromSeconds(30)).ConfigureAwait(false);

                Logger.Instance.Information("[HuntGroupJob] Transfer completed successfully!");
            }
            else
            {
                // The call is already accepted and transfered by some one else
                Logger.Instance.Information("[HuntGroupJob] The call is already accepted and transfered by some one else; cancelling the transfer for " + agent);

                await invite.RelatedConversation.DeleteAsync(LoggingContext).ConfigureAwait(false);
            }
        }
Exemplo n.º 12
0
        internal static void Bind(this IModel model, ITransfer addr, string route, string queue)
        {
            var exchange = addr.Exchange;
            IDictionary <string, object> args = null;

            model.QueueBind(queue, exchange, route, args);
        }
Exemplo n.º 13
0
 public SnapshotPaginationProvider(IFhirStore fhirStore, ITransfer transfer, ILocalhost localhost, ISnapshotPaginationCalculator snapshotPaginationCalculator)
 {
     this.fhirStore = fhirStore;
     this.transfer  = transfer;
     this.localhost = localhost;
     _snapshotPaginationCalculator = snapshotPaginationCalculator;
 }
Exemplo n.º 14
0
        private void OnNodeUpdated(INode node)
        {
            if (!node.Equals(Source))
            {
                throw new ArgumentException("Received updated callback for wrong node");
            }

            Source.Updated -= OnNodeUpdated;

            foreach (var child in ((IFolder)node).Children)
            {
                ITransfer t = Transfers.CreateTransfer(child, Path.Combine(Destination, child.Name), 0);
                SubTransfers.Add(t);
            }

            if (startCalled)
            {
                Download();
            }
            else
            {
                Status      = Status.Pending;
                listingDone = true;
            }
        }
Exemplo n.º 15
0
        /// <param name="bootloader"></param>
        /// <param name="pin"></param>
        public VersionFrm(IBootloader bootloader, ITransfer pin)
        {
            manager = new Manager(bootloader.Env);
            _pin    = pin;

            InitializeComponent();
            Icon = Resource.Package_32;

            editorStepGen._.WordWrap        = false;
            editorStepGen._.IsReadOnly      = true;
            editorStepGen._.FontSize        = 9.25f;
            editorStepGen.setBackgroundFromString("#F4F4F4");

            editorFinalScript.colorize(TextEditor.ColorSchema.SBEScripts);
            editorFinalScript.codeCompletionInit(new Inspector(bootloader), new MSBuild.Parser(bootloader.Env, bootloader.UVariable));
            editorFinalScript.CodeCompletionEnabled = true;
            editorFinalScript._.WordWrap            = false;

            tabControlMain.Top      = -22;
            tabControlMain.Height   += 22;
            tcRevNumber.SizeMode    = TabSizeMode.Fixed;
            tcReplType.SizeMode     = TabSizeMode.Fixed;
            btnPrevStep.Visible     = false;

            string spath = bootloader.Env.SolutionPath ?? Settings.WPath;

            ftbInputNum.Dialog.InitialDirectory = ftbOutputFile.Dialog.InitialDirectory
                                                = ftbReplFile.Dialog.InitialDirectory
                                                = spath.PathFormat();
        }
Exemplo n.º 16
0
        public EnvDteSniffer(IEnvironment env, ITransfer link)
        {
            this.env    = env;
            this.link   = link;

            InitializeComponent();
            Icon = Resource.Package_32;
        }
Exemplo n.º 17
0
        public void Publish <T>(ITransfer addr, T message)
        {
            Model.CreateExchange(addr);
            var route = message.GetType().FullName;
            var bytes = Serializer.Serialize(message);

            Model.Publish(addr, route, bytes, Id);
        }
Exemplo n.º 18
0
        public EnvDteSniffer(IEnvironment env, ITransfer link)
        {
            this.env  = env;
            this.link = link;

            InitializeComponent();
            Icon = Resource.Package_32;
        }
Exemplo n.º 19
0
 private void ConnectTransfer(object obj)
 {
     if (obj is ITransfer)
     {
         ITransfer t = (ITransfer)obj;
         t.Connect();
     }
 }
        public void Test_Get_All_Supporting_Countries()
        {
            connectionClient = new ConnectionClient(BASEURL, Util.getHeader(PUBLICKEY, MERCHANTID));
            transaction      = new Transfer(connectionClient);
            JObject response = transaction.allSupportingCountries().Result;

            Assert.AreEqual("SUCCESSFUL", response.GetValue("message").ToString());
        }
Exemplo n.º 21
0
        public DTECommandsFrm(IEnumerable <EnvDTE.Command> commands, ITransfer pin)
        {
            _commands = commands ?? Enumerable.Empty <EnvDTE.Command>();
            _pin      = pin;

            InitializeComponent();
            Icon = Resource.Package_32;
        }
Exemplo n.º 22
0
        private void AddTransferItem(ITransfer t)
        {
            var ti = new PrototypeTransferItem();
            ti.Init(t);

            Items.Add(ti);
            RefreshStart();
        }
Exemplo n.º 23
0
 internal Transfer(ITransfer transfer)
 {
     Id = transfer.Id;
     TargetUserId = transfer.TargetUserId;
     KeyBlobId = transfer.KeyBlobId;
     TargetBlobId = transfer.TargetBlobId;
     Complete = transfer.Complete;
 }
Exemplo n.º 24
0
 protected void Set(ITransfer transfer)
 {
     Id = transfer.Id;
     TargetUserId = transfer.TargetUserId;
     KeyId = transfer.KeyId;
     TargetBlobId = transfer.TargetBlobId;
     Complete = transfer.Complete;
 }
Exemplo n.º 25
0
        public DTECommandsFrm(IEnumerable<EnvDTE.Command> commands, ITransfer pin)
        {
            _commands = commands;
            this._pin = pin;

            InitializeComponent();
            Icon = Resource.Package_32;
        }
Exemplo n.º 26
0
 protected void Initialize(IObjectClient objectClient, IBucketClient bucketClient, IMultipartClient multipartClient, IMultipartTransfer multipartTransfer, ITransfer transfer, ISignedObjectClient signedObjectClient)
 {
     _objectClient       = objectClient;
     _bucketClient       = bucketClient;
     _multipartClient    = multipartClient;
     _multipartTransfer  = multipartTransfer;
     _transfer           = transfer;
     _signedObjectClient = signedObjectClient;
 }
Exemplo n.º 27
0
        private void AddTransferItem(ITransfer t)
        {
            var ti = new PrototypeTransferItem();

            ti.Init(t);

            Items.Add(ti);
            RefreshStart();
        }
Exemplo n.º 28
0
        public TransferNmdcProtocol(ITransfer trans)
            : this(trans,
#if !COMPACT_FRAMEWORK
            System.AppDomain.CurrentDomain.BaseDirectory
#else
            System.IO.Directory.GetCurrentDirectory()
#endif)
        {
        }
Exemplo n.º 29
0
        internal static void CreateExchange(this IModel model, ITransfer addr)
        {
            var exchange = addr.Exchange;
            var type     = addr.Type;
            var durable  = false;
            var autoDel  = true;
            IDictionary <string, object> args = null;

            model.ExchangeDeclare(exchange, type, durable, autoDel, args);
        }
Exemplo n.º 30
0
        public void Subscribe <I>() where I : IRequest
        {
            var cid = Client.Id;
            var ids = new ITransfer[] { cid.Multi, cid.Uni };

            foreach (var id in ids)
            {
                Client.Subscribe <I>(id, OnRequest);
            }
        }
        public PropertiesFrm(IEnvironment env, ITransfer pin)
        {
            InitializeComponent();
            Icon = Resource.Package_32;

            _env             = env;
            _msbuild         = new MSBuild.Parser(_env);
            _pin             = pin;
            _cacheProperties = new ConcurrentDictionary <string, List <MSBuild.PropertyItem> >();
        }
Exemplo n.º 32
0
        public List <ValidationResult> ValidateResource(ITransfer resource, bool validateModelForPost)
        {
            var context = new ValidationContext(resource, null, null);
            var results = new List <ValidationResult>();

            Validator.TryValidateObject(resource, context, results, true);
            ValidateTransferRules(resource, results, validateModelForPost);

            return(results);
        }
Exemplo n.º 33
0
        public PropertiesFrm(IEnvironment env, ITransfer pin)
        {
            InitializeComponent();
            Icon = Resource.Package_32;

            _env                = env;
            _msbuild            = new MSBuild.Parser(_env);
            _pin                = pin;
            _cacheProperties    = new ConcurrentDictionary<string, List<MSBuild.PropertyItem>>();
        }
Exemplo n.º 34
0
        public PropertiesFrm(IEnvironment env, ITransfer pin)
        {
            InitializeComponent();
            Icon = Resource.Package_32;

            _env             = env;
            _msbuild         = MSBuild.MakeEvaluator(_env);
            _pin             = pin;
            _cacheProperties = new ConcurrentDictionary <string, IEnumerable <PropertyItem> >();
        }
Exemplo n.º 35
0
        public ITransfer GetTransfer(string key)
        {
            ITransfer old = null;

            lock (this)
            {
                transfers.TryGetValue(key, out old);
            }
            return(old);
        }
Exemplo n.º 36
0
        public void EndTransfer(ITransfer trans)
        {
            string id = string.Format("{0}{1}", trans.RemoteAddress.Address.ToString(), trans.RemoteAddress.Port);

            trans.Disconnect();
            lock (this)
            {
                transfers.Remove(id);
            }
        }
Exemplo n.º 37
0
 public static bool Transfer()
 {
     if (currentCustomer.AccountCount() < 2)
     {
         ConsoleUtil.DisplayWait(Properties.Resources.TransferRequiresTwoAccounts);
         return false;
     }
     ITransfer from = SelectAccount<ITransfer>(Properties.Resources.SelectAccountTransferFrom);
     return Transfer(from);
 }
        public async Task <TransferResult> ExecuteAsync(TransferCommand transferCommand)
        {
            BlockchainType blockchainType = await _assetSettingsService.GetNetworkAsync(transferCommand.AssetId);

            IBlockchainApiClient blockchainClient = _blockchainClientProvider.Get(blockchainType);

            BlockchainTransferCommand cmd = new BlockchainTransferCommand(transferCommand.AssetId);

            string lykkeAssetId = transferCommand.AssetId.IsGuid()
                ? transferCommand.AssetId
                : await _lykkeAssetsResolver.GetLykkeId(transferCommand.AssetId);

            foreach (var transferCommandAmount in transferCommand.Amounts)
            {
                decimal balance = await blockchainClient.GetBalanceAsync(transferCommandAmount.Source, lykkeAssetId);

                if (transferCommandAmount.Amount == null)
                {
                    if (balance > 0)
                    {
                        cmd.Amounts.Add(new TransferAmount
                        {
                            Amount      = balance,
                            Source      = transferCommandAmount.Source,
                            Destination = transferCommandAmount.Destination
                        });

                        continue;
                    }

                    throw new InsufficientFundsException(transferCommandAmount.Source, transferCommand.AssetId);
                }

                if (transferCommandAmount.Amount > balance)
                {
                    throw new InsufficientFundsException(transferCommandAmount.Source, transferCommand.AssetId);
                }

                cmd.Amounts.Add(transferCommandAmount);
            }

            BlockchainTransferResult blockchainTransferResult = await blockchainClient.TransferAsync(cmd);

            ITransfer transfer = await _transferRepository.AddAsync(new Transfer
            {
                AssetId      = transferCommand.AssetId,
                Blockchain   = blockchainTransferResult.Blockchain,
                CreatedOn    = DateTime.UtcNow,
                Amounts      = transferCommand.Amounts,
                Transactions = Mapper.Map <IEnumerable <TransferTransaction> >(blockchainTransferResult.Transactions)
            });

            return(Mapper.Map <TransferResult>(transfer));
        }
Exemplo n.º 39
0
 public void Init(ITransfer t)
 {
     this.ContextMenu = new TransferMenu(t);
     transfer = t;
     transfer.TransferDone += OnTransferDone;
     var icons = IconHandler.Instance;
     pauseButton.Image = icons.MediaPlaybackPause;
     deleteButton.Image = icons.ProcessStop;
     fileName.Text = t.Source.Name;
     info.Text = "";
     Anchor = AnchorStyles.Left | AnchorStyles.Right;
 }
Exemplo n.º 40
0
 public void Remove(ITransfer transfer)
 {
     throw new NotImplementedException();
     //Use the following event: public event TransferDelegate TransferRemoved;
 }
Exemplo n.º 41
0
 private CloudClient()
 {
     pipeProxy = GetChannel(channelName).CreateChannel();
 }
Exemplo n.º 42
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Transfer"/> class.
 /// </summary>
 /// <param name="transfer">The transfer.</param>
 internal Transfer(ITransfer transfer)
 {
     Set(transfer);
 }
Exemplo n.º 43
0
        public TransferNmdcProtocol(ITransfer trans, string dir)
        {
            directory = dir;
            this.trans = trans;
            MessageReceived = new FmdcEventHandler(OnMessageReceived);
            MessageToSend = new FmdcEventHandler(OnMessageToSend);
            ChangeDownloadItem = new FmdcEventHandler(OnChangeDownloadItem);
            RequestTransfer = new FmdcEventHandler(OnRequestTransfer);
            Error = new FmdcEventHandler(OnError);
            Update = new FmdcEventHandler(OnUpdate);

            TimerCallback timerDelegate = new TimerCallback(OnTimer);
            long interval = 10 * 1000; // 10 seconds
            timer = new System.Threading.Timer(timerDelegate, trans, interval, interval);

            trans.ConnectionStatusChange += new FmdcEventHandler(trans_ConnectionStatusChange);
        }
Exemplo n.º 44
0
 public void AddTransfer(ITransfer trans)
 {
     string id = string.Format("{0}{1}", trans.RemoteAddress.Address.ToString(), trans.RemoteAddress.Port);
     //if (ContainsTransfer(id))
     //{
     //    trans.Disconnect("stop creating stuff");
     //    return;
     //}
     RemoveTransfer(id);
     trans.ConnectionStatusChange += new FmdcEventHandler(trans_ConnectionStatusChange);
     // Add transfer to list.
     lock (transfers)
     {
         transfers.Add(id, trans);
     }
 }
Exemplo n.º 45
0
 public bool TransferUpdate(ITransfer obj)
 {
     var transferDocument = GetDocumentById(TransfersCollection, obj.Id.ToString());
     if (transferDocument == null)
         return false;
     var updatedTransfer = Client.ReplaceDocumentAsync(transferDocument.SelfLink, obj).Result;
     return updatedTransfer != null;
 }
 public TransferZpocProtocol(ITransfer trans, string dir)
     : base(trans, dir)
 {
 }
Exemplo n.º 47
0
 /// <summary>
 /// If connection to remote ip and port already exist that connection will be closed and then the new one will be connected
 /// </summary>
 /// <param name="trans">Transfer you want to start</param>
 public void StartTransfer(ITransfer trans)
 {
     AddTransfer(trans);
     // Connect transfer.
     #if !COMPACT_FRAMEWORK
     Thread t = new Thread(new ParameterizedThreadStart(ConnectTransfer));
     t.IsBackground = true;
     t.Start(trans);
     #else
     Thread t = new Thread(new ThreadStart(ConnectTransfer));
     t.IsBackground = true;
     t.Start(trans);
     #endif
 }
Exemplo n.º 48
0
 public bool TransferDelete(ITransfer obj)
 {
     var transferDocument = GetDocumentById(TransfersCollection, obj.Id.ToString());
     if (transferDocument == null)
         return true;
     var result = Client.DeleteDocumentAsync(transferDocument.SelfLink);
     return true;
 }
Exemplo n.º 49
0
 public void EndTransfer(ITransfer trans)
 {
     string id = string.Format("{0}{1}", trans.RemoteAddress.Address.ToString(), trans.RemoteAddress.Port);
     trans.Disconnect();
     lock (transfers)
     {
         transfers.Remove(id);
     }
 }
Exemplo n.º 50
0
 public Transfer(TransferHash previous, ITransfer trans)
     : this(previous, trans.DestinyPk)
 {
 }
        public Lock(ITransfer trans)
            : base(trans, null)
        {
            if (trans.Me == null)
                throw new System.ArgumentNullException("Transfer.Me can't be null.");

            extended = true;

            pk = trans.Me.TagInfo.Version.Replace(" ", "").Replace("V:", "") +"ABCABCABCABCABCA";
            if (pk.Length > 16)
                pk = pk.Substring(0, 16);
            MakeRaw();
        }
Exemplo n.º 52
0
 public ITransfer TransferCreate(ITransfer obj)
 {
     dynamic doc = Client.CreateDocumentAsync(TransfersCollection.SelfLink, obj).Result;
     return (Transfer)doc.Resource;
 }
Exemplo n.º 53
0
 public void AddTransfer(ITransfer trans)
 {
     string id = string.Format("{0}{1}", trans.RemoteAddress.Address.ToString(), trans.RemoteAddress.Port);
     RemoveTransfer(id);
     trans.ConnectionStatusChange += new FmdcEventHandler(trans_ConnectionStatusChange);
     // Add transfer to list.
     lock (this)
     {
         transfers.Add(id, trans);
     }
 }
Exemplo n.º 54
0
 private void OnTransferAdded(ITransfer t)
 {
     AddTransferItem(t);
 }