コード例 #1
0
        private void LoadData(string devicePath)
        {
            Task.Factory.StartNew(() =>
            {
                IsFiltering = true;

                _currentDevicePath = devicePath;

                //DetectionManager.Instance.Detect(devicePath);
                var dataList = DeviceExternsion.LoadDeviceData(devicePath);
                foreach (var item in dataList)
                {
                    item.BuildParent();
                }
                AsyncOperator.Execute(() =>
                {
                    DataList = dataList;

                    //重置数据
                    MessageAggregation.SendGeneralMsg(new GeneralArgs <ObservableCollection <DataExtactionItem> >(MessageKeys.SetDataListKey)
                    {
                        Parameters = DataList
                    });

                    IsFiltering = false;
                    HasDataList = DataList != null && DataList.Count > 0;

                    SelectDefaultNode(DataList);
                });
            });
        }
コード例 #2
0
 /// <summary>
 /// 删除某个提取项数据
 /// </summary>
 private void DoDeleteDataCommond(object item)
 {
     if (item == null)
     {
         return;
     }
     if (ShowMessageBox(string.Format(Languagekeys.DeleteNotice, item)))
     {
         Task.Factory.StartNew(() =>
         {
             AsyncOperator.Execute(() => { CurrentOperation = Languagekeys.DeletingData; IsFiltering = true; });
             string path = Path.Combine(_currentDevicePath, item.ToString());
             BaseUtility.Helper.FileHelper.RemoveDirectoryReadOnly(path);
             Directory.Delete(path, true);
             AsyncOperator.Execute(() =>
             {
                 IsFiltering = false;
                 var d       = DataList.FirstOrDefault(e => e.Text == item.ToString());
                 DataList.Remove(d);
                 HasDataList = DataList != null && DataList.Count > 0;
                 if (!SelectDefaultNode(DataList))
                 {
                     LayoutViewItems        = new ObservableCollection <object>();
                     SelectedLayoutViewItem = null;
                     HasData = SelectedLayoutViewItem != null;
                 }
             });
         });
     }
 }
コード例 #3
0
 internal P_LoadedPackageState(DefaultDescriptionPackageService service, DescriptionPackageLocator locator)
 {
     service.EnsureNotNull(nameof(service));
     locator.EnsureNotNull(nameof(locator));
     //
     _service    = service;
     _locator    = locator;
     _disposeCts = new CancellationTokenSource();
     _loader     = new AsyncOperator <IDescriptionPackage>(asyncFactory: P_LoadNewPackageInstanceAsync, ownsResult: true);
 }
コード例 #4
0
    public void Release()
    {
        Stop();


        if (!AsyncOperator.Contains(this))
        {
            sAsyncOperators.Enqueue(this);
        }
    }
コード例 #5
0
 internal P_LoadedPackageState(DefaultDescriptionPackageService service, IDescriptionPackage package, DescriptionPackageLocator locator, bool ownsPackage = false)
 {
     service.EnsureNotNull(nameof(service));
     package.EnsureNotNull(nameof(package));
     locator.EnsureNotNull(nameof(locator));
     //
     _service    = service;
     _locator    = locator;
     _disposeCts = null;
     _loader     = new AsyncOperator <IDescriptionPackage>(result: package, ownsResult: ownsPackage);
 }
コード例 #6
0
 public static AsyncOperator Retrieve()
 {
     if (sAsyncOperators.Count > 0)
     {
         return(sAsyncOperators.Dequeue());
     }
     else
     {
         AsyncOperator ao = new AsyncOperator();
         return(ao);
     }
 }
