Автор работы: Пользователь скрыл имя, 03 Апреля 2013 в 16:48, дипломная работа
С целью анализа базы метеорологических данных, а также контроля данных в реальном времени и был разработан web-интерфейс “Анализ базы метеоданных ”. В программе возможен просмотр метеорологических данных в реальном времени, в виде таблицы статистики с возможностью выбора любого параметра; с полями, в виде отчёта созданного с помощью приложения Crystal Report; так же в виде графика, отражающего зависимость значения метеорологического параметра от времени. Есть так же возможность администрирования базы данных, с целью упорядочить вывод необходимых данных.
ВВЕДЕНИЕ 5
1. ПОСТАНОВКА ЗАДАЧ ДИПЛОМНОЙ РАБОТЫ 6
1.1 СТРУКТУРА ВЫВОДА ДАННЫХ 6
1.2 ОСНОВНЫЕ ЗАДАЧИ ПРОГРАММЫ “АНАЛИЗ БАЗЫ МЕТЕОРОЛОГИЧЕСКИХ ДАННЫХ ”. 7
2. АНАЛИЗ ПРЕДМЕТНОЙ ОБЛАСТИ 8
3. ПРОЕКТИРОВАНИЕ БАЗЫ ДАННЫХ 9
3.1 ПРИЧИНЫ ВЫБОРА ПО ДЛЯ РАЗРАБОТКИ WEB-ИНТЕРФЕЙСА. 9
3.2 ЯЗЫК БАЗ ДАННЫХ - ЯЗЫК SQL. 13
3.3 БАЗА ДАННЫХ НА SQL СЕРВЕРЕ. 16
4.ПРОЕКТИРОВАНИЕ WEB ИНТЕРФЕЙСА 22
4.1 НАЗНАЧЕНИЕ ПАКЕТА BPWIN 22
4.2 ПРОЕКТИРОВАНИЕ В VISUAL STUDIO 2003. 22
4.3 ПАКЕТ ГЕНЕРАТОРА ОТЧЕТОВ CRYSTAL REPORT 34
5. РАБОТА С WEB-ИНТЕРФЕЙСОМ. 43
6. ЗАЩИТА ИНФОРМАЦИИ НА WEB-СТРАНИЦЕ. 48
7. ОСОБЕННОСТИ УСТАНОВКИ ПРОЕКТА НА WEB-СЕРВЕР 49
ЗАКЛЮЧЕНИЕ 50
ЛИТЕРАТУРА 51
if(date2_1.Month.ToString().
else monthfull2=date2_1.Month.
string d1=date1_1.Year.ToString() + monthfull1 + dayfull1 + "000000";
string d2=date2_1.Year.ToString() + monthfull2 + dayfull2 + "000000";
//Response.Write(date1_1 + "<br>"+ date2_1);
SqlConnection conn = new SqlConnection
(ConfigurationSettings.
string query="SELECT "+ResursList.SelectedValue.
query = query + "WHERE (convert(datetime,Col003,4) between
convert(datetime,'" +date1.Value.ToString()+ "',104)
and convert(datetime,'" +date2.Value.ToString()+ "',104))
and ("+ResursList.SelectedValue.
query = query + "ORDER BY ident desc ";
//Response.Write(query+"<br><
try
{
daSA = new SqlDataAdapter(query, conn);
DataSet dsSA = new DataSet();
daSA.Fill(dsSA);
dgStatic.DataSource = dsSA;
dgStatic.DataBind();
}
catch(Exception ex)
{
Response.Write(ex);
}
}
Часть программного кода файла report.aspx.cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;
using System.Data.SqlClient;
namespace agentmeteo
{
public class report : System.Web.UI.Page
{
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.HtmlControls.
protected System.Web.UI.HtmlControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Data.SqlClient.
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.ButtonReport.Click += new System.EventHandler(this.
this.ButtonGeneral.Click += new System.EventHandler(this.
this.Load += new System.EventHandler(this.Page_
}
#endregion
private void ButtonGeneral_Click(object sender, System.EventArgs e)
{
Response.Redirect("default.
}
private void ButtonReport_Click(object sender, System.EventArgs e)
{
Session["date1"]=date1.Value.
Session["date2"]=date2.Value.
Response.Redirect("
}
}
}
Часть программного кода файла CrystalReport.aspx
CR:CRYSTALREPORTVIEWER id="crPaging" runat="server"
Width="350px" HasDrillUpButton="False" HasZoomFactorList="False"HasGo
</CR:CRYSTALREPORTVIEWER>
Часть программного кода файла CrystalReport.aspx.cs
string date1 = Session["date1"].ToString();
string date2 = Session["date2"].ToString();
if(date1.Length == 0)
{
date1="01.01.2007";
}
if(date2.Length == 0)
{
date2="01.01.2007";
}
<!-- ------------------------------
try
{
ci.ServerName = ConfigurationSettings.
ci.DatabaseName = ConfigurationSettings.
ci.UserID = ConfigurationSettings.
ci.Password = ConfigurationSettings.
log.ConnectionInfo = ci;
rDoc.Load(Server.MapPath("
crPaging.ReportSource = rDoc;
ParameterField paramFromDate = new ParameterField();
ParameterField paramToDate = new ParameterField();
ParameterDiscreteValue dvStartDate = new ParameterDiscreteValue();
ParameterDiscreteValue dvFinishDate = new ParameterDiscreteValue();
paramFromDate = crPaging.ParameterFieldInfo["@
dvStartDate.Value= date1;
paramFromDate.CurrentValues.
paramToDate = crPaging.ParameterFieldInfo["@
dvFinishDate.Value= date2;
paramToDate.CurrentValues.Add(
Tables tables = rDoc.Database.Tables;
foreach (CrystalDecisions.
{
log = table.LogOnInfo;
log.ConnectionInfo = ci;
table.ApplyLogOnInfo(log);
}
}
catch(Exception ex)
{
Response.Write(ex);
}
Часть программного кода файла login.aspx.cs
private void enterButton_Click(object sender, System.EventArgs e)
{
SqlConnection connection = new SqlConnection ("packet size=4096;user id=" + txtLogin.Text + ";data source=localhost;persist security info=False;initial catalog=Meteor;password=" + txtPwd.Text + "");
try
{
connection.Open();
SqlCommand command
= new SqlCommand(string.Format("
SqlDataReader reader = command.ExecuteReader();
if (!reader.Read()) // пароль или логин неверны
{
AttentionLbl.Text = "Неверный пароль - попробуйте еще раз";
return ;
}
else
{
string iduser = reader["id"].ToString();
FormsAuthentication.
}
}
catch(Exception ex)
{
AttentionLbl.Text = "Ошибка входа в систему";
}
finally
{
connection.Close();
}
Часть программного кода файла default.aspx
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Security;
using System.Security;
namespace meteoadmin
{
/// <summary>
/// Summary description for redactDB.
/// </summary>
public class redactDB : System.Web.UI.Page
{
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.HtmlControls.
protected System.Web.UI.HtmlControls.
protected System.Web.UI.HtmlControls.
protected System.Web.UI.HtmlControls.
protected System.Web.UI.HtmlControls.
protected System.Web.UI.HtmlControls.
protected System.Web.UI.HtmlControls.
protected System.Data.SqlClient.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.HtmlControls.
protected System.Web.UI.WebControls.
int SelectIndex;
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.HtmlControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.HtmlControls.
string SelectItemIndex, SelectText;
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.HtmlControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.HtmlControls.
protected System.Web.UI.WebControls.
private void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostBack)
{
ButtonDelete.Attributes.Add( "onClick", "return confirm('Вы желаете удалить ресурс?');");
ButtonUpdate.Attributes.Add( "onClick", "return confirm('Вы желаете переименовать ресурс?');");
SqlConnection conn = new SqlConnection
(ConfigurationSettings.
daSA = new SqlDataAdapter("select (Name +' '+LastName)
as fio from UserMeteor where id = " + int.Parse(User.Identity.Name.
DataSet dsSA = new DataSet();
daSA.Fill(dsSA);
LabelName.Text=dsSA.Tables[0].
}
private void ButtonAddNewItem_Click(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection
(ConfigurationSettings.
string tbl;
tbl="Rus";
//Response.Write(DDL_New.
switch (DDL_New.SelectedIndex)
{
case 1:
tbl="Rus";
break;
case 2:
tbl="Lit";
break;
}
try
{
string query ="INSERT " + tbl + " VALUES ('" + TextBoxIDNew.Text + "','" + TextBoxNameNew.Text + "','" + TextBoxParamNew.Text + "','" + TextBoxNormaNew.Text + "')";
string arch_query="INSERT archive_action VALUES(" + int.Parse(User.Identity.Name.
Response.Write(arch_query);
SqlCommand cmd = new SqlCommand(query, conn);
SqlCommand arch_cmd = new SqlCommand(arch_query, conn);
conn.Open();
cmd.ExecuteNonQuery();
arch_cmd.ExecuteNonQuery();
conn.Close();
switch (RadioResurs.SelectedIndex)
{
case 0:
RusDataBind();
break;
case 1:
LitDataBind();
break;
}
}
catch(Exception ex)
{
Response.Write(ex);
}
}
Часть программного кода файла web.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!-- Строка соединения с базой данных -->
<add key="SAConnectionString" value="packet size=4096;user id=meteor;data source=localhost;persist security info=False;initial catalog=Meteor;password=123"/>
</appSettings> // логин и пароль подключения к базе данных
<system.web>
<!-- DYNAMIC DEBUG COMPILATION
Set compilation debug="true" to enable ASPX debugging. Otherwise, setting this value to
false will improve runtime performance of this application.
Set compilation debug="true" to insert debugging symbols (.pdb information)
into the compiled page. Because this creates a larger file that executes
more slowly, you should set this value to true only when debugging and to
false at all other times. For more information, refer to the documentation about
debugging ASP.NET files.
-->
<compilation
defaultLanguage="c#"
debug="true"
/>
<!-- CUSTOM ERROR MESSAGES
Set customErrors mode="On" or "RemoteOnly" to enable custom error messages, "Off" to disable.
Add <error> tags for each of the errors you want to handle.
"On" Always display custom (friendly) messages.
"Off" Always display detailed ASP.NET error information.
"RemoteOnly" Display custom (friendly) messages only to users not running
on the local Web server. This setting is recommended for security purposes, so
that you do not display application detail information to remote clients.
-->
<customErrors
mode="RemoteOnly"
/>
<!-- AUTHENTICATION
This section sets the authentication policies of the application. Possible modes are "Windows",
"Forms", "Passport" and "None"
"None" No authentication is performed.
"Windows" IIS performs authentication (Basic, Digest, or Integrated Windows) according to
its settings for the application. Anonymous access must be disabled in IIS.
"Forms" You provide a custom form (Web page) for users to enter their credentials, and then
you authenticate them in your application. A user credential token is stored in a cookie.
"Passport" Authentication is performed via a centralized authentication service provided
by Microsoft that offers a single logon and core profile services for member sites.
-->
<authentication mode="Forms" > >//использование форм при аутентификации
<forms name="WebForm1" //имя открываемой формы при входе
loginUrl="login.aspx" //адрес главной страницы
protection="All" " //шифрование всех данных и проверка их при пересылке
path="/">
</forms>
</authentication>
//защита от входа через адресную строку браузера
<!-- AUTHORIZATION
This section sets the authorization policies of the application. You can allow or deny access
to application resources by user or role. Wildcards: "*" mean everyone, "?" means anonymous
(unauthenticated) users.
-->
<authorization>
<deny users="?" /> <!-- Allow all users --> //все подключения только через аутентификацию
<!-- <allow users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
<deny users="[comma separated list of users]"
roles="[comma separated list of roles]"/>
-->
</authorization>
<!-- APPLICATION-LEVEL TRACE LOGGING
Application-level tracing enables trace log output for every page within an application.
Set trace enabled="true" to enable application trace logging. If pageOutput="true", the
trace information will be displayed at the bottom of each page. Otherwise, you can view the
application trace log by browsing the "trace.axd" page from your web application
root.
-->
<trace
enabled="false"
requestLimit="10"
pageOutput="false"
traceMode="SortByTime"
localOnly="true"
/>
<!-- SESSION STATE SETTINGS
By default ASP.NET uses cookies to identify which requests belong to a particular session.
If cookies are not available, a session can be tracked by adding a session identifier to the URL.
To disable cookies, set sessionState cookieless="true".
-->
<sessionState
mode="InProc"
stateConnectionString="tcpip=1
sqlConnectionString="data source=127.0.0.1;Trusted_
cookieless="false"
timeout="20"
/>
<!-- GLOBALIZATION
This section sets the globalization settings of the application.
-->
<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
/>
</system.web>
</configuration>
Схема работы web-интерфейса (BPWin)
Рисунок К.1
Рисунок К.2
Схема работы web-интерфейса
Рисунок Л.1
Информация о работе Разработка WEB - интерфейса для анализа базы метеореологических данных