问:
Understanding the delegates in UITableView and UITableViewController
I am learning how to use the UITableView and UITableViewController in the iOS and I think I may have confused myself. I have created a simple TableView and I have 2 sections.  Nothing complicated.

I have the following defined and it builds fine:

```<code>-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section
{
    // Section is going to be either 0 or 1, high or low
    if (section == 0) {
        return 1;
    }
    else {
        return 2;
    }
}
</code>```

However what I don't understand is the definitions of the methods.  Both methods have to return an integer so I understand the starting (NSInteger).  The numberOfRowsInSection starts with tableView:(UITableView *)tableView and I don't understand why?

I'm am new to programming the iOS so be gentle :-)  All help greatly appreciated.

Mike

答: tableView:(UITableView *)tableView is helpful if you need to know which tableView sent that delegate method.

Body:
I am learning how to use the UITableView and UITableViewController in the iOS and I think I may have confused myself. I have created a simple TableView and I have 2 sections.  Nothing complicated.

I have the following defined and it builds fine:

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView
 numberOfRowsInSection:(NSInteger)section
{
    // Section is going to be either 0 or 1, high or low
    if (section == 0) {
        return 1;
    }
    else {
        return 2;
    }
}

However what I don't understand is the definitions of the methods.  Both methods have to return an integer so I understand the starting (NSInteger).  The numberOfRowsInSection starts with tableView:(UITableView *)tableView and I don't understand why?

I'm am new to programming the iOS so be gentle :-)  All help greatly appreciated.

Mike


来源: stackexchange

问:
What is the difference between no access specifier and public in java 9 module?
From java 9, public access is limited to it's own module. Does it mean public acts like a package protected ( no access specifier )? Can someone clarify this?

答:
package elements are only accessible within the package. Other packages in the module have no access to these elements.

public without exports are accessible to any other packages in the module.

In other words:

package elements are package-local

public without exports are module-local.

So, public without exports is wider than package.

ContentLicense: CC BY-SA 3.0


问:
ASPNet.Core HostingEnvironment for Integration Tests?
In building the Integration tests for my ASPNet.Core web app, https://learn.microsoft.com/en-us/aspnet/core/testing/integration-testing,
I am coming across an issue. The Startup is run when I run the app and the configuration is read and contains all the information in my apsettings.json file.
Now, when I run the integration test as shown below. the Startup is run but the configuration is different. Why would that happen and how do I make sure it reads
the one for the app itself?

```<code>[TestFixture]
class HSMControllerTests
{
    private readonly TestServer _server;
    private readonly HttpClient _client;

    public HSMControllerTests()
    {
        _server = new TestServer(new WebHostBuilder()
        .UseStartup<Startup>());
        _client = _server.CreateClient();
    }

    [Test]
    public async global::System.Threading.Tasks.Task GET_PingHSM_ShouldSucceedAsync()
    {
        HttpResponseMessage response = await _client.GetAsync("HSM/PingHSM");
        Assert.NotNull(response);
        Assert.IsInstanceOf<OkObjectResult>(response);
    }
}
</code>```

I am getting the exception Missing configuration section ServiceConfig.

This is how the WebHost is built in Program.cs in my app:

```<code>WebHost.CreateDefaultBuilder(args)
       .UseStartup<Startup>()
       .UseKestrel(o => o.AddServerHeader = false)
       .Build();
</code>```

Could the difference in how it is built in the Test code be the problem?

Modified ControllerTest constructor:

```<code>public HSMControllerTests()
{
    var builder = new ConfigurationBuilder()
        .SetBasePath(Path.GetFullPath(@"../../../../HSM.WebApi.IntegrationTests"))
        .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
        .AddEnvironmentVariables();

    Configuration = builder.Build();

    _server = new TestServer(WebHost.CreateDefaultBuilder()
        .UseStartup<Startup>());
    _client = _server.CreateClient();
}
</code>```

Now, how to inject the new Configuration into the Startup? Our Startup is defined like this:

```<code>public Startup(IConfiguration configuration, IHostingEnvironment environment)
        : base(typeof(Startup), configuration, environment)
{
}
</code>```

modification based on last post by @poke

```<code>_server = new TestServer(WebHost.CreateDefaultBuilder()
    .ConfigureAppConfiguration(configBuilder => new ConfigurationBuilder()
        .SetBasePath(Path.GetFullPath(@"../../../../HSM.WebApi.IntegrationTests"))
        .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
        .AddEnvironmentVariables()
    )
    .UseStartup<Startup>());
</code>```

Got it working, somewhat...

```<code>var config = new ConfigurationBuilder()
    .SetBasePath(Path.GetFullPath(@"../../../../HSM.WebApi.IntegrationTests"))
    .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
    .AddEnvironmentVariables();

var Configuration = config.Build();

_server = new TestServer(WebHost.CreateDefaultBuilder()
    .UseConfiguration(Configuration)
    .UseStartup<Startup>());
_client = _server.CreateClient();
</code>```

But now, the HostingEnvironment is set to the directory of the Tests app vs. the directory of the Web app and it attempts to read to appsettings.json file from there in the HomeController constructor, here:

```<code>public HSMController(IHostingEnvironment hostingEnvironment)
{
    _hostingEnvironment = hostingEnvironment;
    contentRootPath = _hostingEnvironment.ContentRootPath;
}
</code>```

答:
ASP .Net Core 2.0

Copy you appsettings.json files to your integration test and set them to copy always.

Create MyTestServer Class as it will likely be reused in many tests.  Remember that CreateDefaultBuilder will automatically load your appsettings and use environment.

```<code>  public class ApiTestServer : TestServer
  {
    public ApiTestServer() : base(WebHostBuilder())
    { }

    private static IWebHostBuilder WebHostBuilder() =>
      WebHost.CreateDefaultBuilder()
        .UseStartup<Startup>()
        .UseEnvironment("Local")
        .UseKestrel(options =>
        {
          options.Listen(IPAddress.Any, 5001);
        });
  }
</code>```

Then in your test

```<code>public SettingsTests()
{
  TestServer = new ApiTestServer();
  HttpClient = TestServer.CreateClient();
}
</code>```

Body:
In building the Integration tests for my ASPNet.Core web app, https://learn.microsoft.com/en-us/aspnet/core/testing/integration-testing,
I am coming across an issue. The Startup is run when I run the app and the configuration is read and contains all the information in my apsettings.json file.
Now, when I run the integration test as shown below. the Startup is run but the configuration is different. Why would that happen and how do I make sure it reads
the one for the app itself?

[TestFixture]
class HSMControllerTests
{
    private readonly TestServer _server;
    private readonly HttpClient _client;

    public HSMControllerTests()
    {
        _server = new TestServer(new WebHostBuilder()
        .UseStartup<Startup>());
        _client = _server.CreateClient();
    }

    [Test]
    public async global::System.Threading.Tasks.Task GET_PingHSM_ShouldSucceedAsync()
    {
        HttpResponseMessage response = await _client.GetAsync("HSM/PingHSM");
        Assert.NotNull(response);
        Assert.IsInstanceOf<OkObjectResult>(response);
    }
}

I am getting the exception Missing configuration section ServiceConfig.

This is how the WebHost is built in Program.cs in my app:

WebHost.CreateDefaultBuilder(args)
       .UseStartup<Startup>()
       .UseKestrel(o => o.AddServerHeader = false)
       .Build();

Could the difference in how it is built in the Test code be the problem?

Modified ControllerTest constructor:

public HSMControllerTests()
{
    var builder = new ConfigurationBuilder()
        .SetBasePath(Path.GetFullPath(@"../../../../HSM.WebApi.IntegrationTests"))
        .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
        .AddEnvironmentVariables();

    Configuration = builder.Build();

    _server = new TestServer(WebHost.CreateDefaultBuilder()
        .UseStartup<Startup>());
    _client = _server.CreateClient();
}

Now, how to inject the new Configuration into the Startup? Our Startup is defined like this:

public Startup(IConfiguration configuration, IHostingEnvironment environment)
        : base(typeof(Startup), configuration, environment)
{
}

modification based on last post by @poke

_server = new TestServer(WebHost.CreateDefaultBuilder()
    .ConfigureAppConfiguration(configBuilder => new ConfigurationBuilder()
        .SetBasePath(Path.GetFullPath(@"../../../../HSM.WebApi.IntegrationTests"))
        .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
        .AddEnvironmentVariables()
    )
    .UseStartup<Startup>());

Got it working, somewhat...

var config = new ConfigurationBuilder()
    .SetBasePath(Path.GetFullPath(@"../../../../HSM.WebApi.IntegrationTests"))
    .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
    .AddEnvironmentVariables();

var Configuration = config.Build();

_server = new TestServer(WebHost.CreateDefaultBuilder()
    .UseConfiguration(Configuration)
    .UseStartup<Startup>());
_client = _server.CreateClient();

But now, the HostingEnvironment is set to the directory of the Tests app vs. the directory of the Web app and it attempts to read to appsettings.json file from there in the HomeController constructor, here:

public HSMController(IHostingEnvironment hostingEnvironment)
{
    _hostingEnvironment = hostingEnvironment;
    contentRootPath = _hostingEnvironment.ContentRootPath;
}

Body:
ASP .Net Core 2.0

Copy you appsettings.json files to your integration test and set them to copy always.

Create MyTestServer Class as it will likely be reused in many tests.  Remember that CreateDefaultBuilder will automatically load your appsettings and use environment.

  public class ApiTestServer : TestServer
  {
    public ApiTestServer() : base(WebHostBuilder())
    { }

    private static IWebHostBuilder WebHostBuilder() =>
      WebHost.CreateDefaultBuilder()
        .UseStartup<Startup>()
        .UseEnvironment("Local")
        .UseKestrel(options =>
        {
          options.Listen(IPAddress.Any, 5001);
        });
  }

Then in your test

public SettingsTests()
{
  TestServer = new ApiTestServer();
  HttpClient = TestServer.CreateClient();
}


问:
How to remove multiple header from kendo grid
I am creating a sample application in which I show data in kendo grid.
For this I get the page size data in kendo grid and then load it. when page change I load next data.

When my page change event call the grid is added in already exist grid. By this it shows multiple column header.

My sample is - http://jsfiddle.net/pporwal26/y6KdK/78/

```<code>var jsonData = JSON.parse("{\"Report\":\"type1\",\"FileList\":[{\"owner\":\"machine-174\\\\admin\",\"path\":\"C:\\\\workarea\\\\WinTest1lakhfileinKB\\\\WinTest\\\\nGYh\\\\SMv\\\\U1P8FLx\\\\vMbhdo\\\\TgFSW\\\\42Ioulj0w.txt\"},{\"owner\":\"machine-174admin\",\"path\":\"C:\\\\workarea\\\\bada_data\\\\Employee Database - Copy (7) - Copy.mdb\"}],\"Count\":100,\"total\":100,\"page\":4}");

function nextData(page){
jsonData = JSON.parse("{\"Report\":\"type1\",\"FileList\":[{\"owner\":\"machine-170\\\\admin\",\"path\":\"C:\\\\workarea\\\\WinTest1lakhfileinKB\\\\WinTest\\\\nGYh\\\\SMv\\\\U1P8FLx\"},{\"owner\":\"machine-170admin\",\"path\":\"C:\\\\workarea\"}],\"Count\":100,\"total\":100,\"page\":5}");
$("#grid").kendoGrid({  dataSource: {
       serverPaging: true,
       schema: {
           data: "FileList",
           total: "total"
       },
       data: jsonData
   } })
}

createGrid(jsonData);
function createGrid(jsonData){
$("#grid").kendoGrid({
   pageable: true,
   scrollable: true,

   pageable: {
         pageSize: 2,
         refresh: true,
         change:function(e){
           nextData(e.index);
         }
     },
   dataSource: {
       serverPaging: true,
       schema: {
           data: "FileList",
           total: "total",
       },
       data: jsonData
   }
});
}
</code>```

How I remove multiple header when page change event call?

答:
Try modifying your nextData function as below.

function nextData(page){
    jsonData = JSON.parse("{\"Report\":\"type1\",\"FileList\":[{\"owner\":\"machine-170\\\\admin\",\"path\":\"C:\\\\workarea\\\\WinTest1lakhfileinKB\\\\WinTest\\\\nGYh\\\\SMv\\\\U1P8FLx\"},{\"owner\":\"machine-170admin\",\"path\":\"C:\\\\workarea\"}],\"Count\":100,\"total\":100,\"page\":5}");
    var _dataSource = new kendo.data.DataSource({
       schema: {
           data: "FileList",
           total: "total"
       },
       data: jsonData,
       serverPaging : true,
       pageSize : 2,
       page     : page
    });
    $("#grid").data("kendoGrid").setDataSource(_dataSource);
}```

Body:
I am creating a sample application in which I show data in kendo grid.
For this I get the page size data in kendo grid and then load it. when page change I load next data.

When my page change event call the grid is added in already exist grid. By this it shows multiple column header.

My sample is - http://jsfiddle.net/pporwal26/y6KdK/78/

var jsonData = JSON.parse("{\"Report\":\"type1\",\"FileList\":[{\"owner\":\"machine-174\\\\admin\",\"path\":\"C:\\\\workarea\\\\WinTest1lakhfileinKB\\\\WinTest\\\\nGYh\\\\SMv\\\\U1P8FLx\\\\vMbhdo\\\\TgFSW\\\\42Ioulj0w.txt\"},{\"owner\":\"machine-174admin\",\"path\":\"C:\\\\workarea\\\\bada_data\\\\Employee Database - Copy (7) - Copy.mdb\"}],\"Count\":100,\"total\":100,\"page\":4}");

function nextData(page){
jsonData = JSON.parse("{\"Report\":\"type1\",\"FileList\":[{\"owner\":\"machine-170\\\\admin\",\"path\":\"C:\\\\workarea\\\\WinTest1lakhfileinKB\\\\WinTest\\\\nGYh\\\\SMv\\\\U1P8FLx\"},{\"owner\":\"machine-170admin\",\"path\":\"C:\\\\workarea\"}],\"Count\":100,\"total\":100,\"page\":5}");
$("#grid").kendoGrid({  dataSource: {
       serverPaging: true,
       schema: {
           data: "FileList",
           total: "total"
       },
       data: jsonData
   } })
}

createGrid(jsonData);
function createGrid(jsonData){
$("#grid").kendoGrid({
   pageable: true,
   scrollable: true,

   pageable: {
         pageSize: 2,
         refresh: true,
         change:function(e){
           nextData(e.index);
         }
     },
   dataSource: {
       serverPaging: true,
       schema: {
           data: "FileList",
           total: "total",
       },
       data: jsonData
   }
});
}

How I remove multiple header when page change event call?


问:
Jupyterhub config for limit tensorflow gpu memory
I am building a tensorflow environment with Jupyterhub(docker spawner) for my students in class, but I face a problem with this.

By default, TensorFlow maps nearly all of the GPU memory of all GPUs
  (subject to CUDA_VISIBLE_DEVICES) visible to the process. This is done
  to more efficiently use the relatively precious GPU memory resources
  on the devices by reducing memory fragmentation.
  (from https://www.tensorflow.org/tutorials/using_gpu)

If anyone in class use python program with gpu,then the gpu memory will nearly exhaust.According to this situation,I need to add some limit code manually.
like:

```<code>config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config, ...)
</code>```

But this is not a great solution.I should add this code every time when new code generated.

If jupyterhub can add some config to avoid this situation or other great solutions?
Please let me know,thanks!

答:
```<code>import tensorflow as tf
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.2)
sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))
</code>```

this works well

Body:
I am building a tensorflow environment with Jupyterhub(docker spawner) for my students in class, but I face a problem with this.

By default, TensorFlow maps nearly all of the GPU memory of all GPUs
  (subject to CUDA_VISIBLE_DEVICES) visible to the process. This is done
  to more efficiently use the relatively precious GPU memory resources
  on the devices by reducing memory fragmentation.
  (from https://www.tensorflow.org/tutorials/using_gpu)

If anyone in class use python program with gpu,then the gpu memory will nearly exhaust.According to this situation,I need to add some limit code manually.
like:

config = tf.ConfigProto()
config.gpu_options.allow_growth = True
session = tf.Session(config=config, ...)

But this is not a great solution.I should add this code every time when new code generated.

If jupyterhub can add some config to avoid this situation or other great solutions?
Please let me know,thanks!

Body:
import tensorflow as tf
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.2)
sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))

this works well


问:
Adding days to date jquery or JS
I have a select to add days from an input on 'dd/mm/yy' format to show the result in another input, I tried to do this but this is not working.</p>

```<code><input type="text" id="startdate" value="15/11/17">

<select name="Select1" id="days">
<option value="1">1 day</option>
<option value="2">2 days</option>
<option value="3">3 days</option>
</select>

<input type="text" id="fdate" value="">

