////////////////////////////////////////////////// /// @brief Récupère la configuration du visiteur ////////////////////////////////////////////////// public void Visiteur_Configuration() { string req = "SELECT config_id FROM wmsUSERAGENT WHERE config_useragent=@USERAGENT"; DataServices oData = new DataServices(VisiteurDsn, req); oData.AddParameter("@USERAGENT", SqlDbType.NVarChar, 1000, ParameterDirection.Input, VisiteurUserAgent, "config_useragent"); oData.GetStructures(); if (!oData.UtilityDataExiste) { req = "INSERT INTO wmsUSERAGENT (config_OS,config_navigateur,config_version,config_screen,config_cookies,config_crawler, config_useragent) VALUES (@PLATFORM,@NAVIGATEUR,@VERSION,@SCREENW,@COOKIE,@CRAWLER,@USERAGENT)"; oData.UtilitySqlCommand = new SqlCommand(req, oData.UtilitySqlConnection); oData.AddParameter("@PLATFORM", SqlDbType.VarChar, 50, ParameterDirection.Input, VisiteurBrowser.Platform, "config_OS"); oData.AddParameter("@NAVIGATEUR", SqlDbType.VarChar, 50, ParameterDirection.Input, VisiteurBrowser.Type, "config_navigateur"); oData.AddParameter("@VERSION", SqlDbType.VarChar, 50, ParameterDirection.Input, VisiteurBrowser.Version, "config_version"); oData.AddParameter("@SCREENW", SqlDbType.Int, 0, ParameterDirection.Input, VisiteurBrowser.ScreenPixelsWidth, "config_screen"); oData.AddParameter("@COOKIE", SqlDbType.Int, 0, ParameterDirection.Input, VisiteurBrowser.Cookies, "config_cookies"); oData.AddParameter("@CRAWLER", SqlDbType.Int, 0, ParameterDirection.Input, VisiteurBrowser.Crawler, "config_crawler"); oData.AddParameter("@USERAGENT", SqlDbType.NVarChar, 1000, ParameterDirection.Input, VisiteurUserAgent, "config_useragent"); oData.Execute(DataServices.ExecutionMode.INSERT); _config_id = (int)oData.UtilityDataId; } else { _config_id = (int)oData.UtilityDataField; } oData.Dispose(); }
////////////////////////////////////////////////// /// @brief Desc ////////////////////////////////////////////////// private void ChargeData(string _layer, string _dsn) { var oData = new DataServices(_dsn, "select * from wmsCOMPOSANT_ATTRIBUT WHERE composant_id=" + _layer); oData.GetStructures(); LayerData = oData.UtilityDataTable; oData.Dispose(); }
////////////////////////////////////////////////// /// @brief Desc ////////////////////////////////////////////////// private DataTable GetDataTable(string requete) { DataTable _result; oData = new DataServices(_dsn, requete); oData.GetStructures(); _result = oData.UtilityDataTable; oData.Dispose(); return(_result); }
////////////////////////////////////////////////// /// @brief Desc ////////////////////////////////////////////////// private DataTable Charge(string _slide, string _dsn) { var oData = new DataServices(_dsn, _slide); oData.GetStructures(); DataTable dataTable = oData.UtilityDataTable; oData.Dispose(); return(dataTable); }
////////////////////////////////////////////////// /// @brief Enregistre la visite ////////////////////////////////////////////////// public void Visiteur_Enregistre_Visite(string _session) { string pays_nom; double code_ip; string req; DataServices oData; Visiteur_Configuration(); try { string[] IP = VisiteurAddress.Split('.'); code_ip = (16777216 * Convert.ToDouble((IP[0]))) + (65536 * Convert.ToDouble((IP[1]))) + (256 * Convert.ToDouble((IP[2]))) + Convert.ToDouble((IP[3])); req = "SELECT TOP 1 iplocation_pays FROM wmsIPLOCATION WHERE iplocation_code_debut <=@DEBUT AND iplocation_code_fin >= @FIN"; oData = new DataServices(VisiteurDsn, req); oData.AddParameter("@DEBUT", SqlDbType.Float, 0, ParameterDirection.Input, code_ip, "iplocation_code_debut"); oData.AddParameter("@FIN", SqlDbType.Float, 0, ParameterDirection.Input, code_ip, "iplocation_code_fin"); oData.GetStructures(); if (oData.UtilityDataExiste) { pays_nom = oData.UtilityDataField.ToString(); } else { pays_nom = "N/A"; code_ip = 0; } } catch { pays_nom = "N/A"; code_ip = 0; } req = "INSERT INTO wmsVISITE (visite_date_debut,visite_session,visiteur_id,config_id,visite_host_ip,visite_site,visite_code,visite_pays,visite_debut,visite_fin,visite_duree,visite_pages,visite_pages_in) "; req += "values (@DATE,@SESSION,@VISITEUR,@CONFIG,@IP,@SITE,@VISITE,@PAYS,@DEBUT,@FIN,@DUREE,@PAGES,@PAGESINT)"; oData = new DataServices(VisiteurDsn, req); oData.AddParameter("@DATE", SqlDbType.DateTime, 0, ParameterDirection.Input, DateTime.Now, "visite_date_debut"); oData.AddParameter("@VISITEUR", SqlDbType.Int, 0, ParameterDirection.Input, VisiteurId, "visiteur_id"); oData.AddParameter("@CONFIG", SqlDbType.Int, 0, ParameterDirection.Input, _config_id, "config_id"); oData.AddParameter("@IP", SqlDbType.VarChar, 20, ParameterDirection.Input, VisiteurAddress, "visite_host_ip"); oData.AddParameter("@SITE", SqlDbType.Int, 0, ParameterDirection.Input, VisiteurSite, "visite_site"); oData.AddParameter("@VISITE", SqlDbType.Float, 0, ParameterDirection.Input, code_ip, "visite_code"); oData.AddParameter("@PAYS", SqlDbType.VarChar, 50, ParameterDirection.Input, pays_nom, "visite_pays"); oData.AddParameter("@SESSION", SqlDbType.VarChar, 50, ParameterDirection.Input, _session, "visite_session"); oData.AddParameter("@DEBUT", SqlDbType.DateTime, 0, ParameterDirection.Input, DateTime.Now, "visite_debut"); oData.AddParameter("@FIN", SqlDbType.DateTime, 0, ParameterDirection.Input, DateTime.Now, "visite_fin"); oData.AddParameter("@DUREE", SqlDbType.Int, 0, ParameterDirection.Input, 0, "visite_duree"); oData.AddParameter("@PAGES", SqlDbType.Int, 0, ParameterDirection.Input, 0, "visite_pages_in"); oData.AddParameter("@PAGESINT", SqlDbType.Int, 0, ParameterDirection.Input, 0, "visite_pages"); oData.Execute(DataServices.ExecutionMode.INSERT); VisiteurVisiteId = (int)oData.UtilityDataId; oData.Dispose(); }
////////////////////////////////////////////////// /// @brief Charge le chemin de la page d'accueil pour le profil et pour le site sélectionné ////////////////////////////////////////////////// private string Charge_Visiteur_Homepage() { string _accueil = "/"; string req = "select page_url FROM wmsPAGE where page_id = (select page_id from crmDROIT_SITE where site_id=@SITE AND profil_id=@PROFIL)"; DataServices oData = new DataServices(VisiteurDsn, req); oData.AddParameter("@PROFIL", SqlDbType.Int, 0, ParameterDirection.Input, VisiteurProfil, "profil_id"); oData.AddParameter("@SITE", SqlDbType.Int, 0, ParameterDirection.Input, VisiteurSite, "site_id"); oData.GetStructures(); _accueil += oData.UtilityDataField; oData.Dispose(); return(_accueil); }
////////////////////////////////////////////////// /// @brief Charge la table avec les données attendues ////////////////////////////////////////////////// private DataTable Charge(string _requete, int _site = -1, string _champ = null) { oData = new DataServices(_dsn, _requete); oData.UtilitySqlCommand = new SqlCommand(_requete, oData.UtilitySqlConnection); if (_champ != null) { oData.AddParameter("@SITE", SqlDbType.Int, 0, ParameterDirection.Input, _site, _champ); } oData.GetStructures(); oData.Dispose(); if (_requete.IndexOf("wmsCOMPOSANT_PAGE") > 1 && _site != -1) { ChangeVariable("composants", _site); } return(oData.UtilityDataTable); }
////////////////////////////////////////////////// /// @brief Construit un Datatable contenant les rubriques accessibles par le profil pour le site sélectionné ////////////////////////////////////////////////// private DataTable Charge_Profil_Visiteur() { DataTable oDroits = new DataTable(); Object[] newRow = new object[0]; oDroits.Columns.Add(new DataColumn("page_id", Type.GetType("System.Int32"))); String req = "SELECT * FROM crmDROIT_PAGE WHERE profil_id IN (SELECT profil_id FROM crmDROIT_SITE WHERE site_id=@SITE) AND profil_id=@PROFIL"; DataServices oData = new DataServices(VisiteurDsn, req); oData.AddParameter("@SITE", SqlDbType.Int, 0, ParameterDirection.Input, VisiteurSite, "site_id"); oData.AddParameter("@PROFIL", SqlDbType.Int, 0, ParameterDirection.Input, VisiteurProfil, "profil_id"); oData.GetStructures(); foreach (DataRow oRub in oData.UtilityDataTable.Rows) { newRow[0] = oRub["page_id"]; oDroits.Rows.Add(newRow); } oData.Dispose(); VisiteurHomePage = Charge_Visiteur_Homepage(); return(oDroits); }
////////////////////////////////////////////////// /// @brief Desc ////////////////////////////////////////////////// private string[] ChargeDestinataires(string _code) { string[] _emailCondition = s_choix.Split('|'); string _req; DataServices oData; for (int i = 0; i <= 2; i++) { if (string.IsNullOrEmpty(_emailCondition[i])) { _emailCondition[i] = "-"; } else { _emailCondition[i] = CleanQuotes(_emailCondition[i]); } } _req = "select destinataire_emails from crmDESTINATAIRES WHERE destinataire_source='" + _code + "'"; _req += " and (destinataire_filtre1='" + _emailCondition[0] + "' or destinataire_filtre1='*')"; _req += " and (destinataire_filtre2='" + _emailCondition[1] + "' or destinataire_filtre2='*')"; _req += " and (destinataire_filtre3='" + _emailCondition[2] + "' or destinataire_filtre3='*')"; oData = new DataServices(s_dsn, _req); oData.GetStructures(); string[] result; if (oData.UtilityDataExiste) { result = oData.UtilityDataField.ToString().Split('|'); } else { result = "-".Split('|'); } oData.Dispose(); return(result); }