ok singolo DOC!!!!

This commit is contained in:
Samuele E. Locatelli
2015-05-25 12:54:36 +02:00
parent 1aa0d3ee18
commit 54e0b65b1a
14 changed files with 125 additions and 21 deletions
+1 -1
View File
@@ -40,7 +40,7 @@
</ul>
il tutto viene fatto tramite la classe helper GestData
<br />
Demo: <a href="SyncDoc.aspx?DOC=OC0001616">SyncDoc.aspx?DOC=OC0001616</a>
Demo: <a href="SyncDoc.aspx?DOC=OC0001616&Anno=2015">SyncDoc.aspx?DOC=OC0001616&Anno=2015</a>
</div>
</form>
</body>
+56 -8
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data.Odbc;
namespace DataUploader
{
@@ -12,12 +13,17 @@ namespace DataUploader
{
setupConnString();
}
protected OdbcConnection conn;
/// <summary>
/// configurazione stringa connesisone dati
/// </summary>
private void setupConnString()
{
conn = new OdbcConnection();
// ho creato un DSN di sistema a nome "DB_Sigla" cui faccio riferimento (32 perché 32 bit x mia demo... ho dovuto convertire accdb in mdb...)
string connectionString = "Dsn=DB_Sigla32;Initial Catalog=DB2_TESDOCUM;"; // qui va sistemato correttamente
//string connectionString = "Driver={Microsoft Access Driver(*.mdb, *.accdb)};DBQ=C:\\DB_SIGLA.accdb;";
conn.ConnectionString = connectionString;
}
public static GestData proc = new GestData();
@@ -55,20 +61,62 @@ namespace DataUploader
/// <summary>
/// restituisce un array di stringhe URL da chiamare per caricare i dati documento / cliente
/// </summary>
/// <param name="CodDoc">Codice docuemnto richiesto</param>
/// <param name="CodDoc">Codice documento richiesto</param>
/// <param name="Anno">Anno documento richiesto</param>
/// <returns></returns>
public string[] getDocsUrls(string CodDoc)
public string[] getDocsUrls(string CodDoc, string Anno)
{
string[] answ = new string[2]; // 2 stringhe, una x doc e 1 x cliente x ogni invio...
// effettuo chaimata ODBC e recupero dati
// per ogni record trovato compongo un record DOCS ed uno CLI
string[] rDoc = new string[19];
string[] rCli = new string[11];
// formatto answ...
answ[0] = createUrlDoc(rDoc);
answ[1] = createUrlCli(rCli);
// effettuo chaimata ODBC e recupero dati
try
{
conn.Open();
string tipoDoc = CodDoc.Substring(0,2);
string NumDoc = CodDoc.Replace(tipoDoc,"");
// questa è la vera stringa SQL
string comando = string.Format("SELECT DB2_TESDOCUM.TIPOPROTOC, DB2_TESDOCUM.NUMERO, DB2_TESDOCUM.ESERPROTOC, DB2_TESDOCUM.NUMEPROTOC, DB2_TESDOCUM.DATAPROTOC, DB2_TESDOCUM.ESERRIFERI, DB2_TESDOCUM.NUMERIFERI, DB2_TESDOCUM.TIPORIFERI, DB2_TESDOCUM.DATARIFERI, DB2_TESDOCUM.NUMEDOCRIF, DB2_TESDOCUM.DATADOCRIF, DB2_TESDOCUM.ESERCOLLEG, DB2_TESDOCUM.CLI_FOR, DB2_TESDOCUM.DESTINATAR, DB2_TESDOCUM.RGSOC_DEST, DB2_TESDOCUM.INDIR_DEST, DB2_TESDOCUM.LOCAL_DEST, DB2_TESDOCUM.CAP_DEST, DB2_TESDOCUM.ULT_AGG FROM DB2_TESDOCUM WHERE DB2_TESDOCUM.TIPOPROTOC='{0}' AND DB2_TESDOCUM.NUMEPROTOC ='{1}' AND DB2_TESDOCUM.ESERPROTOC ='{2}';", tipoDoc, NumDoc, Anno);
using (OdbcCommand com = new OdbcCommand(comando, conn))
{
using (OdbcDataReader reader = com.ExecuteReader())
{
while (reader.Read())
{
for (int i = 0; i < 19; i++)
{
try
{
rDoc[i] = reader.GetString(i);
}
catch
{
rDoc[i] = "";
}
}
for (int i = 0; i < 11; i++)
{
rCli[i] = "";//readerCli.GetString(i);
}
//string word = reader.GetString(0);
//listBox1.Items.Add(word);
}
// formatto answ...
answ[0] = createUrlDoc(rDoc);
answ[1] = createUrlCli(rCli);
}
}
}
catch (Exception ex)
{
//MessageBox.Show(ex.message);
}
finally
{
conn.Close();
}
return answ;
}
+11 -3
View File
@@ -8,9 +8,17 @@
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<div>
<h1>SyncDoc</h1>
Modalità chiamata: è SEMPRE necessario nell'URL il numero del documento e l'anno! ?DOC=OC0001616&Anno=2015
<ul>
<li>Senza parametri: effettua tutte le chiamate remote</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>
+42 -1
View File
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
@@ -11,7 +13,46 @@ namespace DataUploader
{
protected void Page_Load(object sender, EventArgs e)
{
// verifico se vado in modalità demo o meno...
bool demoMode = false;
string DOC = "";
string Anno = "";
try
{
demoMode = Convert.ToBoolean(Request.QueryString["DemoMode"]);
DOC = Request.QueryString["DOC"];
Anno = Request.QueryString["Anno"];
}
catch
{ }
// recupero numero doc da cod documento + anno...
if (DOC != "" && Anno != "")
{
// recupero i dati da caricare...
string[] urlsUpdate = GestData.proc.getDocsUrls(DOC, Anno);
if (demoMode)
{
lblOut.Text = string.Format("DEMO MODE!<br/>DOC: {0}/{1}", DOC, Anno);
for (int i = 0; i < urlsUpdate.Length; i++)
{
lblOut.Text += string.Format("<br/>{0:000}) {1}", i + 1, urlsUpdate[i]);
}
}
else
{
lblOut.Text = string.Format("Normal MODE!<br/>DOC: {0}/{1}", DOC, Anno);
var client = new WebClient();
for (int i = 0; i < urlsUpdate.Length; i++)
{
try
{
var content = client.DownloadString(urlsUpdate[i]);
}
catch
{ }
}
}
}
}
}
}
+15 -8
View File
@@ -3,17 +3,15 @@
// This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace DataUploader
{
public partial class SyncDoc
{
namespace DataUploader {
public partial class SyncDoc {
/// <summary>
/// form1 control.
/// </summary>
@@ -22,5 +20,14 @@ namespace DataUploader
/// 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;
}
}
Binary file not shown.