$( "#days" ).change(function() {
var sta = $('#startdate').val()
var sel = parseInt($(this).val())
$('#fdate').val(sta+sel )
});
</code>```

答:
You should use Date object of javascript

```<code>$( "#days" ).change(function() {
    var sta = $('#startdate').val().split('/');
    // Note that JS treats date as  mm/dd/yy
    var date = new Date([sta[1], sta[0], sta[2]].join('/'));
    var sel = parseInt($(this).val());
    date = new Date(date.getTime() + 60*60*24*sel);
    $('#fdate').val(date.getDaty() + '/' + date.getMonth() + '/' + date.getYear());
});
</code>```

Also please consider to change year displaying to full year because of same reasons Date.getYear deprecated

Title: Adding days to date jquery or JS

Body:
I have a select to add days from an input on 'dd/mm/yy' format to show the result in another input, I tried to do this but this is not working.

<input type="text" id="startdate" value="15/11/17">

<select name="Select1" id="days">
<option value="1">1 day</option>
<option value="2">2 days</option>
<option value="3">3 days</option>
</select>

<input type="text" id="fdate" value="">

$( "#days" ).change(function() {
var sta = $('#startdate').val()
var sel = parseInt($(this).val())
$('#fdate').val(sta+sel )
});

Body:
You should use Date object of javascript

$( "#days" ).change(function() {
    var sta = $('#startdate').val().split('/');
    // Note that JS treats date as  mm/dd/yy
    var date = new Date([sta[1], sta[0], sta[2]].join('/'));
    var sel = parseInt($(this).val());
    date = new Date(date.getTime() + 60*60*24*sel);
    $('#fdate').val(date.getDaty() + '/' + date.getMonth() + '/' + date.getYear());
});

Also please consider to change year displaying to full year because of same reasons Date.getYear deprecated


答:
Try this...</p>

```<code>$( "#days" ).change(function() {

var dates = $('#startdate').val();
dates = dates.split('/');
var someDate = new Date(dates[1] +"/" + dates[0] + "/"+dates[2]);
var numberOfDaysToAdd = parseInt($(this).val());
someDate.setDate(someDate.getDate() + numberOfDaysToAdd);
var dd = someDate.getDate();
var mm = someDate.getMonth() + 1;
var y = someDate.getFullYear();

var someFormattedDate = dd + '/'+ mm + '/'+ y;
$('#fdate').val(someFormattedDate);

});
</code>```

Title: Adding days to date jquery or JS

Body:
Try this...

$( "#days" ).change(function() {

var dates = $('#startdate').val();
dates = dates.split('/');
var someDate = new Date(dates[1] +"/" + dates[0] + "/"+dates[2]);
var numberOfDaysToAdd = parseInt($(this).val());
someDate.setDate(someDate.getDate() + numberOfDaysToAdd);
var dd = someDate.getDate();
var mm = someDate.getMonth() + 1;
var y = someDate.getFullYear();

var someFormattedDate = dd + '/'+ mm + '/'+ y;
$('#fdate').val(someFormattedDate);

});


问:
Spring data cdi multiple persistence unit error
i have a project in jee(Jboss 6.0.1) using jsf and ejbs.

I was using spring data with cdi and one persistence unit without any problems.
The configuration to inject persistence unit to the spring data.

```<code>public class CdiConfig {
    @Produces
    @Dependent
    @PersistenceContext(unitName = "simje")
    private EntityManager entityManager;
</code>```

But now i have another persistence unit in my persistence.xml ("sigroUnit"). So when i trying to deploy my application to jboss i'm getting

Persistence unitName was not specified and there are 2 persistence
  unit definitions in application deployment "simje.ear"

I did tried to create the same configuration to the other persistence unit.

```<code>    @Produces
    @Dependent
    @PersistenceContext(unitName = "sigro")
    private EntityManager entityManagerSigro;
</code>```

So i'm still getting the error from jboss.

Persistence unitName was not specified and there are 2 persistence
  unit definitions in application deployment "simje.ear"

Anyone has any ideia how to fix that problem?

My persistence

```<code>   <persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    version="2.0">
    <persistence-unit name="simje">
        <jta-data-source>java:/SimjeDS</jta-data-source>

        <!-- Entidades mapeados para o projeto devem ser adicionadas com o fullname -->
        <!-- <class>br.gov.cef.projeto.domain.enidade.Entidade</class> -->

        <!-- Entidades do modulo SIICO -->
        <class>br.gov.cef.siico.domain.endereco.Localidade</class>
        <class>br.gov.cef.siico.domain.endereco.MunicipioIbge</class>
        <class>br.gov.cef.siico.domain.endereco.MunicipioIbgePK</class>
        <class>br.gov.cef.siico.domain.endereco.Regiao</class>
        <class>br.gov.cef.siico.domain.endereco.Uf</class>
        <class>br.gov.cef.siico.domain.unidade.Unidade</class>
        <class>br.gov.cef.siico.domain.unidade.VinculoUnidade</class>
        <class>br.gov.cef.siico.domain.unidade.TipoUnidade</class>
        <class>br.gov.cef.siico.domain.unidade.ResponsavelUnidadeCaixa</class>
        <class>br.gov.cef.siico.domain.empregado.EmpregadoCaixa</class>
        <class>br.gov.cef.siico.domain.empregado.Funcao</class>
        <class>br.gov.cef.siico.domain.empregado.Cargo</class>

        <!-- Entidades SIMJE -->
        <class>br.gov.simje.domain.Tribunal</class>
        <class>br.gov.simje.domain.Certificado</class>
        <class>br.gov.simje.domain.Contato</class>
        <class>br.gov.simje.domain.ParametroSistema</class>

        <exclude-unlisted-classes>false</exclude-unlisted-classes>

        <properties>
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.format_sql" value="true" />
            <property name="hibernate.connection.driver_class" value="org.postgresql.Driver" />
            <property name="hibernate.hbm2ddl.auto" value="validate" />
            <property name="hibernate.jdbc.batch_size" value="600" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
            <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider" />
            <property name="hibernate.default_schema" value="pcpsm001" />
        </properties>
    </persistence-unit>

<persistence-unit name="sigro">
        <jta-data-source>java:/SigroDS</jta-data-source>

        <!-- Entidades SIGRO -->
        <class>br.gov.cef.sigro.domain.linhanegocio.LinhaNegocio</class>
        <class>br.gov.cef.sigro.domain.linhanegocio.LinhaNegocioPrincipal</class>
        <class>br.gov.cef.sigro.domain.linhanegocio.LinhaNegocioPrincipalPK</class>
        <class>br.gov.cef.sigro.domain.unidade.ResponsabilidadeUnidade</class>
        <class>br.gov.cef.sigro.domain.siico.UnidadeSigro</class>
        <class>br.gov.cef.sigro.domain.siico.GestaoProdutoSigro</class>
        <class>br.gov.cef.sigro.domain.siico.ProdutoSigro</class>
        <class>br.gov.cef.sigro.domain.informacao.FonteInformacao</class>
        <class>br.gov.cef.sigro.domain.perda.OrigemPerda</class>
        <class>br.gov.cef.sigro.domain.risco.CategoriaRisco</class>
        <class>br.gov.cef.sigro.domain.provisao.GrupoProvisao</class>
        <class>br.gov.cef.sigro.domain.macroprocesso.MacroProcesso</class>
        <class>br.gov.cef.sigro.domain.tipogestao.TipoGestao</class>
        <class>br.gov.cef.sigro.domain.provisao.IndicadorSucessoAcao</class>
        <class>br.gov.cef.sigro.domain.perda.ItemRegistroPerda</class>
        <class>br.gov.cef.sigro.domain.lancamento.LancamentoContabilClassificado</class>
        <class>br.gov.cef.sigro.domain.lancamento.LancamentoContabilPendenteAprovacao</class>
        <class>br.gov.cef.sigro.domain.lancamento.AutorizarLancamentoForaPrazo</class>
        <class>br.gov.cef.sigro.domain.evento.EventoContabil</class>
        <class>br.gov.cef.sigro.domain.macroprocesso.MacroProcessoGestao</class>
        <class>br.gov.cef.sigro.domain.unidade.UnidadeTipoGestao</class>
        <class>br.gov.cef.sigro.domain.provisao.RegistroProvisao</class>
        <class>br.gov.cef.sigro.domain.provisao.TipoLancamentoProvisao</class>
        <class>br.gov.cef.sigro.domain.planoconta.PlanoConta</class>
        <class>br.gov.cef.sigro.domain.risco.EventoRisco</class>
        <class>br.gov.cef.sigro.domain.siico.OperacaoBancaria</class>
        <class>br.gov.cef.sigro.domain.linhanegocio.LinhaNegocioOperacaoBancaria</class>
        <class>br.gov.cef.sigro.domain.produto.ProdutoOperacaoBancaria</class>
        <class>br.gov.cef.sigro.domain.lancamento.ModalidadeLancamentoPerda</class>
        <class>br.gov.cef.sigro.domain.perda.RegistroPerda</class>
        <class>br.gov.cef.sigro.domain.perda.Conciliacao</class>
        <class>br.gov.cef.sigro.domain.evento.RoteiroContabil</class>
        <class>br.gov.cef.sigro.domain.evento.EventoContabilProduto</class>
        <class>br.gov.cef.sigro.domain.evento.EventoExterno</class>
        <class>br.gov.cef.sigro.domain.evento.GestaoEventoContabil</class>
        <class>br.gov.cef.sigro.domain.risco.EventoRiscoEventoContabil</class>
        <class>br.gov.cef.sigro.domain.arquivo.ControleArquivoImportado</class>
        <class>br.gov.cef.sigro.domain.provisao.GrupoProvisaoEventoContabil</class>
        <class>br.gov.cef.sigro.domain.beicf.Instituicao</class>
        <class>br.gov.cef.sigro.domain.beicf.CategoriaBeicf</class>
        <class>br.gov.cef.sigro.domain.beicf.Beicf</class>
        <class>br.gov.cef.sigro.domain.beicf.RegistroBeicf</class>
        <class>br.gov.cef.sigro.domain.parametro.Parametro</class>
        <class>br.gov.cef.sigro.domain.produto.SubContaProduto</class>
        <class>br.gov.cef.sigro.domain.risco.QuestionarioRisco</class>
        <class>br.gov.cef.sigro.domain.risco.PerguntaRisco</class>
        <class>br.gov.cef.sigro.domain.risco.MapeamentoRisco</class>
        <class>br.gov.cef.sigro.domain.risco.QuestionarioPerguntaRisco</class>
        <class>br.gov.cef.sigro.domain.risco.QuestionarioCategoriaRisco</class>
        <class>br.gov.cef.sigro.domain.risco.CategoriaQuestaoRisco</class>
        <class>br.gov.cef.sigro.domain.autoavaliacao.PesquisaAutoavaliacao</class>
        <class>br.gov.cef.sigro.domain.autoavaliacao.PesquisaAutoavaliacaoUnidade</class>
        <class>br.gov.cef.sigro.domain.autoavaliacao.RespostaQuestionarioAutoavaliacao</class>
        <class>br.gov.cef.sigro.domain.autoavaliacao.DetalheRespostaQuestionario</class>
        <class>br.gov.cef.sigro.domain.risco.MapeamentoUnidadeEnvolvida</class>
        <class>br.gov.cef.sigro.domain.risco.MapeamentoRiscoSistema</class>
        <class>br.gov.cef.sigro.domain.risco.MapeamentoRiscoProduto</class>
        <class>br.gov.cef.sigro.domain.risco.RespostaAvaliacaoRisco</class>
        <class>br.gov.cef.sigro.domain.parametro.ParametroMensagemEmail</class>
        <class>br.gov.cef.sigro.domain.lancamento.SituacaoAgendamentoLancamentoContabil</class>
        <class>br.gov.cef.sigro.domain.lancamento.AgendamentoImportacaoLancamentoContabil</class>
        <class>br.gov.cef.sigro.domain.evento.ClassificacaoEventoContabilConta</class>
        <class>br.gov.cef.sigro.domain.matrizrisco.MatrizRisco</class>
        <class>br.gov.cef.sigro.domain.matrizrisco.DetalheMatrizRisco</class>
        <class>br.gov.cef.sigro.domain.matrizrisco.MatrizRiscoPesquisaAutoavaliacao</class>
        <class>br.gov.cef.sigro.domain.matrizrisco.MatrizRiscoPesquisaAutoavaliacaoPK</class>
        <class>br.gov.cef.sigro.domain.escalaimpacto.EscalaImpactoAutoAvaliacao</class>
        <class>br.gov.cef.sigro.domain.recomendacao.RecomendacaoPadrao</class>
        <class>br.gov.cef.sigro.domain.recomendacao.RecomendacaoEvento</class>
        <class>br.gov.cef.sigro.domain.autoavaliacao.NivelImpactoAutoavaliacao</class>
        <class>br.gov.cef.sigro.domain.transferencia.TransferenciaResponsabilidade</class>
        <class>br.gov.cef.sigro.domain.questionarioautoavaliacao.QuestaoAutoavaliacao</class>
        <class>br.gov.cef.sigro.domain.questionarioautoavaliacao.QuestionarioAutoavaliacao</class>
        <class>br.gov.cef.sigro.domain.questionarioautoavaliacao.QuestionarioQuestaoAutoavaliacao</class>
        <class>br.gov.cef.sigro.domain.questionarioautoavaliacao.AlternativaQuestaoAutoavaliacao</class>
        <class>br.gov.cef.sigro.domain.unidade.RepresentacaoUnidade</class>
        <class>br.gov.cef.sigro.domain.unidade.RepresentacaoUnidadePK</class>
        <class>br.gov.cef.sigro.domain.transferencia.ItemTransferenciaResponsabilidade</class>
        <class>br.gov.cef.sigro.domain.lancamento.basehistorica.LancamentoContabilCredito</class>
        <class>br.gov.cef.sigro.domain.lancamento.basehistorica.LancamentoContabilDebito</class>
        <class>br.gov.cef.sigro.domain.risco.EtapaMapeamentoRisco</class>
        <class>br.gov.cef.sigro.domain.risco.EtapaMapeamentoRiscoPK</class>
        <class>br.gov.cef.sigro.domain.questionarioautoavaliacao.ParametroQuestaoAutoavaliacao</class>
        <class>br.gov.cef.sigro.domain.risco.PesquisaAvaliacaoRisco</class>
        <class>br.gov.cef.sigro.domain.risco.PesquisaAvaliacaoRiscoUnidade</class>
        <class>br.gov.cef.sigro.domain.risco.ParametroFaixaNotaAvaliacaoRisco</class>
        <class>br.gov.cef.sigro.domain.perda.RegistroPerdaBaseHistorica</class>
        <class>br.gov.cef.sigro.domain.perda.ItemRegistroPerdaBaseHistorica</class>
        <class>br.gov.cef.sigro.domain.lancamento.AgendamentoImportacaoPerda</class>

        <!-- Entidades SIICO -->
        <class>br.gov.cef.siico.domain.entidade.EntidadeSiico</class>
        <class>br.gov.cef.siico.domain.publico.PublicoAlvo</class>
        <class>br.gov.cef.siico.domain.sistema.Sistema</class>
        <class>br.gov.cef.siico.domain.produto.FonteProduto</class>
        <class>br.gov.cef.siico.domain.produto.FonteRecurso</class>
        <class>br.gov.cef.siico.domain.publico.TipoPublico</class>
        <class>br.gov.cef.siico.domain.produto.TipoCanal</class>
        <class>br.gov.cef.siico.domain.produto.SegmentoAtendimento</class>
        <class>br.gov.cef.siico.domain.produto.AtendimentoProduto</class>
        <class>br.gov.cef.siico.domain.produto.ComercializacaoProduto</class>
        <class>br.gov.cef.siico.domain.empregado.EmpregadoCaixa</class>
        <class>br.gov.cef.siico.domain.endereco.Endereco</class>
        <class>br.gov.cef.siico.domain.empregado.Funcao</class>
        <class>br.gov.cef.siico.domain.empregado.Cargo</class>
        <class>br.gov.cef.siico.domain.endereco.Localidade</class>
        <class>br.gov.cef.siico.domain.endereco.MunicipioIbge</class>
        <class>br.gov.cef.siico.domain.endereco.MunicipioIbgePK</class>
        <class>br.gov.cef.siico.domain.endereco.Regiao</class>
        <class>br.gov.cef.siico.domain.endereco.Uf</class>
        <class>br.gov.cef.siico.domain.unidade.TipoUnidade</class>
        <class>br.gov.cef.siico.domain.unidade.Unidade</class>
        <class>br.gov.cef.siico.domain.unidade.UnidadePK</class>
        <class>br.gov.cef.siico.domain.unidade.VinculoUnidade</class>
        <class>br.gov.cef.siico.domain.unidade.VinculoUnidadePK</class>
        <class>br.gov.cef.siico.domain.unidade.LocalizacaoUnidade</class>
        <class>br.gov.cef.siico.domain.unidade.LocalizacaoUnidadePK</class>
        <class>br.gov.cef.siico.domain.produto.GestaoProduto</class>
        <class>br.gov.cef.siico.domain.produto.ProdutoSiico</class>
        <class>br.gov.cef.siico.domain.operacao.Operacao</class>
        <class>br.gov.cef.siico.domain.operacao.LinhaOperacao</class>
        <class>br.gov.cef.siico.domain.operacao.AreaAtuacao</class>
        <class>br.gov.cef.siico.domain.unidade.ResponsavelUnidadeCaixa</class>
        <class>br.gov.cef.siico.domain.unidade.ResponsavelUnidadeCaixaPK</class>
        <class>br.gov.cef.siico.domain.comunicacao.MeioComunicacao</class>
        <class>br.gov.cef.siico.domain.comunicacao.MeioComunicacaoUnidade</class>
        <class>br.gov.cef.siico.domain.comunicacao.MeioComunicacaoUnidadePK</class>

        <!-- Processamento -->
        <class>br.gov.cef.sigro.domain.processamento.Processamento</class>
        <class>br.gov.cef.sigro.domain.processamento.ExecucaoProcessamento</class>
        <class>br.gov.cef.sigro.domain.processamento.ItemProcessamento</class>

        <!-- Cenário -->
        <class>br.gov.cef.sigro.domain.cenario.Cenario</class>
        <class>br.gov.cef.sigro.domain.cenario.RegistroCenario</class>

        <!-- Plano de Ação -->
        <class>br.gov.cef.sigro.domain.matrizgut.MatrizGut</class>
        <class>br.gov.cef.sigro.domain.matrizgut.DetalheMatrizGut</class>
        <class>br.gov.cef.sigro.domain.planoacao.OrigemApontamento</class>
        <class>br.gov.cef.sigro.domain.planoacao.Acao</class>
        <class>br.gov.cef.sigro.domain.planoacao.PlanoAcaoAcaoMitigacao</class>
        <class>br.gov.cef.sigro.domain.planoacao.ParametrosPlanoAcaoAcaoMitigacao</class>
        <class>br.gov.cef.sigro.domain.planoacao.historico.HistoricoPlanoAcao</class>

        <exclude-unlisted-classes>false</exclude-unlisted-classes>

        <properties>
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.format_sql" value="true" />
            <property name="hibernate.connection.driver_class" value="org.postgresql.Driver" />
            <property name="hibernate.hbm2ddl.auto" value="validate" />
            <property name="hibernate.jdbc.batch_size" value="50" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
            <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider" />
            <property name="hibernate.default_schema" value="grosm001" />
        </properties>
    </persistence-unit>

</persistence>
</code>```

答:
Do not create producer. In your business classes simply use:

```<code>@PersistenceContext(unitName = "simje")
private EntityManager entityManager;
</code>```

or

```<code>@PersistenceContext(unitName = "sigro")
private EntityManager entityManagerSigro;
</code>```

or both.

If you still want to use CDI inject with producer you need to create the qualifier to distinguish between these entity managers. But I never see this solution because it does not makes any sense...

```<code>@Qualifier
</code>```

More info here: Dependency injection

Body:
i have a project in jee(Jboss 6.0.1) using jsf and ejbs.

I was using spring data with cdi and one persistence unit without any problems.
The configuration to inject persistence unit to the spring data.

public class CdiConfig {
    @Produces
    @Dependent
    @PersistenceContext(unitName = "simje")
    private EntityManager entityManager;

But now i have another persistence unit in my persistence.xml ("sigroUnit"). So when i trying to deploy my application to jboss i'm getting

Persistence unitName was not specified and there are 2 persistence
  unit definitions in application deployment "simje.ear"

I did tried to create the same configuration to the other persistence unit.

    @Produces
    @Dependent
    @PersistenceContext(unitName = "sigro")
    private EntityManager entityManagerSigro;

So i'm still getting the error from jboss.

Persistence unitName was not specified and there are 2 persistence
  unit definitions in application deployment "simje.ear"

Anyone has any ideia how to fix that problem?

My persistence

   <persistence xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
    version="2.0">
    <persistence-unit name="simje">
        <jta-data-source>java:/SimjeDS</jta-data-source>

        <class>br.gov.cef.siico.domain.endereco.Localidade</class>
        <class>br.gov.cef.siico.domain.endereco.MunicipioIbge</class>
        <class>br.gov.cef.siico.domain.endereco.MunicipioIbgePK</class>
        <class>br.gov.cef.siico.domain.endereco.Regiao</class>
        <class>br.gov.cef.siico.domain.endereco.Uf</class>
        <class>br.gov.cef.siico.domain.unidade.Unidade</class>
        <class>br.gov.cef.siico.domain.unidade.VinculoUnidade</class>
        <class>br.gov.cef.siico.domain.unidade.TipoUnidade</class>
        <class>br.gov.cef.siico.domain.unidade.ResponsavelUnidadeCaixa</class>
        <class>br.gov.cef.siico.domain.empregado.EmpregadoCaixa</class>
        <class>br.gov.cef.siico.domain.empregado.Funcao</class>
        <class>br.gov.cef.siico.domain.empregado.Cargo</class>

        <class>br.gov.simje.domain.Tribunal</class>
        <class>br.gov.simje.domain.Certificado</class>
        <class>br.gov.simje.domain.Contato</class>
        <class>br.gov.simje.domain.ParametroSistema</class>

        <exclude-unlisted-classes>false</exclude-unlisted-classes>

        <properties>
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.format_sql" value="true" />
            <property name="hibernate.connection.driver_class" value="org.postgresql.Driver" />
            <property name="hibernate.hbm2ddl.auto" value="validate" />
            <property name="hibernate.jdbc.batch_size" value="600" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
            <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider" />
            <property name="hibernate.default_schema" value="pcpsm001" />
        </properties>
    </persistence-unit>

<persistence-unit name="sigro">
        <jta-data-source>java:/SigroDS</jta-data-source>

        <class>br.gov.cef.sigro.domain.linhanegocio.LinhaNegocio</class>
        <class>br.gov.cef.sigro.domain.linhanegocio.LinhaNegocioPrincipal</class>
        <class>br.gov.cef.sigro.domain.linhanegocio.LinhaNegocioPrincipalPK</class>
        <class>br.gov.cef.sigro.domain.unidade.ResponsabilidadeUnidade</class>
        <class>br.gov.cef.sigro.domain.siico.UnidadeSigro</class>
        <class>br.gov.cef.sigro.domain.siico.GestaoProdutoSigro</class>
        <class>br.gov.cef.sigro.domain.siico.ProdutoSigro</class>
        <class>br.gov.cef.sigro.domain.informacao.FonteInformacao</class>
        <class>br.gov.cef.sigro.domain.perda.OrigemPerda</class>
        <class>br.gov.cef.sigro.domain.risco.CategoriaRisco</class>
        <class>br.gov.cef.sigro.domain.provisao.GrupoProvisao</class>
        <class>br.gov.cef.sigro.domain.macroprocesso.MacroProcesso</class>
        <class>br.gov.cef.sigro.domain.tipogestao.TipoGestao</class>
        <class>br.gov.cef.sigro.domain.provisao.IndicadorSucessoAcao</class>
        <class>br.gov.cef.sigro.domain.perda.ItemRegistroPerda</class>
        <class>br.gov.cef.sigro.domain.lancamento.LancamentoContabilClassificado</class>
        <class>br.gov.cef.sigro.domain.lancamento.LancamentoContabilPendenteAprovacao</class>
        <class>br.gov.cef.sigro.domain.lancamento.AutorizarLancamentoForaPrazo</class>
        <class>br.gov.cef.sigro.domain.evento.EventoContabil</class>
        <class>br.gov.cef.sigro.domain.macroprocesso.MacroProcessoGestao</class>
        <class>br.gov.cef.sigro.domain.unidade.UnidadeTipoGestao</class>
        <class>br.gov.cef.sigro.domain.provisao.RegistroProvisao</class>
        <class>br.gov.cef.sigro.domain.provisao.TipoLancamentoProvisao</class>
        <class>br.gov.cef.sigro.domain.planoconta.PlanoConta</class>
        <class>br.gov.cef.sigro.domain.risco.EventoRisco</class>
        <class>br.gov.cef.sigro.domain.siico.OperacaoBancaria</class>
        <class>br.gov.cef.sigro.domain.linhanegocio.LinhaNegocioOperacaoBancaria</class>
        <class>br.gov.cef.sigro.domain.produto.ProdutoOperacaoBancaria</class>
        <class>br.gov.cef.sigro.domain.lancamento.ModalidadeLancamentoPerda</class>
        <class>br.gov.cef.sigro.domain.perda.RegistroPerda</class>
        <class>br.gov.cef.sigro.domain.perda.Conciliacao</class>
        <class>br.gov.cef.sigro.domain.evento.RoteiroContabil</class>
        <class>br.gov.cef.sigro.domain.evento.EventoContabilProduto</class>
        <class>br.gov.cef.sigro.domain.evento.EventoExterno</class>
        <class>br.gov.cef.sigro.domain.evento.GestaoEventoContabil</class>
        <class>br.gov.cef.sigro.domain.risco.EventoRiscoEventoContabil</class>
        <class>br.gov.cef.sigro.domain.arquivo.ControleArquivoImportado</class>
        <class>br.gov.cef.sigro.domain.provisao.GrupoProvisaoEventoContabil</class>
        <class>br.gov.cef.sigro.domain.beicf.Instituicao</class>
        <class>br.gov.cef.sigro.domain.beicf.CategoriaBeicf</class>
        <class>br.gov.cef.sigro.domain.beicf.Beicf</class>
        <class>br.gov.cef.sigro.domain.beicf.RegistroBeicf</class>
        <class>br.gov.cef.sigro.domain.parametro.Parametro</class>
        <class>br.gov.cef.sigro.domain.produto.SubContaProduto</class>
        <class>br.gov.cef.sigro.domain.risco.QuestionarioRisco</class>
        <class>br.gov.cef.sigro.domain.risco.PerguntaRisco</class>
        <class>br.gov.cef.sigro.domain.risco.MapeamentoRisco</class>
        <class>br.gov.cef.sigro.domain.risco.QuestionarioPerguntaRisco</class>
        <class>br.gov.cef.sigro.domain.risco.QuestionarioCategoriaRisco</class>
        <class>br.gov.cef.sigro.domain.risco.CategoriaQuestaoRisco</class>
        <class>br.gov.cef.sigro.domain.autoavaliacao.PesquisaAutoavaliacao</class>
        <class>br.gov.cef.sigro.domain.autoavaliacao.PesquisaAutoavaliacaoUnidade</class>
        <class>br.gov.cef.sigro.domain.autoavaliacao.RespostaQuestionarioAutoavaliacao</class>
        <class>br.gov.cef.sigro.domain.autoavaliacao.DetalheRespostaQuestionario</class>
        <class>br.gov.cef.sigro.domain.risco.MapeamentoUnidadeEnvolvida</class>
        <class>br.gov.cef.sigro.domain.risco.MapeamentoRiscoSistema</class>
        <class>br.gov.cef.sigro.domain.risco.MapeamentoRiscoProduto</class>
        <class>br.gov.cef.sigro.domain.risco.RespostaAvaliacaoRisco</class>
        <class>br.gov.cef.sigro.domain.parametro.ParametroMensagemEmail</class>
        <class>br.gov.cef.sigro.domain.lancamento.SituacaoAgendamentoLancamentoContabil</class>
        <class>br.gov.cef.sigro.domain.lancamento.AgendamentoImportacaoLancamentoContabil</class>
        <class>br.gov.cef.sigro.domain.evento.ClassificacaoEventoContabilConta</class>
        <class>br.gov.cef.sigro.domain.matrizrisco.MatrizRisco</class>
        <class>br.gov.cef.sigro.domain.matrizrisco.DetalheMatrizRisco</class>
        <class>br.gov.cef.sigro.domain.matrizrisco.MatrizRiscoPesquisaAutoavaliacao</class>
        <class>br.gov.cef.sigro.domain.matrizrisco.MatrizRiscoPesquisaAutoavaliacaoPK</class>
        <class>br.gov.cef.sigro.domain.escalaimpacto.EscalaImpactoAutoAvaliacao</class>
        <class>br.gov.cef.sigro.domain.recomendacao.RecomendacaoPadrao</class>
        <class>br.gov.cef.sigro.domain.recomendacao.RecomendacaoEvento</class>
        <class>br.gov.cef.sigro.domain.autoavaliacao.NivelImpactoAutoavaliacao</class>
        <class>br.gov.cef.sigro.domain.transferencia.TransferenciaResponsabilidade</class>
        <class>br.gov.cef.sigro.domain.questionarioautoavaliacao.QuestaoAutoavaliacao</class>
        <class>br.gov.cef.sigro.domain.questionarioautoavaliacao.QuestionarioAutoavaliacao</class>
        <class>br.gov.cef.sigro.domain.questionarioautoavaliacao.QuestionarioQuestaoAutoavaliacao</class>
        <class>br.gov.cef.sigro.domain.questionarioautoavaliacao.AlternativaQuestaoAutoavaliacao</class>
        <class>br.gov.cef.sigro.domain.unidade.RepresentacaoUnidade</class>
        <class>br.gov.cef.sigro.domain.unidade.RepresentacaoUnidadePK</class>
        <class>br.gov.cef.sigro.domain.transferencia.ItemTransferenciaResponsabilidade</class>
        <class>br.gov.cef.sigro.domain.lancamento.basehistorica.LancamentoContabilCredito</class>
        <class>br.gov.cef.sigro.domain.lancamento.basehistorica.LancamentoContabilDebito</class>
        <class>br.gov.cef.sigro.domain.risco.EtapaMapeamentoRisco</class>
        <class>br.gov.cef.sigro.domain.risco.EtapaMapeamentoRiscoPK</class>
        <class>br.gov.cef.sigro.domain.questionarioautoavaliacao.ParametroQuestaoAutoavaliacao</class>
        <class>br.gov.cef.sigro.domain.risco.PesquisaAvaliacaoRisco</class>
        <class>br.gov.cef.sigro.domain.risco.PesquisaAvaliacaoRiscoUnidade</class>
        <class>br.gov.cef.sigro.domain.risco.ParametroFaixaNotaAvaliacaoRisco</class>
        <class>br.gov.cef.sigro.domain.perda.RegistroPerdaBaseHistorica</class>
        <class>br.gov.cef.sigro.domain.perda.ItemRegistroPerdaBaseHistorica</class>
        <class>br.gov.cef.sigro.domain.lancamento.AgendamentoImportacaoPerda</class>

        <class>br.gov.cef.siico.domain.entidade.EntidadeSiico</class>
        <class>br.gov.cef.siico.domain.publico.PublicoAlvo</class>
        <class>br.gov.cef.siico.domain.sistema.Sistema</class>
        <class>br.gov.cef.siico.domain.produto.FonteProduto</class>
        <class>br.gov.cef.siico.domain.produto.FonteRecurso</class>
        <class>br.gov.cef.siico.domain.publico.TipoPublico</class>
        <class>br.gov.cef.siico.domain.produto.TipoCanal</class>
        <class>br.gov.cef.siico.domain.produto.SegmentoAtendimento</class>
        <class>br.gov.cef.siico.domain.produto.AtendimentoProduto</class>
        <class>br.gov.cef.siico.domain.produto.ComercializacaoProduto</class>
        <class>br.gov.cef.siico.domain.empregado.EmpregadoCaixa</class>
        <class>br.gov.cef.siico.domain.endereco.Endereco</class>
        <class>br.gov.cef.siico.domain.empregado.Funcao</class>
        <class>br.gov.cef.siico.domain.empregado.Cargo</class>
        <class>br.gov.cef.siico.domain.endereco.Localidade</class>
        <class>br.gov.cef.siico.domain.endereco.MunicipioIbge</class>
        <class>br.gov.cef.siico.domain.endereco.MunicipioIbgePK</class>
        <class>br.gov.cef.siico.domain.endereco.Regiao</class>
        <class>br.gov.cef.siico.domain.endereco.Uf</class>
        <class>br.gov.cef.siico.domain.unidade.TipoUnidade</class>
        <class>br.gov.cef.siico.domain.unidade.Unidade</class>
        <class>br.gov.cef.siico.domain.unidade.UnidadePK</class>
        <class>br.gov.cef.siico.domain.unidade.VinculoUnidade</class>
        <class>br.gov.cef.siico.domain.unidade.VinculoUnidadePK</class>
        <class>br.gov.cef.siico.domain.unidade.LocalizacaoUnidade</class>
        <class>br.gov.cef.siico.domain.unidade.LocalizacaoUnidadePK</class>
        <class>br.gov.cef.siico.domain.produto.GestaoProduto</class>
        <class>br.gov.cef.siico.domain.produto.ProdutoSiico</class>
        <class>br.gov.cef.siico.domain.operacao.Operacao</class>
        <class>br.gov.cef.siico.domain.operacao.LinhaOperacao</class>
        <class>br.gov.cef.siico.domain.operacao.AreaAtuacao</class>
        <class>br.gov.cef.siico.domain.unidade.ResponsavelUnidadeCaixa</class>
        <class>br.gov.cef.siico.domain.unidade.ResponsavelUnidadeCaixaPK</class>
        <class>br.gov.cef.siico.domain.comunicacao.MeioComunicacao</class>
        <class>br.gov.cef.siico.domain.comunicacao.MeioComunicacaoUnidade</class>
        <class>br.gov.cef.siico.domain.comunicacao.MeioComunicacaoUnidadePK</class>

        <class>br.gov.cef.sigro.domain.processamento.Processamento</class>
        <class>br.gov.cef.sigro.domain.processamento.ExecucaoProcessamento</class>
        <class>br.gov.cef.sigro.domain.processamento.ItemProcessamento</class>

        <class>br.gov.cef.sigro.domain.cenario.Cenario</class>
        <class>br.gov.cef.sigro.domain.cenario.RegistroCenario</class>

        <class>br.gov.cef.sigro.domain.matrizgut.MatrizGut</class>
        <class>br.gov.cef.sigro.domain.matrizgut.DetalheMatrizGut</class>
        <class>br.gov.cef.sigro.domain.planoacao.OrigemApontamento</class>
        <class>br.gov.cef.sigro.domain.planoacao.Acao</class>
        <class>br.gov.cef.sigro.domain.planoacao.PlanoAcaoAcaoMitigacao</class>
        <class>br.gov.cef.sigro.domain.planoacao.ParametrosPlanoAcaoAcaoMitigacao</class>
        <class>br.gov.cef.sigro.domain.planoacao.historico.HistoricoPlanoAcao</class>

        <exclude-unlisted-classes>false</exclude-unlisted-classes>

        <properties>
            <property name="hibernate.show_sql" value="true" />
            <property name="hibernate.format_sql" value="true" />
            <property name="hibernate.connection.driver_class" value="org.postgresql.Driver" />
            <property name="hibernate.hbm2ddl.auto" value="validate" />
            <property name="hibernate.jdbc.batch_size" value="50" />
            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
            <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider" />
            <property name="hibernate.default_schema" value="grosm001" />
        </properties>
    </persistence-unit>

</persistence>

Body:
Do not create producer. In your business classes simply use:

@PersistenceContext(unitName = "simje")
private EntityManager entityManager;

or

@PersistenceContext(unitName = "sigro")
private EntityManager entityManagerSigro;

or both.

If you still want to use CDI inject with producer you need to create the qualifier to distinguish between these entity managers. But I never see this solution because it does not makes any sense...

@Qualifier

More info here: Dependency injection


问:
Azure Service Bus errors
I've been experimenting with the latest Azure Service Bus SDK. Using very low-volume topic messages (posted by manually-executed Azure Function HTTP triggers from my browser), I'm seeing a pretty high failure rate in the Azure dashboard -- something like one out of every four or five messages fails. However, I don't ever catch any exceptions in the Azure Function code. How is a sending application supposed to detect these failures? For that matter, how do I log the specific failures? I see the spikes in the graph but can't find details. (I'm using an MSDN VS Enterprise freebie subscription.) Sometimes the queued messages and/or failures don't show up in the Azure portal for several minutes. (So far I haven't written a subscriber but I'm guessing the portal is effectively a "subscribe to everything" client of some kind.)

The topic is non-partitioned with a long TTL (the 14-day default). No dupe detection. The code is simple enough (try/catch omitted), newevent is a simple C# class with just a couple of properties and ToString is an override using JsonConvert:

```<code>        TopicClient topic = new TopicClient(connection, topic);
        Message msg = new Message(Encoding.UTF8.GetBytes(newevent.ToString()));
        msg.MessageId = newevent.Timestamp;
        await topic.SendAsync(msg);
        await topic.CloseAsync();
</code>```

答:
I don't think it's a blocker for low-volume traffic, but you shouldn't new up and close your TopicClient for each message. You can create it once and reuse for subsequent requests.

In the context of Azure Functions, you are better off using output binding feature instead of creating TopicClient yourself, see example in docs. The runtime will manage topic client for you then.

Title: Azure Service Bus errors

Body:
I've been experimenting with the latest Azure Service Bus SDK. Using very low-volume topic messages (posted by manually-executed Azure Function HTTP triggers from my browser), I'm seeing a pretty high failure rate in the Azure dashboard -- something like one out of every four or five messages fails. However, I don't ever catch any exceptions in the Azure Function code. How is a sending application supposed to detect these failures? For that matter, how do I log the specific failures? I see the spikes in the graph but can't find details. (I'm using an MSDN VS Enterprise freebie subscription.) Sometimes the queued messages and/or failures don't show up in the Azure portal for several minutes. (So far I haven't written a subscriber but I'm guessing the portal is effectively a "subscribe to everything" client of some kind.)

The topic is non-partitioned with a long TTL (the 14-day default). No dupe detection. The code is simple enough (try/catch omitted), newevent is a simple C# class with just a couple of properties and ToString is an override using JsonConvert:

        TopicClient topic = new TopicClient(connection, topic);
        Message msg = new Message(Encoding.UTF8.GetBytes(newevent.ToString()));
        msg.MessageId = newevent.Timestamp;
        await topic.SendAsync(msg);
        await topic.CloseAsync();


问:
Appending php array values with string doesn't give expected output
I have database query which returns an array of string values. I want them to be comma separated and appended to another string.

```<code>$sql1 = "select location.name as name from location,destination where destination.name='".$destination."' AND location.destination_id=destination.destination_id";
$result1 = $conn->query($sql1);
if ($result1->num_rows > 0) {
  $insert = "";
    while($locations = $result1->fetch_assoc()) {
  foreach ($locations as $location) {
$insert .= $location['name'] . ",";
      }
   }

$insert = rtrim($insert, ",");

 }

$sql2 = "select destination.destination_description as description from destination where destination.name='".$destination."'";
$result2 = $conn->query($sql2);
if ($result2->num_rows > 0) {
    while($row = $result2->fetch_assoc()) {
    $response->speech = $destination." is the ".$row["description"].". ".$insert . "are some of the places you can try.";
   echo json_encode($response);
  }
}
</code>```

This $insert array doesn't give the expected result. It gives just "N".

答:
You can remove the line foreach ($locations as $location)

Your while already fetch all rows to locations so you just need to append your locations[‘name’]. Your foreach has retrieved each character in the string $locations

Body:
I have database query which returns an array of string values. I want them to be comma separated and appended to another string.

$sql1 = "select location.name as name from location,destination where destination.name='".$destination."' AND location.destination_id=destination.destination_id";
$result1 = $conn->query($sql1);
if ($result1->num_rows > 0) {
  $insert = "";
    while($locations = $result1->fetch_assoc()) {
  foreach ($locations as $location) {
$insert .= $location['name'] . ",";
      }
   }

$insert = rtrim($insert, ",");

 }

$sql2 = "select destination.destination_description as description from destination where destination.name='".$destination."'";
$result2 = $conn->query($sql2);
if ($result2->num_rows > 0) {
    while($row = $result2->fetch_assoc()) {
    $response->speech = $destination." is the ".$row["description"].". ".$insert . "are some of the places you can try.";
   echo json_encode($response);
  }
}

This $insert array doesn't give the expected result. It gives just "N".


问:
class X : X<T> { } pattern in C# --- what is it used for?
What is this pattern used for ? note that it is different than the C++ "curiously recurring template pattern".</p>

答:
Having the generic ancestor class know the actual descendant that inherits from it helps in scenarios where the generic ancestor needs to expose a particular non-generic descendant class as part of the non-generic descendant's result own contract.

One common example is a factory method declared in the generic ancestor:

```<code>public class Parent<T>
    where T : Parent<T>, new
{
    public static T Create()
    {
        return new T(); // would be typically something more sophisticated
    }
}

public class Child : Parent<Child>
{
}
</code>```

The primary advantage of this concept is code-deduplication.

ContentLicense: CC BY-SA 2.5

Body:
Having the generic ancestor class know the actual descendant that inherits from it helps in scenarios where the generic ancestor needs to expose a particular non-generic descendant class as part of the non-generic descendant's result own contract.

One common example is a factory method declared in the generic ancestor:

public class Parent<T>
    where T : Parent<T>, new
{
    public static T Create()
    {
        return new T(); // would be typically something more sophisticated
    }
}

public class Child : Parent<Child>
{
}

The primary advantage of this concept is code-deduplication.


问:
Get Content Type of Request
To find the incoming content type, docs say:

```<code> request.headers["Content-Type"] # => "text/plain"
</code>```

But I found by trial-and-error, that doesn't work, but this does:

```<code> request.headers["CONTENT_TYPE"]=='application/json'
</code>```

So what's the most robust+portable way to do it?

Title: Get Content Type of Request

Body:
To find the incoming content type, docs say:

 request.headers["Content-Type"] # => "text/plain"

But I found by trial-and-error, that doesn't work, but this does:

 request.headers["CONTENT_TYPE"]=='application/json'

So what's the most robust+portable way to do it?

Body: request.format == 'application/json'


问:
Access JSON data through variable .-string interpolation
Trying to access integer stored under id's/keys in json object. Why doesn't this code work on its own?

```<code> var rooms = {
    'kitchen': [7, 40, 36, 16],
    'livingroom': 31,
    'livingroom2': 15,
    'livingroom3': 38,
    'gallery': 35,
    'gallery2': 29,
    'gallery3': 12,
    'office': [22, 32],
    'neekonsbedroom': 18,
    'homeworkroom': 33,
    'diningroom': 13,
    'atrium': 11
}
function switchOne(id) {
    console.log(rooms.id)
}
 switchOne('office')
</code>```

console.log() returns undefined, but simply console.log(rooms.office) returns [ 22, 32 ]
Any and all help is greatly appreciated!
Happy coding!

答: You should try this way object[key]

Body:
Trying to access integer stored under id's/keys in json object. Why doesn't this code work on its own?

 var rooms = {
    'kitchen': [7, 40, 36, 16],
    'livingroom': 31,
    'livingroom2': 15,
    'livingroom3': 38,
    'gallery': 35,
    'gallery2': 29,
    'gallery3': 12,
    'office': [22, 32],
    'neekonsbedroom': 18,
    'homeworkroom': 33,
    'diningroom': 13,
    'atrium': 11
}
function switchOne(id) {
    console.log(rooms.id)
}
 switchOne('office')

console.log() returns undefined, but simply console.log(rooms.office) returns [ 22, 32 ]
Any and all help is greatly appreciated!
Happy coding!

Body: You should try this way object[key]


问:
XamlParseException: Attribute in custom control missing, but it's defined!
I sometimes get the following exception for a custom control of mine:

XamlParseException occurred Unknown attribute Points in element SectionClickableArea [Line: 10 Position 16]

The stack trace:

```<code>{System.Windows.Markup.XamlParseException: Unknown attribute Points on element SectionClickableArea. [Line: 10 Position: 16]
   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
   at SomeMainDialog.InitializeComponent()
   at SomeMainDialog..ctor()}
</code>```

The element declaration where this happens looks like this (the event handler referenced here is defined, of course):

```<code><l:SectionClickableArea x:Name="SomeButton"
    Points="528,350, 508,265, 520,195, 515,190, 517,165, 530,120, 555,75, 570,61, 580,60, 600,66, 615,80, 617,335, 588,395, 550,385, 540,390, 525,393, 520,385"
    Click="SomeButton_Click"/>
</code>```

This is part of the code of SectionClickableArea:

```<code>public partial class SectionClickableArea : Button {

    public static readonly DependencyProperty PointsProperty
        = DependencyProperty.Register("Points", typeof(PointCollection), typeof(SectionClickableArea),
            new PropertyMetadata((s, e) => {
                SectionClickableArea area = (SectionClickableArea) s;
                area.areaInfo.Points = (PointCollection) e.NewValue;
                area.UpdateLabelPosition();
            }));
    public PointCollection Points {
        get { return (PointCollection) GetValue(PointsProperty); }
        set { SetValue(PointsProperty, value); }
    }
</code>```

I use this control for something like a polygon-shaped button. Therefore I'm inheriting from button. I've had similar problems (E_AG_BAD_PROPERTY_VALUE on another DependencyProperty of type string, according to the line and column given, etc) with this control for weeks, but I have absolutely no idea why.

Another exception for the same control occurred this morning for another user (taken from a log and translated from German):

```<code>Type: System.InvalidCastException Message: The object of type System.Windows.Controls.ContentControl could not be converted to type [...]SectionClickableArea. at SomeOtherMainDialog.InitializeComponent()
    at SomeOtherMainDialog..ctor()
</code>```

Inner exception:

```<code>Type: System.Exception Message:  An HRESULT E_FAIL error was returned when calling COM component at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
    at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper obj, DependencyProperty property, DependencyObject doh)
    at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper doh, DependencyProperty property, Object obj)
    at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
    at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isSetByStyle, Boolean isSetByBuiltInStyle)
    at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value)
    at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
    at System.Windows.Controls.Control.set_DefaultStyleKey(Object value)
    at System.Windows.Controls.ContentControl..ctor()
    at System.Windows.CoreTypes.GetCoreWrapper(Int32 typeId)
    at MS.Internal.ManagedPeerTable.EnsureManagedPeer(IntPtr unmanagedPointer, Int32 typeIndex, Type type, Boolean preserveManagedObjectReference)
    at MS.Internal.ManagedPeerTable.EnsureManagedPeer(IntPtr unmanagedPointer, Int32 typeIndex, Type type)
    at MS.Internal.ManagedPeerTable.GetManagedPeer(IntPtr nativeObject)
    at MS.Internal.FrameworkCallbacks.SetPropertyAttribute(IntPtr nativeTarget, String attrName, String attrValue, String attachedDPOwnerNamespace, String attachedDPOwnerAssembly)
