Exemple #1
0
        private async Task RunTestSyncOrAsync(TestMethod testMethod, TestMethodAsync testMethodAsync, StsType stsType)
        {
            this.AppendText(string.Format("{0}: ", (testMethod != NullTestMethod) ? testMethod.Method.Name : testMethodAsync.Method.Name));
            try
            {
                Sts sts = StsFactory.CreateSts(stsType);
                AdalTests.InitializeTest();
                AdalTests.EndBrowserDialogSession();
                if (testMethod != NullTestMethod)
                {
                    testMethod(sts);
                }

                if (testMethodAsync != NullTestMethodAsync)
                {
                    await testMethodAsync(sts);
                }

                this.AppendText("PASSED.\n", Color.Green);
            }
            catch (AssertFailedException)
            {
                this.AppendText("FAILED!\n", Color.Red);
            }
            catch (Exception ex)
            {
                this.AppendText(string.Format("FAILED with exception '{0}'!\n", ex), Color.Red);
            }
        }
Exemple #2
0
 public SettingsWindow(Sts st)
 {
     InitializeComponent();
     stt = st;
     if (stt.ImpBpm)
     {
         ImpBpm.IsChecked = true;
     }
     if (stt.ImpMrg)
     {
         ImpMrg.IsChecked = true;
     }
     if (stt.RemoveBpm)
     {
         RemBpm.IsChecked = true;
     }
     if (stt.RemEpt)
     {
         RemEptt.IsChecked = true;
     }
     if (stt.TrsPpq)
     {
         trsppq.IsChecked = true;
     }
     if (stt.RemPB)
     {
         RemPB.IsChecked = true;
     }
     if (stt.RemPC)
     {
         RemPC.IsChecked = true;
     }
     offset.Value = stt.offst;
     minvol.Value = stt.minvol - 1;
 }
Exemple #3
0
        public MainPage()
        {
            this.InitializeComponent();

            this.NavigationCacheMode = NavigationCacheMode.Required;

            this.sts = StsFactory.CreateSts(StsType.AAD);
        }
Exemple #4
0
        public MainViewModel(IEnumerable <RepStructure> sts, StructureSet ss)
        {
            SSId       = ss.Id;
            Pat        = ss.Patient;
            Sts        = sts.ToList();
            Displaying = Sts.First();
            var brush = new SolidColorBrush(Sts.First().Color);

            Model3D = new GeometryModel3D(Sts.First().Mesh, new DiffuseMaterial(brush));
        }
Exemple #5
0
        public string CopyDisplaying()
        {
            Pat.BeginModifications();
            var ss     = Pat.StructureSets.First(e => e.Id == SSId);
            var d_copy = ss.AddStructure("CONTROL", Displaying.Id + "cp");

            d_copy.SegmentVolume = ss.Structures.First(e => e.Id == Displaying.Id);
            Sts.Add(new RepStructure(d_copy.Id, d_copy.Color, Helpers.SolveMeshReference(d_copy.MeshGeometry)));
            Logger += $"Copied {d_copy.Id} with success";
            return(d_copy.Id);
        }
Exemple #6
0
        public GeometryModel3D UpdateDisplaying(string id)
        {
            var model = new GeometryModel3D();

            Displaying     = Sts.First(e => e.Id == id);
            model.Geometry = Displaying.Mesh;
            var brush = new SolidColorBrush(Displaying.Color);

            model.Material = new DiffuseMaterial(brush);
            return(model);
        }
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            this.sts = StsFactory.CreateSts(StsType.AAD);

            this.fls = new FileLoggingSession("Test File Logging Session");
            this.fls.AddLoggingChannel(AdalTrace.AdalLoggingChannel, LoggingLevel.Verbose);

            this.ls = new LoggingSession("Test Logging Session");
            this.ls.AddLoggingChannel(AdalTrace.AdalLoggingChannel, LoggingLevel.Verbose);
        }
