Merge branch 'develop'
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
|
||||
@@ -158,6 +158,7 @@
|
||||
</Content>
|
||||
<Content Include="Default.aspx" />
|
||||
<Content Include="demoUpload.aspx" />
|
||||
<Content Include="DocTemplates\Proto.txt" />
|
||||
<Content Include="GestioneDocumenti.aspx" />
|
||||
<Content Include="Help.aspx" />
|
||||
<Content Include="HelpOnLine\content_style\content.css" />
|
||||
@@ -653,6 +654,9 @@
|
||||
<Content Include="NLog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Include="DocTemplates\ETS-Fax.docx" />
|
||||
<None Include="DocTemplates\ETS-Lettera.docx" />
|
||||
<None Include="DocTemplates\ETS-Proto.docx" />
|
||||
<None Include="DocTemplates\PlaceHolder.file" />
|
||||
<None Include="logs\PlaceHolder.file" />
|
||||
<None Include="NLog.xsd">
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<add key="appName" value="ETS-WS" />
|
||||
<add key="SiteName" value="ETS" />
|
||||
<add key="mainRev" value="0.9" />
|
||||
<add key="minRev" value="84" />
|
||||
<add key="minRev" value="85" />
|
||||
<add key="copyRight" value="SteamWare, ETS © 2012" />
|
||||
<add key="tempUplDir" value="~/TempUploads" />
|
||||
<add key="archiveDir" value="~/ArchivioDocs" />
|
||||
|
||||
@@ -182,7 +182,7 @@ namespace ETS_WS
|
||||
/// </summary>
|
||||
/// <param name="idxFile"></param>
|
||||
/// <returns></returns>
|
||||
public string nomeFileFromIdxFile(int idxFile)
|
||||
public static string nomeFileFromIdxFile(int idxFile)
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
@@ -193,6 +193,117 @@ namespace ETS_WS
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// nome del file da idx DB
|
||||
/// </summary>
|
||||
/// <param name="idxFile"></param>
|
||||
/// <returns></returns>
|
||||
public static string nomeFileFullFromIdxFile(int idxFile)
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = utils.obj.taDoc.getByIdxFile(idxFile)[0].Nome;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// protocollo del file da idx DB
|
||||
/// </summary>
|
||||
/// <param name="idxFile"></param>
|
||||
/// <returns></returns>
|
||||
public static string protocolloFromIdxFile(int idxFile)
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = string.Format("{0}-{1}", utils.obj.taDoc.getByIdxFile(idxFile)[0].Numero, utils.obj.taDoc.getByIdxFile(idxFile)[0].Anno);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// effettua operazione di archiviazione file
|
||||
/// </summary>
|
||||
/// <param name="docsData">oggetto metadati documento</param>
|
||||
/// <param name="pathOrig">path origine del file</param>
|
||||
/// <param name="pathDest">path di destinazione del file</param>
|
||||
/// <param name="nomeFile">nome del file da archiviare</param>
|
||||
/// <param name="redattore">redattore</param>
|
||||
/// <returns>restituisce valore INT del nuovo file archiviato</returns>
|
||||
public static int archiviaFile(docMetaDataSet docsData, string pathOrig, string pathDest, string nomeFile, string redattore)
|
||||
{
|
||||
int answ = 0;
|
||||
string autore = ""; // tolto!
|
||||
string numComm = "";
|
||||
string annoComm = "";
|
||||
// ricavo num ed anno commessa...
|
||||
try
|
||||
{
|
||||
numComm = docsData.commessa.Substring(0, docsData.commessa.IndexOf("-"));
|
||||
annoComm = docsData.commessa.Substring(docsData.commessa.IndexOf("-") + 1);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
// salvo su db le info del file...
|
||||
int? newIdxFile = 0;
|
||||
utils.obj.taDoc.insertQuery(nomeFile, pathDest, utils.obj.currUserAD, docsData.reqProto, docsData.dataRic, docsData.dataDoc, numComm, annoComm, docsData.fase, docsData.fonte, docsData.oggetto, docsData.InOut, autore, redattore, docsData.isRed, ref newIdxFile);
|
||||
// salvo i tags!
|
||||
if (newIdxFile > 0)
|
||||
{
|
||||
// se ho tags...
|
||||
if (docsData.tags.Count > 0)
|
||||
{
|
||||
foreach (string tag in docsData.tags)
|
||||
{
|
||||
try
|
||||
{
|
||||
utils.obj.taTags2Doc.Insert((int)newIdxFile, Convert.ToInt32(tag));
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
}
|
||||
answ = (int)newIdxFile;
|
||||
}
|
||||
// ricalcolo nome file
|
||||
string newFileName = WebShipUtils.nomeFileFullFromIdxFile((int)newIdxFile);
|
||||
// sposto file
|
||||
fileMover.obj.muoviFile(pathOrig, pathDest, nomeFile, newFileName, true);
|
||||
// restituisco idxFile...
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// aggiorna file archiviato (prendendo da temp utente!)
|
||||
/// </summary>
|
||||
/// <param name="nomeFile"></param>
|
||||
public void aggiornaFileArchiviato(string nomeFile)
|
||||
{
|
||||
lg.Info("Caricato file {0} per sostituzione", nomeFile);
|
||||
int idxFile = WebShipUtils.mng.idxFileEdit;
|
||||
// effettuo operazioni sostituzione file!
|
||||
docMetaDataSet docsData = WebShipUtils.mng.docMetaFromIdxFile(idxFile);
|
||||
string path = docsData.path;
|
||||
if (path != "")
|
||||
{
|
||||
// calcolo path
|
||||
path = string.Format("{0}{1}", utils.obj.confReadString("archiveDir"), docsData.path);
|
||||
// elimino file vecchio
|
||||
fileMover.obj.eliminaFile(path, WebShipUtils.nomeFileFullFromIdxFile(idxFile));
|
||||
// aggiorno su DB
|
||||
utils.obj.taDoc.updateFile(idxFile, utils.obj.currUserAD, nomeFile, path);
|
||||
lg.Info("Aggiornato in db nome file {0} per sostituzione", nomeFile);
|
||||
// ricalcolo nome file
|
||||
string newFileName = WebShipUtils.nomeFileFullFromIdxFile(idxFile);
|
||||
// sposto file
|
||||
fileMover.obj.muoviFile(WebShipUtils.mng.UserTempPath, path, nomeFile, newFileName, true);
|
||||
lg.Info("Spostato file {0} per sostituzione", nomeFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -244,26 +244,11 @@ namespace ETS_WS.WebUserControls
|
||||
grView.SelectedIndex = grView.EditIndex;
|
||||
WebShipUtils.mng.idxFileEdit = Convert.ToInt32(grView.SelectedDataKey["idxFile"]);
|
||||
string nomeFile = mod_singleFileUpload1.newFileName;
|
||||
lg.Info("Caricato file {0} per sostituzione", nomeFile);
|
||||
int idxFile = WebShipUtils.mng.idxFileEdit;
|
||||
// effettuo operazioni sostituzione file!
|
||||
docMetaDataSet docsData = WebShipUtils.mng.docMetaFromIdxFile(idxFile);
|
||||
string path = docsData.path;
|
||||
if (path != "")
|
||||
{
|
||||
// calcolo path
|
||||
path = string.Format("{0}{1}", utils.obj.confReadString("archiveDir"), docsData.path);
|
||||
// elimino file vecchio
|
||||
fileMover.obj.eliminaFile(path, WebShipUtils.mng.nomeFileFromIdxFile(idxFile));
|
||||
// sposto file
|
||||
fileMover.obj.muoviFile(WebShipUtils.mng.UserTempPath, path, nomeFile);
|
||||
lg.Info("Spostato file {0} per sostituzione", nomeFile);
|
||||
// aggiorno su DB
|
||||
utils.obj.taDoc.updateFile(WebShipUtils.mng.idxFileEdit, utils.obj.currUserAD, nomeFile, path);
|
||||
lg.Info("Aggiornato in db nome file {0} per sostituzione", nomeFile);
|
||||
// update gridview!
|
||||
grView.DataBind();
|
||||
}
|
||||
WebShipUtils.mng.aggiornaFileArchiviato(nomeFile);
|
||||
// update gridview!
|
||||
grView.DataBind();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ namespace ETS_WS.WebUserControls
|
||||
/// <param name="e"></param>
|
||||
protected void rblProto_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
showProto();
|
||||
updateVisual();
|
||||
}
|
||||
/// <summary>
|
||||
/// controlla visualizzazione protocollo
|
||||
@@ -153,7 +153,7 @@ namespace ETS_WS.WebUserControls
|
||||
// popolo!
|
||||
try
|
||||
{
|
||||
answ.reqProto = Convert.ToBoolean(rblInOut.SelectedValue);
|
||||
answ.reqProto = Convert.ToBoolean(rblProto.SelectedValue);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -200,19 +200,16 @@ namespace ETS_WS.WebUserControls
|
||||
// recupero metadati da sessione...
|
||||
docMetaDataSet docsData = WebShipUtils.mng.currMetaData;
|
||||
//check del path
|
||||
string path = docsData.path;
|
||||
string pathDest = docsData.path;
|
||||
// verifico path presente
|
||||
if (path != "")
|
||||
if (pathDest != "")
|
||||
{
|
||||
// aggiunto al path cartella archivio...
|
||||
path = string.Format("{0}{1}", utils.obj.confReadString("archiveDir"), docsData.path);
|
||||
pathDest = string.Format("{0}{1}", utils.obj.confReadString("archiveDir"), docsData.path);
|
||||
// verifico path valido o creo...
|
||||
fileMover.checkDir(path);
|
||||
fileMover.checkDir(pathDest);
|
||||
string nomeFile = "";
|
||||
string autore = ""; // tolto!
|
||||
string redattore = utils.obj.currUserCognomeNome; // usa utente corrente
|
||||
string numComm = "";
|
||||
string annoComm = "";
|
||||
// sposto i files selezionati secondo i dati in sessione
|
||||
foreach (GridViewRow riga in grView.Rows)
|
||||
{
|
||||
@@ -220,36 +217,7 @@ namespace ETS_WS.WebUserControls
|
||||
{
|
||||
// devo salvare file con le info relative...
|
||||
nomeFile = ((HyperLink)riga.FindControl("hlNome")).Text;
|
||||
// ricavo num ed anno commessa...
|
||||
try
|
||||
{
|
||||
numComm = docsData.commessa.Substring(0, docsData.commessa.IndexOf("-"));
|
||||
annoComm = docsData.commessa.Substring(docsData.commessa.IndexOf("-") + 1);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
// salvo su db le info del file...
|
||||
int? newIdxFile = 0;
|
||||
utils.obj.taDoc.insertQuery(nomeFile, path, utils.obj.currUserAD, docsData.reqProto, docsData.dataRic, docsData.dataDoc, numComm, annoComm, docsData.fase, docsData.fonte, docsData.oggetto, docsData.InOut, autore, redattore, docsData.isRed, ref newIdxFile);
|
||||
// salvo i tags!
|
||||
if (newIdxFile > 0)
|
||||
{
|
||||
// se ho tags...
|
||||
if (docsData.tags.Count > 0)
|
||||
{
|
||||
foreach (string tag in docsData.tags)
|
||||
{
|
||||
try
|
||||
{
|
||||
utils.obj.taTags2Doc.Insert((int)newIdxFile, Convert.ToInt32(tag));
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
}
|
||||
}
|
||||
// sposto il file!
|
||||
fileMover.obj.muoviFile(WebShipUtils.mng.UserTempPath, path, nomeFile);
|
||||
WebShipUtils.archiviaFile(docsData, WebShipUtils.mng.UserTempPath, pathDest, nomeFile, redattore);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,12 +22,14 @@
|
||||
<asp:Button ID="btnSubmit" runat="server" Text="Archivia" CssClass="submit" OnClick="btnSubmit_Click" TabIndex="12" />
|
||||
</div>
|
||||
<div class="clearDiv" style="text-align: center; padding: 2px 0px 4px 0px;">
|
||||
generatore:
|
||||
<asp:Button ID="btnStaccaProto" runat="server" Text="Protocollo" ToolTip="stacca e blocca protocollo" CssClass="btnGenProto" TabIndex="13" OnClick="btnStaccaProto_Click" />
|
||||
|
||||
<asp:Button ID="btnGenLettera" runat="server" Text="Lettera" ToolTip="Genera doc tipo lettera" CssClass="btnGenDoc" TabIndex="14" />
|
||||
|
||||
<asp:Button ID="btnGenFax" runat="server" Text="Fax" ToolTip="Genera doc tipo Fax" CssClass="btnGenFax" TabIndex="15" />
|
||||
|
||||
<asp:Button ID="btnGenMail" runat="server" Text="Email" ToolTip="Genera email" CssClass="btnGenMail" TabIndex="16" />
|
||||
<asp:Panel runat="server" ID="pnlGenDocs">
|
||||
generatore protocolli:
|
||||
<asp:Button ID="btnStaccaProto" runat="server" Text="Vuoto" ToolTip="stacca e blocca protocollo" CssClass="btnGenProto" TabIndex="13" OnClick="btnStaccaProto_Click" />
|
||||
|
||||
<asp:Button ID="btnGenLettera" runat="server" Text="Lettera" ToolTip="Genera doc tipo lettera" CssClass="btnGenDoc" TabIndex="14" />
|
||||
|
||||
<asp:Button ID="btnGenFax" runat="server" Text="Fax" ToolTip="Genera doc tipo Fax" CssClass="btnGenFax" TabIndex="15" />
|
||||
|
||||
<asp:Button ID="btnGenMail" runat="server" Text="Email" ToolTip="Genera email" CssClass="btnGenMail" TabIndex="16" />
|
||||
</asp:Panel>
|
||||
</div>
|
||||
|
||||
@@ -33,6 +33,8 @@ namespace ETS_WS.WebUserControls
|
||||
lblFullPath.Text = WebShipUtils.mng.path(WebShipUtils.mng.currMetaData);
|
||||
// verifico attivazione button submin (ovvero ci sono tutti i valori...)
|
||||
btnSubmit.Visible = WebShipUtils.mng.metaPresent;
|
||||
// mostro gen protocolli SE ho richiesta di generare protocollo
|
||||
pnlGenDocs.Visible = (WebShipUtils.mng.metaPresent && WebShipUtils.mng.currMetaData.reqProto);
|
||||
}
|
||||
/// <summary>
|
||||
/// richiesta update
|
||||
@@ -69,7 +71,30 @@ namespace ETS_WS.WebUserControls
|
||||
/// <param name="e"></param>
|
||||
protected void btnStaccaProto_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
// effettua upload del documento "dummy" proto
|
||||
string nomeFile = "ETS-Proto.docx";
|
||||
fileMover.obj.muoviFile("~/DocTemplates/", WebShipUtils.mng.UserTempPath, nomeFile, false);
|
||||
// stacco un nuovo protocollo!
|
||||
docMetaDataSet docsData = WebShipUtils.mng.currMetaData;
|
||||
//check del path
|
||||
string pathDest = docsData.path;
|
||||
if (pathDest != "")
|
||||
{
|
||||
pathDest = string.Format("{0}{1}", utils.obj.confReadString("archiveDir"), docsData.path);
|
||||
string redattore = utils.obj.currUserCognomeNome; // usa utente corrente
|
||||
int idxFile = WebShipUtils.archiviaFile(docsData, WebShipUtils.mng.UserTempPath, pathDest, nomeFile, redattore);
|
||||
// recupero dati documento
|
||||
docsData = WebShipUtils.mng.docMetaFromIdxFile(idxFile);
|
||||
// recupero full path del documento
|
||||
string fullPath = Server.MapPath(string.Format("{0}{1}", pathDest, WebShipUtils.nomeFileFullFromIdxFile(idxFile)));
|
||||
string protocollo = WebShipUtils.protocolloFromIdxFile(idxFile);
|
||||
// prendo il nuovo file generato e sostituisco parte del nome con il codice protocollo
|
||||
officeXmlMan.replaceDocxText(fullPath, "{{Protocollo}}", protocollo);
|
||||
officeXmlMan.replaceDocxText(fullPath, "{{DataDoc}}", docsData.dataDoc.ToShortDateString());
|
||||
officeXmlMan.replaceDocxText(fullPath, "{{Redattore}}", utils.obj.currUserCognomeNome);
|
||||
// link: msdn.microsoft.com/en-us/library/bb508261.aspx
|
||||
}
|
||||
Response.Redirect("~/GestioneDocumenti.aspx");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -57,6 +57,15 @@ namespace ETS_WS.WebUserControls {
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Button btnSubmit;
|
||||
|
||||
/// <summary>
|
||||
/// pnlGenDocs 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.Panel pnlGenDocs;
|
||||
|
||||
/// <summary>
|
||||
/// btnStaccaProto control.
|
||||
/// </summary>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -47,6 +47,7 @@
|
||||
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="DocumentFormat.OpenXml, Version=2.0.5022.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
|
||||
<Reference Include="NLog">
|
||||
<HintPath>..\ETS-WS\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -58,6 +59,7 @@
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DS_Anagrafica.Designer.cs">
|
||||
@@ -76,6 +78,7 @@
|
||||
<DependentUpon>DS_WebScip.xsd</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="fileMover.cs" />
|
||||
<Compile Include="officeXmlMan.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
|
||||
namespace ETS_Data
|
||||
{
|
||||
/// <summary>
|
||||
/// gestioen documetni office/xml
|
||||
/// </summary>
|
||||
public class officeXmlMan
|
||||
{
|
||||
/// <summary>
|
||||
/// fa sostituzioni di testo in un doc .docx
|
||||
/// </summary>
|
||||
/// <param name="fullPathFile"></param>
|
||||
/// <param name="textOrig"></param>
|
||||
/// <param name="textNew"></param>
|
||||
public static void replaceDocxText(string fullPathFile, string textOrig, string textNew)
|
||||
{
|
||||
using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(fullPathFile, true))
|
||||
{
|
||||
// lettura
|
||||
string docText = null;
|
||||
using (StreamReader sr = new StreamReader(wordDoc.MainDocumentPart.GetStream()))
|
||||
{
|
||||
docText = sr.ReadToEnd();
|
||||
}
|
||||
// sostituzione
|
||||
Regex regexText = new Regex(textOrig);
|
||||
docText = regexText.Replace(docText, textNew);
|
||||
// scrittura
|
||||
using (StreamWriter sw = new StreamWriter(wordDoc.MainDocumentPart.GetStream(FileMode.Create)))
|
||||
{
|
||||
sw.Write(docText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user