/// <summary>
        /// 多媒体插入一条记录
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public string InsertMultimedia(MultimediaAttachmentInput input)
        {
            AttachmentEntity att = new AttachmentEntity
            {
                Id           = Guid.NewGuid().ToString(),
                FKey         = input.FKey,
                PhysicalName = input.PhysicalName,
                LogicName    = input.LogicName,
                FileSize     = input.FileSize,
                Extension    = input.Extension,
                Sn           = input.Sn,
                iState       = 1,
                CreateTime   = DateTime.Now,
                CreateName   = input.CreateName,
                PhysicalPath = input.PhysicalPath,
                HttpPath     = input.HttpPath,
                TypeCode     = input.TypeCode
            };

            try
            {
                return(_iAttachmentRepository.InsertAndGetId(att));
            }
            catch (Exception)
            {
                return(null);
            }
        }
示例#2
0
        private void loadAttachment(int id)
        {
            string fp = "";

            try
            {
                AttachmentBL     attachmentBL = new AttachmentBL();
                AttachmentEntity entity       = attachmentBL.getById(id);
                string           fileName     = entity.Tables[0].Rows[0][AttachmentEntity.FIELD_FILE_NAME].ToString();
                try
                {
                    fileName = fileName.Substring(fileName.LastIndexOf("\\")).Replace("\\", "");
                }
                catch (Exception e) { }
                byte[] imageData = (byte[])entity.Tables[AttachmentEntity.TableName].Rows[0][AttachmentEntity.FIELD_CONTENT];

                string s = Application.ExecutablePath;
                fp  = s.Substring(0, s.LastIndexOf("\\")) + "\\tmp\\";
                fp += fileName;
                File.WriteAllBytes(fp, imageData);

                Process.Start(fp);
            }
            catch (Exception e)
            {
                string tt = "خطای زیر رخ داده است" + "\n" +
                            "سیستم قادر به نمایش این فایل نیست" + "\n" +
                            "\n" + e.Message + "\n"
                            + "برای مشاهده این فایل به مسیر زیر مراجعه نمایید" + "\n"
                            + fp;

                MessageBox.Show(tt);
            }
        }
示例#3
0
        public Attachment GetAttachmentInfo(string attachmetID)
        {
            if (string.IsNullOrEmpty(attachmetID))
            {
                return(null);
            }

            string[] split = attachmetID.Split(';');
            if (split.Length != 2)
            {
                return(null);
            }

            string         pk = split[0];
            string         rk = split[1];
            TableOperation retrieveOperation = TableOperation.Retrieve <AttachmentEntity>(pk, rk);
            TableResult    retrievedResult   = _attachment.ExecuteRetriveOperation(retrieveOperation);

            if (retrievedResult.Result == null)
            {
                return(null);
            }
            AttachmentEntity entity = (AttachmentEntity)retrievedResult.Result;

            return(entity.toAttachment());
        }
示例#4
0
        public Attachment Upload(string filename,
                                 string filetype,
                                 int filesize,
                                 Stream filestream,
                                 string uploader)
        {
            Attachment attachment = new Attachment();

            attachment.UploadTimestamp = DateTime.UtcNow;
            attachment.Filename        = filename;
            attachment.Filetype        = filetype;
            attachment.Filesize        = filesize;
            attachment.Uploader        = uploader;
            attachment.FileID          = Guid.NewGuid().ToString() + Path.GetExtension(filename);
            //attachment.AttachmentId = GenerateAttachmentID(attachment.Uploader, attachment.FileID, attachment.UploadTimestamp);

            AttachmentEntity attachmentEntity = new AttachmentEntity(attachment);
            TableOperation   insertOperation  = TableOperation.InsertOrReplace(attachmentEntity);

            _attachment.Execute(insertOperation);

            CloudBlockBlob blockBlob = _blobcontainer.GetBlockBlobReference(attachment.FileID);

            blockBlob.UploadFromStream(filestream);

            blockBlob.Properties.ContentType = filetype;
            return(attachment);
        }
 protected void ButtonConfirm_Click(object sender, EventArgs e)
 {
     if (inputFile.PostedFile.ContentLength > 0)
     {
         string path        = this.inputFile.PostedFile.FileName;
         string fileName    = path.Substring(path.LastIndexOf("\\", System.StringComparison.Ordinal) + 1);
         int    size        = this.inputFile.PostedFile.ContentLength;
         string type        = FileHelper.GetPostfixStr(fileName);//this.inputFile.PostedFile.ContentType;
         string newId       = BusinessLogic.NewGuid();
         Stream imageStream = inputFile.PostedFile.InputStream;
         var    content     = new byte[size];
         imageStream.Read(content, 0, size);
         var entity = new AttachmentEntity
         {
             Id                = newId,
             WorkFlowId        = WorkFlowId,
             WorkFlowInsId     = WorkFlowInsId,
             WorkTaskId        = WorkTaskId,
             WorkTaskInsId     = WorkTaskInsId,
             AttachmentName    = fileName,
             AttachmentContent = content,
             AttachmentType    = type,
             AttachmentSize    = size,
             Enabled           = 1,
             DeleteMark        = 0
         };
         RDIFrameworkService.Instance.WorkFlowHelperService.InsertAttachment(Utils.UserInfo, entity);
         labelUpResult.Text = "上传成功!";
         InitData();
     }
 }
        /// <summary>
        /// 异步插入一个
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <bool> Insert(AttachmentInput input)
        {
            AttachmentEntity att = new AttachmentEntity
            {
                Id           = Guid.NewGuid().ToString(),
                FKey         = input.FKey,
                PhysicalName = input.PhysicalName,
                LogicName    = input.LogicName,
                FileSize     = input.FileSize,
                Extension    = input.Extension,
                Sn           = input.Sn,
                iState       = 1,
                CreateTime   = DateTime.Now,
                CreateName   = input.CreateName,
                PhysicalPath = input.PhysicalPath,
                HttpPath     = input.HttpPath
            };

            try
            {
                await _iAttachmentRepository.InsertAsync(att);
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
示例#7
0
        private static AttachmentEntity TranslateAttachmentInfo(AttachmentInfo attachmentInfo, bool isAPI)
        {
            AttachmentEntity result = new AttachmentEntity();

            if (attachmentInfo != null)
            {
                result.AttachmentID   = attachmentInfo.AttachmentID;
                result.FileName       = attachmentInfo.FileName;
                result.FileExtendName = attachmentInfo.FileExtendName;
                if (isAPI)
                {
                    result.FilePath = attachmentInfo.FilePath.Replace("~", FileUrl);
                }
                else
                {
                    result.FilePath = attachmentInfo.FilePath;
                }
                result.UploadDate   = attachmentInfo.UploadDate;
                result.FileType     = attachmentInfo.FileType;
                result.BusinessType = attachmentInfo.BusinessType;
                result.Channel      = attachmentInfo.Channel;
                result.FileSize     = attachmentInfo.FileSize;
                result.Remark       = attachmentInfo.Remark;
                result.Operator     = attachmentInfo.Operator;
            }


            return(result);
        }
        public async Task <Result <ProjectDiscussionAttachment> > AddAttachment(int projectDiscussionId, string path)
        {
            try
            {
                using (var adapter = Adapter.Create())
                {
                    var attachmentEntity = new AttachmentEntity
                    {
                        Path = path,
                        ProjectDiscussionId = projectDiscussionId
                    };

                    var result = await adapter.SaveEntityAsync(attachmentEntity, true);

                    var meta = new LinqMetaData(adapter);

                    var attachmentModel = new ProjectDiscussionAttachment();
                    attachmentModel.AttachmentId        = attachmentEntity.Id;
                    attachmentModel.ProjectDiscussionId = projectDiscussionId;

                    return(Result <ProjectDiscussionAttachment> .True(attachmentModel));
                }
            }
            catch (Exception ex)
            {
                return(Result <ProjectDiscussionAttachment> .False(ex));
            }
        }
示例#9
0
        public int delete(int id)
        {
            AbstractCommonData entity   = new AttachmentEntity();
            string             delQuery = "DELETE FROM " + entity.TableName + " WHERE " + AttachmentEntity.indexField + "=" + provider.getSQLString(id);

            return(provider.delete(delQuery));
        }
        private string EditAttachment(NameValueCollection rParams)
        {
            string res = "{success:false,msg:'编辑失败'}";

            //组装参数
            AttachmentEntity entity = new AttachmentEntity();

            if (!string.IsNullOrEmpty(rParams["id"]))
            {
                entity = new AttachmentBLL(CurrentUserInfo).GetByID(rParams["id"]);
            }
            entity = DataLoader.LoadFrom <AttachmentEntity>(rParams, entity);

            entity.ClientID = CurrentUserInfo.ClientID;
            if (!string.IsNullOrEmpty(rParams["id"]))
            {
                new AttachmentBLL(CurrentUserInfo).Update(entity);
            }
            else
            {
                new AttachmentBLL(CurrentUserInfo).Create(entity);
            }
            res = "{success:true,msg:'编辑成功',id:'" + entity.AttachmentID + "'}";
            return(res);
        }
示例#11
0
        /// <summary>
        /// Attachment Upd
        /// </summary>
        public static async Task <AttachmentEntity> AttachmentUpd(AttachmentEntity item)
        {
            try
            {
                var pixMakeRepository = await PixMakeMySqlRepository.GetConnection();

                var result = await pixMakeRepository.QueryFirstOrDefaultAsync <AttachmentEntity>(
                    "pm_attachment_upd", new
                {
                    service_group_guid_in = item.service_group_guid,
                    user_guid_in          = item.user_guid,
                    container_in          = item.container,
                    object_guid_in        = item.object_guid,
                    name_in = item.name,
                    uri_in  = item.uri
                },
                    commandType : CommandType.StoredProcedure);

                pixMakeRepository.Close();
                return(result);
            }
            catch (Exception ex)
            {
                await SendError.SendErrorAsync(ex, customMessage : "MySql");

                return(null);
            }
        }
示例#12
0
        public async Task <IResultModel <AttachmentUploadResultModel> > Upload(AttachmentUploadModel model, FileInfo fileInfo)
        {
            var result = new ResultModel <AttachmentUploadResultModel>();

            var entity = new AttachmentEntity
            {
                FileName = model.Name.NotNull() ? model.Name : fileInfo.FileName,
                SaveName = fileInfo.SaveName,
                Ext      = fileInfo.Ext,
                Md5      = fileInfo.Md5,
                Path     = fileInfo.Path,
                FullPath = Path.Combine(fileInfo.Path, fileInfo.SaveName),
                Size     = fileInfo.Size.Size,
                SizeCn   = fileInfo.Size.ToString(),

                Module = model.Module,
                Group  = model.Group
            };

            var media = await _mediaTypeRepository.FirstAsync(m => m.Ext == fileInfo.Ext);

            entity.MediaType = media?.Value;

            if (await _attachmentRepository.InsertAsync(entity))
            {
                var resultModel = _mapper.Map <AttachmentUploadResultModel>(entity);
                return(result.Success(resultModel));
            }

            return(result.Failed("上传失败"));
        }
示例#13
0
        public ActionResult PreviewAttachment()
        {
            Logger.Info(_logMsg.Clear().SetPrefixMsg("Preview Attachment").ToInputLogString());

            try
            {
                AttachmentEntity selectedAttach = (AttachmentEntity)TempData["FILE_DOWNLOAD"];
                TempData["FILE_DOWNLOAD"] = selectedAttach; // keep object

                _commonFacade = new CommonFacade();
                string documentFolder = selectedAttach.DocumentLevel == Constants.DocumentLevel.Customer ?
                                        _commonFacade.GetCSMDocumentFolder() : _commonFacade.GetSrDocumentFolder();
                string pathFile  = string.Format(CultureInfo.InvariantCulture, "{0}\\{1}", documentFolder, selectedAttach.Url);
                byte[] byteArray = System.IO.File.ReadAllBytes(pathFile);

                return(File(byteArray, selectedAttach.ContentType, selectedAttach.Filename));
            }
            catch (Exception ex)
            {
                Logger.Error("Exception occur:\n", ex);
                Logger.Info(_logMsg.Clear().SetPrefixMsg("Preview Attachment").Add("Error Message", ex.Message).ToFailLogString());
                return(Error(new HandleErrorInfo(ex, this.ControllerContext.RouteData.Values["controller"].ToString(),
                                                 this.ControllerContext.RouteData.Values["action"].ToString())));
            }
        }
示例#14
0
        public int delete(int id)
        {
            AttachmentEntity entity   = new AttachmentEntity();
            string           delQuery = "DELETE FROM " + AttachmentEntity.TableName + " WHERE " + AttachmentEntity.indexField + "=" + id;

            return(provider.delete(delQuery));
        }
示例#15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int attachmentID = HnDGeneralUtils.TryConvertToInt(Request.QueryString["AttachmentID"]);

            MessageEntity relatedMessage = MessageGuiHelper.GetMessageWithAttachmentLogic(attachmentID);

            if (relatedMessage == null)
            {
                // not found
                Response.Redirect("default.aspx", true);
            }

            // thread has been loaded into the related message object as well. This is needed for the forum access right check
            if (!SessionAdapter.CanPerformForumActionRight(relatedMessage.Thread.ForumID, ActionRights.AccessForum))
            {
                // user can't access this forum
                Response.Redirect("default.aspx", true);
            }

            // Check if the thread is sticky, or that the user can see normal threads started
            // by others. If not, the user isn't allowed to view the thread the message is in, and therefore is denied access.
            if ((relatedMessage.Thread.StartedByUserID != SessionAdapter.GetUserID()) &&
                !SessionAdapter.CanPerformForumActionRight(relatedMessage.Thread.ForumID, ActionRights.ViewNormalThreadsStartedByOthers) &&
                !relatedMessage.Thread.IsSticky)
            {
                // user can't view the thread the message is in, because:
                // - the thread isn't sticky
                // AND
                // - the thread isn't posted by the calling user and the user doesn't have the right to view normal threads started by others
                Response.Redirect("default.aspx", true);
            }

            AttachmentEntity toStream = MessageGuiHelper.GetAttachment(attachmentID);

            if (toStream == null)
            {
                // not found
                Response.Redirect("default.aspx", true);
            }

            if (!toStream.Approved && !SessionAdapter.CanPerformForumActionRight(relatedMessage.Thread.ForumID, ActionRights.ApproveAttachment))
            {
                // the attachment hasn't been approved yet, and the caller isn't entitled to approve attachments, so deny.
                // approval of attachments requires to be able to load the attachment without the attachment being approved
                Response.Redirect("default.aspx", true);
            }

            // all set, load stream the attachment data to the browser
            // create header
            Response.ClearHeaders();
            Response.ClearContent();
            Response.AddHeader("Content-Type", "application/unknown");
            Response.AddHeader("Content-length", toStream.Filecontents.Length.ToString());
            Response.AddHeader("Content-Disposition", "attachment; filename=" + toStream.Filename.Replace(" ", "_"));
            Response.AddHeader("Content-Transfer-Encoding", "Binary");
            // stream the data
            Response.BinaryWrite(toStream.Filecontents);
            Response.Flush();
            Response.End();
        }
示例#16
0
		/// <summary>
		/// Approves / revokes the approval of the attachment with ID passed in.
		/// </summary>
		/// <param name="attachmentID">The attachment ID.</param>
		/// <param name="approved">the new flag value for Approved</param>
		public static void ModifyAttachmentApproval(int attachmentID, bool approved)
		{
			// we'll update the approved flag directly in the db, so we don't load the whole attachment into memory. 
			AttachmentEntity updater = new AttachmentEntity();
			AttachmentCollection attachments = new AttachmentCollection();
			updater.Approved = approved;
			attachments.UpdateMulti(updater, (AttachmentFields.AttachmentID == attachmentID));
		}
示例#17
0
        /// <summary>Creates a new, empty AttachmentEntity object.</summary>
        /// <returns>A new, empty AttachmentEntity object.</returns>
        public override IEntity Create()
        {
            IEntity toReturn = new AttachmentEntity();

            // __LLBLGENPRO_USER_CODE_REGION_START CreateNewAttachment
            // __LLBLGENPRO_USER_CODE_REGION_END
            return(toReturn);
        }
示例#18
0
        /// <summary>
        /// Загрузка файлов Azure Storage
        /// </summary>
        public static async Task <AttachmentEntity> UploadFileAzureStorage(AttachmentEntity uploadedFile)
        {
            var fileNameBlobPath = $@"{uploadedFile.object_guid}/{uploadedFile.name}";
            var blockBlob        = AzureStorage.GetCloudBlock(uploadedFile.container, fileNameBlobPath);
            await AzureStorage.UploadBlobFile(fileNameBlobPath, uploadedFile);

            uploadedFile.uri = blockBlob.Uri.ToString();
            return(uploadedFile);
        }
示例#19
0
	  public virtual object execute(CommandContext commandContext)
	  {
		AttachmentEntity updateAttachment = commandContext.DbEntityManager.selectById(typeof(AttachmentEntity), attachment.Id);

		updateAttachment.Name = attachment.Name;
		updateAttachment.Description = attachment.Description;

		return null;
	  }
示例#20
0
        public AttachmentEntity getById(int id)
        {
            AttachmentEntity entity = new AttachmentEntity();
            String           cond   = AttachmentEntity.FIELD_ID + "=" + id;

            provider.loadToDataSet(AttachmentEntity.TableName, entity, cond);
            fillRadif(entity);
            return(entity);
        }
示例#21
0
        public AttachmentEntity getById(int id)
        {
            AttachmentEntity entity = new AttachmentEntity();
            String           cond   = AttachmentEntity.FIELD_ID + "=" + provider.getSQLString(id);

            provider.loadToDataSet(entity, cond);

            return(entity);
        }
示例#22
0
        private void fillGrid()
        {
            AttachmentEntity entity = null;

            entity = _attachmentBl.get(_insuranceId);

            System.Collections.Hashtable hash = new Hashtable();
            _gridTools.bindDataToGrid(dataGridView1, entity, AttachmentEntity.TableName, null, hash);
        }
示例#23
0
        public virtual object Execute(CommandContext commandContext)
        {
            AttachmentEntity updateAttachment = commandContext.AttachmentManager.Get(Attachment.Id);

            updateAttachment.Name        = Attachment.Name;
            updateAttachment.Description = Attachment.Description;

            return(null);
        }
示例#24
0
 private AttachmentDTO Entity2DTO(AttachmentEntity attachmentEntity)
 {
     return(new AttachmentDTO()
     {
         CreateDateTime = attachmentEntity.CreateDateTime,
         IconName = attachmentEntity.IconName,
         Id = attachmentEntity.Id,
         Name = attachmentEntity.Name
     });
 }
示例#25
0
        private AttachmentDTO ToDTO(AttachmentEntity entity)
        {
            AttachmentDTO dto = new AttachmentDTO();

            dto.Id             = entity.Id;
            dto.Name           = entity.Name;
            dto.IconName       = entity.IconName;
            dto.CreateDateTime = entity.CreateDateTIme;
            return(dto);
        }
示例#26
0
        public AttachmentDTO ToDTO(AttachmentEntity attachment)
        {
            AttachmentDTO attachmentDto = new AttachmentDTO();

            attachmentDto.IconName       = attachment.IconName;
            attachmentDto.Name           = attachment.Name;
            attachmentDto.Id             = attachment.Id;
            attachmentDto.CreateDateTime = attachmentDto.CreateDateTime;
            return(attachmentDto);
        }
示例#27
0
        private AttachmentDTO ToDTO(AttachmentEntity att)
        {
            AttachmentDTO dto = new AttachmentDTO();

            dto.CreateDateTime = att.CreateDateTime;
            dto.IconName       = att.IconName;
            dto.Id             = att.Id;
            dto.Name           = att.Name;
            return(dto);
        }
示例#28
0
        public int getCount(int insuranceId)
        {
            //ToDo reprogram this lines
            AttachmentEntity entity = new AttachmentEntity();
            String           sql    = "SELECT COUNT(1) FROM " + AttachmentEntity.TableName + " WHERE " + AttachmentEntity.FIELD_INSURANCE_ID
                                      + "=" + insuranceId;
            String cond = AttachmentEntity.FIELD_INSURANCE_ID + "=" + insuranceId;

            provider.loadToDataSet(AttachmentEntity.TableName, entity, cond);
            return(entity.Tables[AttachmentEntity.TableName].Rows.Count);
        }
示例#29
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, AttachmentEntity entity)
 {
     try
     {
         service.SaveForm(keyValue, entity);
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#30
0
        public int getCount(int letterid)
        {
            //ToDo reprogram this lines
            AttachmentEntity entity = new AttachmentEntity();
            String           sql    = "SELECT COUNT(1) FROM " + entity.TableName + " WHERE " + AttachmentEntity.FIELD_LETTER_ID
                                      + "=" + provider.getSQLString(letterid);
            String cond = AttachmentEntity.FIELD_LETTER_ID + "=" + provider.getSQLString(letterid);

            provider.loadToDataSet(entity, cond);
            return(entity.Tables[entity.FilledTableName].Rows.Count);
        }