public MemoryStream CHECK(MemoryStream xml) { Dictionary<object, Object> param = null; MemoryStream mresult = null; bool demo = false; int r = -1; 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)) { r = CONTEXT.EXECUTE_INT_STORED_PROCEDURE("SESSIONcheck", param, new List<string> { "DEMO" }); } mresult = Serializer.WRITES<Int32>(r); return mresult; } catch (Exception ex) { throw new ApplicationException(String.Empty, ex); } }
public MemoryStream Update_Data(MemoryStream xml) { Dictionary<Object, Object> param = null; MemoryStream mresult = null; bool demo = false; try { param = Serializer.READC<Dictionary<Object, Object>>(xml); demo = ((param.Keys.Any(x => x.Equals("DEMO"))) && (param["DEMO"] != null)) ? Convert.ToBoolean(param["DEMO"]) : false; string command = param["commandName"].ToString(); using (var CONTEXT = new dbAbisEntities((!demo) ? CS : CS_DEMO)) { switch (command) { case "ITEMScopier": CONTEXT.EXECUTE_SCALAR_STORED_PROCEDURE("ITEMScopier", param, new List<string> { "DEMO", "commandName" }); break; case "ITEMSdeplacer": CONTEXT.EXECUTE_SCALAR_STORED_PROCEDURE("ITEMSdeplacer", param, new List<string> { "DEMO", "commandName" }); break; case "ITEMSupdateOrdre": CONTEXT.EXECUTE_SCALAR_STORED_PROCEDURE("ITEMSupdateOrdre", param, new List<string> { "DEMO", "commandName" }); break; case "ITEMSdelete": CONTEXT.EXECUTE_SCALAR_STORED_PROCEDURE("ITEMSdelete", param, new List<string> { "DEMO", "commandName" }); break; case "ITEMSinsert": int id_numcrit = Convert.ToInt32(CONTEXT.EXECUTE_INT_STORED_PROCEDURE("ITEMSinsert", param, new List<string> { "DEMO", "commandName" })); mresult = Serializer.WRITES<int>(id_numcrit); break; case "ITEMS": CONTEXT.EXECUTE_SCALAR_STORED_PROCEDURE("ITEMSupdate", param, new List<string> { "DEMO", "commandName" }); break; case "REPONSES": DataTable dtReponse = param["Reponses"] as DataTable; //Dictionary<Object, Object> paramDelete = new Dictionary<object, object>(); //paramDelete.Add("ID_COMMANDE", param["ID_COMMANDE"]); //paramDelete.Add("ID_CONTACT", param["ID_CLIENT_CONTACT"]); //paramDelete.Add("ID_PRODUIT", param["ID_PRODUIT"]); //paramDelete.Add("ID_NUMCRIT", null); //foreach (DataRow rItem in dtReponse.Rows) //{ // int r = -1; // paramDelete["ID_NUMCRIT"] = rItem["ID_NUMCRIT"]; // r = (CONTEXT.EXECUTE_INT_STORED_PROCEDURE("REPONSESdelete", paramDelete)); //} param.Remove("Reponses"); param.Add("ID_NUMCRIT", null); param.Add("REPONSE", null); param.Add("REPONSE2", null); param.Add("STR_REPONSE", null); foreach (DataRow rReponse in dtReponse.Rows) { param["ID_NUMCRIT"] = rReponse["ID_NUMCRIT"]; param["REPONSE"] = rReponse["REPONSE"]; param["REPONSE2"] = rReponse["REPONSE2"]; param["STR_REPONSE"] = rReponse["STR_REPONSE"]; CONTEXT.EXECUTE_INT_STORED_PROCEDURE("REPONSESupdate", param, new List<string> { "DEMO", "commandName" }); } break; case "ITEMS_DETAIL": DataTable dtItemDetail = param["ItemDetail"] as DataTable; string langue = param["langue"].ToString(); int idNumcrit = Convert.ToInt32(param["ID_NUMCRIT"]); param.Remove("ItemDetail"); param.Remove("langue"); CONTEXT.EXECUTE_SCALAR_STORED_PROCEDURE("ITEMS_DETAILSdelete", param, new List<string> { "DEMO", "commandName" }); Dictionary<Object, Object> paramItemDetail = new Dictionary<object, object>(); foreach (DataRow rItemDetail in dtItemDetail.Rows) { paramItemDetail.Clear(); paramItemDetail.Add("ID_VALEUR_NOM", rItemDetail["ID_VALEUR_NOM"]); paramItemDetail.Add("ID_COMMANDE", rItemDetail["ID_COMMANDE"]); paramItemDetail.Add("valeur1", rItemDetail["valeur"]); paramItemDetail.Add("Valeur2", rItemDetail["VALEUR_NUM"]); paramItemDetail.Add("langue", langue); paramItemDetail.Add("ID_NUMCRIT", idNumcrit); paramItemDetail.Add("perception", DBNull.Value); if (Convert.ToInt32(rItemDetail["ID_VALEUR_NOM"]) != 1) paramItemDetail.Add("id_refer", DBNull.Value); else paramItemDetail.Add("id_refer", rItemDetail["id_refer"]); CONTEXT.EXECUTE_SCALAR_STORED_PROCEDURE("ITEMS_DETAILSinsert", paramItemDetail); } break; case "REPONSES_HISTORIQUE" : CONTEXT.EXECUTE_SCALAR_STORED_PROCEDURE("REPONSES_HISTORIQUEinsert", param, new List<string> { "DEMO", "commandName" }); break; } } return mresult; } catch (Exception ex) { string sParam = ""; foreach (var v in param) { sParam += v.Key + " = " + v.Value + "\r\n"; } File.WriteAllText(@"c:\Users\NICOLAS\Desktop\Refactor\exception.txt", sParam + ex.ToString()); 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); } }
public MemoryStream GetNbSujetAgeSexe(MemoryStream xml) { Dictionary<Object, Object> param = null; MemoryStream mresult = null; bool demo = false; int r = -1; 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)) { r = CONTEXT.EXECUTE_INT_STORED_PROCEDURE("SUJETgetNbByAgeSexeAndIdTypeFoyer", param, new List<string> { "DEMO" }); } mresult = Serializer.WRITES<int>(r); 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 row in (param[p] as DataTable).Rows) { foreach (DataColumn c in (param[p] as DataTable).Columns) { if (row[c.ColumnName] != DBNull.Value) s += "-> " + c.ColumnName + " = " + row[c.ColumnName].ToString() + "\r\n"; } s += "\r\n\r\n"; } } } } //File.WriteAllText(@"c:\inetpub\wwwroot\CYS\SCYS\param.txt", ParamToString(param)); 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 row in (param[p] as DataTable).Rows) { foreach (DataColumn c in (param[p] as DataTable).Columns) { if (row[c.ColumnName] != DBNull.Value) s += "-> " + c.ColumnName + " = " + row[c.ColumnName].ToString() + "\r\n"; } s += "\r\n\r\n"; } } } } // File.WriteAllText(@"c:\inetpub\wwwroot\CYS\SCYS\param.txt", ParamToString(param)); return mresult; throw new ApplicationException(String.Empty, ex); } }
public MemoryStream InsertCommande(MemoryStream xml) { Dictionary<Object, Object> param = null; MemoryStream mresult = null; bool demo = false; int res = 0; 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; List<string> ignorParam = new List<string>(); ignorParam.Add("commandName"); ignorParam.Add("DEMO"); using (var CONTEXT = new dbAbisEntities((!demo) ? CS : CS_DEMO)) { switch (param["commandName"].ToString()) { case "Cout": res = CONTEXT.EXECUTE_INT_STORED_PROCEDURE("PROJETS_COUTSinsert", param, ignorParam); mresult = Serializer.WRITES<int>(res); break; case "Traduction": ignorParam.Add("traduction"); CONTEXT.EXECUTE_INT_STORED_PROCEDURE("PROJETS_LANGUES_TRADUCTIONdelete", param, ignorParam); foreach (DataRow rTraduction in (param["traduction"] as DataTable).Rows) { Dictionary<Object, Object> paramTraduction = new Dictionary<object, object>(); paramTraduction.Add("id_projet", param["id_projet"]); paramTraduction.Add("id_langue", rTraduction["id_langue"]); res = Convert.ToInt32(CONTEXT.EXECUTE_INT_STORED_PROCEDURE("PROJETS_LANGUES_TRADUCTIONinsert", paramTraduction, ignorParam)); mresult = Serializer.WRITES<int>(res); } break; case "Projet": object idProdjet = CONTEXT.EXECUTE_INT_STORED_PROCEDURE("PROJETSinsert", param, ignorParam); int idProj = Convert.ToInt32(idProdjet); mresult = Serializer.WRITES<int>(idProj); break; case "Commande": int idCommande = Convert.ToInt32(CONTEXT.EXECUTE_INT_STORED_PROCEDURE("COMMANDES_ESSAISinsert", param, ignorParam)); mresult = Serializer.WRITES<int>(idCommande); break; case "Produit": ignorParam.Add("produit"); //CONTEXT.EXECUTE_INT_STORED_PROCEDURE("PRODUITSdelete", param, ignorParam); foreach (DataRow rProduit in (param["produit"] as DataTable).Rows) { Dictionary<Object, Object> paramProduit = new Dictionary<object, object>(); paramProduit.Add("id_commande", param["id_commande"]); paramProduit.Add("id_produit", rProduit["id_produit"]); paramProduit.Add("gencod", rProduit["gencod"]); paramProduit.Add("nom", rProduit["nom"]); paramProduit.Add("anonymat", rProduit["anonymat"]); paramProduit.Add("image", rProduit["pathimage"]); paramProduit.Add("poids", rProduit["poids"]); //File.WriteAllText(@"c:\inetpub\wwwroot\CYS\CYS\param.log", ParamToString(paramProduit)); CONTEXT.EXECUTE_INT_STORED_PROCEDURE("PRODUITSinsert", paramProduit); } break; case "Filtre": ignorParam.Add("filtre"); CONTEXT.EXECUTE_INT_STORED_PROCEDURE("COMMANDES_ESSAIS_RAYONSdelete", param, ignorParam); int nb = 0; foreach (DataRow rFiltre in (param["filtre"] as DataTable).Rows) { Dictionary<Object, Object> paramFiltre = new Dictionary<object, object>(); paramFiltre.Add("id_commande", param["id_commande"]); paramFiltre.Add("frequence", rFiltre["frequence"]); paramFiltre.Add("coderay3", rFiltre["coderay3"]); paramFiltre.Add("classement", 0); paramFiltre.Add("taux", 100); paramFiltre.Add("filtre", 1); CONTEXT.EXECUTE_INT_STORED_PROCEDURE("COMMANDES_ESSAIS_RAYONSinsert", paramFiltre); nb++; } break; case "Sexe": CONTEXT.EXECUTE_INT_STORED_PROCEDURE("PROJETS_SEXEinsert", param, ignorParam); break; case "Age": CONTEXT.EXECUTE_INT_STORED_PROCEDURE("PROJETS_AGEinsert", param, ignorParam); break; case "Destinataire": ignorParam.Add("destinataire"); CONTEXT.EXECUTE_INT_STORED_PROCEDURE("PROJETS_DESTINATAIRESdelete", param, ignorParam); foreach (var rDestinataire in (param["destinataire"] as List<CLIENTS_CONTACTS>)) { Dictionary<Object, Object> paramDestinataire = new Dictionary<object, object>(); paramDestinataire.Add("id_commande", param["id_commande"]); paramDestinataire.Add("id_contact", rDestinataire.ID_CONTACT); CONTEXT.EXECUTE_INT_STORED_PROCEDURE("PROJETS_DESTINATAIRESinsert", paramDestinataire, ignorParam); } break; case "Repartition": ignorParam.Add("repartition"); CONTEXT.EXECUTE_INT_STORED_PROCEDURE("PROJETS_SITES_REPARTITIONdelete", param, ignorParam); foreach (DataRow rRepatition in (param["repartition"] as DataTable).Rows) { Dictionary<Object, Object> paramRepartition = new Dictionary<object, object>(); paramRepartition.Add("id_commande", param["id_Commande"]); paramRepartition.Add("id_site", rRepatition["ID_SITE"]); paramRepartition.Add("Demande", rRepatition["TAUX"]); CONTEXT.EXECUTE_INT_STORED_PROCEDURE("PROJETS_SITES_REPARTITIONinsert", paramRepartition); } break; case "Protocole": ignorParam.Add("protocole"); CONTEXT.EXECUTE_INT_STORED_PROCEDURE("FICHIER_DEVISdelete", param, ignorParam); foreach (DataRow rProtocole in (param["protocole"] as DataTable).Rows) { Dictionary<Object, Object> paramRepartition = new Dictionary<object, object>(); paramRepartition.Add("id_commande", param["id_Commande"]); paramRepartition.Add("NomClient", rProtocole["NomClient"]); paramRepartition.Add("Path", rProtocole["path"]); object o = CONTEXT.EXECUTE_INT_STORED_PROCEDURE("FICHIER_DEVISinsert", paramRepartition, ignorParam); } break; case "Statut": CONTEXT.EXECUTE_INT_STORED_PROCEDURE("PROJETS_STATUTinsert", param, ignorParam); break; } } return mresult; } catch (Exception ex) { throw new ApplicationException(String.Empty, ex); } }
public MemoryStream UpdateCommande(MemoryStream xml) { Dictionary<Object, Object> param = null; MemoryStream mresult = null; bool demo = false; int r = -1; 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 "updateDestinataire": r = CONTEXT.EXECUTE_INT_STORED_PROCEDURE("COMMANDES_ESSAISupdate", param, new List<string> { "DEMO", "commandName" }); break; case "updateCommande": r = CONTEXT.EXECUTE_INT_STORED_PROCEDURE("COMMANDES_ESSAISupdate", param, new List<string> { "DEMO", "commandName" }); break; case "updateProjet": r = CONTEXT.EXECUTE_INT_STORED_PROCEDURE("PROJETSupdate", param, new List<string> { "DEMO", "commandName" }); break; case "updateDateFinSaisie": r = CONTEXT.EXECUTE_INT_STORED_PROCEDURE("COMMANDES_ESSAISupdateDateSaisie", param, new List<string> { "DEMO", "commandName" }); break; case "updateDateEnLigne": r = CONTEXT.EXECUTE_INT_STORED_PROCEDURE("COMMANDES_ESSAISupdateDateEnLigne", param, new List<string> { "DEMO", "commandName" }); break; } } mresult = Serializer.WRITES<int>(r); return mresult; } catch (Exception ex) { throw new ApplicationException(String.Empty, ex); } }