コード例 #7
0
        private void LoadData(string devicePath)
        {
            if (IsFiltering)
            {
                return;
            }
            IsFiltering = true;
            Task.Factory.StartNew(() =>
            {
                try
                {
                    //AsyncOperator.Execute(() => IsFiltering = true);

                    //devicePath = @"C:\Users\fhjun\Desktop\默认案例_20171115[081055]\默认案例_20171115[081055]\R7007_20171115[081055]";
                    _currentDevicePath = devicePath;
                    var dataList       = DeviceExternsion.LoadDeviceData(devicePath);
                    foreach (var item in dataList)
                    {
                        item.BuildParent();
                    }
                    AsyncOperator.Execute(() =>
                    {
                        DataList = dataList;

                        //重置数据
                        MessageAggregation.SendGeneralMsg(new GeneralArgs <ObservableCollection <DataExtactionItem> >(MessageKeys.SetDataListKey)
                        {
                            Parameters = DataList
                        });

                        IsFiltering = false;
                        HasDataList = DataList != null && DataList.Count > 0;

                        SelectDefaultNode(DataList);
                    });
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    AsyncOperator.Execute(() =>
                    {
                        IsFiltering = false;
                        MessageAggregation.SendGeneralMsg(new GeneralArgs <object>(MessageKeys.DataLoadedCompletedKey)
                        {
                            Parameters = true
                        });
                    });
                }
            });
        }
コード例 #8
0
        /// <summary>
        /// 设置查询状态
        /// </summary>
        /// <param name="obj"></param>
        private void StartFilter(GeneralArgs <bool> obj)
        {
            AsyncOperator.Execute(() =>
            {
                CurrentOperation = Languagekeys.Searching;
                IsFiltering      = obj.Parameters;

                if (!IsFiltering)
                {
                    SelectDefaultNode(DataList);
                }
            });
        }
コード例 #9
0
 protected override void Dispose(bool explicitDispose)
 {
     if (explicitDispose)
     {
         _loader?.Dispose();
         _disposeCts?.Dispose();
     }
     _service    = null;
     _locator    = null;
     _disposeCts = null;
     _loader     = null;
     //
     base.Dispose(explicitDispose);
 }
コード例 #10
0
        public EarlyWarningResultPage()
        {
            InitializeComponent();

            AsyncOperator.LoadAsyncOperation(this);

            //var preview = IocManagerSingle.Instance.GetViewPart(ExportKeys.DataPreView);
            //if (preview != null)
            //{
            //    preview.DataSource.LoadViewModel();
            //    _preVM = preview.DataSource;
            //    preView.Content = preview;

            //    MsgAggregation.Instance.RegisterGeneralMsg<object>(this, MessageKeys.PreviewKey, RefreshPreview);
            //}
        }
コード例 #11
0
 internal AsyncRequest(SEUResources resource, System.Action <SEUResources> callback = null)
 {
     m_Resource = resource;
     if (resource.asset == null)
     {
         AsyncOperator.SendReqest(MainLoop(callback));
     }
     else
     {
         if (callback != null)
         {
             callback(resource);
         }
         m_KepWaiting = false;
     }
 }
コード例 #12
0
        /// <summary>
        /// 异步加密打包 MHX 包,传入Files
        /// </summary>
        /// <param name="files">文件+文件夹</param>
        /// <returns></returns>
        public static AsyncOperate ASyncBuild_MHX_DATA(string[] files, Action <Exception> OnError = null)
        {
            var          ao = new AsyncOperator();
            AsyncOperate op = new AsyncOperate(ao);

            op.Start();
            try
            {
                Action <string> sync_log     = log => { ao.log = log; };
                Action <float>  sync_process = log => { ao.process = log; };
                Action <bool>   sync_state   = log => { ao.isdone = log; };

                string passwd  = "F41E6-F565-41F1F-C1DR5-6QW";
                var    ZipFile = "data.mhx";
                new Thread(() =>
                {
                    ZipHelper.ASyncCompressFilesAndFolder(sync_process, sync_log, sync_state, OnError, files, ZipFile, 5, passwd);
                })
                {
                    IsBackground = true,
                    Name         = "_async_build_mhx_data"
                }.Start();
            }
            catch (Exception e)
            {
                if (OnError != null)
                {
                    OnError(e);
                }
                //op.isDone = true;
                ao.log    = e.ToString();
                ao.isdone = true;
                if (File.Exists("data.mhx"))
                {
                    File.Delete("data.mhx");
                }
            }
            return(op);
        }
コード例 #13
0
ファイル: Bundle.cs プロジェクト: ZengHuiAn/sgk
    static IEnumerator AsyncLoad(AsyncOperator op)
    {
        var b    = op.b;
        var path = op.path;
        AssetBundleRequest req = b.Asset.LoadAssetAsync(path, op.t);

        if (req.asset == null)
        {
            yield return(req);
        }

        List <System.Action <Object> > cbs = null;

        if (b.mAsyncs.TryGetValue(path, out cbs))
        {
            for (int i = 0; i < cbs.Count; ++i)
            {
                cbs[i](req.asset);
            }
            cbs.Clear();
            b.mAsyncs.Remove(path);
        }
    }
