Exemplo n.º 1
0
        private bool ValidarAlteracao()
        {
            bool retorno = true;

            SiteUtil.ValidacaoTextBoxReset(txtTelefone);
            if (string.Empty.Equals(txtTelefone.Text.Trim()))
            {
                SiteUtil.ValidacaoTextBox(txtTelefone);
                retorno = false;
            }

            SiteUtil.ValidacaoTextBoxReset(txtNumero);
            if (!string.Empty.Equals(txt_Logradouro.Text) && string.Empty.Equals(txtNumero.Text))
            {
                SiteUtil.ValidacaoTextBox(txtNumero);
                throw new Exception("Favor informar um número para o endereço");
            }

            if (string.Empty.Equals(txt_Logradouro.Text))
            {
                LimparEndereco();
                txtNumero.Text      = string.Empty;
                txtComplemento.Text = string.Empty;
            }

            return(retorno);
        }
Exemplo n.º 2
0
        //HISTORICO

        private void CarregarComboboxHistorico()
        {
            HistoricoPacientes = new Service1Client().ConsultarHistorico(Paciente).ToList();
            int dataSelecionada = 0;

            foreach (HistoricoPaciente item in HistoricoPacientes)
            {
                string dataFormatada = SiteUtil.FormatarData(item.DataConsulta);
                dataConsultaHistorico.Items.Add(new KeyValuePair <HistoricoPaciente, string>(item, dataFormatada));
                if (DataConsulta.Equals(dataFormatada))
                {
                    dataSelecionada = dataConsultaHistorico.Items.Count - 1;
                }
            }

            dataConsultaHistorico.SelectedValuePath = "Key";
            dataConsultaHistorico.DisplayMemberPath = "Value";

            if (dataSelecionada > 0)
            {
                dataConsultaHistorico.SelectedIndex = dataSelecionada;
            }
            else if ((int)dataConsultaHistorico.SelectedIndex < 0)
            {
                dataConsultaHistorico.SelectedIndex = 0;
            }
        }
Exemplo n.º 3
0
        public void CanLoginLocallyAfterChangingPassword()
        {
            var email          = "*****@*****.**";
            var firstPassword  = "******";
            var secondPassword = "******";

            using (var site = new KeyHubWebDriver())
            {
                SiteUtil.CreateLocalAccount(site, email, firstPassword);

                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    SiteUtil.SubmitLoginForm(browser, email, firstPassword);
                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    browser.FindElementByCssSelector("a[href^='/Account']").Click();
                    browser.FindElementByCssSelector("a[href^='/Account/ChangePassword']").Click();

                    browser.FindElementByCssSelector("#OldPassword").SendKeys(firstPassword);
                    browser.FindElementByCssSelector("#NewPassword").SendKeys(secondPassword);
                    browser.FindElementByCssSelector("#ConfirmPassword").SendKeys(secondPassword);
                    browser.FindElementByCssSelector("input[type='submit']").Click();

                    // Ensure the change saves by waiting for the browser to return to the account edit page
                    browser.FindElementByCssSelector("a[href^='/Account/Edit']");
                }

                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    SiteUtil.SubmitLoginForm(browser, email, secondPassword);
                }
            }
        }
Exemplo n.º 4
0
 // ALTERAR CADASTRO
 private void CarregarInformacoesPaciente()
 {
     txtNomePaciente.Text        = Paciente.Nome;
     txtCpf.Text                 = SiteUtil.FormatarCPF(Paciente.Cpf);
     txtTelefone.Text            = SiteUtil.FormatarTelefone(Paciente.Telefone);
     dataNascimento.SelectedDate = Paciente.Date;
     if (Sexo.FEMININO.Equals(Paciente.Sexo))
     {
         rb_feminino.IsChecked  = true;
         rb_masculino.IsChecked = false;
     }
     txtCEP.Text         = SiteUtil.FormatarCEP(Paciente.Cep);
     txt_Logradouro.Text = Paciente.Logradouro;
     txtComplemento.Text = Paciente.Complemento;
     txt_Estado.Text     = Paciente.Estado;
     txt_Cidade.Text     = Paciente.Cidade;
     txt_Bairro.Text     = Paciente.Bairro;
     if (!0L.Equals(Paciente.Numero))
     {
         txtNumero.Text = Convert.ToString(Paciente.Numero);
     }
     else
     {
         txtNumero.Text = string.Empty;
     }
 }