</code>```

Any ideas what's wrong with the control, or what I can do to find the source of these exceptions? As I said, these problem occur only every few dozen times the control is instantiated.

答:
I think that we are seeing the same problem.  I just get the invalidcast exception more frequently. When, through blind commenting of stuff, I can suppress the invalidcast, I do sometimes get the attribute missing error for an attribute that is, in fact, there.  Have you found a solution?

BTW: the easy way to repro it is to just load the offending app and repeatedly hit F5 to refresh the page.  You will get it eventually.

I have also seen an intermittent InvalidOperationException that is through from DependencyObject.get_NativeObject().

see my SO question here:
Intermittent InavlidCastException in a UserControl.InitializeComponent()

See my silverlight.net bug report here:
http://silverlight.net/forums/t/67732.aspx

OwnerDisplayName: Daniel Beck

Body:
I sometimes get the following exception for a custom control of mine:

XamlParseException occurred Unknown attribute Points in element SectionClickableArea [Line: 10 Position 16]

The stack trace:

{System.Windows.Markup.XamlParseException: Unknown attribute Points on element SectionClickableArea. [Line: 10 Position: 16]
   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
   at SomeMainDialog.InitializeComponent()
   at SomeMainDialog..ctor()}

The element declaration where this happens looks like this (the event handler referenced here is defined, of course):

<l:SectionClickableArea x:Name="SomeButton"
    Points="528,350, 508,265, 520,195, 515,190, 517,165, 530,120, 555,75, 570,61, 580,60, 600,66, 615,80, 617,335, 588,395, 550,385, 540,390, 525,393, 520,385"
    Click="SomeButton_Click"/>

This is part of the code of SectionClickableArea:

public partial class SectionClickableArea : Button {

    public static readonly DependencyProperty PointsProperty
        = DependencyProperty.Register("Points", typeof(PointCollection), typeof(SectionClickableArea),
            new PropertyMetadata((s, e) => {
                SectionClickableArea area = (SectionClickableArea) s;
                area.areaInfo.Points = (PointCollection) e.NewValue;
                area.UpdateLabelPosition();
            }));
    public PointCollection Points {
        get { return (PointCollection) GetValue(PointsProperty); }
        set { SetValue(PointsProperty, value); }
    }

I use this control for something like a polygon-shaped button. Therefore I'm inheriting from button. I've had similar problems (E_AG_BAD_PROPERTY_VALUE on another DependencyProperty of type string, according to the line and column given, etc) with this control for weeks, but I have absolutely no idea why.

Another exception for the same control occurred this morning for another user (taken from a log and translated from German):

Type: System.InvalidCastException Message: The object of type System.Windows.Controls.ContentControl could not be converted to type [...]SectionClickableArea. at SomeOtherMainDialog.InitializeComponent()
    at SomeOtherMainDialog..ctor()

Inner exception:

Type: System.Exception Message:  An HRESULT E_FAIL error was returned when calling COM component at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
    at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper obj, DependencyProperty property, DependencyObject doh)
    at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper doh, DependencyProperty property, Object obj)
    at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
    at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isSetByStyle, Boolean isSetByBuiltInStyle)
    at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value)
    at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
    at System.Windows.Controls.Control.set_DefaultStyleKey(Object value)
    at System.Windows.Controls.ContentControl..ctor()
    at System.Windows.CoreTypes.GetCoreWrapper(Int32 typeId)
    at MS.Internal.ManagedPeerTable.EnsureManagedPeer(IntPtr unmanagedPointer, Int32 typeIndex, Type type, Boolean preserveManagedObjectReference)
    at MS.Internal.ManagedPeerTable.EnsureManagedPeer(IntPtr unmanagedPointer, Int32 typeIndex, Type type)
    at MS.Internal.ManagedPeerTable.GetManagedPeer(IntPtr nativeObject)
    at MS.Internal.FrameworkCallbacks.SetPropertyAttribute(IntPtr nativeTarget, String attrName, String attrValue, String attachedDPOwnerNamespace, String attachedDPOwnerAssembly)

Any ideas what's wrong with the control, or what I can do to find the source of these exceptions? As I said, these problem occur only every few dozen times the control is instantiated.

OwnerDisplayName: caryden


问:
CSS Selector issue with list items
I am facing a problem with CSS selector. I have content in "list Items(LI)" and "list Items(LI)" having class"child". I need to style for first "list Items(LI)" with the class name ".child". only in CSS.

ul{margin:0;padding:0 32px 0 32px}
li{ color:red;}
.child{
  color:green;
  background:red;
  width:100%;
}
li.child ~ .child{
  color:#fff;
  font-size:20px;
  background:green;
  width:10px;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><ul>
  <li>hellow</li>
  <li>hellow</li>
  <li>hellow</li>
  <li>hellow</li>
  <li>hellow</li>
  <li>hellow</li>
  <li>hellow</li>
  <li class="child">
This need to be Red Color
  </li>
  <li class="child">sub text</li>
  <li class="child">sub text</li>
  <li class="child">sub text</li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
  <li></li>
</ul></code>```

