示例#1
0
void RearrangeFileArrayWithDoubleFileName(CStringArray &fileArr)
{
	// rearrange of file array( follow the order of number )
	int nArr = fileArr.GetSize();
	CString curFileDir;
	CStringArray newfileArr;
	newfileArr.Copy(fileArr);
	int nLength1 = 0;

	// The number of file length 1
	for ( int i = 0; i < nArr; i++ ) {	
		curFileDir = GetFileName(newfileArr[i]);
		curFileDir = curFileDir.Left(curFileDir.ReverseFind('-'));
		curFileDir = curFileDir.Left(curFileDir.ReverseFind('-'));

		if ( curFileDir.GetLength() == 1 )
			nLength1++;
	}

	// Set file length 1 path to real fileArr
	int q=0;
	for ( int i = 0; i < nArr; i++ ) {
		curFileDir = GetFileName(newfileArr[i]);
		curFileDir = curFileDir.Left(curFileDir.ReverseFind('-'));
		curFileDir = curFileDir.Left(curFileDir.ReverseFind('-'));
		if ( curFileDir.GetLength() == 1 )
		{
			fileArr.SetAt(q,newfileArr[i]);
			q++;
		}
	}

	// Set file length 2 path to real fileArr
	q=0;
	for ( int i = 0; i < nArr; i++ ) {
		curFileDir = GetFileName(newfileArr[i]);
		curFileDir = curFileDir.Left(curFileDir.ReverseFind('-'));
		curFileDir = curFileDir.Left(curFileDir.ReverseFind('-'));
		if ( curFileDir.GetLength() != 1  )
		{
			fileArr.SetAt( nLength1+q, newfileArr[i]);
			q++;
		}
	}
}
示例#2
0
void EnumerateTuple(PyObject* pTuple, CStringArray& astrRet, int argcountlimit = 100)
{
	Py_ssize_t nNumItems = min(PyTuple_GET_SIZE(pTuple),argcountlimit);
	astrRet.SetSize(nNumItems);
	for(int i = 0; i < nNumItems; i++)
	{
		PyObject* pItem = PyTuple_GET_ITEM( pTuple, i );
		astrRet.SetAt(i, CA2T(PyString_AsString(pItem)));
	}
}
示例#3
0
BOOL GetLastEditScript(CStringArray &anArray)
{
	int i;

	anArray.RemoveAll();
	if (!m_bEditScriptValid) return FALSE;

	anArray.SetSize(m_EditScript.GetSize());
	for (i=0; i<m_EditScript.GetSize(); i++) anArray.SetAt(i, m_EditScript.GetAt(i));

	return TRUE;
}
示例#4
0
	void CLangManager::GetLangList(CStringArray &langs)
	{

		CMyUtility::GetFileList(langs, _T("langs"));

		for (int i=0; i<langs.GetCount(); ++i)
		{
			CString temp = langs.GetAt(i);
			temp = temp.Left(temp.GetLength() - 4);
			langs.SetAt(i, temp);
		}

	}
示例#5
0
// 根据宽高排序
void BubbleSort(CStringArray &ca)
{
    int len = ca.GetCount();
    int width1 = 0;
    int height1 = 0;
    int width2 = 0;
    int height2 = 0;
    CString tmp;

    for (int i = 0; i < len; i++)
    {
        for (int j = i; j < len; j++)
        {
            swscanf_s(ca[i].GetBuffer(), _T("%dx%d"), &width1, &height1);
            swscanf_s(ca[j].GetBuffer(), _T("%dx%d"), &width2, &height2);
            if ((width1 > width2) || (width1 == width2 && height1 > height2))
            {
                tmp = ca.GetAt(i);
                ca.SetAt(i, ca.GetAt(j));
                ca.SetAt(j, tmp);
            }
        }
    }
}
示例#6
0
文件: Tool.cpp 项目: ngphloc/design
void Alpha(CStringArray& aszS)
{
    int i=0;
    while(i<aszS.GetSize())
    {
        CString tempS;
        Alpha(aszS[i],tempS);
        if(tempS.IsEmpty())
            aszS.RemoveAt(i);
        else
        {
            aszS.SetAt(i,tempS);
            i++;
        }
    }

}
void CLookupForm::OnInitialize()
{
    if(m_isHR)
    {
        SetWindowText(_T("Lookup HRESULT values"));

        m_listCtrl.InsertColumn(0, _T("Name"), LVCFMT_LEFT, 120);
        m_listCtrl.InsertColumn(1, _T("Hex value"), LVCFMT_RIGHT, 80);
        m_listCtrl.InsertColumn(2, _T("Dec value"), LVCFMT_RIGHT, 80);
        m_listCtrl.InsertColumn(3, _T("Message"), LVCFMT_LEFT, 250);

        int i = 0;
        while(GraphStudio::InsertHresultLookup(i, &m_listCtrl)) i++;
    }
    else
    {
        SetWindowText(_T("Lookup GUID values"));

        m_listCtrl.InsertColumn(0, _T("Name"), LVCFMT_LEFT, 160);
        m_listCtrl.InsertColumn(1, _T("Value"), LVCFMT_LEFT, 242);
        m_listCtrl.InsertColumn(2, _T("From"), LVCFMT_LEFT, 80);
        m_listCtrl.InsertColumn(3, _T("Info"), LVCFMT_LEFT, 300);

        int i = 0;
        while(GraphStudio::InsertGuidLookup(i, &m_listCtrl)) i++;
    }

    // Make Item-Data lower for better search (more results)
    int count = m_listCtrl.GetItemCount();
    for(int i=0;i<count;i++)
    {
        CStringArray* arData = (CStringArray*)m_listCtrl.GetItemData(i);
        for(int j=0;j<arData->GetCount();j++)
        {
            CString str = arData->GetAt(j);
            str.MakeLower();
            arData->SetAt(j, str);
        }
    }

    m_listCtrl.SortItems(CompareFunction, (DWORD_PTR)&sortData);

    m_listCtrl.SetExtendedStyle( m_listCtrl.GetExtendedStyle() | LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP );
}
void CBCGPPlannerPrintMonth::OnDrawHeader (CDC* pDC, const CRect& rectHeader)
{
	ASSERT_VALID (pDC);

	const int dxColumn = m_ViewRects [0].Width ();

	CRect rectDayCaption (rectHeader);
	
	DrawHeader (pDC, rectDayCaption, dxColumn);

	rectDayCaption.right = rectDayCaption.left + dxColumn;

	COleDateTime day 
		(
			GetFirstWeekDay2 (m_Date, CBCGPPlannerManagerCtrl::GetFirstDayOfWeek () + 1)
		);

	const int nEnd = m_bCompressWeekend ? 6 : 7;

	CStringArray sa;
	sa.SetSize (nEnd);

	int iColumn = 0;
	for (iColumn = 0; iColumn < nEnd; iColumn++)
	{
		CString strDate;

		if (IsCompressWeekend () && day.GetDayOfWeek () == 7)
		{
			for (int i = 0; i < 2; i++)
			{
				CString strTemp;
				strTemp.GetBuffer (_MAX_PATH);

				SYSTEMTIME st;
				day.GetAsSystemTime (st);

				::GetDateFormat (LOCALE_USER_DEFAULT, 0, &st, 
					_T("ddd"), (LPTSTR)(LPCTSTR)strTemp, _MAX_PATH);

				strTemp.ReleaseBuffer ();

				strDate += strTemp;

				if (i == 0)
				{
					strDate += _T("/");
				}

				day += COleDateTimeSpan (1, 0, 0, 0);
			}
		}
		else
		{
			strDate.GetBuffer (_MAX_PATH);

			SYSTEMTIME st;
			day.GetAsSystemTime (st);

			::GetDateFormat (LOCALE_USER_DEFAULT, 0, &st, 
				m_strCaptionFormat, (LPTSTR)(LPCTSTR)strDate, _MAX_PATH);

			strDate.ReleaseBuffer ();

			day += COleDateTimeSpan (1, 0, 0, 0);
		}

		sa.SetAt (iColumn, strDate);
	}

	for (iColumn = 0; iColumn < nEnd; iColumn++)
	{
		DrawCaption (pDC, rectDayCaption, sa[iColumn], TRUE, TRUE, m_brGray);
		rectDayCaption.OffsetRect (dxColumn + m_OnePoint.cx, 0);
	}
}
// 更新过滤数据
BOOL CDlgCheckRuleFeaName::UpdateFilterControlByCheckRule(const CheckRule &checkRule)
{
	CStringArray arrMdlFilterCheckRule;//模型筛选
	CStringToCStringArray(checkRule.strRuleName, arrMdlFilterCheckRule);
	int nArrSize = (int)arrMdlFilterCheckRule.GetSize();
	if (nArrSize < 3 || arrMdlFilterCheckRule.GetAt(0).CompareNoCase(L"filter") != 0)
	{
		arrMdlFilterCheckRule.SetSize(3);
		arrMdlFilterCheckRule.SetAt(0, L"filter");
		arrMdlFilterCheckRule.SetAt(1, L"parameter");
		arrMdlFilterCheckRule.SetAt(2, L"abc");
	}

	m_cmbFilterCategory.ResetContent();
	m_cmbFilterCategory.AddString(L"模型名");
	m_cmbFilterCategory.AddString(L"公用名称");
	m_cmbFilterCategory.AddString(L"参数");

	m_cmbFilterParaName.ResetContent();

	int ntag = -1;
	CString strCatagory = arrMdlFilterCheckRule.GetAt(1);
	if (strCatagory.CompareNoCase(L"name") == 0)
	{
		ntag = 0;
		m_cmbFilterParaName.EnableWindow(FALSE);
	}
	else if (strCatagory.CompareNoCase(L"common_name") == 0)
	{
		ntag = 1;
		m_cmbFilterParaName.EnableWindow(FALSE);
	}
	else if (strCatagory.CompareNoCase(L"parameter") == 0)
	{
		ntag = 2;
		m_cmbFilterParaName.EnableWindow(TRUE);
		m_strParaParameter = arrMdlFilterCheckRule.GetAt(2);//参数名静态变量赋值
	}
	else
		return TRUE;

	m_cmbFilterCategory.SetCurSel(ntag);

	if (ntag == 2)
	{
		CString strParaContent = arrMdlFilterCheckRule.GetAt(2);
		int nFind = -1;
		for (int i = 0; i < theApp.m_arrMdlParam.GetSize(); i++)
		{
			m_cmbFilterParaName.AddString(theApp.m_arrMdlParam[i]);
			if (strParaContent.CompareNoCase(theApp.m_arrMdlParam[i]) == 0)
			{
				nFind = i;
			}
		}
		if (nFind >= 0)
			m_cmbFilterParaName.SetCurSel(nFind);
		else
			m_cmbFilterParaName.SetWindowText(strParaContent);
	}

	if (arrMdlFilterCheckRule.GetSize() == 3)
		m_strFilterContent = arrMdlFilterCheckRule.GetAt(2);
	else
		m_strFilterContent = arrMdlFilterCheckRule.GetAt(3);

	if (arrMdlFilterCheckRule.GetSize() > 4)
		m_bMdlFilter = _wtoi(arrMdlFilterCheckRule.GetAt(4));
	if (m_bMdlFilter)
	{
		m_cmbFilterCategory.EnableWindow(TRUE);
		int nIndex = m_cmbFilterCategory.GetCurSel();
		if (nIndex == 0)
			m_cmbFilterParaName.EnableWindow(FALSE);
		else if (nIndex == 1)
			m_cmbFilterParaName.EnableWindow(FALSE);
		else
			m_cmbFilterParaName.EnableWindow(TRUE);
		GetDlgItem(IDC_EDIT_MDL_PARA_CATA_CONTENT)->EnableWindow(TRUE);
	}
	else
	{
		m_cmbFilterCategory.EnableWindow(FALSE);
		m_cmbFilterParaName.EnableWindow(FALSE);
		GetDlgItem(IDC_EDIT_MDL_PARA_CATA_CONTENT)->EnableWindow(FALSE);
	}

	UpdateData(FALSE);
	return TRUE;
}
void CLibraryDetailView::CacheItem(int nItem)
{
	CLibraryFile* pFile = Library.LookupFile( m_pList[ nItem ].nIndex );
	if ( ! pFile ) return;
	
	LDVITEM* pItem = &m_pList[ nItem ];
	pItem->nCookie = m_nListCookie;
	
	if ( pItem->pText == NULL ) pItem->pText = new CStringArray();
	
	CStringArray* pText = pItem->pText;
	pText->SetSize( m_nStyle == LVS_REPORT ? DETAIL_COLUMNS + m_pColumns.GetCount() : 1 );
	
	CString strName( pFile->m_sName );
	int nDot = strName.ReverseFind( '.' );
	if ( nDot >= 0 ) strName.SetAt( nDot, 0 );
	pText->SetAt( 0, strName );
	
	if ( m_nStyle == LVS_ICON )
	{
		pItem->nIcon = ShellIcons.Get( pFile->m_sName, 32 );
	}
	else
	{
		if ( pFile->m_nIcon16 >= 0 )
			pItem->nIcon = pFile->m_nIcon16;
		else
			pItem->nIcon = pFile->m_nIcon16 = ShellIcons.Get( pFile->m_sName, 16 );
	}
	
	pItem->nState &= LDVI_SELECTED;
	if ( ! pFile->IsShared() ) pItem->nState |= LDVI_PRIVATE;
	if ( ! pFile->m_bSHA1 ) pItem->nState |= LDVI_UNSCANNED;
	if ( pFile->m_bVerify == TS_FALSE ) pItem->nState |= LDVI_UNSAFE;
	
	if ( m_nStyle != LVS_REPORT ) return;
	
	if ( LPCTSTR pszType = _tcsrchr( pFile->m_sName, '.' ) )
		pText->SetAt( 1, pszType + 1 );
	else
		pText->SetAt( 1, _T("") );
	
	pText->SetAt( 2, Settings.SmartVolume( pFile->GetSize(), FALSE ) );
	if ( pFile->m_pFolder != NULL ) pText->SetAt( 3, pFile->m_pFolder->m_sPath );
	
	CString str;
	str.Format( _T("%lu (%lu)"), pFile->m_nHitsToday, pFile->m_nHitsTotal );
	pText->SetAt( 4, str );
	str.Format( _T("%lu (%lu)"), pFile->m_nUploadsToday, pFile->m_nUploadsTotal );
	pText->SetAt( 5, str );
	
	TCHAR szModified[ 64 ];
	SYSTEMTIME pTime;
	
	FileTimeToSystemTime( &pFile->m_pTime, &pTime );
	SystemTimeToTzSpecificLocalTime( NULL, &pTime, &pTime );
	
	GetDateFormat( LOCALE_USER_DEFAULT, 0, &pTime, _T("yyyy-MM-dd"), szModified, 64 );
	_tcscat( szModified, _T(" ") );
	GetTimeFormat( LOCALE_USER_DEFAULT, 0, &pTime, _T("hh:mm tt"), szModified + _tcslen( szModified ), 64 - _tcslen( szModified ) );
	
	pText->SetAt( 6, szModified );
	
	if ( m_pSchema == NULL ) return;
	
	int nColumn = DETAIL_COLUMNS;
	
	BOOL bSource =	pFile->m_pMetadata && m_pSchema->Equals( pFile->m_pSchema ) &&
					m_pSchema->m_sSingular.CompareNoCase( pFile->m_pMetadata->GetName() ) == 0;
	
	for ( POSITION pos = m_pColumns.GetHeadPosition() ; pos ; nColumn++ )
	{
		CSchemaMember* pMember = (CSchemaMember*)m_pColumns.GetNext( pos );
		
		if ( pMember->m_sName.CompareNoCase( _T("SHA1") ) == 0 )
		{
			if ( pFile->m_bSHA1 )
			{
				pText->SetAt( nColumn, CSHA::HashToString( &pFile->m_pSHA1 ) );
			}
			else pText->SetAt( nColumn, _T("") );
		}
		else if ( bSource )
		{
			pText->SetAt( nColumn, pMember->GetValueFrom( pFile->m_pMetadata, NULL, TRUE ) );
		}
		else
		{
			pText->SetAt( nColumn, _T("") );
		}
	}
}
示例#11
0
double CompareFunctions(FUNC_COMPARE_METHOD nMethod,
											CFuncDescFile *pFile1, int nFile1FuncNdx,
											CFuncDescFile *pFile2, int nFile2FuncNdx,
											BOOL bBuildEditScript)
{
	CFuncDesc *pFunction1;
	CFuncDesc *pFunction2;
	CStringArray zFunc1;
	CStringArray zFunc2;
	double nRetVal = 0;
	CString strTemp;

	m_bEditScriptValid = FALSE;
	m_EditScript.RemoveAll();

	if ((pFile1 == NULL) || (pFile2 == NULL)) return nRetVal;

	pFunction1 = pFile1->GetFunc(nFile1FuncNdx);
	pFunction2 = pFile2->GetFunc(nFile2FuncNdx);
	if ((pFunction1 == NULL) ||
		(pFunction2 == NULL)) return nRetVal;

	pFunction1->ExportToDiff(zFunc1);
	pFunction2->ExportToDiff(zFunc2);
	if ((zFunc1.GetSize() == 0) ||
		(zFunc2.GetSize() == 0)) return nRetVal;

	if ((bBuildEditScript) && (nMethod == FCM_DYNPROG_XDROP)) {
		// Note: XDROP Method currently doesn't support building
		//		of edit scripts, so if caller wants to build an
		//		edit script and has selected this method, replace
		//		it with the next best method that does support
		//		edit scripts:
		nMethod = FCM_DYNPROG_GREEDY;
	}

	switch (nMethod) {
		case FCM_DYNPROG_XDROP:
		{
			//
			//	The following algorithm comes from the following source:
			//			"A Greedy Algorithm for Aligning DNA Sequences"
			//			Zheng Zhang, Scott Schwartz, Lukas Wagner, and Webb Miller
			//			Journal of Computational Biology
			//			Volume 7, Numbers 1/2, 2000
			//			Mary Ann Liebert, Inc.
			//			Pp. 203-214
			//
			//			p. 205 : Figure 2 : "A dynamic-programming X-drop algorithm"
			//
			//		T' <- T <- S(0,0) <- 0
			//		k <- L <- U <- 0
			//		repeat {
			//			k <- k + 1
			//			for i <- ceiling(L) to floor(U)+1 in steps of 1/2 do {
			//				j <- k - i
			//				if i is an integer then {
			//					S(i, j) <- Max of:
			//								S(i-1/2, j-1/2) + mat/2		if L <= i-1/2 <= U and a(i) = b(j)
			//								S(i-1/2, j-1/2) + mis/2		if L <= i-1/2 <= U and a(i) != b(j)
			//								S(i, j-1) + ind				if i <= U
			//								S(i-1, j) + ind				if L <= i-1
			//				} else {
			//					S(i, j) <- S(i-1/2, j-1/2)
			//								+ mat/2	if a(i+1/2) = b(j+1/2)
			//								+ mis/2	if a(i+1/2) != b(j+1/2)
			//				}
			//				T' <- max{T', S(i, j)}
			//				if S(i, j) < (T - X) then S(i, j) <- -oo
			//			}
			//			L <- min{i : S(i, k-i) > -oo }
			//			U <- max{i : S(i, k-i) > -oo }
			//			L <- max{L, k+1-N}				<<< Should be: L <- max{L, k+1/2-N}
			//			U <- min{U, M-1}				<<< Should be: U <- min(U, M-1/2}
			//			T <- T'
			//		} until L > U+1
			//		report T'
			//
			//	Given:
			//		arrays: a(1..M), b(1..N) containing the two strings to compare
			//		mat : >0 : Weighting of a match
			//		mis : <0 : Weighting of a mismatch
			//		ind : <0 : Weighting of an insertion/deletion
			//		X = Clipping level : If scoring falls more than X below the
			//				best computed score thus far, then we don't consider
			//				additional extensions for that alignment.  Should
			//				be >= 0 or -1 for infinity.
			//
			//	Returning:
			//		T' = Composite similarity score
			//
			//	For programmatic efficiency, all S indexes have been changed from
			//		0, 1/2 to even/odd and the i loop runs as integers of even/odd
			//		instead of 1/2 increments:
			//
			//	Testing has also been done and it has been proven that the order of
			//		the two arrays has no effect on the outcome.
			//
			//	In the following, we will define oo as DBL_MAX and -oo as -DBL_MAX.
			//
			//	To hold to the non-Generalized Greedy Algorithm requirements, set
			//		ind = mis - mat/2
			//

			CStringArray &a = zFunc1;
			CStringArray &b = zFunc2;
			double Tp, T;
			double **S;
			int i, j, k, L, U;
			double nTemp;
			int M = a.GetSize();
			int N = b.GetSize();
			const double mat = 2;
			const double mis = -2;
			const double ind = -3;
			const double X = -1;

			// Allocate Memory:
			S = new double*[((M+1)*2)];
			if (S == NULL) {
				AfxThrowMemoryException();
				return nRetVal;
			}
			for (i=0; i<((M+1)*2); i++) {
				S[i] = new double[((N+1)*2)];
				if (S[i] == NULL) AfxThrowMemoryException();
			}

			// Initialize:
			for (i=0; i<((M+1)*2); i++) {
				for (j=0; j<((N+1)*2); j++) {
					S[i][j] = -DBL_MAX;
				}
			}

			// Algorithm:
			Tp = T = S[0][0] = 0;
			k = L = U = 0;

			do {
				k = k + 2;
				for (i = L+((L & 0x1) ? 1 : 0); i <= (U - ((U & 0x1) ? 1 : 0) + 2); i++) {
					j = k - i;
					ASSERT(i >= 0);
					ASSERT(i < ((M+1)*2));
					ASSERT(j >= 0);
					ASSERT(j < ((N+1)*2));
					if ((i&1) == 0) {
						nTemp = -DBL_MAX;
						if ((L <= (i-1)) &&
							((i-1) <= U)) {
							// TODO : Improve A/B Comparison:
							if (a.GetAt((i/2)-1).CompareNoCase(b.GetAt((j/2)-1)) == 0) {
								nTemp = __max(nTemp, S[i-1][j-1] + mat/2);
							} else {
								nTemp = __max(nTemp, S[i-1][j-1] + mis/2);
							}
						}
						if (i <= U) {
							nTemp = __max(nTemp, S[i][j-2] + ind);
						}
						if (L <= (i-2)) {
							nTemp = __max(nTemp, S[i-2][j] + ind);
						}
						S[i][j] = nTemp;
					} else {
						// TODO : Improve A/B Comparison:
						if (a.GetAt(((i+1)/2)-1).CompareNoCase(b.GetAt(((j+1)/2)-1)) == 0) {
							S[i][j] = S[i-1][j-1] + mat/2;
						} else {
							S[i][j] = S[i-1][j-1] + mis/2;
						}
					}
					Tp = __max(Tp, S[i][j]);
					if ((X>=0) && (S[i][j] < (T-X))) S[i][j] = -DBL_MAX;
				}

				for (L = 0; L < ((M+1)*2); L++) {
					if ((k - L) < 0) continue;
					if ((k - L) >= ((N+1)*2)) continue;
					if (S[L][k-L] > -DBL_MAX) break;
				}
				if (L == ((M+1)*2)) L=INT_MAX;

				for (U=((M+1)*2)-1; U>=0; U--) {
					if ((k - U) < 0) continue;
					if ((k - U) >= ((N+1)*2)) continue;
					if (S[U][k-U] > -DBL_MAX) break;
				}
				if (U == -1) U=INT_MIN;

				L = __max(L, k + 1 - (N*2));
				U = __min(U, (M*2) - 1);
				T = Tp;
			} while (L <= U+2);

			// If the two PrimaryLabels at the function's address don't match, decrement match by 1*mat.
			//		This helps if there are two are more functions that the user has labeled that
			//		are identical except for the labels:
			if (pFile1->GetPrimaryLabel(pFunction1->GetMainAddress()).CompareNoCase(
					pFile2->GetPrimaryLabel(pFunction2->GetMainAddress())) != 0) Tp = __max(0, Tp - mat);

			// Normalize it:
			nRetVal = Tp/(__max(M,N)*mat);

			// Deallocate Memory:
			for (i=0; i<((M+1)*2); i++) delete[] (S[i]);
			delete[] S;
		}
		break;

		case FCM_DYNPROG_GREEDY:
		{
			//
			//	The following algorithm comes from the following source:
			//			"A Greedy Algorithm for Aligning DNA Sequences"
			//			Zheng Zhang, Scott Schwartz, Lukas Wagner, and Webb Miller
			//			Journal of Computational Biology
			//			Volume 7, Numbers 1/2, 2000
			//			Mary Ann Liebert, Inc.
			//			Pp. 203-214
			//
			//			p. 209 : Figure 4 : "Greedy algorithm that is equivalent to the algorithm
			//								of Figure 2 if ind = mis - mat/2."
			//
			//		i <- 0
			//		while i < min{M, N} and a(i+1) = b(i+1) do i <- i + 1
			//		R(0, 0) <- i
			//		T' <- T[0] <- S'(i+i, 0)
			//		d <- L <- U <- 0
			//		repeat
			//			d <- d + 1
			//			d' <- d - floor( (X + mat/2)/(mat - mis) ) - 1
			//			for k <- L - 1 to U + 1 do
			//				i <- max of:
			//							R(d-1, k-1) + 1		if L < k
			//							R(d-1, k) + 1		if L <= k <= U
			//							R(d-1, k+1)			if k < U
			//				j <- i - k
			//				if i > -oo and S'(i+j, d) >= T[d'] - X then
			//					while i<M, j<N, and a(i+1) = b(j+1) do
			//						i <- i + 1;  j <- j + 1
			//					R(d, k) <- i
			//					T' <- max{T', S'(i+j, d)}
			//				else R(d, k) <- -oo
			//			T[d] <- T'
			//			L <- min{k : R(d, k) > -oo}
			//			U <- max{k : R(d, k) > -oo}
			//			L <- max{L, max{k : R(d, k) = N + k} + 2}	<<< Should be: L <- max{L, max{k : R(d, k) = N + k} + 1}
			//			U <- min{U, min{k : R(d, k) = M } - 2}		<<< Should be: U <- min{U, min{k : R(d, k) = M } - 1}
			//		until L > U + 2
			//		report T'
			//
			//	Given:
			//		arrays: a(1..M), b(1..N) containing the two strings to compare
			//		mat : >0 : Weighting of a match
			//		mis : <0 : Weighting of a mismatch
			//		ind : <0 : Weighting of an insertion/deletion
			//		(Satisfying: ind = mis - mat/2)
			//		X = Clipping level : If scoring falls more than X below the
			//				best computed score thus far, then we don't consider
			//				additional extensions for that alignment.  Should
			//				be >= 0 or -1 for infinity.
			//		S'(i+j, d) = (i+j)*mat/2 - d*(mat-mis)
			//		or S'(k, d) = k*mat/2 - d*(mat-mis)
			//
			//	Returning:
			//		T' = Composite similarity score
			//
			//	Testing has also been done and it has been proven that the order of
			//		the two arrays has no effect on the outcome.
			//
			//	In the following it will be assumed that the number of mismatches
			//	(i.e. array bounds) can't exceed M+N since the absolute maximum
			//	edit script to go from an array of M objects to an array of N
			//	objects is to perform M deletions and N insertions.  However,
			//	these differences can be tracked either forward or backward, so
			//	the memory will be allocated for the full search field.
			//
			//	We are also going to define -oo as being -2 since no index can be
			//	lower than 0.  The reason for the -2 instead of -1 is to allow
			//	for the i=R(d,k)+1 calculations to still be below 0.  That is
			//	to say so that -oo + 1 = -oo
			//

			CStringArray &a = zFunc1;
			CStringArray &b = zFunc2;
			double Tp;				// T' = Overall max for entire comparison
			double Tpp;				// T'' = Overall max for current d value
			double *T;
			double nTemp;
			int **Rm;
			int *Rvisitmin;			// Minimum k-index of R visited for a particular d (for speed)
			int *Rvisitmax;			// Maximum k-index of R visited for a particular k (for speed)
			int i, j, k, L, U;
			int d, dp;
			int dbest, kbest;
			int M = a.GetSize();
			int N = b.GetSize();
			const int dmax = ((M+N)*2)+1;
			const int kmax = (M+N+1);
			const int rksize = (kmax*2)+1;
			const double mat = 2;
			const double mis = -2;
			const double X = -1;
			const int floored_d_offset = (int)((X+(mat/2))/(mat-mis));
			#define Sp(x, y) ((double)((x)*(mat/2) - ((y)*(mat-mis))))
			#define R(x, y) (Rm[(x)][(y)+kmax])

			// Allocate Memory:
			T = new double[dmax];
			if (T == NULL) {
				AfxThrowMemoryException();
				return nRetVal;
			}

			Rvisitmin = new int[dmax];
			if (Rvisitmin == NULL) {
				AfxThrowMemoryException();
				delete T;
				return nRetVal;
			}

			Rvisitmax = new int[dmax];
			if (Rvisitmax == NULL) {
				AfxThrowMemoryException();
				delete T;
				delete Rvisitmin;
				return nRetVal;
			}

			Rm = new int*[dmax];
			if (Rm == NULL) {
				AfxThrowMemoryException();
				delete T;
				delete Rvisitmin;
				delete Rvisitmax;
				return nRetVal;
			}
			for (i=0; i<dmax; i++) {
				Rm[i] = new int[rksize];
				if (Rm[i] == NULL) AfxThrowMemoryException();
			}

			// Initialize:
			for (i=0; i<dmax; i++) {
				T[i] = 0;
				Rvisitmin[i] = kmax+1;
				Rvisitmax[i] = -kmax-1;
				for (j=0; j<rksize; j++) {
					Rm[i][j] = -2;
				}
			}

			// Algorithm:
			i=0;
			// TODO : Improve A/B Comparison:
			while ((i<__min(M, N)) && (a.GetAt(i).CompareNoCase(b.GetAt(i)) == 0)) i++;
			R(0, 0) = i;
			dbest = kbest = 0;
			Tp = T[0] = Sp(i+i, 0);
			d = L = U = 0;
			Rvisitmin[0] = 0;
			Rvisitmax[0] = 0;

/*
printf("\n");
*/

			if ((i != M) || (i != N)) {
				do {
					d++;
					dp = d - floored_d_offset - 1;
					Tpp = -DBL_MAX;
					for (k=(L-1); k<=(U+1); k++) {
						ASSERT(d > 0);
						ASSERT(d < dmax);
						ASSERT(abs(k) <= kmax);
						i = -2;
						if (L < k)			i = __max(i, R(d-1, k-1)+1);
						if ((L <= k) &&
							(k <= U))		i = __max(i, R(d-1, k)+1);
						if (k < U)			i = __max(i, R(d-1, k+1));
						j = i - k;
						if ((i >= 0) && (j >= 0) && ((X<0) || (Sp(i+j, d) >= (((dp >= 0) ? T[dp] : 0) - X)))) {
							// TODO : Improve A/B Comparison:
							while ((i<M) && (j<N) && (a.GetAt(i).CompareNoCase(b.GetAt(j)) == 0)) {
								i++; j++;
							}

							R(d, k) = i;
							if (Rvisitmin[d] > k) Rvisitmin[d] = k;
							if (Rvisitmax[d] < k) Rvisitmax[d] = k;
							nTemp = Sp(i+j, d);
							Tp = __max(Tp, nTemp);
/*
printf("d=%2ld : k=%2ld, i=%2ld, j=%2ld, M=%2ld, N=%2ld, T=%2ld, Tp=%2ld, Tpp=%2ld", d, k, i, j, M, N, (int)nTemp, (int)Tp, (int)Tpp);
*/
							if (nTemp > Tpp) {
								Tpp = nTemp;
/*
printf(" * Best (%2ld)", (int)Tpp);
*/
									dbest = d;
									kbest = k;


									// Account for hitting the max M or N boundaries:
									if ((i != M) || (j != N)) {
										if (j > N) {
											kbest++;
/*
printf(" >>>>>>  k++ j shift");
*/
										} else {
											if (i > M) {
												kbest--;
/*
printf(" <<<<<<  k-- i shift");
*/
											}
										}
									}

							}
/*
printf("\n");
*/

						} else {
							R(d, k) = -2;
							if (Rvisitmin[d] == k) Rvisitmin[d]++;
							if (Rvisitmax[d] >= k) Rvisitmax[d] = k-1;
						}
					}
					T[d] = Tp;

					L = Rvisitmin[d];
					U = Rvisitmax[d];
					for (k=Rvisitmax[d]; k>=Rvisitmin[d]; k--) if (R(d, k) == (N+k)) break;
					if (k<Rvisitmin[d]) k = INT_MIN;
					L = __max(L, k+1);
					for (k=Rvisitmin[d]; k<=Rvisitmax[d]; k++) if (R(d, k) == M) break;
					if (k>Rvisitmax[d]) k = INT_MAX;
					U = __min(U, k-1);
				} while (L <= U+2);
			}

			// If the two PrimaryLabels at the function's address don't match, decrement match by 1*mat.
			//		This helps if there are two are more functions that the user has labeled that
			//		are identical except for the labels:
			if (pFile1->GetPrimaryLabel(pFunction1->GetMainAddress()).CompareNoCase(
					pFile2->GetPrimaryLabel(pFunction2->GetMainAddress())) != 0) Tp = __max(0, Tp - mat);

			// Normalize it:
			nRetVal = Tp/(__max(M,N)*mat);

			// Build Edit Script:
			if (bBuildEditScript) {
				int last_i, last_j;
				int cur_i, cur_j;
				int k_rest;

				if (dbest > 0) {
					m_EditScript.SetSize(dbest);
					k = kbest;
					last_i = M+1;
					last_j = N+1;

/*
printf("\n%s with %s:\n", LPCTSTR(pFunction1->GetMainName()), LPCTSTR(pFunction2->GetMainName()));
*/

					for (d=dbest-1; d>=0; d--) {
						i = __max((R(d, k-1) + 1), __max((R(d, k) + 1), (R(d, k+1))));

/*
printf("(%3ld, %3ld) : %3ld(%5ld), %3ld(%5ld), %3ld(%5ld) :", d, k,
						(R(d, k-1) + 1), (int)Sp((R(d, k-1))*2-k+1, d),
						(R(d, k) + 1), (int)Sp((R(d, k))*2-k, d),
						(R(d, k+1)), (int)Sp((R(d, k+1))*2-k-1, d));

for (j=Rvisitmin[dbest-1]; j<=Rvisitmax[dbest-1]; j++) {
	if (j == k-1) printf("("); else printf(" ");
	if (R(d,j)<0) printf("   "); else printf("%3ld", R(d, j));
	if (j == k+1) printf(")"); else printf(" ");
}
printf("\n");
*/

						j = i-k;

						if (i == (R(d, k-1) + 1)) {
							strTemp.Format("%ld>%ld", i-1, j);
							cur_i = i-1;
							cur_j = j;
							k--;
							k_rest = 1;
						} else {
							if (i == (R(d, k+1))) {
								strTemp.Format("%ld<%ld", i, j-1);
								cur_i = i;
								cur_j = j-1;
								k++;
								k_rest = -1;
							} else {
								// if (i == (R(d, k) + 1))
								strTemp.Format("%ld-%ld", i-1, j-1);
								cur_i = i-1;
								cur_j = j-1;
								// k=k;
								k_rest = 0;
							}
						}
						m_EditScript.SetAt(d, strTemp);
						// The following test is needed since our insertion/deletion indexes are
						//		one greater than the stored i and/or j values from the R matrix.
						//		It is possible that the previous comparison added some extra
						//		entries to the R matrix than what was really needed.  This will
						//		cause extra erroneous entries to appear in the edit script.
						//		However, since the indexes should be always increasing, we simply
						//		filter out extra entries added to the end that don't satisfy
						//		this condition:
						if ((k_rest == 0) &&
							((cur_i == last_i) && (cur_j == last_j))) {
							m_EditScript.RemoveAt(d);
						}

						last_i = cur_i;
						last_j = cur_j;
					}
				}


				// Note: if the two are identical, array stays empty:
				m_bEditScriptValid = TRUE;
			}

			// Deallocate Memory:
			delete[] T;
			delete[] Rvisitmin;
			delete[] Rvisitmax;
			for (i=0; i<dmax; i++) delete[] (Rm[i]);
			delete[] Rm;
		}
		break;
	}

	return nRetVal;
}
示例#12
0
extern "C" _declspec(dllexport) BOOL startRprCmdTsk(CString strNT, _ConnectionPtr ptrCon, char* strCd, char* strPthOt, char* strAc, WCHAR* strNZ){

//	HINSTANCE hInstResClnt;
//	hInstResClnt = AfxGetResourceHandle();
//AfxMessageBox(_T("startRprCmdTsk"));
	AfxSetResourceHandle(::GetModuleHandle("RprCmdTsk.dll"));

//	char* sANZ;
	CStringArray strANZ;
	strANZ.SetSize(1);
	for(int n=0;n<1;n++){
		strANZ.SetAt(n,_T(""));
	}

	CString curStr,strTmp,m_strNZ;
	CString strCod,strAcc,strPathOut;

	m_strNZ    = _T("");
	strCod	   = strCd;
	strCod.TrimLeft();
	strCod.TrimRight();

	strPathOut = strPthOt;
	strPathOut.TrimLeft();
	strPathOut.TrimRight();

	strAcc     = strAc;
	strAcc.TrimLeft();
	strAcc.TrimRight();

	CString strCur,strSql,strCSls;
	CString m_strNT;
	CString m_strCR;	 		//Код грузополучателя
	CString m_strCRAdr;			//Код адреса доставки
	CString m_strCSA;	 		//Код расч.сч. продовца
	CString m_strCREm;			//Код e-mail

//	bPrint =false;
//CCmdTarget c;
//c.BeginWaitCursor();

	_variant_t m_vNULL;
	_RecordsetPtr ptrRs1;
	_CommandPtr ptrCmd1;
	_ConnectionPtr ptrCnn;

	COleVariant vC;
	CBlokRtf m_Blk;
	CWords m_W;

	ptrCnn    = ptrCon;	//Соединение

	CRecSetProc* pR=NULL;
	CString m_strNum,m_strDate,m_strDecDate,sEnd,strCopy;
	CString s,sPrv,m_strNumDec,strSls;

	CString m_strWe1,m_strWe2,m_strInd,m_strOKOHX,m_strOKOH;
	CString m_strVnd,m_strIndVnd,m_strOKOHXV,m_strOKOHV;

//	CString m_strBN;
//	char* m_bsConn;

	int k=0;							//Число складов для наряд заданий
	bool m_bBN;
	int iFind,iNum,i;
										//  № нак
	iFind=strCod.Find('~');
	m_strNum  = strCod.Left(iFind);
	m_strNumDec = m_strNum;
										//  дата
	iNum = strCod.Find('~',iFind+1);
	m_strDecDate = strCod.Mid(iFind+1,iNum-iFind-1);
	iFind = iNum;
										//  код продовца
	iNum = strCod.Find('~',iFind+1);
	strSls = strCod.Mid(iFind+1,iNum-iFind-1);
	iFind = iNum;
		
	iFind   = strCod.ReverseFind('~');
	m_strDate = strCod.Mid(iFind+1);

	m_strNT  = strNT;

// Имена исходящих файлов
	CString strFlNmCmdTsk;
	CString strPath;
	
	strPath =  _T(""); //_T("D:\\MyProjects\\Strg\\Debug\\"); 
	s = m_strDate;
	s.Remove('-');

//AfxMessageBox(strAcc);
	iFind=strAcc.Find('~');				// код грузополучателя
	m_strCR  = strAcc.Left(iFind);

	iNum = strAcc.Find('~',iFind+1);	// Код адреса доставки
	m_strCRAdr = strAcc.Mid(iFind+1,iNum-iFind-1);
	iFind = iNum;

	iNum = strAcc.Find('~',iFind+1);	// Код расч.сч. продовца
	m_strCSA = strAcc.Mid(iFind+1,iNum-iFind-1);
	iFind = iNum;

	iFind   = strAcc.ReverseFind('~');	// Код e-mail
	m_strCREm = strAcc.Mid(iFind+1);

// Входящие шаблоны
	CStdioFile inCmdTsk;  //Наряд-Задание
// Исходящий файл
	CStdioFile otCmdTsk;

	const int iMAX = 1024;
	const int iMIN = 512;

	m_vNULL.vt = VT_ERROR;
	m_vNULL.scode = DISP_E_PARAMNOTFOUND;

	ptrCmd1 = NULL;
	ptrRs1 = NULL;

	ptrCmd1.CreateInstance(__uuidof(Command));
	ptrCmd1->ActiveConnection = ptrCnn;
	ptrCmd1->CommandType = adCmdText;

	ptrRs1.CreateInstance(__uuidof(Recordset));
	ptrRs1->CursorLocation = adUseClient;
	ptrRs1->PutRefSource(ptrCmd1);

	CStringArray aHd;

	int iRpl = 6;	//  строки которые будут меняться (на 1 больше)
	aHd.SetSize(iRpl);
	for(i=0;i<iRpl;i++){
		aHd.SetAt(i,_T(""));
	}

	strCur = m_strNum + _T(",'");
	strCur+= m_strDate + _T("'");

	aHd.SetAt(1,m_strNumDec+_T("      ")+m_strDecDate);

	strSql = _T("RT24NCmdTsk  ");
	strSql+=strCur;
//AfxMessageBox(strSql);

	ptrCmd1->CommandText = (_bstr_t)strSql;
	try{
		if(ptrRs1->State==adStateOpen) ptrRs1->Close();
		ptrRs1->Open(m_vNULL,m_vNULL,adOpenDynamic,adLockOptimistic,adCmdText);

		if(!pR->IsEmptyRec(ptrRs1)){
			i=4;	//Основание
			vC=pR->GetValueRec(ptrRs1,i);
			vC.ChangeType(VT_BSTR);
			s = vC.bstrVal;

			aHd.SetAt(4,s);				// Основание
//AfxMessageBox(s);
			i = 9;
			vC = pR->GetValueRec(ptrRs1,i);
			vC.ChangeType(VT_BSTR);
			s = vC.bstrVal;

			aHd.SetAt(3,s);		// Покупатель


//			bsCmd = _T("RT38 ");	//Они
//			bsCmd+= (_bstr_t)s + _T(",2");
//AfxMessageBox(bsCmd);
//			if(rsWe->State==adStateOpen) rsWe->Close();
//
//			rsWe->Open(bsCmd,cn->ConnectionString,adOpenKeyset,adLockReadOnly,adCmdText);//adCmdStoredProc
//			if(!pR->IsEmptyRec(rsWe)){

				CString strAdr;

				int Num =ptrRs1->GetRecordCount();

				typedef CArray<int,int&> aRec; //Сколько записей
												 //по складу
				ptrRs1->MoveFirst();	
				vC = pR->GetValueRec(ptrRs1,5); // № Склада
				vC.ChangeType(VT_BSTR);
				sPrv = vC.bstrVal;

				aRec aRecSt;
				int r=1;
				aRecSt.Add(r);
				s=_T("");
				for(i=2;i<=Num;i++){
					ptrRs1->MoveNext();
					vC = pR->GetValueRec(ptrRs1,5); 
					vC.ChangeType(VT_BSTR);
					s = vC.bstrVal;
					if(sPrv!=s){
						k++;
						r=1;
						aRecSt.Add(r);
						sPrv=s;
					}
					else{
						r++;
						aRecSt.SetAt(k,r);
//						s.Format("k = %i, r = %i",k,r);
//AfxMessageBox(s);
					}
				}
				k = aRecSt.GetSize();
//s.Format("k = %i",k);
//AfxMessageBox(s);
				i=0;
				ptrRs1->MoveFirst();

				while(i<k){
					CString strNum=_T("");
					CString strStg = _T("");
					vC = pR->GetValueRec(ptrRs1,5); // № Склада
					vC.ChangeType(VT_BSTR);
					strStg = vC.bstrVal;
					aHd.SetAt(2,strStg);
//********************************* Работа с файлами
					int curPos = 0;
					CString strBuf = _T("");
					s = m_strDate;
					s.Remove('-');

					strFlNmCmdTsk = strPathOut;
					strFlNmCmdTsk+=	_T("НЗ_");
					strFlNmCmdTsk+= m_strNumDec + _T("_");
					strFlNmCmdTsk+=	s + _T("_");
					strFlNmCmdTsk+= strStg + _T(".rtf");
					if(strANZ.GetAt(0)==_T("")){
						strANZ.SetAt(0,strFlNmCmdTsk);
					}
					else{
						strANZ.Add(strFlNmCmdTsk);
					}
//AfxMessageBox((LPCTSTR)strNZ.GetAt(i));

					try{
//						strFlNmCmdTsk+= s + _T(".rtf");
//AfxMessageBox(strFlNmCmdTsk);
						otCmdTsk.Open(strFlNmCmdTsk,CFile::modeCreate|CFile::modeReadWrite|CFile::typeText);

						s = strPath + _T("CmdTsk.rtf");
						inCmdTsk.Open(s,CFile::modeRead|CFile::shareDenyNone);
//AfxMessageBox(s);
						CString strBuf=_T("");
						CString strRpl=_T("");
						int j=1;
						CString strFnd;
						bool theEnd=true;
//---------------------------Заполняю Шаку
						strFnd.Format("~%i~",j);
						while(theEnd){ 
							inCmdTsk.ReadString(strBuf);
//s=strBuf;
							strFnd.Format("~%i~",j);
							m_Blk.SetRplStrR(strBuf,strFnd,j,aHd);
							curPos = inCmdTsk.GetPosition();

//AfxMessageBox("ВХОД = "+s+'\n'+'\n'+"ВЫХОД = "+strBuf+'\n'+'\n'+strFnd);
							otCmdTsk.WriteString(strBuf);
							if(j==5){
								theEnd = false;
							}
						}
//------------------------------------ Конец Шапки
						//{\cell }

						m_Blk.GetStdPWt(strBuf,inCmdTsk,otCmdTsk, _T("{\\cell }"),curPos);
//						m_Blk.Control(inCmdTsk,300);

						CString strSrc=_T("");

						m_Blk.GetStdPWS(strBuf,inCmdTsk,otCmdTsk, _T("\\pard \\ql"),curPos,strSrc);
						curPos++;
						inCmdTsk.Seek(curPos,CFile::begin);
						strSrc+=_T("\\");
						m_Blk.GetStdPWS(strBuf,inCmdTsk,otCmdTsk, _T("\\pard \\ql"),curPos,strSrc);
//		s.Format("Поиск strSrc После  GetStdPWS curPos = %i",curPos);
//AfxMessageBox(s+'\n'+"strSrc = "+strSrc);
//		m_Blk.Control(inCmdTsk,100);

						CString strPst=_T("");

						m_Blk.GetStdPWS(strBuf,inCmdTsk,otCmdTsk, _T("\\trowd"),curPos,strPst);
						curPos++;
						inCmdTsk.Seek(curPos,CFile::begin);
						strPst+=_T("\\");
						m_Blk.GetStdPWS(strBuf,inCmdTsk,otCmdTsk, _T("\\trowd"),curPos,strPst);
//		s.Format("Поиск strPst После  GetStdPWS curPos = %i",curPos);
//AfxMessageBox(s+'\n'+"strPst = "+strPst);
//		m_Blk.Control(inCmdTsk,100);
//		s.Format("i =%i",aRecSt.GetAt(i));
//AfxMessageBox(s);
						int i5=0;
						CString strNew=_T("");
						for(int x=1;x<=aRecSt.GetAt(i);x++){
							strNew = pR->OnFillRow(ptrRs1,strSrc,5,x,i5);
//AfxMessageBox(_T("strSrc = ")+'\n'+strSrc+'\n'+_T("strNew = ")+'\n'+strNew);
							otCmdTsk.WriteString(strNew);
							otCmdTsk.WriteString(strPst);
							ptrRs1->MoveNext();
//							s.Format("x = %i",x);
//AfxMessageBox(s);
						}

						m_Blk.GetStdPWt(strBuf,inCmdTsk,otCmdTsk, _T("\\cell }\\pard"),curPos);
//						m_Blk.Control(inCmdTsk,300);

						CString strSrc2=_T("");
						m_Blk.GetStdPWS(strBuf,inCmdTsk,otCmdTsk, _T("\\pard \\ql"),curPos,strSrc2);
//						s.Format("Поиск strSrc2 После  GetStdPWS curPos = %i",curPos);
//				AfxMessageBox(s+'\n'+"strSrc2 = "+strSrc2);
//						m_Blk.Control(inCmdTsk,100);

						CString strNew2=_T("");
						strNew2 = pR->OnFillTtl(strSrc2,i5,1);
//				AfxMessageBox("strNew2 = "+'\n'+strNew2);
						otCmdTsk.WriteString(strNew2);

						s = m_W.GetWords(i5,false,false,true);
						aHd.SetAt(5,s);  // Общее кол-во

//						while(inCmdTsk.ReadString(strBuf)){ 
//							otCmdTsk.WriteString(strBuf);
//						}

						while(inCmdTsk.ReadString(strBuf)){ 

				//			s= strBuf;
							strFnd.Format("~%i~",j);
							m_Blk.SetRplStrR(strBuf,strFnd,j,aHd);
				//AfxMessageBox("ВХОД = "+s+'\n'+'\n'+"ВЫХОД = "+strBuf+'\n'+'\n'+strFnd);
							otCmdTsk.WriteString(strBuf);
						}
					otCmdTsk.Close();


					}
					catch(CFileException* fx){
						TCHAR buf[255];
						fx->GetErrorMessage(buf,255);
				//		AfxMessageBox(buf);
						fx->Delete();
					}

					i++;
					inCmdTsk.Close();
//s.Format("i = %i",i);
//AfxMessageBox(s);
//				}
			}
/*AfxMessageBox(_T("Begin"));
for(int c=0;c<strNZ.GetSize();c++){
	s.Format(_T("c=%i Size = %i"),c,strNZ.GetSize());
	AfxMessageBox(s);
		AfxMessageBox((LPCTSTR)strNZ.GetAt(c));
	AfxMessageBox(s);
}
AfxMessageBox(_T("End"));*/
		}
	}
	catch(_com_error& e){
		AfxMessageBox(e.ErrorMessage());
		if(ptrRs1->State == adStateOpen) ptrRs1->Close();
		ptrRs1 = NULL;
	}

//c.EndWaitCursor();
//	AfxSetResourceHandle(hInstResClnt);

	if(ptrRs1->State == adStateOpen) ptrRs1->Close();
	ptrRs1 = NULL;
	i = 0;
	while(i<k){
		if(i==0){
			m_strNZ =strANZ.GetAt(i);
		}
		else{
			m_strNZ+= _T("~")+strANZ.GetAt(i);
		}
		i++;
	}
//AfxMessageBox(m_strNZ);
//strNZ = m_strNZ.GetBufferSetLength(m_strNZ.GetLength());
	int lw;
	lw = MultiByteToWideChar(CP_ACP,0,m_strNZ,-1,NULL,0);
//	s.Format(_T("lw = %i"),lw);
//	AfxMessageBox(s);
	WCHAR* strW = new WCHAR[lw];
	MultiByteToWideChar(CP_ACP,0,m_strNZ,-1,strW,lw);
//	strNZ = m_strNZ;
	wcscpy_s(strNZ,lw,strW);
//	strNZ=strW;
//AfxMessageBox("exit from RprCmdTs");
//AfxMessageBox(strNZ);
	delete strW;
	return TRUE;
}
示例#13
0
文件: RprBill.cpp 项目: 03bekjob/Strg
extern "C" _declspec(dllexport) BOOL startRprBill(CString strNT, _ConnectionPtr ptrCon, char* strCd, char* strPthOt, char* strAc, WCHAR* strWDoc){
//	HINSTANCE hInstResClnt;

	//hInstResClnt = AfxGetResourceHandle();
	AfxSetResourceHandle(::GetModuleHandle("RprBill.dll"));
	CString curStr,strTmp;
	CString strCod,strAcc,strPathOut;

	strCod	   = strCd;
	strCod.TrimLeft();
	strCod.TrimRight();

	strPathOut = strPthOt;
	strPathOut.TrimLeft();
	strPathOut.TrimRight();

	strAcc     = strAc;
	strAcc.TrimLeft();
	strAcc.TrimRight();

/*AfxMessageBox(strCod);
AfxMessageBox(strPathOut);
AfxMessageBox(strAcc);

return FALSE;
*/
	CString strCur,strSql,strCSls;
	CString m_strNT;
	CString m_strCR;	 		//Код грузополучателя
	CString m_strCRAdr;			//Код адреса доставки
	CString m_strCSA;	 		//Код расч.сч. продовца
	CString m_strCREm;			//Код e-mail

	_variant_t m_vNULL;
	_RecordsetPtr ptrRs1,ptrRs2,ptrRs3,ptrRs4;
	_CommandPtr ptrCmd1,ptrCmd2,ptrCmd3,ptrCmd4;
	_ConnectionPtr ptrCnn;

	COleVariant vC;
	CBlokRtf m_Blk;
	CWords m_W;
//	CCnvrt16 m_Ch16;

//CCmdTargetPrn c;
//c.BeginWaitCursor();
	ptrCnn    = ptrCon;	//Соединение

	CRecSetProc* pR=new CRecSetProc;
	CString m_strNum,m_strDate,m_strDecDate,s,sEnd,strCopy;
	CString m_strNumDec,strSls,strO;

	CString m_strWe1,m_strWe2,m_strInd,m_strOKOHX,m_strOKOH;
	CString m_strVnd,m_strIndVnd,m_strOKOHXV,m_strOKOHV,strCst,m_strCnsgr;

//	char* m_bsConn;
	bool m_bBN;
	int iFind,iNum,i;
										//  № нак
	iFind=strCod.Find('~');
	m_strNum  = strCod.Left(iFind);
	m_strNumDec = m_strNum;
										//  дата
	iNum = strCod.Find('~',iFind+1);
	m_strDecDate = strCod.Mid(iFind+1,iNum-iFind-1);
	iFind = iNum;
										//  код продовца
	iNum = strCod.Find('~',iFind+1);
	strSls = strCod.Mid(iFind+1,iNum-iFind-1);
	iFind = iNum;
		
	iFind   = strCod.ReverseFind('~');
	m_strDate = strCod.Mid(iFind+1);

	m_strNT  = strNT;
//	m_bsConn = bsConn;

//AfxMessageBox(strAcc);
	iFind=strAcc.Find('~');				// код грузополучателя
	m_strCR  = strAcc.Left(iFind);

	iNum = strAcc.Find('~',iFind+1);	// Код адреса доставки
	m_strCRAdr = strAcc.Mid(iFind+1,iNum-iFind-1);
	iFind = iNum;

	iNum = strAcc.Find('~',iFind+1);	// Код расч.сч. продовца
	m_strCSA = strAcc.Mid(iFind+1,iNum-iFind-1);
	iFind = iNum;

	iFind   = strAcc.ReverseFind('~');	// Код e-mail
	m_strCREm = strAcc.Mid(iFind+1);
	
	CString strFlNmBill;
	CString strPath;

	strPath =  _T("");  //_T("D:\\MyProjects\\Strg\\Debug\\");
	s = m_strDate;//
	s.Remove('-');

	strFlNmBill = strPathOut;
	strFlNmBill+=	_T("СЧ_");
	strFlNmBill+= m_strNum + _T("_");
	strFlNmBill+= s + _T(".rtf");

	int lw;
	lw = MultiByteToWideChar(CP_ACP,0,strFlNmBill,-1,NULL,0);
//	s.Format(_T("lw = %i"),lw);
//	AfxMessageBox(s);
	WCHAR* strW = new WCHAR[lw];
	MultiByteToWideChar(CP_ACP,0,strFlNmBill,-1,strW,lw);
//	strNZ = m_strNZ;
	wcscpy_s(strWDoc,lw,strW);
//	strNZ=strW;
//AfxMessageBox("exit from RprCmdTs");
//AfxMessageBox(strNZ);
	delete strW;

//	strDoc = strFlNmBill;

	m_vNULL.vt = VT_ERROR;
	m_vNULL.scode = DISP_E_PARAMNOTFOUND;

	ptrCmd4 = NULL;
	ptrRs4 = NULL;

	ptrCmd4.CreateInstance(__uuidof(Command));
	ptrCmd4->ActiveConnection = ptrCnn;
	ptrCmd4->CommandType = adCmdText;

	ptrRs4.CreateInstance(__uuidof(Recordset));
	ptrRs4->CursorLocation = adUseClient;
	ptrRs4->PutRefSource(ptrCmd4);

	ptrCmd3 = NULL;
	ptrRs3 = NULL;

	ptrCmd3.CreateInstance(__uuidof(Command));
	ptrCmd3->ActiveConnection = ptrCnn;
	ptrCmd3->CommandType = adCmdText;

	ptrRs3.CreateInstance(__uuidof(Recordset));
	ptrRs3->CursorLocation = adUseClient;
	ptrRs3->PutRefSource(ptrCmd3);

	ptrCmd2 = NULL;
	ptrRs2 = NULL;

	ptrCmd2.CreateInstance(__uuidof(Command));
	ptrCmd2->ActiveConnection = ptrCnn;
	ptrCmd2->CommandType = adCmdText;

	ptrRs2.CreateInstance(__uuidof(Recordset));
	ptrRs2->CursorLocation = adUseClient;
	ptrRs2->PutRefSource(ptrCmd2);

	ptrCmd1 = NULL;
	ptrRs1 = NULL;

	ptrCmd1.CreateInstance(__uuidof(Command));
	ptrCmd1->ActiveConnection = ptrCnn;
	ptrCmd1->CommandType = adCmdText;

	ptrRs1.CreateInstance(__uuidof(Recordset));
	ptrRs1->CursorLocation = adUseClient;
	ptrRs1->PutRefSource(ptrCmd1);

// Входящие шаблоны
	CStdioFile inBill;  // Счёт
// Исходящий файл
	CStdioFile otBill;

	strCur = m_strNum + _T(",'");
	strCur+= m_strDate + _T("'");

	strSql = _T("RT24NBill ");	//RT24Bill
	strSql+= strCur;

//AfxMessageBox(strSql );
//AfxMessageBox(strAcc);
	ptrCmd1->CommandText = (_bstr_t)strSql;
	try{
		if(ptrRs1->State==adStateOpen) ptrRs1->Close();
		ptrRs1->Open(m_vNULL,m_vNULL,adOpenDynamic,adLockOptimistic,adCmdText);
		if(!pR->IsEmptyRec(ptrRs1))	{

			i = 9;		//Код продовца
			vC=pR->GetValueRec(ptrRs1,i);
			vC.ChangeType(VT_BSTR);
			strSls = vC.bstrVal;
			strSls.TrimLeft();
			strSls.TrimRight();

			i = 8;		//Код покупателя
			vC=pR->GetValueRec(ptrRs1,i);
			vC.ChangeType(VT_BSTR);
			strCst = vC.bstrVal;
			strCst.TrimLeft();
			strCst.TrimRight();
		}
	}
	catch(_com_error& e){
		AfxMessageBox(e.ErrorMessage());
		if(ptrRs1->State==adStateOpen) ptrRs1->Close();
		ptrRs1=NULL;
		if(ptrRs2->State==adStateOpen) ptrRs2->Close();
		ptrRs2=NULL;
		if(ptrRs3->State==adStateOpen) ptrRs3->Close();
		ptrRs3=NULL;
		if(ptrRs4->State==adStateOpen) ptrRs4->Close();
		ptrRs4=NULL;
		return FALSE;
	}

	CStringArray aHd;
	int iRpl = 25;	//  строки которые будут меняться (на 1 больше)
	aHd.SetSize(iRpl);
	for(i=0;i<iRpl;i++){
		aHd.SetAt(i,_T(""));
	}
	CString m_strSls;
/*----------------------------- ПРОДАВЕЦ-----------------------*/
/*	bsCmd = _T("RT38Sls "); 
	bsCmd+= (_bstr_t)strSls +_T(",");
	bsCmd+= _T("2,");		// Юридический адрес
	bsCmd+= (_bstr_t)strAcc;
*/
	strSql = _T("RT38Sls_1 ");		//Мы RT38Sls
	strSql+= strSls + _T(",2,");	//Юр адрес - 2
	strSql+= m_strCSA;				//Код расч.сч. продовца

	ptrCmd2->CommandText = (_bstr_t)strSql;
//AfxMessageBox(strSql);
	try{
		//---------------------------------------Про Продовца
		if(ptrRs2->State==adStateOpen) ptrRs2->Close();
		ptrRs2->Open(m_vNULL,m_vNULL,adOpenDynamic,adLockOptimistic,adCmdText);
		if(!pR->IsEmptyRec(ptrRs2))	{
			i=1;
			vC=pR->GetValueRec(ptrRs2,i);
			vC.ChangeType(VT_BSTR);
			m_strSls = vC.bstrVal;
			m_strSls.TrimLeft();
			m_strSls.TrimRight();
			m_strSls+= _T(" ");

			i=2;
			vC=pR->GetValueRec(ptrRs2,i);
			vC.ChangeType(VT_BSTR);
			s = vC.bstrVal;
			s.TrimLeft();
			s.TrimRight();
			m_strSls+= s;

			aHd.SetAt(1,m_strSls);	// Наименование

			i=3;					//Индекс
			vC=pR->GetValueRec(ptrRs2,i);
			vC.ChangeType(VT_BSTR);
			m_strSls = vC.bstrVal;
			m_strSls.TrimLeft();
			m_strSls.TrimRight();
			m_strSls+= _T(",");

			i=4;					//Адрес юридический
			vC=pR->GetValueRec(ptrRs2,i);
			vC.ChangeType(VT_BSTR);
			s = vC.bstrVal;
			s.TrimLeft();
			s.TrimRight();
			m_strSls+=s + _T(", ");		

			i=5;					// тел
			vC=pR->GetValueRec(ptrRs2,i);
			vC.ChangeType(VT_BSTR);
			s = vC.bstrVal;
			s.TrimLeft();
			s.TrimRight();
//			m_strSls+=_T("тел.: ") + s;		
			m_strSls+= s;

			aHd.SetAt(2,m_strSls);	// Адрес,тел

			i=8;
			vC=pR->GetValueRec(ptrRs2,i);
			vC.ChangeType(VT_BSTR);
			s = vC.bstrVal;
			s.TrimLeft();
			s.TrimRight();
//			m_strSls=_T("ИНН/КПП ");
			m_strSls+= s;
			aHd.SetAt(3,m_strSls);	// ИНН/КПП

			aHd.SetAt(4,aHd.GetAt(1));
			
			i=6;					// Расч. счёт
			vC=pR->GetValueRec(ptrRs2,i);
			vC.ChangeType(VT_BSTR);
			m_strSls = vC.bstrVal;
			m_strSls.TrimLeft();
			m_strSls.TrimRight();
			aHd.SetAt(5,m_strSls);	

			i=7;					//Банк
			vC=pR->GetValueRec(ptrRs2,i);
			vC.ChangeType(VT_BSTR);
			m_strSls = vC.bstrVal;
			m_strSls.TrimLeft();
			m_strSls.TrimRight();
			aHd.SetAt(8,m_strSls);	// Банк

			i=11;					//БИК
			vC=pR->GetValueRec(ptrRs2,i);
			vC.ChangeType(VT_BSTR);
			m_strSls = vC.bstrVal;
			m_strSls.TrimLeft();
			m_strSls.TrimRight();
			aHd.SetAt(9,m_strSls);	// БИК

			i=12;					// Кор.счёт
			vC=pR->GetValueRec(ptrRs2,i);
			vC.ChangeType(VT_BSTR);
			m_strSls = vC.bstrVal;
			m_strSls.TrimLeft();
			m_strSls.TrimRight();
			aHd.SetAt(11,m_strSls);	// Кор.счёт
		}
	}
	catch(_com_error& e){
		AfxMessageBox(e.ErrorMessage());
		if(ptrRs1->State==adStateOpen) ptrRs1->Close();
		ptrRs1=NULL;
		if(ptrRs2->State==adStateOpen) ptrRs2->Close();
		ptrRs2=NULL;
		if(ptrRs3->State==adStateOpen) ptrRs3->Close();
		ptrRs3=NULL;
		if(ptrRs4->State==adStateOpen) ptrRs4->Close();
		ptrRs4=NULL;
		return FALSE;
	}
	ptrRs2->Close();
/*--------------------------- ПОКУПАТЕЛЬ-----------------------*/
	CString m_strCst;
/*	bsCmd = _T("RT38Cst "); 
	bsCmd+= (_bstr_t)strCst +_T(",");
	bsCmd+= _T("2,");		// Юридический адрес
	bsCmd+= _T("1");		// Только Наименование
*/
	strSql = _T("RT38Cst_1 ");	//Они
	strSql+= strCst + _T(",2,");
	strSql+= _T("0");

//AfxMessageBox(strSql);
	ptrCmd3->CommandText = (_bstr_t)strSql;

	try{
		if(ptrRs3->State==adStateOpen) ptrRs3->Close();
//AfxMessageBox(strSql);
		ptrRs3->Open(m_vNULL,m_vNULL,adOpenDynamic,adLockOptimistic,adCmdText);
		if(!pR->IsEmptyRec(ptrRs3)){
			i=1;
			vC=pR->GetValueRec(ptrRs3,i);
			vC.ChangeType(VT_BSTR);
			m_strCst = vC.bstrVal;
			m_strCst+= _T(" ");

			i=2;
			vC=pR->GetValueRec(ptrRs3,i);
			vC.ChangeType(VT_BSTR);
			s = vC.bstrVal;
			m_strCst+= s;

			aHd.SetAt(15,m_strCst);	// Плательщик
		}
	}
	catch(_com_error& e){
		AfxMessageBox(e.ErrorMessage());
		if(ptrRs1->State==adStateOpen) ptrRs1->Close();
		ptrRs1=NULL;
		if(ptrRs2->State==adStateOpen) ptrRs2->Close();
		ptrRs2=NULL;
		if(ptrRs3->State==adStateOpen) ptrRs3->Close();
		ptrRs3=NULL;
		if(ptrRs4->State==adStateOpen) ptrRs4->Close();
		ptrRs4=NULL;
		return FALSE;
	}
//------------------------------------- про Грузополучателей
		strSql = _T("RT38Cnsgr ");		
		strSql+= m_strCR   + _T(",");	//Код грузополучателя
		strSql+= m_strCRAdr+ _T(",");	//Код адреса доставки
		strSql+= _T("1");				//не полная инф

//AfxMessageBox(strSql);
		ptrCmd4->CommandText = (_bstr_t)strSql;

		try{
			if(ptrRs4->State==adStateOpen) ptrRs4->Close();
			ptrRs4->Open(m_vNULL,m_vNULL,adOpenDynamic,adLockOptimistic,adCmdText);
			if(!pR->IsEmptyRec(ptrRs4)){

					i=1;	//Вид собственности
					vC=pR->GetValueRec(ptrRs4,i);
					vC.ChangeType(VT_BSTR);
					s = vC.bstrVal;
					s.TrimLeft();
					s.TrimRight();
					m_strCnsgr+= s +_T(" ");

					i=2;	//Наименование
					vC=pR->GetValueRec(ptrRs4,i);
					vC.ChangeType(VT_BSTR);
					s = vC.bstrVal;
					s.TrimLeft();
					s.TrimRight();
					m_strCnsgr+= s;

					aHd.SetAt(16,m_strCnsgr);	// Грузополучатель
//AfxMessageBox(m_strCnsgr);
			}
		}
		catch(_com_error& e){
			AfxMessageBox(e.ErrorMessage());
			if(ptrRs1->State==adStateOpen) ptrRs1->Close();
			ptrRs1=NULL;
			if(ptrRs2->State==adStateOpen) ptrRs2->Close();
			ptrRs2=NULL;
			if(ptrRs3->State==adStateOpen) ptrRs3->Close();
			ptrRs3=NULL;
			if(ptrRs4->State==adStateOpen) ptrRs4->Close();
			ptrRs4=NULL;
			return FALSE;
		}

	aHd.SetAt(12,m_strNum);			// №
	CString sD,sMY,sDMY;
	sD = m_strDecDate.Left(m_strDecDate.Find(_T(".")));
	sD = _T("\" ")+sD;
	sD+= _T(" \"");

	aHd.SetAt(13,sD);

	sDMY= m_W.GetWrdMnth(m_strDecDate,1,true);
	sMY = sDMY.Mid(sDMY.Find(" "));
	aHd.SetAt(14,sMY);
	aHd.SetAt(23,_T("Головина О.В."));	//Фильцов Д.Н.
	aHd.SetAt(24,_T("Радостева М.С."));	//Ермакова Е.В.

//************************* Работа с файлами
	int curPos = 0;
	CString strBuf = _T("");
	try{
		s = strPath + _T("Bill.rtf");
		otBill.Open(strFlNmBill,CFile::modeCreate|CFile::modeReadWrite|CFile::typeText);
		inBill.Open(s,CFile::modeRead|CFile::shareDenyNone);

		CString strBuf=_T("");
		CString strRpl=_T("");
		int j=1;
		CString strFnd;
		bool theEnd=true;
//---------------------------заполняю Шапку
		strFnd.Format("~%i~",j);
		while(theEnd){ 
			inBill.ReadString(strBuf);

//			s=strBuf;

			strFnd.Format("~%i~",j);
			m_Blk.SetRplStrR(strBuf,strFnd,j,aHd);
			curPos = inBill.GetPosition();

//AfxMessageBox("ВХОД = "+s+'\n'+'\n'+"ВЫХОД = "+strBuf+'\n'+'\n'+strFnd);
			otBill.WriteString(strBuf);
			if(j==17){
				theEnd = false;
//				AfxMessageBox("ok");
			}
		}
//		m_Blk.Control(inBill,300);

		m_Blk.GetStdPWt(strBuf,inBill,otBill, _T("\\row }\\trowd"),curPos);
//		m_Blk.Control(inBill,300);
		m_Blk.GetStdPWt(strBuf,inBill,otBill, _T("{1\\cell "),curPos);
//		m_Blk.Control(inBill,300);
		m_Blk.GetStdPWt(strBuf,inBill,otBill, _T("\\pard \\qc "),curPos);
//		m_Blk.Control(inBill,300);

		CString strSrc=_T("");

		m_Blk.GetStdPWS(strBuf,inBill,otBill, _T("\\pard \\ql"),curPos,strSrc);
//		s.Format("Поиск strSrc После  GetStdPWS curPos = %i",curPos);
//AfxMessageBox(s+'\n'+"strSrc = "+strSrc);
//		m_Blk.Control(inBill,300);

		CString strPst=_T("");

		m_Blk.GetStdPWS(strBuf,inBill,otBill, _T("\\trowd"),curPos,strPst);
		curPos++;
		inBill.Seek(curPos,CFile::begin);
		strPst+=_T("\\");
		m_Blk.GetStdPWS(strBuf,inBill,otBill, _T("\\trowd"),curPos,strPst);
//		s.Format("Поиск strPst После  GetStdPWS curPos = %i",curPos);
//AfxMessageBox(s+'\n'+"strPst = "+strPst);
//		m_Blk.Control(inBill,300);

		CString strNew;
		long Num = ptrRs1->GetRecordCount();
//		s = m_W.GetWords(Num,false,false,true);
		s.Format("%i",Num);
		s.TrimRight();
		aHd.SetAt(20,s);  // Порядковых номеров
//AfxMessageBox(s);
		double d17,d18,d19,dT;
		d17=d18=d19=dT=0;
		for(int x=1;x<=Num;x++){
//			otInvOrd.WriteString(strPrv);
//AfxMessageBox(strSrc);
			strNew = pR->OnFillRow(ptrRs1,strSrc,6,x, d17, d18, d19);
//AfxMessageBox(strNew);
			vC = pR->GetValueRec(ptrRs1,5);
			vC.ChangeType(VT_R8);
			dT = vC.dblVal;
			d18 +=dT;

			vC = pR->GetValueRec(ptrRs1,6);
			vC.ChangeType(VT_R8);
			dT = vC.dblVal;
			d19 +=dT;
			otBill.WriteString(strNew);
			otBill.WriteString(strPst);
			ptrRs1->MoveNext();
		}

		s.Format("%16.4f",d17);
		s.TrimRight();
		s.TrimLeft();
		aHd.SetAt(17,s);  // Итого

		s.Format("%16.4f",d18);
		s.TrimRight();
		s.TrimLeft();
		aHd.SetAt(18,s);  // Итого НДС

		s.Format("%16.2f",d19);
		s.TrimRight();
		s.TrimLeft();
		aHd.SetAt(19,s);  // Всего к оплате
		aHd.SetAt(21,s);  // на сумму

		s = m_W.GetWords(d19,true,true,true);
		aHd.SetAt(22,s);  // на сумму прописью
		

		while(inBill.ReadString(strBuf)){ 

//			s= strBuf;
			strFnd.Format("~%i~",j);
			m_Blk.SetRplStrR(strBuf,strFnd,j,aHd);
//AfxMessageBox("ВХОД = "+s+'\n'+'\n'+"ВЫХОД = "+strBuf+'\n'+'\n'+strFnd);
			otBill.WriteString(strBuf);
		}
		inBill.Close();
		otBill.Close();
	}
	catch(CFileException* fx){
		TCHAR buf[255];
		fx->GetErrorMessage(buf,255);
//		AfxMessageBox(buf);
		fx->Delete();
	}

	delete pR;
//c.EndWaitCursor();
//	AfxSetResourceHandle(hInstResClnt);
	if(ptrRs1->State==adStateOpen) ptrRs1->Close();
	ptrRs1=NULL;
	if(ptrRs2->State==adStateOpen) ptrRs2->Close();
	ptrRs2=NULL;
	if(ptrRs3->State==adStateOpen) ptrRs3->Close();
	ptrRs3=NULL;
	if(ptrRs4->State==adStateOpen) ptrRs4->Close();
	ptrRs4=NULL;
	return TRUE;
}
示例#14
0
// 版本转换
BOOL CCheckRuleXMLParse::RuleConvertor(int nRuleType, const CString &strRuleContent, CStringArray& arrRuleContent)
{
	if (strRuleContent.IsEmpty())
		return FALSE;

	int nIndex = -1;
	CString strTemp;
	switch (nRuleType)
	{
	// 第1类:规则参数内部无空格,按照空格拆分
	case CRT_MDL_NAME:
	case CRT_FEA_NAME:
	case CRT_PARA:
	case CRT_TOL:
	case CRT_APPEARANCE:
	case CRT_MDL_COMMON_NAME:
	case CRT_QUALITY:
	case CRT_ASS_FAM_INSTNAME:
	case CRT_ASS_FAM_INSTPARAVALID:
	case CRT_ROUND_RAD:
	case CRT_CHAMFER_DIM:
	case CRT_HOLE_PART_EDGE_DIS:
	case CRT_DRW_SHEET_TEXT_SIZE:
	case CRT_DRW_DIM_TEXT_STYLE:
	case CRT_DRW_NOTE_TEXT_STYLE:
		CStringToCStringArray(strRuleContent, arrRuleContent);
		break;
	// 第2类:规则参数只有1个,直接赋值
	case CRT_MAT:
	case CRT_MDL_MATDENS:
	case CRT_ASS_FEA_FOR_LAST:
	case CRT_ASS_MDL_CMD:
	case CRT_CHAMFER_ANG:
	case CRT_SHELL_THICKNESS:
	case CRT_DRAFT_ANGLE:
	case CRT_DEEP_HOLE:
	case CRT_HOLE_DIS:
	case CRT_HOLE_AXIS_IN_MATERIAL:
	case CRT_LONG_AXIS:
	case CRT_AXIS_SHOULDER_ANG:
	case CRT_PART_MAX_SIZE:
	case CRT_FEA_MIN_SIZE:
	case CRT_DEEP_FILLET:
	case CRT_DRW_SHEET_SIZE:
	case CRT_DRW_SHEET_ANGLE:
	case CRT_DRW_SHEET_TEXT_FONT:
	case CRT_DRW_SHEET_SCALE:
		arrRuleContent.SetSize(1);
		arrRuleContent.SetAt(0, strRuleContent);
		break;
	// 第3类:特殊
	case CRT_UNIT:
		CStringToCStringArray(strRuleContent, arrRuleContent, L"#");
		break;
	case CRT_HOLE_DIA:
		nIndex = strRuleContent.Find(L" ");
		if (nIndex >= 0 )
		{
			strTemp = strRuleContent.Left(nIndex);
			if (!strTemp.IsEmpty())
			{
				arrRuleContent.SetSize(2);
				arrRuleContent.SetAt(0, strTemp);
				strTemp = strRuleContent.Mid(nIndex + 1);
				arrRuleContent.SetAt(1, strTemp);
			}
		}
		break;
	default:
		break;
	}
	return TRUE;
}