Exemplo n.º 1
0
        public string exportData(WebReference.AttachmentItemInfo info)
        {
            int offset = 0;

            WebReference.getAttachmentRequest  req;
            WebReference.getAttachmentResponse resp;

            String fileName = Guid.NewGuid().ToString();
            // String path = "c:\\temp\\" + info.name;
            String path = HttpContext.Current.Server.MapPath("~/TemporaryFiles/") + fileName + System.IO.Path.GetExtension(info.name);

            System.IO.FileStream   fs = new System.IO.FileStream(path, System.IO.FileMode.Create);
            System.IO.BinaryWriter fw = new System.IO.BinaryWriter(fs);

            for (;;)
            {
                req        = new WebReference.getAttachmentRequest();
                req.id     = info.id.Value;
                req.length = 6144;
                req.offset = offset;
                resp       = ws.getAttachmentRequestMessage(req);
                if (0 != resp.status.code)
                {
                    break;
                }
                fw.Write(resp.part.Value);
                offset = resp.part.offset;
                if (0 == offset)
                {
                    break;
                }
            }
            fs.Close();
            path = path.Replace(HttpContext.Current.Request.ServerVariables["APPL_PHYSICAL_PATH"], String.Empty);
            return(path);
        }