Exemplo n.º 5
0
        public void AdminShouldBeAbleToCreateUsers()
        {
            var username = "******";
            var password = "******";

            using (var site = new KeyHubWebDriver())
            {
                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Navigate().GoToUrl(site.UrlFor("/Account/Create"));
                    SiteUtil.SubmitLoginForm(browser, "admin", "password");

                    browser.FindElementByCssSelector("#User_Email").SendKeys(username);
                    browser.FindElementByCssSelector("#User_Password").SendKeys(password);
                    browser.FindElementByCssSelector("#User_ConfirmPassword").SendKeys(password);
                    browser.FindElementByCssSelector("input[value='Save']").Click();
                    var successMessage = browser.FindElementByCssSelector(".success");
                    Assert.Contains("New user succesfully created", successMessage.Text);
                }

                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    SiteUtil.SubmitLoginForm(browser, "admin", "password");
                }
            }
        }
Exemplo n.º 6
0
        private static async Task BackupTableStorage()
        {
            var ticks = Environment.TickCount;

            BackupUploaderEventSource.Log.BackupTableStorageStart();

            var apps = await StorageHelper.GetAllApps().ConfigureAwait(false);

            var context        = new OperationContext();
            var appsSerialized = apps.Select(a => a.WriteEntity(context).ToDictionary(kvp => kvp.Key, kvp => kvp.Value.PropertyAsObject));

            var baseFilename     = String.Format(CultureInfo.InvariantCulture, "apps-{0}-{1}", SiteUtil.CurrentTimestamp, Guid.NewGuid());
            var xmlFilename      = Path.ChangeExtension(baseFilename, "xml");
            var sevenzipFilename = Path.ChangeExtension(baseFilename, "7z");

            SerializeAppsToFile(appsSerialized, xmlFilename, apps.Count);

            int exitCode = await CompressAppsData(xmlFilename, sevenzipFilename).ConfigureAwait(false);

            if (exitCode != 0)
            {
                throw new InvalidOperationException("Could not compress backup XML, 7-Zip exited with code: " + exitCode);
            }

            await UploadAppBackupToBlobStorage(sevenzipFilename, baseFilename).ConfigureAwait(false);

            await SiteUtil.SendSuccessMail("Storage Backup Uploader", apps.Count + " app(s) backed up", ticks)
            .ConfigureAwait(false);

            BackupUploaderEventSource.Log.BackupTableStorageStop(apps.Count);
        }
Exemplo n.º 7
0
        public void CanLoginLocallyAfterChangingEmail()
        {
            var firstEmail  = "*****@*****.**";
            var secondEmail = "*****@*****.**";
            var password    = "******";

            using (var site = new KeyHubWebDriver())
            {
                SiteUtil.CreateLocalAccount(site, firstEmail, password);

                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    SiteUtil.SubmitLoginForm(browser, firstEmail, password);

                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    browser.FindElementByCssSelector("a[href^='/Account']").Click();
                    browser.FindElementByCssSelector("a[href^='/Account/Edit']").Click();

                    var emailForm = browser.FindElementByCssSelector("#Email");
                    emailForm.Clear();
                    emailForm.SendKeys(secondEmail);
                    browser.FindElementByCssSelector("input[value='Save']").Click();

                    // Ensure the change saves by waiting for the browser to return to the account edit page
                    browser.FindElementByCssSelector("a[href^='/Account/Edit']");
                }

                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    SiteUtil.SubmitLoginForm(browser, secondEmail.ToUpper(), password);
                }
            }
        }
Exemplo n.º 8
0
        public void VendorCanEditAFeature()
        {
            using (var site = new KeyHubWebDriver())
            {
                var scenario = new WithAVendorScenario();
                scenario.Setup(site);

                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    SiteUtil.SubmitLoginForm(browser, scenario.UserEmail, scenario.UserPassword);

                    VendorUtil.CreateFeature(browser, "first feature", scenario.VendorName);

                    var featureRow = browser.FindElement(By.XPath("//td[contains(text(),'first feature')]/ancestor::tr"));
                    featureRow.FindElement(By.CssSelector("a[href^='/Feature/Edit']")).Click();

                    var nameInput = browser.FindElementByCssSelector("#Feature_FeatureName");
                    nameInput.Clear();
                    nameInput.SendKeys("second name");

                    browser.FindElementByCssSelector("form[action^='/Feature/Edit'] input[type='submit']").Click();
                    browser.FindElementByCssSelector(".success");

                    browser.FindElement(By.XPath("//td[contains(text(),'second name')]"));
                }
            }
        }
