基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,215 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace Lskj.AttachStart.Service
|
||||
{
|
||||
internal class LSDBManage
|
||||
{
|
||||
public SqlConnection conn = null;
|
||||
public static string connectionStr = "";
|
||||
public static Dictionary<string, LSDBManage> dbmanageList = new Dictionary<string, LSDBManage>();
|
||||
|
||||
public int checkFileLockState(int fileId, int parentId, string name)
|
||||
{
|
||||
int num = 0;
|
||||
try
|
||||
{
|
||||
SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@RetParam", SqlDbType.Int), new SqlParameter("@fileId", SqlDbType.Int), new SqlParameter("@parentId", SqlDbType.Int), new SqlParameter("@name", SqlDbType.VarChar, 64) };
|
||||
parameterArray[0].Direction = ParameterDirection.ReturnValue;
|
||||
parameterArray[1].Value = fileId;
|
||||
parameterArray[2].Value = parentId;
|
||||
parameterArray[3].Value = name;
|
||||
using (SqlCommand command = new SqlCommand("pr_fm_CheckFileLockState", this.conn))
|
||||
{
|
||||
command.CommandType = CommandType.StoredProcedure;
|
||||
foreach (SqlParameter parameter in parameterArray)
|
||||
{
|
||||
command.Parameters.Add(parameter);
|
||||
}
|
||||
command.ExecuteNonQuery();
|
||||
num = int.Parse(parameterArray[0].Value.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
//PubUtils.WriteLog("LSDBManage.createFile error is : {0} ", new object[] { exception });
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public int createFile(int parentId, string name, int fileSize, int creator, int productId)
|
||||
{
|
||||
int num = 0;
|
||||
try
|
||||
{
|
||||
SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@RetParam", SqlDbType.Int), new SqlParameter("@parentId", SqlDbType.Int), new SqlParameter("@name", SqlDbType.VarChar, 500), new SqlParameter("@fileSize", SqlDbType.Int), new SqlParameter("@creator", SqlDbType.Int), new SqlParameter("@productId", SqlDbType.Int) };
|
||||
parameterArray[0].Direction = ParameterDirection.ReturnValue;
|
||||
parameterArray[1].Value = parentId;
|
||||
parameterArray[2].Value = name;
|
||||
parameterArray[3].Value = fileSize;
|
||||
parameterArray[4].Value = creator;
|
||||
parameterArray[5].Value = productId;
|
||||
using (SqlCommand command = new SqlCommand("pr_fm_createFile", this.conn))
|
||||
{
|
||||
command.CommandType = CommandType.StoredProcedure;
|
||||
foreach (SqlParameter parameter in parameterArray)
|
||||
{
|
||||
command.Parameters.Add(parameter);
|
||||
}
|
||||
command.ExecuteNonQuery();
|
||||
num = int.Parse(parameterArray[0].Value.ToString());
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
//PubUtils.WriteLog("LSDBManage.createFile error is : {0} ", new object[] { exception });
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public bool deleteFile(int fileId)
|
||||
{
|
||||
bool flag = false;
|
||||
try
|
||||
{
|
||||
SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@RetParam", SqlDbType.Int), new SqlParameter("@fileId", SqlDbType.Int) };
|
||||
parameterArray[0].Direction = ParameterDirection.ReturnValue;
|
||||
parameterArray[1].Value = fileId;
|
||||
using (SqlCommand command = new SqlCommand("pr_fm_deleteFile", this.conn))
|
||||
{
|
||||
command.CommandType = CommandType.StoredProcedure;
|
||||
foreach (SqlParameter parameter in parameterArray)
|
||||
{
|
||||
command.Parameters.Add(parameter);
|
||||
}
|
||||
command.ExecuteNonQuery();
|
||||
flag = int.Parse(parameterArray[0].Value.ToString()) == 1;
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
//PubUtils.WriteLog("LSDBManage.deleteFile fileId={0} error is : {1} ", new object[] { fileId, exception });
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public bool existFile(int parentId, string name)
|
||||
{
|
||||
bool flag = false;
|
||||
try
|
||||
{
|
||||
SqlCommand command = new SqlCommand(string.Format("select * from P_fm_FileTab where parentId={0} and sName='{1}'", parentId, name), this.conn)
|
||||
{
|
||||
CommandType = CommandType.Text
|
||||
};
|
||||
using (SqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
command.Dispose();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
//PubUtils.WriteLog("LSDBManage.existFile error is : {0} ", new object[] { exception });
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
public string getAbsoluteFile(int dwFileId)
|
||||
{
|
||||
if (dwFileId <= 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
string str = "";
|
||||
try
|
||||
{
|
||||
using (SqlDataReader reader = this.querySql(string.Format("select dbo.[fun_fm_getAbsolutePath]({0}) as absolutePath", dwFileId)))
|
||||
{
|
||||
if ((reader != null) && reader.Read())
|
||||
{
|
||||
str = reader["absolutePath"].ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
//PubUtils.WriteLog("LSDBManage.getAbsoluteFile error is : {0} ", new object[] { exception });
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public SqlDataReader getDownloadFileList(int parentId, string fileIds, string strProductIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
SqlCommand command = new SqlCommand("pr_fm_getDownloadFileInfo", this.conn)
|
||||
{
|
||||
CommandType = CommandType.StoredProcedure
|
||||
};
|
||||
SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@parentId", SqlDbType.Int), new SqlParameter("@fileIds", SqlDbType.VarChar, 1000), new SqlParameter("@productIds", SqlDbType.VarChar, 1000) };
|
||||
parameterArray[0].Value = parentId;
|
||||
parameterArray[1].Value = fileIds;
|
||||
parameterArray[2].Value = strProductIds;
|
||||
command.Parameters.Add(parameterArray[0]);
|
||||
command.Parameters.Add(parameterArray[1]);
|
||||
command.Parameters.Add(parameterArray[2]);
|
||||
return command.ExecuteReader();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
//PubUtils.WriteLog("LSDBManage.getDownloadFileList error is : {0} ", new object[] { exception });
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public string getRelativePath(int parentId)
|
||||
{
|
||||
if (parentId <= 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
string str = "";
|
||||
try
|
||||
{
|
||||
using (SqlDataReader reader = this.querySql(string.Format("select dbo.[fun_fm_getRelativePath]({0}) as relativePath", parentId)))
|
||||
{
|
||||
if ((reader != null) && reader.Read())
|
||||
{
|
||||
str = reader["relativePath"].ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
//PubUtils.WriteLog("LSDBManage.getRelativePath error is : {0} ", new object[] { exception });
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public SqlDataReader querySql(string strSql)
|
||||
{
|
||||
try
|
||||
{
|
||||
SqlCommand command = new SqlCommand(strSql, this.conn)
|
||||
{
|
||||
CommandType = CommandType.Text
|
||||
};
|
||||
return command.ExecuteReader();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
//PubUtils.WriteLog("LSDBManage.querySql error is : {0} ", new object[] { exception });
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user