-
Notifications
You must be signed in to change notification settings - Fork 0
/
Global.asax
132 lines (80 loc) · 3.94 KB
/
Global.asax
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<%--
Copyright (C) 2017 Maurizio Ferrera
This file is part of asmartcatalogue
asmartcatalogue is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
asmartcatalogue is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with asmartcatalogue. If not, see <http://www.gnu.org/licenses/>.
--%>
<%@ Application Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Web.Security" %>
<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Web.Routing" %>
<script RunAt="server">
private static void defineroutes(RouteCollection routes)
{
routes.MapPageRoute("prod",
"prod/{nomeprodotto}/{idArt}", "~/shop/articoli.aspx");
routes.MapPageRoute("cat",
"catalog/{nomecategoria}/{idCatSelected}", "~/shop/preview.aspx");
}
public void Application_Start(Object sender, EventArgs e)
{
defineroutes(RouteTable.Routes);
asc.language.loadlanguages();
using (OleDbConnection cnn = new OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings["strcnn"].ConnectionString))
{
OleDbCommand cmd;
OleDbDataAdapter da;
string sql;
DataTable dtcurrencies = new DataTable();
sql = "SELECT id, cambio, decimali, decimalseparatorsymbol, nome, groupseparatorsymbol FROM tcurrencies where cambio>0 order by nome";
cmd = new OleDbCommand(sql, cnn);
da = new OleDbDataAdapter(cmd);
da.Fill(dtcurrencies);
dtcurrencies.PrimaryKey = new DataColumn[] { dtcurrencies.Columns["id"] };
Application["dtcurrenciesavailable"] = dtcurrencies;
}
asc.config.storeConfig(); // setta variabili di applicazione
asc.caching.cacheallcategories();
}
void Session_OnStart()
{
HttpContext.Current.Session["currentfrontlanguage"] = System.Configuration.ConfigurationManager.AppSettings["defaultfrontlanguage"];
int idcurrency = (int)HttpContext.Current.Application["config_idmastercurrency"];
DataRow rowcurrentcurrency = ((DataTable)Application["dtcurrenciesavailable"]).Rows.Find(idcurrency);
asc.currency curr = new asc.currency(
(int)rowcurrentcurrency["id"],
(double)rowcurrentcurrency["cambio"],
rowcurrentcurrency["nome"].ToString(),
rowcurrentcurrency["decimalseparatorsymbol"].ToString(),
(int)rowcurrentcurrency["decimali"],
(string)rowcurrentcurrency["groupseparatorsymbol"]
);
Session["frontendcurrency"] = curr;
HttpContext.Current.Session["coda"] = new System.Collections.Generic.List<asc.product>();
HttpContext context = HttpContext.Current;
HttpCookieCollection cookies = context.Request.Cookies;
if (cookies["starttime"] == null)
{
HttpCookie cookie = new HttpCookie("starttime", DateTime.Now.ToString());
cookie.Path = "/";
context.Response.Cookies.Add(cookie);
}
else
{
if (Request.Path.ToLower().IndexOf("admin_") > 0 || Request.Path.IndexOf("admin.aspx") > 0) { }
else context.Response.Redirect("~/shop/timeout.aspx");
}
}
</script>