Диаграмма классов
07.01.2013, 02:14. Показов 1797. Ответов 4
Здравствуйте, помогите пожалуйста создать диаграмму классов
Создаю WebService, и Web Site в одном проекте, делаю ссылочку клиента на сервер, нажимаю создать диаграмму классов но, не делает класса Default, помогите разобраться, не понимаю в чем ошибка,
Сервер:
Service.cs
| C# | 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
| using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public struct Result
{
public double Square, Square2, M1, M2, M3, M4, M5, SMK1, SMK2, SMK3, SMK4, SMK5;
public int time1, time2, time3, time4, time5;
public double pogr1, pogr2, pogr3, pogr4, pogr5;
public double m1, m2, m3, m4, m5;
}
public struct Point
{
public double x, y;
}
public int Time; //время расчета
public Point a = new Point();
public Point b = new Point();
public Point c = new Point();
public Point e = new Point();
public Result S = new Result();
public Service()
{
}
[WebMethod]
public Result Monte_Karlo(Point a, Point b, Point c, Point e)
{
double k1 = 0;
double b1 = 0;
double k2 = 0;
double b2 = 0;
if (e.x < c.x)
{
S.Square = (b.y - a.y) * (c.x - a.x);
}
if (e.x > c.x)
{
S.Square = (b.y - a.y) * (e.x - a.x);
}
if (e.x == c.x)
{
S.Square = (b.y - a.y) * (c.x - a.x);
}
if (e.x < c.x)
{
k1 = (b.y - a.y) / (b.x - a.x);
b1 = b.y - k1 * b.x;
k2 = (e.y - c.y) / (e.x - c.x);
b2 = e.y - k2 * e.x;
S.Square2 = 0.5 *((e.x - a.x) + (c.x - b.x)) * (b.y - a.y);
}
if (e.x > c.x)
{
k1 = (b.y - a.y) / (b.x - a.x);
b1 = b.y - k1 * b.x;
k2 = (e.y - c.y) / (e.x - c.x);
b2 = e.y - k2 * e.x;
S.Square2 = 0.5 * ((e.x - a.x) + (c.x - b.x)) * (b.y - a.y);
}
if (e.x == c.x)
{
k1 = (b.y - a.y) / (b.x - a.x);
b1 = b.y - k1 * b.x;
k2 = 0;
b2 = e.y - k2 * e.x;
S.Square2 = 0.5 * ((e.x - a.x) + (c.x - b.x)) * (b.y - a.y);
}
S.M1 = count(1000, a, b, c, e, k1, b1, k2, b2);
S.SMK1 = S.Square * S.M1 / 1000;
S.pogr1 = Math.Abs((S.Square2 - S.SMK1) / S.Square2) * 100;
S.time1 = Time;
S.M2 = count(10000, a, b, c, e, k1, b1, k2, b2);
S.SMK2= S.Square* S.M2 / 10000;
S.pogr2 = Math.Abs((S.Square2 - S.SMK2) / S.Square2)* 100;
S.time2 = Time;
S.M3 = count(100000, a, b, c, e, k1, b1, k2, b2);
S.SMK3 = S.Square * S.M3 / 100000;
S.pogr3 = Math.Abs((S.Square2 - S.SMK3) / S.Square2) * 100;
S.time3 = Time;
S.M4 = count(1000000, a, b, c, e, k1, b1, k2, b2);
S.SMK4 = S.Square * S.M4 / 1000000;
S.pogr4 = Math.Abs((S.Square2 - S.SMK4) / S.Square2) * 100;
S.time4 = Time;
S.M5 = count(10000000, a, b, c, e, k1, b1, k2, b2);
S.SMK5 = S.Square* S.M5 / 10000000;
S.pogr5 = Math.Abs((S.Square2 - S.SMK5) / S.Square2) * 100;
S.time5 = Time;
return S;
}
public double count(double N,
Point a, Point b, Point c, Point e, double k1, double b1, double k2, double b2)
{
double M = 0;
double bx;
double bxx;
Point xy = new Point();
Random Randomator = new Random();
DateTime StartTime, EndTime;
StartTime = DateTime.Now;
if (e.x < c.x)
{
for (int i = 1; i <= N; i++)
{
xy.x = a.x + Randomator.NextDouble() * (c.x - a.x);
xy.y = a.y + Randomator.NextDouble() * (b.y - a.y);
bx = xy.y - k1 * xy.x;
bxx = xy.y - k2 * xy.x;
if ((bx<=b1) && (bxx>=b2))
M++;
}
}
if (e.x > c.x)
{
for (int i = 1; i <= N; i++)
{
xy.x = a.x + Randomator.NextDouble() * (e.x - a.x);
xy.y = a.y + Randomator.NextDouble() * (b.y - a.y);
bx = xy.y - k1 * xy.x;
bxx = xy.y - k2 * xy.x;
if ((bx <= b1) && (bxx <= b2))
M++;
}
}
if (e.x == c.x)
{
for (int i = 1; i <= N; i++)
{
xy.x = a.x + Randomator.NextDouble() * (c.x - a.x);
xy.y = a.y + Randomator.NextDouble() * (b.y - a.y);
bx = xy.y - k1 * xy.x;
if ((bx <= b1))
M++;
}
}
EndTime = DateTime.Now;
Time = (EndTime.Minute - StartTime.Minute) * 60000 + (EndTime.Second - StartTime.Second) * 1000
+ (EndTime.Millisecond - StartTime.Millisecond);
return M;
}
} |
|
Клиент:
Default.aspx
| HTML5 | 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
| <%@ Page Language="C#" Async="true" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Метод Монте-Карло</title>
<style type="text/css">
.style1
{
width: 253px;
}
.style2
{
height: 40px;
}
.style5
{
width: 33px;
}
.style7
{
width: 58px;
}
.style8
{
width: 33px;
height: 11px;
}
.style9
{
width: 29px;
}
.style11
{
width: 43px;
}
.style12
{
width: 236px;
}
.style17
{
width: 31px;
height: 11px;
}
.style19
{
width: 48px;
}
.style21
{
height: 11px;
}
.style22
{
width: 41px;
}
.style23
{
width: 60px;
}
.style26
{
width: 209px;
}
.style28
{
width: 205px;
}
</style>
<script language="javascript" type="text/javascript">
// <![CDATA[
function Img_onclick() {
}
// ]]>
</script>
</head>
<body id="Body1" style="text-align: left" runat="server" bgcolor = "#FFDAB9" >
<form id="Form1" name="Form" runat="server">
<asp:ScriptManager ID="scriptMgr" runat="server" >
</asp:ScriptManager>
<h3 align="center">Метод Монте-Карло</h3>
<table id="Table1" width="689" border="0" runat="server" align="center">
<tr>
<th height="279" scope="col" class="style1">
<img id="Img" src="ris.jpg" alt="" width="302" height="165" runat="server" onclick="return Img_onclick()" />
<br />
</th>
<th scope="col" align="center" class="style2">
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table align="center">
<tr>
<td class="style12">
<h4 align="center">Координаты точки A: </h4>
</td>
<td class="style17">x = </td>
<td class="style21">
<asp:TextBox ID="ax" runat="server" Columns="7" MaxLength="5"
ontextchanged="ax_TextChanged" Width="50px"></asp:TextBox>
</td>
<td class="style8">y = </td>
<td><asp:TextBox ID="ay" runat="server" Columns="7" MaxLength="5" Width="50px"></asp:TextBox></td>
</tr>
</table>
<table align="center">
<tr>
<td>
<h4 align="center" style="width: 199px; height: 19px">Координаты точки B: </h4>
</td>
<td class="style19">x = </td>
<td>
<asp:TextBox ID="bx" runat="server" Columns="7" MaxLength="5"
ontextchanged="bx_TextChanged" Width="50px"></asp:TextBox>
</td>
<td class="style22">y = </td>
<td> <asp:TextBox ID="by" runat="server" Columns="7" MaxLength="5"
Width="50px"></asp:TextBox></td>
</tr>
</table>
<table align="center">
<tr>
<td class="style26">
<h4 align="center">Координаты точки C: </h4>
</td>
<td class="style5">x = </td>
<td>
<asp:TextBox ID="cx" runat="server" Columns="7" MaxLength="5" Width="50px"></asp:TextBox>
</td>
<td class="style9">y = </td>
<td> <asp:TextBox ID="cy" runat="server" Columns="7" MaxLength="5" Width="50px"></asp:TextBox></td>
</tr>
</table>
<table align="center">
<tr>
<td class="style28">
<h4 align="center" style="width: 193px; height: 20px">Координаты точки E: </h4>
</td>
<td class="style7">x = </td>
<td>
<asp:TextBox ID="ex" runat="server" Columns="7" MaxLength="5" Width="50px"></asp:TextBox>
</td>
<td class="style23">y = </td>
<td class="style11"><asp:TextBox ID="ey" runat="server" Columns="7" MaxLength="5"
Width="50px"></asp:TextBox></td>
</tr>
</table>
<br>
<asp:Button ID="Button1" runat="server" Text="Контрольный пример 1 (B < E < C)" OnClick="Button1_Click" width="250" style="margin-left: 0px" />
<asp:Button ID="Button2" runat="server" Text="Контрольный пример 2 (E > C)" width="254px" OnClick="Button2_Click"/>
<asp:Button ID="Button3" runat="server" Text="Контрольный пример 3 (E = C)" width="255px" OnClick="Button3_Click" />
<asp:Button ID="Button4" runat="server" Text="Случайные координаты" onclick="Button4_Click"
/>
</ContentTemplate>
</asp:UpdatePanel>
</th>
</tr>
</table>
<asp:Button ID="ButtonCalculate" runat="server" Text="Рассчитать"
OnClick="ButtonCalculate_Click" Height="25px"
Width="120px" style="margin-left: 478px" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div align="center">
<asp:Label ID="LabelResults" runat="server"></asp:Label> <br/>
</div>
<asp:Table ID="TableResults" runat="server" CaptionAlign="Bottom" border="1" Visible="False" align="center">
<asp:TableHeaderRow BorderStyle="Double">
<asp:TableHeaderCell>Кол-во точек</asp:TableHeaderCell>
<asp:TableHeaderCell>Кол-во попавших точек</asp:TableHeaderCell>
<asp:TableHeaderCell>Площадь Монте-Карло</asp:TableHeaderCell>
<asp:TableHeaderCell>Площадь</asp:TableHeaderCell>
<asp:TableHeaderCell>Погрешность, %</asp:TableHeaderCell>
<asp:TableHeaderCell>Время расчета, ms</asp:TableHeaderCell>
</asp:TableHeaderRow>
</asp:Table>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ButtonCalculate" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</form>
</body>
</html> |
|
Default.aspx.cs
| C# | 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
| using System;
using System.Configuration;
using System.Data;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using localhost;
public partial class Default : System.Web.UI.Page
{
//
public localhost.Result S = new localhost.Result();
public localhost.Point A = new localhost.Point();
public localhost.Point B = new localhost.Point();
public localhost.Point C = new localhost.Point();
public localhost.Point E = new localhost.Point();
private Service serv = new Service();
// public delegate Result Dl(Point a, Point b, Point c, Point e);
protected void Page_Load(object sender, EventArgs e)
{
}
protected void MK(object sender, EventArgs e)
{
TableResults.Visible = false;
LabelResults.Text = "";
try
{
A.x = double.Parse(ax.Text);
}
catch
{
LabelResults.Text = "Введите координаты";
return;
}
try
{
A.y = double.Parse(ay.Text);
}
catch
{
LabelResults.Text = "Введите координаты";
return;
}
try
{
B.x = double.Parse(bx.Text);
}
catch
{
LabelResults.Text = "Введите координаты";
return;
}
try
{
B.y = double.Parse(by.Text);
}
catch
{
LabelResults.Text = "Введите координаты";
return;
}
try
{
C.x = double.Parse(cx.Text);
}
catch
{
LabelResults.Text = "Введите координаты";
return;
}
try
{
C.y = double.Parse(cy.Text);
}
catch
{
LabelResults.Text = "Введите координаты";
return;
}
try
{
E.x = double.Parse(ex.Text);
}
catch
{
LabelResults.Text = "Введите координаты";
return;
}
try
{
E.y = double.Parse(ey.Text);
}
catch
{
LabelResults.Text = "Введите координаты";
return;
}
if (A.y == E.y && B.y == C.y)
{
Service serv = new Service();
serv.Monte_KarloCompleted += new Monte_KarloCompletedEventHandler(table);
serv.Monte_KarloAsync(A, B, C, E);
/* Dl Delegator = new Dl(serv.Monte_Karlo);
IAsyncResult async = Delegator.BeginInvoke(A,B,C,E, null, null);
S = Delegator.EndInvoke(async);
table(S);*/
}
else
LabelResults.Text = "Введите координаты правильно.";
}
private void table(object sender, Monte_KarloCompletedEventArgs e)
// private void table(Result S)
{
TableResults.Visible = true;
for (int row = 1; row <= 5; row++)
{
TableResults.Rows.Add(new TableRow());
for (int col = 0; col <= 5; col++)
TableResults.Rows[row].Cells.Add(new TableCell());
}
TableResults.Rows[1].Cells[0].Text = Convert.ToString(1000);
TableResults.Rows[1].Cells[1].Text = Convert.ToString(Math.Round(e.Result.M1, 0));
TableResults.Rows[1].Cells[2].Text = Convert.ToString(Math.Round(e.Result.SMK1, 3));
TableResults.Rows[1].Cells[3].Text = Convert.ToString(e.Result.Square2);
TableResults.Rows[1].Cells[4].Text = Convert.ToString(Math.Round(e.Result.pogr1, 3));
TableResults.Rows[1].Cells[5].Text = Convert.ToString(e.Result.time1);
TableResults.Rows[2].Cells[0].Text = Convert.ToString(10000);
TableResults.Rows[2].Cells[1].Text = Convert.ToString(Math.Round(e.Result.M2, 0));
TableResults.Rows[2].Cells[2].Text = Convert.ToString(Math.Round(e.Result.SMK2, 3));
TableResults.Rows[2].Cells[3].Text = Convert.ToString(e.Result.Square2);
TableResults.Rows[2].Cells[4].Text = Convert.ToString(Math.Round(e.Result.pogr2, 3));
TableResults.Rows[2].Cells[5].Text = Convert.ToString(e.Result.time2);
TableResults.Rows[3].Cells[0].Text = Convert.ToString(100000);
TableResults.Rows[3].Cells[1].Text = Convert.ToString(Math.Round(e.Result.M3, 0));
TableResults.Rows[3].Cells[2].Text = Convert.ToString(Math.Round(e.Result.SMK3, 3));
TableResults.Rows[3].Cells[3].Text = Convert.ToString(e.Result.Square2);
TableResults.Rows[3].Cells[4].Text = Convert.ToString(Math.Round(e.Result.pogr3, 3));
TableResults.Rows[3].Cells[5].Text = Convert.ToString(e.Result.time3);
TableResults.Rows[4].Cells[0].Text = Convert.ToString(1000000);
TableResults.Rows[4].Cells[1].Text = Convert.ToString(Math.Round(e.Result.M4, 0));
TableResults.Rows[4].Cells[2].Text = Convert.ToString(Math.Round(e.Result.SMK4, 3));
TableResults.Rows[4].Cells[3].Text = Convert.ToString(e.Result.Square2);
TableResults.Rows[4].Cells[4].Text = Convert.ToString(Math.Round(e.Result.pogr4, 3));
TableResults.Rows[4].Cells[5].Text = Convert.ToString(e.Result.time4);
TableResults.Rows[5].Cells[0].Text = Convert.ToString(10000000);
TableResults.Rows[5].Cells[1].Text = Convert.ToString(Math.Round(e.Result.M5, 0));
TableResults.Rows[5].Cells[2].Text = Convert.ToString(Math.Round(e.Result.SMK5, 3));
TableResults.Rows[5].Cells[3].Text = Convert.ToString(e.Result.Square2);
TableResults.Rows[5].Cells[4].Text = Convert.ToString(Math.Round(e.Result.pogr5, 3));
TableResults.Rows[5].Cells[5].Text = Convert.ToString(e.Result.time5);
}
protected void ButtonCalculate_Click(object sender, EventArgs e)
{
MK(sender, e);
}
protected void Button1_Click(object sender, EventArgs e)
{
ax.Text = Convert.ToString(100);
ay.Text = Convert.ToString(100);
bx.Text = Convert.ToString(200);
by.Text = Convert.ToString(300);
cx.Text = Convert.ToString(500);
cy.Text = Convert.ToString(300);
ex.Text = Convert.ToString(400);
ey.Text = Convert.ToString(100);
}
protected void Button2_Click(object sender, EventArgs e)
{
ax.Text = Convert.ToString(100);
ay.Text = Convert.ToString(100);
bx.Text = Convert.ToString(200);
by.Text = Convert.ToString(300);
cx.Text = Convert.ToString(500);
cy.Text = Convert.ToString(300);
ex.Text = Convert.ToString(800);
ey.Text = Convert.ToString(100);
}
protected void Button3_Click(object sender, EventArgs e)
{
ax.Text = Convert.ToString(100);
ay.Text = Convert.ToString(100);
bx.Text = Convert.ToString(200);
by.Text = Convert.ToString(300);
cx.Text = Convert.ToString(500);
cy.Text = Convert.ToString(300);
ex.Text = Convert.ToString(500);
ey.Text = Convert.ToString(100);
}
protected void Button4_Click(object sender, EventArgs e)
{
Random rand = new Random();
int axx = rand.Next(0, 1000);
int ayy = rand.Next(0, 1000);
int bxx = rand.Next(axx, 1000);
int byy = rand.Next(ayy, 1000);
int cxx = rand.Next(bxx, 1000);
int cyy = byy;
int exx = rand.Next(bxx, 1000);
int eyy = ayy;
ax.Text = Convert.ToString(axx);
ay.Text = Convert.ToString(ayy);
bx.Text = Convert.ToString(bxx);
by.Text = Convert.ToString(byy);
cx.Text = Convert.ToString(cxx);
cy.Text = Convert.ToString(cyy);
ex.Text = Convert.ToString(exx);
ey.Text = Convert.ToString(eyy);
}
protected void ax_TextChanged(object sender, EventArgs e)
{
}
protected void bx_TextChanged(object sender, EventArgs e)
{
}
} |
|
0
|