diff --git a/C2P/C2P.csproj b/C2P/C2P.csproj index 841d5d4..7abdf48 100644 --- a/C2P/C2P.csproj +++ b/C2P/C2P.csproj @@ -295,19 +295,19 @@ Reference.svcmap - - Reference.svcmap - Reference.svcmap - - - - + + Reference.svcmap + + + + + WCF Proxy Generator Reference.cs - + @@ -387,7 +387,7 @@ Designer - + Web.config diff --git a/C2P/Service References/RemoteWS/C2P.RemoteWS.testResponse.datasource b/C2P/Service References/RemoteWS/C2P.RemoteWS.updateLemmaResponse.datasource similarity index 55% rename from C2P/Service References/RemoteWS/C2P.RemoteWS.testResponse.datasource rename to C2P/Service References/RemoteWS/C2P.RemoteWS.updateLemmaResponse.datasource index 69205b7..3e7c1b0 100644 --- a/C2P/Service References/RemoteWS/C2P.RemoteWS.testResponse.datasource +++ b/C2P/Service References/RemoteWS/C2P.RemoteWS.updateLemmaResponse.datasource @@ -5,6 +5,6 @@ Renaming the file extension or editing the content of this file may cause the file to be unrecognizable by the program. --> - - C2P.RemoteWS.testResponse, Service References.RemoteWS.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null + + C2P.RemoteWS.updateLemmaResponse, Service References.RemoteWS.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null \ No newline at end of file diff --git a/C2P/Service References/RemoteWS/Reference.cs b/C2P/Service References/RemoteWS/Reference.cs index 46ad03d..82bb4c1 100644 --- a/C2P/Service References/RemoteWS/Reference.cs +++ b/C2P/Service References/RemoteWS/Reference.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34011 +// Runtime Version:4.0.30319.34014 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -24,13 +24,6 @@ namespace C2P.RemoteWS { [System.ServiceModel.ServiceContractAttribute(ConfigurationName="RemoteWS.WS_dataSoap")] public interface WS_dataSoap { - // CODEGEN: Generating message contract since element name prefixText from namespace http://tempuri.org/ is not marked nillable - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/test", ReplyAction="*")] - C2P.RemoteWS.testResponse test(C2P.RemoteWS.testRequest request); - - [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/test", ReplyAction="*")] - System.Threading.Tasks.Task testAsync(C2P.RemoteWS.testRequest request); - // CODEGEN: Generating message contract since element name prefixText from namespace http://tempuri.org/ is not marked nillable [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Clients", ReplyAction="*")] C2P.RemoteWS.ClientsResponse Clients(C2P.RemoteWS.ClientsRequest request); @@ -58,74 +51,13 @@ namespace C2P.RemoteWS { [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/Vocabolario", ReplyAction="*")] System.Threading.Tasks.Task VocabolarioAsync(C2P.RemoteWS.VocabolarioRequest request); - } - - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - [System.ServiceModel.MessageContractAttribute(IsWrapped=false)] - public partial class testRequest { - [System.ServiceModel.MessageBodyMemberAttribute(Name="test", Namespace="http://tempuri.org/", Order=0)] - public C2P.RemoteWS.testRequestBody Body; + // CODEGEN: Generating message contract since element name lingua from namespace http://tempuri.org/ is not marked nillable + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/updateLemma", ReplyAction="*")] + C2P.RemoteWS.updateLemmaResponse updateLemma(C2P.RemoteWS.updateLemmaRequest request); - public testRequest() { - } - - public testRequest(C2P.RemoteWS.testRequestBody Body) { - this.Body = Body; - } - } - - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - [System.Runtime.Serialization.DataContractAttribute(Namespace="http://tempuri.org/")] - public partial class testRequestBody { - - [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=0)] - public string prefixText; - - public testRequestBody() { - } - - public testRequestBody(string prefixText) { - this.prefixText = prefixText; - } - } - - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - [System.ServiceModel.MessageContractAttribute(IsWrapped=false)] - public partial class testResponse { - - [System.ServiceModel.MessageBodyMemberAttribute(Name="testResponse", Namespace="http://tempuri.org/", Order=0)] - public C2P.RemoteWS.testResponseBody Body; - - public testResponse() { - } - - public testResponse(C2P.RemoteWS.testResponseBody Body) { - this.Body = Body; - } - } - - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - [System.Runtime.Serialization.DataContractAttribute(Namespace="http://tempuri.org/")] - public partial class testResponseBody { - - [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=0)] - public C2P.RemoteWS.ArrayOfString testResult; - - public testResponseBody() { - } - - public testResponseBody(C2P.RemoteWS.ArrayOfString testResult) { - this.testResult = testResult; - } + [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/updateLemma", ReplyAction="*")] + System.Threading.Tasks.Task updateLemmaAsync(C2P.RemoteWS.updateLemmaRequest request); } [System.Diagnostics.DebuggerStepThroughAttribute()] @@ -393,6 +325,82 @@ namespace C2P.RemoteWS { } } + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ServiceModel.MessageContractAttribute(IsWrapped=false)] + public partial class updateLemmaRequest { + + [System.ServiceModel.MessageBodyMemberAttribute(Name="updateLemma", Namespace="http://tempuri.org/", Order=0)] + public C2P.RemoteWS.updateLemmaRequestBody Body; + + public updateLemmaRequest() { + } + + public updateLemmaRequest(C2P.RemoteWS.updateLemmaRequestBody Body) { + this.Body = Body; + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.Runtime.Serialization.DataContractAttribute(Namespace="http://tempuri.org/")] + public partial class updateLemmaRequestBody { + + [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=0)] + public string lingua; + + [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=1)] + public string lemma; + + [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=2)] + public string traduzione; + + public updateLemmaRequestBody() { + } + + public updateLemmaRequestBody(string lingua, string lemma, string traduzione) { + this.lingua = lingua; + this.lemma = lemma; + this.traduzione = traduzione; + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.ServiceModel.MessageContractAttribute(IsWrapped=false)] + public partial class updateLemmaResponse { + + [System.ServiceModel.MessageBodyMemberAttribute(Name="updateLemmaResponse", Namespace="http://tempuri.org/", Order=0)] + public C2P.RemoteWS.updateLemmaResponseBody Body; + + public updateLemmaResponse() { + } + + public updateLemmaResponse(C2P.RemoteWS.updateLemmaResponseBody Body) { + this.Body = Body; + } + } + + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + [System.Runtime.Serialization.DataContractAttribute(Namespace="http://tempuri.org/")] + public partial class updateLemmaResponseBody { + + [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false, Order=0)] + public string updateLemmaResult; + + public updateLemmaResponseBody() { + } + + public updateLemmaResponseBody(string updateLemmaResult) { + this.updateLemmaResult = updateLemmaResult; + } + } + [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] public interface WS_dataSoapChannel : C2P.RemoteWS.WS_dataSoap, System.ServiceModel.IClientChannel { } @@ -420,31 +428,6 @@ namespace C2P.RemoteWS { base(binding, remoteAddress) { } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - C2P.RemoteWS.testResponse C2P.RemoteWS.WS_dataSoap.test(C2P.RemoteWS.testRequest request) { - return base.Channel.test(request); - } - - public C2P.RemoteWS.ArrayOfString test(string prefixText) { - C2P.RemoteWS.testRequest inValue = new C2P.RemoteWS.testRequest(); - inValue.Body = new C2P.RemoteWS.testRequestBody(); - inValue.Body.prefixText = prefixText; - C2P.RemoteWS.testResponse retVal = ((C2P.RemoteWS.WS_dataSoap)(this)).test(inValue); - return retVal.Body.testResult; - } - - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] - System.Threading.Tasks.Task C2P.RemoteWS.WS_dataSoap.testAsync(C2P.RemoteWS.testRequest request) { - return base.Channel.testAsync(request); - } - - public System.Threading.Tasks.Task testAsync(string prefixText) { - C2P.RemoteWS.testRequest inValue = new C2P.RemoteWS.testRequest(); - inValue.Body = new C2P.RemoteWS.testRequestBody(); - inValue.Body.prefixText = prefixText; - return ((C2P.RemoteWS.WS_dataSoap)(this)).testAsync(inValue); - } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] C2P.RemoteWS.ClientsResponse C2P.RemoteWS.WS_dataSoap.Clients(C2P.RemoteWS.ClientsRequest request) { return base.Channel.Clients(request); @@ -542,5 +525,34 @@ namespace C2P.RemoteWS { inValue.Body = new C2P.RemoteWS.VocabolarioRequestBody(); return ((C2P.RemoteWS.WS_dataSoap)(this)).VocabolarioAsync(inValue); } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + C2P.RemoteWS.updateLemmaResponse C2P.RemoteWS.WS_dataSoap.updateLemma(C2P.RemoteWS.updateLemmaRequest request) { + return base.Channel.updateLemma(request); + } + + public string updateLemma(string lingua, string lemma, string traduzione) { + C2P.RemoteWS.updateLemmaRequest inValue = new C2P.RemoteWS.updateLemmaRequest(); + inValue.Body = new C2P.RemoteWS.updateLemmaRequestBody(); + inValue.Body.lingua = lingua; + inValue.Body.lemma = lemma; + inValue.Body.traduzione = traduzione; + C2P.RemoteWS.updateLemmaResponse retVal = ((C2P.RemoteWS.WS_dataSoap)(this)).updateLemma(inValue); + return retVal.Body.updateLemmaResult; + } + + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)] + System.Threading.Tasks.Task C2P.RemoteWS.WS_dataSoap.updateLemmaAsync(C2P.RemoteWS.updateLemmaRequest request) { + return base.Channel.updateLemmaAsync(request); + } + + public System.Threading.Tasks.Task updateLemmaAsync(string lingua, string lemma, string traduzione) { + C2P.RemoteWS.updateLemmaRequest inValue = new C2P.RemoteWS.updateLemmaRequest(); + inValue.Body = new C2P.RemoteWS.updateLemmaRequestBody(); + inValue.Body.lingua = lingua; + inValue.Body.lemma = lemma; + inValue.Body.traduzione = traduzione; + return ((C2P.RemoteWS.WS_dataSoap)(this)).updateLemmaAsync(inValue); + } } } diff --git a/C2P/Service References/RemoteWS/WS_data.wsdl b/C2P/Service References/RemoteWS/WS_data.wsdl index b289a47..36bcd31 100644 --- a/C2P/Service References/RemoteWS/WS_data.wsdl +++ b/C2P/Service References/RemoteWS/WS_data.wsdl @@ -2,25 +2,6 @@ - - - - - - - - - - - - - - - - - - - @@ -35,6 +16,11 @@ + + + + + @@ -73,14 +59,24 @@ + + + + + + + + + + + + + + + + - - - - - - @@ -105,11 +101,13 @@ + + + + + + - - - - @@ -126,18 +124,13 @@ + + + + - - - - - - - - - @@ -174,18 +167,18 @@ + + + + + + + + + - - - - - - - - - @@ -222,6 +215,15 @@ + + + + + + + + + diff --git a/C2P/Services/WS_data.asmx.cs b/C2P/Services/WS_data.asmx.cs index 11aad0f..39b7e03 100644 --- a/C2P/Services/WS_data.asmx.cs +++ b/C2P/Services/WS_data.asmx.cs @@ -19,21 +19,6 @@ namespace C2P.Services [System.Web.Script.Services.ScriptService] public class WS_data : System.Web.Services.WebService { - - [WebMethod] - [ScriptMethod(ResponseFormat = ResponseFormat.Json)] - public string[] test(string prefixText) - { - //TODO: implement real search here! - // dummy implementation - List output = new List(); - for (int i = 0; i < 10; i++) - { - output.Add(string.Format("{0}{1}#{1}", prefixText, i)); - } - return output.ToArray(); - } - [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string[] Clients(string prefixText) @@ -99,7 +84,15 @@ namespace C2P.Services } return suggerimenti.ToArray(); } - + + [WebMethod] + [ScriptMethod(ResponseFormat = ResponseFormat.Json)] + public string updateLemma(string lingua, string lemma, string traduzione) + { + string answ = ""; + selDataVoc.mgr.upsertLemma(lingua, lemma, traduzione); + return answ; + } } } diff --git a/C2P/WebUserControls/mod_SyncVoc.ascx b/C2P/WebUserControls/mod_SyncVoc.ascx index 4b1ece1..aabf698 100644 --- a/C2P/WebUserControls/mod_SyncVoc.ascx +++ b/C2P/WebUserControls/mod_SyncVoc.ascx @@ -1,4 +1,39 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="mod_SyncVoc.ascx.cs" Inherits="C2P.WebUserControls.mod_SyncVoc" %> - -
- + +
+
+
+