コード例 #14
0
ファイル: Compiler.cs プロジェクト: radtek/HinxCor
        /// <summary>
        /// 自解压程序;
        /// 需要 DCARE.exe; 需要 HinxCor.CompressionDot45.dll;需要 ICSharpCode.SharpZipLib.dll;需要 data.mhx;
        /// 需要 code.depub 和 icon
        /// require Windows dotNet 4.0
        /// </summary>
        /// <param name="outName"></param>
        /// <param name="key"></param>
        /// <param name="csFile"></param>
        public static AsyncOperate AsyncTryComplire(string outName, Action <Exception> OnError = null, string key = crcKey, string csFile = csFileName, string icon = "icon.ico")
        {
            var          ao = new AsyncOperator();
            AsyncOperate op = new AsyncOperate(ao);

            op.Start();
            //proc =;
            try
            {
                new Thread(() =>
                {
                    ao.process    = 0.01f;
                    ao.log        = "准备中";
                    ao.hlog       = new FormerLog(FormerLog.LogType.Log, ao.log);
                    var data      = File.ReadAllBytes(csFile);//加密了的数据
                    ao.process    = 0.08f;
                    ao.log        = "加载加密码";
                    string csname = "code.depub.decode";

                    using (var rc4 = new RC4(Encoding.UTF8.GetBytes(key)))
                    {
                        ao.process      = 0.09f;
                        ao.log          = "准备解密";
                        string cedetail = rc4.Decrypt(data);
                        ao.process      = 0.15f;
                        ao.log          = "写入钥文";
                        File.WriteAllText(csname, cedetail);

                        ao.process = 0.20f;
                        ao.log     = "环境监测";
                        if (Directory.Exists(cscEnv) == false)
                        {
                            ao.process = 0.23f;
                            ao.hlog    = new FormerLog(FormerLog.LogType.Error, "需要.net 4.0");
                            return;
                        }
                        if (!EnvironmentTools.AddPath(cscEnv))
                        {
                            ao.process = 0.33f;
                            ao.hlog    = new FormerLog(FormerLog.LogType.Warning, "无法正确加入环境变量");
                            //return;
                        }
                        ao.process = 0.30f;
                        ao.log     = "准备OK";
                        Thread.Sleep(100);
                        ao.process = 0.40f;

                        ao.log        = "编译中";
                        string batcmd = string.Format(@"csc -out:{0} {1} -win32icon:{6} -resource:{2} -resource:{3} -resource:{4} -resource:{5}"
                                                      , outName, csname, "DCARE.exe", "HinxCor.CompressionDot45.dll", "ICSharpCode.SharpZipLib.dll", "data.mhx", icon);
                        ao.process = 0.50f;
                        ao.log     = "编译中.";
                        ao.log     = "编译中..";
                        ao.log     = "编译中...";
                        var res    = Windows.ExecuteCommand(batcmd);
                        if (res.hasError)
                        {
                            throw new Exception(res.Error);
                        }

                        ao.log     = "编译结束";
                        ao.process = 0.80f;

                        ao.log = "清理文件";
                        File.Delete(csname);
                        ao.log     = "清理文件";
                        ao.process = 0.90f;
                        File.Delete("data.mhx");
                        ao.process = 1f;
                        ao.log     = "完成:无异常";
                        ao.isdone  = true;
                    }
                })
                {
                    IsBackground = true,
                    Name         = "_complair"
                }.Start();
            }
            catch (Exception e)
            {
                if (OnError != null)
                {
                    OnError(e);
                }
                ao.log    = e.ToString();
                ao.isdone = true;
            }
            return(op);
        }
