⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 repuploaddlg.cpp

📁 一个电视台专用的信息管理软件源代码
💻 CPP
字号:
// RepUploadDlg.cpp : implementation file
//

#include "stdafx.h"
#include "tvnews.h"
#include "RepUploadDlg.h"
#include "Role.h"
#include "Channel.h"
#include "Column.h"
#include "UserChannel.h"
#include "NewsAudit.h"
#include "FtpDlg.h"
#include "ServerPC.h"
#include "News.h"
#include "SendFile.h"
#include "reporterDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CRepUploadDlg dialog
extern CTVNewsApp theApp;

CRepUploadDlg::CRepUploadDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CRepUploadDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CRepUploadDlg)
	m_editUPFileSel = _T("");
	m_strTitle = _T("");
	m_strDesc = _T("");
	//}}AFX_DATA_INIT
}


void CRepUploadDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CRepUploadDlg)
	DDX_Control(pDX, IDC_PROGRESS1, m_Progress);
	DDX_Control(pDX, IDC_EDITUP_TITLE, m_edtTitle);
	DDX_Control(pDX, IDC_UPLOAD_CBACTOR, m_cmbZRAudit);
	DDX_Control(pDX, IDC_UPLOAD_CMBFORMAT, m_cmbUPFormat);
	DDX_Control(pDX, IDC_UPLOAD_CMBCOLUMN, m_cmbUPColumn);
	DDX_Text(pDX, IDC_UPLOAD_EDITFILESEL, m_editUPFileSel);
	DDX_Text(pDX, IDC_EDITUP_TITLE, m_strTitle);
	DDX_Text(pDX, IDC_EDITUP_DESC, m_strDesc);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CRepUploadDlg, CDialog)
	//{{AFX_MSG_MAP(CRepUploadDlg)
	ON_BN_CLICKED(IDC_UPLOAD_BTNUP, OnUploadBtnup)
	ON_BN_CLICKED(IDC_UPLOAD_BTNSELFILE, OnUploadBtnselfile)
	ON_CBN_SELCHANGE(IDC_UPLOAD_CMBCOLUMN, OnSelchangeUploadCmbcolumn)
	ON_BN_CLICKED(IDC_UPLOAD_BTN_AGENTUP, OnUploadBtnAgentup)
	ON_BN_CLICKED(IDC_BTNCANCEL_RINFO, OnBtncancelRinfo)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRepUploadDlg message handlers

void CRepUploadDlg::OnUploadBtnup() 
{
	// TODO: Add your control notification handler code here
	ServerPC.GetUploadInf(0,0);
	Upload();
     
}

BOOL CRepUploadDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	UpdateData(true);
	//初始化评审
	CRole role;
	role.GetAllRole(allRoles,1);
	
	int i;

	m_UserID=theApp.m_user.GetUID();
	CUserChannel userChannel;

	m_ChannelID = userChannel.GetChannelIDByUserID(m_UserID);

	
	CColumn column;
	column.GetAllColumn(allColumns,m_ChannelID);

	for(i=0;i<allColumns.GetSize();i++)
	{
		m_cmbUPColumn.AddString(allColumns.GetAt(i));	
	}
	
	m_cmbUPColumn.SelectString(-1, ColumnName);

	m_cmbUPFormat.SetCurSel(0);

	GetzrAuditList();

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CRepUploadDlg::OnUploadBtnselfile() ////////////////////
{
//	CReporterDlg* tmpDlg=(CReporterDlg*)GetParent();
 //   tmpDlg->m_bBrowse=TRUE;

	CFileDialog dlg(true);
	
	char cFilter[] = "All files (*.*)\0*.*\0\0";
	dlg.m_ofn.lpstrFilter=cFilter;
	int iResult;
	iResult=dlg.DoModal();
	if(IDOK == iResult)
	{
		
		m_FilePath = dlg.GetPathName();
		m_FileName = dlg.GetFileName();
		UpdateData(TRUE);
		m_editUPFileSel = m_FileName;

		
		UpdateData(false);		
	
	}

//	tmpDlg->m_bBrowse=TRUE; 
//	tmpDlg=NULL;

}

void CRepUploadDlg::OnSelchangeUploadCmbcolumn() 
{
	// TODO: Add your control notification handler code here
	GetzrAuditList();
	
}

void CRepUploadDlg::GetzrAuditList()
{
	CColumn Column;
	
	int number = m_cmbUPColumn.GetCurSel(); 
	CString strName;
	m_cmbUPColumn.GetLBText(number,strName);
	int ColumnID = Column.GetIDByName(strName);
	
	CString strSQL,strColumnID,strChannelID;

	strColumnID.Format("%d", ColumnID);
	strChannelID.Format("%d", m_ChannelID);
	strSQL ="AND Users.RoleID = 2 AND ChannelID = " + strChannelID + " AND ColumnID = " + strColumnID  ;

	CStringArray allzrAudit;
	CUsers Users;
	Users.GetNames(allzrAudit,strSQL);
	int i;
	m_cmbZRAudit.ResetContent();
	for(i=0;i<allzrAudit.GetSize();i++)
	{
		m_cmbZRAudit.AddString(_T(allzrAudit.GetAt(i)));	
	}
	m_cmbZRAudit.SetCurSel(0);
}



BOOL CRepUploadDlg::UploadFile(int &FileSize)
{  
	WSADATA wsaData;
	WSAStartup(MAKEWORD(1,0), &wsaData );
	

	char szErrorString[256];
	char szSvrFileName[512];
	CString msg;

	FILE_SVR_HEADER FileSvrHeader;
	memset(&FileSvrHeader,0,sizeof(FileSvrHeader));

	strcpy(FileSvrHeader.szDir1,m_ServerPath);
	strcpy(FileSvrHeader.szFileName, m_FileName);
	
	
	if(!SendNewsFile(m_ServerIP,m_Port,m_FilePath,&FileSvrHeader,szSvrFileName,szErrorString,FileSize))
	{
		MessageBox(szErrorString);
		m_Progress.SetPos(0);
		return false;
	}
	else
	{
		msg.Format("上传到评审服务器成功,文件名为:%s\n",m_FileName);
		MessageBox(msg);
	}
    
	m_Progress.SetPos(0);
	
	WSACleanup();

	return true;
	
}

void CRepUploadDlg::OnUploadBtnAgentup() 
{
	// TODO: Add your control notification handler code here
	ServerPC.GetUploadInf(1,1);
	Upload();

	
}


void CRepUploadDlg::Upload()
{
	UpdateData();

	m_ServerIP = ServerPC.GetIPStr();
	m_Port = ServerPC.GetPort();

	m_ServerPath = ServerPC.GetPSDir();

	CChannel Channel;
	Channel.GetData(theApp.m_user.GetChannelID());
	m_ServerPath += Channel.GetName();
//	m_ServerPath += theApp.m_user.GetName() +"\\";


	if(m_FilePath.GetLength() == 0)
	{
		MessageBox("请先选择要上传的文件!");
		return;
	}
	m_strTitle.TrimLeft();
	m_strTitle.TrimRight();
	if(m_strTitle.GetLength() == 0)
	{
		MessageBox("请输入标题!");
		return;
	}
	

	CNews News;
	if(News.QryTitleExist(m_strTitle))
	{
		MessageBox("标题重复!");
		return;
	}

	//获取频道的ID
	long userID=theApp.m_user.GetUID();

	//栏目选择,获取栏目的ID
	CString strColumn;
	int iColumnSel=m_cmbUPColumn.GetCurSel();
	m_cmbUPColumn.GetLBText(iColumnSel,strColumn);
	CColumn column;
	long columnUID=column.getUIDByColumnName(strColumn);

	int iSel;
	CUsers Users;
	//责任编辑
	CString strzrName;
	long zrUID;
	iSel=m_cmbZRAudit.GetCurSel();
	m_cmbZRAudit.GetLBText(iSel,strzrName);
	zrUID=Users.getIDByName(strzrName);

	long iFlg;
	CString cMessage;

	int FileSize;
	CString FilePath;
	CNews news;
	if(1==news.QryFileExist(m_ServerPath,m_FileName))
	{
		/*
		if(MessageBox("你所选择的文件已经存在,你确定要覆盖吗?","询问信息", MB_YESNO ) == IDYES)

		{
			if(UploadFile(FileSize))
			{
				
				news.UploadNews(m_strTitle,userID,columnUID,m_strDesc,m_editUPFileSel,FileSize,zrUID,0,m_ServerPath,iFlg,cMessage);
				if(iFlg == 0)
				    MessageBox(cMessage);
			}

		}
		*/

		MessageBox("你所选择的文件已经存在,请修改文件名,例如在后面加不同的数字加以区别!!!");
		return;
	}
	else
	{
		if(UploadFile(FileSize))
		{
			
			news.UploadNews(m_strTitle,userID,columnUID,m_strDesc,m_editUPFileSel,FileSize,zrUID,0,m_ServerPath,iFlg,cMessage);
			if(iFlg == 0)
			    MessageBox(cMessage);
		}
	}


}

BOOL CRepUploadDlg::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(pMsg->message   ==   WM_KEYDOWN)   
     {   
           if(pMsg->wParam   ==   VK_RETURN)   
           {   
			    CWnd   *pWnd   =   GetFocus();   
                if(pWnd->GetDlgCtrlID()==IDC_UPLOAD_BTN_AGENTUP)
				{
					OnUploadBtnAgentup();
				}
				else if(pWnd->GetDlgCtrlID()==IDC_UPLOAD_BTNUP)
				{
					OnUploadBtnup();
				}
				else if(pWnd->GetDlgCtrlID()==IDC_BTNCANCEL_RINFO)
				{
					OnBtncancelRinfo();
				}
				else if(pWnd->GetDlgCtrlID()==IDC_UPLOAD_BTNSELFILE)
				{
					OnUploadBtnselfile();
				}
				else
				{
					NextDlgCtrl();
					return true;
				}
            }   
       }

	
	return CDialog::PreTranslateMessage(pMsg);
}

void CRepUploadDlg::OnBtncancelRinfo() 
{
	// TODO: Add your control notification handler code here
	CDialog::OnCancel();
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -