コード例 #1
0
/**
 * Create XML document to request 'staff' report from the 'PERCo_S20_SDK::IExchangeMain'.
 *
 * Parameters:
 * None.
 *
 * Returns:
 * XML document instance.
 */
ATL::CComPtr<IXMLDOMDocument2> perco_exchange::getStaffRequest() const
{
    ATL::CComPtr<IXMLDOMDocument2> document;
    if (SUCCEEDED(document.CoCreateInstance(CLSID_DOMDocument60, nullptr, CLSCTX_INPROC_SERVER)))
    {
        ATL::CComPtr<IXMLDOMProcessingInstruction> processingInstruction;
        if (SUCCEEDED(document->createProcessingInstruction(
            TEXT("xml"), TEXT("version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\""), &processingInstruction)))
        {
            document->appendChild(processingInstruction, nullptr);
            // Create root <documentrequest> element.
            ATL::CComPtr<IXMLDOMElement> documentRequest;
            if (SUCCEEDED(document->createElement(TEXT("documentrequest"), &documentRequest)))
            {
                ATL::CComPtr<IXMLDOMAttribute> attribute;
                if (SUCCEEDED(document->createAttribute(TEXT("type"), &attribute)))
                {
                    ATL::CComVariant value(TEXT("staff"));
                    if (SUCCEEDED(attribute->put_value(value)) &&
                        SUCCEEDED(documentRequest->setAttributeNode(attribute, nullptr)))
                    {
                        attribute.Release();
                        if (SUCCEEDED(document->createAttribute(TEXT("mode_display"), &attribute)))
                        {
                            value = TEXT("employ_and_dismiss");
                            if (SUCCEEDED(attribute->put_value(value)) &&
                                SUCCEEDED(documentRequest->setAttributeNode(attribute, nullptr)))
                            {
                                if (FAILED(document->appendChild(documentRequest, nullptr)))
                                {
                                    document.Release();
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return document;
}
コード例 #2
0
/**
* Create XML document to send 'sendcommands' request via the 'PERCo_S20_SDK::IExchangeMain'.
*
* Parameters:
 * >szDoor
 * Path to lock device for the door.
*
* Returns:
* XML document instance.
*/
ATL::CComPtr<IXMLDOMDocument2> perco_exchange::getSendCommandsRequest(_In_ STLADD string_unique_ptr_t&& szDoor) const
{
    ATL::CComPtr<IXMLDOMDocument2> document;
    if (SUCCEEDED(document.CoCreateInstance(CLSID_DOMDocument60, nullptr, CLSCTX_INPROC_SERVER)))
    {
        ATL::CComPtr<IXMLDOMProcessingInstruction> processingInstruction;
        if (SUCCEEDED(document->createProcessingInstruction(
            TEXT("xml"), TEXT("version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\""), &processingInstruction)))
        {
            document->appendChild(processingInstruction, nullptr);
            // Create root <documentrequest> element.
            ATL::CComPtr<IXMLDOMElement> documentRequest;
            if (SUCCEEDED(document->createElement(TEXT("documentrequest"), &documentRequest)))
            {
                ATL::CComPtr<IXMLDOMAttribute> attribute;
                if (SUCCEEDED(document->createAttribute(TEXT("type"), &attribute)))
                {
                    ATL::CComVariant value(TEXT("sendcommands"));
                    if (SUCCEEDED(attribute->put_value(value)) &&
                        SUCCEEDED(documentRequest->setAttributeNode(attribute, nullptr)) &&
                        SUCCEEDED(document->appendChild(documentRequest, nullptr)))
                    {
                        attribute.Release();
                        ATL::CComPtr<IXMLDOMElement> login;
                        if (SUCCEEDED(document->createElement(TEXT("login"), &login)) &&
                            SUCCEEDED(document->createAttribute(TEXT("loginname"), &attribute)))
                        {
                            value = TEXT("login name");
                            if (SUCCEEDED(attribute->put_value(value)) &&
                                SUCCEEDED(login->setAttributeNode(attribute, nullptr)) &&
                                SUCCEEDED(documentRequest->appendChild(login, nullptr)))
                            {
                                ATL::CComPtr<IXMLDOMElement> command;
                                if (SUCCEEDED(document->createElement(TEXT("command"), &command)))
                                {
                                    attribute.Release();
                                    if (SUCCEEDED(document->createAttribute(TEXT("commandnumber"), &attribute)))
                                    {
                                        // cmd #120 is "unlock device reader".
                                        value = "120";
                                        if (SUCCEEDED(attribute->put_value(value)))
                                        {
                                            command->setAttributeNode(attribute, nullptr);
                                        }
                                    }
                                    attribute.Release();
                                    if (SUCCEEDED(document->createAttribute(TEXT("commandname"), &attribute)))
                                    {
//                                        value = L"Открыть (разблокировать) ИУ";
                                        value = L"";
                                        if (SUCCEEDED(attribute->put_value(value)))
                                        {
                                            command->setAttributeNode(attribute, nullptr);
                                        }
                                    }
                                    attribute.Release();
                                    if (SUCCEEDED(document->createAttribute(TEXT("commandpath"), &attribute)))
                                    {
                                        value = szDoor->c_str();
                                        if (SUCCEEDED(attribute->put_value(value)))
                                        {
                                            command->setAttributeNode(attribute, nullptr);
                                        }
                                    }
                                    attribute.Release();
                                    if (SUCCEEDED(document->createAttribute(TEXT("devicename"), &attribute)))
                                    {
//                                        value = L"Считыватель №2";
                                        value = L"";
                                        if (SUCCEEDED(attribute->put_value(value)))
                                        {
                                            command->setAttributeNode(attribute, nullptr);
                                        }
                                    }
                                    attribute.Release();
                                    if (SUCCEEDED(document->createAttribute(TEXT("typename"), &attribute)))
                                    {
//                                        value = L"ReaderTI1_";
                                        value = L"";
                                        if (SUCCEEDED(attribute->put_value(value)))
                                        {
                                            command->setAttributeNode(attribute, nullptr);
                                        }
                                    }
                                    if (SUCCEEDED(login->appendChild(command, nullptr)))
                                    {
                                        ATL::CComPtr<IXMLDOMElement> commandAttributes;
                                        if (SUCCEEDED(
                                            document->createElement(TEXT("command_attributes"), &commandAttributes)) &&
                                            SUCCEEDED(command->appendChild(commandAttributes, nullptr)))
                                        {
                                            ATL::CComPtr<IXMLDOMElement> commandAttribute;
                                            if (SUCCEEDED(
                                                document->createElement(TEXT("command_attribute"), &commandAttribute)))
                                            {
                                                attribute.Release();
                                                if (SUCCEEDED(
                                                    document->createAttribute(TEXT("displayname"), &attribute)))
                                                {
//                                                    value = L"Время разблокировки";
                                                    value = L"";
                                                    if (SUCCEEDED(attribute->put_value(value)))
                                                    {
                                                        commandAttribute->setAttributeNode(attribute, nullptr);
                                                    }
                                                }
                                                attribute.Release();
                                                if (SUCCEEDED(document->createAttribute(TEXT("value"), &attribute)))
                                                {
                                                    value = L"5";
                                                    if (SUCCEEDED(attribute->put_value(value)))
                                                    {
                                                        commandAttribute->setAttributeNode(attribute, nullptr);
                                                    }
                                                }
                                                attribute.Release();
                                                if (SUCCEEDED(
                                                    document->createAttribute(TEXT("rangeindex"), &attribute)))
                                                {
                                                    value = L"1";
                                                    if (SUCCEEDED(attribute->put_value(value)))
                                                    {
                                                        commandAttribute->setAttributeNode(attribute, nullptr);
                                                    }
                                                }
                                                if (FAILED(commandAttributes->appendChild(commandAttribute, nullptr)))
                                                {
                                                    document.Release();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    szDoor.reset();
    return document;
}