/// <summary> /// Initializes a new instance of the <see cref="Transfer"/> class. /// </summary> /// <param name="direction">The transfer direction.</param> /// <param name="username">The username of the peer to or from which the file is to be transferred.</param> /// <param name="filename">The filename of the file to be transferred.</param> /// <param name="token">The unique token for the transfer.</param> /// <param name="state">The state of the transfer.</param> /// <param name="size">The size of the file to be transferred, in bytes.</param> /// <param name="startOffset">The start offset of the transfer, in bytes.</param> /// <param name="bytesTransferred">The total number of bytes transferred.</param> /// <param name="averageSpeed">The current average download speed.</param> /// <param name="startTime"> /// The time at which the transfer transitioned into the <see cref="TransferStates.InProgress"/> state. /// </param> /// <param name="endTime"> /// The time at which the transfer transitioned into the <see cref="TransferStates.Completed"/> state. /// </param> /// <param name="remoteToken">The remote unique token for the transfer.</param> /// <param name="ipEndPoint">The ip endpoint of the remote transfer connection, if one has been established.</param> public Transfer( TransferDirection direction, string username, string filename, int token, TransferStates state, long size, long startOffset, long bytesTransferred = 0, double averageSpeed = 0, DateTime?startTime = null, DateTime?endTime = null, int?remoteToken = null, IPEndPoint ipEndPoint = null) { Direction = direction; Username = username; Filename = filename; Token = token; State = state; Size = size; StartOffset = startOffset; BytesTransferred = bytesTransferred; AverageSpeed = averageSpeed; StartTime = startTime; EndTime = endTime; RemoteToken = remoteToken; IPEndPoint = ipEndPoint; }
public ActionResult UpdateTransfer(Transfer transfer) { try { TransferStates status = (TransferStates)Enum.ToObject(typeof(TransferStates), transfer.Status); Axapta axDB1 = new Axapta(); System.Net.NetworkCredential ncDB1 = new System.Net.NetworkCredential("EP_AX2012", "VendTable1", "RIWAL01"); axDB1.LogonAs(ConfigurationManager.AppSettings["User"], ConfigurationManager.AppSettings["Domain"], ncDB1, transfer.DataAreaId, ConfigurationManager.AppSettings["Language"], ConfigurationManager.AppSettings["AOS"], ""); axDB1.TTSBegin(); AxaptaRecord A4URequest = (AxaptaRecord)axDB1.CallStaticRecordMethod("A4URequests", "Find", transfer.RequestId, true); if (transfer.ExactDateInput) { A4URequest.set_Field("DateOffHire", transfer.DateOffHire); } else { A4URequest.set_Field("DateExpectedOffHire", transfer.DateOffHire); } A4URequest.set_Field("Status", (int)status); A4URequest.Update(); axDB1.TTSCommit(); axDB1.Logoff(); axDB1.Dispose(); return(Content("true")); } catch { return(Content("false")); } }
public void Instantiates_With_Expected_Data( TransferDirection direction, string username, string filename, int token, TransferStates state, long size, long startOffset, long bytesTransferred, double averageSpeed, DateTime?startTime, DateTime?endTime, int?remoteToken, IPEndPoint endpoint) { var t = new Transfer( direction, username, filename, token, state, size, startOffset, bytesTransferred, averageSpeed, startTime, endTime, remoteToken, endpoint); Assert.Equal(direction, t.Direction); Assert.Equal(username, t.Username); Assert.Equal(filename, t.Filename); Assert.Equal(token, t.Token); Assert.Equal(state, t.State); Assert.Equal(size, t.Size); Assert.Equal(startOffset, t.StartOffset); Assert.Equal(bytesTransferred, t.BytesTransferred); Assert.Equal(averageSpeed, t.AverageSpeed); Assert.Equal(startTime, t.StartTime); Assert.Equal(endTime, t.EndTime); Assert.Equal(remoteToken, t.RemoteToken); Assert.Equal(endpoint, t.IPEndPoint); Assert.Equal(t.Size - t.BytesTransferred, t.BytesRemaining); Assert.Equal(t.EndTime - t.StartTime, t.ElapsedTime); Assert.Equal((t.BytesTransferred / (double)t.Size) * 100, t.PercentComplete); Assert.NotNull(t.RemainingTime); }
internal void TransferStateChangedEventArgs_Instantiates_With_The_Given_Data(string username, string filename, int token, TransferStates transferStates) { var dl = new TransferInternal(TransferDirection.Download, username, filename, token); var d = new TransferStateChangedEventArgs(transferStates, new Transfer(dl)); Assert.Equal(transferStates, d.PreviousState); }
/// <summary> /// Initializes a new instance of the <see cref="TransferStateChangedEventArgs"/> class. /// </summary> /// <param name="previousState">The previous state of the transfer.</param> /// <param name="transfer">The transfer which raised the event.</param> internal TransferStateChangedEventArgs(TransferStates previousState, Transfer transfer) : base(transfer) { PreviousState = previousState; }