ldj/codeSmith/WcfService.cst

149 lines
5.2 KiB
Plaintext
Raw Normal View History

2023-05-23 16:13:17 +08:00
<%@ CodeTemplate Language="C#" TargetLanguage="Text" Description="This template demonstrates using properties defined in external assemblies." %>
<%@ Property Name="SourceDatabase" Type="SchemaExplorer.DatabaseSchema" Category="Context" Description="Database that the documentation should be based on." %>
<%@ Property Name="SourceTable" Type="SchemaExplorer.TableSchema" Category="Context" Description="The table to use for this sample." %>
<%@ Assembly Name="SchemaExplorer" %>
<%@ Import Namespace="SchemaExplorer" %>
<script runat="template">
<!-- #include file="scripts.cs" -->
</script>
/// <summary>
///WCF service
///FOR TABLE <%=this.SourceTable.Name%>
///By wm
///on <%= DateTime.Now.ToString("MM/dd/yyyy")%>
/// </summary>
using System.Collections.Generic;
using System.Data;
using DeiNiu.wms.Data.Model.Wcf ;
using DeiNiu.wms.Data.Model;
using System.Transactions;
using DeiNiu.Utils;
using System;
using DeiNiu.Wcf.erp.wcfData;
namespace DeiNiu.Wcf
{
// 注意: 使用“重构”菜单上的“重命名”命令可以同时更改代码、svc 和配置文件中的类名 。
public class <%=getTableName() %> : <%=getWcfSvcInterfaceName() %>
{
#region options
/*: basicService,
private static <%=getLogicClassName()%> _<%=getLogicClassName()%> ;
<%=getLogicClassName()%> <%=getLogicClassName()%>Obj
{
get
{
if ( _<%=getLogicClassName()%> == null || _<%=getLogicClassName()%>.operId != getOperId())
{
_<%=getLogicClassName()%>= new <%=getLogicClassName()%>(getOperId());
}
return _<%=getLogicClassName()%>;
}
}
*/
#endregion
public enumDbResult add(<%=getWcfClassName() %> obj)
{
return obj.getDbObject().Add()>0? enumDbResult.成功: enumDbResult.失败;
}
public enumDbResult update(<%=getWcfClassName() %> obj)
{
return obj.getDbObject().Update()>0? enumDbResult.成功: enumDbResult.失败;
}
public enumDbResult delete(<%=getWcfClassName() %> obj)
{
return obj.getDbObject().Delete()>0? enumDbResult.成功: enumDbResult.失败;
}
#region options
/*
public List<Result> updateList(List<<%=getWcfClassName() %>> objs)
{
List<Result> results = new List<Result>();
// using (TransactionScope scope = new TransactionScope())
{
foreach (<%=getWcfClassName() %> obj in objs)
{
Result rs = new Result(obj.id, obj.getDbObject().Update());
results.Add(rs);
}
// scope.Complete();
}
return results;
}
public List<Result> addList(List<<%=getWcfClassName() %>> objs)
{
List<Result> results = new List<Result>();
// using (TransactionScope scope = new TransactionScope())
{
foreach (<%=getWcfClassName() %> obj in objs)
{
Result rs = new Result( obj.getDbObject().Add(),1);
results.Add(rs);
}
// scope.Complete();
}
return results;
}
public List<Result> deleteList(List<<%=getWcfClassName() %>> objs)
{
List<Result> results = new List<Result>();
// using (TransactionScope scope = new TransactionScope())
{
foreach (<%=getWcfClassName() %> obj in objs)
{
Result rs = new Result(obj.id, obj.getDbObject().Delete());
results.Add(rs);
}
// scope.Complete();
}
return results;
}*/
#endregion
public <%=getWcfClassName() %> getObj(int Id)
{
<%=getWcfClassName() %> wcfObj = new <%=getWcfClassName() %> ();
<%=getObjClassNameExt() %> dbObj = new <%=getObjClassNameExt() %>(Id);
return wcfObj.getWcfObject(dbObj);
}
public <%=getWcfClassName() %>List query(string condition, int pageno)
{
condition = string.IsNullOrEmpty(condition) ? "" : condition;
<%=getWcfClassName() %>List objLst = new <%=getWcfClassName() %>List();
List<<%=getWcfClassName() %>> lst = new List<<%=getWcfClassName() %>>();
<%=getObjClassNameExt() %> dbObj = new <%=getObjClassNameExt() %>();
dbObj.rownumStart =(Convert.ToInt16( pageno)-1)* WmsConstants.PAGER_SIZE;
dbObj.rownumEnd = dbObj.rownumStart + DeiNiu.Utils.WmsConstants.PAGER_SIZE;
DataSet ds = dbObj.Query(condition);
DataTable dt = ds.Tables[0];
foreach(DataRow dr in dt.Rows)
{
lst.Add(new <%=getWcfClassName() %>(dr));
}
objLst.list =lst;
objLst.page = Convert.ToInt16(pageno);
objLst.pageSize = WmsConstants.PAGER_SIZE;
objLst.rows = Convert.ToInt32(ds.Tables[1].Rows[0][0].ToString());
objLst.pageCnt = objLst.rows / WmsConstants.PAGER_SIZE;
return objLst;
}
}
}