You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
5.5 KiB
C#

10 months ago
using System;
using System.Data;
using System.Collections.Generic;
using System.Text;
using DSWeb.MvcShipping.Models.FtpSet;
using Microsoft.Practices.EnterpriseLibrary.Data;
using DSWeb.Areas.CommMng.Models;
using HcUtility.Comm;
namespace DSWeb.MvcShipping.DAL.MsCodeFtpSet
{
public class MsCodeFtpSetDAL
{
#region Inquery DataList
static public List<CodeFtpSet> GetDataList(string strCondition, string companyid, string sort = null)
{
var strSql = new StringBuilder();
strSql.Append("SELECT ");
strSql.Append("GID,EDINAME,SERVERIP,FOLDERNAME,USERNAME,[PASSWORD],CORPID,SENDCODE,RECEIVEEMAIL,RECEIVESIEMAIL,SERVERIP2,FOLDERNAME2,USERNAME2,[PASSWORD2],ISSSL,SFTPPORT,ISDJYKF,");
strSql.Append("RECEIVECODE,SENDNAME,SENDATTN,SENDTEL,SENDEMAIL,RECEIVEOP,RECEIVESALE,RECEIVEDEPT,SENDCOMPANYCODE,SENDSUBCOMPANYCODE,CARRIERID,SHIPPERTEL,CONSIGNEETEL,NOTIFYPARTYTEL,ISUSETEL,ALIASSENDCODE,TMPFOLDERNAME,SFTPCERFILENAME ");
strSql.Append(" from code_FtpSet where CORPID='"+companyid+"'");
if (!string.IsNullOrEmpty(strCondition))
{
strSql.Append(" and " + strCondition);
}
var sortstring = DatasetSort.Getsortstring(sort);
if (!string.IsNullOrEmpty(sortstring))
{
strSql.Append(" order by " + sortstring);
}
else {
strSql.Append(" order by EDINAME");
}
return SetData(strSql);
}
static public CodeFtpSet GetData(string condition, string companyid)
{
CodeFtpSet data = null;
var list = GetDataList(condition,companyid);
if (list.Count > 0)
data = list[0];
if (data == null)
{
data = new CodeFtpSet();
}
return data;
}
private static List<CodeFtpSet> SetData(StringBuilder strSql)
{
var headList = new List<CodeFtpSet>();
Database db = DatabaseFactory.CreateDatabase();
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
{
while (reader.Read())
{
CodeFtpSet data = new CodeFtpSet();
#region Set DB data to Object
data.GID = Convert.ToString(reader["GID"]);
data.EDINAME = Convert.ToString(reader["EDINAME"]);
data.SERVERIP = Convert.ToString(reader["SERVERIP"]);
data.FOLDERNAME = Convert.ToString(reader["FOLDERNAME"]);
data.USERNAME = Convert.ToString(reader["USERNAME"]);
data.PASSWORD = Convert.ToString(reader["PASSWORD"]);
data.CORPID = Convert.ToString(reader["CORPID"]);
data.SENDCODE = Convert.ToString(reader["SENDCODE"]);
data.RECEIVECODE = Convert.ToString(reader["RECEIVECODE"]);
data.SENDNAME = Convert.ToString(reader["SENDNAME"]);
data.SENDATTN = Convert.ToString(reader["SENDATTN"]);
data.SENDTEL = Convert.ToString(reader["SENDTEL"]);
data.SENDEMAIL = Convert.ToString(reader["SENDEMAIL"]);
data.RECEIVEOP = Convert.ToString(reader["RECEIVEOP"]);
data.RECEIVESALE = Convert.ToString(reader["RECEIVESALE"]);
data.RECEIVEDEPT = Convert.ToString(reader["RECEIVEDEPT"]);
data.SENDCOMPANYCODE = Convert.ToString(reader["SENDCOMPANYCODE"]);
data.SENDSUBCOMPANYCODE = Convert.ToString(reader["SENDSUBCOMPANYCODE"]);
data.CARRIERID = Convert.ToString(reader["CARRIERID"]);
data.RECEIVEEMAIL = Convert.ToString(reader["RECEIVEEMAIL"]);
data.RECEIVESIEMAIL = Convert.ToString(reader["RECEIVESIEMAIL"]);
data.SHIPPERTEL = Convert.ToString(reader["SHIPPERTEL"]);
data.CONSIGNEETEL = Convert.ToString(reader["CONSIGNEETEL"]);
data.NOTIFYPARTYTEL = Convert.ToString(reader["NOTIFYPARTYTEL"]);
data.ISUSETEL = Convert.ToString(reader["ISUSETEL"]);
data.SERVERIP2 = Convert.ToString(reader["SERVERIP2"]);
data.FOLDERNAME2 = Convert.ToString(reader["FOLDERNAME2"]);
data.USERNAME2 = Convert.ToString(reader["USERNAME2"]);
data.PASSWORD2 = Convert.ToString(reader["PASSWORD2"]);
data.ALIASSENDCODE = Convert.ToString(reader["ALIASSENDCODE"]);
data.TMPFOLDERNAME = Convert.ToString(reader["TMPFOLDERNAME"]);
data.SFTPCERFILENAME = Convert.ToString(reader["SFTPCERFILENAME"]);
if (reader["ISSSL"] != DBNull.Value)
data.ISSSL = Convert.ToBoolean(reader["ISSSL"]);//货主箱标志,是否自有箱
if (reader["ISDJYKF"] != DBNull.Value)
data.ISDJYKF = Convert.ToBoolean(reader["ISDJYKF"]);//货主箱标志,是否自有箱
if (reader["SFTPPORT"] != DBNull.Value)
data.SFTPPORT = Convert.ToString(reader["SFTPPORT"]);
#endregion
headList.Add(data);
}
reader.Close();
}
return headList;
}
#endregion
#region 参照部分
#endregion
}
}