Exemple #8
0
        public void AcquireTokenWithPromptBehaviorNeverTestAsync()
        {
            // TODO: Not fully working at this point due to session cookies being deleted between WAB calls.

            Sts sts = Sts;

            // Should not be able to get a token silently passing redirectUri.
            var context = new AuthenticationContextProxy(sts.Authority, sts.ValidateAuthority);
            AuthenticationResultProxy result = context.AcquireToken(sts.ValidResource, sts.ValidClientId, sts.ValidDefaultRedirectUri, PromptBehaviorProxy.Never);

            AdalTests.VerifyErrorResult(result, Sts.InvalidArgumentError, "SSO");

            AuthenticationContextProxy.SetCredentials(sts.ValidUserName, sts.ValidPassword);
            result = context.AcquireToken(sts.ValidResource, sts.ValidClientId, sts.ValidDefaultRedirectUri);
            AdalTests.VerifySuccessResult(sts, result);

            AuthenticationContextProxy.ClearDefaultCache();
            result = context.AcquireToken(sts.ValidResource, sts.ValidClientId, sts.ValidDefaultRedirectUri);
            AdalTests.VerifySuccessResult(sts, result);

            // Should not be able to get a token silently on first try.
            result = context.AcquireToken(sts.ValidResource, sts.ValidClientId, null, PromptBehaviorProxy.Never);
            AdalTests.VerifyErrorResult(result, Sts.UserInteractionRequired, null);

            AuthenticationContextProxy.SetCredentials(sts.ValidUserName, sts.ValidPassword);
            // Obtain a token interactively.
            result = context.AcquireToken(sts.ValidResource, sts.ValidClientId, null);
            AdalTests.VerifySuccessResult(sts, result);

            // Obtain a token interactively.
            AuthenticationContextProxy.ClearDefaultCache();
            result = context.AcquireToken(sts.ValidResource, sts.ValidClientId, null);
            AdalTests.VerifySuccessResult(sts, result);

            AuthenticationContextProxy.SetCredentials(null, null);
            // Now there should be a token available in the cache so token should be available silently.
            result = context.AcquireToken(sts.ValidResource, sts.ValidClientId, null, PromptBehaviorProxy.Never);
            AdalTests.VerifySuccessResult(sts, result);

            // Clear the cache and silent auth should work via session cookies.
            AuthenticationContextProxy.ClearDefaultCache();
            result = context.AcquireToken(sts.ValidResource, sts.ValidClientId, null, PromptBehaviorProxy.Never);
            AdalTests.VerifySuccessResult(sts, result);

            // Clear the cache and cookies and silent auth should fail.
            AuthenticationContextProxy.ClearDefaultCache();
            AdalTests.EndBrowserDialogSession();
            result = context.AcquireToken(sts.ValidResource, sts.ValidClientId, null, PromptBehaviorProxy.Never);
            AdalTests.VerifyErrorResult(result, Sts.UserInteractionRequired, null);
        }
Exemple #9
0
        public static async Task <string> GetTokenIntegratedAuthAsync(Sts Sts)
        {
            try
            {
                PublicClientApplication app = new PublicClientApplication(Sts.Authority, "7c7a2f70-caef-45c8-9a6c-091633501de4");
                var result = await app.AcquireTokenWithIntegratedAuthAsync(Sts.ValidScope);

                return(result.Token);
            }
            catch (Exception ex)
            {
                string msg = ex.Message + "\n" + ex.StackTrace;

                return(msg);
            }
        }
Exemple #10
0
        public string MoveDisplaying(double x, double y, double z)
        {
            Pat.BeginModifications();
            var       mmchange = new VVector(x, y, z);
            var       ss       = Pat.StructureSets.First(e => e.Id == SSId);
            var       wantMove = ss.Structures.First(e => e.Id == Displaying.Id);
            Structure dCopy    = null;

            if (ss.Structures.Any(e => e.Id == Displaying.Id + "mv"))
            {
                dCopy = ss.Structures.Single(e => e.Id == Displaying.Id + "mv");
            }
            else
            {
                dCopy = ss.AddStructure("CONTROL", Displaying.Id + "mv");
            }
            dCopy.SegmentVolume = new SegShift(mmchange, ss, wantMove).MoveStructure();
            Logger += "Moved with success";
            Sts.Add(new RepStructure(dCopy.Id, dCopy.Color, Helpers.SolveMeshReference(dCopy.MeshGeometry)));
            return(dCopy.Id);
        }