答:
Update your css rules </p>

```<code>ul{margin:0;padding:0 32px 0 32px}
li{ color:red;}

li.child{
  color:yellow;
  font-size:20px;
}
li.child ~ .child {
    color:green;
}
</code>```

Title: CSS Selector issue with list items

Body:
I am facing a problem with CSS selector. I have content in "list Items(LI)" and "list Items(LI)" having class"child". I need to style for first "list Items(LI)" with the class name ".child". only in CSS.

ul{margin:0;padding:0 32px 0 32px}
li{ color:red;}
.child{
  color:green;
  background:red;
  width:100%;
}
li.child ~ .child{
  color:#fff;
  font-size:20px;
  background:green;
  width:10px;
}

hellow

hellow

hellow

hellow

hellow

hellow

hellow

This need to be Red Color

sub text

sub text

sub text

Body:
Update your css rules

ul{margin:0;padding:0 32px 0 32px}
li{ color:red;}

li.child{
  color:yellow;
  font-size:20px;
}
li.child ~ .child {
    color:green;
}


问:
AnyChart more than one Floating Decimal points
I have create Anychart candlestick with 4 decimal point in Y axis. But It will automatically converted to single decimal point like (1.32444 to 1.3).

The chart source code is

```<code>$rootScope.$on('ReportCandleChartView', function (event, data)
    {
        $rootScope.$apply(function ()
        {

            var dataTable = anychart.data.table();
            dataTable.addData(data);
            var mapping = dataTable.mapAs({'open': 1, 'high': 2, 'low': 3, 'close': 4});
            $rootScope.ch = anychart.stock();
            var plot = $rootScope.ch.plot(0);

            plot.yGrid(true)
                .xGrid(true)
                .yMinorGrid(true)
                .xMinorGrid(true);
            var series = plot.candlestick(mapping);
            series.name($rootScope.globalChartsymbol);
            $rootScope.ch.scroller().candlestick(mapping);
            plot.yAxis().orientation('right');
            var indicator1 = $rootScope.ch.plot(0).priceIndicator();
            indicator1.value('last-visible');
            $rootScope.ch.container('containerxone');
            $rootScope.ch.draw();

        });
    });
</code>```

