miércoles, 6 de junio de 2012

Mostrar Código de Barras Vertical



static container MostrarBarCodeVertical()
{
System.Drawing.Bitmap   BarcodeBitmap;
System.Drawing.Graphics BarcodeGraphics;

int     dx=30;
int     dy=300;

str     barcodetxt;
Image   BarcodeImage;

System.Drawing.Pen                TxtPen;
System.Drawing.Brush              TxtBrush;

System.Drawing.Brush              DrawBrush;

System.Drawing.StringFormat       StringFormat;
System.Drawing.StringAlignment    StringAlignment;

System.Drawing.Font BarcodeFont = new System.Drawing.Font('BC C128 Medium',22,System.Drawing.FontStyle::Regular);

Int64             BarcodeBitmapPtr;
//BarcodeCode39    MyBarcode = BarcodeCode39::construct();
BarcodeCode128 MyBarcode=BarcodeCode128::construct();

    ;

BarcodeImage = new Image();

BarcodeBitmap = new System.Drawing.Bitmap(dx,dy);
BarcodeGraphics = System.Drawing.Graphics::FromImage(BarcodeBitmap);

barcodetxt="123456789012345678901234567890";
MyBarCode.string(true,barcodetxt);
MyBarCode.encode();
barcodetxt=MyBarCode.barcodeStr();

// clear canvas
DrawBrush = System.Drawing.Brushes::get_White();
BarcodeGraphics.FillRectangle(DrawBrush,0,0,any2int(dx),any2int(dy));

// set barcode text
TxtBrush = System.Drawing.Brushes::get_Black();
TxtPen = new System.Drawing.Pen(TxtBrush);

// set text alignment
StringFormat = new System.Drawing.StringFormat();
StringAlignment = System.Drawing.StringAlignment::Center;
StringFormat.set_Alignment(StringAlignment);
StringFormat.set_LineAlignment(StringAlignment);

// init rotation
BarcodeGraphics.TranslateTransform(any2int(dx),0);
BarcodeGraphics.RotateTransform(90);
  //  BarcodeGraphics.RotateTransform(

// draw text
BarcodeGraphics.DrawString(barcodetxt, BarcodeFont,TxtBrush, 0,0);

// transfer image to Ax
BarcodeBitmapPtr=BarcodeBitmap.GetHbitmap();
BarcodeImage.importBitmap(BarcodeBitmapPtr);

BarcodeImage.resize(dx+10,dy,InterpolationMode::InterpolationModeNearestNeighbor);
//BarcodeImage.saveImage("c:\\prueba.bmp");
return BarcodeImage.getData();
}

martes, 8 de mayo de 2012

Obtener Dimensiones Ax 2012


  container dimensionValueIn;
   
    ;
   

print AxdDimensionUtil::getMultiTypeAccountId(enumName2Id("LedgerJournalACType"),0,["ABTECH-MTY-Produccion","11161004"]);
print AxdDimensionUtil::getDimensionAttributeValueSetId([2,"División","ABTECH","Sucursal","MTY"]);
  dimensionValueIn=AxdDimensionUtil::getDimensionAttributeValueSetValue(AxdDimensionUtil::getDimensionAttributeValueSetId([2,"División","ABTECH","Sucursal","MTY"]));
 
   pause;

miércoles, 28 de marzo de 2012

Crear y leer Archivos Dynamics ax 2012

