示例#1
0
asCScriptObject::~asCScriptObject()
{
    objType->Release();

    // The engine pointer should be available from the objectType
    asCScriptEngine *engine = objType->engine;

    // Destroy all properties
    for( asUINT n = 0; n < objType->properties.GetLength(); n++ )
    {
        asCObjectProperty *prop = objType->properties[n];
        if( prop->type.IsObject() )
        {
            // Destroy the object
            void **ptr = (void**)(((char*)this) + prop->byteOffset);
            if( *ptr )
            {
                FreeObject(*ptr, prop->type.GetObjectType(), engine);
                *(asDWORD*)ptr = 0;
            }
        }
    }
}
CK_RV PKCS11_Objects_OpenSSL::DestroyObject(Cryptoki_Session_Context* pSessionCtx, CK_OBJECT_HANDLE hObject)
{
    OBJECT_DATA* pData = GetObjectFromHandle(pSessionCtx, hObject);

    if(pData == NULL) return CKR_OBJECT_HANDLE_INVALID;

    if(--pData->RefCount <= 0)
    {
        if(pData->Type == KeyType)
        {
            PKCS11_Keys_OpenSSL::DeleteKey(pSessionCtx, (KEY_DATA *)pData->Data);
        }
        else if(pData->Type == CertificateType)
        {
            CERT_DATA* pCert = (CERT_DATA*)pData->Data;
            X509_free(pCert->cert);
        }
        
        return FreeObject(pSessionCtx, hObject) == NULL ? CKR_OBJECT_HANDLE_INVALID : CKR_OK;
    }

    return CKR_OK;
}
示例#3
0
Bool testRanges( unsigned rank, unsigned nProcs, unsigned watch ) {
    Bool		result = True;
    unsigned	nInds = 100;
    unsigned	inds[100];
    RangeSet*	set;
    unsigned	i;

    for( i = 0; i < nInds; i++ )
        inds[i] = (i/10)*10 + i;

    set = RangeSet_New();

    RangeSet_SetIndices( set, nInds, inds );
    if( rank == watch ) {
        if( set->nInds != nInds ||
                set->nRanges != nInds/10 )
        {
            result = False;
            goto done;
        }

        for( i = 0; i < nInds; i++ ) {
            if( set->ranges[i/10].begin != (i/10)*20 ||
                    set->ranges[i/10].end != (i/10)*20 + 10 ||
                    set->ranges[i/10].step != 1 )
            {
                result = False;
                goto done;
            }
        }
    }

done:
    FreeObject( set );

    return result;
}
示例#4
0
文件: clb.c 项目: mingpen/OpenNT
LRESULT
ClbWndProc(
    IN HWND hWnd,
    IN UINT message,
    IN WPARAM wParam,
    IN LPARAM lParam
    )

/*++

Routine Description:

    This function is the window procedure for the Clb custom control.

Arguments:

    Standard window procedure parameters.

Return Value:

    LRESULT - dependent on the supplied message.

--*/