Exemple #11
0
 protected void ChangeState_Click(object sender, EventArgs e)
 {
     try
     {
         if (GridView.SelectedIndex == -1)
         {
             throw new ValueNotSelectedException();
         }
         else
         {
             Sts.DataSource     = CreateDataSourceForStatus();
             Sts.DataTextField  = "StatusName";
             Sts.DataValueField = "StatusValue";
             Sts.DataBind();
             Sts.Visible          = true;
             UpdateButton.Visible = true;
         }
     }
     catch (Exception ex)
     {
         FailureText.Text     = ex.Message;
         ErrorMessage.Visible = true;
     }
 }
 private static void VerifySuccessResultAndTokenContent(Sts sts, AuthenticationResultProxy result, bool supportRefreshToken = true, bool supportUserInfo = true)
 {
     VerifySuccessResult(sts, result, supportRefreshToken, supportUserInfo);
 }
Exemple #13
0
        public override void EnterState()
        {
            FlagBitMgr.Instance.FindBy(this.singleSiteStateMachine.ConveyorNo).State.SubSitesCurrState.SingleSiteState = SingleSiteStateEnum.出板中;

            if (ConveyorPrmMgr.Instance.FindBy(this.singleSiteStateMachine.ConveyorNo).ExitIsSMEMA ||
                FlagBitMgr.Instance.FindBy(this.singleSiteStateMachine.ConveyorNo).UILevel.SelectedMode == UILevel.RunMode.PassThrough)
            {
                ConveyorController.Instance.InStoreSignalling(this.singleSiteStateMachine.ConveyorNo, true);
            }

            Task.Factory.StartNew(new Action(() =>
            {
                ConveyorController.Instance.SetWorkingSiteStopper(this.singleSiteStateMachine.ConveyorNo, false);

                DateTime stopperDelay = DateTime.Now;
                //如果是RTV
                if (Machine.Instance.Setting.MachineSelect == MachineSelection.RTV && ConveyorPrmMgr.Instance.FindBy(0).RTVPrm.IOEnable)
                {
                    while (!DiType.待料阻挡下位.Sts().Is(StsType.High))
                    {
                        if (this.isBreak)
                        {
                            return;
                        }

                        if (DateTime.Now - stopperDelay > TimeSpan.FromSeconds(ConveyorPrmMgr.Instance.FindBy(0).RTVPrm.IOStuckTime))
                        {
                            this.liftIsStuck = true;
                            return;
                        }

                        Thread.Sleep(2);
                    }
                }
                else
                {
                    while (DateTime.Now - stopperDelay < TimeSpan.FromMilliseconds(ConveyorPrmMgr.Instance.FindBy
                                                                                       (this.singleSiteStateMachine.ConveyorNo).StopperUpDelay))
                    {
                        if (this.isBreak)
                        {
                            return;
                        }
                    }
                }

                this.ConveyorRun();

                DateTime stuckTime = DateTime.Now;
                //SMEMA模式出板
                if (ConveyorPrmMgr.Instance.FindBy(this.singleSiteStateMachine.ConveyorNo).ExitIsSMEMA ||
                    FlagBitMgr.Instance.FindBy(this.singleSiteStateMachine.ConveyorNo).UILevel.SelectedMode == UILevel.RunMode.PassThrough)
                {
                    Sts SingleSiteExitSensor = new Sts();
                    int fallCount            = 0;
                    while (DateTime.Now - stuckTime < TimeSpan.FromMilliseconds(ConveyorPrmMgr.Instance.FindBy
                                                                                    (this.singleSiteStateMachine.ConveyorNo).DownStreamStuckTime))
                    {
                        SingleSiteExitSensor.Update(ConveyorController.Instance.SingleSiteExitSensor(this.singleSiteStateMachine.ConveyorNo).Value);
                        if (SingleSiteExitSensor.Is(StsType.IsFalling))
                        {
                            fallCount++;
                            Logger.DEFAULT.Info("fallingCount: " + fallCount + "\r\n");
                        }
                        if (!ConveyorPrmMgr.Instance.FindBy(this.singleSiteStateMachine.ConveyorNo).ReceiveSMEMAIsPulse &&
                            ConveyorController.Instance.DownstreamAskBoard(this.singleSiteStateMachine.ConveyorNo).Is(StsType.Low) &&
                            (fallCount >= 1))
                        {
                            this.taskIsDone = true;
                            return;
                        }
                        else if (ConveyorPrmMgr.Instance.FindBy(this.singleSiteStateMachine.ConveyorNo).ReceiveSMEMAIsPulse &&
                                 ConveyorController.Instance.SingleSiteExitSensor(this.singleSiteStateMachine.ConveyorNo).Is(StsType.Low))
                        {
                            this.taskIsDone = true;
                            return;
                        }
                    }
                }
                else
                {
                    while (DateTime.Now - stuckTime < TimeSpan.FromMilliseconds(ConveyorPrmMgr.Instance.FindBy
                                                                                    (this.singleSiteStateMachine.ConveyorNo).WorkingSitePrm.ExitStuckTime))
                    {
                        //自动出板
                        if (ConveyorPrmMgr.Instance.FindBy(this.singleSiteStateMachine.ConveyorNo).AutoExitBoard)
                        {
                            if (ConveyorController.Instance.SingleSiteExitSensor(this.singleSiteStateMachine.ConveyorNo).Is(StsType.IsFalling))
                            {
                                this.taskIsDone = true;
                                return;
                            }
                        }
                        //手动出板
                        else
                        {
                            if (ConveyorController.Instance.SingleSiteExitSensor(this.singleSiteStateMachine.ConveyorNo).Is(StsType.High))
                            {
                                ConveyorController.Instance.ConveyorAbortStop(this.singleSiteStateMachine.ConveyorNo);
                                this.taskIsDone = true;
                                return;
                            }
                        }
                    }
                }

                this.isStuck = true;
            }));
        }