Exemplo n.º 9
0
        public void VendorCanRenameAndRemovePrivateKeys()
        {
            using (var site = new KeyHubWebDriver())
            {
                var scenario = new WithAVendorScenario();
                scenario.Setup(site);

                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    SiteUtil.SubmitLoginForm(browser, scenario.UserEmail, scenario.UserPassword);

                    var privateKeyName = VendorUtil.CreatePrivateKey(browser, scenario.VendorName);

                    var privateKeyRow = browser.FindElementByXPath("//td[contains(text(),'" + privateKeyName + "')]/ancestor::tr");
                    privateKeyRow.FindElement((By.CssSelector("a[href^='/PrivateKey/Edit']"))).Click();

                    var nameInput = browser.FindElementByCssSelector("input#PrivateKey_DisplayName");
                    nameInput.Clear();
                    nameInput.SendKeys("second name");
                    browser.FindElementByCssSelector("form[action^='/PrivateKey/Edit'] input[type='submit']").Click();

                    privateKeyRow = browser.FindElementByXPath("//td[contains(text(),'second name')]/ancestor::tr");

                    Assert.Equal(1, browser.FindElementsByCssSelector(".private-key-list").Count());
                    Assert.Equal(1, browser.FindElementsByCssSelector(".private-key-list tbody tr").Count());
                    privateKeyRow.FindElement((By.CssSelector("a[href^='/PrivateKey/Remove']"))).Click();

                    browser.FindElementByCssSelector("form[action^='/PrivateKey/Remove'] input[type='submit']").Click();

                    Assert.Equal(1, browser.FindElementsByCssSelector(".private-key-list").Count());
                    Assert.Equal(0, browser.FindElementsByCssSelector(".private-key-list tbody tr").Count());
                }
            }
        }
Exemplo n.º 10
0
        public void Setup(KeyHubWebDriver site, bool canDeleteManualDomainsOfLicense = true)
        {
            using (var browser = BrowserUtil.GetBrowser())
            {
                base.Setup(site);

                browser.Navigate().GoToUrl(site.UrlFor("/"));
                SiteUtil.SubmitLoginForm(browser, UserEmail, UserPassword);

                VendorUtil.CreatePrivateKey(browser, VendorName);

                VendorUtil.CreateFeature(browser, "first feature", VendorName);
                VendorUtil.CreateFeature(browser, "second feature", VendorName);

                VendorUtil.CreateSku(browser, "first sku", VendorName, "first feature", canDeleteManualDomainsOfLicense);
                VendorUtil.CreateSku(browser, "second sku", VendorName, "second feature", canDeleteManualDomainsOfLicense);

                //  Create a Customer
                var customerName = VendorUtil.CreateCustomer(browser);

                //  Create a License
                VendorUtil.CreateLicense(browser, "first sku", customerName);
                VendorUtil.CreateLicense(browser, "second sku", customerName);
            }
        }
        private void CarregarTreeView(List <Consulta> resultado)
        {
            treeViewConsultaSimplificada.Items.Clear();

            String       data     = string.Empty;
            TreeView     rootView = treeViewConsultaSimplificada;
            TreeViewItem rootNode = null;

            foreach (Consulta item in resultado)
            {
                if (data.Equals(SiteUtil.FormatarData(item.DataConsulta)))
                {
                    PreencherItemNodeTreeView(rootNode, item);
                }
                else
                {
                    data     = SiteUtil.FormatarData(item.DataConsulta);
                    rootNode = new TreeViewItem
                    {
                        Header = data
                    };
                    rootView.Items.Add(rootNode);

                    PreencherItemNodeTreeView(rootNode, item);
                }
            }
        }
Exemplo n.º 12
0
        private void PreencherPaciente()
        {
            Paciente = new Paciente
            {
                Nome        = txtNomePaciente.Text,
                Date        = (DateTime)dataNascimento.SelectedDate,
                Sexo        = (bool)rb_feminino.IsChecked ? Sexo.FEMININO : Sexo.MASCULINO,
                Logradouro  = txt_Logradouro.Text,
                Numero      = SiteUtil.ConverterStringParaLong(txtNumero.Text),
                Complemento = txtComplemento.Text,
                Estado      = txt_Estado.Text,
                Cidade      = txt_Cidade.Text,
                Bairro      = txt_Bairro.Text
            };

            string retornoCPF = SiteUtil.RemoverCaracteresEspecial(txtCpf.Text);

            Paciente.Cpf = SiteUtil.ConverterStringParaLong(retornoCPF);

            string retornoTelefone = SiteUtil.RemoverCaracteresEspecial(txtTelefone.Text);

            Paciente.Telefone = SiteUtil.ConverterStringParaLong(retornoTelefone);

            string retornoCEP = SiteUtil.RemoverCaracteresEspecial(txtCEP.Text);

            Paciente.Cep = SiteUtil.ConverterStringParaLong(retornoCEP);
        }
