本文整理汇总了C#中System.Objects.LogFilePack方法的典型用法代码示例。如果您正苦于以下问题:C# Objects.LogFilePack方法的具体用法?C# Objects.LogFilePack怎么用?C# Objects.LogFilePack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Objects
的用法示例。
在下文中一共展示了Objects.LogFilePack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LogFilePack
/// <summary>
/// Logs a downloaded file pack and send a new FPR message if is necessary.
/// </summary>
/// <param name="Download">The download object.</param>
/// <param name="StartPoint">The star point of the file pack.</param>
/// <param name="SenderPeer">The sender peer object.</param>
/// <param name="Status">If the file-pack has been written or not ( other ).</param>
public static void LogFilePack(Objects.Download Download, int StartPoint, Objects.Peer SenderPeer, Status_FilePack Status)
{
// indicate the downloading of a file pack
SenderPeer.FilePackDownloaded = true;
if (Status == Status_FilePack.Written)
{
#region ...
int filePackNum = StartPoint / 16384;
int filePartNum = StartPoint / 2097152;
// control if the file pack is already been downloaded
if (Download.ListFilePacks[filePackNum] == false)
{
// update the list of file packs
Download.ListFilePacks[filePackNum] = true;
// update the number of remaining file packs
Download.RemainingFilePacks--;
// update the list of file parts
Download.ListFileParts[filePartNum]--;
// control if the file part is completed
if (Download.ListFileParts[filePartNum] == 0)
{
// update the number of remaining file parts
Download.RemainingFileParts--;
// control if the download is finished
if (Download.RemainingFilePacks == 0)
{
// move the completed download from temp-directory to shared-directory
File.Move(Global.TempDirectory + Download.Name, Global.SharedDirectory + Download.Name);
// update download's informations
Download.Progress = 100;
Download.Active = false;
}
else
{
// send a new FPR to the peer for the next not downloaded file pack of a new file part
StartDownloadNextFilePart(Download, SenderPeer);
}
}
else
{
// send a new FPR to the peer for the next not downloaded file pack of a this file part
if (DownloadNextFilePackOfAFilePart(filePackNum, filePartNum, Download, SenderPeer) == false)
{
StartDownloadNextFilePart(Download, SenderPeer);
}
}
// log the file pack
Download.LogFilePack(SenderPeer.IP, filePackNum);
NewOrUpdatedDownload = true;
}
#endregion
}
// if the FilePack is damaged, will send a new FPR-mess to the peer;
else if (Status == Status_FilePack.Damaged)
{
#region ...
string[] Params = new string[3];
Params[0] = Download.Name;
Params[1] = Download.SHA1;
Params[2] = StartPoint.ToString();
Messages.IMessage FprMess = Messages.MessagesFactory.Instance.CreateMessage(Messages.Commands.FPR, Params);
SenderPeer.Send(FprMess);
#endregion
}
}