Exemple #14
0
 public static Task NullTestMethodAsync(Sts sts)
 {
     return(null);
 }
Exemple #15
0
 public static void NullTestMethod(Sts sts)
 {
 }
 private static void VerifySuccessResultAndTokenContent(Sts sts, AuthenticationResultProxy result, bool supportRefreshToken = true, bool supportUserInfo = true)
 {
     VerifySuccessResult(sts, result, supportRefreshToken, supportUserInfo);
 }
Exemple #17
0
        public void LoadGroup(object sender, RoutedEventArgs e)
        {
            string         infile;
            OpenFileDialog sfg = new OpenFileDialog
            {
                Filter = "CJCAMM group files (*.cjcamm)|*.cjcamm"
            };

            if ((bool)sfg.ShowDialog())
            {
                infile = sfg.FileName;
            }
            else
            {
                return;
            }
            Stream gro  = File.Open(infile, FileMode.Open, FileAccess.Read, FileShare.Read);
            string head = "Hccdymerge  ";

            for (int i = 0; i < 12; i++)
            {
                if (head[i] != (char)gro.ReadByte())
                {
                    gro.Close();
                    MessageBox.Show("This is not a valid CJCAMM group file!", "Invalid file", MessageBoxButton.OK);
                    return;
                }
            }
            gro.ReadByte(); gro.ReadByte(); gro.ReadByte(); gro.ReadByte();
            List <ListBoxItem> itms = new List <ListBoxItem>();

            while (true)
            {
                string      filename = "";
                List <byte> fn       = new List <byte>();
                int         ch;
                bool        end = false;
                while ((ch = gro.ReadByte()) != 0)
                {
                    if (ch < 0)
                    {
                        if (filename == "" && ch == -1)
                        {
                            end = true;
                            break;
                        }
                        gro.Close();
                        MessageBox.Show("This is not a valid CJCAMM group file!", "Invalid file", MessageBoxButton.OK);
                        return;
                    }
                    fn.Add((byte)ch);
                }
                filename = Encoding.UTF8.GetString(fn.ToArray());
                if (end)
                {
                    break;
                }
                ListBoxItem itm = new ListBoxItem
                {
                    Content = filename
                };
                Sts st = new Sts();
                while ((ch = gro.ReadByte()) != 0)
                {
                    if (ch < 32)
                    {
                        gro.Close();
                        MessageBox.Show("This is not a valid CJCAMM group file!", "Invalid file", MessageBoxButton.OK);
                        return;
                    }
                    if (ch == 'o')
                    {
                        int offst = 0;
                        for (int j = 0; j < 4; j++)
                        {
                            int sh = gro.ReadByte();
                            if (sh == -1)
                            {
                                gro.Close();
                                MessageBox.Show("This is not a valid CJCAMM group file!", "Invalid file", MessageBoxButton.OK);
                                return;
                            }
                            offst = offst * 256 + sh;
                        }
                        st.offst = offst;
                    }
                    if (ch == 'v')
                    {
                        st.minvol = gro.ReadByte();
                        if (st.minvol == -1)
                        {
                            gro.Close();
                            MessageBox.Show("This is not a valid CJCAMM group file!", "Invalid file", MessageBoxButton.OK);
                            return;
                        }
                        st.minvol++;
                    }
                    if (ch == 'B')
                    {
                        st.ImpBpm = true;
                    }
                    if (ch == 'M')
                    {
                        st.ImpMrg = true;
                    }
                    if (ch == 'R')
                    {
                        st.RemoveBpm = true;
                    }
                    if (ch == 'E')
                    {
                        st.RemEpt = true;
                    }
                    if (ch == 'P')
                    {
                        st.TrsPpq = true;
                    }
                    if (ch == 'W')
                    {
                        st.RemPB = true;
                    }
                    if (ch == 'C')
                    {
                        st.RemPC = true;
                    }
                }
                itm.DataContext = st;
                itms.Add(itm);
            }
            gro.Close();
            for (int i = 0; i < itms.Count; i++)
            {
                MidisAdded.Items.Add(itms[i]);
            }
        }
