Example #1
0
void CDownloadGroupDlg::OnCbnCloseupSchemas()
{
    // Get filters
    CList< CString > oList;
    for ( int nItem = 0 ; nItem < m_wndFilterList.GetCount() ; nItem++ )
    {
        CString strFilter;
        m_wndFilterList.GetLBText( nItem, strFilter );
        if ( oList.Find( strFilter ) == NULL )
            oList.AddTail( strFilter );
    }

    // Remove old schema filters (preserve custom ones)
    if ( CSchemaPtr pOldSchema = SchemaCache.Get( m_sOldSchemaURI ) )
    {
        for ( POSITION pos = pOldSchema->GetFilterIterator(); pos ; )
        {
            CString strFilter;
            BOOL bResult;
            pOldSchema->GetNextFilter( pos, strFilter, bResult );
            if ( bResult )
            {
                strFilter.Insert( 0, _T('.') );
                while ( POSITION pos = oList.Find( strFilter ) )
                    oList.RemoveAt( pos );
            }
        }
    }

    // Add new schema filters
    if ( CSchemaPtr pNewSchema = SchemaCache.Get( m_wndSchemas.GetSelectedURI() ) )
    {
        for ( POSITION pos = pNewSchema->GetFilterIterator(); pos ; )
        {
            CString strFilter;
            BOOL bResult;
            pNewSchema->GetNextFilter( pos, strFilter, bResult );
            if ( bResult )
            {
                strFilter.Insert( 0, _T('.') );
                oList.AddTail( strFilter );
            }
        }
    }

    // Refill interface filters list
    m_wndFilterList.ResetContent();
    for ( POSITION pos = oList.GetHeadPosition() ; pos ; )
        m_wndFilterList.AddString( oList.GetNext( pos ) );

    m_sOldSchemaURI = m_wndSchemas.GetSelectedURI();
}
Example #2
0
bool FileMisc::LoadFile(const TCHAR* szPathname, CString& sText)
{
	CStdioFile file;

	if (file.Open(szPathname, CFile::modeRead | CFile::shareDenyWrite))
	{
		if (file.GetLength())
		{
			// init size
			CString sTemp(_T('\0'), (int)file.GetLength());
			sText = sTemp;

			CString sLine;
			int nPos = 0;

			while (file.ReadString(sLine))
			{
				sText.Insert(nPos, sLine);
				nPos += sLine.GetLength();
			}
		}

		return true;
	}

	return false;
}
Example #3
0
static int InsertTabs(CString &str, int numTabs, const TCHAR* indent, bool& bracketed)
{
	CString tabs = indent ? indent : _T("");
	for(int i = 0; i < numTabs; i++)
		tabs += _T("\t");

	str.TrimRight();
	str = tabs + str;
	bool sol = true; int line = 0;
	bracketed = false;
	for (int i = 0; i < str.GetLength(); i++)
	{
		if (str[i] == _T('\n') || str[i] == _T('\r'))
		{
			while (i < str.GetLength()-1 && str[++i] == _T('\n'));
			if (i < str.GetLength())
			{
				str.Insert(i, tabs);
				i += tabs.GetLength();
			}
			sol = true;
			continue;
		}
		if (str[i] == _T('(') && sol)
			bracketed = true;
		if (!_istspace(str[i]) && sol)
			line++, sol = false;
	}
	return line;
}
Example #4
0
bool CBrowseRefsDlg::PickRefForCombo(CComboBoxEx* pComboBox, int pickRef_Kind)
{
	CString origRef;
	pComboBox->GetLBText(pComboBox->GetCurSel(), origRef);
	CString resultRef = PickRef(false,origRef,pickRef_Kind);
	if(resultRef.IsEmpty())
		return false;
	if(wcsncmp(resultRef,L"refs/",5)==0)
		resultRef = resultRef.Mid(5);
//	if(wcsncmp(resultRef,L"heads/",6)==0)
//		resultRef = resultRef.Mid(6);

	//Find closest match of choice in combobox
	int ixFound = -1;
	int matchLength = 0;
	CString comboRefName;
	for(int i = 0; i < pComboBox->GetCount(); ++i)
	{
		pComboBox->GetLBText(i, comboRefName);
		if(comboRefName.Find(L'/') < 0 && !comboRefName.IsEmpty())
			comboRefName.Insert(0,L"heads/"); // If combo contains single level ref name, it is usualy from 'heads/'
		if(matchLength < comboRefName.GetLength() && resultRef.Right(comboRefName.GetLength()) == comboRefName)
		{
			matchLength = comboRefName.GetLength();
			ixFound = i;
		}
	}
	if(ixFound >= 0)
		pComboBox->SetCurSel(ixFound);
	else
		ASSERT(FALSE);//No match found. So either pickRef_Kind is wrong or the combobox does not contain the ref specified in the picker (which it should unless the repo has changed before creating the CBrowseRef dialog)

	return true;
}
Example #5
0
BOOL CTEditCtrlWnd::TimeFormat(CString str)
{
	if(!m_bTimeType)
		return FALSE;		
	
	CString strTime;
	if(m_pEditCtrl != NULL)
		GetWindowText(strTime);
	
	if(strTime.GetLength() == 6)
	{
		strTime.Insert(2, _T(':'));
		strTime.Insert(5, _T(':'));

		m_pEditCtrl->SetWindowText((LPCTSTR)strTime);
		m_pEditCtrl->SetTimeType(TRUE);
	}
	else
	{
		CString strErrorMsg;
		strErrorMsg.Format("시분초 각 두자리씩 숫자로만 표시해주십시요.");
		MessageBox(strErrorMsg, MB_OK);
		SetFocus();
		return FALSE;						
	}

	return TRUE;
}
Example #6
0
void CWndDialog::Say( LPCTSTR lpszString, DWORD dwQuest )
{
 	QuestProp* pQuestProp = prj.m_aPropQuest.GetAt( dwQuest );
 	CString string = "  ";
	if( dwQuest )
	{
		string = "#b#cff5050f0";
		string += pQuestProp->m_szTitle;
		string += "#nb#nc\n";
		string += "  ";
		string += lpszString;
	}
	else
		string += lpszString;

	int nLength = string.GetLength();//_tcslen( szString );
	int i,j; for( i = 0, j = 0; i < nLength; i++ )
	{
		if( string[ i ] == '\\' && string[ i + 1 ] == 'n' )
		{
			// 중간의 두개의 코드를 \n와 ' '로 대체.
			string.SetAt( i, '\n' );
			string.SetAt( i + 1, ' ' );
			// 그리고 스페이스 한개 삽입.
			string.Insert( i + 1, " " );
		}
	}
	m_dwQuest = dwQuest;
	ParsingString( string );
	EndSay();
}
Example #7
0
/******************************************************************************
Function Name  :  strCopyBSTRToCString
Input(s)       :  CComVariant& varSrc
Output         :  CString
Functionality  :  Copies BSTR to CString
Member of      :  -
Friend of      :  -
Author(s)      :  Arunkumar K
Date Created   :  20/07/2011
Modifications  :
Codetag        :
******************************************************************************/
CString strCopyBSTRToCString(CComVariant& varSrc)
{
    CString strDest ;
    char tChar = NULL;
    _bstr_t bstrNodeValue(varSrc.bstrVal);
    ULONG ulLen = bstrNodeValue.length();

    for (unsigned int i = 0; i< ulLen*2; i+=2)
    {
        tChar = (char)*(varSrc.pcVal+i);
        strDest.Insert(i/2, tChar);
    }

    tChar = NULL;
    strDest.Insert(ulLen, tChar);
    return strDest;
}
Example #8
0
CString fsBytesToStr (UINT64 uBytes, BOOL bAdd_bytes_String)
{
	CString strBytes; 
	if (bAdd_bytes_String)
	{
		strBytes = " ";
		strBytes += LS (L_B);
	}
	CString str;
	UINT u;

	do
	{
		 if (uBytes > 1000)
			 u = UINT (uBytes % 1000);
		 else
			 u = 0;

		if (u)
		{
			str.Format (",%d", u);
			if (str.GetLength () == 2)
				str.Insert (1, "00");
			else if (str.GetLength () == 3)
				str.Insert (1, "0");
		}
		else
		{
			if (uBytes < 1000)
				str.Format ("%d", (UINT)uBytes);
			else
			{
				str = ",000";
			}
		}

		uBytes /= 1000;

		strBytes.Insert (0, str);
	}
	while (uBytes);

	return strBytes;
}
//转换字符串
void MakeString(CString &strNum,SCORE lNumber)
{
	CString strTempNum;
	strTempNum.Format(_T("%I64d"), (lNumber>0?lNumber:-lNumber));

	int nLength = strTempNum.GetLength();
	for (int i = 0; i < int((nLength-1)/3); i++)
		strTempNum.Insert(nLength - 3*(i+1), _T(","));
	strNum.Format(_T("%s%s"), (lNumber<0?_T("-"):_T("")), strTempNum);
}
	int XMLWriter::WriteValue(CString name, CString value)
	{
		if (!has_params.empty()) {
			bool param = has_params.back();
			if (!param) {
				has_params.pop_back();
				has_params.push_back(true);
			}
		}

		#pragma region Escape Special Characters
		// NOTE: http://www.w3.org/TR/html4/sgml/entities.html#h-24.4.1
		for (int i=value.GetLength()-1; i>=0; i--) {
			CString replacement;
			switch(value[i]) {
				case _T('&'):
					replacement = _T("&amp;");
					break;
				case _T('<'):
					replacement = _T("&lt;");
					break;
				case _T('>'):
					replacement = _T("&gt;");
					break;
			}
			if(replacement.IsEmpty())
				continue;
			value.Delete(i);
			value.Insert(i, replacement);
		}
		#pragma endregion

		// escape quotes
		for (int i=value.GetLength()-1; i>=0; i--) {
			if (value[i] == L'\"') {
				value.Insert(i, _T("\\"));
			}
		}

		ret += _T(" ")+name+_T("=\"") + value + _T("\"");
		return 0;
	}
