Пример #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string user = username.Text;
            string pass = password.Password;

            rec = recemail.Text;
            var Page2 = new PaymentConfirmOTP();
            var Page3 = new LoginOTP();
            var ec    = new EnterCredentials();

            LibraryUtils.EmailLogin(user, pass);

            if (LibraryUtils.IsElementPresent(By.XPath("//span[contains(text(), 'Incorrect')]")))
            {
                MessageBox.Show("Invalid sign-in details. Please try again");
            }
            else if (LibraryUtils.IsElementPresent(By.XPath("//input[@id = 'otp']")))
            {
                Page3.Show();
                this.Close();
            }
            else if (LibraryUtils.IsElementPresent(By.XPath("//span[text() = 'PAY']")))
            {
                LibraryUtils.conBen(rec);
                LibraryUtils.money();
                LibraryUtils.aftermoney();
                this.Close();
            }
        }
Пример #2
0
        public async Task <IHttpActionResult> PostValidate([FromBody] JObject value)
        {
            var url      = (string)value["url"];
            var resource = await LibraryUtils.TryValidateResource(url);

            return(Ok(resource));
        }
Пример #3
0
        private void Cancel_Click(object sender, RoutedEventArgs e)
        {
            LibraryUtils.Cancel();
            var ec = new EnterCredentials();

            ec.Show();
            this.Close();
        }
Пример #4
0
    //Check should be pplaced to see if the user has enough credit for transaction, if they do not they should be notified  they don't have funds in account
    public static void aftermoney()
    {
        var Page2 = new easyeftthc.PaymentConfirmOTP();

        if (LibraryUtils.IsElementPresent(By.XPath("//span[text() = 'The amount exceeds your available balance']")))
        {
            LibraryUtils.driver.Quit();
        }
        else
        {
            LibraryUtils.conPay();
            Page2.Show();
        }
    }
Пример #5
0
        public async Task <IHttpActionResult> PostResource([FromBody] JObject value)
        {
            var start      = (int?)value["start"];
            var finish     = (int?)value["finish"];
            var hasSegment = start.HasValue && finish.HasValue;

            if (hasSegment && ((start.Value < 0) || (finish.Value < 0) || (start >= finish)))
            {
                return(BadRequest("Segment time is wrong."));
            }

            var url      = (string)value["url"];
            var resource = await LibraryUtils.TryValidateResource(url);

            // If validation is unsuccessfull, TryValidateResource returns null
            if ((resource == null) || (resource.Format != LibraryUtils.Formats.Youtube))
            {
                return(BadRequest("Resource not found."));
            }

            // Idempotent. The stored procedure returns the processed resource back.
            resource = (await DapperHelper.QueryResilientlyAsync <ResourceDto>("dbo.libCreatePersonalResource",
                                                                               new
            {
                UserId = this.GetUserId(),
                Format = resource.Format,
                NaturalKey = resource.NaturalKey,
                Segment = hasSegment ? Resource.BuildSegment(start.Value, finish.Value) : null,
                Title = resource.Title,
                CategoryIds = LibraryUtils.KnownCategories.GameCopycat,
                Tags = LibraryUtils.KnownTags.GameCopycat,
                HasVideo = resource.HasVideo,
                IsForCopycat = true,
            },
                                                                               CommandType.StoredProcedure))
                       .Single();

            var transcript = (string)value["transcript"];

            if (!String.IsNullOrEmpty(transcript))
            {
                await InternalSaveTranscript(resource.Id, transcript);
            }

            return(Ok(resource));
        }
Пример #6
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string otp = conotp.Password;
            var    ec  = new EnterCredentials();

            LibraryUtils.OTPSequence(otp);

            if (LibraryUtils.con.Contains("successful"))
            {
                MessageBox.Show("Payment successful");
            }
            else
            {
                MessageBox.Show("Payment unsuccessful");
            }

            ec.Show();
            this.Close();
        }