Exemple #18
0
        public void SaveGroup(object sender, RoutedEventArgs w)
        {
            Groups grp = new Groups
            {
                ms   = new List <Groups>(),
                file = ".cjcamm",
                st   = new Sts()
            };

            try
            {
                for (int i = 0; i < MidisAdded.Items.Count; i++)
                {
                    Groups gr = getgroup((string)((ListBoxItem)MidisAdded.Items[i]).Content, 0);
                    gr.st = (Sts)((ListBoxItem)MidisAdded.Items[i]).DataContext;
                    grp.ms.Add(gr);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("One of the group isn't a valid CJCAMM group or it contains an infinite recursion!", "Invalid group", MessageBoxButton.OK);
                return;
            }
            string     output;
            SaveWindow sfg = new SaveWindow();

            if (grp.ms.Count > 0)
            {
                sfg.ppq.Value = grp.ms[0].ppq;
            }
            sfg.ShowInTaskbar = false;
            sfg.Owner         = this;
            sfg.ShowDialog();
            if (!sfg.ss)
            {
                return;
            }
            SaveFileDialog save = new SaveFileDialog
            {
                Filter = "CJCAMM group files (*.cjcamm)|*.cjcamm"
            };

            if ((bool)save.ShowDialog())
            {
                output = save.FileName;
            }
            else
            {
                return;
            }
            Stream gro  = File.Open(output, FileMode.Create, FileAccess.Write, FileShare.Write);
            string head = "Hccdymerge  ";

            byte[] Head = new byte[12];
            for (int i = 0; i < 12; i++)
            {
                Head[i] = (byte)head[i];
            }
            gro.Write(Head, 0, 12);
            List <byte> go = new List <byte>
            {
                (byte)(Convert.ToInt32(sfg.ppq.Value) / 256),
                (byte)(Convert.ToInt32(sfg.ppq.Value) % 256),
                0,
                1
            };

            for (int i = 0; i < MidisAdded.Items.Count; i++)
            {
                string file = (string)((ListBoxItem)MidisAdded.Items[i]).Content;
                byte[] arr  = Encoding.UTF8.GetBytes(file);
                for (int j = 0; j < arr.Length; j++)
                {
                    go.Add(arr[j]);
                }
                go.Add(0);
                Sts st = (Sts)((ListBoxItem)MidisAdded.Items[i]).DataContext;
                if (st.offst > 0)
                {
                    go.Add((byte)'o');
                    go.Add((byte)(st.offst / 256 / 256 / 256));
                    go.Add((byte)(st.offst / 256 / 256 % 256));
                    go.Add((byte)(st.offst / 256 % 256));
                    go.Add((byte)(st.offst % 256));
                }
                if (st.minvol > 0)
                {
                    go.Add((byte)'v');
                    go.Add((byte)(st.minvol - 1));
                }
                if (st.RemoveBpm)
                {
                    go.Add((byte)'R');
                }
                if (st.ImpBpm)
                {
                    go.Add((byte)'B');
                }
                if (st.ImpMrg)
                {
                    go.Add((byte)'M');
                }
                if (st.RemEpt)
                {
                    go.Add((byte)'E');
                }
                if (st.TrsPpq)
                {
                    go.Add((byte)'P');
                }
                if (st.RemPB)
                {
                    go.Add((byte)'W');
                }
                if (st.RemPC)
                {
                    go.Add((byte)'C');
                }
                go.Add(0);
            }
            gro.Write(go.ToArray(), 0, go.Count);
            gro.Close();
        }