Exemplo n.º 13
0
        private static bool TryGetMinutes(IEnumerable <HtmlNode> listItems, string type, int hltbId, HtmlDocument doc, out int minutesFrom, out int minutesTo)
        {
            var durationListItem = listItems.FirstOrDefault(hn => hn.InnerText != null && hn.InnerText.Contains(type, StringComparison.OrdinalIgnoreCase));

            if (durationListItem == null)
            {
                minutesFrom = 0;
                minutesTo   = -1;
                return(false);
            }

            var durationDiv = durationListItem.Descendants("div").FirstOrDefault();

            if (durationDiv == null)
            {
                throw GetFormatException("TTB div not found inside list item", hltbId, doc);
            }

            var durationText = durationDiv.InnerText;

            if (durationText == null)
            {
                throw GetFormatException("Hours div inner text is null", hltbId, doc);
            }

            var durationTexts = durationText.Split(new [] { " - " }, StringSplitOptions.RemoveEmptyEntries);

            if (durationTexts.Length > 2)
            {
                throw GetFormatException("Cannot parse duration (invalid range) from list item with text: " + durationListItem.InnerText, hltbId, doc);
            }

            try
            {
                minutesFrom = GetMinutes(durationTexts[0]);
                if (durationTexts.Length == 1)
                {
                    minutesTo = -1;
                }
                else
                {
                    minutesTo = GetMinutes(durationTexts[1]);
                    if (minutesTo < minutesFrom)
                    {
                        SiteUtil.Swap(ref minutesFrom, ref minutesTo);
                    }
                }
            }
            catch (FormatException e)
            {
                throw GetFormatException("Cannot parse duration from list item with text: " + durationListItem.InnerText, hltbId, doc, e);
            }
            catch (OverflowException e)
            {
                throw GetFormatException("Cannot parse duration (overflow) from list item with text: " + durationListItem.InnerText, hltbId, doc, e);
            }

            return(true);
        }
Exemplo n.º 14
0
        private static void SerializeAppsToFile(IEnumerable <Dictionary <string, object> > appsSerialized, string xmlFilename, int appCount)
        {
            BackupUploaderEventSource.Log.SerializeAppsStart(appCount, xmlFilename);

            SiteUtil.DataContractSerializeToFile(appsSerialized, xmlFilename);

            BackupUploaderEventSource.Log.SerializeAppsStop(appCount, xmlFilename);
        }
Exemplo n.º 15
0
        private void ValidarInclusao()
        {
            bool retorno = true;

            SiteUtil.ValidacaoTextBoxReset(txtNomePaciente);
            if (string.Empty.Equals(txtNomePaciente.Text.Trim()))
            {
                SiteUtil.ValidacaoTextBox(txtNomePaciente);
                retorno = false;
            }

            SiteUtil.ValidacaoTextBoxReset(txtCpf);
            if (string.Empty.Equals(txtCpf.Text))
            {
                SiteUtil.ValidacaoTextBox(txtCpf);
                retorno = false;
            }

            SiteUtil.ValidacaoTextBoxReset(txtTelefone);
            if (string.Empty.Equals(txtTelefone.Text))
            {
                SiteUtil.ValidacaoTextBox(txtTelefone);
                retorno = false;
            }

            dataNascimento.BorderBrush = SiteUtil.BorderBrushPadrao();
            if (dataNascimento.SelectedDate.Equals(null) || SiteUtil.FormatarData(DateTime.Now).Equals(SiteUtil.FormatarData((DateTime)dataNascimento.SelectedDate)))
            {
                dataNascimento.BorderBrush = Brushes.Red;
                retorno = false;
            }

            if (!retorno)
            {
                throw new Exception(SiteUtil.CAMPOOBRIGATORIO);
            }

            SiteUtil.ValidacaoTextBoxReset(txtCpf);
            if (!string.Empty.Equals(txtCpf.Text) && !SiteUtil.IsValidCPF(txtCpf.Text))
            {
                SiteUtil.ValidacaoTextBox(txtCpf);
                throw new Exception("Favor informa um CPF valido!");
            }

            SiteUtil.ValidacaoTextBoxReset(txtNumero);
            if (!string.Empty.Equals(txt_Logradouro.Text) && string.Empty.Equals(txtNumero.Text))
            {
                SiteUtil.ValidacaoTextBox(txtNumero);
                throw new Exception("Favor informar um número para o endereço");
            }

            if (string.Empty.Equals(txt_Logradouro.Text))
            {
                LimparEndereco();
                txtNumero.Text      = string.Empty;
                txtComplemento.Text = string.Empty;
            }
        }
        private static void PreencherItemNodeTreeView(TreeViewItem rootNode, Consulta item)
        {
            TreeViewItem rootItem = new TreeViewItem
            {
                Header = SiteUtil.FormatarHora(item.DataConsulta) + " - " + item.Paciente.Nome
            };

            rootNode.Items.Add(rootItem);
        }