Пример #7
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string otp   = logOTP.Password;
            var    Page2 = new PaymentConfirmOTP();

            LibraryUtils.loginOTP(otp);

            if (LibraryUtils.IsElementPresent(By.XPath("//span[text() = 'PAY']")))
            {
                LibraryUtils.conBen(EnterCredentials.rec);
                LibraryUtils.money();
            }

            if (LibraryUtils.IsElementPresent(By.XPath("//span[text() = 'The amount exceeds your available balance']")))
            {
                LibraryUtils.driver.Quit();
            }
            else
            {
                LibraryUtils.conPay();
                Page2.Show();
                this.Close();
            }
        }
Пример #8
0
    //public static string rec;



    //Mehtod should be called after user enters credentialss and clicks the login button
    public static void EmailLogin(String email, String password)
    {
        FirefoxOptions option = new FirefoxOptions();

        option.AddArguments("--headless", "--disable-gpu", "--window-size=1200,900");
        //System.Environment.SetEnvironmentVariable("webdriver.chrome.driver", @"C:\EFT\chromedriver.exe");
        //driver = new ChromeDriver("C:\\EFT", option);
        //var service = ChromeDriverService.CreateDefaultService(AppDomain.CurrentDomain.BaseDirectory);
        //Convert.ToString(service);
        //option.BinaryLocation = "C:\\Users\\Public\\chromedriver.exe";
        //string opt = Convert.ToString(service);
        //opt += @".chromedriver";
        //option.BinaryLocation = @"C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe";
        //System.Environment.SetEnvironmentVariable("webdriver.chrome.driver", "C:\\Users\\Public\\chromedriver.exe");
        // ChromeOptions opts = new ChromeOptions();
        // opts.AddExcludedArgument("enable-automation");
        //opts.AddAdditionalCapability("useAutomationExtension", false);
        driver = new FirefoxDriver(/*service,*/ option);

        //driver.Navigate().GoToUrl("https://onlinebanking.standardbank.co.za/#/login?intcmp=coza-sitewide-headernav-direct-login");
        driver.Navigate().GoToUrl("https://onlinebanking.standardbank.co.za/#/login");
        WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

        //Credentials will be called from login credentials page
        wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@id = 'username']"))).SendKeys(email);

        wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//button[text() = 'Next']"))).Click();

        if (LibraryUtils.IsElementPresent(By.XPath("//span[text() = 'Sign In With Password']/..")))
        {
            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//span[text() = 'Sign In With Password']/.."))).Click();
        }
        wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//input[@type = 'password']"))).SendKeys(password);

        wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//span[text() = 'Sign in']/.."))).Click();
    }
