Exemplo n.º 1
0
        private void OnFileUploadReq(Datagram datagram)
        {
            FileUploadReq req = datagram.UnSerialData <FileUploadReq>();

            Upload upload    = new Upload(FileRootPath + "\\" + datagram.Sender.ToString(), req.Path, req.Name, req.Size);
            Guid   upload_id = Guid.NewGuid();

            if (FileCache.TryAdd(upload_id, upload))
            {
                FileUploadRes res = new FileUploadRes
                {
                    UploadID = upload_id
                };
                datagram.DataType    = DatagramType.Client;
                datagram.MessageType = CloudDatagramDefine.FileUploadRes;

                datagram.Datas = res.ToByteArray();
                if (!Send(datagram.ToByteArray()))
                {
                    Notify(IKXTServer.LogLevel.Error, "数据发送异常");
                    Close();
                }
            }
            else
            {
                upload.Clear();
            }
        }
Exemplo n.º 2
0
        void IDataSender.FileUpload(Guid request_id, FileUploadReq req)
        {
            Datagram datagram = new Datagram
            {
                DataType    = DatagramType.Cloud,
                MessageType = CloudDatagramDefine.FileUploadReq,
                RequestID   = request_id,
                Datas       = req.ToByteArray()
            };

            if (!Send(datagram))
            {
                RunningDatas.InfoNotify("网络连接失败 请重启软件后重试");
            }
        }