!https://ibb.co/mZN9YG
I've posted one Image that contain Anystock chart. On that we want to change the decimal point more than one digits.

答:
Put the following line before the chart creating code. It sets numbers of decimal for the whole chart.

```<code>anychart.format.locales.default.numberLocale.decimalsCount = 5;
</code>```

Also, if you want to fill in the remaining decimal places zeros use then the following line:

```<code>anychart.format.locales.default.numberLocale.zeroFillDecimals = true;
</code>```

Body:
I have create Anychart candlestick with 4 decimal point in Y axis. But It will automatically converted to single decimal point like (1.32444 to 1.3).

The chart source code is

$rootScope.$on('ReportCandleChartView', function (event, data)
    {
        $rootScope.$apply(function ()
        {

            var dataTable = anychart.data.table();
            dataTable.addData(data);
            var mapping = dataTable.mapAs({'open': 1, 'high': 2, 'low': 3, 'close': 4});
            $rootScope.ch = anychart.stock();
            var plot = $rootScope.ch.plot(0);

            plot.yGrid(true)
                .xGrid(true)
                .yMinorGrid(true)
                .xMinorGrid(true);
            var series = plot.candlestick(mapping);
            series.name($rootScope.globalChartsymbol);
            $rootScope.ch.scroller().candlestick(mapping);
            plot.yAxis().orientation('right');
            var indicator1 = $rootScope.ch.plot(0).priceIndicator();
            indicator1.value('last-visible');
            $rootScope.ch.container('containerxone');
            $rootScope.ch.draw();

        });
    });