Пример #9
0
    public void GetSciData()
    {
        if (ResearchAndDevelopment.Instance == null)
        {
            return;
        }
        dataOutputList = new List <Experiment>();
        List <ScienceSubject> newExperiments = new List <ScienceSubject>();
        List <string>         exIds          = ResearchAndDevelopment.GetExperimentIDs();
        List <ScienceSubject> subjectslist   = ResearchAndDevelopment.GetSubjects();

        //I am glad this code runs only once! Too expensive!
        foreach (string id in exIds)
        {
            foreach (ExperimentSituations experimentSituation in Enum.GetValues(typeof(ExperimentSituations)))
            {
                foreach (CelestialBody body in FlightGlobals.Bodies)
                {
                    bool ocean = body.ocean;
                    if (ExperimentSituations.SrfSplashed == experimentSituation && !ocean)
                    {
                        continue;
                    }
                    if ((ExperimentSituations.FlyingHigh == experimentSituation || ExperimentSituations.FlyingLow == experimentSituation) && !body.atmosphere)
                    {
                        continue;
                    }
                    ScienceExperiment experiment = ResearchAndDevelopment.GetExperiment(id);
                    bool available = experiment.IsAvailableWhile(experimentSituation, body);
                    if (available)
                    {
                        bool shouldHaveBiome = experiment.BiomeIsRelevantWhile(experimentSituation);
                        if (shouldHaveBiome)
                        {
                            foreach (string biome in ResearchAndDevelopment.GetBiomeTags(body))
                            {
                                if (KSPScienceSettings.getBoolSetting("ShowOnlyKnownBiomes"))
                                {
                                    bool foundBiome = subjectslist.Any(subject => subject.id.Contains("@" + body.name) && subject.id.Contains(biome.Replace(" ", "")));
                                    if (!foundBiome)
                                    {
                                        continue;
                                    }
                                }
                                ScienceSubject ssj = new ScienceSubject(experiment, experimentSituation, body, biome);
                                if (id == "asteroidSample")
                                {
                                    ssj.scienceCap = experiment.scienceCap;
                                }
                                newExperiments.Add(ssj);
                            }
                            if (body.BiomeMap == null || body.BiomeMap.Attributes.Length == 0)
                            {
                                ScienceSubject ssj = new ScienceSubject(experiment, experimentSituation, body, "");
                                if (id == "asteroidSample")
                                {
                                    ssj.scienceCap = experiment.scienceCap;
                                }
                                newExperiments.Add(ssj);
                            }
                        }
                        else
                        {
                            ScienceSubject ssj = new ScienceSubject(experiment, experimentSituation, body, "");
                            if (id == "asteroidSample")
                            {
                                ssj.scienceCap = experiment.scienceCap;
                            }
                            newExperiments.Add(ssj);
                        }
                    }
                }
            }
        }


        foreach (ScienceSubject scienceSubject in subjectslist)
        {
            newExperiments.RemoveAll(subject => subject.id == scienceSubject.id);
            string     title      = scienceSubject.id;
            double     earned     = Math.Round(scienceSubject.science, 1);
            double     remain     = Math.Round(scienceSubject.scienceCap - scienceSubject.science, 1);
            string     body       = LibraryUtils.FindExperimentBody(scienceSubject.id.Split('@')[1]);
            string     type       = scienceSubject.id.Split('@')[0];
            Experiment experiment = new Experiment(title, earned, remain, body, type);
            dataOutputList.Add(experiment);
        }

        foreach (ScienceSubject newExperiment in newExperiments)
        {
            newExperiment.scientificValue = 1f;
            CelestialBody thisBody = FlightGlobals.Bodies.Find(celestialBody => newExperiment.id.Split('@')[1].StartsWith(celestialBody.name));
            Experiment    ex       = new Experiment(newExperiment.id, 0, Math.Round(newExperiment.scienceCap, 1), thisBody.name, newExperiment.id.Split('@')[0]);
            dataOutputList.Add(ex);
        }
        dataOutputList.Sort(SortByName);

        if (KSPScienceSettings.getBoolSetting("ShowOnlyKnownExperiments"))
        {
            allExperimentTypes = GetKnownExperimentTypes();
        }
        else
        {
            allExperimentTypes = GetAllExperimentTypes();
        }
    }
Пример #10
0
        public async Task <IHttpActionResult> PostResource(ResourceDto resource)
        {
            ResourceDto result;

            // In the case of a new resource Id is not passed. In the case of a common resource Id has a value.
            if (resource.Id == 0)
            {
                var newResource = await LibraryUtils.TryValidateResource(resource.Url);

                // If validation is unsuccessfull, TryValidateResource returns null
                if (newResource != null)
                {
                    resource.Format     = newResource.Format;
                    resource.NaturalKey = newResource.NaturalKey;
                    resource.Title      = newResource.Title ?? resource.Title;
                    resource.HasVideo   = newResource.HasVideo || resource.HasVideo;
                }
                else
                {
                    resource.NaturalKey = null;
                }
            }

            if (resource.NaturalKey != null)
            {
                var userId = this.GetUserId();
                // Idempotent
                result = (await DapperHelper.QueryResilientlyAsync <ResourceDto>("dbo.libCreatePersonalResource",
                                                                                 new
                {
                    UserId = userId,
                    Id = resource.Id,
                    Format = resource.Format,
                    NaturalKey = resource.NaturalKey,
                    Segment = resource.Segment,
                    Title = resource.Title,
                    CategoryIds = GeneralUtils.SanitizeSpaceSeparatedWords(resource.CategoryIds),
                    Tags = GeneralUtils.SanitizeSpaceSeparatedWords((resource.Tags ?? "").Replace("-", String.Empty).ToLower()),
                    SourceId = resource.SourceId,
                    HasExplanation = resource.HasExplanation,
                    HasExample = resource.HasExample,
                    HasExercise = resource.HasExercise,
                    HasText = resource.HasText,
                    HasPicture = resource.HasPicture,
                    HasAudio = resource.HasAudio,
                    HasVideo = resource.HasVideo,
                    Comment = resource.Comment,
                },
                                                                                 CommandType.StoredProcedure))
                         .SingleOrDefault();

                // Update the search index.
                var indexHelper = new PersonalIndexHelper(DapperHelper.GetConnectionString());
                if (resource.Id == 0)
                {
                    // A new resource is added on the Personal tab. It is waiting to update the category list. Update the index ASAP.
                    await indexHelper.IndexUserResource(CancellationToken.None, userId, result.Id, true);
                }
                else
                {
                    // If a common resource is added to the personal collection, update the search index in background. Return response early.
                    //// If this task fails, the WebJob will process everything.
                    //var queueTask = AzureStorageUtils.QueueMessage(
                    //    AzureStorageUtils.WebJobsConnectionStringName,
                    //    AzureStorageUtils.QueueNames.IndexPersonal,
                    //    userId.ToString() + " " + resourceId.ToString()
                    //    );
                    //await Task.WhenAll(dbTask, queueTask);
                    HostingEnvironment.QueueBackgroundWorkItem(ct => indexHelper.IndexUserResource(ct, userId, result.Id, true));
                }
            }
            else
            {
                throw new ArgumentException("Wrong web address.");
            }

            return(Ok(result));
        }