Exemplo n.º 17
0
        protected void Application_Start()
        {
            TelemetryManager.Setup("d0a63409-84bf-4f88-a8cf-8440ce670471");
            SiteUtil.SetDefaultConnectionLimit();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            GamesController.StartUpdatingCache(); //make sure caching starts as soon as site is up

            InitMvc();
        }
Exemplo n.º 18
0
        public void CanManageVendorCredentials()
        {
            using (var site = new KeyHubWebDriver())
            {
                using (var browser = BrowserUtil.GetBrowser())
                {
                    //  Log in as pre-created admin user
                    browser.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3));
                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    SiteUtil.SubmitLoginForm(browser, "admin", "password");

                    //  Create a vendor
                    AdminUtil.CreateVendor(browser);

                    //  Create a VendorCredential for the vendor
                    browser.FindElementByCssSelector("a[href^='/VendorCredential/Create']").Click();

                    var firstVendorCredentialName  = "first vendor secret name";
                    var firstVendorCredentialValue = "vendor secret shared secret";

                    FillVendorCredentialForm(browser, firstVendorCredentialName, firstVendorCredentialValue);
                    browser.FindElementByCssSelector("form[action^='/VendorCredential/Create'] input[type=submit]").Click();

                    //  Make sure the VendorCredential was created, and edit it.
                    var editButton = browser.FindElementByCssSelector("a[href^='/VendorCredential/Edit']");
                    Assert.Contains(firstVendorCredentialName, browser.PageSource);
                    editButton.Click();

                    AssertVendorCredentialFormValues(browser, firstVendorCredentialName, firstVendorCredentialValue);
                    var secondVendorCredentialName  = "second vendor secret name";
                    var secondVendorCredentialValue = "second vendor secret";
                    FillVendorCredentialForm(browser, secondVendorCredentialName, secondVendorCredentialValue);
                    browser.FindElementByCssSelector("form[action^='/VendorCredential/Edit'] input[type=submit]").Click();

                    //  Check the VendorCredential edit page to ensure the edit saved
                    editButton = browser.FindElementByCssSelector("a[href^='/VendorCredential/Edit']");
                    Assert.DoesNotContain(firstVendorCredentialName, browser.PageSource);
                    Assert.Contains(secondVendorCredentialValue, browser.PageSource);
                    editButton.Click();

                    AssertVendorCredentialFormValues(browser, secondVendorCredentialName, secondVendorCredentialValue);

                    //  Return to the Vendor edit page
                    browser.FindElementByCssSelector("a[href^='/Vendor/Details']").Click();

                    //  Remove the VendorCredential
                    var removeButton = browser.FindElementByCssSelector("a[href^='/VendorCredential/Remove']");
                    removeButton.Click();
                    browser.FindElementByCssSelector("form[action^='/VendorCredential/Remove'] input[type=submit]").Click();

                    browser.FindElementByCssSelector(".success");
                    Assert.DoesNotContain(firstVendorCredentialName, browser.PageSource);
                    Assert.DoesNotContain(secondVendorCredentialValue, browser.PageSource);
                }
            }
        }