コード例 #15
0
ファイル: Compiler.cs プロジェクト: radtek/HinxCor
        /// <summary>
        /// 自解压程序; dCare 需要 dll1,dll2,data,mhx
        /// 需要 DCARE.exe; HinxCor.CompressionDot45.dll; ICSharpCode.SharpZipLib.dll; data.mhx;
        /// require Windows dotNet 4.0
        /// </summary>
        /// <param name="outName">输出路径</param>
        /// <param name="resFiles">资源文件列表</param>
        /// <param name="icopth">ICO文件路径</param>
        /// <param name="key">解密秘钥(可默认)</param>
        /// <param name="csFile">加密的CS文件路劲</param>
        public static AsyncOperate AsyncTryComplire(string outName, string[] resFiles, string icopth, string key = crcKey, string csFile = csFileName)
        {
            var          ao = new AsyncOperator();
            AsyncOperate op = new AsyncOperate(ao);

            op.Start();
            //proc =;
            new Thread(() =>
            {
                ao.process    = 0.01f;
                ao.log        = "准备中";
                ao.hlog       = new FormerLog(FormerLog.LogType.Log, ao.log);
                var data      = File.ReadAllBytes(csFile);//加密了的数据
                ao.process    = 0.08f;
                ao.log        = "加载加密码";
                string csname = "code.depub.decode";

                using (var rc4 = new RC4(Encoding.UTF8.GetBytes(key)))
                {
                    try
                    {
                        ao.process      = 0.09f;
                        ao.log          = "准备解密";
                        string cedetail = rc4.Decrypt(data);
                        ao.process      = 0.15f;
                        ao.log          = "写入钥文";
                        File.WriteAllText(csname, cedetail);

                        ao.process = 0.20f;
                        ao.log     = "环境监测";
                        if (Directory.Exists(cscEnv) == false)
                        {
                            ao.process = 0.23f;
                            ao.hlog    = new FormerLog(FormerLog.LogType.Error, "需要.net 4.0");
                            return;
                        }
                        if (!EnvironmentTools.AddPath(cscEnv))
                        {
                            ao.process = 0.33f;
                            ao.hlog    = new FormerLog(FormerLog.LogType.Warning, "无法正确加入环境变量");
                            //return;
                        }
                        ao.process = 0.30f;
                        ao.log     = "准备OK";
                        Thread.Sleep(100);
                        ao.process = 0.40f;

                        ao.log           = "编译中";
                        StringBuilder sb = new StringBuilder();
                        sb.Append("csc");
                        sb.Append(' ');
                        sb.Append("-out:");
                        sb.Append(outName);
                        sb.Append(' ');
                        sb.Append(csname);
                        sb.Append(' ');
                        sb.Append("-win32icon:");
                        sb.Append(icopth);
                        sb.Append(' ');
                        for (int i = 0; i < resFiles.Length; i++)
                        {
                            sb.Append("-resource:");
                            sb.Append(resFiles[i]);
                            sb.Append(' ');
                        }

                        //        string batcmd = string.Format(@"csc -out:{0} {1} -win32icon:icon.ico -resource:{2} -resource:{3} -resource:{4} -resource:{5}"
                        //, outName, csname, "DCARE.exe", "HinxCor.CompressionDot45.dll", "ICSharpCode.SharpZipLib.dll", "data.mhx");
                        ao.process = 0.50f;
                        ao.log     = "编译中.";
                        ao.log     = "编译中..";
                        ao.log     = "编译中...";
                        ao.hlog    = new FormerLog(FormerLog.LogType.Error, ao.log);
                        Windows.ExecuteCommand(sb.ToString());
                        ao.log     = "编译结束";
                        ao.process = 0.80f;
                        ao.hlog    = new FormerLog(FormerLog.LogType.Error, ao.log);

                        ao.log = "清理文件";
                        File.Delete(csname);
                        ao.log     = "清理文件";
                        ao.process = 0.90f;
                        File.Delete("data.mhx");
                        ao.process = 1f;
                        ao.log     = "完成:无异常";
                        ao.isdone  = true;
                    }
                    catch (Exception e)
                    {
                        ao.log    = "失败:" + e.ToString();
                        ao.hlog   = new FormerLog(FormerLog.LogType.Error, ao.log);
                        ao.isdone = true;
                    }
                }
            })
            {
                IsBackground = true,
                Name         = "_complair"
            }.Start();
            return(op);
        }
コード例 #16
0
 private static bool Contains(AsyncOperator ao)
 {
     return(sAsyncOperators.Contains(ao));
 }