Example #1
0
        public static long SaveMessage(string body, string flag, long? ParentId, File[] files,bool ishotnews)
        {
            var db = DCFactory.GetDataContext<BasicDataContext>();
            var msg = new Message
            {
                Body = body,
                CreatedBy = flag == MessageFlag.SystemMessage ? "SYSTEM" : UserHelper.IsDealer ? UserHelper.DealerCode : UserHelper.Username,
                CreatedDate = DateTime.Now,
                Flag = flag,
                ParentId = ParentId,
                Type= MessageType.NormalMessage
            };
            if (ishotnews)
                msg.Type = MessageType.HotMesssage;
            if (files != null)
            {
                foreach (var item in files)
                    if (item != null)
                        item.Message = msg;
            }

            db.Messages.InsertOnSubmit(msg);
            db.SubmitChanges();

            return msg.MessageId;
        }
Example #2
0
 public static File CreateFile(HttpPostedFile postedFile)
 {
     if (postedFile == null) return null;
     File obj = null;
     int length = postedFile.ContentLength;
     string Filename = postedFile.FileName.Substring(postedFile.FileName.LastIndexOf(@"\") + 1);
     if (length != 0 && length / 1024 < 5000)
     {
         obj = new File() { Body = new byte[length], FileName = Filename };
         postedFile.InputStream.Read(obj.Body, 0, length);
         obj.Body = Compressor.Compress(obj.Body);
         obj.FileName = Filename;
     }
     return obj;
 }
 private void detach_Files(File entity)
 {
     this.SendPropertyChanging();
     entity.Message = null;
 }
 private void attach_Files(File entity)
 {
     this.SendPropertyChanging();
     entity.Message = this;
 }