Пример #1
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Add(OperatorMsg model)
 {
     using (DBHelper db = DBHelper.Create())
     {
         db.Insert <OperatorMsg>(model);
     }
 }
Пример #2
0
        public JsonResult AddMessageNew(string AcceptIDS, string Title, string Content)
        {
            AjaxResult result = new AjaxResult();
            Message    msg    = new Message();

            msg.Content = Content;
            msg.Title   = Title;
            try
            {
                MessageRule msgR = new MessageRule();
                if (string.IsNullOrEmpty(msg.ID))                //新增
                {
                    msg.ID         = Guid.NewGuid().ToString("N");
                    msg.OperatorID = MyTicket.CurrentTicket.UserID;
                    msg.CreateDate = DateTime.Now;
                    msgR.Add(msg);
                    //不选接收人,默认发送给所有人
                    if (string.IsNullOrEmpty(AcceptIDS))
                    {
                        List <Ajax.Model.Customer> acceptList = new CustomerRule().GetList("");
                        foreach (Ajax.Model.Customer c in acceptList)
                        {
                            AcceptIDS += c.OperatorID + ",";
                        }
                    }
                    string[] strAcceptIDs = AcceptIDS.Remove(AcceptIDS.Length - 1, 1).Split(',');                    //Request.Form["txtAcceptIDs"].Split(',');
                    //接收人
                    OperatorMsgRule    omsgR    = new OperatorMsgRule();
                    List <OperatorMsg> oMsgList = new List <OperatorMsg>();
                    foreach (string acceptID in strAcceptIDs)
                    {
                        if (string.IsNullOrEmpty(acceptID))
                        {
                            continue;
                        }
                        OperatorMsg omsg = new OperatorMsg();
                        omsg.ID         = Guid.NewGuid().ToString("N");
                        omsg.Status     = 0;                    //默认为未读
                        omsg.MsgID      = msg.ID;
                        omsg.OperatorID = acceptID;
                        oMsgList.Add(omsg);
                    }
                    omsgR.AddMul(oMsgList);
                    result.Success = true;
                    result.Message = "公告已经成功发出。";
                }
                else                //编辑
                {
                    result.Success = msgR.Update(msg);
                    result.Message = result.Success ? "公告已经成功修改。" : "公告修改失败!";
                }
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = "操作失败:" + ex.Message;
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Пример #3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(OperatorMsg model)
 {
     using (DBHelper db = DBHelper.Create())
     {
         db.Update <OperatorMsg>(model);
         return(true);
     }
 }
Пример #4
0
 public void Call(MobileAccount sender, MobileAccount reciever)
 {
     if (InitClients(sender, reciever))
     {
         OperatorMsg?.Invoke(reciever.CallIn(sender));
         _journalOfActions[sender.GetNumber()].CallOut++;
         _journalOfActions[reciever.GetNumber()].CallIn++;
     }
 }
Пример #5
0
 private bool InitClients(params MobileAccount[] accounts)
 {
     foreach (MobileAccount account in accounts)
     {
         if (!VerificationNumber(account.GetNumber()))
         {
             OperatorMsg?.Invoke($"Operator: New number {account.GetNumber()} detected, we added it to dictOfClients");
             AddClient(account);
         }
     }
     return(true);
 }
Пример #6
0
        private void Call(MobileAccount sender, MobileAccount receiver)
        {
            OperatorMsg?.Invoke(receiver.CallIn(sender));

            _journalOfActions.Add(id++, new JournalActionItem()
            {
                Time           = DateTime.Now,
                InvokerNumber  = sender.MobileNumber,
                ReceiverNumber = receiver.MobileNumber,
                ActionType     = MobileAccountActionType.Call
            });
        }
Пример #7
0
 public void AddClient(MobileAccount account)
 {
     if (!VerificationNumber(account.MobileNumber))
     {
         _dictOfClients.Add(account.MobileNumber, account);
         account.MakeCall    += Call;
         account.MakeMessage += Message;
     }
     else
     {
         OperatorMsg?.Invoke("Account is already exists");
     }
 }