📄 serverpc.cpp
字号:
// ServerPC.cpp: implementation of the CServerPC class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "ServerPC.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CServerPC::CServerPC()
{
}
CServerPC::~CServerPC()
{
}
int CServerPC::GetUID()
{
return UID;
}
void CServerPC::SetUID(int iUID)
{
UID=iUID;
}
CString CServerPC::GetIPStr()
{
return IPStr;
}
CString CServerPC::GetDesc()
{
return Desc;
}
int CServerPC::GetType()
{
return Type;
}
int CServerPC::GetPriority()
{
return Priority;
}
CString CServerPC::GetPSDir()
{
return PSDir;
}
CString CServerPC::GetPSDir1()
{
return PSDir1;
}
CString CServerPC::GetPSDir2()
{
return PSDir2;
}
CString CServerPC::GetPSDir3()
{
return PSDir3;
}
void CServerPC::SetIPStr(CString cIPStr)
{
IPStr=cIPStr;
}
void CServerPC::SetDesc(CString cDesc)
{
Desc=cDesc;
}
void CServerPC::SetType(int iType)
{
Type=iType;
}
void CServerPC::SetPriority(int iPriority)
{
Priority=iPriority;
}
void CServerPC::SetPSDir(CString cPSDir)
{
PSDir=cPSDir;
}
void CServerPC::SetPSDir1(CString cPSDir1)
{
PSDir1=cPSDir1;
}
void CServerPC::SetPSDir2(CString cPSDir2)
{
PSDir2=cPSDir2;
}
void CServerPC::SetPSDir3(CString cPSDir3)
{
PSDir3=cPSDir3;
}
void CServerPC::SetPort(int iPort)
{
Port=iPort;
}
int CServerPC::GetPort()
{
return Port;
}
int CServerPC::GetIDByIPStr(CString cIPStr)
{
int iUID=0;
vSQL = "SELECT UID FROM ServerPC WHERE IsDelete = 0 AND IPStr='" + cIPStr+"'";
//执行SELETE语句
m_pRecordset = GetRecordSet(vSQL);
//返回各列的值
if (m_pRecordset->adoEOF)
CServerPC();
else
{
iUID = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("UID"));
}
return iUID;
}
void CServerPC::ShowList(CListCtrl& listctrl)
{
int i=0;
LV_ITEM lvitem;
lvitem.mask=LVIF_TEXT | LVIF_IMAGE | LVIF_STATE;
lvitem.state=0;
lvitem.stateMask=0;
CString strUID,strIPStr,strDesc,strDescription,strType,strPriority;
CString strPSDir,strPSDir1,strPSDir2,strPSDir3,strPort,strTemp;
//设置SELECT语句
vSQL = "SELECT * FROM ServerPC WHERE IsDelete = 0";
//执行SELETE语句
m_pRecordset = GetRecordSet(vSQL);
listctrl.DeleteAllItems();
while(!m_pRecordset->adoEOF)
{
lvitem.iItem=i;
lvitem.iSubItem=0;
strUID=(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("UID");
lvitem.pszText=(LPTSTR)(LPCTSTR)strUID;
listctrl.InsertItem(&lvitem);
strIPStr =(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("IPStr");
listctrl.SetItemText(i,1,strIPStr);
_variant_t varDescription = m_pRecordset->GetCollect("Description");
if(varDescription.vt != VT_NULL)
{
strDescription = (LPCSTR)(_bstr_t)(varDescription);
}
listctrl.SetItemText(i,2,strDescription);
strTemp =(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Type");
if(strTemp=="0")
{
strType="审片服务器";
}
else
{
strType="总串服务端";
}
listctrl.SetItemText(i,3,strType);
strTemp =(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Priority");
if(strTemp=="0")
{
strPriority="主服务器";
}
else
{
strPriority="备份服务器";
}
listctrl.SetItemText(i,4,strPriority);
_variant_t varPSDir = m_pRecordset->GetCollect("PSDir");
if(varPSDir.vt != VT_NULL)
{
strPSDir = (LPCSTR)(_bstr_t)(varPSDir);
}
listctrl.SetItemText(i,5,strPSDir);
strPort =(LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Port");
listctrl.SetItemText(i,6,strPort);
i++;
m_pRecordset->MoveNext();
}
}
void CServerPC::sql_insert(CString cIPStr,CString cDesc,long iType,long iPriority,CString cPSDir,long iPort,long& iFlg,CString& cMessage)
{
try
{
m_pCommand.CreateInstance(__uuidof(Command));
m_pCommand->ActiveConnection=m_pConnection;
m_pCommand->CommandType=adCmdStoredProc;
m_pCommand->CommandText=_bstr_t("ins_ServerPC");
_variant_t vvar1,vvar2,vvar3,vvar4,vvar5,vvar6,vvar7,vvar8;
vvar1=_variant_t(_bstr_t(cIPStr));
vvar2=_variant_t(_bstr_t(cDesc));
vvar3=_variant_t(iType);
vvar4=_variant_t(iPriority);
vvar5=_variant_t(_bstr_t(cPSDir));
vvar6=_variant_t(iPort);
vvar7=_variant_t(iFlg);
vvar8=_variant_t(_bstr_t(cMessage));
_ParameterPtr mp_var1,mp_var2,mp_var3,mp_var4,mp_var5,mp_var6,mp_var7,mp_var8,mp_var9,mp_var10,mp_var11;
mp_var1.CreateInstance(__uuidof(Parameter));
mp_var2.CreateInstance(__uuidof(Parameter));
mp_var3.CreateInstance(__uuidof(Parameter));
mp_var4.CreateInstance(__uuidof(Parameter));
mp_var5.CreateInstance(__uuidof(Parameter));
mp_var6.CreateInstance(__uuidof(Parameter));
mp_var7.CreateInstance(__uuidof(Parameter));
mp_var8.CreateInstance(__uuidof(Parameter));
mp_var1=m_pCommand->CreateParameter
(
_bstr_t("var1"),
adVarChar,
adParamInput,
50,
vvar1
);
m_pCommand->Parameters->Append(mp_var1);
mp_var2=m_pCommand->CreateParameter
(
_bstr_t("var2"),
adVarChar,
adParamInput,
200,
vvar2
);
m_pCommand->Parameters->Append(mp_var2);
mp_var3=m_pCommand->CreateParameter
(
_bstr_t("var3"),
adBigInt,
adParamInput,
5,
vvar3
);
m_pCommand->Parameters->Append(mp_var3);
mp_var4=m_pCommand->CreateParameter
(
_bstr_t("var4"),
adBigInt,
adParamInput,
5,
vvar4
);
m_pCommand->Parameters->Append(mp_var4);
mp_var5=m_pCommand->CreateParameter
(
_bstr_t("var5"),
adVarChar,
adParamInput,
200,
vvar5
);
m_pCommand->Parameters->Append(mp_var5);
mp_var6=m_pCommand->CreateParameter
(
_bstr_t("var6"),
adBigInt,
adParamInput,
5,
vvar6
);
m_pCommand->Parameters->Append(mp_var6);
mp_var7=m_pCommand->CreateParameter
(
_bstr_t("var7"),
adBigInt,
adParamOutput,
5,
vvar7
);
m_pCommand->Parameters->Append(mp_var7);
mp_var8=m_pCommand->CreateParameter
(
_bstr_t("var8"),
adVarChar,
adParamOutput,
200,
vvar8
);
m_pCommand->Parameters->Append(mp_var8);
_variant_t vNull;
vNull.vt=VT_ERROR;
vNull.scode=DISP_E_PARAMNOTFOUND;
m_pCommand->Execute(&vNull,&vNull,adCmdStoredProc);
iFlg=mp_var7->Value;
cMessage=mp_var8->Value.bstrVal;
}
catch(_com_error &error)
{
AfxMessageBox(error.ErrorMessage(),MB_OK,0);
AfxMessageBox(error.Description(),MB_OK,0);
AfxMessageBox("ADO错误!",MB_OK,0);
}
}
void CServerPC::sql_update(long iUID,CString cIPStr,CString cDesc,long iType,long iPriority,CString cPSDir,long iPort,long& iFlg,CString& cMessage)
{
try
{
m_pCommand.CreateInstance(__uuidof(Command));
m_pCommand->ActiveConnection=m_pConnection;
m_pCommand->CommandType=adCmdStoredProc;
m_pCommand->CommandText=_bstr_t("edt_ServerPC");
_variant_t vvar1,vvar2,vvar3,vvar4,vvar5,vvar6,vvar7,vvar8,vvar9;
vvar1=_variant_t(_bstr_t(cIPStr));
vvar2=_variant_t(_bstr_t(cDesc));
vvar3=_variant_t(iType);
vvar4=_variant_t(iPriority);
vvar5=_variant_t(_bstr_t(cPSDir));
vvar6=_variant_t(iPort);
vvar7=_variant_t(iUID);
vvar8=_variant_t(iFlg);
vvar9=_variant_t(_bstr_t(cMessage));
_ParameterPtr mp_var1,mp_var2,mp_var3,mp_var4,mp_var5,mp_var6,mp_var7,mp_var8,mp_var9,mp_var10,mp_var11,mp_var12;
mp_var1.CreateInstance(__uuidof(Parameter));
mp_var2.CreateInstance(__uuidof(Parameter));
mp_var3.CreateInstance(__uuidof(Parameter));
mp_var4.CreateInstance(__uuidof(Parameter));
mp_var5.CreateInstance(__uuidof(Parameter));
mp_var6.CreateInstance(__uuidof(Parameter));
mp_var7.CreateInstance(__uuidof(Parameter));
mp_var8.CreateInstance(__uuidof(Parameter));
mp_var9.CreateInstance(__uuidof(Parameter));
mp_var1=m_pCommand->CreateParameter
(
_bstr_t("var1"),
adVarChar,
adParamInput,
50,
vvar1
);
m_pCommand->Parameters->Append(mp_var1);
mp_var2=m_pCommand->CreateParameter
(
_bstr_t("var2"),
adVarChar,
adParamInput,
200,
vvar2
);
m_pCommand->Parameters->Append(mp_var2);
mp_var3=m_pCommand->CreateParameter
(
_bstr_t("var3"),
adBigInt,
adParamInput,
5,
vvar3
);
m_pCommand->Parameters->Append(mp_var3);
mp_var4=m_pCommand->CreateParameter
(
_bstr_t("var4"),
adBigInt,
adParamInput,
5,
vvar4
);
m_pCommand->Parameters->Append(mp_var4);
mp_var5=m_pCommand->CreateParameter
(
_bstr_t("var5"),
adVarChar,
adParamInput,
200,
vvar5
);
m_pCommand->Parameters->Append(mp_var5);
mp_var6=m_pCommand->CreateParameter
(
_bstr_t("var6"),
adBigInt,
adParamInput,
5,
vvar6
);
m_pCommand->Parameters->Append(mp_var6);
mp_var7=m_pCommand->CreateParameter
(
_bstr_t("var7"),
adBigInt,
adParamInput,
5,
vvar7
);
m_pCommand->Parameters->Append(mp_var7);
mp_var8=m_pCommand->CreateParameter
(
_bstr_t("var8"),
adBigInt,
adParamOutput,
5,
vvar8
);
m_pCommand->Parameters->Append(mp_var8);
mp_var9=m_pCommand->CreateParameter
(
_bstr_t("var9"),
adVarChar,
adParamOutput,
200,
vvar9
);
m_pCommand->Parameters->Append(mp_var9);
_variant_t vNull;
vNull.vt=VT_ERROR;
vNull.scode=DISP_E_PARAMNOTFOUND;
m_pCommand->Execute(&vNull,&vNull,adCmdStoredProc);
iFlg=mp_var8->Value;
cMessage=mp_var9->Value.bstrVal;
}
catch(_com_error &error)
{
AfxMessageBox(error.ErrorMessage(),MB_OK,0);
AfxMessageBox(error.Description(),MB_OK,0);
AfxMessageBox("ADO错误!",MB_OK,0);
}
}
void CServerPC::GetData(int UID)
{
//设置SELECT语句
CString strUID;
strUID.Format("%d",UID);
vSQL = "SELECT * FROM ServerPC WHERE IsDelete = 0 AND UID=" + strUID;
//执行SELETE语句
m_pRecordset = GetRecordSet(vSQL);
//返回各列的值
if (m_pRecordset->adoEOF)
CServerPC();
else
{
IPStr = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("IPStr");
Desc = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Description");
Type = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Type"));
Priority = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Priority"));
PSDir = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("PSDir");
PSDir1 = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("PSDir1");
PSDir2 = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("PSDir2");
PSDir3 = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("PSDir3");
Port = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Port"));
}
}
void CServerPC::sql_delete(long iUID,long& iFlg,CString& cMessage)
{
CString strUID;
strUID.Format("%d", iUID);
vSQL = "UPDATE ServerPC SET IsDelete = 1 WHERE UID= "+ strUID ;
//执行INSERT语句
if(ExecuteSQL(vSQL))
{
iFlg =1;
cMessage="数据库执行成功";
}
else
{
iFlg=0;
cMessage="数据库执行出错";
}
}
/*
CString CServerPC::GetUploadIP()
{
vSQL = "SELECT IPStr FROM ServerPC WHERE Type=0 and Priority =0 and IsDelete=0 ";
//执行SELETE语句
m_pRecordset = GetRecordSet(vSQL);
if (m_pRecordset->adoEOF)
{
CServerPC();
}
else
{
IPStr = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("IPStr");
}
return IPStr;
}
*/
void CServerPC::GetUploadInf(int Type,int Priority)
{
//设置SELECT语句
CString strType,strPriority;
strType.Format("%d",Type);
strPriority.Format("%d",Priority);
vSQL = "SELECT * FROM ServerPC WHERE IsDelete = 0 AND Type=" + strType + " AND Priority= " + strPriority;
//执行SELETE语句
m_pRecordset = GetRecordSet(vSQL);
//返回各列的值
if (m_pRecordset->adoEOF)
CServerPC();
else
{
IPStr = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("IPStr");
Desc = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Description");
Type = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Type"));
Priority = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Priority"));
PSDir = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("PSDir");
PSDir1 = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("PSDir1");
PSDir2 = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("PSDir2");
PSDir3 = (LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("PSDir3");
Port = atoi((LPCTSTR)(_bstr_t)m_pRecordset->GetCollect("Port"));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -