具有 Windows Mobile 和 Web 服务的任务分配器
从中央管理点向所有员工发送消息、命令、任务等。
引言
该系统将是员工和雇主通过 Windows Mobile 和中央位置交换消息或任务的良好解决方案。
我的想法
现在大多数人都在办公室外工作。例如,在交易所大楼工作的股票交易所监控员需要与管理中心发送或接收重要消息。他可以使用 SMS 或电子邮件,但我建议使用 Web 服务和客户端的另一种好方法。
更多关于任务分配器
任务分配器是系统中核心功能的名称。它有一个服务器和一个客户端。服务器是一个 ASP.NET Web 服务,客户端是一个 Windows Mobile 设备。
服务器是公司的中央位置。它有一个名为messagefile.txt的文件。该文件包含向员工发送消息的所有信息。
客户端是安装了 Windows Mobile 的手持设备。当用户登录系统时,系统会检查它是否是授权用户。然后,应用程序检查服务器中是否有特定用户的新消息,这些消息会自动从服务器下载。但是,我们如何处理不需要的数据,以及安全性如何?
对于第一个问题,答案很简单。我们为messagefile.txt使用标准格式。这是文件格式
Hi, Please check the walk Street 27|07-12-2008|18.00|james"
对于第二个问题,我们在服务器中有一个可以访问这些功能的用户列表。因此,我们将用户名和密码发送到服务器并验证用户。我们还使用加密来增加安全性。
从服务器获取消息
一旦用户登录到系统,我们就会自动检查服务器是否有任何新消息,并将所有消息下载到客户端并在列表视图中像摘要一样列出它们。
使用代码
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using FileTransfer.Core.FileService;
using System.Net;
namespace FileTransfer.Core
{
public class FileReader
{
public FileReader()
{
}
char[] spillter = new char[] { '|' };
public Message GetMessageFromServer(string line)
{
Message message = null;
if (!string.IsNullOrEmpty(line))
{
string[] values = line.Split(spillter);
message = new Message();
message.Name = values[3];
message.Content = values[0];
message.Date = values[1];
message.Time = values[2];
}
return message;
}
public Message GetMessageFromServer()
{
return null;
}
public List<Message> GetListOfMessages(string username, string pwd)
{
try
{
List<Message> collection = null;
FileService.FileService service =
new FileTransfer.Core.FileService.FileService();
service.Url = "http://server/wmservice/FileService.asmx";
service.PreAuthenticate = false;
string[] lines = service.ReadFile(username, pwd);
collection = new List<Message>();
if (lines != null && lines.Length > 0)
{
for (int i = 0; i < lines.Length; i++)
{
Message message = GetMessageFromServer(lines[i]);
collection.Add(message);
}
}
return collection;
}
catch (Exception ex)
{
throw ex;
}
}
}
}
上面的代码非常简单。它有助于访问 Web 服务并通过服务从服务器获取所有消息。我定义了一个名为“message
”的对象来构建消息。
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
namespace FileTransfer.Core
{
public class Message
{
string name;
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
string content;
string date;
public string Date
{
get
{
return date;
}
set
{
date = value;
}
}
string time;
public string Time
{
get
{
return time;
}
set
{
time = value;
}
}
public string Content
{
get
{
return content;
}
set
{
content = value;
}
}
}
}
系统设计视图
服务器端
服务器端非常简单,因为我们有一个简单的文本配置文件。管理人员将消息放入标准格式中。之后,Web 服务读取特定用户的文件的消息,并将消息发送给用户。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace WindowsMobileService.Core
{
public class MessageReader
{
public MessageReader()
{
}
public string[] ReadMessage(string filePath)
{
if (string.IsNullOrEmpty(filePath))
{
return null;
}
if (File.Exists(filePath))
{
return File.ReadAllLines(filePath);
}
else
{
return null;
}
}
}
}
设置服务器
这非常简单,只需下载服务代码,在您的 IIS 服务器中创建一个虚拟目录,然后将服务器代码复制到该目录。或者您可以使用 VS IDE 运行它。
最终结果
最终结果如下所示
下一步是什么
这是初始版本。我想在这里列出我计划在即将到来的版本中包含的功能
- 使用服务器验证用户名和密码。
- 包含 AES 加密。
- 如果服务器中存在新消息,则向用户显示通知。
- 检查互联网是否可访问。
- 与其他用户的合作。用户可以连接到服务器并下载消息,以便通过 SMS 或其他方式发送给另一个人。
- 将所有消息放入服务器中的 Excel 表格中。
- 服务器的消息发送功能。
历史
- 2008-12-2008:初始版本。