彩票走势图

【示例教程】使用leadtools的WCF接口功能实现从web端上传Dicom影像文件

原创|使用教程|编辑:黄竹雯|2018-02-06 14:30:51.000|阅读 485 次

概述:本篇教程演示使用leadtools的WCF接口功能实现从web端上传Dicom影像文件。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

相关链接:

 
leadtools为web端提供了wcf接口来供用户可以登录pacs系统,检索,查看以及上传影像。本篇博客讲解如何创建一个网页来实现上传功能,通过WCF进行dicom文件的上传时,是将dicom文件转换为base64数据流,分段进行传输。
 
本篇博客运行的前提是已经部署完成Leadtools HTML5 Web Viewer,可以正常浏览。参考//pclwef.cn/article/2018/2/6/27757.html
 
在部署完成后,将下面的代码复制到一个HTML文件中,即可运行进行测试。另外需要添加html文件所需的jquery.min.js到同文件夹路径下。
<head>
    <meta charset="UTF-8">
</head>

<form onsubmit="return false;">
    <input type="hidden" name="file_base64" id="file_base64">
    <input type="file" id="fileup" multiple="multiple">
    <input type="submit" value="submit" onclick="$.post('./uploader.php', $(this).parent().serialize());">
    <div>
        <div id="msg"></div>
    </div>
</form>
<script src="scripts/jquery.min.js"></script>
<script>

    $(document).ready(function () {
        authcookie = login();
        document.cookie = "authcookie=" + authcookie;
        $("#fileup").change(function () {
            getauthcookie("authcookie");
            filelist = this.files;
            file = filelist[fileindex];
            upload(file);
        });
    });
    var authcookie;//保存authcookie
    var filelist;//上传文件列表
    var file;//当前上传文件
    var tempfile = "";//临时文件名称
    var position = 0;
    var size = 40000;//分段大小
    var done = false;
    var fileindex=0;//当前上传文件序列号

    function upload(tempfile) {
        if(position==0)
            done=false;
        var reader = new FileReader();
        if (file.size > position + 40000)
            reader.readAsArrayBuffer(file.slice(position, position + 40000));
        else 
            reader.readAsArrayBuffer(file.slice(position, file.size));
        reader.onload = function (e) {
            if (e.target.readyState === 2) {
                var base64string = base64ArrayBuffer(e.target.result);
                var data = {
                    authenticationCookie: authcookie,
                    dicomData: base64string,
                    fileName: tempfile,
                    status: position==0?"start":"append"
                };
                tempfile = senddata(JSON.stringify(data));
                if (!done) {
                    position += 40000;
                    upload(tempfile);
                    if (position+40000>file.size)
                        done = true;
                }
                else {
                    var data = {
                        authenticationCookie: authcookie,
                        dicomData: "",
                        fileName: tempfile,
                        status: "done"
                    };
                    tempfile = senddata(JSON.stringify(data));
                    position = 0;
                    $("#msg").html($("#msg").html()+""+(fileindex+1)+"个文件已经上传完成</p>");
                    fileindex += 1;
                    if (fileindex < filelist.length) {
                        file = filelist[fileindex];
                        upload(tempfile);
                    }
                    else {
                        fileindex = 0;
                        $("#msg").html($("#msg").html() + "文件全部已经上传完成</p>");
                    }

                }
            }

        };
        

    }

function senddata(data) {
    var result;
    $.ajax({
        type:"post",
        url: "//localhost/MedicalViewerService19/StoreService.svc/UploadDicomImage",
        data: data,
        contentType: "application/json",
        dataType: "json",
        success: function(data){result= data},
        async: false

    });
    return result;

}

function login() {
    var auth;
    var logininfo = { userName: "a", password: "a", userData: "" };
    $.ajax({
        type: "post",
        url: "//localhost/MedicalViewerService19/AuthenticationService.svc/AuthenticateUser",
        data: JSON.stringify(logininfo),
        contentType: "application/json",
        dataType: "text",
        success: function (data) { auth= data },
        async: false

    });
    return auth;

}

function query() {
    
}

function getauthcookie() {
    document.cookie.split(";").forEach(function (val, index) {
        var index = val.indexOf("=");
        if ($.trim(val.substring(0, index)) == "authcookie") {
            authcookie = $.trim(val.substring(index + 1, val.length));
        }


    });
    return "";
}

function base64ArrayBuffer(arrayBuffer) {
    var base64 = '';
    var encodings = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';

    var bytes = new Uint8Array(arrayBuffer);
    var byteLength = bytes.byteLength;
    var byteRemainder = byteLength % 3;
    var mainLength = byteLength - byteRemainder;

    var a, b, c, d;
    var chunk;

    // Main loop deals with bytes in chunks of 3
    for (var i = 0; i < mainLength; i = i + 3) {
        // Combine the three bytes into a single integer
        chunk = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];

        // Use bitmasks to extract 6-bit segments from the triplet
        a = (chunk & 16515072) >> 18; // 16515072 = (2^6 - 1) << 18
        b = (chunk & 258048) >> 12; // 258048   = (2^6 - 1) << 12
        c = (chunk & 4032) >> 6; // 4032     = (2^6 - 1) << 6
        d = chunk & 63;               // 63       = 2^6 - 1

        // Convert the raw binary segments to the appropriate ASCII encoding
        base64 += encodings[a] + encodings[b] + encodings[c] + encodings[d];
    }

    // Deal with the remaining bytes and padding
    if (byteRemainder == 1) {
        chunk = bytes[mainLength]

        a = (chunk & 252) >> 2; // 252 = (2^6 - 1) << 2

        // Set the 4 least significant bits to zero
        b = (chunk & 3) << 4; // 3   = 2^2 - 1

        base64 += encodings[a] + encodings[b] + '==';
    } else if (byteRemainder == 2) {
        chunk = (bytes[mainLength] << 8) | bytes[mainLength + 1];

        a = (chunk & 64512) >> 10; // 64512 = (2^6 - 1) << 10
        b = (chunk & 1008) >> 4; // 1008  = (2^6 - 1) << 4

        // Set the 2 least significant bits to zero
        c = (chunk & 15) << 2 // 15    = 2^4 - 1

        base64 += encodings[a] + encodings[b] + encodings[c] + '=';
    }

    return base64;
}



</script>

百厂年货节,全场6折起


标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn


为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
相关产品
LEADTOOLS Imaging Pro Developer Toolkit

20多年的老牌图像处理控件,支持TWAIN扫描、200多种图像效果、150多种图像格式…

LEADTOOLS Document Suite Developer Toolkit

LEADTOOLS Document Imaging Suite SDK是LEADTOOLS SDK中各种特点的精选组合,这套强大的工具利用了LEAD行业领先的图像处理技术来智能地识别文档的特征,而根据文档的特征可以识别扫描的或传真的任何类型的表格图像。

LEADTOOLS Document Imaging Developer Toolkit

多语言的文档图像处理控件,支持光符识别处理、条形码扫描识别等。

LEADTOOLS Medical Developer Toolkit

LEADTOOLS Medical Imaging是一款医疗成像控件,包含了一些精心挑选的、经过优化的特性,可以满足医疗成像应用程序开发的特殊需要。

LEADTOOLS Medical Imaging Suite Developer Toolkit

LEADTOOLS Medical Imaging Suite帮您开发功能强大的PACS和医学成像应用程序

扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP