using Silverlight_Log.Web;
namespace Silverlight_Log.Web {
[ServiceContract(Namespace = \)]
[AspNetCompatibilityRequirements(RequirementsMode AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(IncludeExceptionDetailInFaults = true)]
public class Service1 {
private string filePath;
public Service1() {
filePath = HttpContext.Current.Server.MapPath(\); }
[OperationContract]
public void UploadFile(string fileName, byte[] data) {
string file = Path.Combine(filePath, Path.GetFileName(fileName)); using (FileStream fs = new FileStream(file, FileMode.Create)) {
fs.Write(data, 0, (int)data.Length); } }
[OperationContract]
public string[] GetFileList() {
string[] files = Directory.GetFiles(filePath); for (int i = 0; i < files.Count(); i++) files[i] = Path.GetFileName(files[i]); return files; }
[OperationContract]
public List
List
using (tgNetEntities3 en = new tgNetEntities3()) {
=
31
foreach (var e in en.tgNetPrd) {
Product prd = new Product();
prd._pname = e.pname; prd._parea = e.parea; prd._pdisc = e.pdisc;
prd._pDnTime = (DateTime)e.pDnTime; prd._photoPath = e.photoPath; prd._pnum = (int)e.pnum; prd._prc = (decimal)e.prc; prd._premark = e.premark; prd._psize = e.psize; prd._ptgnum = (int)e.ptgnum; prd._ptype = e.ptype;
prd._pUpTime = (DateTime)e.pUpTime; prd._tgprc = (decimal)e.tgprc; prd._pictName = e.pictName;
list.Add(prd); }
return list; } }
[OperationContract]
public void AddProduct(Product e,int g) {
using (tgNetEntities3 en = new tgNetEntities3()) {
tgNetPrd prd = new tgNetPrd(); prd.parea = e._parea; prd.pdisc = e._pdisc; prd.pDnTime = e._pDnTime; prd.photoPath = e._photoPath; prd.pictName = e._pictName;// prd.pname = e._pname; // prd.pnum = e._pnum; prd.prc = (float)e._prc; prd.premark = e._premark; prd.psize = e._psize;
32
prd.ptgnum = e._ptgnum; prd.ptype = e._ptype; prd.pUpTime = e._pUpTime; prd.tgprc = (float)e._tgprc; prd.sellerID = g;
en.AddTotgNetPrd(prd); en.SaveChanges(); } }
[OperationContract]
public BuyerType GetBuyerData(int i) {
using (tgNetEntities3 en = new tgNetEntities3()) {
int j = en.tgNetBLogInfo.Where(n => n.buyerID == i).Count(); if (j != 0) {
var sel = en.tgNetBLogInfo.Where(n => n.buyerID == i).First(); BuyerType st = new BuyerType(); st._bphone = sel.bphone; st._brealname = sel.brealname; st._uemail = sel.uemail; return st; } else {
return null; } } }
[OperationContract]
public List
List
foreach (var e in en.tgNetSLogInfo) {
SellerType st = new SellerType();
33
st._sBankID = e.sBankID; st._sBankName = e.sBankName; st._sellerID = e.sellerID; st._sID = e.sID; st._uemail = e.uemail; st._upsw = e.upsw; st._sname = e.sname; st._sunm = e.sunm; st._sphone = e.sphone; st._srealname = e.srealname;
list.Add(st); }
return list; } }
[OperationContract]
public void AddSeller(SellerType e) {
using (tgNetEntities3 en = new tgNetEntities3()) {
tgNetSLogInfo st = new tgNetSLogInfo(); st.sBankID = e._sBankID; st.sBankName = e._sBankName; st.sellerID = e._sellerID; st.sID = e._sID; st.uemail = e._uemail; st.upsw = e._upsw; st.sname = e._sname; st.sunm = e._sunm; st.sphone = e._sphone; st.srealname = e._srealname; en.AddTotgNetSLogInfo(st); //en.AddToBuyerInf(st); en.SaveChanges(); } }
[OperationContract]
public void AddBuyer(BuyerType e) {
using (tgNetEntities3 en = new tgNetEntities3()) {
tgNetBLogInfo st = new tgNetBLogInfo(); st.bname = e._bname;
34
st.bphone = e._bphone; st.brealname = e._brealname; st.buyerID = e._buyerID; st.uemail = e._uemail; st.upsw = e._upsw; st.bgrade = 10000;
en.AddTotgNetBLogInfo(st); //en.AddToBuyerInf(st); en.SaveChanges(); } }
[OperationContract]
public bool BuyerLog(BuyerType b) {
using (tgNetEntities3 en = new tgNetEntities3()) {
int sel = en.tgNetBLogInfo.Where(n => n.uemail == b._uemail).Where(n => n.upsw == b._upsw).Count(); if (sel == 0) {
return false; } else {
return true; } } }
[OperationContract]
public bool SellerLog(SellerType b) {
using (tgNetEntities3 en = new tgNetEntities3()) {
int sel = en.tgNetSLogInfo.Where(n => n.uemail == b._uemail).Where(n => n.upsw == b._upsw).Count(); if (sel == 0) {
return false; } else {
return true; } }
35