{
    BOOL            Success;
    LPCLB_INFO      ClbInfo;




    if( message == WM_NCCREATE ) {

        LONG    Long;

        //
        // Save the original styles.
        //

        Long = SetWindowLong(
                        hWnd,
                        GWL_USERDATA,
                        (( LPCREATESTRUCT ) lParam )->style
                        );
        DbgAssert( Long == 0 );


        //
        // Get rid of any styles that are uninteresting to the Clb.
        //

        SetWindowLong(
                hWnd,
                GWL_STYLE,
                  (( LPCREATESTRUCT ) lParam )->style
                & CLBS_CLB
                );

        return TRUE;
    }


    if( message == WM_CREATE ) {

        //
        // Assert that there is no prior per window information associated
        // with this Clb.
        //

        DbgAssert( RestoreClbInfo( hWnd ) == NULL );

        //
        // Restore the original styles.
        //

        (( LPCREATESTRUCT ) lParam )->style = GetWindowLong(
                                                hWnd,
                                                GWL_USERDATA
                                                );


        //
        // Allocate a CLB_INFO object for this Clb and initialize the Clb
        // relevant fields.
        //

        ClbInfo = AllocateObject( CLB_INFO, 1 );
        DbgPointerAssert( ClbInfo );

        //
        // Set the number of columns to zero so that remainder of creation
        // understands the state of the Clb.
        //

        ClbInfo->Columns = 0;

        //
        // Create the header portion of the Clb.
        //

        Success = CreateHeader( hWnd, ClbInfo, ( LPCREATESTRUCT ) lParam );
        DbgAssert( Success );

        //
        // Create the list box portion of the Clb.
        //

        Success = CreateListBox( hWnd, ClbInfo, ( LPCREATESTRUCT ) lParam );
        DbgAssert( Success );

        //
        // Adjust the column number, widths based on the heading text.
        //

        Success = AdjustClbHeadings( hWnd, ClbInfo, (( LPCREATESTRUCT ) lParam )->lpszName );
        DbgAssert( Success );

        //
        // Everything was succesfully created so set the Clb's signature
        // and save it away as part of the per window data.
        //

        SetSignature( ClbInfo );

        SaveClbInfo( ClbInfo );

        return 0;
    }

    //
    // Get the ClbInfo object for this Clb and make sure that its already
    // been created i.e. WM_CREATE was already executed and thereby initialized
    // and saved a ClbInfo object.
    //

    ClbInfo = RestoreClbInfo( hWnd );

    if( ClbInfo != NULL ) {

        //
        // Validate that this really is a ClbInfo object.
        //

        DbgAssert( CheckSignature( ClbInfo ));

        switch( message ) {

        case WM_DESTROY:
            {
                //
                // Delete the font used in the list box.
                //

                Success = DeleteObject( ClbInfo->hFontListBox );
                DbgAssert( Success );

                //
                // Delete the array of right habd edges.
                //

                Success = FreeObject( ClbInfo->Right );
                DbgAssert( Success );

                //
                // Delete the CLB_INFO object for this window.
                //

                Success = FreeObject( ClbInfo );
                DbgAssert( Success );

                SaveClbInfo ( ClbInfo );
                return 0;
            }

        case WM_PAINT:
            {
                PAINTSTRUCT     ps;
                RECT            Rect;
                POINT           Points[ 2 ];
                HDC             hDC;
                HPEN            hPen;

                hDC = BeginPaint( hWnd, &ps );
                DbgAssert( hDC == ps.hdc );

                Success = GetClientRect( hWnd, &Rect );
                DbgAssert( Success );

                Points[ 0 ].x = 0;
                Points[ 0 ].y = ClbInfo->HeaderHeight + 1;
                Points[ 1 ].x = Rect.right - Rect.left;
                Points[ 1 ].y = ClbInfo->HeaderHeight + 1;

                hPen = GetStockObject( BLACK_PEN );
                DbgHandleAssert( hPen );

                hPen = SelectObject( hDC, hPen );

                Success = Polyline( hDC, Points, NumberOfEntries( Points ));
                DbgAssert( Success );

                hPen = SelectObject( hDC, hPen );

                Success = DeleteObject( hPen );
                DbgAssert( Success );

                Success = EndPaint( hWnd, &ps );
                DbgAssert( Success );

                return 0;
            }

        case WM_COMMAND:

            switch( LOWORD( wParam )) {

            case ID_LISTBOX:

                switch( HIWORD( wParam )) {

                case LBN_DBLCLK:
                case LBN_KILLFOCUS:
                case LBN_SELCHANGE:
                    {
                        //
                        // These messages come to ClbWndProc because it is the parent
                        // of the list box, but they are really intended for the parent
                        // of the Clb.
                        //

                        HWND    hWndParent;

                        //
                        // Forward the message to the Clb's parent if it has a parent.
                        //

                        hWndParent = GetParent( hWnd );
                        DbgHandleAssert( hWndParent );

                        if( hWndParent != NULL ) {

                            //
                            // Replace the control id and handle with the Clb's.
                            //

                            LOWORD( wParam ) = GetDlgCtrlID( hWnd );
                            DbgAssert( LOWORD( wParam ) != 0 );

                            lParam = ( LPARAM ) hWnd;

                            //
                            // Forward the message...
                            //

                            return SendMessage(
                                        hWndParent,
                                        message,
                                        wParam,
                                        lParam
                                        );
                        }
                    }
                }
                break;

            }
            break;

        //
        // Forward to listbox.
        //

        case LB_GETCURSEL:
        case LB_SETCURSEL:
        case LB_FINDSTRING:
        case LB_GETITEMDATA:
        case LB_RESETCONTENT:
        case WM_CHAR:
        case WM_GETDLGCODE:
        case WM_KILLFOCUS:

            return SendMessage(
                    ClbInfo->hWndListBox,
                    message,
                    wParam,
                    lParam
                    );

        case WM_SETFOCUS:
            {
                SetFocus(
                    ClbInfo->hWndListBox
                    );

                return 0;
            }

        case WM_COMPAREITEM:
            {
                //
                // This message comes to ClbWndProc because it is the parent
                // of the list box, but is really intended for the parent
                // of the Clb.
                //

                HWND    hWndParent;

                //
                // Forward the message to the Clb's parent if it has a parent.
                //

                hWndParent = GetParent( hWnd );
                DbgHandleAssert( hWndParent );

                if( hWndParent != NULL ) {

                    int                     ControlId;
                    LPCOMPAREITEMSTRUCT     lpcis;

                    lpcis = ( LPCOMPAREITEMSTRUCT ) lParam;

                    ControlId = GetDlgCtrlID( hWnd );
                    DbgAssert( ControlId != 0 );

                    //
                    // Modify the COMPAREITEMSTRUCT so that it refers to the Clb.
                    //

                    lpcis->CtlID    = ControlId;
                    lpcis->hwndItem = hWnd;

                    //
                    // Forward the message...
                    //

                    return SendMessage(
                                hWndParent,
                                message,
                                ( WPARAM ) ControlId,
                                lParam
                                );
                }

                break;
            }

        case WM_DELETEITEM:
            {
                LPDELETEITEMSTRUCT  lpditms;
                LPCLB_ROW           ClbRow;
                DWORD               i;


                DbgAssert( wParam == ID_LISTBOX );

                //
                // Retrieve the pointer to the DELETEITEMSTRUCT.
                //

                lpditms = ( LPDELETEITEMSTRUCT ) lParam;
                DbgAssert(( lpditms->CtlType == ODT_LISTBOX )
                        &&( lpditms->CtlID == ID_LISTBOX ));

                //
                // If there is no data, just return.
                //

                if( lpditms->itemData == 0 ) {

                    return TRUE;
                }

                //
                // Retrieve the CLB_ROW object for this row.
                //

                ClbRow = ( LPCLB_ROW ) lpditms->itemData;

                //
                // For each column delete the string.
                //

                for( i = 0; i < ClbInfo->Columns; i++ ) {

                    //
                    // Strings were copied with _tcsdup so they must be
                    // freed with free( ).
                    //

                    free( ClbRow->Strings[ i ].String );
                }

                //
                // Free the CLB_STRING object.
                //

                Success = FreeObject( ClbRow->Strings );
                DbgAssert( Success );

                //
                // Free the CLB_ROW object.
                //

                Success = FreeObject( ClbRow );
                DbgAssert( Success );

                return TRUE;
            }

        case WM_DRAWITEM:
            {
                LPDRAWITEMSTRUCT    lpdis;
                BOOL                DrawFocus;

                DbgAssert( wParam == ID_LISTBOX );

                //
                // Retrieve the pointer to the DRAWITEMSTRUCT.
                //

                lpdis = ( LPDRAWITEMSTRUCT ) lParam;
                DbgAssert(( lpdis->CtlType == ODT_LISTBOX )
                        &&( lpdis->CtlID == ID_LISTBOX ));

                //
                // If there is no data, just return.
                //

                if( lpdis->itemData == 0 ) {

                    return TRUE;
                }

                if( lpdis->itemAction & ( ODA_DRAWENTIRE | ODA_SELECT )) {

                    DWORD               i;
                    LPCLB_ROW           ClbRow;
                    COLORREF            TextColor;
                    COLORREF            BkColor;

                    //
                    // Retrieve the CLB_ROW object for this row.
                    //

                    ClbRow = ( LPCLB_ROW ) lpdis->itemData;

                    //
                    // If the item is selected, set the selection colors.
                    //

                    if( lpdis->itemState & ODS_SELECTED ) {

                        BkColor     = COLOR_HIGHLIGHT;
                        TextColor   = COLOR_HIGHLIGHTTEXT;

                    } else {

                        BkColor     = COLOR_WINDOW;
                        TextColor   = COLOR_WINDOWTEXT;
                    }

                    BkColor = GetSysColor( BkColor );
                    TextColor = GetSysColor( TextColor );

                    BkColor = SetBkColor( lpdis->hDC, BkColor );
                    DbgAssert( BkColor != CLR_INVALID );

                    TextColor = SetTextColor( lpdis->hDC, TextColor );
                    DbgAssert( TextColor != CLR_INVALID );


                    //
                    // For each column display the text.
                    //

                    for( i = 0; i < ClbInfo->Columns; i++ ) {

                        RECT    ClipOpaqueRect;
                        int     x;
                        int     Left;
                        UINT    GdiErr;

                        //
                        // Depending on the format, adjust the alignment reference
                        // point (x) and the clipping rectangles left edge so that
                        // there are five pixels between each column.
                        //

                        switch( ClbRow->Strings[ i ].Format ) {

                        case CLB_LEFT:

                            if( i == 0 ) {

                                x = 2;

                            } else {

                                x = ClbInfo->Right[ i - 1 ] + 2;
                            }

                            Left = x - 2;

                            break;

                        case CLB_RIGHT:

                            if( i == 0 ) {

                                Left = 0;

                            } else {

                                Left = ClbInfo->Right[ i - 1 ];
                            }

                            x = ClbInfo->Right[ i ] - 3;

                            break;

                        default:

                            DbgAssert( FALSE );
                        }


                        //
                        // Set the format for this column.
                        //

                        GdiErr = SetTextAlign(
                                        lpdis->hDC,
                                          ClbRow->Strings[ i ].Format
                                        | TA_TOP
                                        );
                        DbgAssert( GdiErr != GDI_ERROR );

                        //
                        // Clip each string to its column width less two pixels
                        // (for asthetics).
                        //

                        Success = SetRect(
                                    &ClipOpaqueRect,
                                    Left,
                                    lpdis->rcItem.top,
                                    ClbInfo->Right[ i ],
                                    lpdis->rcItem.bottom
                                    );
                        DbgAssert( Success );

                        Success = ExtTextOut(
                                    lpdis->hDC,
                                    x,
                                    lpdis->rcItem.top,
                                      ETO_CLIPPED
                                    | ETO_OPAQUE,
                                    &ClipOpaqueRect,
                                    ClbRow->Strings[ i ].String,
                                    ClbRow->Strings[ i ].Length,
                                    NULL
                                    );
                        DbgAssert( Success );

                        //
                        // If the item has the focus, draw the focus rectangle.
                        //

                        DrawFocus = lpdis->itemState & ODS_FOCUS;
                    }

                } else {

                    //
                    // If the Clb has the focus, display a focus rectangle
                    // around the selected item.
                    //

                    DrawFocus = lpdis->itemAction & ODA_FOCUS;
                }

                //
                // If needed, toggle the focus rectangle.
                //

                if( DrawFocus ) {

                    Success = DrawFocusRect(
                                lpdis->hDC,
                                &lpdis->rcItem
                                );
                    DbgAssert( Success );
                }

                return TRUE;
            }

        case WM_NOTIFY:
            {
            HD_NOTIFY * lpNot;
            HD_ITEM   *pHDI;

            lpNot = (HD_NOTIFY *)lParam;
            pHDI = lpNot->pitem;

            switch( lpNot->hdr.code) {

            static
            DRAW_ERASE_LINE DrawEraseLine;

            static
            HPEN            hPen;

            static
            HDC             hDCClientListBox;
            HD_ITEM         hdi;
            UINT            iRight;
            UINT            i;
            RECT            ClientRectHeader;


            case HDN_BEGINTRACK:
                {

                    RECT    ClientRectListBox;

                    //
                    // Get thd HDC for the list box.
                    //

                    hDCClientListBox = GetDC( ClbInfo->hWndListBox );
                    DbgHandleAssert( hDCClientListBox );

                    //
                    // Create the pen used to display the drag position and
                    // select it into the in list box client area DC. Also set
                    // the ROP2 code so that drawing with the pen twice in the
                    // same place will erase it. This is what allows the
                    // line to drag.
                    //

                    hPen = CreatePen( PS_DOT, 1, RGB( 255, 255, 255 ));
                    DbgHandleAssert( hPen );

                    hPen = SelectObject( hDCClientListBox, hPen );
                    SetROP2( hDCClientListBox, R2_XORPEN );

                    //
                    // Set up the DRAW_ERASE_LINE structure so that the drag line is
                    // drawn from the top to the bottom of the list box at the
                    // current drag position.
                    //

                    Success = GetClientRect(
                                    ClbInfo->hWndListBox,
                                    &ClientRectListBox
                                    );
                    DbgAssert( Success );

                    //
                    // Draw the initial drag line from the top to the bottom
                    // of the list box equivalent with the header edge grabbed
                    // by the user.
                    //

                    DrawEraseLine.Draw.Src.x = ClbInfo->Right[ pHDI->cxy ];
                    DrawEraseLine.Draw.Src.y = 0;
                    DrawEraseLine.Draw.Dst.x = ClbInfo->Right[ pHDI->cxy ];
                    DrawEraseLine.Draw.Dst.y =   ClientRectListBox.bottom
                                               - ClientRectListBox.top;

                    Success = DrawLine( hDCClientListBox, &DrawEraseLine );
                    DbgAssert( Success );

                    return 0;
                }

            case HDN_TRACK:
                {

                    //DWORD           Columns;

                    //
                    // Get new drag position.
                    //

                    iRight = 0;
                    hdi.mask = HDI_WIDTH;

                    for( i = 0; i < ClbInfo->Columns - 1; i++ ) {
                        if (i != (UINT)lpNot->iItem) {
                          Header_GetItem(ClbInfo->hWndHeader, i, &hdi);
                        } else {
                          hdi.cxy = pHDI->cxy;
                        }
                        iRight += hdi.cxy;
                        ClbInfo->Right[i] = iRight;
                    }

                    GetClientRect( ClbInfo->hWndHeader, &ClientRectHeader );
                    ClbInfo->Right[i] = ClientRectHeader.right;

                    //
                    // Erase the old line and draw the new one at the new
                    // drag position.
                    //

                    Success = RedrawVerticalLine(
                                hDCClientListBox,
                                ClbInfo->Right[lpNot->iItem],
                                &DrawEraseLine
                                );
                    DbgAssert( Success );

                    return 0;
                }

            case HDN_ENDTRACK:

                //
                // Replace the old pen and delete the one created
                // during HBN_BEGINDRAG.
                //

                hPen = SelectObject( hDCClientListBox, hPen );
                Success = DeleteObject( hPen );
                DbgAssert( Success );

                //
                // Release the DC for the list box.
                //

                Success = ReleaseDC( ClbInfo->hWndListBox, hDCClientListBox );
                DbgAssert( Success );

                Success = RedrawWindow(
                                hWnd,
                                NULL,
                                NULL,
                                  RDW_ERASE
                                | RDW_INVALIDATE
                                | RDW_UPDATENOW
                                | RDW_ALLCHILDREN
                                );
                DbgAssert( Success );

                return 0;
            }

            break;
            }

        case WM_SETTEXT:

            //
            // Adjust the column number and widths based on the heading text.
            //

            Success = AdjustClbHeadings( hWnd, ClbInfo, ( LPCWSTR ) lParam );
            DbgAssert( Success );

            return Success;

        case WM_SIZE:
            {
                HDWP    hDWP;
                LONG    Width;
                LONG    Height;
                LONG    Style;
                LONG    VScrollWidth;

                Width   = LOWORD( lParam );
                Height  = HIWORD( lParam );

                hDWP = BeginDeferWindowPos( 2 );
                DbgHandleAssert( hDWP );

                //
                // Retrieve the list box's styles.
                //

                Style = GetWindowLong(
                            ClbInfo->hWndListBox,
                            GWL_STYLE
                            );

                //
                // If the list box has a vertical scroll bar compute its
                // width so that the header window's width can be adjusted
                // appropriately.
                //

                VScrollWidth =   ( Style & WS_VSCROLL )
                               ?   GetSystemMetrics( SM_CXVSCROLL )
                                 + ( GetSystemMetrics( SM_CXBORDER ) * 2 )
                               : 0;

                //
                // Size the header window to the width of the Clb and its
                // default / original height.
                //

                hDWP = DeferWindowPos(
                            hDWP,
                            ClbInfo->hWndHeader,
                            NULL,
                            0,
                            0,
                            Width - VScrollWidth,
                            ClbInfo->HeaderHeight,
                              SWP_NOACTIVATE
                            | SWP_NOMOVE
                            | SWP_NOZORDER
                            );
                DbgHandleAssert( hDWP );

                //
                // If the list box has a vertical scroll bar, bump the width
                // and height by two so that its border overwrites the Clb
                // border. This eliminates a double border (and a gap) between
                // the right and bottom edges of the scroll bar and the Clb.
                //

                if( Style & WS_VSCROLL ) {

                    Height += 2;
                    Width += 2;
                }

                //
                // Size the list box so that it is the size of the Clb less
                // the height of the header window less the height of the
                // border.
                //

                hDWP = DeferWindowPos(
                            hDWP,
                            ClbInfo->hWndListBox,
                            NULL,
                            0,
                            0,
                            Width,
                              Height
                            - ClbInfo->HeaderHeight
                            - 3,
                              SWP_NOACTIVATE
                            | SWP_NOMOVE
                            | SWP_NOZORDER
                            );
                DbgHandleAssert( hDWP );

                Success = EndDeferWindowPos( hDWP );
                DbgAssert( Success );

                break;
            }

        }
    }

    return DefWindowProc( hWnd, message, wParam, lParam );
}
示例#5
0
int DepositInfo::_dealIn(DepositServCondOne *&pInOne,vector<DepositServCondTwo *>&vInTwo)
{
	//充值,开户
	//校验资料是否存在(否,先开户),充值
	int iRet=0;
	bool bState=false;
	ServAcctInfo oServAcct={0};
	ServAcctInfoSeq oServAcctInfoSeq={0};
	ServAcctInfoSeq oSendSeq={0};
	DepositServCondOne   *pInTwo=NULL;
	PaymentInfoALLCCR pPaymentInfoCCR={0};
	StructPaymentSeqInfo  sStructPaymentSeqInfo={0};
	
	ABMException oExp;
	try 
	{
	
		//普通充值
		//查询用户信息
		iRet=pAllocateBalanceSql->preQryServAcctInfo(pInOne->m_sDestinationAccount,2,oServAcct,oExp);
		switch(iRet)
		{
			case 1://无资料
				{
					__DEBUG_LOG0_(0, "没有资料,开始创建用户信息,然后充值  ");
					iRet=CreateServAcctInfo(pInOne,oServAcctInfoSeq);
					if(iRet!=0)
					{
						__DEBUG_LOG1_(0, "创建用户信息  失败==[%d]",iRet);
						throw iRet;
					}
				}
				break;
			case 0://有资料
				{
					__DEBUG_LOG0_(0, "已有用户资料,充值");
					oServAcctInfoSeq.m_lServID=oServAcct.m_servId;
					oServAcctInfoSeq.m_lAcctID=oServAcct.m_acctId;
					iRet=UpdateAcctInfo(pInOne,oServAcctInfoSeq);
					if(iRet!=0)
					{
						__DEBUG_LOG1_(0, "已有用户资料,充值  失败==[%d]",iRet);
						throw iRet;
					}
				}
				break;
			default://出错
				{
					__DEBUG_LOG1_(0, "查询用户资料出错=[%d]",iRet);
					throw iRet;
				}
		}
	
		//查询业务流水
		bState=false;
		iRet=m_poSql->QueryPaySeq(sStructPaymentSeqInfo,bState);
		if(iRet!=0)
        	{
			__DEBUG_LOG0_(0, "查询业务流水失败  error");
			throw iRet;
        	}
		//查询其他序列
		bState=true;
		iRet=m_poSql->QueryPaySeq(sStructPaymentSeqInfo,bState);
		if(iRet!=0)
        	{
			__DEBUG_LOG0_(0, "查询其他序列出错  error");
			throw iRet;
        	}
		//记录业务表
		strcpy(pPaymentInfoCCR.m_sOperateSeq,pInOne->m_sReqSerial);
		strcpy(pPaymentInfoCCR.m_sCapabilityCode,"0005");
		pPaymentInfoCCR.m_lServID=oServAcctInfoSeq.m_lServID;
		sStructPaymentSeqInfo.m_lRbkPaymentSeq=0;
		strcpy(pPaymentInfoCCR.m_sSpID,"1");
		strcpy(pPaymentInfoCCR.m_sServicePlatformID,"1");
		strcpy(pPaymentInfoCCR.m_sOrderID,"1");
		strcpy(pPaymentInfoCCR.m_sDescription,"划拨充值");
		strcpy(pPaymentInfoCCR.m_sMicropayType,"0");
		strcpy(pPaymentInfoCCR.m_sOrderState,"C0C");
		pPaymentInfoCCR.m_lPayAmount=pInOne->m_iVoucherValue;
		iRet=m_poSql->InsertPaymentInfo(pPaymentInfoCCR,sStructPaymentSeqInfo);
		if(iRet!=0)
        	{
			__DEBUG_LOG0_(0, "记录业务流水表出错!");
			throw iRet;
        	}
		
		sStructPaymentSeqInfo.m_lAcctBalanceID=oServAcctInfoSeq.m_lAcctBalanceID;
		strcpy(pInOne->m_sSourceType,"5VB");
		strcpy(pInOne->m_sSourceDesc,"划拨充值");
		strcpy(pInOne->m_sAllowDraw,"ADY");
		//记录来源表
		iRet=m_poSql->InsertBalanceSource(pInOne,sStructPaymentSeqInfo);
		if(iRet!=0)
        	{
			__DEBUG_LOG0_(0, "记录余额来源表失败! ");
			throw iRet;
        	}

		//优惠充值,只记录账本+来源表
		for(vector<DepositServCondTwo *>::iterator iter=vInTwo.begin();iter!=vInTwo.end();iter++)
		{

			__DEBUG_LOG0_(0, "充值存在优惠,开始优惠充值");
			__DEBUG_LOG1_(0, "优惠数据 (*iter)->m_iBonusUnit=[%d]",(*iter)->m_iBonusUnit);
			//__DEBUG_LOG1_(0, "优惠数据 (*iter)->m_sBalanceType=[%s]",(*iter)->m_sBalanceType);
			__DEBUG_LOG1_(0, "优惠数据 (*iter)->m_iBalanceType=[%d]",(*iter)->m_iBalanceType);
			__DEBUG_LOG1_(0, "优惠数据 (*iter)->m_iBonusStartTime=[%d]",(*iter)->m_iBonusStartTime);
			__DEBUG_LOG1_(0, "优惠数据 (*iter)->m_iBonusExpirationTime=[%d]",(*iter)->m_iBonusExpirationTime);
			__DEBUG_LOG1_(0, "优惠数据 (*iter)->m_iBonusAmount=[%d]",(*iter)->m_iBonusAmount);
			pInTwo=new DepositServCondOne;
			pInTwo->m_iDestinationBalanceUnit=(*iter)->m_iBonusUnit;//优惠额单位,0-分,1-条
			pInTwo->m_iVoucherValue=(*iter)->m_iBonusAmount;//赠与的优惠金额
			//strcpy(pInTwo->m_sBalanceType,(*iter)->m_sBalanceType);//余额类型
			pInTwo->m_iBalanceType=(*iter)->m_iBalanceType;//余额类型
			pInTwo->m_iBonusStartTime=(*iter)->m_iBonusStartTime;//优惠有效期起始时间,yyyymmdd
			pInTwo->m_iBonusExpirationTime=(*iter)->m_iBonusExpirationTime;//优惠有效期终结时间,yyyymmdd
			strcpy(pInTwo->m_sDestinationAccount,pInOne->m_sDestinationAccount);
			iRet=UpdateAcctInfo(pInTwo,oServAcctInfoSeq);
			if(iRet!=0)
			{
				__DEBUG_LOG0_(0, "更新用户账户失败  ");
				throw iRet;
			}
			strcpy(pInTwo->m_sSourceType,"5VF");
			strcpy(pInTwo->m_sSourceDesc,"VC优惠充值");
			strcpy(pInTwo->m_sAllowDraw,"ADN");
			bState=false;
			memset(&oSendSeq,0,sizeof(ServAcctInfoSeq));
			iRet=m_poSql->QueryServAcctSeq(oSendSeq,bState);
			if(iRet!=0)
			{
				__DEBUG_LOG1_(0, "查询用户序列失败=[%d]!",iRet);
				throw iRet;
			}
			sStructPaymentSeqInfo.m_lBalanceSourceSeq=oSendSeq.m_lBalanceSourceID;
			sStructPaymentSeqInfo.m_lAcctBalanceID=oServAcctInfoSeq.m_lAcctBalanceID;
			//记录来源表
			iRet=m_poSql->InsertBalanceSource(pInTwo,sStructPaymentSeqInfo);
			if(iRet!=0)
			{
				__DEBUG_LOG0_(0, "记录余额来源失败!");
				throw iRet;
			}
			FreeObject(pInTwo);
		}
		return 0;

		
	}
	catch(TTStatus oSt) 
	{
		iRet=-1;
		__DEBUG_LOG1_(0, "充值失败,错误信息=%s", oSt.err_msg);
	}
	catch(int &value ) 
	{
		iRet=value;
		__DEBUG_LOG1_(0, "充值失败,错误信息=%d",value);
	}
	FreeObject(pInTwo);
	

	return iRet;
} 
示例#6
0
int DepositInfo::UpdateAcctInfo(DepositServCondOne *&pInOne,ServAcctInfoSeq &oServAcctInfoSeq)
{
	int iRet;
	bool bState=false;
	long lDepositAmount=0;
	StructPaymentSeqInfo sStructPaymentSeqInfo={0};
	AcctBalanceInfo *pAcctBalanceInfo=NULL;
	try
	{
		//根据账本类型查询账本
		pAcctBalanceInfo=new AcctBalanceInfo;
		if(!pAcctBalanceInfo)
		{
			__DEBUG_LOG0_(0, "分配内存失败");
			throw ECODE_MEM_MALLOC_FAIL;
		}
		/*
		if(strlen(pInOne->m_sBalanceType)<=0)
		{
			strcpy(pInOne->m_sBalanceType,"10");
		}
		*/
		iRet=m_poSql->QueryAcctBalanceSimple(pInOne,pAcctBalanceInfo);
		switch(iRet)
		{
			case 1://更新
				{
					__DEBUG_LOG0_(0, "存在用户余额账本,更新");
					oServAcctInfoSeq.m_lAcctBalanceID=pAcctBalanceInfo->m_lAcctBalanceID;
					lDepositAmount=pInOne->m_iVoucherValue;
					sStructPaymentSeqInfo.m_lPaymentAmount = (-1)*lDepositAmount;
					iRet=m_poSql->updateAcctBalance(sStructPaymentSeqInfo,pAcctBalanceInfo);
					if(iRet!=0)
					{
						__DEBUG_LOG1_(0, "更新用户余额账本失败  =[%d]",iRet);
						throw iRet;
					}
				}
				break;
			case 0://记录
				{
					__DEBUG_LOG0_(0, "创建用户余额账本,记录");
					iRet=m_poSql->QueryServAcctSeq(oServAcctInfoSeq,bState);
					if(iRet!=0)
					{
						__DEBUG_LOG1_(0, "查询余额账本序列,失败 =[%d]",iRet);
						throw iRet;
					}
					iRet=m_poSql->InsertAcctBalance(oServAcctInfoSeq,pInOne);
					if(iRet!=0)
					{
						__DEBUG_LOG1_(0, "记录余额账本表失败  =[%d]",iRet);
						throw iRet;
					}
				}
				break;
			default:
				{
					__DEBUG_LOG1_(0, "查询余额账本,失败[%d]",iRet);
					throw iRet;
				}
				break;
		}
		FreeObject(pAcctBalanceInfo);
		
		return 0;
	}
	catch(TTStatus oSt) 
	{
		iRet=DEPOSIT_TT_ERR;
		__DEBUG_LOG1_(0, "存在用户资料并记录信息失败,错误信息=%s", oSt.err_msg);
	}
	catch(int &value ) 
	{
		iRet=value;
		__DEBUG_LOG1_(0, "存在用户资料并记录信息失败,错误信息=%d",value);
	}
	FreeObject(pAcctBalanceInfo);

	return iRet;
}
示例#7
0
DepositInfo:: ~DepositInfo()
{
    FreeObject(m_poSql);
    FreeObject(pAllocateBalanceSql);
    FreeObject(m_dccOperation );
}
void WallVCSuite_TestWallVC( WallVCSuiteData* data ) {
   unsigned                    nDomains;
   unsigned                    nDims = 3;
   unsigned                    meshSize[3] = {3, 3, 3};
   int                         procToWatch;
   double                      minCrds[3] = {0.0, 0.0, 0.0};
   double                      maxCrds[3] = {1.0, 1.0, 1.0};
   char*                       vcKey[] = {"WallVC_Front", "WallVC_Back", "WallVC_Left", "WallVC_Right",
                                          "WallVC_Top", "WallVC_Bottom"};
   char*                       vcKeyName[] = {"WallVC_FrontName", "WallVC_BackName", "WallVC_LeftName", "WallVC_RightName",
                                          "WallVC_TopName", "WallVC_BottomName"};
   char*                       varName[] = {"x", "y", "z", "vx", "vy", "vz", "temp"};
   char                        input_file[PCU_PATH_MAX];
   char                        expected_file[PCU_PATH_MAX];
   Mesh*                       mesh;
   Variable_Register*          variable_Register;
   ConditionFunction*          quadCF;
   ConditionFunction*          expCF;
   ConditionFunction_Register* conFunc_Register;
   ExtensionManager_Register*  extensionMgr_Register;
   Dictionary*                 dictionary;
   Dictionary*                 sources;
   Stream*                     stream;
   XML_IO_Handler*             io_handler;
   Variable*                   var[7];
   double*                     array[7];
   VariableCondition*          vc; 
   Index                       i;

   procToWatch = data->nProcs >=2 ? 1 : 0;

   io_handler = XML_IO_Handler_New();

    stream = Journal_Register( Info_Type, (Name)"WallVCStream"  );
   Stream_RedirectFile( stream, "testWallVC.dat" );

   dictionary = Dictionary_New();
   sources = Dictionary_New();
   Dictionary_Add( dictionary, (Dictionary_Entry_Key)"outputPath", Dictionary_Entry_Value_FromString("./output") );

   /* Input file */
   pcu_filename_input( "wallVC.xml", input_file );
   IO_Handler_ReadAllFromFile( io_handler, input_file, dictionary, sources );
   fflush( stdout );

   extensionMgr_Register = ExtensionManager_Register_New(); 

   /* Create a mesh. */
   mesh = (Mesh*) WallVCSuite_buildMesh( nDims, meshSize, minCrds, maxCrds, extensionMgr_Register );
   nDomains = Mesh_GetDomainSize( mesh, MT_VERTEX );

   /* Create CF stuff */
   quadCF = ConditionFunction_New( WallVCSuite_quadratic, (Name)"quadratic", NULL );
   expCF = ConditionFunction_New( WallVCSuite_exponential, (Name)"exponential", NULL);
   conFunc_Register = ConditionFunction_Register_New( );
   ConditionFunction_Register_Add(conFunc_Register, quadCF);
   ConditionFunction_Register_Add(conFunc_Register, expCF);

   /* Create variable register */
   variable_Register = Variable_Register_New();

   /* Create variables */
   for (i = 0; i < 6; i++) {
      array[i] = Memory_Alloc_Array( double, nDomains, "array[i]" );
      var[i] = Variable_NewScalar( varName[i], NULL, Variable_DataType_Double, (Index*)&nDomains, NULL, (void**)&array[i], 0  );
      Variable_Register_Add(variable_Register, var[i]);
   }
   array[6] = Memory_Alloc_Array( double, nDomains * 5, "array[6]" );
   var[6] = Variable_NewVector( varName[6], NULL, Variable_DataType_Double, 5, &nDomains, NULL, (void**)&array[6], 0 );
   Variable_Register_Add(variable_Register, var[6]);
   Variable_Register_BuildAll(variable_Register);

   for (i = 0; i < 6; i++) {
      Index j, k;

      vc = (VariableCondition*) WallVC_New( vcKeyName[i], NULL, vcKey[i], variable_Register, conFunc_Register, dictionary, mesh );
      Stg_Component_Build( vc, 0, False );

      for (j = 0; j < 6; j++)
         memset(array[j], 0, sizeof(double)* nDomains );
      memset(array[6], 0, sizeof(double)* nDomains * 5);
      VariableCondition_Apply(vc, NULL);

      if (data->rank == procToWatch) {
         Journal_Printf( stream,"Testing for %s\n", vcKey[i]);
         for (j = 0; j < 6; j++) {
            Journal_Printf( stream,"\nvar[%u]: %.2lf", j, array[j][0]);
            for (k = 1; k < nDomains; k++)
               Journal_Printf( stream,", %.2lf", array[j][k]);
         }

         Journal_Printf( stream,"\nvar[6]: %.2lf", array[6][0]);
         for (j = 1; j < nDomains*5; j++)
            Journal_Printf( stream,", %.2lf", array[6][j]);
         Journal_Printf( stream,"\n\n");

         for (j = 0; j < 7; j++) {
            for (k = 0; k < nDomains; k++)
               Journal_Printf( stream,"%s ", VariableCondition_IsCondition(vc, k, j) ? "True " : "False");
            Journal_Printf( stream,"\n");
         } Journal_Printf( stream,"\n");

         for (j = 0; j < 7; j++) {
            for (k = 0; k < nDomains; k++) {
               VariableCondition_ValueIndex  valIndex;
               valIndex = VariableCondition_GetValueIndex(vc, k, j);
               if (valIndex != (unsigned)-1)
                  Journal_Printf( stream,"%03u ", valIndex);
               else
                  Journal_Printf( stream,"XXX ");
            } Journal_Printf( stream,"\n");
         } Journal_Printf( stream,"\n");
      }
      Stg_Class_Delete(vc);
   }

   if (data->rank == procToWatch) {
      pcu_filename_expected( "testWallVC.expected", expected_file );
      pcu_check_fileEq( "testWallVC.dat", expected_file );
      remove( "testWallVC.dat" );
   }

   Stg_Class_Delete(variable_Register);
   for (i = 0; i < 7; i++) {
      Stg_Class_Delete(var[i]);
      if (array[i]) Memory_Free(array[i]);
   }
   Stg_Class_Delete(extensionMgr_Register);
   Stg_Class_Delete(io_handler);
   Stg_Class_Delete(conFunc_Register);
   Stg_Class_Delete(quadCF);
   Stg_Class_Delete(expCF);
   Stg_Class_Delete(dictionary);
   Stg_Class_Delete(sources);
   FreeObject( mesh );
}
void Decomp_Sync_Negotiate_RemoteSearch( Decomp_Sync_Negotiate* self, Decomp_Sync* sync, 
					 unsigned** nRemFound, unsigned*** remFound )
{
	unsigned*	nFound;
	unsigned**	found;
	RangeSet*	rSet;
	unsigned	nBytes;
	Stg_Byte*	bytes;
	unsigned*	remNBytes;
	unsigned**	remBytes;
	RangeSet**	remSets;
	unsigned	p_i;

	assert( self );
	assert( sync );
	assert( nRemFound );
	assert( remFound );

	if( sync->commTopo->nInc ) {
		/* Build a range set of our remotes and pickle. */
		rSet = RangeSet_New();
		RangeSet_SetIndices( rSet, sync->nRemotes, sync->remotes );
		RangeSet_Pickle( rSet, &nBytes, &bytes );

		/* Broadcast our remotes to neighbours. */
		CommTopology_Allgather( sync->commTopo, 
					nBytes, bytes, 
					&remNBytes, (void***)&remBytes, 
					sizeof(Stg_Byte) );

		/* Free bytes. */
		FreeArray( bytes );

		/* Unpickle range sets. */
		remSets = Memory_Alloc_Array_Unnamed( RangeSet*, sync->commTopo->nInc );
		for( p_i = 0; p_i < sync->commTopo->nInc; p_i++ ) {
			remSets[p_i] = RangeSet_New();
			RangeSet_Unpickle( remSets[p_i], remNBytes[p_i], (void*)remBytes[p_i] );
		}

		/* Free remote bytes. */
		FreeArray( remNBytes );
		FreeArray( remBytes );

		/* Replace our remote range set with a local one, then intersect remote sets. */
		RangeSet_SetIndices( rSet, sync->decomp->nLocals, sync->decomp->locals );
		nFound = Memory_Alloc_Array_Unnamed( unsigned, sync->commTopo->nInc );
		found = Memory_Alloc_Array_Unnamed( unsigned*, sync->commTopo->nInc );
		for( p_i = 0; p_i < sync->commTopo->nInc; p_i++ ) {
			RangeSet_Intersection( remSets[p_i], rSet );
			RangeSet_GetIndices( remSets[p_i], nFound + p_i, found + p_i );
			FreeObject( remSets[p_i] );
		}

		/* Free remote set array. */
		FreeArray( remSets );

		/* Send back all the ones we found and receive from all others all our requireds they found. */
		CommTopology_Alltoall( sync->commTopo, 
				       nFound, (void**)found, 
				       nRemFound, (void***)remFound, 
				       sizeof(unsigned) );

		/* Release some memory. */
		FreeArray( nFound );
		FreeArray2D( sync->commTopo->nInc, found );
	}
示例#10
0
void YKReader::ReadData( const YK_TYPE& type )
{
	WRDataInfo& dataInfo = m_pDS->GetDataInfo();
	dataInfo.type = type;
	m_pCallBack->SetCurCallBack(type);
	if (!IsEnableSync())
	{
		m_pDS->Clear();
		if (!m_pCallBack->ProBeforeProData(dataInfo, this) ||
			!BeforeProData(dataInfo))
			return;
	}

	if (!IsEnableSync() && dataInfo.type != type)
	{
		m_pCallBack->SetCurCallBack(dataInfo.type);
		if (!m_pCallBack->ProBeforeProData(dataInfo, this))
			return;
	}

	if (dataInfo.type == TblTableState)
	{
		ReadTblModel(dataInfo);
		return;
	}else if(viewWnd_def == dataInfo.type)
	{
		ReadViewStates(dataInfo);
		return;
	}
	else if(dataInfo.type == TblCustomRule)
	{
		ReadTableTypeValue(dataInfo);
		return;
	}

	if (dataInfo.type == TblSpec)
	{
		int num = 0;
	}
	while (m_pDS->Step())
	{
		//BOOST_ASSERT(m_pDS->ValidData());
		if(!m_pDS->ValidData())	continue;
		YKObjectSPtr obj = CreateObj(dataInfo);
		if (!obj.ValidObj())
			continue;
		
		if (!IsEnableSync())
		{
			if (!m_pCallBack->ProBeforeObject(obj, dataInfo, this) ||
				!BeforeObject(obj, dataInfo))
			{
				continue;
			}
		}

		const std::size_t len = dataInfo.m_vecFields.size();
		dataInfo.bInvalidObj = false;
		for (std::size_t i = 0; i < len; ++i)
		{
 			YK_UINT field = dataInfo.m_vecFields[i];
			dataInfo.curField = field;
			YKString val = std::move(m_pDS->GetData(i));
			val.Replace(dataInfo.replaceField, dataInfo.sepField);
			val.Replace(dataInfo.replaceObject, dataInfo.sepObject);
			if (IsEnableSync() || (m_pCallBack->ProProField(obj, dataInfo, val, this) &&
				ProField(obj, dataInfo, val) && field != DATESAVE_SPEC_COL && field != DATESAVE_SPEC_DATA_COL && field != DATESAVE_SPEC_RANGE_COL))
			{
				m_dataWriter.Write(dataInfo.type, obj, field, val);
			}
			if (dataInfo.bInvalidObj)
				break;
		}

		if (!IsEnableSync() && !dataInfo.bInvalidObj)
		{
			if (m_pCallBack->ProAfterObject(obj, dataInfo, this))
				AfterObject(obj, dataInfo);
		}

		if (!IsEnableSync())
		{
			if (dataInfo.bInvalidObj)
				FreeObject(obj, dataInfo);
			else
				obj->GetFlag().m_bTempRead = false;
		}
	}

	if (!IsEnableSync())
	{
		if (m_pCallBack->ProAfterProData(dataInfo, this))
			AfterProData(dataInfo);
	}
}
示例#11
0
void SurfaceAdaptor_Generate( void* adaptor, void* _mesh ) {
	SurfaceAdaptor*			self = (SurfaceAdaptor*)adaptor;
	Mesh*				mesh = (Mesh*)_mesh;
	SurfaceAdaptor_DeformFunc*	deformFunc;
	unsigned*			gSize;
	Grid*				grid;
	unsigned*			inds;
	unsigned			d_i, n_i;

	/* Build base mesh, which is assumed to be cartesian. */
	MeshGenerator_Generate( self->generator, mesh );

	/* If we're not 2D or 3D, forget about it. */
	if( mesh->topo->nDims != 2 && mesh->topo->nDims != 3 )
		return;

	/* What kind of surface do we want? */
	switch( self->surfaceType ) {
	case SurfaceAdaptor_SurfaceType_Wedge:
		deformFunc = SurfaceAdaptor_Wedge;
		break;
	case SurfaceAdaptor_SurfaceType_Sine:
		deformFunc = SurfaceAdaptor_Sine;
		break;
	case SurfaceAdaptor_SurfaceType_Cosine:
		deformFunc = SurfaceAdaptor_Cosine;
		break;
	default:
		break;
	};

	/* Extract the cartesian information. */
	gSize = (unsigned*)ExtensionManager_Get( mesh->info, mesh, 
						 ExtensionManager_GetHandle( mesh->info, "cartesianGlobalSize" ) );

	/* Build grid and space for indices. */
	grid = Grid_New();
	Grid_SetNDims( grid, mesh->topo->nDims );
	for( d_i = 0; d_i < mesh->topo->nDims; d_i++ )
		gSize[d_i]++;
	Grid_SetSizes( grid, gSize );
	for( d_i = 0; d_i < mesh->topo->nDims; d_i++ )
		gSize[d_i]--;
	inds = Memory_Alloc_Array_Unnamed( unsigned, mesh->topo->nDims );

	/* Loop over domain nodes. */
	for( n_i = 0; n_i < MeshTopology_GetDomainSize( mesh->topo, MT_VERTEX ); n_i++ ) {
		unsigned	gNode;
		double		height;

		gNode = MeshTopology_DomainToGlobal( mesh->topo, MT_VERTEX, n_i );
		Grid_Lift( grid, gNode, inds );

		/* Calculate a height percentage. */
		height = (double)inds[1] / (double)(gSize[1] - 1);

		/* Deform this node. */
		mesh->nodeCoord[n_i][1] += height * deformFunc( self, mesh, gSize, n_i, inds );
	}

	/* Free resources. */
	FreeArray( inds );
	FreeObject( grid );
}
示例#12
0
文件: resp.c 项目: mingpen/OpenNT
BOOL InitializeSystemResourceLists(
    IN HREGKEY hRegKey
    )

/*++

Routine Description:

    InitializeSystemResourceLists recursively walks the resource map in the
    registry and builds the SYSTEM_RESOURCE lists. This is a data structure
    that links all resources of the same type together, as well as linking all
    resources belonging to a specific device/driver together. Lastly each
    resource is independently linked to the device/driver that owns it. This
    leds to a 'mesh' of linked lists with back pointers to the owning
    device/driver object.

Arguments:

    hRegKey - Supplies a handle to a REGKEY object where the search is to
              continue.

Return Value:

    BOOL    - returns TRUE if the resource lists are succesfully built.

--*/

{
    BOOL    Success;
    HREGKEY hRegSubkey;

    DbgHandleAssert( hRegKey );

    //
    // While there are still more device/driver resource descriptors...
    //

    while( QueryNextValue( hRegKey )) {

        PCM_FULL_RESOURCE_DESCRIPTOR    FullResource;
        LPSYSTEM_RESOURCES              SystemResource;
        LPDEVICE                        Device;
        LPTSTR                          Extension;
        DWORD                           Count;
        DWORD                           i;
        DWORD                           j;

        //
        // Based on the type of key, prepare to walk the list of
        // RESOURCE_DESCRIPTORS (the list may be one in length).
        //

        if( hRegKey->Type == REG_FULL_RESOURCE_DESCRIPTOR ) {

            Count           = 1;
            FullResource    = ( PCM_FULL_RESOURCE_DESCRIPTOR ) hRegKey->Data;

        } else if( hRegKey->Type == REG_RESOURCE_LIST ) {

            Count           = (( PCM_RESOURCE_LIST ) hRegKey->Data )->Count;
            FullResource    = (( PCM_RESOURCE_LIST ) hRegKey->Data )->List;

        } else {

            DbgAssert( FALSE );
            continue;
        }

        //
        // Allocate a DEVICE object.
        //

        Device = AllocateObject( DEVICE, 1 );
        DbgPointerAssert( Device );
        if( Device == NULL ) {
            Success = DestroySystemResourceLists( _SystemResourceLists );
            DbgAssert( Success );
            return FALSE;
        }

        //
        // Allocate a buffer for the device/driver name. The maximum size of
        // the name will be the number of characters in both the key and
        // value name.
        //

        Device->Name = AllocateObject(
                            TCHAR,
                              _tcslen( hRegKey->Name )
                            + _tcslen( hRegKey->ValueName )
                            + sizeof( TCHAR )
                            );
        DbgPointerAssert( Device->Name );
        if( Device->Name == NULL ) {
            Success = DestroySystemResourceLists( _SystemResourceLists );
            DbgAssert( Success );
            return FALSE;
        }

        //
        // Rationalize the device name such that it is of the form Device.Raw
        // or Device.Translated.
        //

        Device->Name[ 0 ] = TEXT( '\0' );
        if(     ( _tcsnicmp( hRegKey->ValueName, TEXT( ".Raw" ), 4 ) == 0 )
            ||  ( _tcsnicmp( hRegKey->ValueName, TEXT( ".Translated" ), 11 ) == 0 )) {

            _tcscpy( Device->Name, hRegKey->Name );
        }
        _tcscat( Device->Name, hRegKey->ValueName );

        //
        // Based on the device name, determine if the resource descriptors
        // should be added to the RAW or TRANSLATED lists.
        //

        if( Extension = _tcsstr( Device->Name, TEXT( ".Raw" ))) {

            SystemResource = &_SystemResourceLists[ RAW ];

        } else if( Extension = _tcsstr( Device->Name, TEXT( ".Translated" ))) {

            SystemResource = &_SystemResourceLists[ TRANSLATED ];

        } else {

            DbgAssert( FALSE );
            Success = DestroySystemResourceLists( _SystemResourceLists );
            DbgAssert( Success );
            return FALSE;
        }

        //
        // Strip off the extension (.Raw or .Translated) from the device name.
        //

        Device->Name[ Extension - Device->Name ] = TEXT( '\0' );

        //
        // Set the signature in the DEVICE object.
        //

        SetSignature( Device );

        //
        // If the DEVICE object list is empty, add the device to the beginning
        // of the list else add it to the end of the list.
        //

        if( SystemResource->DeviceHead == NULL ) {

            SystemResource->DeviceHead = Device;
            SystemResource->DeviceTail = Device;

        } else {

            LPDEVICE    ExistingDevice;

            //
            // See if the DEVICE object is already in the list.
            //

            ExistingDevice = SystemResource->DeviceHead;
            while( ExistingDevice ) {

                if( _tcsicmp( ExistingDevice->Name, Device->Name ) == 0 ) {
                    break;
                }
                ExistingDevice = ExistingDevice->Next;
            }

            //
            // If the DEVICE object is not already in the list, add it else
            // free the DEICE object.
            //

            if( ExistingDevice == NULL ) {

                SystemResource->DeviceTail->Next = Device;
                SystemResource->DeviceTail       = Device;

            } else {

                Success = FreeObject( Device );
                DbgAssert( Success );
            }
        }

        //
        // NULL terminate the DEVICE object list.
        //

        SystemResource->DeviceTail->Next = NULL;

        //
        // For each CM_FULL_RESOURCE DESCRIPTOR in the current value...
        //

        for( i = 0; i < Count; i++ ) {

            PCM_PARTIAL_RESOURCE_DESCRIPTOR   PartialResourceDescriptor;

            //
            // For each CM_PARTIAL_RESOURCE_DESCRIPTOR in the list...
            //

            for( j = 0; j < FullResource->PartialResourceList.Count; j++ ) {

                LPRESOURCE_DESCRIPTOR   ResourceDescriptor;
                LPRESOURCE_DESCRIPTOR*  Head;
                LPRESOURCE_DESCRIPTOR*  Tail;

                //
                // Allocate a RESOURCE_DESCRIPTOR object.
                //

                ResourceDescriptor = AllocateObject( RESOURCE_DESCRIPTOR, 1 );
                DbgPointerAssert( ResourceDescriptor );
                if( ResourceDescriptor == NULL ) {
                    Success = DestroySystemResourceLists( _SystemResourceLists );
                    DbgAssert( Success );
                    return FALSE;
                }

                //
                // Get a pointer to the current CM_PARTIAL_RESOURCE_DESCRIPTOR
                // in the current CM_FULLRESOURCE_DESCRIPTOR in the list.
                //

                PartialResourceDescriptor = &( FullResource[ i ].PartialResourceList.PartialDescriptors[ j ]);

                //
                // Based on the resource type grab the pointers to the head and
                // tail of the appropriate list.
                //

                switch( PartialResourceDescriptor->Type ) {

                case CmResourceTypePort:

                    Head = &SystemResource->PortHead;
                    Tail = &SystemResource->PortTail;
                    break;

                case CmResourceTypeInterrupt:

                    Head = &SystemResource->InterruptHead;
                    Tail = &SystemResource->InterruptTail;
                    break;

                case CmResourceTypeMemory:

                    Head = &SystemResource->MemoryHead;
                    Tail = &SystemResource->MemoryTail;
                    break;

                case CmResourceTypeDma:

                    Head = &SystemResource->DmaHead;
                    Tail = &SystemResource->DmaTail;
                    break;

                case CmResourceTypeDeviceSpecific:

                    //
                    // Since device specific data is not be collected, free the
                    // associated RESOURCCE_DESCRIPTOR object.
                    //

                    Success = FreeObject( ResourceDescriptor );
                    DbgAssert( Success );
                    break;

                default:

                    DbgPrintf(( L"Winmsd : Unknown PartialResourceDescriptor->Type == %1!d!\n", PartialResourceDescriptor->Type ));
                    continue;
                }

                //
                // If the list is empty add the RESOURCE_DESCRIPTOR object to
                // the beginning of the list, else add it to the end.
                //

                if( *Head == NULL ) {

                    *Head = ResourceDescriptor;
                    *Tail = ResourceDescriptor;

                } else {

                    ( *Tail )->NextSame = ResourceDescriptor;
                    *Tail = ResourceDescriptor;
                }

                //
                // NULL terminate the list.
                //

                ( *Tail )->NextSame = NULL;

                //
                // Make a copy of the actual resource descriptor data.
                //

                CopyMemory(
                    &ResourceDescriptor->CmResourceDescriptor,
                    PartialResourceDescriptor,
                    sizeof( CM_PARTIAL_RESOURCE_DESCRIPTOR )
                    );

                //
                // Note the owner (device/driver) of this resource descriptor.
                //

                ResourceDescriptor->Owner = SystemResource->DeviceTail;

                //
                // The RESOURCE_DESCRIPTOR is complete so set its signature.
                //

                SetSignature( ResourceDescriptor );

                //
                // Add the RESOURCE_DESCRIPTOR to the list of resources owned
                // by the current DEVICE.
                //

                if( SystemResource->DeviceTail->ResourceDescriptorHead == NULL ) {

                    SystemResource->DeviceTail->ResourceDescriptorHead
                        = ResourceDescriptor;

                    SystemResource->DeviceTail->ResourceDescriptorTail
                        = ResourceDescriptor;

                } else {

                    SystemResource->DeviceTail->ResourceDescriptorTail->NextDiff
                        = ResourceDescriptor;

                    SystemResource->DeviceTail->ResourceDescriptorTail
                        = ResourceDescriptor;

                }

                //
                // NULL terminate the list.
                //

                SystemResource->DeviceTail->ResourceDescriptorTail->NextDiff
                    = NULL;
            }

            //
            // Get the next CM_FULL_RESOURCE_DESCRIPTOR from the list.
            //

            FullResource = ( PCM_FULL_RESOURCE_DESCRIPTOR )( PartialResourceDescriptor + 1 );
        }
    }

    //
    // Traverse the list of keys in the resource descriptor portion of the
    // registry and continue building the lists.
    //

    while(( hRegSubkey = QueryNextSubkey( hRegKey )) != NULL ) {

        Success = InitializeSystemResourceLists( hRegSubkey );
        DbgAssert( Success );
        if( Success == FALSE ) {

            Success = DestroySystemResourceLists( _SystemResourceLists );
            DbgAssert( Success );
            return FALSE;
        }

        Success = CloseRegistryKey( hRegSubkey );
        DbgAssert( Success );
        if( Success == FALSE ) {

            Success = DestroySystemResourceLists( _SystemResourceLists );
            DbgAssert( Success );
            return FALSE;
        }
    }

    //
    // Set the signatures in both of the fully initialized lists.
    //

    SetSignature( &_SystemResourceLists[ RAW ]);
    SetSignature( &_SystemResourceLists[ TRANSLATED ]);

    return TRUE;
}
示例#13
0
文件: resp.c 项目: mingpen/OpenNT
BOOL
DestroySystemResourceLists(
    IN LPSYSTEM_RESOURCES SystemResourceLists
    )

/*++

Routine Description:

    DestroySystemResourceLists merely walks the list of DEVICE and the lists of
    RESOURCE_DESCRIPTORS and frees all of them.

Arguments:

    SystemResourceLists - Supplies a pointer to a SYSTEM_RESOURCE object whose
                          lists will be tarversed and objects freed.

Return Value:

    BOOL - Returns TRUE if everything was succesfully freed, FALSE otherwise.

--*/

{
    BOOL        Success;
    int         i;

    //
    // Validate  that the supplied SYSTEM_RESOURCES is the one created.
    //

    DbgAssert( SystemResourceLists == _SystemResourceLists );

    //
    // Traverse both the raw and translated lists.
    //

    for( i = RAW; i <= TRANSLATED; i++ ) {

        int                     j;

        //
        // Setup an array of pointers to the heads of each list.
        //

        LPRESOURCE_DESCRIPTOR   ResourceDescriptor[ ] = {

                                    SystemResourceLists[ i ].DmaHead,
                                    SystemResourceLists[ i ].InterruptHead,
                                    SystemResourceLists[ i ].MemoryHead,
                                    SystemResourceLists[ i ].PortHead
                                };


        //
        // Walk the list of DEVICE objects freeing all of their resources
        // along the way.
        //

        while( SystemResourceLists[ i ].DeviceHead ) {

            LPDEVICE    NextDevice;

            //
            // Remember the next DEVICE.
            //

            NextDevice = SystemResourceLists[ i ].DeviceHead->Next;

            //
            // Free the name buffer.
            //

            DbgPointerAssert( SystemResourceLists[ i ].DeviceHead->Name );
            Success = FreeObject( SystemResourceLists[ i ].DeviceHead->Name );
            DbgAssert( Success );

            //
            // Free the DEVICE object.
            //

            Success = FreeObject( SystemResourceLists[ i ].DeviceHead );
            DbgAssert( Success );

            //
            // Point at the next DEVICE object.
            //

            SystemResourceLists[ i ].DeviceHead = NextDevice;
        }

        //
        // For each resource list...
        //

        for( j = 0; j < NumberOfEntries( ResourceDescriptor ); j++ ) {

            //
            // Walk the list of RESOURCE_DESCRIPTOR objects freeing all of their
            // resources along the way.
            //

            while( ResourceDescriptor[ j ]) {

                LPRESOURCE_DESCRIPTOR   NextResourceDescriptor;

                //
                // Remember the next RESOURCE_DESCRIPTOR.
                //

                NextResourceDescriptor = ResourceDescriptor[ j ]->NextSame;

                //
                // Free the RESOURCE_DESCRIPTOR object.
                //

                Success = FreeObject( ResourceDescriptor[ j ]);
                DbgAssert( Success );


                //
                // Point at the next RESOURCE_DESCRIPTOR object.
                //

                ResourceDescriptor[ j ] = NextResourceDescriptor;
            }
        }

    }

    return TRUE;
}
示例#14
0
// 余额划拨冲正
// 1.修改原业务流水记录状态为C0R
// 2.业务流水记录中充值一笔正钱,状态为C0F
// 3.更新余额来源,balance字段
// 4.同时更新余额帐本表
// 5.做余额支出,负钱
// 6.做余额来源支出关系记录

int PaymentInfo::ReverseDeductBalance(char* sOldRequestId,ReqReverseDeductSvc &oRvsInfo)
{
	int iRet=-1;
	
	long lOperPayoutId=0L;
	long lAcctBalanceId=0L;
	long lAmount=0L;
	long lOptId=0L;
	bool bFlag = false;
	string m_sOperType;
	
	long lBalanceSourceId=0L;
	
	long lServId=0L;
	
	
	StructPaymentSeqInfo  sStructPaymentSeqInfo={0};// 业务流水信息
	BalanceSourceInfo *pBalanceSourceInfo=NULL;
	
	AcctBalanceInfo *pAcctBalanceInfo=new AcctBalanceInfo;
	vector<BalanceSourceInfo *> vBalanceSourceInfo;
	try
	{
		PaymentInfoALLCCR pPaymentInfoCCR={0};
		StructPaymentSeqInfo  sStructPaymentSeqInfo={0};
		// 生成业务流水号
		iRet = m_poSql->QueryPaySeq(sStructPaymentSeqInfo,bFlag);
		if(iRet != 0)
		{
			__DEBUG_LOG0_(0, "取业务流水号失败。");
			throw iRet;
		}
		
		// 根据请求冲正流水号查找被冲正记录业务流水
		//iRet = m_poSql->QueryOptID(sOldRequestId,lOptId);
		//iRet = m_poSql->qryOptidByForeignId(sOldRequestId,lOptId);
		// Modify 2011.7.5 增加查询Serv_Id
		iRet = m_poSql->qryOptInfoByForeignId(sOldRequestId,lOptId,lServId);
		if(iRet != 0)
		{
			__DEBUG_LOG0_(0, "查找被冲正业务流水号失败。");
			throw iRet;
		}
		
		strcpy(pPaymentInfoCCR.m_sOperateSeq ,oRvsInfo.m_sRequestId); // 外部流水号
		strcpy(pPaymentInfoCCR.m_sCapabilityCode,"0018"); // 能力编码
		strcpy(pPaymentInfoCCR.m_sServicePlatformID,oRvsInfo.m_sABMId);// 平台ID
		strcpy(pPaymentInfoCCR.m_sDescription,"划拨冲正");// 操作描述
		strcpy(pPaymentInfoCCR.m_sOrderState,"COF");
		pPaymentInfoCCR.m_lServID= lServId; // 被冲正业务流水的用户标识
		__DEBUG_LOG1_(0, "被冲正业务流水的用户标识lServId=[%ld]",lServId);
		sStructPaymentSeqInfo.m_lRbkPaymentSeq = lOptId; // 被冲正业务流水号
		__DEBUG_LOG1_(0, "被冲正业务流水号lOptId=[%ld]",lOptId);
		
		// 1.更新被冲正流水号的状态为C0R
		iRet = m_poSql->updateOperation(lOptId);
		if(iRet != 0)
		{
			__DEBUG_LOG0_(0, "被冲正业务流水号状态修改失败。");
			throw iRet;
		}
		// m_lPayAmount 冲正金额,怎么获取???
		/*
		// 2.插入划拨冲正业务流水记录, 状态C0F	
		iRet = m_poSql->InsertPaymentInfo(pPaymentInfoCCR,sStructPaymentSeqInfo);
		if(iRet != 0)
		{
			__DEBUG_LOG0_(0, "插入业务流水号失败。");
			throw iRet;
		}
		*/
		
		long lTotalAmount=0L;
		
		
		// 3.根据被冲正流水号查询余额划拨时所对应的余额来源
		iRet = m_poSql->qryBalanceSource(lOptId,vBalanceSourceInfo);
		if(iRet != 0)
		{
			__DEBUG_LOG0_(0, "查询被冲正业务流水号余额来源信息失败。");
			throw iRet;
		}
		
		for(vector<BalanceSourceInfo*>::iterator it=vBalanceSourceInfo.begin();it!=vBalanceSourceInfo.end();it++)
		{
			// 生成余额支出、来源支出流水
			bFlag = true;
			iRet = m_poSql->QueryPaySeq(sStructPaymentSeqInfo,bFlag);
			if(iRet != 0)
			{
				__DEBUG_LOG0_(0, "取业务流水号失败。");
				throw iRet;
			}
			
			// 取余额来源基本信息
			lBalanceSourceId = (*it)->m_lOperIncomeID; // 余额来源标识
			lAcctBalanceId = (*it)->m_lAcctBalanceId; // 余额帐本标识
			lAmount = (*it)->m_lAmount;	// 金额
			
			// 重写来源流水号,此处未生成新的来源记录
			sStructPaymentSeqInfo.m_lBalanceSourceSeq = lBalanceSourceId;
			
			// 4.更新余额来源的Balance
			sStructPaymentSeqInfo.m_lPaymentAmount = lAmount; // 付款金额,即来源记录中的剩余金额
			iRet = m_poSql->updateBalanceSource(sStructPaymentSeqInfo,(*it));
			if(iRet != 0)
			{
				__DEBUG_LOG0_(0, "更新被冲正业务流水号余额来源信息失败。");
				throw iRet;
			}
			// 5.做余额支出记录 ***
			m_sOperType.clear();
			m_sOperType="5UK";
			iRet = m_poSql->InsertBalancePayout(sStructPaymentSeqInfo,(*it),m_sOperType);
			if(iRet != 0)
			{
				__DEBUG_LOG0_(0, "插入被冲正业务流水号余额支出信息失败。");
				throw iRet;
			}
			// 6.做来源支出记录
			iRet = m_poSql->InsertBalanceSourcePayoutRela(sStructPaymentSeqInfo,(*it));
			if(iRet != 0)
			{
				__DEBUG_LOG0_(0, "插入被冲正业务流水号余额来源支出信息失败。");
				throw iRet;
			}
			// 7.更新余额帐本记录
			long ltmp = 0-lAmount;
			iRet = m_poSql->updateAcctBalance(lAcctBalanceId,ltmp);
			if(iRet != 0)
			{
				__DEBUG_LOG0_(0, "更新余额帐本信息失败。");
				throw iRet;
			}
			
			lTotalAmount +=ltmp;
		}
		
		// 2.插入划拨冲正业务流水记录, 状态C0F	
		pPaymentInfoCCR.m_lPayAmount = lTotalAmount;
		iRet = m_poSql->InsertPaymentInfo(pPaymentInfoCCR,sStructPaymentSeqInfo);
		if(iRet != 0)
		{
			__DEBUG_LOG0_(0, "插入业务流水号失败。");
			throw iRet;
		}
			
		/*
		// 查询支出信息
		iRet=m_poSql->qryPayoutInfo(lOldRequestId,vBalancePayOut);
		
		if(iRet != 0)
		{
			__DEBUG_LOG0_(0, "查询被冲正余额支出失败。");
			throw iRet;
		}
		
		for(vector<BalancePayoutInfo*>::iterator it=vBalancePayOut.begin();it!=vBalancePayOut.end();it++)
		{
			lAcctBalanceId = (*it)->m_lAcctBalanceId;
			lAmount = (*it)->m_lAmount;
			lOptId = (*it)->m_lOptId;
			lOperPayoutId = (*it)->m_lOperPayoutId;
			
			__DEBUG_LOG1_(0, "余额支出lAcctBalanceId=[%ld] ",lAcctBalanceId);
			__DEBUG_LOG1_(0, "余额支出lAmount=[%ld]",lAmount);
			__DEBUG_LOG1_(0, "余额支出lOptId=[%ld]",lOptId);
			__DEBUG_LOG1_(0, "余额支出ID[%ld]",lOperPayoutId);
			
			// 查询被冲正记录对应的余额来源,余额支出ID,来源支出关系表
			iRet = m_poSql->qryBalanceSource(lOptId,pBalanceSourceInfo);
			
			if(iRet!=0)
			{
				__DEBUG_LOG0_(0, "PaymentInfo::QryPayoutInfo 冲正记录余额来源不存在或查询失败");
				throw iRet;
			}
			
			
			// 更新余额来源,剩余金额+lAmount
			//pBalanceSourceInfo->m_lBalance = pBalanceSourceInfo->m_lBalance + lAmount;
			sStructPaymentSeqInfo.m_lPaymentAmount = -lAmount;		
			iRet = m_poSql->updateBalanceSource(sStructPaymentSeqInfo,pBalanceSourceInfo);
			
			// 更新余额支出记录状态10X
			iRet = m_poSql->updateBalancePayout(lOperPayoutId);
			if(iRet!=0)
			{
				__DEBUG_LOG0_(0, "更新余额支出记录状态10X失败");
				throw iRet;
			}
			
			
			// 余额来源和支出记录关系表 - 更新状态10X
			iRet = m_poSql->updateBalanceSourcePayoutRela(lOperPayoutId);
			if(iRet!=0)
			{
				__DEBUG_LOG0_(0, "余额来源和支出记录关系表 - 更新状态10X失败");
				throw iRet;
			}
			
			
			// 5.对应余额帐本表记录更新
			pAcctBalanceInfo->m_lAcctBalanceID = lAcctBalanceId;
			
			// 查询余额帐本
			iRet = m_poSql->qryAcctBalance(lAcctBalanceId,pAcctBalanceInfo);
			
			
			// 余额帐本金额
			iRet = m_poSql->updateAcctBalance(sStructPaymentSeqInfo,pAcctBalanceInfo);
			if(iRet!=0)
			{
				__DEBUG_LOG0_(0, "余额帐本金额更新失败");
				throw iRet;
			}	
		}
		*/
	}
	catch(TTStatus oSt) 
	{
		iRet=REVER_BALANCE_PAYOUT_TT_ERR;
		__DEBUG_LOG1_(0, "PaymentInfo::QryPayoutInfo oSt.err_msg=%s", oSt.err_msg);
	}
	catch(int &value ) 
	{
		iRet=value;
		__DEBUG_LOG1_(0, "PaymentInfo::QryPayoutInfo value=%d",value);
	}
	
	FreeObject(pAcctBalanceInfo);
	FreeObject(pBalanceSourceInfo);
	
	return iRet;
示例#15
0
// 支付冲正 
int PaymentInfo::ReversePayoutInfo(char *sOldRequestId,ReversePaySvc &oRvsInfo,vector<BalancePayoutInfo*> &vBalancePayOut)
{
	int iRet;
	
	long lOperPayoutId;
	long lAcctBalanceId;
	long lAmount;
	long lOptId;
	bool bFlag = false;
	
	StructPaymentSeqInfo  sStructPaymentSeqInfo={0};// 业务流水信息
	BalanceSourceInfo *pBalanceSourceInfo=NULL;
	
	AcctBalanceInfo *pAcctBalanceInfo=new AcctBalanceInfo;
	try
	{
		PaymentInfoALLCCR pPaymentInfoCCR={0};
		StructPaymentSeqInfo  sStructPaymentSeqInfo={0};
		// 生成业务流水号
		iRet = m_poSql->QueryPaySeq(sStructPaymentSeqInfo,bFlag);
		if(iRet != 0)
		{
			__DEBUG_LOG0_(0, "取业务流水号失败。");
			throw iRet;
		}
		
		strcpy(pPaymentInfoCCR.m_sOperateSeq ,oRvsInfo.sOperationSeq); // 外部流水号
		strcpy(pPaymentInfoCCR.m_sCapabilityCode,"0006"); // 能力编码
		strcpy(pPaymentInfoCCR.m_sServicePlatformID,oRvsInfo.sServicePlatformId);// 平台ID
		strcpy(pPaymentInfoCCR.m_sSpID,oRvsInfo.sSpId);// 商家ID
		strcpy(pPaymentInfoCCR.m_sSpName,oRvsInfo.sSpName);// 商家名称
		strcpy(pPaymentInfoCCR.m_sOrderState,"COF");
		strcpy(pPaymentInfoCCR.m_sDescription,"支付冲正");// 操作描述
		
		// todo:需增加根据外部流水号,查找业务流水号,记录被冲正业务流水号
		//char sForeignId[64]={0};
		
		//strcpy(sForeignId,ltoa(lOldRequestId));
		long lOptId;
		long lOldRequestId=0L;
		iRet = m_poSql->qryOptidByForeignId(sOldRequestId,lOptId);
		lOldRequestId = lOptId; // 
		
		__DEBUG_LOG0_(0, "根据外部流水查业务流水号");
		__DEBUG_LOG1_(0, "业务流水号:%d",lOptId);
		
		sStructPaymentSeqInfo.m_lRbkPaymentSeq = lOldRequestId; // 被冲正流水号 
		// 插入划拨冲正业务流水记录	
		/* 根据支出记录,统计冲正金额
		iRet = m_poSql->InsertPaymentInfo(pPaymentInfoCCR,sStructPaymentSeqInfo);
		if(iRet != 0)
		{
			__DEBUG_LOG0_(0, "插入业务流水号失败。");
			throw iRet;
		}
		*/
		
		// 1.更新被冲正流水号的状态为C0R
		iRet = m_poSql->updateOperation(lOptId);
		if(iRet != 0)
		{
			__DEBUG_LOG0_(0, "被冲正业务流水号状态修改失败。");
			throw iRet;
		}
		
		// 查询支出信息
		// todo:传入的应该是opt_id
		iRet=m_poSql->qryPayoutInfo(lOldRequestId,vBalancePayOut);
		
		if(iRet != 0)
		{
			__DEBUG_LOG0_(0, "查询被冲正余额支出失败。");
			throw iRet;
		}
		long lTotalAmount=0L;
		for(vector<BalancePayoutInfo*>::iterator it=vBalancePayOut.begin();it!=vBalancePayOut.end();it++)
		{
			lAcctBalanceId = (*it)->m_lAcctBalanceId;
			lAmount = (*it)->m_lAmount;
			lOptId = (*it)->m_lOptId;
			lOperPayoutId = (*it)->m_lOperPayoutId;
			lTotalAmount+=lAmount;// 被冲正总金额
			__DEBUG_LOG1_(0, "余额支出lAcctBalanceId=[%ld] ",lAcctBalanceId);
			__DEBUG_LOG1_(0, "余额支出lAmount=[%ld]",lAmount);
			__DEBUG_LOG1_(0, "余额支出lOptId=[%ld]",lOptId);
			__DEBUG_LOG1_(0, "余额支出ID[%ld]",lOperPayoutId);
			
			// 查询被冲正记录对应的余额来源,余额支出ID,来源支出关系表
			iRet = m_poSql->qryBalanceSource(lOptId,pBalanceSourceInfo);
			
			if(iRet!=0)
			{
				__DEBUG_LOG0_(0, "PaymentInfo::QryPayoutInfo 冲正记录余额来源不存在或查询失败");
				throw iRet;
			}
			
			
			// 更新余额来源,剩余金额+lAmount
			//pBalanceSourceInfo->m_lBalance = pBalanceSourceInfo->m_lBalance + lAmount;
			sStructPaymentSeqInfo.m_lPaymentAmount = -lAmount;		
			iRet = m_poSql->updateBalanceSource(sStructPaymentSeqInfo,pBalanceSourceInfo);
			
			// 更新余额支出记录状态10X
			iRet = m_poSql->updateBalancePayout(lOperPayoutId);
			if(iRet!=0)
			{
				__DEBUG_LOG0_(0, "更新余额支出记录状态10X失败");
				throw iRet;
			}
			
			
			// 余额来源和支出记录关系表 - 更新状态10X
			iRet = m_poSql->updateBalanceSourcePayoutRela(lOperPayoutId);
			if(iRet!=0)
			{
				__DEBUG_LOG0_(0, "余额来源和支出记录关系表 - 更新状态10X失败");
				throw iRet;
			}
			
			
			// 5.对应余额帐本表记录更新
			pAcctBalanceInfo->m_lAcctBalanceID = lAcctBalanceId;
			
			// 查询余额帐本
			iRet = m_poSql->qryAcctBalance(lAcctBalanceId,pAcctBalanceInfo);
			
			
			// 余额帐本金额
			iRet = m_poSql->updateAcctBalance(sStructPaymentSeqInfo,pAcctBalanceInfo);
			if(iRet!=0)
			{
				__DEBUG_LOG0_(0, "余额帐本金额更新失败");
				throw iRet;
			}	

	
		}
		
		pPaymentInfoCCR.m_lPayAmount = lTotalAmount;
		// 插入划拨冲正业务流水记录	
		iRet = m_poSql->InsertPaymentInfo(pPaymentInfoCCR,sStructPaymentSeqInfo);
		if(iRet != 0)
		{
			__DEBUG_LOG0_(0, "插入业务流水号失败。");
			throw iRet;
		}
	}
	catch(TTStatus oSt) 
	{
		iRet=REVERSE_PAYMENT_TT_ERR;
		__DEBUG_LOG1_(0, "PaymentInfo::QryPayoutInfo oSt.err_msg=%s", oSt.err_msg);
	}
	catch(int &value ) 
	{
		iRet=value;
		__DEBUG_LOG1_(0, "PaymentInfo::QryPayoutInfo value=%d",value);
	}
	
	FreeObject(pAcctBalanceInfo);
	FreeObject(pBalanceSourceInfo);
	
	return iRet;
示例#16
0
文件: clb.c 项目: mingpen/OpenNT
BOOL
ClbSetColumnWidths(
    IN HWND hWnd,
    IN int ControlId,
    IN LPDWORD Widths
    )

/*++

Routine Description:

    ClbSetColumnWidths sets the width of each column based on the supplied
    widths in characters. Note that the column on the far right extends to
    the edge of the Clb.

Arguments:

    hWnd        - Supplies the window handle for the parent window.
    ControlId   - Supplies the control id for this Clb for the supplied hWnd.
    Widths      - Supplies an array of widths, one less then the number of
                  columns, in characters.

Return Value:

    BOOL        - Returns TRUE if the widths were successfully adjusted.


--*/

{
    BOOL        Success;
    DWORD       Columns;
    LPCLB_INFO  ClbInfo;
    HWND        hWndClb;
    LONG        CharWidth;
    LONG        CharHeight;
    DWORD       i;
    LPLONG      WidthsInPixels;
    LONG        TotalPixels;
    HDC         hDCClientHeader;
    HD_ITEM     hdi;
    UINT        iRight;

    //
    // Validate arguments.
    //

    DbgHandleAssert( hWnd );
    DbgPointerAssert( Widths );

    //
    // Retrieve information for this ColumnListBox.
    //

    hWndClb = GetDlgItem( hWnd, ControlId );
    DbgHandleAssert( hWndClb );
    ClbInfo = RestoreClbInfo( hWndClb );
    DbgPointerAssert( ClbInfo );
    DbgAssert( CheckSignature( ClbInfo ));

    //
    // Get thd HDC for the header.
    //

    hDCClientHeader = GetDC( ClbInfo->hWndHeader );
    DbgHandleAssert( hDCClientHeader );

    //
    // Get the width of a character.
    //

    Success = GetCharMetrics(
                hDCClientHeader,
                &CharWidth,
                &CharHeight
                );
    DbgAssert( Success );

    //
    // Release the DC for the header.
    //

    Success = ReleaseDC( ClbInfo->hWndHeader, hDCClientHeader );
    DbgAssert( Success );

    //
    // Allocate an array of pixel widths, one for each column.
    //

    WidthsInPixels = AllocateObject( LONG, ClbInfo->Columns );
    DbgPointerAssert( WidthsInPixels );

    //
    // Compute the width of each column (not including the rightmost) in pixels,
    // and the total number of pixels used by these columns.
    //

    TotalPixels = 0;
    for( i = 0; i < ClbInfo->Columns - 1; i++ ) {

        WidthsInPixels[ i ] = Widths[ i ] * CharWidth;
        TotalPixels += WidthsInPixels[ i ];
    }

    //
    // The caller did not specify the width of the rightmost column.
    //

    if( Widths[ i ] == -1 ) {

        RECT    Rect;

        //
        // Set the width of the rightmost column to the remainder of the width
        // of the header window.
        //

        Success = GetClientRect(
                            ClbInfo->hWndHeader,
                            &Rect
                            );
        DbgAssert( Success );

        WidthsInPixels[ i ] = ( Rect.right - Rect.left ) - TotalPixels;

    } else {

        //
        // Set the width of the rightmost column to the value supplied
        // by the caller.
        //

        WidthsInPixels[ i ] = Widths[ i ] * CharWidth;
    }

    //
    // Tell the header window the width of each column.
    //

    hdi.mask = HDI_WIDTH;

    for( i = 0; i < ClbInfo->Columns - 1; i++ ) {

        hdi.cxy = WidthsInPixels[i];
        Success = Header_SetItem(ClbInfo->hWndHeader, i, &hdi);

        DbgAssert( Success );
    }

    //
    // Calc the array of right edges.
    //

    iRight = 0;

    for( i = 0; i < ClbInfo->Columns - 1; i++ ) {
        iRight += WidthsInPixels[i];
        ClbInfo->Right[i] = iRight;
    }

    //
    // Free the array of pixel widths.
    //

    Success = FreeObject( WidthsInPixels );
    DbgAssert( Success );

    return TRUE;
}
示例#17
0
文件: drives.c 项目: mingpen/OpenNT
BOOL
FreeDriveInfoStructures(
    HWND hWnd
    )
/*++

Routine Description:

    Walks the tree in the tree view window, freeing DRIVE_INFO objects.

Arguments:

    hWnd - tab window handle

Return Value:

    BOOL    true if successful
--*/

{
   HWND hWndTree = GetDlgItem(hWnd, IDC_TV_DRIVE_LIST);
   TV_ITEM tvi;
   TV_ITEM tviChild;
   LPDRIVE_INFO lpdi;

   tvi.mask = tviChild.mask = TVIF_HANDLE | TVIF_PARAM;

   tvi.hItem = TreeView_GetRoot( hWndTree );
   tvi.hItem = TreeView_GetChild( hWndTree, tvi.hItem);

   //
   // Walk the TreeView, freeing memory associated with the tvis.item.lParam
   //

   while( tvi.hItem ){

      if ( TreeView_GetItem(hWndTree, &tvi) ){

         //
         // If we have found a pointer to a DRIVE_INFO, free it
         //

         lpdi = (LPDRIVE_INFO) tvi.lParam;

         if( ( lpdi != NULL ) && ( CheckSignature( lpdi ) ) ){

             FreeObject( lpdi );

         }

      }

      //
      // Check the children as well
      //

      tviChild.hItem = TreeView_GetChild( hWndTree, tvi.hItem);

      while( tviChild.hItem ) {

         if ( TreeView_GetItem(hWndTree, &tviChild) ){

            //
            // If we have found a pointer to a DRIVE_INFO, free it
            //

            lpdi = (LPDRIVE_INFO) tviChild.lParam;

            if( ( lpdi != NULL ) && ( CheckSignature( lpdi ) ) ){

               FreeObject( lpdi );

            }
         }

         tviChild.hItem = TreeView_GetNextSibling(hWndTree, tviChild.hItem);

      }

      //
      // Get next tree item
      //

      tvi.hItem = TreeView_GetNextSibling(hWndTree, tvi.hItem);

   }

   return(TRUE);

}
示例#18
0
asCScriptObject::~asCScriptObject()
{
	if( extra )
	{
		if( extra->weakRefFlag )
		{
			extra->weakRefFlag->Release();
			extra->weakRefFlag = 0;
		}

		if( objType->engine )
		{
			// Clean the user data
			for( asUINT n = 0; n < extra->userData.GetLength(); n += 2 )
			{
				if( extra->userData[n+1] )
				{
					for( asUINT c = 0; c < objType->engine->cleanScriptObjectFuncs.GetLength(); c++ )
						if( objType->engine->cleanScriptObjectFuncs[c].type == extra->userData[n] )
							objType->engine->cleanScriptObjectFuncs[c].cleanFunc(this);
				}
			}
		}

		asDELETE(extra, SExtra);
	}

	// The engine pointer should be available from the objectType
	asCScriptEngine *engine = objType->engine;

	// Destroy all properties
	// In most cases the members are initialized in the order they have been declared, 
	// so it's safer to uninitialize them from last to first. The order may be different
	// depending on the use of inheritance and or initialization in the declaration.
	// TODO: Should the order of initialization be stored by the compiler so that the 
	//       reverse order can be guaranteed during the destruction?
	for( int n = (int)objType->properties.GetLength()-1; n >= 0; n-- )
	{
		asCObjectProperty *prop = objType->properties[n];
		if( prop->type.IsObject() )
		{
			// Destroy the object
			asCObjectType *propType = prop->type.GetObjectType();
			if( prop->type.IsReference() || propType->flags & asOBJ_REF )
			{
				void **ptr = (void**)(((char*)this) + prop->byteOffset);
				if( *ptr )
				{
					FreeObject(*ptr, propType, engine);
					*(asDWORD*)ptr = 0;
				}
			}
			else
			{
				// The object is allocated inline. As only POD objects may be allocated inline
				// it is not a problem to call the destructor even if the object may never have
				// been initialized, e.g. if an exception interrupted the constructor.
				asASSERT( propType->flags & asOBJ_POD );

				void *ptr = (void**)(((char*)this) + prop->byteOffset);
				if( propType->beh.destruct )
					engine->CallObjectMethod(ptr, propType->beh.destruct);
			}
		}
	}

	objType->Release();
	objType = 0;

	// Something is really wrong if the refCount is not 0 by now
	asASSERT( refCount.get() == 0 );
}