Exemplo n.º 19
0
        private static void VendorManuallyCreatesTransaction(Action <RemoteWebDriver> vendorActionBeforeCreatingTransaction, Action <RemoteWebDriver> transactionSubmitHandler)
        {
            var vendorScenario = new WithAVendorDBScenario();
            var vendorEmail    = "*****@*****.**";
            var vendorPassword = "******";

            using (var site = new KeyHubWebDriver())
            {
                string editVendorUserUrl = null;

                SiteUtil.CreateLocalAccount(site, vendorEmail, vendorPassword, firstBrowser =>
                {
                    firstBrowser.FindElementByCssSelector("a[href='/Account/LogOff']");
                    firstBrowser.Navigate().GoToUrl(site.UrlFor("/Account"));

                    editVendorUserUrl =
                        firstBrowser.FindElementByCssSelector("a[href^='/Account/Edit']").GetAttribute("href");
                });

                //  Log in as admin to give the new vendor account vendor permissions
                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Navigate().GoToUrl(site.UrlFor(editVendorUserUrl));

                    SiteUtil.SubmitLoginForm(browser, "admin", "password");

                    AdminUtil.CreateAccountRightsFor(browser, vendorEmail, ObjectTypes.Vendor, vendorScenario.VendorName);
                }

                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    SiteUtil.SubmitLoginForm(browser, vendorEmail, vendorPassword);

                    vendorActionBeforeCreatingTransaction(browser);

                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    browser.FindElementByCssSelector("a[href='/Transaction/Create']").Click();

                    SiteUtil.SetValueForChosenJQueryControlMulti(browser, "div#Transaction_SelectedSKUGuids_chzn",
                                                                 vendorScenario.SkuCode);

                    browser.FindElementByCssSelector("form[action^='/Transaction/Create'] input[type='submit']").Click();

                    transactionSubmitHandler(browser);

                    var appKeyValue = GetAppKeyFromTransactionCompletePage(browser);

                    LicenseValidatorTests.AssertRemoteValidationCheckPasses(
                        site, "example.com",
                        appKeyValue,
                        vendorScenario.FeatureCode,
                        vendorScenario.PublicKeyXml);
                }
            }
        }
Exemplo n.º 20
0
        private static async Task UpdateMissingGames()
        {
            var tickCount = Environment.TickCount;

            MissingUpdaterEventSource.Log.UpdateMissingGamesStart();

            var allSteamAppsTask = GetAllSteamApps(s_client);
            var allKnownAppsTask = StorageHelper.GetAllApps(null, StorageRetries);

            await Task.WhenAll(allSteamAppsTask, allKnownAppsTask).ConfigureAwait(false);

            var allSteamApps = allSteamAppsTask.Result;
            var allKnownApps = allKnownAppsTask.Result;

            var knownSteamIdsHash = new HashSet <int>(allKnownApps.Select(ae => ae.SteamAppId));
            var missingApps       = allSteamApps.Where(a => !knownSteamIdsHash.Contains(a.appid)).Take(UpdateLimit).ToArray();

            MissingUpdaterEventSource.Log.MissingAppsDetermined(missingApps);

            var updates = new ConcurrentBag <AppEntity>();
            InvalidOperationException ioe = null;

            try
            {
                await SteamStoreHelper
                .GetStoreInformationUpdates(missingApps.Select(a => new BasicStoreInfo(a.appid, a.name, null)).ToArray(), s_client, updates)
                .ConfigureAwait(false);
            }
            catch (Exception e)
            {
                ioe = new InvalidOperationException("Could not retrieve store information for all games", e);
            }

            var measuredUpdates = updates.Where(a => a.Measured).ToArray();

            if (measuredUpdates.Length > 0)
            {
                await HltbScraper.ScrapeHltb(measuredUpdates).ConfigureAwait(false);

                //re-impute for measured updates
                await Imputer.Impute(allKnownApps.Where(a => a.Measured).Concat(measuredUpdates).ToArray()).ConfigureAwait(false);
            }

            //we're inserting new entries, no fear of collisions (even if two jobs overlap the next one will fix it)
            await StorageHelper.Insert(updates, "updating missing games", StorageHelper.SteamToHltbTableName, StorageRetries).ConfigureAwait(false);

            if (ioe != null)
            {
                throw ioe; //fail job
            }

            await SiteUtil.SendSuccessMail("Missing updater", updates.Count + " app(s) added", tickCount).ConfigureAwait(false);

            MissingUpdaterEventSource.Log.UpdateMissingGamesStop();
        }
        public static string GetPartitionKey([NotNull] this TableOperation operation)
        {
            if (operation == null)
            {
                throw new ArgumentNullException(nameof(operation));
            }

            return(operation.OperationType == TableOperationType.Retrieve
                ? SiteUtil.GetNonpublicInstancePropertyValue <string>(operation, "RetrievePartitionKey")
                : operation.Entity.PartitionKey);
        }
