Пример #1
0
        public static AttachSegments Insert(string attachId, int segmentContentSize, int sortNo, string pathName)
        {
            AttachSegments result = null;

            try
            {
                string         cmdTxt     = @"insert into TBL_AttachSegments(AttachId,SegmentSize,SerialNumber,SegmentContent,UploadDate,IpAddr)
                                  values (@AttachId,@SegmentSize,@SerialNumber,@SegmentContent,@UploadDate,@IpAddr) ";
                SqlParameter[] parameters = new SqlParameter[] {
                    new SqlParameter("@AttachId", attachId),
                    new SqlParameter("@SegmentSize", segmentContentSize),
                    new SqlParameter("@SerialNumber", sortNo),
                    new SqlParameter("@SegmentContent", pathName),
                    new SqlParameter("@UploadDate", DateTime.Now.ToString()),
                    new SqlParameter("@IpAddr", ""),
                };
                SqlHelper.ExecuteNonQuery(DBConnectConfig.DBAttach, System.Data.CommandType.Text, cmdTxt, parameters);
                result = new AttachSegments
                {
                    AttachId       = attachId,
                    IpAddr         = "",
                    SegmentSize    = segmentContentSize,
                    SegmentContent = pathName,
                    SerialNumber   = sortNo
                };
            }
            catch (Exception ex)
            {
                result = null;
                Logger.SaveLog(ex.ToString());
            }
            return(result);
        }
Пример #2
0
        public int InsertSegment(byte[] segmentContent, int sortNo, string pathName)
        {
            int i = 0;

            if (this.RemainingCapacity >= segmentContent.Length)
            {
                AttachSegments segment = AttachSegments.Insert(this.AttachID, segmentContent.Length, sortNo, pathName);
                if (segment != null)
                {
                    this.Segments.Add(segment);
                }
                i = 1;
            }
            else
            {
                throw new Exception("上传的文件片段内容大小超出文件总大小");
            }
            return(i);
        }