Пример #11
0
    public void Update()
    {
        if (Input.GetMouseButtonUp(0))
        {
            resizingWindow = false;
        }
        if (resizingWindow)
        {
            windowPosition.width  = Input.mousePosition.x - windowPosition.x + 10;
            windowPosition.height = (Screen.height - Input.mousePosition.y) - windowPosition.y + 10;
        }
        // using "while" for possibility to "break". So we dont have to use GOTO. using timer to skip frames.
        while (drawWindow && (lateUpdateTimer < Time.time || lateUpdateTimerCounter > 3))
        {
            lateUpdateTimer = Time.time + 1;

            ExperimentSituations experimentSituation = ScienceUtil.GetExperimentSituation(FlightGlobals.ActiveVessel);
            CelestialBody        mainbody            = FlightGlobals.ActiveVessel.mainBody;
            string biome;
            if (FlightGlobals.ActiveVessel.landedAt != string.Empty)
            {
                biome = FlightGlobals.ActiveVessel.landedAt;
            }
            else
            {
                biome = ScienceUtil.GetExperimentBiome(FlightGlobals.ActiveVessel.mainBody, FlightGlobals.ActiveVessel.latitude, FlightGlobals.ActiveVessel.longitude);
            }

            if (mainbody == lastMainBody && biome == lastBiome && lastExperimentSituation == experimentSituation && lateUpdateTimerCounter <= 3)
            {
                lateUpdateTimer = 0;
                lateUpdateTimerCounter++;
                break;
            }
            lateUpdateTimerCounter = 0;
            lastBiome               = biome;
            lastMainBody            = mainbody;
            lastExperimentSituation = experimentSituation;

            Output.Clear();
            OnShip.Clear();


            //List<ScienceExperiment> PossibleExperiments = new List<ScienceExperiment>();

            //Search for all Science Experiment Modules on vessel, Check experiment available and add in "Output" and "OnShip"
            foreach (ModuleScienceExperiment moduleScienceExperiment in FlightGlobals.ActiveVessel.FindPartModulesImplementing <ModuleScienceExperiment>())
            {
                string            firstExperimentId = moduleScienceExperiment.experimentID;
                ScienceExperiment scienceExperiment = ResearchAndDevelopment.GetExperiment(firstExperimentId);
                bool available = scienceExperiment.IsAvailableWhile(experimentSituation, mainbody);
                if (available)
                {
                    if (moduleScienceExperiment.Deployed)
                    {
                        foreach (ScienceData scienceData in moduleScienceExperiment.GetData())
                        {
                            ExperimentView experimentView = new ExperimentView(scienceData);
                            if (!Output.Contains(experimentView))
                            {
                                Output.Add(experimentView);
                            }
                            OnShip.Add(experimentView);
                        }
                    }
                    {
                        ScienceSubject scienceSubject = LibraryUtils.GetExperimentSubject(scienceExperiment, experimentSituation, mainbody, scienceExperiment.BiomeIsRelevantWhile(experimentSituation) ? biome : "");
                        ExperimentView experimentView = new ExperimentView(scienceSubject);
                        if (!Output.Contains(experimentView))
                        {
                            Output.Add(experimentView);
                        }
                    }
                }
            }

            // Check for Kerbals on board. That means we can also use "evaReport", "surfaceSample", "asteroidSample" in EVA.
            if (FlightGlobals.ActiveVessel.GetCrewCount() > 0)
            {
                {
                    string            firstExperimentId = "evaReport";
                    ScienceExperiment scienceExperiment = ResearchAndDevelopment.GetExperiment(firstExperimentId);
                    bool available = scienceExperiment.IsAvailableWhile(experimentSituation, mainbody);
                    if (available)
                    {
                        ScienceSubject scienceSubject = LibraryUtils.GetExperimentSubject(scienceExperiment, experimentSituation, mainbody, scienceExperiment.BiomeIsRelevantWhile(experimentSituation) ? biome : "");
                        ExperimentView experimentView = new ExperimentView(scienceSubject);
                        if (!Output.Contains(experimentView))
                        {
                            Output.Add(experimentView);
                        }
                    }
                }
                {
                    string            firstExperimentId = "surfaceSample";
                    ScienceExperiment scienceExperiment = ResearchAndDevelopment.GetExperiment(firstExperimentId);
                    bool available = scienceExperiment.IsAvailableWhile(experimentSituation, mainbody);
                    if (available)
                    {
                        ScienceSubject scienceSubject = LibraryUtils.GetExperimentSubject(scienceExperiment, experimentSituation, mainbody, scienceExperiment.BiomeIsRelevantWhile(experimentSituation) ? biome : "");
                        ExperimentView experimentView = new ExperimentView(scienceSubject);
                        if (!Output.Contains(experimentView))
                        {
                            Output.Add(experimentView);
                        }
                    }
                }

                // Find asteroid that could be used for science. (I hope it will not be too many asteroids, because of linear complexity of this code)
                ModuleAsteroid[] asteroids = FindObjectsOfType <ModuleAsteroid>();
                foreach (ModuleAsteroid asteroid in asteroids)
                {
                    Vector3 destination3   = asteroid.gameObject.transform.position - FlightGlobals.ActiveVessel.gameObject.transform.position;
                    float   unfocusedRange = asteroid.Events["TakeSampleEVAEvent"].unfocusedRange;
                    unfocusedRange *= unfocusedRange;
                    if (destination3.sqrMagnitude < unfocusedRange)
                    {
                        string            firstExperimentId = "asteroidSample";
                        ScienceExperiment scienceExperiment = ResearchAndDevelopment.GetExperiment(firstExperimentId);
                        bool available = scienceExperiment.IsAvailableWhile(experimentSituation, mainbody);
                        if (available)
                        {
                            string         asteroidname   = asteroid.part.partInfo.name + asteroid.part.flightID;
                            ScienceSubject scienceSubject = LibraryUtils.GetExperimentSubject(scienceExperiment, experimentSituation, asteroidname, "", mainbody, scienceExperiment.BiomeIsRelevantWhile(experimentSituation) ? biome : "");
                            ExperimentView experimentView = new ExperimentView(scienceSubject);
                            if (!Output.Contains(experimentView))
                            {
                                Output.Add(experimentView);
                            }
                        }
                    }
                }
            }
            //Search for all Science Containers on vessel and write all found experiments into OnShip list
            foreach (ModuleScienceContainer moduleScienceContainer in FlightGlobals.ActiveVessel.FindPartModulesImplementing <ModuleScienceContainer>())
            {
                foreach (ScienceData scienceData in moduleScienceContainer.GetData())
                {
                    ExperimentView experimentView = new ExperimentView(scienceData);
                    //if (!Output.Contains(experimentView))
                    Output.Add(experimentView);
                    OnShip.Add(experimentView);
                }
            }

            Output.Sort();
            break;
        }
    }
Пример #12
0
 private void Resubmit_Click(object sender, RoutedEventArgs e)
 {
     LibraryUtils.Resubmit();
 }