Пример #1
0
        internal static String Save(DB.SYS_MSG_Message entry, DataContext dataContext)
        {
            try
            {
                if (dataContext.EntitySystemContext.GetEntityState(entry) == System.Data.Entity.EntityState.Detached)
                {
                    dataContext.EntitySystemContext.SYS_MSG_Message.Add(entry);
                }
            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex)
            {
                return(dataContext.PackageValidationException());
            }

            return("Success");
        }
Пример #2
0
        private void txtMessage_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control && e.KeyCode == Keys.Enter)
            {
                Essential.MSG.MessengerUsers selectedUser = (Essential.MSG.MessengerUsers)grvMessengerUsers.GetFocusedRow();
                DB.SYS_MSG_Message           message      = BL.SYS.SYS_MSG_Message.New;
                message.Message = txtMessage.Text;
                message.ToId    = selectedUser.Id;
                string sent = Essential.MSG.Messenger.Connect(selectedUser, message.Message);
                if (sent.StartsWith("Sent") || sent.StartsWith("Received"))
                {
                    message.Sent     = sent.StartsWith("Sent") || sent.StartsWith("Received");
                    message.Received = sent.StartsWith("Received");
                    message.SentOn   = BL.ApplicationDataContext.Instance.ServerDateTime;
                    try
                    {
                        using (TransactionScope transaction = DataContext.GetTransactionScope())
                        {
                            BL.EntityController.SaveSYS_MSG_Message(message, DataContext);
                            DataContext.SaveChangesEntitySystemContext();
                            DataContext.CompleteTransaction(transaction);
                        }
                        DataContext.EntitySystemContext.AcceptAllChanges();
                    }
                    catch (Exception ex)
                    {
                        DataContext.EntitySystemContext.RejectChanges();
                        if (CDS.Shared.Exception.UserInterfaceExceptionHandler.HandleException(ref ex))
                        {
                            throw ex;
                        }
                    }

                    txtMessage.Text = string.Empty;
                    UpdateMessages();
                }
            }
        }
Пример #3
0
 public static DB.SYS_MSG_Message GetPreviousItem(DB.SYS_MSG_Message SYS_MSG_Message, DataContext dataContext)
 {
     return(dataContext.EntitySystemContext.SYS_MSG_Message.OrderByDescending(o => o.Id).FirstOrDefault(n => n.Id.CompareTo(SYS_MSG_Message.Id) < 0 && n.Id.CompareTo(SYS_MSG_Message.Id) != 0));
 }