Framework recommendation for web admin panels [on hold]

Most of the time I see myself making an admin panel for content management, alongside the Mobile or Web App whose content will be managed (like a e-shop or something else).

For this, I use PHP, HTML5 and JS. I’ve recently added a Babel transpiler to make things easier on the frontend, but if you look at the big picture, it isn’t such a huge leap in development speed.

I’d like to know if there’s something that’s much better, faster and easier to maintain, and less cumbersome (since there is quite a lot of JavaScript) for this kind of development, where there’s a lot of content population (the ‘getters’) and a lot of AJAX requests for saving or deleting. (the ‘setters’).

Obtener último registro de BBDD con Entity Framework en C#

Me encuentro rellenando los campos de una tabla con datos que he recogido de un excel, uno de los campos es ID_C, el cual quiero rellenar obteniendo el último ID_Cregistrado en BBDD y sumarle uno, esto lo quiero hacer en mi código de C#.

No sé como puedo obtener el número del último ID_Cpara poder sumarle uno y que el nuevo registro se guarde con ese resultado.

 public bool AddCust(List<REGISTRO_CARGA> listaDoc)     {         bool ok = false;          using (ABCEntities contexto = new ABCEntities())         {             using (var transaction = contexto.Database.BeginTransaction(IsolationLevel.Serializable))             {                 try                 {                     REGISTRO_CARGA newdoc;                      foreach (REGISTRO_CARGA d in listaDoc)                     {                         newdoc = new REGISTRO_CARGA_()                         {                             LOCALIZACION = d.LOCALIZACION,                             UBICACION = d.UBICACION,                             USUARIO = d.USUARIO,                             //ID_C= d.ID_C                          };                          contexto.REGISTRO_CARGA.Add(newdoc);                      }                     contexto.SaveChanges();                      //falta hacer BACKUP BBDD                     foreach (REGISTRO_CARGA) ;                          contexto.SaveChanges();                      transaction.Commit();                     ok = true;                  }                  catch (Exception ex)                 {                     eLog.RegistrarError(ex);                     transaction.Rollback();                     ok = false;                 }              }           } 

Scaled Agile Framework, PI Planning & Iteration Plans [on hold]

A read of the SAFe PI Planning documentation starts strong with clarifying that PI Planning produces milestones, features and dependencies and places these on the program board. In contrast, “Iteration Plans” or user stories are not listed as an output of PI Planning.

However, towards the end of that same link it makes a passing comment of when PI Planning completes the teams “take PI objectives, iteration plans, and risks back to their regular work area.” Furthermore, the SAFe documentation for Iteration Planning makes the following comment:

In SAFe, iteration planning is a refinement of the level of detail and an adjustment of the initial iteration plans created during Agile Release Train (ART) PI planning.

This SAFe commentary is much too thin to draw conclusions about what was the activity and what was the goal of creating iteration plans during PI Planning.

My interpretation is that any team might create loose iteration plans during PI Planning, but only with the goal of estimating when they will complete a given feature(s). In other words, such loose iteration planning (if it happened at all) is a team-internal scratch-pad that would not be evaluated or published. Accordingly the program board would not be decorated with user stories that result from such loose iteration planning (and in general the program board simply does not have user stories on it).

In my interpretation, no agile coach would tell my team “your scratch-pad iteration plans are insufficient, you must create more.”

In contrast, I recently encountered an organization whose interpretation of SAFe is as follows:

  • SAFe PI Planning requires or expects the activity of Iteration Planning that intentionally covers each and every sprint of the upcoming Program Increment (which is 3 months in their case).
  • The user stories that are created from this comprehensive whole-PI “Iteration Planning,” are placed onto the program board (as a backbone of creating dependencies with features, etcetera).
  • At the end of PI Planning, if the entire Program Increment does not have end-to-end Iteration Plans established for a given team, then that misaligned team must ASAP finish a full suite of Iteration Plans for the entire PI.

In this latter view, subsequent sprint planning for each iteration involves merely making adjustments to the sprints if needed – because otherwise all sprints of the PI have already been planned.

Please note that the above bulleted premises are not seen as customizations of SAFe, but rather they believe it represents the authentic interpretation of SAFe.

I’d like to know if SAFe provides any additional guidance that would clarify which interpretation is “correct.” To me, which interpretation is chosen is a choice between genuinely following an Agile methodology versus following a practice that is half-way waterfall. However, my question is not “what do you prefer,” as what I’m really after is a more official or authentic interpretation of SAFe on this matter.


Best practice for transaction handling using Entity Framework

I am developing an app which uses Entity Framework for data access. The architecture of the app somewhat like below:

enter image description here

As depicted in the drawing, the business service can be consumed from either web app, cli app or windows service. What I’m trying to design is, each service request should be performed in a single transaction. I’m using dependency injection to inject services to web api controllers. If I use request scoped dbcontext using DI container, it’ll do the job for web api, but won’t work for service requests coming directly from CLI app or windows services.

What are best practices used to handle service level transactions with Entity Framework?


// Services public class UserService {     private TaskService _taskService;     private UserRepository _userRepository;      public UserService(TaskService taskService, UserRepository userRepository)     {         this._taskService = taskService;         this._userRepository = userRepository;     }      public void MarkInactive(int userId)     {         this._taskService.CloseAllPendingTasks(userId);         this._userRepository.MarkInactive(userId);     } }  public class TaskService {     public void CloseAllPendingTasks(int userId)     {         ...     } }  // Consumer // Scenario 1: this._taskService.CloseAllPendingTasks(1);  // Scenario 2: this._userService.MarkInactive(2); 

In above example, In case of Scenario 1, task service should create new transaction for the operation. While in Scenario 2, user service should create a transaction and task service should join the already open transaction.

Entity Framework C# updating an entity list generic solution

I have an entity which has a list of other entities in it.

for example:

class Library {    public virtual List<Book> Books{get;set;} } 

And I would like to update the entity and also the list of entities inside.

I came up with this solution:

private void UpdateChild<T>(DbSet<T> dbset, ICollection<T> existingItems, ICollection<T> newItems, Func<T, T, bool> isEqual) where T : class {     dbset.RemoveRange(existingItems);      foreach (var newItem in newItems)     {         T oldItem = existingItems.FirstOrDefault(x => isEqual(newItem, x));          if (null != oldItem)         {             oldItem = newItem;              dbset.Update(oldItem);         }         else         {             dbset.Add(newItem);         }     } } 

But I am not sure if this solution is a good approach.

Clean Architecture and Entity Framework

I faced few problems when generating database schema from business objects with EF Core:

  • No support for struct properties
  • No support for interface properties
  • I need additional columns that should belong to Data layer only.

I don’t want to change my business layer (structs/interfaces to classes) just because of EF as this goes against clean architecture principles (framework should serve your application not the other way around). Also adding persistence specific columns to the business layer is out of question.

I suppose the right thing to do is to add persistence objects to persistence layer which would represent entities in the business layer. On top of that some mappers would have to be used by business layer to abstract persistence objects mapping them to the business entities.

Few question about this approach:

  • Is this a correct thing to do? Are there any alternatives? For example: EF configuration capabilities that would help me to deal with the issues listed above without replicating entities in the persistence layer?
  • This feels like a lot of boilerplate code and replication of same properties. Seems like this code could be auto-generated by some tool, does something like this exist?
  • Is there a good example of how such approach should look?

Entity Framework Core – may cause cycles or multiple cascade paths error

I was creating some models and this error appeared while i was configuring fluent API and added migration. I don’t understand why it tells me this when i set DeleteBehaviour.Restrict ?

public class Registo {     public int CelulaId { get; set; }     public Celula Celula { get; set; }      public int ReferenciaId { get; set; }     public Referencia Referencia { get; set; }      public ICollection<ComponenteArranque> Componentes { get; set; }     public ICollection<RegistoGeometria> RegistosGeometria { get; set; } }  [Table("hGeometrias")] public class Geometria {     public int Id { get; set; }     public string Referencia { get; set; }     public int MatrizCelulaReferenciaId { get; set; }     public MatrizCelulaReferencia Matriz { get; set; }      public ICollection<RegistoGeometria> RegistosGeometria { get; set; } }  [Table("hRegistosGeomtrias")] public class RegistoGeometria {     public int Id { get; set; }      public float X1 { get; set; }     public float X2 { get; set; }     public float X3 { get; set; }     public float X4 { get; set; }      public int RegistoId { get; set; }     public Registo Registo { get; set; }      public int GeometriaId { get; set; }     public Geometria Geometria { get; set; } } 

fluet api

   modelBuilder.Entity<RegistoGeometria>()             .HasOne(rg => rg.Registo)             .WithMany(r => r.RegistosGeometria)             .OnDelete(DeleteBehavior.Restrict); 

Introducing FOREIGN KEY constraint ‘FK_hRegistosGeomtrias_hRegistos_RegistoId’ on table ‘hRegistosGeomtrias’ may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. Could not create constraint or index. See previous errors.

Integrating Django Rest Framework and Scrapy

Both Scrapy and Django Frameworks are standalone best framework of Python to build crawler and web applications with less code, Though still whenever You want to create a spider you always have to generate new code file and have to write same piece of code(though with some variation.) I was trying to integrate both. But stuck at a place where i need to send the status 200_OK that spider run successfully, and at the same time spider keep running and when it finish off it save data to database.

Though i know the API are already available with scrapyd. But i Wanted to make it more versatile. That lets you create crawler without writing multiple file. I thought The Crawlrunner would help in this,therefor try this thing also t Easiest way to run scrapy crawler so it doesn't block the script but it give me error that the builtins.ValueError: signal only works in main thread

Even though I get the response back from the Rest Framework. But Crawler failed to run due to this error does that mean i need to switch to main thread? I am doing this with a simple piece of code

spider = GeneralSpider(pk) runner = CrawlerRunner() d = runner.crawl(GeneralSpider, pk) d.addBoth(lambda _: reactor.stop()) 

Fazer uma consultar com base externa no Zend Framework


  public function excluirFiliadosNaoEnviados($  base) {          $  sql = "SELECT FROM " . $  base . ".debito_automatico";       $  acao = $  this->conexao->prepare($  sql);         if($  acao->execute()){         return true;       }else{         return false;       }    } 


public function prepararfiliadosAction() {      $  base = DATABASE_GERAL;       if($  this->repositorio->excluirFiliadosNaoEnviados($  base)) {         echo $  this->repositorio->prepararFiliados($  this->getMesCompetencia()) ? 'true' : 'false';     }      $  this->_helper->layout->disableLayout();     $  this->_helper->viewRenderer->setNoRender(TRUE); } 

A consulta não esta funcionando sempre retornando false.

Mais de uma rota de método get sem parâmetros no mesmo controller no entity framework

Tenho um controller EmpresaController, nele possuo as duas rotas de get: uma que lista todas as empresas e outra que lista uma determinada empresa:


Preciso criar uma api que liste os funcionários de uma empresa, para isso, eu deveria criar um novo controller EmpresaFuncionarioController ou tem alguma forma de fazer essa chamada dentro do meu EmpresaController?