!https://ibb.co/mZN9YG
I've posted one Image that contain Anystock chart. On that we want to change the decimal point more than one digits.

Body:
Put the following line before the chart creating code. It sets numbers of decimal for the whole chart.

anychart.format.locales.default.numberLocale.decimalsCount = 5;

Also, if you want to fill in the remaining decimal places zeros use then the following line:

anychart.format.locales.default.numberLocale.zeroFillDecimals = true;


答:
Problems:

your start date is not parsed to a date so you can't do any operation on it

Then you are adding a string to a integer representing your days to add: '15/11/17' + 3. This is not going to work

Solution:

I highly suggest you give a look at momentJS

```<code>$('#days').change(function() {
  var sta = moment($('#startdate').val(), "MM-DD-YY");
  var sel = parseInt($(this).val());
  $('#fdate').val(sta.add(sel, 'days'));
});
</code>```

Title: Adding days to date jquery or JS

Body:
Problems:

your start date is not parsed to a date so you can't do any operation on it

Then you are adding a string to a integer representing your days to add: '15/11/17' + 3. This is not going to work

Solution:

I highly suggest you give a look at momentJS

$('#days').change(function() {
  var sta = moment($('#startdate').val(), "MM-DD-YY");
  var sel = parseInt($(this).val());
  $('#fdate').val(sta.add(sel, 'days'));
});


问:
Start JMeter thread after another thread
I want to run a thread x times. The thread group contains three samplers and because I dont want them to be mixed up in the result windows I only want to start the next thread when another is finished. I don't want to use a Ramp-Up Period because a thread could take 1 to 20 seconds.</p>

答:
You could use 3 thread groups and module controller (to referencd in the 2 other thread groups the elements in the first one to avoid copy ) and check on test plan the option:

Run Thread Group sequentially


问:
No plugin found for prefix 'docker' in the current project and in the plugin groups
deploy Spring Cloud project with docker, some code in the pom.xml:

```<code><build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <!-- tag::plugin[] -->
        <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>1.0.0</version>
            <configuration>
                <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
                <dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
                <resources>
                    <resource>
                        <targetPath>/</targetPath>
                        <directory>${project.build.directory}</directory>
                        <include>${project.build.finalName}.jar</include>
                    </resource>
                </resources>
            </configuration>
        </plugin>
        <!-- end::plugin[] -->
    </plugins>
</build>
</code>```

when i execute the command: mvn package docker:build, it throws the above errors:

```<code>    Downloaded: http://3.2.4.2:8888/repository/maven-public/org/apache/maven/plugins/maven-metadata.xml (14 KB at 5.7 KB/sec)
    Downloaded: http://3.2.4.2:8888/repository/maven-public/org/codehaus/mojo/maven-metadata.xml (21 KB at 7.3 KB/sec)
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Summary:
    [INFO]
    [INFO] eureka-server ...................................... SUCCESS [ 26.279 s]
    [INFO] service-1 ......................................... SUCCESS [ 14.649 s]
    [INFO] demo1 ........................................... FAILURE [  2.850 s]
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 45.535 s
    [INFO] Finished at: 2017-11-15T14:28:05+08:00
    [INFO] Final Memory: 47M/532M
    [INFO] ------------------------------------------------------------------------
    [ERROR] No plugin found for prefix 'docker' in the current project
and in the plugin groups [org.sonatype.plugins, org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/../Repository), nexus (http://3.2.4.2:8888/repository/maven-public/)]
</code>```

how to solve it?

答:
add the below code to your maven conf/setting.xml：

```<code><pluginGroups>
    <pluginGroup>com.spotify</pluginGroup>
</pluginGroups>
</code>```

if you want to get more detail, pls refer to https://github.com/spotify/docker-maven-plugin/issues/322

Body:
deploy Spring Cloud project with docker, some code in the pom.xml:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>com.spotify</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>1.0.0</version>
            <configuration>
                <imageName>${docker.image.prefix}/${project.artifactId}</imageName>
                <dockerDirectory>${project.basedir}/src/main/docker</dockerDirectory>
                <resources>
                    <resource>
                        <targetPath>/</targetPath>
                        <directory>${project.build.directory}</directory>
                        <include>${project.build.finalName}.jar</include>
                    </resource>
                </resources>
            </configuration>
        </plugin>

    </plugins>
</build>

when i execute the command: mvn package docker:build, it throws the above errors:

    Downloaded: http://3.2.4.2:8888/repository/maven-public/org/apache/maven/plugins/maven-metadata.xml (14 KB at 5.7 KB/sec)
    Downloaded: http://3.2.4.2:8888/repository/maven-public/org/codehaus/mojo/maven-metadata.xml (21 KB at 7.3 KB/sec)
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Summary:
    [INFO]
    [INFO] eureka-server ...................................... SUCCESS [ 26.279 s]
    [INFO] service-1 ......................................... SUCCESS [ 14.649 s]
    [INFO] demo1 ........................................... FAILURE [  2.850 s]
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 45.535 s
    [INFO] Finished at: 2017-11-15T14:28:05+08:00
    [INFO] Final Memory: 47M/532M
    [INFO] ------------------------------------------------------------------------
    [ERROR] No plugin found for prefix 'docker' in the current project
