public async Task <Package> Process(Package request, string pipelineName = "")
        {
            var deliveryId = Guid.NewGuid();

            request.ExternalDeliverBoxId = deliveryId;
            var waitBox = new WaitBox();

            if (!mWaitBoxes.TryAdd(deliveryId, waitBox))
            {
                throw new UnableToPostPackageOnProcessing();
            }
            try
            {
                RouteMessage(request);
                var result = await waitBox.WaitTask();

                return(new Package
                {
                    Load = result.Load
                });
            }
            finally
            {
                mWaitBoxes.TryRemove(deliveryId, out waitBox);
            }
        }
        private void BtnSave_Click(object sender, RoutedEventArgs e)
        {
            WaitBox wb = null;
            var     t  = new Thread(() =>
            {
                wb = new WaitBox();
                wb.ShowDialog();//不能用Show
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();

            List <CircuitInfo> allCircuits;

            CacheGraph.GetCircuits(out allCircuits);
            var dbCircuits  = allCircuits.Where(circuit => circuit.ParentCableId == Cable.CableId).ToList();
            var curCircuits = _circuits.Select(circuit => circuit.Info).ToList();

            CacheGraph.AddCircuits(curCircuits.Except(dbCircuits).ToList());
            CacheGraph.DelCircuits(dbCircuits.Except(curCircuits).ToList());


            List <DotInfo> alldots;

            CacheGraph.GetDos(out alldots);
            var dbDots  = alldots.Where(dot => dot.ParentCableId == Cable.CableId).ToList();
            var curDots = _dots.Select(dot => dot.Info).ToList();

            CacheGraph.AddDots(curDots.Except(dbDots).ToList());
            CacheGraph.DelDots(dbDots.Except(curDots).ToList());

            CacheGraph.CacheSaveCable();
            wb.Dispatcher.Invoke((Action)(() => wb.Close()));
            InfoBox.InfoMsg("保存成功");
        }
Exemple #3
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            BtnOk.IsEnabled = false;

            WaitBox wb = null;
            var     t  = new Thread(() =>
            {
                wb = new WaitBox();
                wb.ShowDialog();//不能用Show
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();


            int pointNo;
            int circuitNo;
            List <List <string> > shortCircuitInfoResult;
            bool isSelfCheckOk;

            if (!SampleCheck.BeginSampleCheck(out isSelfCheckOk, out shortCircuitInfoResult, out pointNo, out circuitNo))
            {
                InfoBox.ErrorMsg("自检失败,请检查设备连接");
                wb.Dispatcher.Invoke((Action)(() => wb.Close()));
                return;
            }


            if (!isSelfCheckOk)
            {
                CheckResults.Clear();
                var id = 0;
                foreach (var tmpList in shortCircuitInfoResult)
                {
                    var tmpResult = tmpList.Aggregate("", (current, tmp) => current + (tmp + "-"));
                    ++id;
                    CheckResults.Add(new BindCheckResult
                    {
                        Id          = id,
                        CheckResult = tmpResult.Remove(tmpResult.Length - 1, 1)
                    });
                }
            }

            BtnOk.IsEnabled = true;
            wb.Dispatcher.Invoke((Action)(() => wb.Close()));
            InfoBox.PlaySound(isSelfCheckOk);
            new ResultPopUp(isSelfCheckOk, true, true).ShowDialog();
        }
Exemple #4
0
        private void BtnStart_Click(object sender, RoutedEventArgs e)
        {
            WaitBox wb = null;
            var     t  = new Thread(() =>
            {
                wb = new WaitBox();
                wb.ShowDialog();//不能用Show
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();

            _viewModel.Sample();

            wb.Dispatcher.Invoke((Action)(() => wb.Close()));
        }
Exemple #5
0
        private void ManualCheck()
        {
            WaitBox wb = null;
            var     t  = new Thread(() =>
            {
                wb = new WaitBox();
                wb.ShowDialog();//不能用Show
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();

            int             pointNo;
            int             circuitNo;
            List <string[]> shortCircuitList;
            List <string[]> openCircuitList;

            if (!SampleCheck.ManualCheck(_circuitLoop, out pointNo, out circuitNo, out shortCircuitList, out openCircuitList))
            {
                wb.Dispatcher.Invoke((Action)(() => wb.Close()));
                return;
            }

            List <List <string> > shortCircuitResult;
            List <List <string> > openCircuitResult;

            CpldControl.DataParser.CommonParser.PointToCircuit(shortCircuitList, out shortCircuitResult);
            CpldControl.DataParser.CommonParser.PointToPair(openCircuitList, out openCircuitResult);

            RemoveErrorLine();
            var isCheckOk = true;                         //0-NG, 1-OK

            if (!(shortCircuitList.Count == 0 && openCircuitList.Count == 0))
            {
                isCheckOk = false;
                DrawErrorLines(shortCircuitResult, openCircuitResult);
            }
            string tmp;

            InfoBox.RichTextMsg(out tmp, isCheckOk, pointNo, circuitNo, shortCircuitResult, openCircuitList, _phyAddrMapToDot);

            TbInfo.Text = tmp;
            wb.Dispatcher.Invoke((Action)(() => wb.Close()));
            HandleCheckResult(isCheckOk, shortCircuitResult, openCircuitList);
        }
Exemple #6
0
        private void btnExport_Click(object sender, RoutedEventArgs e)
        {
            var sfdSaveFile = new Microsoft.Win32.SaveFileDialog
            {
                RestoreDirectory = true,
                DefaultExt       = "xlsx",
                Filter           = "Excel文件(*.xlsx)|*.xlsx",
                FileName         = "*.xlsx"
            };

            //设置保存文件的格式
            if (sfdSaveFile.ShowDialog() != true)
            {
                return;
            }

            if (File.Exists(sfdSaveFile.FileName))
            {
                var vHandle = _lopen(sfdSaveFile.FileName, OfReadwrite | OfShareDenyNone);
                if (vHandle == HfileError)
                {
                    InfoBox.ErrorMsg("文件已打开,请关闭后导出!");
                    CloseHandle(vHandle);
                    return;
                }

                CloseHandle(vHandle);
                File.Delete(sfdSaveFile.FileName);
            }

            WaitBox wb = null;
            var     t  = new Thread(() =>
            {
                wb = new WaitBox();
                wb.ShowDialog();//不能用Show
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            InfoBox.InfoMsg(WriteExcelToFile(sfdSaveFile.FileName)?"导出成功":"导出失败");
            wb.Dispatcher.Invoke((Action)(() => wb.Close()));
        }
Exemple #7
0
    private void OnGUI()
    {
        #region AlertDialog
        if (GUILayout.Button("AlertDialog"))
        {
            //加载一个AlertDialog
            AlertDialog aDialog = DialogBuilder.GetDialog(UiType.AlertDialog) as AlertDialog;
            //内容
            aDialog.SetTitle("test标题")
            .SetMessage("这是test的内容")
            .SetNegativeButton("取消", () =>
            {
                Debug.Log("Click Negative Button");
            })
            .SetPositiveButton("确定", () =>
            {
                Debug.Log("Click Positive Button");
            });
            //设置动画类型
            aDialog.SetAnimation(UiAnimationType.Zoom, 0.5f, UiAnimationType.Zoom, 0.5f);
            aDialog.Show();
        }
        #endregion

        #region InputDialog

        if (GUILayout.Button("InputDialog"))
        {
            InputDialog iDialog = DialogBuilder.GetDialog(UiType.InputDialog) as InputDialog;
            iDialog.SetTitle("请输入一个数字")
            .SetInputType(UnityEngine.UI.InputField.ContentType.IntegerNumber)
            .SetCloseButton(() =>
            {
                Debug.Log("关闭输入框");
            })
            .SetConfirmButton((string inputStr) =>
            {
                Debug.Log(string.Format("你输入了{0}", inputStr));
            });
            iDialog.Show();
        }

        #endregion

        #region MessageBox

        if (GUILayout.Button("MessageBox"))
        {
            MessageBox mbox = DialogBuilder.GetDialog(UiType.MessageBox) as MessageBox;
            mbox.SetMsg("这是一个小的小的小的消息框")
            .SetShowTime(1.5f)
            .SetCloseAction(() => { Debug.Log("MessageBox关闭了"); });
            mbox.Show();
        }

        #endregion

        #region ListChooseDialog

        if (GUILayout.Button("ListChooseDialog"))
        {
            ListChooseDialog lcDialog = DialogBuilder.GetDialog(UiType.ListChooseDialog) as ListChooseDialog;
            string[]         lsList   = { "香蕉", "苹果", "葡萄" };
            lcDialog.SetTitle("请选择你最喜欢的水果")
            .SetDropList(lsList)
            .SetConfirmAction((int x) =>
            {
                Debug.Log("你最喜欢的水果是:" + lsList[x]);
            });
            lcDialog.Show();
        }

        #endregion

        #region ProgressDialog

        if (GUILayout.Button("ProgressDialog"))
        {
            ProgressDialog pDialog = DialogBuilder.GetDialog(UiType.ProgressDialog) as ProgressDialog;
            pDialog.SetTitle("加载中,请稍等");
            pDialog.SetCompletedAction(() =>
            {
                Debug.Log("加载完成了");
                CancelInvoke("updatePrograssDialog");
            });
            pDialog.Show();
            float val = 0;
            DOTween.To(() => val, x => val = x, 1, 5).OnUpdate(() =>
            {
                pDialog.UpdateSlider(val);
            });
        }

        #endregion

        #region WaitBox

        if (GUILayout.Button("WaitBox"))
        {
            WaitBox wBox = DialogBuilder.GetDialog(UiType.WaitBox) as WaitBox;
            wBox.SetRotateSpeed(10)
            .SetWaitTime(5)
            .SetEndAction(() =>
            {
                Debug.Log("等待结束");
            });
            wBox.Show();
        }

        #endregion

        #region CountDownBox

        if (GUILayout.Button("CountDownBox"))
        {
            CountDownBox cdBox = DialogBuilder.GetDialog(UiType.CountDownBox) as CountDownBox;
            cdBox.SetCountShowTime(24, 0, 0)
            .SetCountWaitTime(20)
            .SetOverAction(() => { Debug.Log("计时结束"); });
            cdBox.Show();
        }

        #endregion

        #region ImageDialog

        if (GUILayout.Button("ImageDialog"))
        {
            //网络图片
            //List<ImageModel> images = new List<ImageModel>();
            //images.Add(new ImageModel("图片1", "http://www.bavlo.com/NewsImage/20120601205840_495.png"));
            //images.Add(new ImageModel("图片2", "http://img13.360buyimg.com/n0/jfs/t1978/18/1896890800/23165/d53299e/56812e0cNe1676e78.jpg"));
            //images.Add(new ImageModel("图片3", "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1516956451402&di=d836b57e165b8a09edf273136f398ce5&imgtype=0&src=http%3A%2F%2Fpic34.photophoto.cn%2F20150104%2F0005018399195651_b.jpg"));
            //本地图片
            List <ImageModel> images = new List <ImageModel>();
            images.Add(new ImageModel("unity800x300", Application.dataPath + "/Assets/imgs/unity800x300.png"));
            images.Add(new ImageModel("unity900x1200", Application.dataPath + "/Assets/imgs/unity900x1200.png"));
            images.Add(new ImageModel("unity1060x500", Application.dataPath + "/Assets/imgs/unity1060x500.png"));
            images.Add(new ImageModel("unity1070x800", Application.dataPath + "/Assets/imgs/unity1070x800.png"));
            images.Add(new ImageModel("unity2000x300", Application.dataPath + "/Assets/imgs/unity2000x300.png"));

            ImageDialog iDialog = DialogBuilder.GetDialog(UiType.ImageDialog) as ImageDialog;
            iDialog.SetTitle("图片")
            .SetCloseAction(() =>
            {
                Debug.Log("close image Dialog");
            })
            .SetImageList(images)
            .SetAnimation(UiAnimationType.Zoom, 1f, UiAnimationType.Zoom, 1f);
            iDialog.Show();
        }

        #endregion

        #region VideoDialog

        if (GUILayout.Button("VideoDialog"))
        {
            VideoDialog vDialog = DialogBuilder.GetDialog(UiType.VideoDialog) as VideoDialog;
            vDialog.SetAnimation(UiAnimationType.Zoom, 1, UiAnimationType.Zoom, 1);
            vDialog.Show();
        }

        #endregion
    }