static void Job_File_IO_TextIo_Write_Read(Args _args)
{
    TextIo txIoRead,
         txIoWrite;
    FileIOPermission fioPermission;
    container containFromRead;
    int xx,
        iConLength;
    str sTempPath,
        sFileName = "Test_File_IO.txt",
        sOneRecord;
    ;
    // Get the temporary path.
    sTempPath = WINAPI::getTempPath();
    info("File is at: " + sTempPath + sFileName);

    // Assert permission.
    fioPermission = new FileIOPermission
        (sTempPath + sFileName ,"RW");
    fioPermission.assert();
 
    // If the test file already exists, delete it.
    if (WINAPI::fileExists(sFileName))
    {
        WINAPI::deleteFile(sTempPath + sFileName);
    }
    
    // Open a test file for writing.
    // "W" mode overwrites existing content, or creates the file.
    txIoWrite = new TextIo( sTempPath + sFileName ,"W");

    // Write records to the file.
    txIoWrite.write("Hello        World.");
    txIoWrite.write("The sky is blue.");
    txIoWrite.write("");
    txIoWrite.write("// EOFile");

    // Close the test file.
    txIoRead = null;

    // Open the same file for reading.
    txIoRead = new TextIo(sTempPath + sFileName ,"R");
    // Read the entire file into a container.
    containFromRead = txIoRead.read();

    // Loop through the container of file records.
    while (containFromRead)
    {
        sOneRecord = "";
        iConLength = conLen(containFromRead);
        // Loop through the token in the current record.
        for (xx=1; xx <= iConLength; xx++)
        {
            if (xx > 1) sOneRecord += " ";
            sOneRecord += conPeek(containFromRead ,xx);
        }
        info(sOneRecord);

        // Read the next record from the container.
        containFromRead = txIoRead.read();
    }

    // Close the test file.
    txIoRead = null;
    // Delete the test file.
    WINAPI::deleteFile(sTempPath + sFileName);

    // revertAssert is not really necessary here,
    // because the job (or method) is ending.
    CodeAccessPermission::revertAssert();
}
Fuente: http://msdn.microsoft.com/en-us/library/cc967403.aspx

martes, 13 de marzo de 2012

Crear Asiento Ax 2012

 LedgerVoucher   lv;
    NumberSeq       numberSeq;
   currencyExchangeHelper currencyExchangeHelper ;
    LedgerVoucherTransObject LedgerVoucherTransObject;
   LedgerVoucherObject LedgerVoucherObject;
    ;
    currencyExchangeHelper = CurrencyExchangeHelper::newExchangeDate(Ledger::current(), today());
    ttsBegin;
    numberSeq = NumberSeq::newGetVoucher(LedgerParameters::numRefLedgerExchAdjVoucher());

    lv = LedgerVoucher::newLedgerPost(
        DetailSummary::Detail,
        SysModule::Ledger,
        numberSeq.parmNumberSequenceCode());

    LedgerVoucherObject= LedgerVoucherObject::newVoucher(numberSeq.voucher(),today(), SysModule::Ledger,LedgerTransType::Invent);
    lv.addVoucher(LedgerVoucherObject);

    LedgerVoucherTransObject=LedgerVoucherTransObject::newTransactionAmountDefault(
            LedgerVoucherObject,//("ABI-000437"),
            LedgerPostingType::LedgerJournal,
            DimensionDefaultingService::serviceCreateLedgerDimension(5637157573),           // Ledger account
            Ledger::find(Ledger::current()).AccountingCurrency,
            2004,              // Amount
            currencyExchangeHelper);
     lv.addTrans(LedgerVoucherTransObject);

     LedgerVoucherTransObject=LedgerVoucherTransObject::newTransactionAmountDefault(
            LedgerVoucherObject,//("ABI-000437"),
            LedgerPostingType::LedgerJournal,
            DimensionDefaultingService::serviceCreateLedgerDimension(5637158025),           // Ledger account
            Ledger::find(Ledger::current()).AccountingCurrency,
            -2004,              // Amount
            currencyExchangeHelper);
     lv.addTrans(LedgerVoucherTransObject);
    lv.end();
    ttsCommit

jueves, 9 de febrero de 2012

AifQueueManager Manual

static void AIFProcessing(Args _args)
{
AifOutboundProcessingService outboundService = new AifOutBoundProcessingService();
AifGatewaySendService sendService = new AifGatewaySendService();
;
outboundService.run();
sendService.run();
}