Exemplo n.º 22
0
 private void TxtTelefone_LostFocus(object sender, EventArgs e)
 {
     if (!16.Equals(txtTelefone.Text.Length) && !11.Equals(txtTelefone.Text.Length))
     {
         txtTelefone.Text = string.Empty;
     }
     else
     {
         txtTelefone.Text = SiteUtil.FormatarTelefone(txtTelefone.Text);
     }
 }
Exemplo n.º 23
0
        public void VendorCanManuallyCreateLicensedApplicationAndChangeItsSkus()
        {
            var vendorAndCustomerScenario = new VendorWithALicensedCustomerScenario();

            using (var site = new KeyHubWebDriver())
            {
                vendorAndCustomerScenario.Setup(site);

                var firstCustomerAppName  = "customerApp.name1";
                var secondCustomerAppName = "customerApp.name2";

                using (var browser = BrowserUtil.GetBrowser())
                {
                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    SiteUtil.SubmitLoginForm(browser, vendorAndCustomerScenario.UserEmail, vendorAndCustomerScenario.UserPassword);
                    //  Create a CustomerApp / Licensed Application
                    browser.Navigate().GoToUrl(site.UrlFor("/"));
                    browser.FindElementByCssSelector("a[href='/CustomerApp']").Click();
                    browser.FindElementByCssSelector("a[href='/CustomerApp/Create']").Click();
                    browser.FindElementByCssSelector("input#ApplicationName").SendKeys(firstCustomerAppName);
                    SiteUtil.SetValueForChosenJQueryControlMulti(browser, "#SelectedLicenseGUIDs_chzn", "first sku");
                    browser.FindElementByCssSelector("form[action='/CustomerApp/Create'] input[type=submit]").Click();
                    browser.FindElementByCssSelector(".success");

                    AssertApplicationNameIs(browser, firstCustomerAppName);
                    AssertApplicationSkuIs(browser, "first sku");

                    //  Rename the customer app
                    browser.FindElementByCssSelector("a[href^='/CustomerApp/Edit']").Click();
                    var nameElement = browser.FindElementByCssSelector("input#ApplicationName");
                    nameElement.Clear();
                    nameElement.SendKeys(secondCustomerAppName);
                    browser.FindElementByCssSelector("form[action^='/CustomerApp/Edit'] input[type='submit']").Click();
                    browser.FindElementByCssSelector(".success");

                    AssertApplicationNameIs(browser, secondCustomerAppName);

                    // Switch licenses on the customer app
                    browser.FindElementByCssSelector("a[href^='/CustomerApp/Edit']").Click();
                    SiteUtil.SetValueForChosenJQueryControlMulti(browser, "#SelectedLicenseGUIDs_chzn", "second sku", clearExisting: true);
                    browser.FindElementByCssSelector("form[action^='/CustomerApp/Edit'] input[type='submit']").Click();
                    browser.FindElementByCssSelector(".success");

                    AssertApplicationSkuIs(browser, "second sku");

                    // Remove the customer app
                    browser.FindElementByCssSelector("a[href^='/CustomerApp/Remove']").Click();
                    browser.FindElementByCssSelector("form[action^='/CustomerApp/Remove'] input[type='submit']").Click();
                    browser.FindElementByCssSelector(".success");

                    Assert.Equal(0, browser.FindElementsByCssSelector("a[href^='/CustomerApp/Remove']").Count());
                }
            }
        }
Exemplo n.º 24
0
        private static async Task <int> CompressAppsData(string xmlFilename, string sevenzipFilename)
        {
            BackupUploaderEventSource.Log.CompressAppsDataStart(xmlFilename, sevenzipFilename);

            var exitCode = await SiteUtil.RunProcessAsync("7za.exe",
                                                          String.Format(CultureInfo.InvariantCulture, "a {0} {1}", sevenzipFilename, xmlFilename)).ConfigureAwait(false);

            BackupUploaderEventSource.Log.CompressAppsDataStop(xmlFilename, sevenzipFilename);

            return(exitCode);
        }
        private void ConsultarPacientePorParametro()
        {
            String   retorno = SiteUtil.RemoverCaracteresEspecial(tb_Paciente_CPF.Text);
            Paciente pFiltro = new Paciente
            {
                Nome = tb_Paciente_Nome.Text,
                Cpf  = !string.Empty.Equals(retorno) ? Convert.ToInt64(retorno) : 0L
            };

            DataGridPacientes(new Service1Client().ConsultarPaciente(pFiltro).ToList());
        }
