Update x problemi timeout download immagini con getUserList

This commit is contained in:
Samuele E. Locatelli
2019-04-16 10:46:56 +02:00
parent 76726d0545
commit d5da75b066
5 changed files with 145 additions and 40 deletions
+69 -23
View File
@@ -328,10 +328,14 @@ namespace MConnectSDK
}
catch
{ }
// bonifico eventuali null...
answ.RemoveAll(item => item == null);
return answ;
}
set
{
value.RemoveAll(item => item == null);
value.Sort();
string serVal = JsonConvert.SerializeObject(value);
ML.setRSV(ML.redHash("UserListCache"), serVal);
}
@@ -1035,29 +1039,8 @@ namespace MConnectSDK
Image userImg = null;
UserStatus currStatus = UserStatus.NOT_IMPORTED;
// recupero effettivi dati utente e restituisco...
Parallel.ForEach(resp.result, item =>
foreach (var item in resp.result)
{
// se richiesto aggiungo immagine...
if (getImages)
{
userImg = null;
try
{
// creo obj userData... SE HO immagine...
if (item.Image_Url != "")
{
var imgRes = Task.Run(() => Utils.getImageAsync(pageUrlImgDownload, item.Image_Url));
imgRes.Wait();
if (imgRes.Result != null)
{
userImg = imgRes.Result;
}
}
}
catch
{
}
}
// verifica SE FOSSE GIA' esistente --> tengo STATUS...
resFilt = userListOld.FindAll(X => X.Username == item.Username);
if (resFilt.Count > 0)
@@ -1085,7 +1068,8 @@ namespace MConnectSDK
UserImage = userImg
};
answ.Add(_newUser);
});
}
// se ne avessi ricevuti (da cloud) meno di quanti ne avevo --> cerco DELETED...
if (numFound != numImp)
{
@@ -1111,6 +1095,68 @@ namespace MConnectSDK
}
}
}
// se richiesto aggiungo immagine...
if (getImages)
{
// in modalità parallela TENTO scaricamento imagini...
Parallel.ForEach(resp.result, item =>
{
userImg = null;
try
{
// creo obj userData... SE HO immagine...
if (item.Image_Url != "")
{
var imgRes = Task.Run(() => Utils.getImageAsync(pageUrlImgDownload, item.Image_Url));
imgRes.Wait();
if (imgRes.Result != null)
{
userImg = imgRes.Result;
}
}
}
catch
{
}
resFilt = answ.FindAll(X => X.Username == item.Username);
if (resFilt.Count == 1)
{
resFilt[0].UserImage = userImg;
}
#if false
// verifica SE FOSSE GIA' esistente --> tengo STATUS...
resFilt = userListOld.FindAll(X => X.Username == item.Username);
if (resFilt.Count > 0)
{
currStatus = resFilt[0].LoginStatus;
if (currStatus == UserStatus.IMPORTED)
{
numFound++;
}
}
else
{
currStatus = UserStatus.NOT_IMPORTED;
}
// creo utente
_newUser = new UserData
{
UserId = item.Id,
IsAdmin = item.IsAdmin,
Username = item.Username,
Email = item.Email,
Cognome = item.Lastname,
Nome = item.Firstname,
LoginStatus = currStatus,
UserImage = userImg
};
answ.Add(_newUser);
#endif
});
}
return answ;
}
+47 -1
View File
@@ -709,6 +709,51 @@ namespace MConnectSDK
public string link { get; set; } = "";
public string expiry { get; set; } = "";
}
/// <summary>
/// Classe ordinabile x UserData
/// </summary>
public class UserData : IComparable<UserData>
{
/// <summary>
/// Codice utente (es asfd.0002)
/// </summary>
public string UserId = "";
/// <summary>
/// Indica se sia ADMIN
/// </summary>
public bool IsAdmin = false;
/// <summary>
/// Indica lo stsatus dell'utente
/// </summary>
public UserStatus LoginStatus = UserStatus.NOT_IMPORTED;
/// <summary>
/// UserName (univoco)
/// </summary>
public string Username = "";
/// <summary>
/// Email
/// </summary>
public string Email = "";
/// <summary>
/// Cognome
/// </summary>
public string Cognome = "";
/// <summary>
/// Nome
/// </summary>
public string Nome = "";
/// <summary>
/// Immagine utente
/// </summary>
[JsonConverter(typeof(ImageConverter))]
public Image UserImage = null;
public int CompareTo(UserData other)
{
return this.UserId.CompareTo(other.UserId);
}
}
#if false
/// <summary>
/// Classe info UTENTE
/// </summary>
@@ -747,7 +792,8 @@ namespace MConnectSDK
/// </summary>
[JsonConverter(typeof(ImageConverter))]
public Image UserImage = null;
}
}
#endif
/// <summary>
/// Classe info UTENTE + pwd (cifrata...) x cache localedi login
/// </summary>
+2 -2
View File
@@ -8,5 +8,5 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCopyright("Copyright © Steamware 2019")]
[assembly: AssemblyTrademark("_")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("1.1.1904.81")]
[assembly: AssemblyFileVersion("1.1.1904.81")]
[assembly: AssemblyVersion("1.1.1904.83")]
[assembly: AssemblyFileVersion("1.1.1904.83")]
+26 -13
View File
@@ -33,6 +33,7 @@
this.toolStripProgressBar1 = new System.Windows.Forms.ToolStripProgressBar();
this.lblClock = new System.Windows.Forms.ToolStripStatusLabel();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.btnFakeQR = new System.Windows.Forms.Button();
this.txtUploadFile = new System.Windows.Forms.TextBox();
this.btnUploadFile = new System.Windows.Forms.Button();
this.lblUserCode = new System.Windows.Forms.Label();
@@ -65,7 +66,7 @@
this.pictBox = new System.Windows.Forms.PictureBox();
this.label6 = new System.Windows.Forms.Label();
this.lblConsole = new System.Windows.Forms.Label();
this.btnFakeQR = new System.Windows.Forms.Button();
this.chkGetImg = new System.Windows.Forms.CheckBox();
this.statusStrip1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
@@ -122,6 +123,16 @@
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Connection Parameters";
//
// btnFakeQR
//
this.btnFakeQR.Location = new System.Drawing.Point(932, 23);
this.btnFakeQR.Name = "btnFakeQR";
this.btnFakeQR.Size = new System.Drawing.Size(111, 32);
this.btnFakeQR.TabIndex = 33;
this.btnFakeQR.Text = "fake QR";
this.btnFakeQR.UseVisualStyleBackColor = true;
this.btnFakeQR.Click += new System.EventHandler(this.btnFakeQR_Click);
//
// txtUploadFile
//
this.txtUploadFile.Location = new System.Drawing.Point(454, 28);
@@ -171,6 +182,7 @@
//
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox2.Controls.Add(this.chkGetImg);
this.groupBox2.Controls.Add(this.btnTryEnroll);
this.groupBox2.Controls.Add(this.btnDeleteUserCloud);
this.groupBox2.Controls.Add(this.btnDeleteUserHMI);
@@ -237,7 +249,7 @@
//
// btnGetUserCreatedList
//
this.btnGetUserCreatedList.Location = new System.Drawing.Point(519, 59);
this.btnGetUserCreatedList.Location = new System.Drawing.Point(506, 59);
this.btnGetUserCreatedList.Name = "btnGetUserCreatedList";
this.btnGetUserCreatedList.Size = new System.Drawing.Size(132, 32);
this.btnGetUserCreatedList.TabIndex = 26;
@@ -268,7 +280,7 @@
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(669, 67);
this.label10.Location = new System.Drawing.Point(684, 67);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(33, 17);
this.label10.TabIndex = 23;
@@ -284,7 +296,7 @@
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(669, 29);
this.label9.Location = new System.Drawing.Point(684, 29);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(36, 17);
this.label9.TabIndex = 21;
@@ -310,7 +322,7 @@
//
// btnGetUserList
//
this.btnGetUserList.Location = new System.Drawing.Point(519, 21);
this.btnGetUserList.Location = new System.Drawing.Point(506, 21);
this.btnGetUserList.Name = "btnGetUserList";
this.btnGetUserList.Size = new System.Drawing.Size(132, 32);
this.btnGetUserList.TabIndex = 18;
@@ -459,15 +471,15 @@
this.lblConsole.TabIndex = 7;
this.lblConsole.Text = "...";
//
// btnFakeQR
// chkGetImg
//
this.btnFakeQR.Location = new System.Drawing.Point(932, 23);
this.btnFakeQR.Name = "btnFakeQR";
this.btnFakeQR.Size = new System.Drawing.Size(111, 32);
this.btnFakeQR.TabIndex = 33;
this.btnFakeQR.Text = "fake QR";
this.btnFakeQR.UseVisualStyleBackColor = true;
this.btnFakeQR.Click += new System.EventHandler(this.btnFakeQR_Click);
this.chkGetImg.AutoSize = true;
this.chkGetImg.Location = new System.Drawing.Point(645, 29);
this.chkGetImg.Name = "chkGetImg";
this.chkGetImg.Size = new System.Drawing.Size(52, 21);
this.chkGetImg.TabIndex = 31;
this.chkGetImg.Text = "img";
this.chkGetImg.UseVisualStyleBackColor = true;
//
// MainForm
//
@@ -533,6 +545,7 @@
private System.Windows.Forms.Button btnUploadFile;
private System.Windows.Forms.TextBox txtUploadFile;
private System.Windows.Forms.Button btnFakeQR;
private System.Windows.Forms.CheckBox chkGetImg;
}
}
+1 -1
View File
@@ -341,7 +341,7 @@ namespace TestClient
{
await Task.Run(() =>
{
var userResult = MCC.getUserListAsync(true);
var userResult = MCC.getUserListAsync(chkGetImg.Checked);
List<UserData> userList = ((UserPayload)userResult.Result.Payload).UserList;
synchronizationContext.Post(new SendOrPostCallback(o =>