I have the following problem... on a server I have a project and it is in a Bitbucket repository.
If I dogit shortlog -sn
I list:
36 root
4 Mi User
I need to add another authorized user from Bitbucker for you to do commits and push
I have the following problem... on a server I have a project and it is in a Bitbucket repository.
If I dogit shortlog -sn
I list:
36 root
4 Mi User
I need to add another authorized user from Bitbucker for you to do commits and push
I have a FormArray
that is composed of FormGroup
with the following structure:
let formGroup: FormGroup = this.fb.group({
checked: this.fb.control(false),
id_lista: this.fb.control(element.id_lista[0]),
nombre: this.fb.control(element.nombre),
codigoInterno: this.fb.control(element.codigo_interno),
porcentaje_original: this.fb.control({ value: element.porcentaje_revision, disabled: true }),
porcentaje: this.fb.control(element.porcentaje_revision, [Validators.min(10), Validators.max(100)]),
auditoria_original: this.fb.control({ value: element.porcentaje_auditoria, disabled: true }),
auditoria: this.fb.control(element.porcentaje_auditoria, [Validators.min(10), Validators.max(100)]),
});
And I show them in the HTML like this:
<tr *ngFor="let saleList of salesListArray.controls [formGroupName]="index">
<td>
<input type="checkbox" formControlName="checked" (change)="onChange(saleList, $event.target.checked)">
</td>
....
</tr>
Try to do a Filter
:
@Pipe({ name: 'filter' })
export class FilterPipe implements PipeTransform {
public transform(values: any[], filter: string): any[] {
if (!values || !values.length) return [];
if (!filter) return values;
return values.filter(v => v.value.nombre.indexOf(filter) >= 0);
}
}
However, it returns me the filtered items but without values, only the FormGroup
.
UPDATE
Dear, I found the error, apparently by not having an index within ngFor
it, the data was lost and that is why they did not load.
<tr *ngFor="let saleList of salesListArray.controls | filter: searchText; let i=index;" [formGroupName]="i">
I am working with Angular2 and I have a simple form:
<div class='col-12'>
<div class="form-group">
<label class="form-control-label" for="nombre">Nombre</label>
<input class="form-control input-md" placeholder="Ingresar nombre identificador de la Lista" #nombre="ngModel" required id="nombre" name="nombre" type="text" [(ngModel)]="lista.nombre">
<small class="form-text text-muted danger" *ngIf="send && lista.nombre === ''">Debe ingresar un nombre para la Lista de Chequeo</small>
</div>
</div>
In the component I have an object of the typeLista
export class ListaChequeoEditComponent implements OnInit {
title = 'Lista de Chequeo';
lista: Lista;
id_lista: any;
constructor(private router: Router,
private route: ActivatedRoute, private formDataService: FormDataService,
private workflowService: WorkflowService, public partidaService: PartidasServiceService, public ubicacionService: UbicacionService,
public listaService: ListaService) {
}
obtenerLista(){
this.route.queryParams.subscribe(params => {
this.id_lista = params["id_lista"];
this.listaService.getLista({id_lista: this.id_lista}).subscribe(
result => {
var objLista = new Lista(
result[0].nombre
);
this.lista = objLista;
}, error => {
this.loading = false;
console.log(error);
});
});
}
ngOnInit() {
this.obtenerLista();
}
}
Model:
export class Lista {
nombre: string = '';
constructor(nombre: string){
this.nombre = nombre;
}
}
I get from the call to an api the values of an object and try to set them:
this.lista.nombre = 'Nuevo Nombre';
But I get the error
ERROR TypeError: Cannot read property 'name' of undefined
EDITION
I implemented Pablo's solution, but it still doesn't work.
Builder:
constructor(private router: Router,
private route: ActivatedRoute, private formDataService: FormDataService,
private workflowService: WorkflowService, public partidaService: PartidasServiceService, public ubicacionService: UbicacionService,
public listaService: ListaService) {
this.lista = new Lista();
}
ngOnInit
ngOnInit() {
this.obtenerLista();
}
obtenerLista(){
this.route.queryParams.subscribe(params => {
this.id_lista = params["id_lista"];
this.listaService.getLista({id_lista: this.id_lista}).subscribe(
result => {
var objLista = new Lista();
objLista.nombre = result[0].nombre
this.lista = objLista;
console.log(this.lista);
}, error => {
this.loading = false;
console.log(error);
});
});
}
The value of this.lista
if it is updated, I check it by printing, but in the DOM the data is not updated.
I'm working with NodeJS, I create a Array
and then I make a query to my database. When I get results, I do push
to add elements to the array, however when I want to print the elements there is nothing.
function sendMessageToUser(req, res) {
var devicesTokenNotification = new Array();
req.getConnection(function(err,connection){
var query = connection.query('SELECT usuario_id, PERIOD_DIFF(DATE_FORMAT(created, "%Y%m"), DATE_FORMAT(NOW(), "%Y%m")) as meses FROM documento', [], function(err, rows){
if(err)
console.log("Error Selecting : %s ",err );
if (rows.length > 0) {
for (var i = 0; i < rows.length; i++) {
if (rows[i].meses > 7){
var queryUsuarios = connection.query('SELECT deviceToken from usuario where id = ?', [rows[i].usuario_id], function(err, row){
if(err)
console.log("Error Selecting : %s ",err );
devicesTokenNotification.push(row[0].deviceToken);
});
}
}
}
for (var cont = 0; cont < devicesTokenNotification.length; cont++) {
console.log(devicesTokenNotification[cont]);
}
});
});
};
However, if I apply the same for
but inside the query queryUsuarios
if it prints the values.
I have the following regular expression
/^(([^<>()\[\]\.,;:\s@\"]+(\.[^<>()\[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i
To validate emails, I must also validate that the email does not contain the word "does not have" and the expression is /^((?!notiene).)*$
, however I cannot mix the two.
To my bad luck, an API that we use in a project, returns the dates with the string format 211119
, taking into account that this date is 2021/11/19
I would like to be able to create an object Date
and be able to compare it with another... obviously the first thing I try is to apply a slice
, create the date but I believe the date 1921/11/19
.
var fecha = '211119';
var anio = fecha.slice(0, 2);
var mes = parseInt(fecha.slice(2, 4));
var dia = fecha.slice(4, 6);
console.log(moment(new Date(anio, mes - 1 , dia)).format('DD/MM/YYYY'))
<script src="https://momentjs.com/downloads/moment.js"></script>
Output:
1921/11/19
I am developing my web app with angularjs, previously I work with angularjs in Ionic. In mobile applications I used an encryption plugin that prevented me from seeing the source code and with that I passed security. However, this time I am in a web development with angularjs and only with "View source", I can access constants, controllers, etc etc.
My question is the following: How can I add security to my application files?
I found a regular expression that works for a particular case: an input that can receive all kinds of accents and also a hyphen, and prevents any other signs inside the input.
However, I don't really understand why it is defined like this. I don't want to copy and paste something that I don't understand why it works for me. I don't know if it applies to a question, but I ask it anyway.
/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/
I need to check if a number is greater than 50,000,000, but I want to avoid the typical:
if (numero > 50000000) {
//....
}
Is there a way to check it with "regex", or another way?
I have a Model called Question :
public class Pregunta
{
public int id { get; set; }
public string descripcion { get; set; }
public int peso_id { get; set; }
public List<int> roles_id { get; set; }
public int dimension_id { get; set; }
public int amsa_id { get; set; }
public int modelo_operativo_id { get; set; }
public List<Alternativa> alternativas { get; set; }
}
and the alternative model
public class Alternativa
{
public int id { get; set; }
public string descripcion { get; set; }
public int pregunta_id { get; set; }
public int maduracion_id { get; set; }
}
By business rule one Pregunta
can have 1 or many alternatives (5 is the limit) and I need to create form of alternatives depending on the value that the user selects in an element<select>
<div class="form-group">
<label class="control-label col-md-2">Cantidad de Alternativas</label>
<div class="col-md-10">
<select class="form-control" id="cantidad_alternativas">
<option value="0" selected>Seleccione cantidad</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
</div>
To test I did the following:
@for (int i = 0; i < 5; i++)
{
<div class="form-group">
@Html.LabelFor(model => model.alternativas[i].descripcion, "Descripcion", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.alternativas[i].descripcion, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.alternativas[i].descripcion, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.alternativas[i].maduracion_id, "Maduracion", htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.alternativas[i].maduracion_id, (SelectList)ViewBag.Maduraciones, "Seleccione Maduracion", htmlAttributes: new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.alternativas[i].maduracion_id, "", new { @class = "text-danger" })
</div>
</div>
}
problem 1
How can I delimit the end of the for loop, with the value that the user selects in the
<select>
I am trying to get to be able to do a format for a list that will be generated by a ng-repeat
. I want to get something like this (Before hand I apologize for my lousy design, I'm lousy at css xD)
Where those circles will be user images that I already have so I have no problem.
The thing is, I got this:
<div style="width: 40px;height: 40px;background-color: red;float: left;margin-left: 15px;">
</div>
<div style="width: 40px;height: 40px;background-color: blue;float: left;margin-top: 25px;z-index: 1000;margin-left: -15px;">
</div>
<div style="width: 40px;height: 40px;background-color: red;float:right;margin-right: 15px;">
</div>
<div style="width: 40px;height: 40px;background-color: blue;float: right;margin-top: 25px;z-index: 1000;margin-right: -15px;">
</div>
I have not been able to put the text next to each div.
I have developed a service with C# that queries a database with certain functions.
I moved from AngularJS to Angular2 and here came my problems.
Inside my WCF I have:
[OperationContract]
[WebInvoke(UriTemplate = "/GetCaptaciones", Method = "POST", ResponseFormat = WebMessageFormat.Json, RequestFormat=WebMessageFormat.Json , BodyStyle = WebMessageBodyStyle.Wrapped)]
List<Captacion> GetCaptaciones(int id_captador)
From Angular2 I am making the call to this method like this:
let data = JSON.stringify({ id_captador: 11 });
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({ headers: headers });
this.http.post(url + "/GetCaptaciones", data, options).subscribe(data => {
console.log(data);
});
But I am getting the error that the input data is not correct. It receives data Raw
while the data it expects is JSON
. However, if I copy it in Postman JSON
and send it, everything works correctly.
NetWork tab data
Response Header
Access-Control-Allow-Headers:Accept, Content-Type, Origin
Access-Control-Allow-Methods:GET, PUT, POST, DELETE, OPTIONS
Access-Control-Allow-Origin:*
Allow:POST
Cache-Control:private
Content-Type:text/html; charset=UTF-8
Date:Thu, 27 Apr 2017 21:45:34 GMT
Server:Microsoft-IIS/7.0
Transfer-Encoding:chunked
X-AspNet-Version:4.0.30319
Request Header
Accept:'*/*'
Accept-Encoding:gzip, deflate, sdch
Accept-Language:es-ES,es;q=0.8
Access-Control-Request-Headers:content-type
Access-Control-Request-Method:POST
Connection:keep-alive
Host:XXXXXXX
Origin:http://localhost:8100
Referer:http://localhost:8100/
User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
I have developed a mobile app with Ionic v1 . In one of the modules or sections that my app has, I show user data, such as name , email , telephone and also the IMAGE . The image is saved on my server, my WebService receives the file from the mobile app and saves it.
When I select all users to display on the mobile app the JSON
one I submitted has the format of the object plus the base64 encoded image . I tried with 10 or 15 users without any problem but today we went to the QA phase, with around 100 users and there my server collapsed. I think I understand that it is for so many characters that my function returns since the image comes in base64 code .
My webservice is created in WCF framework 4.0 with C# , in the web config I have the following:
<bindings>
<webHttpBinding>
<binding name="LargeWsHttp" maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647"
transferMode="Streamed"
sendTimeout="00:05:00">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647"/>
<security mode="None" />
</binding>
</webHttpBinding>
</bindings>
For the matter of sending and receiving data. But obviously you must exceed this limit. My query is: What is the best option for the treatment of images?
I thought :
Send the URL of the image and display it in the application, the problem is that the app can also work offline.
Download the image from the mobile app and save it to the app. Here I don't know if it saves as a file or in the app's local database to save it with the base64 code . This download would be done by obtaining the URL of the file.
Users can increase, it can be 500, 1000, 2000 since it is an application that will be very popular within a community of a specific sport.
I receive help and constructive criticism, in order to improve my product.
Anything you need, code, explanations of the flows etc, I will provide.
I am creating an app with angularjs and Ionic. I have some type number inputs but on the android device, the keyboard that presents me is with the option to add a period (.) and it is not what I need.
I tried :
if (
($.inArray(e.keyCode, [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 8, 13, 190, 189]) == -1) // digits, digits in num pad, 'back', 'enter', '.', '-'
|| (e.keyCode == 190 && $(e.target).val().indexOf(".") != -1) // not allow double dot '.'
|| (e.keyCode == 190 && $(e.target).val().length == 0) // not allow dot '.' at the begining
) {
e.preventDefault();
}
Also
text = text.replace('.', '');
Also
<input type="number" pattern="[0-9]*" ng-model="nuevo_cliente.numero_nueva_direccion" placeholder="Número">
All this within the event keyup
without any result. I can't remove the dot from the value.
$(':input[type="number"]').on('keyup', function(e) {
var model = $(this).attr('ng-model');
var myRegex = /^[0-9]\d*$/;
var text = $(this).val();
if (
($.inArray(e.keyCode, [48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 8, 13, 190, 189]) == -1) // digits, digits in num pad, 'back', 'enter', '.', '-'
|| (e.keyCode == 190 && $(e.target).val().indexOf(".") != -1) // not allow double dot '.'
|| (e.keyCode == 190 && $(e.target).val().length == 0) // not allow dot '.' at the begining
) {
e.preventDefault();
}
if (myRegex.test(text)) {
console.log("fdsf");
text = removeDiacritics(text);
text = text.replace('_', '');
text = text.replace('-', '');
text = text.replace('.', '');
text = text.replace(/[^\w\s]/gi, '');
}
$scope.$apply();
});
I work in a branch called master2
, the thing is that I made small changes in 1 file and when I tried to upload them, I made a mistake and git pull origin master
when push
I did, almost all the files in the repository with conflict appeared, I tried to solve them but there was no case. I need to go back to the latest stable version of the repository or if it is possible, revert the changes or delete thecommits
EDITION
There are 4 commits after the one you want to go back, can you go back 4 commits before?
I am trying to make one SELECT
that brings me all the records that are between two dates. However, I want to ignore the time (hours, minutes, seconds, etc...). For example, I have a record that has 2016-11-14 11:47:56.207
, but I send by parameter to my stored procedure
only 14-11-2016
. If I send it like this, I get no result.
WHERE GRP.GRP_Fecha BETWEEN @desde AND @hasta
I have a service developed with WCF
, in this service I call a stored procedure
, it returns 4 fields: id
, id_visita
, fecha
, observaciones
. It may be the case that the field id_visita
is null and this is because the corresponding visit has not been made, therefore the value fecha
is from a day before today and the field observaciones
is also null.
In my service I do the following:
int gestion_ruta_visita_id = Convert.ToInt32(dr["id_visita"]);
if (gestion_ruta_visita_id != 0)
{
//Si es que ya fue visitada, obtener detalles de la visita
gestionRuta.estado = 1;
gestionRuta.gestion_ruta_visita_fecha = Convert.ToDateTime(dr["fecha"]).ToString("dd-MM-yyyy HH:mm");
gestionRuta.gestion_ruta_visita_observaciones = Convert.ToString(dr["observaciones"]);
}
In this code I obtain whether or not it has the id_visita
, if it is different from 0, it means that the visit has already been carried out, therefore my object gestionRuta
has the following:
[DataMember]
public string gestion_ruta_visita_fecha { get; set; }
[DataMember]
public string gestion_ruta_visita_observaciones { get; set; }
These fields are ONLY filled when the id_visita
is different from 0, but in the other case, that is 0, I don't want them to appear as null in my json, just not to appear.
Current result :
"rutas": [
{
"estado": 1,
"gestion_ruta_codigo_sala": "3200007286",
"gestion_ruta_direccion_sala": "La Florida",
"gestion_ruta_latitud_sala": "-33.4141632",
"gestion_ruta_longitud_sala": "-70.627686",
"gestion_ruta_nombre_sala": "Jumbo La Florida",
"gestion_ruta_programacion_fecha": "25-05-2015",
"gestion_ruta_programacion_id": 391,
"gestion_ruta_visita_fecha": "02-06-2016 16:11",
"gestion_ruta_visita_observaciones": "Sin observaciones"
},
{
"estado": 2,
"gestion_ruta_codigo_sala": "3200007286",
"gestion_ruta_direccion_sala": "La Florida",
"gestion_ruta_latitud_sala": "-33.4141632",
"gestion_ruta_longitud_sala": "-70.627686",
"gestion_ruta_nombre_sala": "Jumbo La Florida",
"gestion_ruta_programacion_fecha": "27-05-2015",
"gestion_ruta_programacion_id": 392,
"gestion_ruta_visita_fecha": null,
"gestion_ruta_visita_observaciones": null
},
Expected result :
"rutas": [
{
"estado": 1,
"gestion_ruta_codigo_sala": "3200007286",
"gestion_ruta_direccion_sala": "La Florida",
"gestion_ruta_latitud_sala": "-33.4141632",
"gestion_ruta_longitud_sala": "-70.627686",
"gestion_ruta_nombre_sala": "Jumbo La Florida",
"gestion_ruta_programacion_fecha": "25-05-2015",
"gestion_ruta_programacion_id": 391,
"gestion_ruta_visita_fecha": "02-06-2016 16:11",
"gestion_ruta_visita_observaciones": "Sin observaciones"
},
{
"estado": 2,
"gestion_ruta_codigo_sala": "3200007286",
"gestion_ruta_direccion_sala": "La Florida",
"gestion_ruta_latitud_sala": "-33.4141632",
"gestion_ruta_longitud_sala": "-70.627686",
"gestion_ruta_nombre_sala": "Jumbo La Florida",
"gestion_ruta_programacion_fecha": "27-05-2015",
"gestion_ruta_programacion_id": 392
},
I have a mobile application that calls different services that I have in c#
con Wcf
. The issue is that I have one of those services in which the user from the mobile sends an object called Medicion
. This object has a list of CeldaKeyValUpload
.
public class Medicion
{
[DataMember]
public string medicion_user_email { get; set; }
[DataMember]
public string medicion_user_nombre { get; set; }
[DataMember]
public string medicion_app_os { get; set; }
[DataMember]
public string medicion_app_version { get; set; }
[DataMember]
public string medicion_latitud { get; set; }
[DataMember]
public string medicion_longitud { get; set; }
[DataMember]
public string medicion_sala_id { get; set; }
[DataMember]
public string medicion_codigo_empresa { get; set; }
[DataMember]
public string medicion_codigo_cadena { get; set; }
[DataMember]
public string medicion_codigo_modulo { get; set; }
[DataMember]
public string medicion_categoria_codigo { get; set; }
[DataMember]
public List<CeldaKeyValUpload> celdas { get; set; }
}
Y
public class CeldaKeyValUpload
{
[DataMember]
public int celda_id { get; set; }
[DataMember]
public string celda_key_codigo { get; set; }
[DataMember]
public string celda_key_valor { get; set; }
}
The list that can reach me from the mobile can be very extensive, let's say an example of 200 records. In my database I have two tables one called MedicionEncabezado
and MedicionDetalle
. Everything in the class is saved in the first table Medicion
except the list CeldaKeyValUpload
, since it is saved in MedicionDetalle
.
The problem I have is that I put myself in the case that for whatever reason the mobile loses internet and cannot upload these 200 records. For this I have created temporary tables called TmpMedicionEncabezado
and TmpMedicionDetalle
. When the device sends the data, it loads these temporary tables, and upon successful completion, the load fills my official tables with the data . This is why I need to create one Stored Procedure
that is in charge of passing the data from the temporary tables to the official tables. Why am I doing this? To not fill my table with garbage data.
The problem I have is that I don't know how to get the data from the temporary tables and save it to the official tables. I still don't know much about sql-server-2005
.
In Sql server 2008 it was very simple for me to obtain the distance between two latitude and longitude points, but now I am using Sql server 2005 and the data type geography
does not seem to exist... I did this:
DECLARE @source geography = 'POINT(0 51.5)'
DECLARE @target geography = 'POINT(-3 56)'
SELECT @source.STDistance(@target)
Unfortunately this doesn't work for me on Sql server 2005
Any idea or type of data to help me with this, if it doesn't exist, will I have to do the calculation, let's say "manual"?
I am executing stored procedures in my project WCF C#
. From one of my SP I receive something like this:
CeldaId
CeldaIndicadorCodigo
CeldaIndicadorTipoCodigo
Then with the value of Celda Id
I call another SP that brings me:
CeldaKeyCodigo
CeldaKeyValor
From the first SP I get CeldaId
and with that value I get the results of the second SP.
My idea is from my service to deliver an array JSON
more or less with this structure
Celdas : [
IndicadorCodigo : [
{
CeldaKeyCodigo : valor,
CeldaKeyValor : valor
},
{
CeldaKeyCodigo : valor,
CeldaKeyValor : valor
}
]
]
That is, group the values of the query of my second SP by the value that IndicatorCodigo has.
The way I did it was the following... I created a class called Cell with the fields named above plus a List of a class called CellKeyVal with the fields returned by my second SP.
public class Celda
{
[DataMember]
public int celda_id { get; set; }
[DataMember]
public int celda_indicador_codigo { get; set; }
[DataMember]
public int celda_indicador_tipo_codigo { get; set; }
[DataMember]
public List<CeldaKeyVal> valores_celda { get; set; }
}
public class CeldaKeyVal
{
[DataMember]
public string celda_key_codigo { get; set; }
[DataMember]
public string celda_key_valor { get; set; }
}
After having this structure, I go through the results like this:
public ListaCeldas GetCheckIn(int gsalid)
{
SqlConnection conn = new SqlConnection(Db);
List < Celda > celdas = new List < Celda > ();
ListaCeldas listaCeldas = new ListaCeldas();
try {
SqlCommand cmd = new SqlCommand("MBL_SEL_CELDAS", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("gsalid", gsalid);
conn.Open();
cmd.ExecuteNonQuery();
DataTable dtCelda = new DataTable();
dtCelda.Load(cmd.ExecuteReader());
foreach(DataRow dr in dtCelda.Rows) {
Celda celda = new Celda();
celda.celda_id = Convert.ToInt32(dr["CeldaId"]);
celda.celda_indicador_codigo = Convert.ToString(dr["CeldaIndicadorCodigo"]);
celda.celda_indicador_tipo = Convert.ToString(dr["CeldaIndicadorTipoCodigo"]);
DataTable dtCeldasKey = new DataTable();
SqlCommand cmd_celdas_key = Helper.GetCeldaValoresKey(celda.celda_id);
dtCeldasKey.Load(cmd_celdas_key.ExecuteReader());
List < CeldaKeyVal > listaCeldaKey = new List < CeldaKeyVal > ();
foreach(DataRow drCeldasKey in dtCeldasKey.Rows) {
CeldaKeyVal celda_key_val = new CeldaKeyVal();
celda_key_val.celda_key_codigo = Convert.ToString(drCeldasKey["CeldaKeyCodigo"]);
celda_key_val.celda_key_valor = Convert.ToString(drCeldasKey["CeldaKeyValue"]);
listaCeldaKey.Add(celda_key_val);
}
celda.valores_celda = listaCeldaKey;
celdas.Add(celda);
}
List < Celda > cl = celdas.OrderBy(c => c.celda_indicador_codigo).ToList();
listaCeldas.celdas = cl;
if (celdas.Count > 0) {
listaCeldas.status = 1;
}
} catch (Exception e) {
listaCeldas.status = 0;
} finally {
conn.Close();
}
return listaCeldas;
}
This works fine for me but not the order I want, this is the JSON I get
{
"GetCheckInResult": {
"celdas": [
{
"celda_id": 1,
"celda_indicador_codigo": "I001",
"celda_indicador_tipo": "T01",
"valores_celda": [
{
"celda_key_codigo": "CODIGO",
"celda_key_valor": "CHECK1"
},
{
"celda_key_codigo": "IMAGEN",
"celda_key_valor": "L76nD.jpg"
},
{
"celda_key_codigo": "SUBTEXTO",
"celda_key_valor": "prueba subtexto 1"
},
{
"celda_key_codigo": "TEXTO",
"celda_key_valor": "Prueba dominio 1"
}
]
},
{
"celda_id": 4,
"celda_indicador_codigo": "I002",
"celda_indicador_tipo": "T03",
"valores_celda": [
{
"celda_key_codigo": "CODIGO",
"celda_key_valor": "codigo"
}
]
},
{
"celda_id": 5,
"celda_indicador_codigo": "I002",
"celda_indicador_tipo": "T03",
"valores_celda": [
{
"celda_key_codigo": "CODIGO",
"celda_key_valor": "ssddsds"
}
]
},
{
"celda_id": 3,
"celda_indicador_codigo": "I003",
"celda_indicador_tipo": "T02",
"valores_celda": [
{
"celda_key_codigo": "CODIGO",
"celda_key_valor": "sdadsa"
},
{
"celda_key_codigo": "IMAGEN",
"celda_key_valor": "L76nD.jpg"
},
{
"celda_key_codigo": "TEXTO",
"celda_key_valor": "Texto 1"
}
]
}
],
"status": 1
}
}
I know that the error is in my class structure but I can't think of how to assemble them to get the format I want to get.
WHAT I EXPECT
Get an array of cells and their values ordered byIndicadorCodigo
Expected json :
{
"GetCheckInResult": {
"celdas": [
"T01" : [
{
"celda_key_codigo": "CODIGO",
"celda_key_valor": "CHECK1"
},
{
"celda_key_codigo": "IMAGEN",
"celda_key_valor": "L76nD.jpg"
},
{
"celda_key_codigo": "SUBTEXTO",
"celda_key_valor": "prueba subtexto 1"
},
{
"celda_key_codigo": "TEXTO",
"celda_key_valor": "Prueba dominio 1"
}
],
"T02" : [
{
"celda_key_codigo": "CODIGO",
"celda_key_valor": "CHECK1"
},
{
"celda_key_codigo": "IMAGEN",
"celda_key_valor": "L76nD.jpg"
},
{
"celda_key_codigo": "SUBTEXTO",
"celda_key_valor": "prueba subtexto 1"
},
{
"celda_key_codigo": "TEXTO",
"celda_key_valor": "Prueba dominio 1"
}
]
],
"status": 1
}
}