Merge branch 'develop'

This commit is contained in:
Samuele E. Locatelli
2016-02-03 16:38:11 +01:00
20 changed files with 383 additions and 9 deletions
Binary file not shown.
+8
View File
@@ -71,6 +71,7 @@
<Content Include="favicon.ico" />
<Content Include="FullSync.aspx" />
<Content Include="images\LogoSteamware.png" />
<Content Include="ResyncLastDocs.aspx" />
<Content Include="SyncDoc.aspx" />
<Content Include="Web.config">
<SubType>Designer</SubType>
@@ -100,6 +101,13 @@
</Compile>
<Compile Include="GestData.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ResyncLastDocs.aspx.cs">
<DependentUpon>ResyncLastDocs.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
</Compile>
<Compile Include="ResyncLastDocs.aspx.designer.cs">
<DependentUpon>ResyncLastDocs.aspx</DependentUpon>
</Compile>
<Compile Include="SyncDoc.aspx.cs">
<DependentUpon>SyncDoc.aspx</DependentUpon>
<SubType>ASPXCodeBehind</SubType>
+168 -1
View File
@@ -37,6 +37,7 @@ namespace DataUploader
public static GestData proc = new GestData();
/// <summary>
/// restituisce un array di stringhe URL da chiamare per caricare i dati documento / cliente
/// </summary>
@@ -57,7 +58,7 @@ namespace DataUploader
string[] rCli = new string[12];
string comandoDoc;
// qui va fatto ciclo x spazzare 1 ad 1 i docuemnti ed i relativi clienti
// qui va fatto ciclo x spazzare 1 ad 1 i documenti ed i relativi clienti
if (false)
{ // query in formato ACCESS 2010
comandoDoc = string.Format(@"SELECT TOP {0}
@@ -201,6 +202,172 @@ namespace DataUploader
// end ciclo, resituisco tutti i records
return answ;
}
/// <summary>
/// restituisce un array di stringhe URL da chiamare per caricare i dati documento / cliente
/// </summary>
/// <param name="numeroFrom">numero ultimo doc caricato (restituirà docs successivi)</param>
/// <param name="num2reload">numero di doc da ricaricare (prima dell'ultimo caricato...)</param>
/// <returns></returns>
public string[] reloadLastDocs(int numeroFrom, int num2reload)
{
if (ConfigurationManager.AppSettings["debugMode"] == "true")
{
logger.Info("Inizio getNewDocsUrls");
}
// ipotesi: si caricano maxDocsToUpload documenti alal volta (e quindi altrettanti clienti)
int maxDocsToUpload = num2reload + 1;
string[] answ = new string[maxDocsToUpload * 2]; // 2 stringhe, una x doc e 1 x cliente x ogni invio...
string[] rDoc = new string[20];
string[] rCli = new string[12];
string comandoDoc;
// qui va fatto ciclo x spazzare 1 ad 1 i documenti ed i relativi clienti
if (false)
{ // query in formato ACCESS 2010
comandoDoc = string.Format(@"SELECT TOP {0}
TESDOCUM.TIPOPROTOC, TESDOCUM.NUMERO, TESDOCUM.ESERPROTOC,
TESDOCUM.NUMEPROTOC, TESDOCUM.DATAPROTOC, TESDOCUM.ESERRIFERI,
TESDOCUM.NUMERIFERI, TESDOCUM.TIPORIFERI, TESDOCUM.DATARIFERI,
TESDOCUM.NUMEDOCRIF, TESDOCUM.DATADOCRIF, TESDOCUM.ESERCOLLEG,
TESDOCUM.CLI_FOR, TESDOCUM.DESTINATAR, TESDOCUM.RGSOC_DEST,
TESDOCUM.INDIR_DEST, TESDOCUM.LOCAL_DEST, TESDOCUM.CAP_DEST,
TESDOCUM.ULT_AGG, TESDOCUM.ANNOTAZION
FROM TESDOCUM
WHERE (CLng(TESDOCUM.NUMERO) > ({1}))
AND (TESDOCUM.TIPOPROTOC IN ('OC', 'DC'))
ORDER BY TESDOCUM.NUMERO
",
maxDocsToUpload, numeroFrom);
}
else
{ // query in formato DB2
comandoDoc = string.Format(@"SELECT
TESDOCUM.TIPOPROTOC, TESDOCUM.NUMERO, TESDOCUM.ESERPROTOC,
TESDOCUM.NUMEPROTOC, TESDOCUM.DATAPROTOC, TESDOCUM.ESERRIFERI,
TESDOCUM.NUMERIFERI, TESDOCUM.TIPORIFERI, TESDOCUM.DATARIFERI,
TESDOCUM.NUMEDOCRIF, TESDOCUM.DATADOCRIF, TESDOCUM.ESERCOLLEG,
TESDOCUM.CLI_FOR, TESDOCUM.DESTINATAR, TESDOCUM.RGSOC_DEST,
TESDOCUM.INDIR_DEST, TESDOCUM.LOCAL_DEST, TESDOCUM.CAP_DEST,
TESDOCUM.ULT_AGG, TESDOCUM.ANNOTAZION
FROM TESDOCUM
WHERE (INT(TESDOCUM.NUMERO) > ({1}))
AND (TESDOCUM.TIPOPROTOC IN ('OC', 'DC'))
ORDER BY TESDOCUM.NUMERO
FETCH FIRST {0} ROWS ONLY
",
maxDocsToUpload, numeroFrom - num2reload);
}
// try/catch x db e ciclo su dati...
try
{
conn.Open();
if (ConfigurationManager.AppSettings["debugMode"] == "true")
{
logger.Info("Aperta connessione ODBC");
}
// dati documento
int num = 0;
using (OdbcCommand com = new OdbcCommand(comandoDoc, conn))
{
using (OdbcDataReader reader = com.ExecuteReader())
{
while (reader.Read())
{
for (int i = 0; i < 20; i++)
{
try
{
rDoc[i] = reader.GetString(i).Trim().Replace(" ", "+");
}
catch
{
rDoc[i] = "";
}
}
//if (ConfigurationManager.AppSettings["debugMode"] == "true")
//{
// logger.Info("Completata lettura ODBC x DOC");
//}
// il campo 12 è il cod cliente!
rCli[0] = rDoc[12];
// cellulare e email trovati in USRCLIFO, relazionato su CODSIGLA
string comandoCli = string.Format(@"SELECT CLIFO.CODICE, CLIFO.RAGIONESOC, CLIFO.COFI,
CLIFO.TEL, USRCLIFO.CELNM AS CELL,
CASE WHEN USRCLIFO.CELNM <> ' ' THEN 1 ELSE 0 END AS ENABLE_SMS,
USRCLIFO.E_MAILL AS EMAIL,
CLIFO.INDIR1, CLIFO.CAP, CLIFO.LOCALITA,
CLIFO.PROVINCIA, '' AS NoteCli
FROM CLIFO INNER JOIN USRCLIFO
ON CLIFO.CODICE = USRCLIFO.CODSIGLA
WHERE CLIFO.TIPO='C'
AND CLIFO.CODICE = '{0}'",
rCli[0]);
try
{
using (OdbcCommand comCli = new OdbcCommand(comandoCli, conn))
{
using (OdbcDataReader readerCli = comCli.ExecuteReader())
{
while (readerCli.Read())
{
for (int j = 0; j < 12; j++)
{
try
{
rCli[j] = readerCli.GetString(j).Trim().Replace(" ", "+");
}
catch
{
rCli[j] = "";
}
}
}
}
}
//if (ConfigurationManager.AppSettings["debugMode"] == "true")
//{
// logger.Info("Completata lettura ODBC x CLI");
//}
// formatto answ... prima CLI poi DOCS...
answ[num++] = createUrlCli(rCli);
answ[num++] = createUrlDoc(rDoc);
}
catch (Exception ex)
{
logger.Error("Eccezione in comandoCli{0}Comando: {1}{0}{2}", Environment.NewLine, comandoCli, ex);
}
}
}
}
}
catch (Exception ex)
{
logger.Error("Eccezione{0}Comando: {1}{0}{2}", Environment.NewLine, comandoDoc, ex);
}
finally
{
conn.Close();
}
if (ConfigurationManager.AppSettings["debugMode"] == "true")
{
logger.Info("Chiusura connessione ODBC");
}
// end ciclo, resituisco tutti i records
return answ;
}
/// <summary>
/// restituisce un array di stringhe URL da chiamare per caricare i dati documento / cliente
/// </summary>
@@ -10,7 +10,7 @@ by editing this MSBuild file. In order to learn more about this please visit htt
</PropertyGroup>
<ItemGroup>
<File Include="bin/DataUploader.dll">
<publishTime>10/01/2015 19:37:03</publishTime>
<publishTime>02/03/2016 15:59:04</publishTime>
</File>
<File Include="bin/NLog.config">
<publishTime>09/03/2015 11:38:11</publishTime>
@@ -43,13 +43,16 @@ by editing this MSBuild file. In order to learn more about this please visit htt
<publishTime>09/03/2015 11:38:11</publishTime>
</File>
<File Include="PrecompiledApp.config">
<publishTime>10/01/2015 19:37:04</publishTime>
<publishTime>02/03/2016 15:59:05</publishTime>
</File>
<File Include="ResyncLastDocs.aspx">
<publishTime>02/03/2016 15:13:36</publishTime>
</File>
<File Include="SyncDoc.aspx">
<publishTime>09/18/2015 10:37:41</publishTime>
</File>
<File Include="Web.config">
<publishTime>10/01/2015 19:37:03</publishTime>
<publishTime>02/03/2016 15:33:45</publishTime>
</File>
</ItemGroup>
</Project>
+25
View File
@@ -0,0 +1,25 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ResyncLastDocs.aspx.cs" Inherits="DataUploader.ResyncLastDocs" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>ResyncLastDocs</h1>
Modalità chiamata:
<ul>
<li>Senza parametri: effettua il caricamento forzato degli ultimi doc (numero impostato in web.config) arrivando all'ultimo che risulta caricato online</li>
<li>Specificando parametro Num2Reload: effettua il caricamento forzato degli ultimi Num2Reload doc arrivando all'ultimo che risulta caricato online</li>
<li>Con aggiunto il parametro "?DemoMode=true" nell'url --> NON viene chiamata (per ogni record) la pagina remota ma viene mostrato l'elenco delle chiamate che SI SAREBBERO EFFETTUATE</li>
</ul>
<hr />
<h2>OUTPUT</h2>
<asp:Label runat="server" ID="lblOut" />
</div>
</form>
</body>
</html>
+112
View File
@@ -0,0 +1,112 @@
using NLog;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace DataUploader
{
public partial class ResyncLastDocs : System.Web.UI.Page
{
private static Logger logger = LogManager.GetCurrentClassLogger();
protected void Page_Load(object sender, EventArgs e)
{
logger.Info(">>>------ Inizio ResyncLastDoc ------<<<");
DateTime tick = DateTime.Now;
int numDocCaricati = 0;
using (var client = new WebClient())
{
client.Proxy = null;
ServicePointManager.DefaultConnectionLimit = int.MaxValue;
// verifico se vado in modalità demo o meno...
bool demoMode = false;
int Num2Reload = 0;
try
{
Num2Reload = Convert.ToInt32(Request.QueryString["Num2Reload"]);
}
catch
{ }
if (Num2Reload == 0)
{
Num2Reload = Convert.ToInt32(ConfigurationManager.AppSettings["numDocDaRicaricare"]);
}
try
{
demoMode = Convert.ToBoolean(Request.QueryString["DemoMode"]);
}
catch
{ }
// recupero ultimo numero doc caricato...
int lastNum = 0;
try
{
var content = client.DownloadString(ConfigurationManager.AppSettings["remoteDocUrl"]); // http://webscr.steamware.net/Rigamonti/Upload/Document
// converto a int!
lastNum = Convert.ToInt32(content);
logger.Info("Recuperato last num: {0}", lastNum);
}
catch
{ }
// recupero i dati da caricare...
string[] urlsUpdate = GestData.proc.reloadLastDocs(lastNum, Num2Reload);
if (demoMode)
{
lblOut.Text = string.Format("DEMO MODE!<br/>ultimo NUMERO: {0}", lastNum);
for (int i = 0; i < urlsUpdate.Length; i++)
{
lblOut.Text += string.Format("<br/>{0:000}) {1}", i + 1, urlsUpdate[i]);
}
logger.Info("Effettuato DEMO upload FULL SYNC: durata {0} msec", DateTime.Now.Subtract(tick).TotalMilliseconds);
}
else
{
if (ConfigurationManager.AppSettings["debugMode"] == "true")
{
logger.Info("Inizio chiamate URL");
}
lblOut.Text = string.Format("Normal MODE!<br/>{0}", lastNum);
string content = "";
for (int i = 0; i < urlsUpdate.Length; i++)
{
try
{
if (ConfigurationManager.AppSettings["logFull"] == "true")
{
logger.Info("Chiamata [{0}]", i);
}
// se ho qualcosa da scaricare...
if (urlsUpdate[i] != "")
{
// versione SYNC
content = client.DownloadString(urlsUpdate[i]);
numDocCaricati++;
}
if (ConfigurationManager.AppSettings["logFull"] == "true")
{
logger.Info("Risposta [{0}] - {1}", content, urlsUpdate[i]);
}
}
catch
{ }
}
try
{
logger.Info(">>>------ Effettuato upload RESYNC: durata {0} msec, {1} chiamate! ------<<<", DateTime.Now.Subtract(tick).TotalMilliseconds, numDocCaricati);
}
catch
{
logger.Info(">>>------ Effettuato upload RESYNC: durata {0} sec, {1} chiamate! ------<<<", DateTime.Now.Subtract(tick).Seconds, numDocCaricati);
}
}
}
}
}
}
+33
View File
@@ -0,0 +1,33 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace DataUploader {
public partial class ResyncLastDocs {
/// <summary>
/// form1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
/// <summary>
/// lblOut control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblOut;
}
}
+2 -2
View File
@@ -2,8 +2,8 @@
<configuration>
<appSettings>
<!--parametri base-->
<!--<add key="maxDocsToUpload" value="50" />-->
<add key="maxDocsToUpload" value="5" />
<add key="maxDocsToUpload" value="10" />
<add key="numDocDaRicaricare" value="200" />
<add key="remoteDocUrl" value="http://webscr.steamware.net/Rigamonti/Upload/Document" />
<add key="remoteCliUrl" value="http://webscr.steamware.net/Rigamonti/Upload/Client" />
<add key="debugMode" value="false" />
Binary file not shown.
+2 -2
View File
@@ -2,8 +2,8 @@
<configuration>
<appSettings>
<!--parametri base-->
<!--<add key="maxDocsToUpload" value="50" />-->
<add key="maxDocsToUpload" value="5" />
<add key="maxDocsToUpload" value="10" />
<add key="numDocDaRicaricare" value="200" />
<add key="remoteDocUrl" value="http://webscr.steamware.net/Rigamonti/Upload/Document" />
<add key="remoteCliUrl" value="http://webscr.steamware.net/Rigamonti/Upload/Client" />
<add key="debugMode" value="false" />
Binary file not shown.
@@ -0,0 +1,25 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ResyncLastDocs.aspx.cs" Inherits="DataUploader.ResyncLastDocs" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>ResyncLastDocs</h1>
Modalità chiamata:
<ul>
<li>Senza parametri: effettua il caricamento forzato degli ultimi doc (numero impostato in web.config) arrivando all'ultimo che risulta caricato online</li>
<li>Specificando parametro Num2Reload: effettua il caricamento forzato degli ultimi Num2Reload doc arrivando all'ultimo che risulta caricato online</li>
<li>Con aggiunto il parametro "?DemoMode=true" nell'url --> NON viene chiamata (per ogni record) la pagina remota ma viene mostrato l'elenco delle chiamate che SI SAREBBERO EFFETTUATE</li>
</ul>
<hr />
<h2>OUTPUT</h2>
<asp:Label runat="server" ID="lblOut" />
</div>
</form>
</body>
</html>
+2 -1
View File
@@ -2,7 +2,8 @@
<configuration>
<appSettings>
<!--parametri base-->
<add key="maxDocsToUpload" value="50" />
<add key="maxDocsToUpload" value="10" />
<add key="numDocDaRicaricare" value="200" />
<add key="remoteDocUrl" value="http://webscr.steamware.net/Rigamonti/Upload/Document" />
<add key="remoteCliUrl" value="http://webscr.steamware.net/Rigamonti/Upload/Client" />
<add key="debugMode" value="false" />
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.