//************************************************************************
// author: yuzhengyang
// date: 2017.10.12 - 2017.10.12
// desc: 客户端定居工具
// Copyright (c) yuzhengyang. All rights reserved.
//************************************************************************
using Azylee.Core.IOUtils.DirUtils;
using Azylee.Core.IOUtils.FileUtils;
using System.Collections.Generic;
using System.IO;
namespace Azylee.Core.AppUtils
{
///
/// 客户端定居工具
///
public class AppSettleTool
{
///
/// 判断是否已定居
///
/// 定居路径
/// 货物清单
///
public static bool IsSettle(string path, Dictionary list)
{
if (Directory.Exists(path))
{
if (list != null)
{
bool allOk = true;
foreach (var l in list)
{
if (!string.IsNullOrWhiteSpace(l.Value))
allOk &= File.Exists(l.Value);
}
return allOk;
}
else
{
return true;
}
}
return false;
}
///
/// 定居
///
/// 定居路径
/// 货物清单
///
public static bool Settle(string path, Dictionary list)
{
if (DirTool.Create(path))
{
if (list != null)
{
foreach (var l in list)
{
FileTool.Copy(l.Key, l.Value, true);
}
}
}
return IsSettle(path, list);
}
}
}