Form1.cs
3.6 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
using LineWebService;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.ServiceModel.Web;
using System.ServiceModel;
using System.Linq.Expressions;
using BLL;
namespace WebServiceTest
{
public partial class Form1 : Form//, IWebService_Callback
{
public Form1()
{
InitializeComponent();
}
private WebServiceHost _serviceHost;
public void HostOpen()
{
try
{
ClsWebService service = new ClsWebService();
_serviceHost = new WebServiceHost(typeof(ClsWebService));//service, new Uri(url)
if (_serviceHost.State != CommunicationState.Opened)//判断服务是否关闭
{
_serviceHost.Open();
}
label1.Text="Web服务已开启";
}
catch (Exception ex)
{
//AGVControl.Common.log.Error("Open", ex);
MessageBox.Show(ex.ToString());
}
}
public void HostClose()
{
try
{
if (_serviceHost.State != CommunicationState.Closed)//判断服务是否关闭
{
_serviceHost.Close();//关闭服务
}
//_serviceHost.Close();
label1.Text="Web服务已关闭";
}
catch (Exception ex)
{
//AGVControl.Common.log.Error("Close", ex);
MessageBox.Show(ex.ToString());
}
}
//public void GetEmptyRecycleTask(string lineName)
//{
// label1.Text = lineName;
// MessageBox.Show(lineName);
//}
public void RecycleTask(string lineName)
{
label1.Text = lineName;
MessageBox.Show(lineName);
//if (AGVControl.Common.agvProductionLine.TryGetValue(lineName, out string value))
//{
// AGVControl.Common.LogInfo("WebService Response OK");
// //加到任务
// //int idx = AGVControl.Common.nodeInfo.FindIndex(s => s.Name == value);
// //if (idx > -1)
// // AGVControl.Common.linePlace.Add(value);
// //else
// // AGVControl.Common.log.Error("CreateEmptyRecycleTask " + value + "不存在");
// if (!Common.AddLinePlace(value))
// Common.log.Error("CreateEmptyRecycleTask 节点【" + value + "】不存在");
// else
// {
// Common.LogInfo("任务:" + value + " 出空料架 【" + lineName + "】");
// }
// //System.IO.File.WriteAllLines(Common.CONFIG_PATH + "LinePlace.txt", Common.linePlace);
//}
//else
//{
// AGVControl.Common.LogInfo("WebService Response false");
//}
}
private void button1_Click(object sender, EventArgs e)
{
HostOpen();
}
private void button2_Click(object sender, EventArgs e)
{
HostClose();
}
private void button3_Click(object sender, EventArgs e)
{
textBox3.Text=AGVManager.CreateEmptyTask(textBox1.Text,textBox2.Text);
}
private void button4_Click(object sender, EventArgs e)
{
AGVManager.GetWebservice(textBox1.Text, textBox2.Text);
}
}
}