예제 #1
0
        protected void dataProvidersGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            var valuesDataList = dataProvidersGridView.Rows[e.RowIndex].Cells[0].FindControl("EditDataList") as DataList;
            var id             = (Guid)this.dataProvidersGridView.DataKeys[e.RowIndex].Value;

            using (var dataContext = new CprBroker.Data.DataProviders.DataProvidersDataContext())
            {
                DataProvider dbProv = (from dp in dataContext.DataProviders where dp.DataProviderId == id select dp).Single();
                foreach (DataListItem item in valuesDataList.Items)
                {
                    SmartTextBox smartTextBox = item.FindControl("SmartTextBox") as SmartTextBox;
                    if (smartTextBox.Confidential)
                    {
                        // Only update the password if something is entered to avoid erasing the password by mistake
                        if (!string.IsNullOrEmpty(smartTextBox.Text))
                        {
                            dbProv[valuesDataList.DataKeys[item.ItemIndex].ToString()] = smartTextBox.Text;
                        }
                    }
                    else
                    {
                        dbProv[valuesDataList.DataKeys[item.ItemIndex].ToString()] = smartTextBox.Text;
                    }
                }
                dataContext.SubmitChanges();
                dataProvidersGridView.EditIndex = -1;
                dataProvidersGridView.DataBind();
            }
        }
예제 #2
0
 protected void dataProvidersGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     using (var dataContext = new CprBroker.Data.DataProviders.DataProvidersDataContext())
     {
         var id     = (Guid)this.dataProvidersGridView.DataKeys[e.RowIndex].Value;
         var dbProv = dataContext.DataProviders.Where(dp => dp.DataProviderId == id).FirstOrDefault();
         dataContext.DataProviders.DeleteOnSubmit(dbProv);
         dataContext.SubmitChanges();
         dataProvidersGridView.DataBind();
     }
 }
예제 #3
0
 public static DataProvider[] ReadDatabaseDataProviders()
 {
     using (var dataContext = new CprBroker.Data.DataProviders.DataProvidersDataContext())
     {
         var dbProviders = (from prov in dataContext.DataProviders
                            where prov.IsEnabled == true
                            orderby prov.Ordinal
                            select prov).ToArray();
         return(dbProviders);
     }
 }
        private static void PatchWebsite_2_1_1(Session session)
        {
            // This patch adds /PersonMasterService12 to the address of existing person master data providers for versions prior to 2.1.1
            try
            {
                // Load connection string and encryption keys
                var webInstallationInfo = WebInstallationInfo.CreateFromFeature(session, "CPR");
                var configFilePath      = webInstallationInfo.GetWebConfigFilePath(EventBrokerCustomActions.PathConstants.CprBrokerWebsiteDirectoryRelativePath);
                var config = CprBroker.Installers.Installation.OpenConfigFile(configFilePath);
                DataProvider.EncryptionAlgorithm = DataProviderKeysSection.GetFromConfig(config);
                var connectionString = config.ConnectionStrings.ConnectionStrings["CprBroker.Config.Properties.Settings.CprBrokerConnectionString"].ConnectionString;

                using (var dataContext = new CprBroker.Data.DataProviders.DataProvidersDataContext(connectionString))
                {
                    var providers = dataContext.DataProviders.ToArray();
                    providers = providers
                                .Where(dp =>
                    {
                        var type = Type.GetType(dp.TypeName, false, true);
                        return
                        (type != null &&
                         string.Equals(type.Name, typeof(CprBroker.Providers.PersonMaster.PersonMasterDataProvider).Name));
                    }
                                       ).ToArray();

                    foreach (var prov in providers)
                    {
                        var adr = prov["Address"];
                        if (!string.IsNullOrEmpty(adr))
                        {
                            if (!adr.EndsWith("/PersonMasterService12", StringComparison.InvariantCultureIgnoreCase))
                            {
                                prov["Address"] += "/PersonMasterService12";
                            }
                        }
                    }
                    dataContext.SubmitChanges();
                }
            }
            finally
            {
                // Unload encryption keys
                DataProvider.EncryptionAlgorithm = null;
            }
        }
        public void GetDataProviderList_Valid_ExecutesFast(
            [ValueSource("GuidLargeCounts")] uint count)
        {
            var  facade = new GuidFacade(count);
            Type t      = typeof(GuidDataProvider);

            DataProvider[] dbProviders;

            Stopwatch watch = new Stopwatch();

            watch.Start();

            using (var dataContext = new CprBroker.Data.DataProviders.DataProvidersDataContext())
            {
                dbProviders = (from prov in dataContext.DataProviders
                               where prov.IsEnabled
                               orderby prov.Ordinal
                               select prov).ToArray();
            }


            DataProvidersConfigurationSection section = DataProvidersConfigurationSection.GetCurrent();


            bool missingDataProvidersExist;
            var  result = facade.CreateSubMethodRunStates(out missingDataProvidersExist);

            watch.Stop();


            var expectedDuration = TimeSpan.FromMilliseconds(1 * count);

            if (!GetDataProviderList_Valid_ExecutesFast_Called)
            {
                expectedDuration = TimeSpan.FromSeconds(3);
                GetDataProviderList_Valid_ExecutesFast_Called = true;
            }

            Console.WriteLine(string.Format("{0} ms for {1} entries - {2} ms/item", watch.Elapsed.TotalMilliseconds, count, watch.Elapsed.TotalMilliseconds / count));

            Assert.LessOrEqual(watch.Elapsed, expectedDuration);
        }
예제 #6
0
        protected void newDataProviderGridView_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Insert")
            {
                try
                {
                    using (var dataContext = new CprBroker.Data.DataProviders.DataProvidersDataContext())
                    {
                        DataProvider dbProv = new DataProvider()
                        {
                            DataProviderId = Guid.NewGuid(),
                            IsExternal     = true,
                            TypeName       = newDataProviderDropDownList.SelectedValue,
                            Ordinal        = dataContext.DataProviders.OrderByDescending(dp => dp.Ordinal).Select(p => p.Ordinal).FirstOrDefault() + 1,
                            IsEnabled      = true
                        };

                        foreach (GridViewRow item in newDataProviderGridView.Rows)
                        {
                            SmartTextBox smartTextBox = item.FindControl("SmartTextBox") as SmartTextBox;
                            string       propName     = newDataProviderGridView.DataKeys[item.RowIndex].Value.ToString();
                            dbProv[propName] = smartTextBox.Text;
                        }

                        dataContext.DataProviders.InsertOnSubmit(dbProv);
                        dataContext.SubmitChanges();
                        dataProvidersGridView.DataBind();
                        newDataProviderGridView.DataBind();
                    }
                }
                catch (Exception ex)
                {
                    Master.AppendError(ex.Message);
                }
            }
        }