-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefault.aspx.cs
More file actions
146 lines (137 loc) · 5.29 KB
/
Default.aspx.cs
File metadata and controls
146 lines (137 loc) · 5.29 KB
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
using System;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Collections.Generic;
using System.Web.Security;
using System.Web.UI.HtmlControls;
public partial class _Default : Page
{
private System.Data.DataSet _dataSet;
protected string _errorMessage;
private string _itemName;
protected void Page_PreInit(object sender, EventArgs e)
{
Theme = "Gray";
}
protected void Page_Init(object sender, EventArgs e)
{
//_home = new Home();
_dataSet = new System.Data.DataSet();
}
protected void Page_Load(object sender, EventArgs e)
{
Page.ClientScript.RegisterClientScriptInclude("somescript", ResolveUrl("JS/Common.js"));
if (!Page.IsPostBack)
{
try
{
BindData("Oil");
Draft.Text = "Oil";
}
catch (Exception Ex)
{
_errorMessage = Ex.Message;
}
}
}
private void BindData(string itemName)
{
try
{
_itemName = itemName;
Draft.Text = _itemName;
string[] filesindirectory = Directory.GetFiles(Server.MapPath("~/ReportImages/" + _itemName));
List<String> images = new List<string>(filesindirectory.Length);
foreach (string item in filesindirectory)
{
//if (System.IO.Path.GetExtension(item) != ".txt")
//{
//images.Add(String.Format("~/ReportImages/" + itemName + "/{0}", System.IO.Path.GetFileName(item)));
//images.Add(System.IO.Path.GetFullPath(item));
images.Add(item);
//}
//else
//{
// using (System.IO.StreamReader reader = new System.IO.StreamReader(String.Format("~/ReportImages/" + itemName + "/{0}", System.IO.Path.GetFileName(item))))
// {
// images.Add(reader.ReadToEnd());
// }
//}
}
images.Sort((a, b) => a.CompareTo(b));
RepeaterImages.DataSource = images;
RepeaterImages.DataBind();
//string body = string.Empty;
//if (File.Exists(3
//{
// divHTML.Attributes.Add("style", "block");
// using (System.IO.StreamReader reader = new System.IO.StreamReader(Server.MapPath("~/ReportImages/" + itemName + "/" + itemName + ".txt")))
// {
// divHTML.InnerHtml = reader.ReadToEnd();
// }
//}
//else
//{
// divHTML.InnerHtml = "";
// divHTML.Attributes.Add("style", "none");
//}
}
catch
{
throw;
}
}
public void OpenNewWindow(string url)
{
ClientScript.RegisterStartupScript(this.GetType(), "newWindow", String.Format("<script>window.open('{0}');</script>", url));
}
protected void HomeLnk_Click(object sender, EventArgs e)
{
Response.Redirect(FormsAuthentication.DefaultUrl);
}
protected void QuickLinkMenu_MenuItemClick(object sender, MenuEventArgs e)
{
BindData(e.Item.Text);
}
protected void RepeaterImages_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Image imgComodity = (Image)e.Item.FindControl("imgComodity");
HtmlGenericControl divComodity = (HtmlGenericControl)e.Item.FindControl("divComodity");
//HtmlGenericControl headerComodity = (HtmlGenericControl)e.Item.FindControl("headerComodity");
if (System.IO.Path.GetExtension(e.Item.DataItem.ToString()) != ".txt")
{
imgComodity.ImageUrl = String.Format("~/ReportImages/" + _itemName + "/{0}", System.IO.Path.GetFileName(e.Item.DataItem.ToString()));
imgComodity.Visible = true;
divComodity.Visible = false;
//headerComodity.Visible = false;
}
else
{
using (System.IO.StreamReader reader = new System.IO.StreamReader(e.Item.DataItem.ToString()))
{
imgComodity.Visible = false;
divComodity.Visible = true;
divComodity.InnerHtml = reader.ReadToEnd();
//if (e.Item.DataItem.ToString().ToUpper().Contains("HEADER"))
//{
// imgComodity.Visible = false;
// divComodity.Visible = false;
// headerComodity.Visible = true;
// headerComodity.InnerHtml = reader.ReadToEnd();
//}
//else
//{
// imgComodity.Visible = false;
// divComodity.Visible = true;
// headerComodity.Visible = false;
// divComodity.InnerHtml = reader.ReadToEnd();
//}
}
}
}
}
}