Sync Db Vocabolario

+ +
+
+
+
Lemmi Locali
+
+ +
+
+
+
Lemmi Remoti
+
+ +
+
+
+
Update Locali
+
+ +
+
+
+
Insert Remoti
+
+ +
+
+
+
+ +
+
+
diff --git a/C2P/WebUserControls/mod_SyncVoc.ascx.cs b/C2P/WebUserControls/mod_SyncVoc.ascx.cs index 42f906e..d7a0321 100644 --- a/C2P/WebUserControls/mod_SyncVoc.ascx.cs +++ b/C2P/WebUserControls/mod_SyncVoc.ascx.cs @@ -10,9 +10,32 @@ namespace C2P.WebUserControls { public partial class mod_SyncVoc : System.Web.UI.UserControl { + /// + /// wrapper classe WS remota + /// + protected RemoteWS.WS_dataSoapClient clientWS = new RemoteWS.WS_dataSoapClient(); + /// + /// dati remoti + /// + protected List remoteData; + protected void Page_Load(object sender, EventArgs e) { + if (!Page.IsPostBack) + { + reloadData(); + } + } + private void reloadData() + { + DataWrap.DW.resetVocabolario(); + // carico dati locali... + lblNumLoc.Text = string.Format("{0} record", DataWrap.DW.dictVocabolario.Count); + + // carico dati remoti + remoteData = clientWS.Vocabolario(); + lblNumRem.Text = string.Format("{0} record", remoteData.Count); } /// /// (Ri)carico dati vocabolario remoto @@ -21,25 +44,50 @@ namespace C2P.WebUserControls /// protected void btnSync_Click(object sender, EventArgs e) { + reloadData(); + // inizio processo... DateTime inizio = DateTime.Now; - RemoteWS.WS_dataSoapClient client = new RemoteWS.WS_dataSoapClient(); - List risultati = client.Vocabolario(); // ciclo sui risultati... string[] termine; - int fatti = 0; - foreach (string risultato in risultati) + int updLoc = 0; + int insRem = 0; + // step 1: update da remoto a locale + foreach (string risultato in remoteData) { + // cerco termini splittando try { termine = risultato.Split('#'); - // cerco il termine nel nostro db e faccio upsert (always) - selDataVoc.mgr.upsertLemma(termine[0], termine[1], termine[2]); - fatti++; + // verifico se il termine sia cambiato... + if (DataWrap.DW.dictVocabolario[termine[0] + "#" + termine[1]] != termine[2] || DataWrap.DW.dictVocabolario[termine[0] + "#" + termine[1]] == null) + { + // faccio upsert + selDataVoc.mgr.upsertLemma(termine[0], termine[1], termine[2]); + updLoc++; + } } catch { } } + // step 2: caricamento termini NUOVI locali in db remoto... + string trovato = ""; + foreach (string key in DataWrap.DW.dictVocabolario.Keys) + { + // cerco la chiave nell'elenco... + trovato = remoteData.Find(x => x.StartsWith(key)); + // se non la trovo chiamo metodo di upsert! + if (trovato == "" || trovato == null) + { + termine = key.Split('#'); + clientWS.updateLemma(termine[0], termine[1], DataWrap.DW.dictVocabolario[key]); + insRem++; + } + } // mostro esito! - lblRes.Text = string.Format("Sync effettuato: {0} termini, {1} ms", fatti, DateTime.Now.Subtract(inizio).TotalMilliseconds); + lblUpdLoc.Text = string.Format("{0} termini aggiornati in locale", updLoc); + lblInsRem.Text = string.Format("{0} termini nuovi caricati in remoto", insRem); + lblRes.Text = string.Format("Sync effettuato: {0} ms", DateTime.Now.Subtract(inizio).TotalMilliseconds); + // ricarico dati locali e remoti + reloadData(); } } } \ No newline at end of file diff --git a/C2P/WebUserControls/mod_SyncVoc.ascx.designer.cs b/C2P/WebUserControls/mod_SyncVoc.ascx.designer.cs index 7b5eb1d..70ecd5e 100644 --- a/C2P/WebUserControls/mod_SyncVoc.ascx.designer.cs +++ b/C2P/WebUserControls/mod_SyncVoc.ascx.designer.cs @@ -21,6 +21,42 @@ namespace C2P.WebUserControls { /// protected global::System.Web.UI.WebControls.Button btnSync; + /// + /// lblNumLoc control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblNumLoc; + + /// + /// lblNumRem control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblNumRem; + + /// + /// lblUpdLoc control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblUpdLoc; + + /// + /// lblInsRem control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label lblInsRem; + /// /// lblRes control. /// diff --git a/C2P/bin/C2P.dll b/C2P/bin/C2P.dll index 25f08c8..c917bcf 100644 Binary files a/C2P/bin/C2P.dll and b/C2P/bin/C2P.dll differ diff --git a/C2P/bin/C2P_Data.dll b/C2P/bin/C2P_Data.dll index d463d15..788955f 100644 Binary files a/C2P/bin/C2P_Data.dll and b/C2P/bin/C2P_Data.dll differ diff --git a/C2P/bin/SteamWare.dll b/C2P/bin/SteamWare.dll index b81e13c..8f9bdd1 100644 Binary files a/C2P/bin/SteamWare.dll and b/C2P/bin/SteamWare.dll differ diff --git a/C2P_Data/bin/Release/C2P_Data.dll b/C2P_Data/bin/Release/C2P_Data.dll index 3b59bb3..895a39c 100644 Binary files a/C2P_Data/bin/Release/C2P_Data.dll and b/C2P_Data/bin/Release/C2P_Data.dll differ diff --git a/C2P_Data/bin/Release/SteamWare.dll b/C2P_Data/bin/Release/SteamWare.dll index 0dcaf99..43fea22 100644 Binary files a/C2P_Data/bin/Release/SteamWare.dll and b/C2P_Data/bin/Release/SteamWare.dll differ