and in the plugin groups [org.sonatype.plugins, org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/../Repository), nexus (http://3.2.4.2:8888/repository/maven-public/)]

how to solve it?

Body:
add the below code to your maven conf/setting.xml：

<pluginGroups>
    <pluginGroup>com.spotify</pluginGroup>
</pluginGroups>

if you want to get more detail, pls refer to https://github.com/spotify/docker-maven-plugin/issues/322


问:
Invoke a method in an Object that was created inside a function
I am confused by this question and not even the JavaScript MDN is clarifying the concept for me.

There is a function called invokeMethod and in that function I have to create an Object. The Object includes a Method. I need to invoke the Method in the Object using bracket notation but nothing needs to be returned.

Here is the Question and my code. I keep getting error messages when I try to call the method in the function parentheses.

Question: method is a string that contains the name of a method on the object
Invoke this method using bracket notation.
Nothing needs to be returned.

Input Example:

```<code>{ foo: function() {} }, 'foo'
</code>```

My code:

```<code>function invokeMethod(object, method) {
  // code here
  const obj = {
    name: 'kung',
    foo: function(){
      console.log('foo');
    }
  };
}

invokeMethod(obj[foo]);
</code>```

答:
Check if this help.

function invokeMethod(object, method) {
  // object definitions
  const obj = {
    name: 'kung',
    foo: function(){
      console.log('foo');
    }
  };

  // conditional invokation
  switch(object){
    case "obj":
      if(typeof obj[method] == "function") return obj[method]();
    default:
      console.log("Given object not found!");
    }
}
// call method
invokeMethod("obj", "foo");```
</div>
</div>
</p>

<p>***If the object itself is to be passed as parameter:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function invokeMethod(object, method) {
 if(typeof object[method] === "function")
  object[method]();
 else
  console.log('Invalid function name!');
  }

  invokeMethod({ foo: function() {console.log('foo');} }, 'foo');</code>```

Body:
I am confused by this question and not even the JavaScript MDN is clarifying the concept for me.

There is a function called invokeMethod and in that function I have to create an Object. The Object includes a Method. I need to invoke the Method in the Object using bracket notation but nothing needs to be returned.

Here is the Question and my code. I keep getting error messages when I try to call the method in the function parentheses.

Question: method is a string that contains the name of a method on the object
Invoke this method using bracket notation.
Nothing needs to be returned.

Input Example:

{ foo: function() {} }, 'foo'

My code:

function invokeMethod(object, method) {
  // code here
  const obj = {
    name: 'kung',
    foo: function(){
      console.log('foo');
    }
  };
}

invokeMethod(obj[foo]);

Body:
Check if this help.

function invokeMethod(object, method) {
  // object definitions
  const obj = {
    name: 'kung',
    foo: function(){
      console.log('foo');
    }
  };

  // conditional invokation
  switch(object){
    case "obj":
      if(typeof obj[method] == "function") return obj[method]();
    default:
      console.log("Given object not found!");
    }
}
// call method
invokeMethod("obj", "foo");

***If the object itself is to be passed as parameter:

function invokeMethod(object, method) {
 if(typeof object[method] === "function")
  object[method]();
 else
  console.log('Invalid function name!');
  }

  invokeMethod({ foo: function() {console.log('foo');} }, 'foo');


问:
How can I have a custom 404 page using Middleman?
I have followed all documentation guides, so I have the following line in my config.rb

```<code>page '/404.html', directory_index: false
</code>```

Also, I have a source/404.html.erb page. I'm not sure what I'm I doing wrong, I am only able to see the File not found error page generated by default.
Thanks

答:
I managed to solve the problem, what I did was:

In my Config.rb

I left this at global level **page '/404.html'**, layout: 'error'

Removed this activate :relative_assets

In production and staging blocks I modified  error document to s3_sync.error_document = '404/index.html', this was the cause why I was losing my assets as once the site has been deployed 404.html does not exist anymore, I was pointing to the wrong error_document

I created a separate layout called error as suggested on this thread for my 404 page.

I am using

'middleman', '~> 4.1', '>= 4.1.10'

'middleman-s3_sync', '~> 4.0', '>= 4.0.2'

"webpack": "~3.5.5"

Hope this help somebody else in the same issue.

Check this Middleman blog if you want to see the whole thread.

Body:
I have followed all documentation guides, so I have the following line in my config.rb

page '/404.html', directory_index: false

Also, I have a source/404.html.erb page. I'm not sure what I'm I doing wrong, I am only able to see the File not found error page generated by default.
Thanks


问:
ASP.NET MVC2 - passing a parameter to a controller
This is for a project I'm doing in the university. We're using ASP.NET MVC2 to build a mini-prototype of a website just to show what we can do.

Now, I have a controller called ItemController.cs, a view Item/Index.aspx, a model Item.cs and a ViewModel ViewItems.cs. I use the ViewModel to pass information to the view from the controller. My question is - how do I call a controller method with parameters? Currently, I use

```<code>Html.ActionLink("View Event Items", "Index", "Item")
</code>```

which points to ItemController's Index() method. Say I want it to take an int parameter (Index(int eventId)) How would I write the ActionLink to pass the parameter to it?

Also, if I have any errors in how I think this stuff works, please feel free to point them out.

答:
You'll need to use the routevalues object (or RouteValuesDictionary) to pass values to your action.
In your example it would look like this:</p>

```<code>Html.ActionLink("View Event Items", "Index", "Item", new { eventId = 1}, new {})
</code>```

<p>...where 2 is your event id. The second empty object (new {}) is for html attributes. Nate's answer is close, but I don't think there is an overload that takes a routevalues object as the second parameter. </p>

Body:
This is for a project I'm doing in the university. We're using ASP.NET MVC2 to build a mini-prototype of a website just to show what we can do.

Now, I have a controller called ItemController.cs, a view Item/Index.aspx, a model Item.cs and a ViewModel ViewItems.cs. I use the ViewModel to pass information to the view from the controller. My question is - how do I call a controller method with parameters? Currently, I use

Html.ActionLink("View Event Items", "Index", "Item")

which points to ItemController's Index() method. Say I want it to take an int parameter (Index(int eventId)) How would I write the ActionLink to pass the parameter to it?

Also, if I have any errors in how I think this stuff works, please feel free to point them out.

Body:
You'll need to use the routevalues object (or RouteValuesDictionary) to pass values to your action.
In your example it would look like this:

Html.ActionLink("View Event Items", "Index", "Item", new { eventId = 1}, new {})

...where 2 is your event id. The second empty object (new {}) is for html attributes. Nate's answer is close, but I don't think there is an overload that takes a routevalues object as the second parameter.


问:
Ran MrBayes on cluster, but cannot find .con.tre file?
I am new leaner about phylogeny. currently i ran MrBayes on cluster with whole mtDNA from 101 species.
Phylogenetic analysis were carried out twice separately, once with the third codon position, once were not. InvGAMMA mode for both analysis.
The strange thing is i can get ".con.tre" file with the third codon position input file, but cannot with non-third codon position input file.
i v ran the analysis twice, but still could not get the .con.tre file.
does anyone know why?
here is my .nex file</p>

```<code>#NEXUS
begin taxa;
dimensions ntax=101;
taxlabels
Ancistrotermes_pakistanicus_Thailand
Blatella_germanica
......
end;

begin characters;
    dimensions nchar=16305;
    format datatype=dna missing=? gap=-;
    matrix
    Ancistrotermes_pakistanicus_Thailand  AAGGAGTTTTATTCTTGC-TT-T...
    ......
;
end;

begin mrbayes;

CHARSET rna12-16S = 1-3141;
CHARSET tRNA = 3142-4875;
CHARSET coding_first = 4876-12495\2;
CHARSET coding_second = 4877-12495\2;

partition favored = 4: rna12-16S, tRNA, coding_first, coding_second;

set partition = favored;

set autoclose=yes nowarn=yes;

lset applyto=(1,2,3,4) nst=6 rates=invgamma;

unlink statefreq=(all) revmat=(all) shape=(all) pinvar=(all);

prset applyto=(all) ratepr=variable;

mcmcp ngen= 10000000 relburnin=yes burninfrac=0.1  printfreq=5000
samplefreq=5000 nchains=4 savebrlens=yes;

mcmc;

sumt;

end;

#My script on cluster.
#!/bin/bash
#SBATCH --job-name=MrBayes
#SBATCH --partition=compute
#SBATCH --time=6-23
#SBATCH --mem-per-cpu=15G
#SBATCH --ntasks=4
#SBATCH --cpus-per-task=8
#SBATCH --mail-type=BEGIN,FAIL,END
export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
module load MrBayes.mpi/3.2.3
srun --mpi=pmi2 mb -i test_mrbayes
</code>```

答:
First of all, a note that does not pertain to the problem directly. The current CHARSET command calls every other base, but a codon is 3 bp long. To sample every first and second codon position, the code must read:

```<code>CHARSET coding_first = 4876-12495\3;
CHARSET coding_second = 4877-12495\3;
</code>```

The analysis must be repeated with the changed partition setting.

The SUMT command seems fine and should have summarised the result. To run the summary on a desktop computer, comment the mcmc command and execute the nexus file again. The folder from where you will execute the commands should include the results sampled trees in the *.t files.

```<code>[all the code above deleted for clarity of the change]
mcmcp ngen= 10000000 relburnin=yes burninfrac=0.1  printfreq=5000
samplefreq=5000 nchains=4 savebrlens=yes;

[mcmc;]

sumt;

end;
</code>```

Body:
I am new leaner about phylogeny. currently i ran MrBayes on cluster with whole mtDNA from 101 species.
Phylogenetic analysis were carried out twice separately, once with the third codon position, once were not. InvGAMMA mode for both analysis.
The strange thing is i can get ".con.tre" file with the third codon position input file, but cannot with non-third codon position input file.
i v ran the analysis twice, but still could not get the .con.tre file.
does anyone know why?
here is my .nex file

#NEXUS
begin taxa;
dimensions ntax=101;
taxlabels
Ancistrotermes_pakistanicus_Thailand
Blatella_germanica
......
end;

begin characters;
    dimensions nchar=16305;
    format datatype=dna missing=? gap=-;
    matrix
    Ancistrotermes_pakistanicus_Thailand  AAGGAGTTTTATTCTTGC-TT-T...
    ......
;
end;

begin mrbayes;

CHARSET rna12-16S = 1-3141;
CHARSET tRNA = 3142-4875;
CHARSET coding_first = 4876-12495\2;
CHARSET coding_second = 4877-12495\2;

partition favored = 4: rna12-16S, tRNA, coding_first, coding_second;

set partition = favored;

set autoclose=yes nowarn=yes;

lset applyto=(1,2,3,4) nst=6 rates=invgamma;

unlink statefreq=(all) revmat=(all) shape=(all) pinvar=(all);

prset applyto=(all) ratepr=variable;

mcmcp ngen= 10000000 relburnin=yes burninfrac=0.1  printfreq=5000
samplefreq=5000 nchains=4 savebrlens=yes;

mcmc;

sumt;

end;

#My script on cluster.
#!/bin/bash
#SBATCH --job-name=MrBayes
#SBATCH --partition=compute
#SBATCH --time=6-23
#SBATCH --mem-per-cpu=15G
#SBATCH --ntasks=4
#SBATCH --cpus-per-task=8
#SBATCH --mail-type=BEGIN,FAIL,END
export OMP_NUM_THREADS=$SLURM_CPUS_PER_TASK
module load MrBayes.mpi/3.2.3
srun --mpi=pmi2 mb -i test_mrbayes

Body:
First of all, a note that does not pertain to the problem directly. The current CHARSET command calls every other base, but a codon is 3 bp long. To sample every first and second codon position, the code must read:

CHARSET coding_first = 4876-12495\3;
CHARSET coding_second = 4877-12495\3;

The analysis must be repeated with the changed partition setting.

The SUMT command seems fine and should have summarised the result. To run the summary on a desktop computer, comment the mcmc command and execute the nexus file again. The folder from where you will execute the commands should include the results sampled trees in the *.t files.

[all the code above deleted for clarity of the change]
mcmcp ngen= 10000000 relburnin=yes burninfrac=0.1  printfreq=5000
samplefreq=5000 nchains=4 savebrlens=yes;

[mcmc;]

sumt;

end;


问:
Goutte - Get table column
how can I get just one column not whole table?

```<code><table cellspacing="0" cellpadding="0" align="Center" rules="all" border="1">
    <tbody>
    <tr>
        <td>Entity Name</td>
        <td>NV Business ID</td>
        <td>Status</td>
        <td>Type</td>
    </tr>
    <tr>
        <td><a href="">GOOGLE</a></td>
        <td><a href=""></a></td>
        <td><a href="">Expired</a></td>
        <td><a href="">Reserved Name</a></td>
    </tr>
    <tr>
        <td><a href="">GOOGLE INC.</a></td>
        <td><a href="">NV20161275322</a></td>
        <td><a href="">Active</a></td>
        <td><a href="">Foreign Corporation</a>
        </td>
    </tr>
    </tbody>
</table>
</code>```

Here is my try:

```<code>        $client = new Client();
        $crawler = $client->request('GET', 'url');
        $form = $crawler->selectButton('Search')->form();
        $crawler = $client->submit($form, array(
            ...
        ));
        $crawler->filter('table tr')->each(function ($node) {
            print $node->text()."\n \n";
//            print $node->filter('td')->text() . '<br />';
        });
</code>```

It's always returning whole table.
Also tried stn like tr[1], etc..

Can someone help please?

Thanks

答:
Try the below code:</p>

```<code>$content  = $crawler->filter( 'table' )->extract( array( '_text' ) );
</code>```

Title: Goutte - Get table column

Body:
how can I get just one column not whole table?

        Entity Name
        NV Business ID
        Status
        Type

        GOOGLE

        Expired
        Reserved Name

        GOOGLE INC.
        NV20161275322
        Active
        Foreign Corporation

Here is my try:

        $client = new Client();
        $crawler = $client->request('GET', 'url');
        $form = $crawler->selectButton('Search')->form();
        $crawler = $client->submit($form, array(
            ...
        ));
        $crawler->filter('table tr')->each(function ($node) {
            print $node->text()."\n \n";
//            print $node->filter('td')->text() . '
';
        });

It's always returning whole table.
Also tried stn like tr[1], etc..

Can someone help please?

Thanks

Body:
Try the below code:

$content  = $crawler->filter( 'table' )->extract( array( '_text' ) );