软件设计实践报告.docx
《软件设计实践报告.docx》由会员分享,可在线阅读,更多相关《软件设计实践报告.docx(34页珍藏版)》请在冰点文库上搜索。
![软件设计实践报告.docx](https://file1.bingdoc.com/fileroot1/2023-7/27/92f08060-26e2-43f8-8af7-7da0be96251d/92f08060-26e2-43f8-8af7-7da0be96251d1.gif)
软件设计实践报告
软件设计实践报告
单位:
信息工程学院
班级:
计算机科学与技术二班
学号:
xxxxxxxxxxxxxx
姓名:
xxxx
任课教师:
xxxxxxxxxxxxx
湘潭大学
2011年8月
软件设计实践
项目名称:
ERP移动扩展手机版通讯录
湘潭大学信息工程学院七组
一、项目概述
1.概述
针对各公司或(商业)机构与外界联系将更为广泛和密切,传统的手工通讯录、地址簿已经难以满足快节奏、高效率的现代生活的需求。
经常发生要在几十甚至上百张名片中找出某一张名片的情况,若由手工完成效率十分低。
为了满足快节奏、高效率的现代生活的需求,需要开发出高效的通讯录管理软件
2.目的和用途
本文档的编制,为了使用户和软件开发者双方对项目所涉及的需求范围、需求的含义有一个共同约定和理解,使之成为后续软件设计、软件开发和系统实施工作的基础。
为公司职员提供公司的通讯录,并实现按照姓名和部门的智能查询功能,提供安全而便捷的办公。
3.需求概述
3.1用户需求列表
用户当前需求如图所示:
编号
需求名称
描述
优先级
1
登陆安全
用户每次登陆时要求验证ERP帐号和密码
P0
2
自动更新
用户登录之后,系统自动更新数据库
P0
3
手动更新
用户可以根据需要手动对数据库进行更新
P0
4
分部门查询
按照部门返回查询信息
P0
5
按姓名查询
根据用户输入的联系人姓名返回查询的信息
P0
6
按号码查询
根据用户输入的联系人号码返回查询的信息
P0
7
模糊查询
根据用户输入的不完整信息返回查询的信息
P0
8
首字母查询
用户输入姓名的首字母查询返回查询的信息
P0
9
语音查询
根据用户语音查询联系人信息
P2
10
错误近似查询
根据用户输入的错误信息,返回最近似的信息
P2
11
查询结果操作
对查询结果进行操作,打电话或者发短信
P0
(注:
P0级为必须实现,P1级为尽可能实现,P2级为希望实现)
3.2需求分析
•功能1:
登陆安全。
用户每次登陆时要求验证用户的ERP账号和密码组合。
如果身份验证正确,方才允许用户的后续操作;否则,拒绝,留在当前登陆页面。
•功能2:
自动更新。
用户在登陆成功之后,系统自动从服务器下载最新数据,更新本地数据库。
•功能3:
手动更新。
用户可以根据需要,点击同步更新按钮,随时从服务器下载最新的数据,以更新本地数据库。
•功能4:
分部门查询。
用户在查询联系人的时候,可以根据联系人所在的部门查询。
用户点击分部门查询,查询返回部门列表,然后再根据子部门向下查询。
•功能5:
按姓名查询。
在查询时,用户输入联系人的中文姓名,系统返回匹配的结果。
•功能6:
按号码查询。
用户输入用户的号码,点击查询,系统能返回正确的匹配信息。
•功能7:
模糊查询。
当用户输入不完整的信息时,系统能进行模糊查询,返回所有跟当前不完整信息吻合的联系人信息。
•功能8:
首字母查询。
用户在查询输入时,可以只输入联系人姓名的首字母。
当首字母与英文名字首字母相同时,应同时返回匹配结果,按照在数据库中的排列顺序排列查询结果。
•功能9:
语音查询。
系统根据用户语音指令查询用户信息。
•功能10:
错误近似查询。
当用户输入的信息错误时,系统能够返回与错误信息最相近的结果供用户进行选择。
•功能11:
对查询结果进行操作。
用户点击查询结果,系统弹出对话框,供用户选择操作,打电话或者发短信。
4.环境要求
1、联想台式机一台
2、windows平台和android平台。
Eclipse编程软件,AndroidSDK,TFT插件。
二系统分析与设计
用例图
图2.1用例图
分析类图
图2.2分析类图
<>:
登陆,查询,更新
<>:
远程验证或本地验证,查询部门或联系人,更新数据
<>:
远程服务器,SharePerferences,本地服务器
时序图
图2.3时序图1
图2.4时序图2
图2.5时序图3
1、系统设计
1.用户界面
1)登陆界面
2)查询界面
3)信息界面
4)更新界面
5)拨号界面
6)发短息界面
2.模块设计
采用工厂模式,总体截图
Com.surekam包中的infor.java,Login.java,progress.java,Search.java为用户界面类,MyDBhelper.java为自定义本地数据库类;
Cmon包中的文件为自定义的数据结构;
Com.surekam.controller包中的文件为控制类;
Com.surekam.data包中的文件为数据库操作类;
Com.surekam.service包中的文件为连接服务器类。
控制类:
数据库操作类:
连接服务器类:
本地数据库:
模块联系图:
2、模块/函数设计
数据库表结构:
登陆界面数据结构:
功能:
用户界面类-------显示设计好的界面布局,监听用户事件,如按钮事件,输入事件等,并传递给控制类。
控制类---------接收从用户界面类传来的事件,做部分处理,使之能直接用于数据库操作,然后交给数据库操作类。
数据库操作类-------根据控制类传来的事件,进行数据库插入,更新,查找等操作。
可以直接对本地数据库进行操作,也可以访问远程服务器。
连接服务器类--------连接远程服务器,下载数据。
本地数据库类--------管理本地数据库,包括重置,最后连接远程数据库时间记录等。
3、测试方案
采用黑盒测试。
三、系统实现
a)连接远程数据库类
packagecom.surekam.service;
importjava.io.BufferedReader;
importjava.io.InputStream;
importjava.io.InputStreamReader;
importjava.util.ArrayList;
importjava.util.List;
importorg.apache.http.HttpResponse;
importorg.apache.http.client.HttpClient;
importorg.apache.http.client.methods.HttpGet;
importorg.apache.http.client.methods.HttpPost;
importorg.apache.http.entity.StringEntity;
importorg.apache.http.impl.client.DefaultHttpClient;
importorg.apache.http.protocol.HTTP;
importorg.json.JSONArray;
importorg.json.JSONException;
importorg.json.JSONObject;
importorg.ksoap2.SoapEnvelope;
importorg.ksoap2.serialization.PropertyInfo;
importorg.ksoap2.serialization.SoapObject;
importorg.ksoap2.serialization.SoapSerializationEnvelope;
importorg.ksoap2.transport.HttpTransportSE;
importandroid.content.Context;
importmon.Member;
publicclassServiceImplimplementsIService{
privateContextcontext;
StringNAMESPACE="http:
//tempuri.org/";
StringSERVICE_URL="
StringvalidateMethod="AuthenticateUser";
StringgetContactsMethod="GetContacts";
StringsoapAction1="http:
//tempuri.org/IContactService/AuthenticateUser";
StringsoapAction2="http:
//tempuri.org/IContactService/GetContacts";
StringSERVICE_URL1="http:
//58.20.0.21:
81/restepmservice";
Stringurl=SERVICE_URL1+"/authenticateuser";
StringgetContactURL;
/*protectedServiceImpl(Contextcontext){
this.context=context;
}
@Override
publicStringvalidate(StringuserName,Stringpasswd){
StringreturnResult="netError";
//Post方式
Mapmap=newHashMap();
map.put("UserId",userName);
map.put("Password",passwd);
JSONObjectjson=newJSONObject(map);
//Stringjson2={"UserId":
"string","Password":
"string"}
returnResult=getPostResponse(url,json.toString());//true/false
returnreturnResult;
}*/
protectedServiceImpl(Contextcontext){
this.context=context;
}
@Override
publicStringvalidate(StringuserName,Stringpasswd){
StringreturnResult="netError";
try{
SoapObjectsoapObject=newSoapObject(NAMESPACE,validateMethod);
PropertyInfoinfo=newPropertyInfo();
info.name="userId";
PropertyInfoinfo2=newPropertyInfo();
info2.name="password";
soapObject.addProperty(info,userName);
soapObject.addProperty(info2,passwd);
SoapSerializationEnvelopeenvelope=newSoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut=soapObject;
envelope.dotNet=true;
HttpTransportSEht=newHttpTransportSE(SERVICE_URL);
ht.call(soapAction1,envelope);
Stringresult=envelope.getResponse().toString();
if(Boolean.parseBoolean(result)){
returnResult="true";
}else{
returnResult="false";
}
}catch(Exceptione){
e.printStackTrace();
}
returnreturnResult;
}
@Override
publicListgetContacts(StringuserName,Stringpwd,StringlastUpdateTime,intstart,
intend){
//GET方式
Membercontact=newMember();
ListreturnList=newArrayList();
getContactURL=SERVICE_URL1+"/read/contactlist?
userId="
+userName+"&password="+pwd+"&start="+start
+"&end="+end+"×tamp="+lastUpdateTime;
Stringresponse=getGetResponse(getContactURL);
try{
JSONObjectjson=newJSONObject(response);
intcount=json.getInt("Count");
intlp=count/end;
for(intj=0;j<=lp;j++)
{
/*inttemp=end;
start=temp*j;
end=temp*(j+1);
getContactURL=SERVICE_URL1+"/read/contactlist?
userId="
+userName+"&password="+pwd+"&start="+start
+"&end="+end+"×tamp="+lastUpdateTime;
Stringresponse1=getGetResponse(getContactURL);
JSONObjectjson1=newJSONObject(response1);*/
JSONArrayarray=json.getJSONArray("Contacts");
for(inti=0;icontact=newMember();
JSONObjectjsonObject=array.getJSONObject(i);
//for(Iteratoriter=jsonObject.keys();iter.hasNext();){
//Stringkey=iter.next();
//jsonObject.get(key);
//}
contact.setRdept(jsonObject.getString("DepartmentName"));
contact.setDept(jsonObject.getString("GroupName"));
contact.setTelephone(jsonObject.getString("MobilePhone"));
contact.setUsername(jsonObject.getString("UserName"));
contact.setUserid(jsonObject.getString("UserId"));
contact.setIsactive(jsonObject.getString("IsActive"));
contact.setPosition(jsonObject.getString("Position"));
//其他属性自己添加吧!
如:
职位、是否离职(是否离职是必须的,做本地数据库时需要根据该属性来增删联系人)
returnList.add(contact);
}
}
}catch(JSONExceptione){
e.printStackTrace();
}
returnreturnList;
}
//用POST方式提交数据给webService
privateStringgetGetResponse(Stringurl){
StringBufferresult=newStringBuffer();
try{
HttpClientclient=newDefaultHttpClient();
HttpGetget=newHttpGet(url);
HttpResponseresponse=client.execute(get);
InputStreaminput=response.getEntity().getContent();
InputStreamReaderreader=newInputStreamReader(input);
BufferedReaderbfReader=newBufferedReader(reader);
Stringtemp;
while((temp=bfReader.readLine())!
=null){
result.append(temp);
}
}catch(Exceptione){
e.printStackTrace();
}
returnresult.toString();
}
//用GET方式获取webservice数据
privateStringgetPostResponse(Stringurl,Stringjson){
//post(fangshi)
Stringresult="false";
try{
//
HttpClientclient=newDefaultHttpClient();
HttpPostpost=newHttpPost(url);
StringEntityentity=newStringEntity(json,HTTP.UTF_8);
entity.setContentType("text/xml");
post.setHeader("Content-Type","application/json;charset=UTF-8");
post.setEntity(entity);
HttpResponseresponse=client.execute(post);
InputStreaminputStream=response.getEntity().getContent();
InputStreamReaderreader=newInputStreamReader(inputStream);
BufferedReaderbfReader=newBufferedReader(reader);
Stringtemp;
StringBufferbs=newStringBuffer();
while((temp=bfReader.readLine())!
=null){
bs.append(temp);
}
result=bs.toString();//true(String)
//"Content-Type","application/json;charset=UTF-8"
}catch(Exceptione){
e.printStackTrace();
}
returnresult;
}
}
b)本地数据库类
packagecom.surekam;
importjava.util.ArrayList;
importjava.util.List;
importandroid.content.Context;
importandroid.database.Cursor;
importandroid.database.sqlite.SQLiteDatabase;
importandroid.database.sqlite.SQLiteOpenHelper;
importmon.Member;
publicclassMyDBhelperextendsSQLiteOpenHelper{
privateArrayListuser=newArrayList();
privateArrayListls;
privateMemberpeople=newMember();
privatestaticfinalStringCREATE_TABLE_SQL="createtableTempTbl(idtextprimarykey,nametext,rdepttext,depttext,teltext,isactivetext,positiontext)";
publicMyDBhelper(Contextc){
super(c,"text1.db",null,2);
//TODOAuto-generatedconstructorstub
}
@Override
publicvoidonCreate(SQLiteDatabasedb){
//TODOAuto-generatedmethodstub
db.execSQL(CREATE_TABLE_SQL);
}
@Override
publicvoidonUpgrade(SQLiteDatabasearg0,intarg1,intarg2){
//TODOAuto-generatedmethodstub
}
/*publicvoid