Ejemplo n.º 1
0
        private void buttonLogout_Click(object sender, EventArgs e)
        {
            ParameterUrl Logout = new ParameterUrl();

            Logout.musename = activeUser;
            Logout.password = "";
            Logout.mode     = API_MODE.LOGOUT;
            Logout.timeout  = 300000;
            Logout.url      = string.Format("{0}{1}", mainUrl, "logout.php").Trim();
            Logout.method   = API_METHOD.POST;
            try
            {
                RESPONSE_FEEDBACK response = new NetworkManager().Connect(Logout);
                if (response.status == false)
                {
                    throw new Exception(string.Format("Logout Failed. {0}", response.message));
                }
                else
                {
                    status = response.status;
                }
                ActionTaken = DialogStep.LOGIN;
                MainDashboard.RunLoop("BypassForm");
            }
            catch (Exception ex)
            {
                MainDashboard.Append(Level.Error, String.Format("what:{0} {1}", ex.HelpLink, ex.Message));
            }
        }
Ejemplo n.º 2
0
        public void SaveLoadPerformance()
        {
            for (int j = 1; j < 20; j++)
            {
                int innerSteps    = j * 5;
                int outerSteps    = 10;
                var innerPlanName = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".TapPlan");
                var outerPlanName = Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".TapPlan");
                {
                    var innerPlan = new TestPlan();
                    for (int i = 0; i < innerSteps; i++)
                    {
                        var step = new DialogStep();
                        innerPlan.Steps.Add(new DialogStep());
                        var td = TypeData.GetTypeData(step);
                        foreach (var mem in td.GetMembers())
                        {
                            if (mem.Writable == false)
                            {
                                continue;
                            }
                            if (mem.IsBrowsable() == false)
                            {
                                continue;
                            }
                            if (mem.HasAttribute <XmlIgnoreAttribute>())
                            {
                                continue;
                            }
                            innerPlan.ExternalParameters.Add(step, mem, mem.Name);
                        }
                    }


                    innerPlan.Save(innerPlanName);
                }

                {
                    var outerPlan = new TestPlan();
                    for (int i = 0; i < outerSteps; i++)
                    {
                        var tpr = new TestPlanReference();
                        tpr.Filepath.Text = innerPlanName;
                        outerPlan.Steps.Add(tpr);
                    }

                    outerPlan.Save(outerPlanName);
                }
                {
                    var sw       = Stopwatch.StartNew();
                    var loadPlan = TestPlan.Load(outerPlanName);
                    var loadtime = sw.Elapsed;
                    sw.Restart();
                    loadPlan.Save(outerPlanName);
                    var savetime = sw.Elapsed;
                    Debug.WriteLine("{2}, {0}, {1}", loadtime.TotalMilliseconds,
                                    savetime.TotalMilliseconds, outerSteps);
                }
            }
        }
Ejemplo n.º 3
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            museid = this.textBoxUser.Text;
            ParameterUrl LoginPHP = new ParameterUrl();

            LoginPHP.musename = museid;
            LoginPHP.password = password;
            LoginPHP.mode     = API_MODE.LOGIN;
            LoginPHP.timeout  = 300000;
            LoginPHP.url      = string.Format("{0}{1}", mainUrl, "login.php").Trim();
            LoginPHP.method   = API_METHOD.POST;
            try
            {
                RESPONSE_FEEDBACK response = new NetworkManager().Connect(LoginPHP);
                if (response.status == false)
                {
                    throw new Exception(string.Format("Login Failed. {0}", response.message));
                }
                status      = response.status;
                actionTaken = DialogStep.BYPASS;
                DialogDashboard.RunLoop("MainForm");
            }
            catch (Exception ex)
            {
                DialogDashboard.Append(Level.Error, String.Format("what:{0} {1}", ex.HelpLink, ex.Message));
            }
        }
Ejemplo n.º 4
0
        private async void SubmitButton_Click(object sender, RoutedEventArgs e)
        {
            if (!App.WebService.IsInternetAvailable())
            {
                Messages.ShowInternetAvailableMessage();
                return;
            }
            if (PageState == DialogStep.ThirdStep)
            {
                if (!App.WebService.IsInternetAvailable())
                {
                    Messages.ShowInternetAvailableMessage();
                    return;
                }
                var responce = await App.WebService.SendJsonResponse(CallRequestData.MasterId, App.AppRepository.User.Data.Number,
                                                                     DescriptionTextBox.Text, TargetDatePicker.Date.Date);

                var json = await App.Deserializer.Execute <SimpleAnswer>(responce.GetResponseStream());

                if (json.Answer == JsonAnswers.OK)
                {
                    flipFromThirdToMain.Begin();
                    PageState = DialogStep.Main;
                    MessageDialog msgBox = new MessageDialog("", "Заявка отправлена");
                    await msgBox.ShowAsync();
                }
                else
                {
                    flipFromThirdToMain.Begin();
                    PageState = DialogStep.Main;
                    MessageDialog msgBox = new MessageDialog(json.Answer, "Ошибка");
                    await msgBox.ShowAsync();
                }
            }
        }