Example #11
0
void Filename_AccountForLOD(CString &string, int iLODLevel)
{
	if (iLODLevel)
	{
		int loc = string.ReverseFind('.');
		if (loc>0)
		{
			string.Insert( loc, va("_%d",iLODLevel));
		}		
	}	
}
Example #12
0
bool MaskCharacters(CString& csInput)
{
   bool bSomethingChanged = false;
   for (int i=0; i<csInput.GetLength(); ++i)
   {
      if (csInput[i] == _T(';') || csInput[i] == _T('\\'))
      {
         csInput.Insert(i, _T('\\'));
         ++i;
         bSomethingChanged = true;
      }
   }

   return bSomethingChanged;
}
Example #13
0
BOOL CFileTransferModeDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CString	str;
	str.Format(_T("此文件夹已包含一个名为“%s”的文件"), m_strFileName);

	for (int i = 0; i < str.GetLength(); i += 120)
	{
		str.Insert(i, "\n");
		i += 1;
	}

	SetDlgItemText(IDC_TIPS, str);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
void CHotGamePanel::OnListPopOpenDir()
{
	if (!AfxGetDbMgr()->GetBoolOpt(OPT_M_BROWSEDIR))
	{
		CString strNotify;
		strNotify.Format(TEXT("对不起,当前设置不允许浏览游戏目录。"));
		AfxMessageBoxEx(strNotify);
		return;
	}	

	size_t nSel = m_lstGame.GetNextItem(-1, LVIS_SELECTED);
	if (nSel == -1 || nSel >= m_GameInfo.size())
		return ;
	tagGameInfo* pGame = m_GameInfo[nSel];

	CString szWorkDir;
	if (pGame->RunType == 2)	//虚拟盘运行的,需要转换路径
	{
		szWorkDir = pGame->SvrPath;
		szWorkDir.Trim();
		tagVDiskInfo* pVDisk = AfxGetDbMgr()->FindVDiskInfo(pGame->VID);
		if (szWorkDir.GetLength() > 3 && pVDisk != NULL)
		{
			szWorkDir.SetAt(0, pVDisk->CliDrv);
		}
	}
	else
	{
		szWorkDir = pGame->CliPath;
	}

	if (szWorkDir.GetLength() && szWorkDir.Right(1) != TEXT("\\"))
		szWorkDir += TEXT("\\");

	if (PathFileExists(szWorkDir))
	{
		ShellExecute(m_hWnd, TEXT("open"), szWorkDir, TEXT(""), TEXT(""), SW_SHOWNORMAL);
	}
	else
	{
		szWorkDir.Insert(0, TEXT("目录不存在:"));
		AfxMessageBoxEx(szWorkDir);
	}
}
Example #15
0
BOOL CErrorDisplay::OnInitDialog()
{
	CDialog::OnInitDialog();

//	m_Edit.SetWindowText(m_MsgText);
	CFont *f = m_Edit.GetDC()->GetCurrentFont();
	
	CRect	r1(0,10,0,10);
	CRect	r2;
	CSize	sz;
	sz.cy	=	m_Edit.GetDC()->DrawText("X",r1,DT_LEFT|DT_SINGLELINE|DT_NOCLIP|DT_CALCRECT);
	sz.cx	=	r1.Width();

	m_Edit.GetClientRect(r2);
	int iStrLen = r2.Width() / sz.cx;
//	char s[2048] = "";
//	strncpy(s, m_MsgText, 2048);
	CString s = m_MsgText;
	char c = '\n';
	int iLastSpace = 0;
	int iCurr = 0;
	for( int i=0; i < (signed)strlen(s); i++ )
	{
		if( s[i] == ' ' ) iLastSpace = i;
		if( iCurr > iStrLen && iLastSpace ) 
		{
//			s[iLastSpace] = '\r';
			s.Insert(iLastSpace, "\r\n");
//			s.
			iCurr = 0;
		} else
			iCurr++;
	}
	m_Edit.SetWindowText(s);

//	m_Edit.
	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Example #16
0
void CMainDlg::DoInMainThread(CString strText)
{
    static int _s_nLogCount = 0;
    
    strText.AppendFormat(L"\r\n输出日志运行线程ID:%d\r\n\r\n", ::GetCurrentThreadId());
    CString strLog;
    GetDlgItemText(IDC_STATIC_TEXT, strLog);
    
    if (_s_nLogCount++ > 100)
    {
        _s_nLogCount = 0;
        strLog.Empty();
    }

    strLog.Insert(0, strText);
    SetDlgItemText(IDC_STATIC_TEXT, strLog);

    CString strInfo;
    strInfo.Format(L"线程池运行线程数:%d,任务数:%d,回收站线程数:%d", SparkThreadPool::Instance().GetThreadCount(),
        SparkThreadPool::Instance().GetTaskCount(), SparkThreadPool::Instance().GetTrashThreadCount());
    SetDlgItemText(IDC_STATIC_INFO, strInfo);
}
Example #17
0
CString CServletMethod::MakeParamsString()
{
	CString strParams;
	
	m_nLocalSerialNo = MakeLocalSerialNo();

	CIBAHelpper::AppendString(strParams, m_nLocalSerialNo, 6);

	strParams.Append(MergeParams());

	CString strMac(MakeMacString(strParams));
	
	if (strMac.IsEmpty())
	{
		CIBAHelpper::FillString(strMac, 16, '0');
	}

	strParams.Insert(0, strMac);
	strParams = EncodeParams(strParams);

	// 2015-3-27 tmelody
	// 上报不打日志
	if (0 == GetMethodName().CompareNoCase(_T("NonSysService")))
	{
#if _DEBUG
		WriteLog(_T("Params:") + strParams);
#endif
	}
	else
	{
		if(CIBAGlobal::NetworkStatus != CIBAGlobal::emNetworkBroken)
		{
			WriteLog(_T("Params:") + strParams);
		}		
	}

	return strParams;
}
Example #18
0
CString CTEditCtrlWnd::GetCurrencyText(CString strSource)
{
	int nCommaPos;
	int nEndPos  = strSource.GetLength();
	int nNegative = 0;
	
	if(strSource.Find('-') != -1)
		nNegative = 1;
	
	if (nEndPos >= 4)
	{
		nCommaPos = nEndPos;
		
		do
		{
			nCommaPos = nCommaPos - 3;
			strSource.Insert(nCommaPos,',');
		}
		while(nCommaPos >= (4 + nNegative));
	}
	
	return strSource;
}
Example #19
0
BOOL GetFileNameFromPath(const CString& strPath, CString& strFileName, BOOL isIncludeExternName, const CString& strExternName)
{
	CString strRealPath = strPath;
	strRealPath.Trim();

	int pos1	= strRealPath.ReverseFind('\\');
	int pos2	= strRealPath.ReverseFind('/');
	int begin	= max(pos1, pos2) + 1;

	strFileName	= strRealPath.Right(strRealPath.GetLength() - begin);
	int len		= strFileName.GetLength();
	if(len > 0 && !isIncludeExternName)
	{
		CString strRealExternName = strExternName;
		strRealExternName.Trim();
		if(strRealExternName.GetLength() > 0)
		{
			if(strRealExternName.GetAt(0) != '.')
				strRealExternName.Insert(0, '.');

			int exlen = strRealExternName.GetLength();
			if(len >= exlen)
			{
				if(strFileName.Right(exlen).CompareNoCase(strRealExternName) == 0)
					strFileName = strFileName.Left(len - exlen);
			}
		}
		else
		{
			int dot = strFileName.ReverseFind('.');
			if(dot != -1)
				strFileName = strFileName.Left(dot);
		}
	}

	return !strFileName.IsEmpty();
}
Example #20
0
//下载像册信息
// http://u.8264.com/home-space-uid-16752722-do-album-id-1766.html
// http://u.8264.com/home-space-uid-16752722-do-album-id-1766-page-4.html#comment
bool CDolo8264COM::SearchLayer3(CString &str_url)
{
	CString cs_webContent;
	CString cs_tmp;
	int photo_num=0;		//像册数量
	int i_tmp;
	vector<string> astr;  //下载链接集合
	int m_page= 1;			//设置页面数
	CString cs_album_name;	//用户目录
	CString cs_sub_album;	//像册目录

	if(str_url.Find(_T("#comment")) < 0)
	{
		str_url.Delete(str_url.GetLength()-5,5);
		str_url+=_T("-page-1.html#comment");
	}
	else
		str_url.SetAt(str_url.GetLength()-14,_T('1'));

	//获得页面
	bool en_P=false;
	bool en_G=false;
	do 
	{
		cs_webContent.Empty();
		DownloadUrlPage(str_url,cs_webContent);	

		i_tmp = cs_webContent.Find(_T("张图片"),0);
		if(i_tmp>-1)
		{
			cs_tmp = cs_webContent.Left(i_tmp);
			cs_tmp = cs_tmp.Right(4);
			cs_tmp.TrimLeft(_T(" ")); 
			cs_tmp.TrimRight( _T(" "));
			if((atoi(cs_tmp)==0)||(cs_tmp.IsEmpty()))
			{
				return false;
			}
			else
				photo_num = atoi(cs_tmp);
		}
		//获得像册的题目
		if(en_P == false)
		{
			int i=cs_webContent.Find(_T("keywords\" content=\""),0);
			if(i>-1)
			{
				cs_sub_album= cs_webContent.Right(cs_webContent.GetLength() -i -19);
				cs_sub_album = cs_sub_album.Left(cs_sub_album.Find(_T("\"")));
				en_P = true;
			}
		}
		//获得用户题目cs_album_name
		if(en_G == false)
		{
			int i=cs_webContent.Find(_T("<h2 class=\"xs2\">"),0);
			if(i>-1)
			{
				i=cs_webContent.Find(_T("html"),i);
				cs_album_name= cs_webContent.Right(cs_webContent.GetLength() -i -6);
				cs_album_name = cs_album_name.Left(cs_album_name.Find(_T("<"),0));
				en_G = true;
			}
		}
		checkDirname(cs_album_name);
		checkDirname(cs_sub_album);
		CreateDirectory(_T("8264com\\")+cs_album_name,NULL);
		CreateDirectory(_T("8264com\\")+cs_album_name+_T("\\")+cs_sub_album,NULL);

		regex reg("html\"><img src=\"[a-zA-z]+://[^\\s]*thumb.jpg");  	//图片模式
		smatch m1; 

		string s = cs_webContent.GetBuffer();	
		string::const_iterator it = s.begin(); 
		string::const_iterator end=s.end();

		while(regex_search(it,end,m1,reg))
		{
/*			int size = m1[0].length();*/
			string msg(m1[0].first,m1[0].second);	
			msg.erase(0,16);
			msg.erase(msg.size()-10,msg.size());
			//astr.push_back(msg);
			
			s_dolo.cs_url=msg.c_str();
			s_dolo.cs_LocalFullPath=_T("8264com\\")+cs_album_name+_T("\\")+cs_sub_album;
			s_dolo.cs_ReferHead=_T("");
			v_doloST.push_back(s_dolo);

			it = m1[0].second; 
			msg.empty();
			myidle();
		}
		s.empty();

		str_url.Delete(str_url.Find(_T("page")),str_url.GetLength()-str_url.Find(_T("page")) );
		str_url.Insert(str_url.GetLength(), _T("page-"));
		CString tc;
		m_page++;
		tc.Format(_T("%d"),m_page);
		str_url.Insert(str_url.GetLength(), tc);
		str_url.Insert(str_url.GetLength(), _T(".html#comment"));	
		tc.Empty();
	} while (photo_num/20 +2 >m_page);
	


	// 	CString cs_album_name;	//主目录名字
	// 	int photo_num;		//像册数量
	// 	CString cs_sub_album;  //子相册名字
//	checkDirname(cs_album_name);


// 	st_lp.urlGroup=astr;
// 	st_lp.strFileURLInServer.IsEmpty();
// 	st_lp.strFileLocalFullPath=_T("8264com\\")+cs_album_name+_T("\\")+cs_sub_album;
// 	st_lp.strReferHead=_T("");					//_T("Referer: http://mm.taobao.com");
// 	st_lp.hWnd=(HWND)this;
// 	m_pMyThread=AfxBeginThread(Download1,(LPVOID)&st_lp);//&st_lp[n]);
// 	astr.empty();
	return true;
}
Example #21
0
CString CmdUrlParser::GetCommandLine()
{
    CString sCmdLine;
    CString temp;
    int pos = 0;
    for(;;)
    {
        temp = m_cmdUrl.Tokenize(_T("?"), pos);
        if (temp.IsEmpty())
        {
            break;
        }
        else if (temp.Left(8).CompareNoCase(_T("tsvncmd:")) == 0)
            temp = temp.Mid(8);

        if (temp.Left(8).CompareNoCase(_T("command:")) == 0)
        {
            CString cmd = temp.Mid(8);
            bool isCmdAllowed = false;

            if (cmd.CompareNoCase(_T("update")) == 0)
                isCmdAllowed = true;
            else if (cmd.CompareNoCase(_T("commit")) == 0)
                isCmdAllowed = true;
            else if (cmd.CompareNoCase(_T("diff")) == 0)
                isCmdAllowed = true;
            else if (cmd.CompareNoCase(_T("repobrowser")) == 0)
                isCmdAllowed = true;
            else if (cmd.CompareNoCase(_T("checkout")) == 0)
                isCmdAllowed = true;
            else if (cmd.CompareNoCase(_T("export")) == 0)
                isCmdAllowed = true;
            else if (cmd.CompareNoCase(_T("blame")) == 0)
                isCmdAllowed = true;
            else if (cmd.CompareNoCase(_T("repostatus")) == 0)
                isCmdAllowed = true;
            else if (cmd.CompareNoCase(_T("revisiongraph")) == 0)
                isCmdAllowed = true;
            else if (cmd.CompareNoCase(_T("showcompare")) == 0)
                isCmdAllowed = true;
            else if (cmd.CompareNoCase(_T("log")) == 0)
                isCmdAllowed = true;

            if (!isCmdAllowed)
                return CString();   // command is not on the allowed list, return empty command line
        }
        temp = CPathUtils::PathUnescape(temp);
        // if the param has spaces in it, enquote it
        if (temp.Find(_T(" ")) >= 0)
        {
            // only insert a quote after the first colon: subsequent colons might be
            // part of an url (e.g., http_:_//something)
            int keyIndex = temp.Find(_T(":")) + 1;
            temp.Insert(keyIndex, _T("\""));
            temp = temp + _T("\"");
        }
        sCmdLine += _T(" /");
        sCmdLine += temp;
    }

    return sCmdLine;
}
Example #22
0
void CClientDlg::SendHttp()
{
	USES_CONVERSION;

	if(!CheckStarted(TRUE))
		return;

	CString strMethod;
	CString strSchema;
	CString strAddress;
	CString strPort;
	CString strPath;

	m_Method.GetWindowText(strMethod);
	m_Schema.GetWindowText(strSchema);
	m_Address.GetWindowText(strAddress);
	m_Port.GetWindowText(strPort);

	if(m_Method.GetCurSel() != 8)
	{
		m_Path.GetWindowText(strPath);
		strPath.Trim();

		if(strPath.IsEmpty() || strPath.GetAt(0) != '/')
			strPath.Insert(0, '/');
	}

	THttpHeaderMap headers;

	int iCount = m_Headers.GetCount();

	for(int i = 0; i < iCount; i++)
	{
		CString strHeader;
		m_Headers.GetText(i, strHeader);

		int j = 0;
		CString strName  = strHeader.Tokenize(_T(": "), j);
		CString strValue = strHeader.Mid(j + 1);

		headers.emplace(THttpHeaderMap::value_type(T2A(strName), T2A(strValue)));
	}

	CStringA strBodyA;
	CStringA strPathA;

	if(m_Method.GetCurSel() <= 2)
	{
		CString strBody;
		m_Body.GetWindowText(strBody);

		strBodyA = T2A(strBody);
	}
	else if(m_Method.GetCurSel() == 8)
	{
		THttpHeaderMapCI it = headers.find("Host");

		if(it != headers.end() && !it->second.IsEmpty())
			strPathA = it->second;
		else
		{
			CString strHost;
			strHost.Format(_T("%s:%s"), strAddress, strPort);
			strPathA = strHost;
		}
	}

	if(strPathA.IsEmpty())
		strPathA = T2A(strPath);

	DWORD dwIndex	= 0;
	DWORD dwSize	= (DWORD)headers.size();
	unique_ptr<THeader[]> szHeaders(new THeader[dwSize]);

	for(THttpHeaderMapCI it = headers.begin(), end = headers.end(); it != end; ++it, ++dwIndex)
	{
		szHeaders[dwIndex].name  = it->first;
		szHeaders[dwIndex].value = it->second;
	}

	CONNID dwConnID = m_pClient->GetConnectionID();

	if(m_pClient->SendRequest(T2A(strMethod), strPathA, szHeaders.get(), dwSize, (const BYTE*)(LPCSTR)strBodyA, strBodyA.GetLength()))
	{
		CString strContent;
		strContent.Format(_T("[%s] %s://%s:%s%s"), strMethod, strSchema, strAddress, strPort, strPath);

		::LogSend(dwConnID, strContent);

		if(!m_bListener)
		{
			CStringA strSummary = GetHeaderSummary(m_pClient.get(), "    ", 0, TRUE);
			::PostOnHeadersComplete(dwConnID, strSummary);
		}

		LPCBYTE pData	= nullptr;
		int iLength		= 0;

		m_pClient->GetResponseBody(&pData, &iLength);

		if(iLength > 0)
		{
			if(!m_bListener) ::PostOnBody(dwConnID, pData, iLength);

			LPCSTR lpszEnc = m_pClient->GetContentEncoding();

			if(lpszEnc && ::StrStrIA(lpszEnc, "gzip"))
			{
				int rs		= 0;
				DWORD dwLen	= ::GZipGuessUncompressBound(pData, iLength);

				if(dwLen == 0 || dwLen > 5 * 1024 * 1024)
					rs = -10;
				else
				{
					CBufferPtr szBuff(dwLen);
					rs = ::GZipUncompress(pData, iLength, szBuff, dwLen);
				}

				if(rs == 0)
					::PostUncompressBody(dwConnID, dwLen);
				else
				{
					::PostUncompressBodyFail(dwConnID, rs);

					if(!m_bListener) ::PostOnMessageComplete(dwConnID);

					OnBnClickedStop();
					return;
				}
			}
		}

		if(!m_bListener) ::PostOnMessageComplete(dwConnID);

		EnHttpUpgradeType enUpgrade = m_pClient->GetUpgradeType();

		if(enUpgrade == HUT_WEB_SOCKET)
		{
			if(!m_bListener) ::PostOnUpgrade(dwConnID, enUpgrade);

			m_bWebSocket = TRUE;
			OnCbnSelchangeMethod();
		}
	}
	else
	{
		::LogSendFail(dwConnID, ::GetLastError(), ::GetSocketErrorDesc(SE_DATA_SEND));
		SetAppState(ST_STOPPED);
	}

	m_pClient->CleanupRequestResult();
}
Example #23
0
bool Skins_Validate( ModelContainer_t *pContainer, int iSkinNumber )
{
	bool bReturn = true;	
	bool bPREV_bReportImageLoadErrors = g_bReportImageLoadErrors;
										g_bReportImageLoadErrors = false;

	bool bCheckMissingMaterials = true;//GetYesNo("Check for materials referenced by model but missing in skinfile(s)?\n\n( Note: This can give false alarms for skins which don't use (eg) \"scarf\" )");

	// first, build up a list of all model materials...
	//	
	StringSet_t MaterialsPresentInModel;
	for (int iSurface = 0; iSurface < pContainer->iNumSurfaces; iSurface++)
	{
		bool bOnOff = GLMModel_SurfaceIsON(pContainer->hModel, iSurface);

		if (bOnOff)
		{
			LPCSTR psMaterial = GLMModel_GetSurfaceShaderName( pContainer->hModel, iSurface);

			MaterialsPresentInModel.insert(MaterialsPresentInModel.end(),psMaterial);
		}
	}

	// build up a list of shaders used...
	//	
	StringSet_t UniqueSkinShaders;	
	SkinFileMaterialsMissing_t SkinFileMaterialsMissing;
	int iThisSkinIndex = 0;
	for (SkinSets_t::iterator itSkins = pContainer->SkinSets.begin(); itSkins != pContainer->SkinSets.end(); ++itSkins, iThisSkinIndex++)
	{
		if (iSkinNumber == iThisSkinIndex || iSkinNumber == -1)
		{
			SkinSet_Validate_BuildList(UniqueSkinShaders, itSkins, MaterialsPresentInModel, SkinFileMaterialsMissing);
		}
	}

	// now process the unique list we've just built...
	//
	CWaitCursor wait;
	string strFoundList;
	string strNotFoundList;
	int iUniqueIndex = 0;
	for (StringSet_t::iterator it = UniqueSkinShaders.begin(); it != UniqueSkinShaders.end(); ++it, iUniqueIndex++)
	{			
		string strShader(*it);

		StatusMessage(va("Processing shader %d/%d: \"%s\"\n",iUniqueIndex,UniqueSkinShaders.size(),strShader.c_str()));

		OutputDebugString(va("Unique: \"%s\"... ",strShader.c_str()));

		int iTextureHandle = Texture_Load(strShader.c_str(), true);	// bInhibitStatus

		GLuint uiGLBind = Texture_GetGLBind( iTextureHandle );

		if (uiGLBind == 0)
		{
			OutputDebugString("NOT FOUND\n");
			
			strNotFoundList += strShader;
			strNotFoundList += "\n";
		}
		else
		{
			OutputDebugString("found\n");

			strFoundList += strShader;
			strFoundList += "\n";
		}
	}

	StatusMessage(NULL);

	
	// see if we were missing any model materials in these skins...
	//
	CString strModelMaterialsMissing;
	if (SkinFileMaterialsMissing.size())
	{
		for (SkinFileMaterialsMissing_t::iterator itSkinFileMaterialsMissing = SkinFileMaterialsMissing.begin(); itSkinFileMaterialsMissing != SkinFileMaterialsMissing.end(); ++itSkinFileMaterialsMissing)
		{
			string strSkinFileName((*itSkinFileMaterialsMissing).first);

			if (iSkinNumber == -1)
			{
				strModelMaterialsMissing += va("\nSkin \"%s\":\n",strSkinFileName.c_str());
			}
																					 
			for (EthnicMaterials_t::iterator itSkinFile = (*itSkinFileMaterialsMissing).second.begin(); itSkinFile != (*itSkinFileMaterialsMissing).second.end(); ++itSkinFile)
			{
				string strEthnicFileName((*itSkinFile).first);

				strModelMaterialsMissing += va("Ethnic \"%s\":   ",strEthnicFileName.c_str());

				StringVector_t& MaterialStrings = (*itSkinFile).second;

				for (int iMaterial = 0; iMaterial != MaterialStrings.size(); ++iMaterial)
				{
					string strMaterial(MaterialStrings[iMaterial]);

					strModelMaterialsMissing += va("%s\"%s\"",(iMaterial==0)?"":", ",strMaterial.c_str());
				}
				strModelMaterialsMissing += "\n";
			}
		}
	}
	if (!strModelMaterialsMissing.IsEmpty())
	{
		if (iSkinNumber == -1)
		{
			strModelMaterialsMissing.Insert(0, "One or more skin files are missing some material definitions referenced by this model's currently-active surfaces.\nList follows...\n\n");
		}
		else
		{
			strModelMaterialsMissing.Insert(0, "This skin file is missing one or more material definitions referenced by this model's currently-active surfaces.\nList follows...\n\n");
		}
	}

	
	if (!strModelMaterialsMissing.IsEmpty())
	{
		if (bCheckMissingMaterials)
		{
			WarningBox(va("Summary Part 1: Missing materials\n\n%s",(LPCSTR)strModelMaterialsMissing));
		}
	}


	// Now output results...

	// If too many lines to fit on screen (which is now happening), send 'em to notepad instead...
	//
	// ( tacky way of counting lines...)
	CString strTackyCount(strNotFoundList.c_str());
			strTackyCount += strFoundList.c_str();

	int iLines = strTackyCount.Replace('\n','?');	// :-)

	#define MAX_BOX_LINES_HERE 50

	if (strNotFoundList.empty())
	{
		if (iLines > MAX_BOX_LINES_HERE)
		{
			if (GetYesNo(va("All shaders found...    :-)\n\nList has > %d entries, send to Notepad?",MAX_BOX_LINES_HERE)))
			{
				SendStringToNotepad(va("All shaders found...    :-)\n\nList follows:\n\n%s",strFoundList.c_str()),"found_shaders.txt");
			}
		}
		else
		{
			InfoBox(va("All shaders found...    :-)\n\nList follows:\n\n%s",strFoundList.c_str()));
		}
	}
	else
	{
		if (iLines > MAX_BOX_LINES_HERE)
		{
			if (GetYesNo(va("Some missing shader, some found, but list is > %d entries, send to Notepad?",MAX_BOX_LINES_HERE)))
			{
				SendStringToNotepad(va("Missing shaders:\n\n%s\n\nFound shaders:\n\n%s",strNotFoundList.c_str(),strFoundList.c_str()),"found_shaders.txt");
			}
		}
		else
		{
			WarningBox(va("Missing shaders:\n\n%s\n\nFound shaders:\n\n%s",strNotFoundList.c_str(),strFoundList.c_str()));
		}
		bReturn = false;
	}


	g_bReportImageLoadErrors = bPREV_bReportImageLoadErrors;
	return bReturn;
}
Example #24
0
void CIBAOutputBar::QueryConsume(COperationInfo &OperationInfo, BOOL bNeedReturnRecord,UINT nConsumeType)
{	
	//strHeader = L"时间|上网账号|姓名|消费类型|消费金额|收银员|备注|用户号";
	
	CWaitCursor wait;

	m_wndConsumeInfo.DeleteAllItems();
	m_wndTabs.SetActiveTab(3);

	if (OperationInfo.GetMemberId() == 0)
	{
		UINT nCardId = 0;

		UINT nMemberId = CServletHellper::GetMemberId(OperationInfo.GetNetId(), nCardId);

		CCurrentNetBarUser::GetInstance()->Balance.SetMemberId(nMemberId);
		CCurrentNetBarUser::GetInstance()->Balance.SetCardId(nCardId);
		CCurrentNetBarUser::GetInstance()->Balance.SetRound(0);//取整

		theApp.GetCurCashier()->DoBalance(CCurrentNetBarUser::GetInstance()->Balance);

		if (CCurrentNetBarUser::GetInstance()->Balance.GetStatusCode() == 0)
		{
			OperationInfo.SetMemberId(nMemberId);
			OperationInfo.SetUserName(CCurrentNetBarUser::GetInstance()->Balance.GetUserName());
		}
		else
		{
			return;
		}
	}

	CConsumeListMethod ConsumeListMethod;
	ConsumeListMethod.SetConsumeType(nConsumeType);//全部消费查询
	ConsumeListMethod.SetNeedBusinessName(2);

	if (OperationInfo.GetIsMember()) //临时用户不传开始时间
	{
		COleDateTime NowTime = COleDateTime::GetCurrentTime(), StartTime;

		StartTime = NowTime - COleDateTimeSpan(1, 0, 0, 0);

		if (OperationInfo.GetOperationType() > 0)
		{
			StartTime = NowTime - COleDateTimeSpan(1, 0, 0, 0);
		}
		else
		{
			if (StartTime < OperationInfo.GetOperationTime())
			{
				StartTime = OperationInfo.GetOperationTime();
			}
		}

		ConsumeListMethod.SetBeginTime(StartTime.Format(_T("%Y%m%d%H%M%S")));
	}

 	ConsumeListMethod.SetMemberId(OperationInfo.GetMemberId());
 
 	theApp.GetCurCashier()->DoConsumeList(ConsumeListMethod);
 
 	if (ConsumeListMethod.GetStatusCode() == 0)
	{
		//消费方式
		CIBAString strConsumeName; //= L"上网|充值|账户购物|增收宝消费|卡购物(旧)|退款|充值卡|增收宝充值";
		strConsumeName.LoadString(IDS_CONSUMETYPE);

		CStringArray saConsumeName;
		CIBAHelpper::SplitLine(strConsumeName, saConsumeName);

		for (INT i = 0; i < (INT)ConsumeListMethod.GetRecordCount(); i++)
		{
			//消费类型|金额|详细信息|收银员|上网账号|姓名

			m_wndConsumeInfo.InsertItem(i, saConsumeName.GetAt(ConsumeListMethod.GetConsumeType(i) - 1));

			CString strTmp;
			//时间
			strTmp = ConsumeListMethod.GetBeginTime(i);
			strTmp.Insert(2, _T("-"));
			strTmp.Insert(5, _T(" "));
			strTmp.Insert(8, _T(":"));
			//strTmp.Insert(11, _T(":"));
			strTmp = strTmp.Left(strTmp.GetLength() - 2);
			m_wndConsumeInfo.SetItemText(i, 2, strTmp);

			/**
			*消费类型0: 全部 1:上网 2:充值 3:卡购物 4:嘟嘟牛消费 5:卡购物(旧) 6:退款 7:充值卡 8:嘟嘟牛充值
			*/
			switch (ConsumeListMethod.GetConsumeType(i))
			{
			case 1://上网
				{
					if (ConsumeListMethod.GetBeginTime(i) != ConsumeListMethod.GetEndTime(i))
					{					
						CString strTmp2(ConsumeListMethod.GetEndTime(i));
						strTmp2.Insert(2, _T("-"));
						strTmp2.Insert(5, _T(" "));
						strTmp2.Insert(8, _T(":"));
						//strTmp2.Insert(11, _T(":"));

						strTmp2 = strTmp2.Left(strTmp2.GetLength() - 2);

						strTmp.Append(_T(" - "));
						strTmp.Append(strTmp2);

						m_wndConsumeInfo.SetItemText(i, 2, strTmp);
					}
				}
				//这里不要break
			case 3:
			case 4:
			case 5://3卡购物 4:嘟嘟牛消费 5:卡购物(旧)4种消费是支出方式
				strTmp.Format(_T("%.2f"), -ConsumeListMethod.GetAmount(i) / 100.0);
				m_wndConsumeInfo.SetItemText(i, 1, strTmp);
				break;

			case 2:
			case 7:
			case 8://充值,充值卡和嘟嘟牛充值,为收入方式
				strTmp.Format(_T("%.2f"), ConsumeListMethod.GetAmount(i) / 100.0);
				m_wndConsumeInfo.SetItemText(i, 1, strTmp);
				break;

			case 6://退款
				strTmp.Format(_T("%.2f"), ConsumeListMethod.GetAmount(i) / 100.0);
				m_wndConsumeInfo.SetItemText(i, 1, strTmp);
				bNeedReturnRecord = FALSE;
				break;
			}

			strTmp = m_wndConsumeInfo.GetItemText(i, 2);
			strTmp.Append(_T(" "));
			strTmp.Append(ConsumeListMethod.GetDescription(i));
			m_wndConsumeInfo.SetItemText(i, 2, strTmp);

			strTmp = ConsumeListMethod.GetBusinessName(i);
			m_wndConsumeInfo.SetItemText(i, 3, strTmp);

			//上网账号
			m_wndConsumeInfo.SetItemText(i, 4, OperationInfo.GetNetId());
			//姓名
			m_wndConsumeInfo.SetItemText(i, 5, OperationInfo.GetUserName());
		}

		if (bNeedReturnRecord) //如果中心没同步过来,则自己补上一条退款记录
		{
			m_wndConsumeInfo.InsertItem(0, saConsumeName.GetAt(5));

			CString strTmp;

			strTmp.Format(_T("%.2f"), OperationInfo.GetOperationAmount() / 100.0);
			
			m_wndConsumeInfo.SetItemText(0, 1, strTmp);

			m_wndConsumeInfo.SetItemText(0, 2, COleDateTime::GetCurrentTime().Format(_T("%m-%d %H:%M")));

			m_wndConsumeInfo.SetItemText(0, 3, theApp.GetCurCashier()->GetName());
			//上网账号
			m_wndConsumeInfo.SetItemText(0, 4, OperationInfo.GetNetId());
			//姓名
			m_wndConsumeInfo.SetItemText(0, 5, OperationInfo.GetUserName());
		}
	}
}
Example #25
0
/*
================
SpinFloatString
================
*/
void SpinFloatString( CString &str, bool up ) {
	int i, dotIndex = -1, digitIndex = -1;

	for ( i = 0; str[i]; i++ ) {
		if ( str[i] == '.' ) {
			if ( dotIndex == -1 ) {
				dotIndex = i;
			}
		}
		else if ( str[i] != '0' ) {
			if ( digitIndex == -1 ) {
				digitIndex = i;
			}
		}
	}
	if ( digitIndex == -1 ) {
		str.SetString( "1" );
		return;
	}

	if ( dotIndex != -1 ) {
		str.Delete( dotIndex, 1 );
		if ( digitIndex > dotIndex ) {
			digitIndex--;
		}
	}
	else {
		dotIndex = i;
	}

	if ( up ) {
		if ( str[digitIndex] == '9' ) {
			str.SetAt( digitIndex, '0' );
			if ( digitIndex == 0 ) {
				str.Insert( 0, '1' );
				dotIndex++;
			}
			else {
				str.SetAt( digitIndex-1, '1' );
			}
		}
		else {
			str.SetAt( digitIndex, str[digitIndex] + 1 );
		}
	}
	else {
		if ( str[digitIndex] == '1' ) {
			if ( str[digitIndex+1] == '\0' ) {
				str.SetAt( digitIndex, '0' );
				str.AppendChar( '9' );
			}
			else if ( str[digitIndex+1] == '0' ) {
				str.SetAt( digitIndex, '0' );
				str.SetAt( digitIndex+1, '9' );
			}
			else {
				str.SetAt( digitIndex+1, str[digitIndex+1] - 1 );
			}
		}
		else {
			str.SetAt( digitIndex, str[digitIndex] - 1 );
		}
	}
	if ( dotIndex < str.GetLength() ) {
		str.Insert( dotIndex, '.' );
		// remove trailing zeros
		for ( i = str.GetLength()-1; i >= 0; i-- ) {
			if ( str[i] != '0' && str[i] != '.' ) {
				break;
			}
		}
		if ( i < str.GetLength() - 1 ) {
			str.Delete( i+1, str.GetLength() - i );
		}
	}
	for ( i = 0; str[i]; i++ ) {
		if ( str[i] == '.' ) {
			if ( i > 1 ) {
				str.Delete( 0, i-1 );
			}
			break;
		}
		if ( str[i] != '0' ) {
			if ( i > 0 ) {
				str.Delete( 0, i );
			}
			break;
		}
	}
}
/*
================
CSyntaxRichEditCtrl::OnKeyDown
================
*/
void CSyntaxRichEditCtrl::OnKeyDown( UINT nKey, UINT nRepCnt, UINT nFlags ) {

	if ( m_TextDoc == NULL ) {
		return;
	}

	if ( autoCompleteStart >= 0 ) {
		int sel;

		switch( nKey ) {
			case VK_UP: {		// up arrow
				sel = Max( 0, autoCompleteListBox.GetCurSel() - 1 );
				autoCompleteListBox.SetCurSel( sel );
				return;
			}
			case VK_DOWN: {		// down arrow
				sel = Min( autoCompleteListBox.GetCount() - 1, autoCompleteListBox.GetCurSel() + 1 );
				autoCompleteListBox.SetCurSel( sel );
				return;
			}
			case VK_PRIOR: {	// page up key
				sel = Max( 0, autoCompleteListBox.GetCurSel() - 10 );
				autoCompleteListBox.SetCurSel( sel );
				return;
			}
			case VK_NEXT: {		// page down key
				sel = Min( autoCompleteListBox.GetCount() - 1, autoCompleteListBox.GetCurSel() + 10 );
				autoCompleteListBox.SetCurSel( sel );
				return;
			}
			case VK_HOME: {		// home key
				autoCompleteListBox.SetCurSel( 0 );
				return;
			}
			case VK_END: {
				autoCompleteListBox.SetCurSel( autoCompleteListBox.GetCount() - 1 );
				return;
			}
			case VK_RETURN:		// enter key
			case VK_TAB: {		// tab key
				AutoCompleteInsertText();
				AutoCompleteHide();
				return;
			}
			case VK_LEFT:		// left arrow
			case VK_RIGHT:		// right arrow
			case VK_INSERT:		// insert key
			case VK_DELETE: {	// delete key
				return;
			}
		}
	}

	BracedSectionHide();

	switch( nKey ) {
		case VK_TAB: {		// multi-line tabs
			long selStart, selEnd;

			GetSel( selStart, selEnd );

			// if multiple lines are selected add tabs to, or remove tabs from all of them
			if ( selEnd > selStart ) {
				CString text;

				text = GetSelText();

				if ( GetAsyncKeyState( VK_SHIFT ) & 0x8000 ) {
					if ( idStr::CharIsTab( text[0] ) ) {
						text.Delete( 0, 1 );
					}
					for ( int i = 0; i < text.GetLength() - 2; i++ ) {
						if ( idStr::CharIsNewLine( text[i] ) ) {
							do {
								i++;
							} while( idStr::CharIsNewLine( text[i] ) );
							if ( idStr::CharIsTab( text[i] ) ) {
								text.Delete( i, 1 );
							}
						}
					}
				} else {
					text.Insert( 0, '\t' );
					for ( int i = 0; i < text.GetLength() - 1; i++ ) {
						if ( idStr::CharIsNewLine( text[i] ) ) {
							do {
								i++;
							} while( idStr::CharIsNewLine( text[i] ) );
							text.Insert( i, '\t' );
						}
					}
				}

				ReplaceSel( text, TRUE );
				SetSel( selStart, selStart + text.GetLength() );
			} else {
				ReplaceSel( "\t", TRUE );
			}
			return;
		}
		case VK_RETURN: {	// auto-indentation
			long selStart, selEnd;
			int line, length, numTabs, i;
			char buffer[1024];
			idStr text;

			GetSel( selStart, selEnd );
			line = LineFromChar( selStart );
			length = GetLine( line, buffer, sizeof( buffer ) );
			for ( numTabs = 0; numTabs < length; numTabs++ ) {
				if ( !idStr::CharIsTab( buffer[numTabs] ) ) {
					break;
				}
			}
			bool first = true;
			for ( i = numTabs; i < length; i++ ) {
				if ( buffer[i] == '{' ) {
					numTabs++;
					first = false;
				} else if ( buffer[i] == '}' && !first ) {
					numTabs--;
				}
			}
			text = "\r\n";
			for ( i = 0; i < numTabs; i++ ) {
				text.Append( '\t' );
			}
			ReplaceSel( text, TRUE );
			return;
		}
	}

	m_TextDoc->Freeze( NULL );

	CRichEditCtrl::OnKeyDown( nKey, nRepCnt, nFlags );

	UpdateVisibleRange();

	m_TextDoc->Unfreeze( NULL );
}
/**************************************************************************
* ++
* Author: VinhLQ1
* Module Name :  CDlogChangeColor::ReadFile(CString lpszName,COLORREF &m_ColorREF_Keyword,COLORREF &m_ColorREF_Command,COLORREF &m_ColorREF_Method,COLORREF &m_ColorREF_Class,COLORREF &m_ColorREF_Other)
*
* Description : thuc hien viec lay mau tu file INIT nguoi dung khong can phai chinh mau lan nua
* 
*
* Mod. History :	12/12/2012 - VinhLQ1
*
* --
************************************************************************/
void  CDlogChangeColor::ReadFile(CString lpszName,COLORREF &m_ColorREF_Keyword,COLORREF &m_ColorREF_Command,COLORREF &m_ColorREF_Method,COLORREF &m_ColorREF_Class,COLORREF &m_ColorREF_Other)
{
	 CString lpszString;     //Dung de luu du lieu cua dong   
	 CString lpszColorForButtonColor;
	 int nP=0;
	 COLORREF clorr =0;

        TRY             //Tien hanh doc file 
        { 
                //Mo file de doc wdfer
                CStdioFile file(lpszName, CFile::modeNoTruncate | CFile::modeRead| CFile::modeCreate); 
                //Tien hanh quet tung dong trong file 
                while(file.ReadString(lpszString)) 
                { 
					//neu tim thay dong chua keyword
					if(lpszString.Find(L"Keyword")>=0)
					{
						int nPosOfStartColor=0;
						for(int i =0 ; i< lpszString.GetLength();i++)
						{
							//quet trong dong chuoi den khi thay dau '=' thi
							// lay cac ki tu o vi tri sau dau bang chinh' la mau.
							if(lpszString[i] == '=')
							{
								nPosOfStartColor=i+2;
								for(int nK= nPosOfStartColor;nK< lpszString.GetLength(); nK++)
								{
									int j = lpszColorForButtonColor.GetLength();
									lpszColorForButtonColor.Insert(j,lpszString[nK]);
								}
							
							}
						}
						//luu lai bien mau
						clorr=_tstoi(lpszColorForButtonColor);
						m_ColorBtt_Keyword.SetColor(clorr);
						lpszColorForButtonColor= "";
						m_ColorREF_Keyword =clorr;

					}
					//neu tim thay dong chua Command
					else if(lpszString.Find(L"Command")>=0)
					{

						int nPosOfStartColor=0;
						for(int i =0 ; i< lpszString.GetLength();i++)
						{
							//quet trong dong chuoi den khi thay dau '=' thi
							// lay cac ki tu o vi tri sau dau bang chinh' la mau.
							if(lpszString[i] == '=')
							{
								nPosOfStartColor=i+2;
								for(int nK= nPosOfStartColor;nK< lpszString.GetLength(); nK++)
								{
									int j = lpszColorForButtonColor.GetLength();
									lpszColorForButtonColor.Insert(j,lpszString[nK]);
								}
							
							}
						}
						//luu lai bien mau
						clorr=_tstoi(lpszColorForButtonColor);
						m_ColorBtt_BCommand.SetColor(clorr);
						lpszColorForButtonColor= "";
						m_ColorREF_Command=clorr;

					}
					//neu tim thay dong chua Method
					else if(lpszString.Find(L"Method")>=0)
					{

						int nPosOfStartColor=0;
						for(int i =0 ; i< lpszString.GetLength();i++)
						{
							//quet trong dong chuoi den khi thay dau '=' thi
							// lay cac ki tu o vi tri sau dau bang chinh' la mau.
							if(lpszString[i] == '=')
							{
								nPosOfStartColor=i+2;
								for(int nK= nPosOfStartColor;nK< lpszString.GetLength(); nK++)
								{
									int j = lpszColorForButtonColor.GetLength();
									lpszColorForButtonColor.Insert(j,lpszString[nK]);
								}
							
							}
						}
						//luu lai bien mau
						clorr=_tstoi(lpszColorForButtonColor);
						m_ColorBtt_BMethod.SetColor(clorr);
						lpszColorForButtonColor= "";
						m_ColorREF_Method=clorr;
					}
					//neu tim thay dong chua Class
					else if(lpszString.Find(L"Class")>=0)
					{

						int nPosOfStartColor=0;
						for(int i =0 ; i< lpszString.GetLength();i++)
						{
							//quet trong dong chuoi den khi thay dau '=' thi
							// lay cac ki tu o vi tri sau dau bang chinh' la mau.
							if(lpszString[i] == '=')
							{
								nPosOfStartColor=i+2;
								for(int nK= nPosOfStartColor;nK< lpszString.GetLength(); nK++)
								{
									int j = lpszColorForButtonColor.GetLength();
									lpszColorForButtonColor.Insert(j,lpszString[nK]);
								}
							
							}
						}
						//luu lai bien mau
						clorr=_tstoi(lpszColorForButtonColor);
						m_ColorBtt_BClass.SetColor(clorr);
						lpszColorForButtonColor= "";
						m_ColorREF_Class= clorr;
					}
					//neu tim thay dong chua Other contraints
					else if(lpszString.Find(L"Other contraints")>=0)
					{
						int nPosOfStartColor=0;
						for(int i =0 ; i< lpszString.GetLength();i++)
						{
							//quet trong dong chuoi den khi thay dau '=' thi
							// lay cac ki tu o vi tri sau dau bang chinh' la mau.
							if(lpszString[i] == '=')
							{
								nPosOfStartColor=i+2;
								for(int nK= nPosOfStartColor;nK< lpszString.GetLength(); nK++)
								{
									int j = lpszColorForButtonColor.GetLength();
									lpszColorForButtonColor.Insert(j,lpszString[nK]);
								}
							
							}
						}
						//luu lai bien mau
						clorr=_tstoi(lpszColorForButtonColor);
						m_ColorBtt_BOther.SetColor(clorr);
						lpszColorForButtonColor= "";
						m_ColorREF_Other= clorr;
					}
                } 
                //Dong file 
                file.Close(); 
		}
		CATCH_ALL(e)
		{
			e->ReportError();
		}
		END_CATCH_ALL;
}
Example #28
0
BOOL CEdRptExport::ExportDBData(ofstream &htm, ofstream &txt)
{
	CDatabase db;
	BOOL bRet = FALSE;

	CString csHeadFile = m_pDoc->m_szHeadRight;
	if (m_pDoc->m_szODBCLink.IsEmpty())
	{
		ShowMessage(m_pDoc->GetHWnd(), "没有给定数据库指针,也没有指定链接字!");
		return FALSE;
	}

	if (!db.OpenEx(m_pDoc->m_szODBCLink, CDatabase::openReadOnly | CDatabase::noOdbcDialog))
	{
		ShowMessage(m_pDoc->GetHWnd(), "无法打开数据库连接 %s", m_pDoc->m_szODBCLink);
		return FALSE;
	}

	try 
	{
		UINT nRecCount = m_pDoc->GetRecordCount(db);

		CString szSQL = m_pDoc->m_szSQL;
		if (nRecCount > (int)m_pDoc->m_nMaxRecordNum)
		{
			CString str;
			str.Format(_T("共有 %d 条记录,但模版设计最大记录数为 %d,\n是否只 %d 条记录?\n"
				"注意:如何选否,会给数据库很大压力,甚至取消操作!"), 
				nRecCount, m_pDoc->m_nMaxRecordNum, m_pDoc->m_nMaxRecordNum);
			
			UINT ulSelect = IDNO;
			if (m_pDoc->GetHWnd())
				ulSelect = MessageBox(m_pDoc->GetHWnd(), str, _T("EdFc"), MB_YESNOCANCEL);
			
			if (ulSelect == IDNO)
				;
			else if (ulSelect == IDCANCEL)
				return FALSE;
			else // IDYES
			{
				csHeadFile.Format(_T("  %d条记录未导出"), nRecCount - m_pDoc->m_nMaxRecordNum);
				nRecCount = m_pDoc->m_nMaxRecordNum;
				
				CString csDBDrv = getDBDriver(m_pDoc->m_szODBCLink);
				csDBDrv.MakeLower();
				if (csDBDrv.Find("oracle") >= 0)
				{
					CString szTmp = szSQL;
					szTmp.MakeLower();
					int nFind = szTmp.Find(" where ");
					if (nFind > 0)
					{
						szTmp.Format(" ROWNUM <= %d AND ", m_pDoc->m_nMaxRecordNum);
						szSQL.Insert(nFind + (int)_tcslen(" where "), (LPCSTR)szTmp);
					}
					else
					{
						szTmp.Format(" WHERE ROWNUM <= %d ", m_pDoc->m_nMaxRecordNum);
						szSQL += szTmp;
					}
				}
				else if (csDBDrv.Find("mysql") >= 0)
				{
					CString szTmp;
					szTmp.Format(" Limit 0, %d ", m_pDoc->m_nMaxRecordNum);
					szSQL += szTmp;
				}
// 				else if (csDBDrv.IsEmpty())
// 					ShowMessage(m_pDoc->GetHWnd(), "报表打印组件无法判断该数据库的类型。");
				else
				{
					CString str;
					str.Format(_T("[ %s ] 数据库无法使用修改SQL的方法限制记录个数,而打开大数据集可能会出现异常\n,是否先修改查询条件,再进行打印?"), csDBDrv);
					if (m_pDoc->GetHWnd() && MessageBox(m_pDoc->GetHWnd(), str,_T("BSRpter"), MB_YESNO) == IDYES)
						return FALSE;
				}
			}
		}
		
		CRecordset rc(&db);
		rc.Open(CRecordset::forwardOnly, szSQL);
		UINT nFieldCount = rc.GetODBCFieldCount();
		
		CString szTitle = m_pDoc->m_szTitle;
		TxtToHtml(szTitle);

		CString szHeadRight = m_pDoc->m_szHeadRight;
		TxtToHtml(szHeadRight);
		htm << "<html><head><title>" 
			<< (LPCTSTR)szTitle 
			<< "</title></head>"
			<< endl;

		htm << "<body>" << endl
			<< "<table width=100%>" << endl
			<< "<tr>" << endl
			<< "\t<td width=20%>&nbsp;</td>" << endl
			<< "\t<td width=60% align=center><font size=+3>" 
			<< (LPCTSTR)szTitle
			<< "</font></td>" << endl
			<< "\t<td width=20% align=right>"
			<< (LPCTSTR)csHeadFile
			<< "</td>" << endl 
			<< "</tr>" << endl
			<< "</table>" << endl;

		htm << "<table border=1 width=100%>" << endl
			<< "<tr>" << endl;

		
		int nWidth = 0;
		for (UINT col = 0; col < nFieldCount; col++)
			nWidth += m_pDoc->m_ColFmt[col].width;

		CString str;
		for (col = 0; col < nFieldCount; col++)
		{	
			str = m_pDoc->m_ColFmt[col].name;

			if (str.IsEmpty())
			{
				CODBCFieldInfo fi;
				rc.GetODBCFieldInfo(col, fi);
				str = fi.m_strName;
			}

			txt << "\"" << (LPCTSTR)str << "\"";
			TxtToHtml(str);
			htm << "\t<td  width=" << m_pDoc->m_ColFmt[col].width * 100 / nWidth
				<< "%  align=center>" << (LPCTSTR)str << "</td>" << endl;
			
			if (col == nFieldCount - 1)
			{
				txt << endl;
				htm << "</tr>" << endl;
			}
			else
				txt << ',';
		}
		
		if (m_pDoc->GetHWnd())
			::SendMessage(m_pDoc->GetHWnd(), WM_CREATEPROGRESS, nRecCount, 0);

		CDBVariant varValue;
		CString strHtml;
		UINT nCount = 0;
		for(UINT row = 0; row < nRecCount; row ++)
		{
			htm << "<tr>" << endl;

			for (UINT col = 0; col < nFieldCount; col ++)
			{
				strHtml = _T("");
				rc.GetFieldValue(col, varValue);

				if (varValue.m_dwType == DBVT_BINARY)
				{
					str = GetPicFile(varValue.m_pbinary, nCount++);
					
					if (str.IsEmpty())	//error
						continue;
					
					m_ZipArc.AddFileToZip(str);
					DeleteFile(str);
					str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
					strHtml.Format("<A href=%s>%s</A>", str, str);
				}
				else 
					str = m_pDoc->GetVarStr(&varValue, m_pDoc->m_ColFmt[col].format);

				varValue.Clear();
				
				txt << "\"" << (LPCTSTR)str << "\"";
				
				TxtToHtml(str);
				if (strHtml.IsEmpty())
					strHtml = str;
					
				htm << "\t<td align=center>" << (LPCTSTR)strHtml << "</td>" << endl;
				
				if (col == nFieldCount - 1)
				{
					txt << endl;
					htm << "</tr>" << endl;
				}
				else
					txt << ',';
			}

			if (m_pDoc->GetHWnd())
				::SendMessage(m_pDoc->GetHWnd(), WM_STEPPROGRESS, nRecCount, row);

			rc.MoveNext();
		}
		
		rc.Close();
	
		CString szFootLeft = m_pDoc->m_szFootLeft;
		TxtToHtml(szFootLeft);
		CString szFootRight = m_pDoc->m_szFootRight;
		if (szFootRight.IsEmpty())
			szFootRight = CTime::GetCurrentTime().Format("%m/%d/%y %H:%M:%S");
		TxtToHtml(szFootRight);

		htm << "</table>" << endl
			<< "<p>" << endl
			<< "<table width=100%>" << endl
			<< "<tr>" << endl 
			<< "\t<td width=50% align=left>"
			<< (LPCTSTR)szFootLeft
			<< "</td>" << endl
			<< "\t<td width=50% align=right>"
			<< (LPCTSTR)szFootRight
			<< "</td>" << endl
			<< "</table>" << endl
			
			<< "<p><hr>" << endl
			<< "<b>FmtFile Infomation</b><br>" << endl
			<< "<ul>" << endl
			<< "\t<li>ODBC: " << (LPCTSTR)m_pDoc->m_szODBCLink << "<br>" << endl
			<< "\t<li>SQL : " << (LPCTSTR)m_pDoc->m_szSQL
			<< "</ul>" << endl
			<< "</body>" << endl
			<< "</html>" << endl;
		
		if (m_pDoc->GetHWnd())
			::SendMessage(m_pDoc->GetHWnd(), WM_DESTROYPROGRESS, 0, 0);
		
		bRet = TRUE;
	}
	catch(CException *edb)
	{
		static TCHAR lpszError[MAX_PATH];
		CString csError;

		if (edb->GetErrorMessage(lpszError, MAX_PATH))
			csError = lpszError;

		if (csError.GetLength() <= 0)
			csError = _T("无法获得数据!");
		
		ShowMessage(m_pDoc->GetHWnd(), csError);

		edb->Delete();
		bRet = FALSE;
	}
	catch(...)
	{
		ShowMessage(m_pDoc->GetHWnd(), _T("无法获得数据!"));
		bRet = FALSE;
	}

	db.Close();

	return bRet;
}