예제 #1
0
        private static DataPumpBase GetMirrorDataPump(Pump key, Int32 hash)
        {
            if (DataPumpCaches.ContainsKey(hash))
            {
                return(DataPumpCaches[hash]);
            }

            DataPumpBase dataPump = null;

            switch (key.OSType)
            {
            case EnumOSType.Android:
                dataPump = new AndroidMirrorDataPump();
                break;

            case EnumOSType.IOS:
                dataPump = new IOSMirrorDataPump();
                break;

            default:
                throw new NotSupportedException(key.OSType.ToString());
            }
            DataPumpCaches.Add(hash, dataPump);
            return(dataPump);
        }
예제 #2
0
        /// <summary>
        /// 执行数据泵。
        /// </summary>
        /// <param name="pump">元数据。</param>
        /// <param name="savePath">保存路径。</param>
        /// <param name="source">数据源。</param>
        /// <param name="reporter">异步通知器。</param>
        /// <param name="items">提取项列表。</param>
        /// <returns>数据泵任务执行上下文。</returns>
        public static DataPumpExecutionContext Execute(this Pump pump, String savePath, SourceFileItem source, IAsyncProgress reporter, IEnumerable <ExtractItem> items = null)
        {
            DataPumpBase                         dataPump  = pump.GetDataPump();
            DataPumpExecutionContext             context   = dataPump.CreateContext(pump, savePath, source);
            DataPumpControllableExecutionContext contextEx = context as DataPumpControllableExecutionContext;

            if (contextEx != null)
            {
                contextEx.Reporter = reporter;
            }
            dataPump.Execute(context);
            return(context);
        }
예제 #3
0
        /// <summary>
        /// 创建执行上下文。
        /// </summary>
        /// <param name="dataPump">数据泵。</param>
        /// <param name="metaData">元数据。</param>
        /// <param name="rootSavePath">保存路径。</param>
        /// <param name="source">数据源。</param>
        /// <param name="extractItems">提取项列表。</param>
        /// <param name="asyn">异步通知器。</param>
        /// <returns>执行上下文。</returns>
        internal static DataPumpExecutionContext CreateContext(this DataPumpBase dataPump, Pump metaData, String rootSavePath, SourceFileItem source, IEnumerable <ExtractItem> extractItems, IAsyncProgress asyn = null)
        {
            DataPumpExecutionContext context = dataPump.CreateContext(metaData, rootSavePath, source);

            context.ExtractItems = extractItems;
            DataPumpControllableExecutionContext contextEx = context as DataPumpControllableExecutionContext;

            if (contextEx != null)
            {
                contextEx.Reporter = asyn;
            }
            return(contextEx);
        }
예제 #4
0
        /// <summary>
        /// 执行数据泵。
        /// </summary>
        /// <param name="dataPump">元数据。</param>
        /// <param name="source">数据源。</param>
        /// <param name="reporter">异步通知器。</param>
        /// <param name="items">提取项列表。</param>
        /// <returns>数据泵任务执行上下文。</returns>
        public static DataPumpExecutionContext Execute(this DataPumpBase dataPump, SourceFileItem source, MultiTaskReporterBase reporter, params ExtractItem[] items)
        {
            DataPumpExecutionContext context = dataPump.CreateContext(source);

            context.ExtractItems = items;
            DataPumpControllableExecutionContext contextEx = context as DataPumpControllableExecutionContext;

            if (contextEx != null)
            {
                contextEx.Reporter = reporter;
            }
            dataPump.Execute(context);
            return(context);
        }
예제 #5
0
        /// <summary>
        /// 根据提取方式和系统类型获取指定的数据泵,并完成数据泵的初始化。
        /// </summary>
        /// <param name="pump">元数据。</param>
        /// <returns>数据泵。</returns>
        public static DataPumpBase GetDataPump(this Pump pump)
        {
            DataPumpBase dp = null;

            switch (pump.Type)
            {
            case EnumPump.USB:
                dp = GetUsbDataDataPump(pump);
                break;

            case EnumPump.Mirror:
                dp = GetMirrorDataPump(pump);
                break;

            default:
                break;
            }
            dp?.Initialize();
            return(dp);
        }
예제 #6
0
        private static DataPumpBase GetUsbDataDataPump(Pump key, Int32 hash)
        {
            if (DataPumpCaches.ContainsKey(hash))
            {
                return(DataPumpCaches[hash]);
            }

            var          device   = (Device)key.Source;
            DataPumpBase dataPump = null;

            switch (key.OSType)
            {
            case EnumOSType.Android:
                if (device.IsRoot || device.Status == EnumDeviceStatus.Recovery)
                {
                    dataPump = new AndroidUsbDataPump();
                }
                else if (device.Brand.ToSafeString().ToLower() == "vivo" || device.Manufacture.ToSafeString().ToLower() == "vivo")
                {
                    dataPump = new AndroidVivoBackupDataPump();
                }
                else
                {
                    dataPump = new AndroidUsbUnrootDataPump();
                }
                break;

            case EnumOSType.IOS:
                dataPump = new IOSUsbDataPump();
                break;

            default:
                throw new NotSupportedException(key.OSType.ToString());
            }
            DataPumpCaches.Add(hash, dataPump);
            return(dataPump);
        }