Exemplo n.º 26
0
        private static async Task DeleteOldLogEntries()
        {
            var ticks = Environment.TickCount;

            BackupUploaderEventSource.Log.DeleteOldLogEntriesStart();

            int deleteCount = await StorageHelper.DeleteOldEntities(StorageHelper.SlabLogsTableName, DateTime.UtcNow.AddDays(-LogRetentionDays), "log entries", BackupUploaderStorageRetries)
                              .ConfigureAwait(false);

            await SiteUtil.SendSuccessMail("Old log deleter", deleteCount + " old logs deleted", ticks).ConfigureAwait(false);

            BackupUploaderEventSource.Log.DeleteOldLogEntriesStop(deleteCount);
        }
 private static void Main()
 {
     try
     {
         SiteUtil.KeepWebJobAlive();
         SiteUtil.MockWebJobEnvironmentIfMissing("SuggestionWatcher");
         WatchForSuggestions().Wait();
     }
     finally
     {
         EventSourceRegistrar.DisposeEventListeners();
     }
 }
Exemplo n.º 28
0
 private static void Main()
 {
     EventSource.SetCurrentThreadActivityId(Guid.NewGuid());
     try
     {
         SiteUtil.KeepWebJobAlive();
         SiteUtil.MockWebJobEnvironmentIfMissing("HltbScraper");
         MainAsync().Wait();
     }
     finally
     {
         EventSourceRegistrar.DisposeEventListeners();
     }
 }
Exemplo n.º 29
0
        private static async Task UpdateUnknownApps()
        {
            var ticks = Environment.TickCount;

            UnknownUpdaterEventSource.Log.UpdateUnknownAppsStart();

            var allUnknownApps = (await StorageHelper.GetAllApps(AppEntity.UnknownFilter, StorageRetries).ConfigureAwait(false)).Take(UpdateLimit).ToArray();

            var updates = new ConcurrentBag <AppEntity>();
            InvalidOperationException ioe = null;

            try
            {
                await SteamStoreHelper.GetStoreInformationUpdates(
                    allUnknownApps.Select(ae => new BasicStoreInfo(ae.SteamAppId, ae.SteamName, ae.AppType)).ToArray(), Client, updates).ConfigureAwait(false);
            }
            catch (Exception e)
            {
                ioe = new InvalidOperationException("Could not retrieve store information for all apps", e);
            }

            UnknownUpdaterEventSource.Log.UpdateNewlyCategorizedApps(updates);

            var measuredUpdates = updates.Where(a => a.Measured).ToArray();

            if (measuredUpdates.Length > 0)
            {
                await HltbScraper.ScrapeHltb(measuredUpdates).ConfigureAwait(false);

                //re-impute with new scraped values for updated games (Enumberable.Union() guarantees measuredUpdates will be enumerated before allApps!)
                var allMeasuredApps = await StorageHelper.GetAllApps(AppEntity.MeasuredFilter).ConfigureAwait(false);

                await Imputer.Impute(measuredUpdates.Union(allMeasuredApps, new AppEntitySteamIdComparer()).ToArray()).ConfigureAwait(false);
            }

            var unknownAppsMap = allUnknownApps.ToDictionary(ae => ae.SteamAppId);
            await StorageHelper.ExecuteOperations(updates,
                                                  ae => new[] { TableOperation.Delete(unknownAppsMap[ae.SteamAppId]), TableOperation.Insert(ae) },
                                                  StorageHelper.SteamToHltbTableName, "updating previously unknown games", StorageRetries).ConfigureAwait(false);

            if (ioe != null)
            {
                throw ioe; //fail job
            }

            await SiteUtil.SendSuccessMail("Unknown updater",
                                           updates.Count + " previously unknown game(s) updated", ticks).ConfigureAwait(false);

            UnknownUpdaterEventSource.Log.UpdateUnknownAppsStop();
        }
Exemplo n.º 30
0
        public DetalhePaciente(ConsultaViewModel ConsultaViewModel)
        {
            InitializeComponent();
            Paciente pFiltro = new Paciente();
            String   retorno = SiteUtil.RemoverCaracteresEspecial(ConsultaViewModel.Cpf);

            if (!string.Empty.Equals(retorno))
            {
                pFiltro.Cpf = Convert.ToInt64(retorno);
            }
            Paciente = new Service1Client().ConsultarPaciente(pFiltro).FirstOrDefault();
            DateTime data = Convert.ToDateTime(ConsultaViewModel.DataConsulta);

            DataConsulta = SiteUtil.FormatarData(data);
        }