将图像上传到序列号 [英] Upload Images to Serial Number

查看:59
本文介绍了将图像上传到序列号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在InItemLotserial表中创建了一个自定义NOTEID字段,以上传自定义页面中每个序列号的图像。

I have created a custom NOTEID field in InItemLotserial Table to upload images for each serial number in a custom page. It works fine without any issue.

I已经写了一个处理页面来更新图像以获取现有的序列号。

I have wrote a processing page to update the images for existing serial numbers.

protected void AttachImage(InfoINItemLotSerialImport row, INItemLotSerial ser, InventoryItem itm)
    {
        string imageurl = row.ImageSourceUrl;
        string imageType = row.ImageType;
        string sRetVal = string.Empty;
        if (itm != null)
        {
            if (ser != null)
            {
                try
                {
                    WebClient wc = new WebClient();
                    byte[] buffer = wc.DownloadData(imageurl);
                    //MemoryStream ms = new MemoryStream(bytes);

                    string fileName = Path.GetFileName(imageurl);
                    fileName = string.Format("Serial Number attribute ({0} {1})\\{2}", itm.InventoryID, ser.LotSerialNbr, fileName);
                    PX.SM.FileInfo fileinfo = null;
                    PX.SM.UploadFileMaintenance filegraph = PXGraph.CreateInstance<PX.SM.UploadFileMaintenance>();
                    fileinfo = new PX.SM.FileInfo(fileName, null, buffer);
                    fileinfo.IsPublic = true;
                    if (filegraph.SaveFile(fileinfo))
                    {
                        ItemLotSerialMnt oLotSerMnt = PXGraph.CreateInstance<ItemLotSerialMnt>();
                        oLotSerMnt.lotserailrecdata.Current = ser;
                        oLotSerMnt.lotserial.Current = ser;
                        PXNoteAttribute.SetFileNotes(oLotSerMnt.lotserailrecdata.Cache, oLotSerMnt.lotserailrecdata.Current, fileinfo.UID.Value);
                        PXNoteAttribute.SetNote(oLotSerMnt.lotserailrecdata.Cache, oLotSerMnt.lotserailrecdata.Current, "");
                        sRetVal = fileinfo.Name;
                    }

                }
                catch
                {

                }
            }
        }
    }

它将数据上传到UploadFile表中,并且输入看起来不错。我可以使用URL来访问图像,但是串行页面的文件部分中没有显示该图像。

It uploads the data into UploadFile table and entry looks fine. I can access the image using the URL, but the same is not reflecting in file section of serial page.

acumatica如何将文件与屏幕链接?

How acumatica links the file with the screen?

更新1

#region UsrNoteID
    public abstract class usrNoteID : PX.Data.IBqlField
    {
    }
    protected Guid? _UsrNoteID;
    [PXNote()]
    public virtual Guid? UsrNoteID
    {
        get
        {
            return this._UsrNoteID;
        }
        set
        {
            this._UsrNoteID = value;
        }
    }
    #endregion


推荐答案

Accumatica支持帮助我解决了该问题。我错过了要保存的触发持久事件。

Accumatica support helped me to fix the issue. I have missed firing persist event to save.

            if (filegraph.SaveFile(fileinfo))
            {
                ItemLotSerialMnt oLotSerMnt = PXGraph.CreateInstance<ItemLotSerialMnt>();
                oLotSerMnt.lotserailrecdata.Current = ser;
                oLotSerMnt.lotserial.Current = ser;
                PXNoteAttribute.SetFileNotes(oLotSerMnt.lotserailrecdata.Cache, oLotSerMnt.lotserailrecdata.Current, fileinfo.UID.Value);
                PXNoteAttribute.SetNote(oLotSerMnt.lotserailrecdata.Cache, oLotSerMnt.lotserailrecdata.Current, "");
                sRetVal = fileinfo.Name;
                oLotSerMnt.Persist();
            }

oLotSerMnt.Persist();

这篇关于将图像上传到序列号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