Ejemplo n.º 5
0
        public override string Initialize()
        {
            _unknownNumber = (new Random()).Next(9);
            _retriesLeft   = 5;
            _mentionedNumbers.Clear();
            CurrentStep = new DialogStep(ProcessGuessResponse, DidntCatchResponse);

            return("Ok. Let's start. Guess a number from 0 to 9");
        }
Ejemplo n.º 6
0
        public void ScopeStepTest()
        {
            var diag = new DialogStep()
            {
                UseTimeout = true
            };
            var    diag2         = new DialogStep();
            var    scope         = new SequenceStep();
            string parameterName = "Scope\"" + DisplayAttribute.GroupSeparator + "Title"; // name intentionally weird to mess with the serializer.

            scope.ChildTestSteps.Add(diag);
            scope.ChildTestSteps.Add(diag2);
            var member = TypeData.GetTypeData(diag).GetMember("Title");

            member.Parameterize(scope, diag, parameterName);
            member.Parameterize(scope, diag2, parameterName);
            TypeData.GetTypeData(diag).GetMember("Timeout").Parameterize(scope, diag, "Group\\The Timeout");

            var annotation  = AnnotationCollection.Annotate(scope);
            var titleMember = annotation.GetMember(parameterName);

            titleMember.Get <IStringValueAnnotation>().Value = "New title";
            annotation.Write();
            Assert.AreEqual("New title", diag.Title);
            Assert.AreEqual("New title", diag2.Title);

            var timeoutMember = annotation.GetMember("Group\\The Timeout");

            Assert.IsFalse(timeoutMember.Get <IAccessAnnotation>().IsReadOnly);
            Assert.AreEqual("Group", TypeData.GetTypeData(scope).GetMember("Group\\The Timeout").GetDisplayAttribute().Group[0]);

            var plan = new TestPlan();

            plan.Steps.Add(scope);
            var str          = new TapSerializer().SerializeToString(plan);
            var plan2        = (TestPlan) new TapSerializer().DeserializeFromString(str);
            var scope2       = plan2.Steps[0];
            var annotation2  = AnnotationCollection.Annotate(scope2);
            var titleMember2 = annotation2.GetMember(parameterName);

            Assert.IsNotNull(titleMember2);
            titleMember2.Get <IStringValueAnnotation>().Value = "New Title 2";
            annotation2.Write();
            foreach (var step in scope2.ChildTestSteps.Cast <DialogStep>())
            {
                Assert.AreEqual(step.Title, "New Title 2");
            }

            var forwardedMember = (ParameterMemberData)TypeData.GetTypeData(scope2).GetMember(parameterName);

            Assert.IsNotNull(forwardedMember);

            member.Unparameterize(forwardedMember, scope2.ChildTestSteps[0]);
            Assert.IsNotNull(TypeData.GetTypeData(scope2).GetMember(parameterName));
            member.Unparameterize(forwardedMember, scope2.ChildTestSteps[1]);
            Assert.IsNull(TypeData.GetTypeData(scope2).GetMember(parameterName)); // last 'Title' removed.
        }
Ejemplo n.º 7
0
        public override string Initialize()
        {
            _unknownNumber = (new Random()).Next(9);
            _retriesLeft = 5;
            _mentionedNumbers.Clear();
            CurrentStep = new DialogStep(ProcessGuessResponse, DidntCatchResponse);

            return "Ok. Let's start. Guess a number from 0 to 9";
        }
Ejemplo n.º 8
0
        public async Task Welcome()
        {
            var testCase = new DialogStep()
            {
                Action        = "message to the bot",
                ExpectedReply = "message from the bot",
            };

            await TestRunner.RunTestCaseAsync(testCase);
        }
Ejemplo n.º 9
0
        private void buttonAccept_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxMuseName.Text))
            {
                System.Windows.Forms.MessageBox.Show(this, string.Format("user name smaller than or empty {0}", textBoxMuseName.Text), "User registration", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (string.IsNullOrEmpty(textBoxMuseId.Text))
            {
                System.Windows.Forms.MessageBox.Show(this, string.Format("user name smaller than or empty {0}", textBoxMuseId.Text), "User registration", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            ParameterUrl Register = new ParameterUrl();

            Register.url      = string.Format("{0}{1}", mainUrl, "register.php");
            Register.musename = textBoxMuseName.Text;
            Register.password = password;
            Register.museid   = textBoxMuseId.Text;
            Register.mode     = API_MODE.REGISTER;
            Register.timeout  = 30000;
            Register.method   = API_METHOD.POST;
            try
            {
                RESPONSE_FEEDBACK response = new NetworkManager().Connect(Register);
                if (response.status == false)
                {
                    actionTaken = DialogStep.LOGIN;
                    DialogLogging.RunLoop("RegisterForm");
                    throw new Exception(string.Format("Registration Failed. {0}", response.message));
                }
                //! create email
                Parameter_Email NewEmail = new Parameter_Email();
                NewEmail.display_name = textBoxMuseName.Text;
                NewEmail.msg_subject  = string.Format("User name:{0} - id:{1}", textBoxMuseName.Text, textBoxMuseId.Text);
                NewEmail.msg_body     = password;
                //! sender email
                NewEmail.sender_address = "*****@*****.**";
                //! recepient email
                NewEmail.receive_address = "*****@*****.**";
                //! credential sender email
                NewEmail.username = "";
                NewEmail.password = "";

                //! send email
                new NetworkManager().SendEmail(NewEmail);

                MessageBox.Show(this, string.Format("Registration success {0}. Please be patien an admin will activated.", textBoxMuseName.Text), "User registration", MessageBoxButtons.OK, MessageBoxIcon.Information);
                actionTaken = DialogStep.LOGIN;
                DialogLogging.RunLoop("RegisterForm");
            }
            catch (Exception ex)
            {
                DialogLogging.Append(Level.Error, String.Format("what:{0} {1}", ex.HelpLink, ex.Message));
            }
        }
Ejemplo n.º 10
0
        //! <>--<>
        DialogStep Loopings(string firstForm)
        {
            DialogStep nextstep = DialogStep.LOGIN;
            string     nextForm = firstForm;
            bool       StopLoop = true;

            while (StopLoop)
            {
                //! getting step from mainform
                Form currentForm = null;
                currentForm = this.ScenarioForm[firstForm] as Form;
                nextstep    = ((IFORM)currentForm).StepResult;

                //! 1. nextstep register
                //! 2. nextstep Bypass

                switch (nextstep)
                {
                case DialogStep.REGISTER:
                    nextForm = this.GetNextDialog(currentForm, nextstep);
                    NextDialogHandler(nextForm, nextstep);
                    currentForm.Dispose();
                    currentForm      = this.ScenarioForm[nextForm] as Form;
                    currentForm.Dock = DockStyle.Top;
                    currentForm.Show();
                    StopLoop = false;
                    break;

                case DialogStep.BYPASS:
                    nextForm = this.GetNextDialog(currentForm, nextstep);
                    NextDialogHandler(nextForm, nextstep);
                    currentForm.Dispose();
                    currentForm      = this.ScenarioForm[nextForm] as Form;
                    currentForm.Dock = DockStyle.Top;
                    currentForm.Show();
                    StopLoop = false;
                    break;

                case DialogStep.LOGIN:
                    nextForm = this.GetNextDialog(currentForm, nextstep);
                    NextDialogHandler(nextForm, nextstep);
                    currentForm.Dispose();
                    currentForm      = this.ScenarioForm[nextForm] as Form;
                    currentForm.Dock = DockStyle.Top;
                    currentForm.Show();
                    StopLoop = false;
                    break;
                }
            }
            return(nextstep);
        }
Ejemplo n.º 11
0
        //! ----->>
        string GetNextDialog(Form curForm, DialogStep firstStep)
        {
            string curFormName = curForm.Name;

            if (curFormName == "MainForm" && firstStep == DialogStep.BYPASS)
            {
                return("BypassForm");
            }
            if (curFormName == "MainForm" && firstStep == DialogStep.REGISTER)
            {
                return("RegisterForm");
            }
            return("MainForm");
        }
Ejemplo n.º 12
0
 //! -->>***
 void NextDialogHandler(string curForm, DialogStep step)
 {
     if (curForm.Equals("BypassForm") && step == DialogStep.BYPASS)
     {
         SetupBypassForm();
     }
     if (curForm.Equals("RegisterForm") && step == DialogStep.REGISTER)
     {
         SetupRegisterForm();
     }
     if (curForm.Equals("MainForm") && step == DialogStep.LOGIN)
     {
         SetupMainForm();
     }
 }
Ejemplo n.º 13
0
        private int _parseSelectedChoice(SocketMessage message, DialogStep currentStep)
        {
            var highest    = 0;
            var highestKey = "";

            foreach (var choice in currentStep.PossibleChoices.Keys)
            {
                var current = choice.ToLower().WordMatches(message.Content.ToLower());
                if (current > highest && current > 0)
                {
                    highest    = current;
                    highestKey = choice;
                }
            }
            return(currentStep.PossibleChoices[highestKey]);
        }
Ejemplo n.º 14
0
        private static async Task _displayStep(IDMChannel dmChannel, DialogStep currentStep)
        {
            if (!string.IsNullOrEmpty(currentStep.ImageUrl))
            {
                var emb = new EmbedBuilder()
                {
                    ImageUrl = currentStep.ImageUrl
                };
                await dmChannel.SendMessageAsync("", false, emb.Build());
            }
            var nextDialog = new StoryFormatter()
                             .AddText(currentStep);

            if (currentStep.PossibleChoices.Count > 0)
            {
                nextDialog.AddOptions(currentStep.PossibleChoices.Keys.ToList());
            }

            await dmChannel.SendMessageAsync(nextDialog.BuildDialog(), false);
        }
Ejemplo n.º 15
0
 private void HardwareButtons_BackPressed(object sender, BackPressedEventArgs e)
 {
     if (PageState == DialogStep.FirstStep)
     {
         flipFromFirstToMain.Begin();
         PageState = DialogStep.Main;
         e.Handled = true;
     }
     if (PageState == DialogStep.SecondStep)
     {
         flipFromSecondToFirst.Begin();
         PageState = DialogStep.FirstStep;
         e.Handled = true;
     }
     if (PageState == DialogStep.ThirdStep)
     {
         flipFromThirdToSecond.Begin();
         PageState = DialogStep.SecondStep;
         e.Handled = true;
     }
 }
Ejemplo n.º 16
0
 public override string Initialize()
 {
     CurrentStep = new DialogStep(ProcessResponseOnYouAreLate, DidntCatchResponse);
     return("Have you seen what time it is? We are late!\nWhere are you?");
 }
Ejemplo n.º 17
0
 public StoryFormatter AddText(DialogStep step)
 {
     _stringBuilder.AppendLine(step.Text);
     return(this);
 }
Ejemplo n.º 18
0
 private void buttonRegister_Click(object sender, EventArgs e)
 {
     actionTaken = DialogStep.REGISTER;
     DialogDashboard.RunLoop("MainForm");
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Вызывается перед отображением этой страницы во фрейме.
        /// </summary>
        /// <param name="e">Данные события, описывающие, каким образом была достигнута эта страница.
        /// Этот параметр обычно используется для настройки страницы.</param>
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            HardwareButtons.BackPressed += HardwareButtons_BackPressed;
            CallRequestData              = new CallRequest();

            if (!App.WebService.IsInternetAvailable())
            {
                Messages.ShowInternetAvailableMessage();
                return;
            }
            if (categoryButtons == null)
            {
                categoryButtons = new List <Button>();
                var response = await App.WebService.GetCategoriesJsonResponse();

                var categories = await App.Deserializer.Execute <CategoriesAnswer>(response.GetResponseStream());

                CategoryProgressRing.IsActive = false;

                foreach (var category in categories.Categories)
                {
                    var button = new Button
                    {
                        Style   = CategoriesStack.Resources["ListItem"] as Style,
                        Content = category.Name
                    };
                    button.Click += async(sender, c) =>
                    {
                        if (PageState == DialogStep.FirstStep)
                        {
                            if (!App.WebService.IsInternetAvailable())
                            {
                                Messages.ShowInternetAvailableMessage();
                                return;
                            }
                            flipFromFirstToSecond.Begin();
                            PageState = DialogStep.SecondStep;
                            CallRequestData.CategoryId = category.Id;

                            MasterStack.Children.Clear();
                            masterButtons = new List <Button>(10);
                            var res = await App.WebService.GetMasterJsonResponse(CallRequestData.CategoryId);

                            var masters = await App.Deserializer.Execute <MastersAnswer>(res.GetResponseStream());

                            MasterProgressRing.IsActive = false;

                            foreach (var master in masters.Masters)
                            {
                                var btn = new Button
                                {
                                    Style   = MasterStack.Resources["ListItem"] as Style,
                                    Content = master.Name
                                };

                                btn.Click += (senderc, cc) =>
                                {
                                    if (PageState == DialogStep.SecondStep)
                                    {
                                        if (!App.WebService.IsInternetAvailable())
                                        {
                                            Messages.ShowInternetAvailableMessage();
                                            return;
                                        }
                                        flipFromSecondToThird.Begin();
                                        PageState = DialogStep.ThirdStep;
                                        CallRequestData.MasterId = master.Id;
                                    }
                                };
                                masterButtons.Add(btn);
                                MasterStack.Children.Add(btn);
                            }
                        }
                    };
                    categoryButtons.Add(button);
                    CategoriesStack.Children.Add(button);
                }
            }
        }
Ejemplo n.º 20
0
        public override string Initialize()
        {
            CurrentStep = new DialogStep(ProcessResponseOnHowAreYouText, ProcessResponseOnHowAreYouImage);

            return("Hey! How are you?");
        }
Ejemplo n.º 21
0
        public void TestNameFormat()
        {
            var culture = System.Threading.Thread.CurrentThread.CurrentCulture;

            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            try
            {
                DelayStep delay = new DelayStep();
                delay.DelaySecs = 1.0;
                delay.Name      = "Delay of {Time Delay} and {Time Delay}";
                var result = delay.GetFormattedName();
                Assert.AreEqual(result, "Delay of 1 s and 1 s");

                delay.Name = "Delay of {} and {Time Delay2}";
                result     = delay.GetFormattedName();
                Assert.AreEqual(result, delay.Name);
                delay.Name = "Delay of {{}} and {{Time Delay2}}";
                result     = delay.GetFormattedName();
                Assert.AreEqual(result, delay.Name);
                delay.Name = "Delay of {{}} and {{Time Delay}}";
                result     = delay.GetFormattedName();
                Assert.AreEqual(result, "Delay of {{}} and {1 s}");
                DialogStep diag = new DialogStep();
                diag.Name    = "Timeout of {Timeout Timeout}";
                diag.Timeout = 2;
                var result2 = diag.GetFormattedName();
                Assert.AreEqual(result2, "Timeout of 2 s");

                SCPIRegexStep scpiRegex = new SCPIRegexStep();
                scpiRegex.RegularExpressionPattern = new Enabled <string> {
                    Value = "asd", IsEnabled = true
                };
                scpiRegex.Name = "|{Set Verdict Regular Expression}|";
                var result3 = scpiRegex.GetFormattedName();
                Assert.AreEqual(result3, "|asd|");

                scpiRegex.Instrument = null;
                scpiRegex.Name       = "|{Instrument}|";
                var result4 = scpiRegex.GetFormattedName();
                Assert.AreEqual(result4, "|Not Set|");

                scpiRegex.Name = "|{asdwasd}|";
                var result5 = scpiRegex.GetFormattedName();
                Assert.AreEqual(result5, scpiRegex.Name);

                var arrayStep = new NullArrayTest()
                {
                    TestArray = new int[] { 1, 3 }
                };
                arrayStep.Name = "{TestArray}";
                var result6 = arrayStep.GetFormattedName();
                Assert.AreEqual(result6, "1, 3");

                var funkyArray = new FunkyArrayStep();
                funkyArray.Name = "{Array}";
                var result7 = funkyArray.GetFormattedName();
                Assert.AreEqual(result7.Count(x => x == ','), funkyArray.Array.Length - 1);
                Assert.IsTrue(result7.Contains(", Test"));
            }
            finally
            {
                System.Threading.Thread.CurrentThread.CurrentCulture = culture;
            }
        }
Ejemplo n.º 22
0
        public override string Initialize()
        {
            CurrentStep = new DialogStep(ProcessResponseOnHowAreYouText, ProcessResponseOnHowAreYouImage);

            return "Hey! How are you?";
        }
Ejemplo n.º 23
0
 public override string Initialize()
 {
     CurrentStep = new DialogStep(FinalResponse, FinalResponse);
     return("I will be happy to have a talk with you a little later");
 }
Ejemplo n.º 24
0
 private void buttonCancel_Click(object sender, EventArgs e)
 {
     actionTaken = DialogStep.LOGIN;
     DialogLogging.RunLoop("RegisterForm");
 }
Ejemplo n.º 25
0
 public override string Initialize()
 {
     CurrentStep = new DialogStep(ProcessResponseOnYouAreLate, DidntCatchResponse);
     return "Have you seen what time it is? We are late!\nWhere are you?";
 }
Ejemplo n.º 26
0
 public void RunLoop(string nform)
 {
     dialogStep = this.Loopings(nform);
 }