public MemoryStream Load_Data(MemoryStream xml) { Dictionary<Object, Object> param = null; MemoryStream mresult = null; bool demo = false; OperationContext.Current.OperationCompleted += new EventHandler(delegate(object sender, EventArgs e) { if (mresult != null) mresult.Dispose(); }); try { param = Serializer.READC<Dictionary<Object, Object>>(xml); demo = ((param.Keys.Any(x => x.Equals("DEMO"))) && (param["DEMO"] != null)) ? Convert.ToBoolean(param["DEMO"]) : false; using (var CONTEXT = new dbAbisEntities((!demo) ? CS : CS_DEMO)) { switch (param["commandName"].ToString()) { case "item": List<ITEMS> listItem = CONTEXT.EXECUTE_ENTITY_STORED_PROCEDURE<ITEMS>("ITEMSgetDataByIdCommande", param, new List<string> { "DEMO", "commandName" }); mresult = Serializer.WRITEC<List<ITEMS>>(listItem); break; case "itemdetail": DataTable listItemDetail = CONTEXT.EXECUTE_DATATABLE_STORED_PROCEDURE("ITEMS_DETAILget", param, new List<string> { "DEMO", "commandName" }); mresult = Serializer.WRITEC<DataTable>(listItemDetail); break; case "valeur": break; case "REPONSES": DataTable listReponse = CONTEXT.EXECUTE_DATATABLE_STORED_PROCEDURE("REPONSESget", param, new List<string> { "DEMO", "commandName" }); mresult = Serializer.WRITEC<DataTable>(listReponse); break; case "REPONSES_HISTORIQUE": List<REPONSES_HISTORIQUE> lReponseHistorique = CONTEXT.EXECUTE_ENTITY_STORED_PROCEDURE<REPONSES_HISTORIQUE>("REPONSES_HISTORIQUEget", param, new List<string> { "DEMO", "commandName" }); mresult = Serializer.WRITEC<List<REPONSES_HISTORIQUE>>(lReponseHistorique); break; case "SEANCE_INSCRIPTION": List<SEANCES_INSCRIPTIONS> lSEANCES_INSCRIPTIONS = CONTEXT.EXECUTE_ENTITY_STORED_PROCEDURE<SEANCES_INSCRIPTIONS>("SEANCES_INSCRIPTIONSget", param, new List<string> { "DEMO", "commandName" }); mresult = Serializer.WRITEC<List<SEANCES_INSCRIPTIONS>>(lSEANCES_INSCRIPTIONS); break; } } return mresult; } catch (Exception ex) { File.AppendAllText(@"C:\Users\Public\s.txt", ex.ToString()); throw new ApplicationException(String.Empty, ex); } }
public MemoryStream DATATABLE_GET(MemoryStream xml) { Dictionary<Object, Object> param = null; MemoryStream mresult = null; string proc = null; bool demo = false; DataTable result = null; OperationContext.Current.OperationCompleted += new EventHandler(delegate(object sender, EventArgs args) { if (mresult != null) mresult.Dispose(); }); try { param = Serializer.READC<Dictionary<object, object>>(xml); if (!param.Keys.Any(x => x.Equals("procName"))) throw new Exception(); proc = param["procName"].ToString(); demo = (param.Keys.Any(x => x.Equals("DEMO"))) ? Convert.ToBoolean(param["DEMO"]) : false; lock (LOCKER) { using (var CONTEXT = new dbAbisEntities((!demo) ? CS : CS_DEMO)) { result = CONTEXT.EXECUTE_DATATABLE_STORED_PROCEDURE(proc, param, new List<string> { "DEMO", "procName" }); } } mresult = Serializer.WRITEC<DataTable>(result); return mresult; } catch (Exception ex) { string s = ""; foreach (object p in param.Keys) { if (p != null && param[p] != null && param[p] != DBNull.Value) { if (!(param[p] is DataTable)) { s += p.ToString() + " = " + param[p].ToString() + "\r\n"; } else { s += "DataTable " + (param[p] as DataTable).TableName + ":\r\n"; foreach (DataRow r in (param[p] as DataTable).Rows) { foreach (DataColumn c in (param[p] as DataTable).Columns) { if (r[c.ColumnName] != DBNull.Value) s += "-> " + c.ColumnName + " = " + r[c.ColumnName].ToString() + "\r\n"; } s += "\r\n\r\n"; } } } } throw new ApplicationException(String.Empty, ex); } }
public MemoryStream GET_TRADUCTION_RATE(MemoryStream xml) { Dictionary<object, object> param = null; MemoryStream mresult = null; bool demo = false; Dictionary<object, object> result = null; OperationContext.Current.OperationCompleted += new EventHandler(delegate(object sender, EventArgs args) { if (mresult != null) mresult.Dispose(); }); try { param = Serializer.READC<Dictionary<object, object>>(xml); demo = ((param.Keys.Any(x => x.Equals("DEMO"))) && (param["DEMO"] != null)) ? Convert.ToBoolean(param["DEMO"]) : false; using (var CONTEXT = new dbAbisEntities((!demo) ? CS : CS_DEMO)) { using (var dt = CONTEXT.EXECUTE_DATATABLE_STORED_PROCEDURE("TRADUCTION_RATEget", param, new List<string> { "DEMO" })) { result = dt.Rows.Cast<DataRow>().ToDictionary(x => x["NAME"], y => y["RATE"]); } } mresult = Serializer.WRITEC<Dictionary<object, object>>(result); return mresult; } catch (Exception ex) { throw new ApplicationException(String.Empty, ex); } }
public MemoryStream GetFiliaireByIdClient(MemoryStream xml) { Dictionary<Object, Object> param = null; MemoryStream mresult = null; bool demo = false; DataTable result; OperationContext.Current.OperationCompleted += new EventHandler(delegate(object sender, EventArgs e) { if (mresult != null) mresult.Dispose(); }); try { param = Serializer.READC<Dictionary<object, object>>(xml); demo = ((param.Keys.Any(x => x.Equals("DEMO"))) && (param["DEMO"] != null)) ? Convert.ToBoolean(param["DEMO"]) : false; using (var CONTEXT = new dbAbisEntities((!demo) ? CS : CS_DEMO)) { result = CONTEXT.EXECUTE_DATATABLE_STORED_PROCEDURE("COMMANDES_ESSAISgetFiliaireByIdClient", param, new List<string> { "DEMO" }); } mresult = Serializer.WRITEC<DataTable>(result); return mresult; } catch (Exception ex) { throw new ApplicationException(String.Empty, ex); } }
public MemoryStream commande_loader(MemoryStream xml) { Dictionary<Object, Object> param = null; MemoryStream mresult = null; bool demo = false; List<COMMANDES_ESSAIS> result = null; try { OperationContext.Current.OperationCompleted += new EventHandler(delegate(object sender, EventArgs e) { if (mresult != null) mresult.Dispose(); }); param = Serializer.READC<Dictionary<Object, Object>>(xml); demo = ((param.Keys.Any(x => x.Equals("DEMO"))) && (param["DEMO"] != null)) ? Convert.ToBoolean(param["DEMO"]) : false; string cn = param["commandName"].ToString(); using (var CONTEXT = new dbAbisEntities((!demo) ? CS : CS_DEMO)) { switch (param["commandName"].ToString()) { case "Traduction": /*List<PROJETS_LANGUES_TRADUCTION> listTraduction = EXECUTE_ENTITY_STORED_PROCEDURE<PROJETS_LANGUES_TRADUCTION>("PROJETS_LANGUES_TRADUCTIONgetByIdCommande", param); mresult = Serializer.WRITEC<List<PROJETS_LANGUES_TRADUCTION>>( listTraduction);*/ break; case "SpeakIn": bool b = Convert.ToBoolean(CONTEXT.EXECUTE_INT_STORED_PROCEDURE("LANGUESspeakIn", param, new List<string> { "DEMO", "commandName" })); mresult = Serializer.WRITES<bool>(b); break; case "Langue": List<LANGUE> listlANGUE = CONTEXT.EXECUTE_ENTITY_STORED_PROCEDURE<LANGUE>("LANGUESgetByIdPays", param, new List<string> { "DEMO", "commandName" }); mresult = Serializer.WRITEC<List<LANGUE>>(listlANGUE); break; case "CoefProjet": DataTable resultCoefCout = CONTEXT.EXECUTE_DATATABLE_STORED_PROCEDURE("PROJETS_COUTSgetByIdCommande", param, new List<string> { "DEMO", "commandName" }); mresult = Serializer.WRITEC<DataTable>(resultCoefCout); break; case "CoefClient": DataTable resultCoefClient = CONTEXT.EXECUTE_DATATABLE_STORED_PROCEDURE("getCoefClient", param, new List<string> { "DEMO", "commandName" }); mresult = Serializer.WRITEC<DataTable>(resultCoefClient); break; case "protocole": DataTable resultProtocole = CONTEXT.EXECUTE_DATATABLE_STORED_PROCEDURE("FICHIER_DEVISgetByIdCommande", param, new List<string> { "DEMO", "commandName" }); mresult = Serializer.WRITEC<DataTable>(resultProtocole); break; case "filtre": DataTable resultFiltre = CONTEXT.EXECUTE_DATATABLE_STORED_PROCEDURE("COMMANDES_ESSAIS_RAYONSgetByIdCommande", param, new List<string> { "DEMO", "commandName" }); mresult = Serializer.WRITEC<DataTable>(resultFiltre); break; case "produit": List<PRODUITS> listProduit = CONTEXT.EXECUTE_ENTITY_STORED_PROCEDURE<PRODUITS>("PRODUITSgetByIdCommande", param, new List<string> { "DEMO", "commandName" }); mresult = Serializer.WRITEC<List<PRODUITS>>(listProduit); break; case "repartition": List<PROJETS_SITES_REPARTITION> listRepartition = CONTEXT.EXECUTE_ENTITY_STORED_PROCEDURE<PROJETS_SITES_REPARTITION>("PROJETS_SITES_REPARTITIONgetByIdCommande", param, new List<string> { "DEMO", "commandName" }); foreach (var v in listRepartition) { CONTEXT.AttachToThis(v); v.SITE_NOMReference.Load(); } mresult = Serializer.WRITEC<List<PROJETS_SITES_REPARTITION>>(listRepartition); break; case "age": List<PROJETS_AGE> listAge = CONTEXT.EXECUTE_ENTITY_STORED_PROCEDURE<PROJETS_AGE>("PROJETS_AGEget", param, new List<string> { "DEMO", "commandName" }); mresult = Serializer.WRITEC<List<PROJETS_AGE>>(listAge); break; case "sexe": List<PROJETS_SEXE> listSexe = CONTEXT.EXECUTE_ENTITY_STORED_PROCEDURE<PROJETS_SEXE>("PROJETS_SEXEget", param, new List<string> { "DEMO", "commandName" }); mresult = Serializer.WRITEC<List<PROJETS_SEXE>>(listSexe); break; case "destinataire": List<CLIENTS_CONTACTS> listDest = CONTEXT.EXECUTE_ENTITY_STORED_PROCEDURE<CLIENTS_CONTACTS>("PROJETS_DESTINATAIRESget", param, new List<string> { "DEMO", "commandName" }); mresult = Serializer.WRITEC<List<CLIENTS_CONTACTS>>(listDest); break; case "liste": result = CONTEXT.EXECUTE_ENTITY_STORED_PROCEDURE<COMMANDES_ESSAIS>("COMMANDES_ESSAIS_GetByIdContact", param, new List<string> { "DEMO", "commandName" }); mresult = Serializer.WRITEC<List<COMMANDES_ESSAIS>>(result); break; case "commande": result = CONTEXT.EXECUTE_ENTITY_STORED_PROCEDURE<COMMANDES_ESSAIS>("COMMANDES_ESSAIS_GetByIdCommande", param, new List<string> { "DEMO", "commandName" }); if (result.Count() != 0) { COMMANDES_ESSAIS commande = result.First(); //CONTEXT.AttachToThis(commande); //commande.PROJETSReference.Load(); mresult = Serializer.WRITEC<COMMANDES_ESSAIS>(commande); } break; } } return mresult; } catch (Exception ex) { throw new ApplicationException(String.Empty, ex); } }