Beispiel #1
0
        public AjaxReturn EditUserSave(JObject json)
        {
            AdminHelper helper      = new AdminHelper(this);
            User        user        = (User)((JObject)json["header"]).To(typeof(User));
            JObject     old         = null;
            string      oldPassword = null;

            if (user.idUser > 0)
            {
                // Existing record
                User header = Database.Get <User>((int)user.idUser);
                oldPassword     = header.Password;
                header.Password = "";
                old             = new JObject().AddRange("header", header);
                old["detail"]   = user.ModulePermissions ? helper.permissions((int)user.idUser).ToJToken() : new JArray();
            }
            AjaxReturn result = helper.EditUserSave(json);

            if (result.error == null)
            {
                JObject header = (JObject)json["header"];
                header["Password"] = oldPassword != null && header.AsString("Password") != oldPassword ? "(changed)" : "";
                if (!header.AsBool("ModulePermissions"))
                {
                    json["detail"] = new JArray();
                }
                Database.AuditUpdate("User", header.AsInt("idUser"), old, json);
            }
            return(result);
        }
Beispiel #2
0
        public AjaxReturn BatchStatus(int id)
        {
            AjaxReturn result = new AjaxReturn();
            BatchJob   batch  = AppModule.GetBatchJob(id);

            if (batch == null)
            {
                Log("Invalid batch id");
                result.error = "Invalid batch id";
            }
            else
            {
                if (batch == null)
                {
                    Log("Invalid batch id");
                    result.error = "Invalid batch id";
                }
                else
                {
                    Log("Batch {0}:{1}%:{2}", batch.Id, batch.PercentComplete, batch.Status);
                    result.data = batch;
                    if (batch.Finished)
                    {
                        result.error    = batch.Error;
                        result.redirect = batch.Redirect;
                        Log("Batch finished - redirecting to {0}", batch.Redirect);
                    }
                }
            }
            return(result);
        }
Beispiel #3
0
        public AjaxReturn DetailSave(Full_Member json)
        {
            Utils.Check(json.MemberTypeId > 0, "Must choose membership type");
            Utils.Check(!string.IsNullOrWhiteSpace(json.Name), "Name must be filled in");
            Utils.Check(json.MemberNo > 0, "Must assign a membership number");
            Utils.Check(json.PaymentAmount >= 0, "Payment amount may not be negative");
            if (json.idMember == null && json.PaymentAmount == 0 && json.NumberOfPayments > 0)
            {
                json.PaymentAmount = Math.Round(json.AnnualSubscription / json.NumberOfPayments);
            }
            Database.BeginTransaction();
            // Record contains most of the data from the associated NameAddress record - save that first
            JObject nameAddress = json.ToJObject();

            if (json.NameAddressId > 0)
            {
                nameAddress["idNameAddress"] = json.NameAddressId;
            }
            nameAddress["Type"] = "M";
            Database.Update("NameAddress", nameAddress);
            json.NameAddressId = nameAddress.AsInt("idNameAddress");
            AjaxReturn r = SaveRecord(json, true);

            if (r.error == null)
            {
                Database.Commit();
            }
            return(r);
        }
Beispiel #4
0
        /// <summary>
        /// Delete a document, first checking it is one of the supplied types
        /// </summary>
        protected AjaxReturn deleteDocument(int id, params DocType[] allowed)
        {
            AjaxReturn result = new AjaxReturn();

            Database.BeginTransaction();
            Extended_Document record = getDocument <Extended_Document>(id);

            Utils.Check(record != null && record.idDocument != null, "Record does not exist");
            DocType type = checkDocType(record.DocumentTypeId, allowed);

            if (record.DocumentOutstanding != record.DocumentAmount)
            {
                result.error = type.UnCamel() + " has been " +
                               (type == DocType.Payment || type == DocType.BillPayment ? "used to pay or part pay invoices" : "paid or part paid")
                               + " it cannot be deleted";
            }
            else if (record.VatPaid > 0)
            {
                result.error = "VAT has been declared on " + type.UnCamel() + " it cannot be deleted";
            }
            else
            {
                Database.Audit(AuditType.Delete, "Document", id, getCompleteDocument(record));
                Database.Execute("DELETE FROM StockTransaction WHERE idStockTransaction IN (SELECT idJournal FROM Journal WHERE DocumentId = " + id + ")");
                Database.Execute("DELETE FROM Line WHERE idLine IN (SELECT idJournal FROM Journal WHERE DocumentId = " + id + ")");
                Database.Execute("DELETE FROM Journal WHERE DocumentId = " + id);
                Database.Execute("DELETE FROM Document WHERE idDocument = " + id);
                Database.Commit();
                result.message = type.UnCamel() + " deleted";
            }
            return(result);
        }
Beispiel #5
0
        public ActionResult ChatEnd(string chatID)
        {
            var result = new AjaxReturn();

            try
            {
                if (string.IsNullOrEmpty(chatID))
                {
                    throw new Exception("传入的参数 chatID 不可为空值!");
                }
                SPhone_Chat entity = SPhone_ChatBLL.GetChat(chatID);
                if (entity == null)
                {
                    throw new Exception(String.Format("找不到需要更新的记录! ChatID:{0}", chatID));
                }
                entity.UpdateBy    = entity.EmployeeID;
                entity.ChatEndTime = DateTime.Now;
                entity.UpdateTime  = DateTime.Now;
                SPhone_ChatBLL.Update <SPhone_Chat>(entity);
            }
            catch (Exception ex)
            {
                result.SetError(ex.Message);
            }
            return(Jsonp(result, JsonRequestBehavior.AllowGet));
        }
Beispiel #6
0
        /// <summary>
        /// 更新Chat记录
        /// </summary>
        /// <param name="chatID"></param>
        /// <param name="nextQueue"></param>
        /// <param name="isMeeting"></param>
        /// <param name="jsonMessageData"></param>
        /// <returns></returns>
        public ActionResult ChatUpdate(string chatID, string nextQueue, int isMeeting, int isRTO, string jsonMessageData)
        {
            var result = new AjaxReturn();

            try
            {
                if (string.IsNullOrEmpty(chatID))
                {
                    throw new Exception("传入的参数 chatID 不可为空值!");
                }
                SPhone_Chat entity = SPhone_ChatBLL.GetChat(chatID);
                entity.NextQueueName = nextQueue;
                entity.IsConference  = isMeeting;
                entity.IsRTO         = isRTO;
                entity.ContentText   = jsonMessageData;
                entity.UpdateBy      = entity.EmployeeID;
                entity.ChatEndTime   = DateTime.Now;
                entity.UpdateTime    = entity.ChatEndTime;
                if (entity == null)
                {
                    throw new Exception(String.Format("找不到需要更新的记录! ChatID:{0}", chatID));
                }
                SPhone_ChatBLL.Update <SPhone_Chat>(entity);
            }
            catch (Exception ex)
            {
                result.SetError(ex.Message);
            }
            return(Jsonp(result, JsonRequestBehavior.AllowGet));
        }
Beispiel #7
0
        /// <summary>
        /// 更新Chat记录
        /// </summary>
        /// <param name="chatID"></param>
        /// <param name="nextQueue"></param>
        /// <param name="isMeeting"></param>
        /// <param name="jsonMessageData"></param>
        /// <returns></returns>
        public ActionResult ChatUpdate(string chatID, string nextQueue, int isMeeting, int isRTO, string jsonMessageData, string chatEndDate, string customerIP, string customerLocation)
        {
            var result = new AjaxReturn();

            try
            {
                if (string.IsNullOrEmpty(chatID))
                {
                    throw new Exception("传入的参数 chatID 不可为空值!");
                }
                if (!string.IsNullOrEmpty(jsonMessageData))
                {
                    jsonMessageData = jsonMessageData.Trim('"');
                }

                DateTime endTime = DateTime.Now;

                if (!string.IsNullOrEmpty(chatEndDate))
                {
                    try
                    {
                        endTime = DateTime.Parse(chatEndDate.Trim('"'));
                    }
                    catch { }
                }

                //try
                //{
                //    string chatContent = System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(jsonMessageData));
                //    if (!string.IsNullOrEmpty(chatContent))
                //    {
                //        // 获取最后一条,作为chat的结束时间
                //    }
                //}
                //catch { }

                SPhone_Chat entity = SPhone_ChatBLL.GetChat(chatID);
                entity.NextQueueName = nextQueue;
                entity.IsConference  = isMeeting;
                entity.IsRTO         = isRTO;
                entity.ContentText   = jsonMessageData;
                entity.UpdateBy      = entity.EmployeeID;
                entity.ChatEndTime   = endTime;
                entity.UpdateTime    = endTime;
                entity.CustomerIP    = customerIP;
                entity.IPLocation    = customerLocation;
                if (entity == null)
                {
                    throw new Exception(String.Format("找不到需要更新的记录! ChatID:{0}", chatID));
                }
                SPhone_ChatBLL.Update <SPhone_Chat>(entity);
            }
            catch (Exception ex)
            {
                result.SetError(ex.Message);
            }
            return(Jsonp(result, JsonRequestBehavior.AllowGet));
        }
Beispiel #8
0
        /// <summary>
        /// 链接服务器
        /// </summary>
        /// <returns></returns>
        public JsonResult ConnectionServer(string tid, string interactionID, string queueName
                                           , string agentID, string placeID, string nickName, string host, string port, int isMeeting)
        {
            AjaxReturn result = new AjaxReturn();

            if (!string.IsNullOrEmpty(interactionID))
            {
                LenovoAgent agent = new LenovoAgent()
                {
                    TicketID = tid, InteractionID = interactionID, AgentId = agentID, PlaceId = placeID, DisplayName = nickName
                };
                try
                {
                    ChatLog.GetInstance().FormatMessage("连接ChatServer:sessionid-{0},queue-{1},agentID-{2},chatServer-{3}:{4}"
                                                        , interactionID, queueName, agentID, host, port);

                    AgentChatContext context = new AgentChatContext(tid, interactionID, agent);
                    context.ChatServerHost = host;
                    context.ChatServerPort = port;
                    context.InitConnecton();
                    if (context.IsAvailableConnection)
                    {
                        string title = GetEmployeeTitle(queueName);
                        context.ChatJoin(interactionID, title);

                        if (isMeeting == 1)
                        {
                            context.SendMessage(interactionID, "<font color='red'>您已进入了多方支持。</font>");
                        }

                        result.Code = 1;

                        DateTime beginTime = context.Room.CreateDate;
                        result.d = new
                        {
                            ChatBeginTime    = beginTime.Ticks,
                            ChatID           = string.Format("{0}{1:yyyyMMddHHmmsshh}C", agentID, beginTime),
                            StrChatBeginTime = beginTime.ToString("yyyy-MM-dd HH:mm:ss")
                        };

                        //JsonResult jr = new JsonpResult() { Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
                        //string s=jr.ToString();
                        //ChatLog.GetInstance().FormatMessage("返回数据:【{0}】", s);
                    }
                }
                catch (Exception ex)
                {
                    ChatLog.GetInstance().LogException(ex);
                }
            }
            return(new JsonpResult()
            {
                Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Beispiel #9
0
        /// <summary>
        /// 通过IP获取DN和Place
        /// </summary>
        /// <returns></returns>
        public ActionResult GetPlaceDN()
        {
            var r = new AjaxReturn();

            r.d = SoftPhone.Business.IPDNBLL.GetPlaceDN(Request.UserHostAddress);
            if (r.d == null)
            {
                r.SetError(Request.UserHostAddress + ":没有找到对应的DN和Place");
            }
            return(Jsonp(r, JsonRequestBehavior.AllowGet));
        }
Beispiel #10
0
        /// <summary>
        /// Save a memorised transaction, then redirect to it for review
        /// </summary>
        public AjaxReturn RepeatTransferSave(TransferDocument json, DateTime date)
        {
            json.idDocument   = null;
            json.DocumentDate = date;
            AjaxReturn result = TransferSave(json);

            if (result.error == null && result.id > 0)
            {
                result.redirect = "/banking/transfer.html?message=Transfer+saved&id=" + result.id;
            }
            return(result);
        }
Beispiel #11
0
        public AjaxReturn EditRepairCafeDelete(int id)
        {
            Database.BeginTransaction();
            Database.Execute($"DELETE FROM ItemType WHERE RepairCafeId = {id}");
            AjaxReturn r = DeleteRecord("RepairCafe", id);

            if (r.error == null)
            {
                Database.Commit();
            }
            return(r);
        }
Beispiel #12
0
        public AjaxReturn VatCodeDelete(int id)
        {
            AjaxReturn result = new AjaxReturn();

            try {
                Database.Delete("VatCode", id, true);
                result.message = "VAT code deleted";
            } catch {
                result.error = "Cannot delete - VAT code in use";
            }
            return(result);
        }
Beispiel #13
0
        public AjaxReturn JobDelete(int id)
        {
            AjaxReturn result = new AjaxReturn();

            try {
                Database.Delete("Schedule", id, false);
                result.message = "Job deleted";
            } catch {
                result.error = "Cannot delete";
            }
            return(result);
        }
Beispiel #14
0
        public AjaxReturn ProductDelete(int id)
        {
            AjaxReturn result = new AjaxReturn();

            try {
                Database.Delete("Product", id, true);
                result.message = "Product deleted";
            } catch {
                result.error = "Cannot delete - Product in use";
            }
            return(result);
        }
Beispiel #15
0
        public AjaxReturn EditFormSave(RepairForm json)
        {
            Database.BeginTransaction();
            AjaxReturn r = SaveRecord(json);

            if (r.error == null)
            {
                checkContact(ContactType.Visitor, json.Name, json);
                checkContact(ContactType.Repairer, json.Repairer);
                Database.Commit();
            }
            return(r);
        }
Beispiel #16
0
        public AjaxReturn EditRepairCafeSave(RepairCafe json)
        {
            Database.BeginTransaction();
            RepairCafe original = null;

            if (json.idRepairCafe > 0)
            {
                Utils.Check(Database.TryGet((int)json.idRepairCafe, out original), "Repair Cafe not found");
            }
            AjaxReturn r = SaveRecord(json);

            if (r.error == null)
            {
                RCSession.RepairCafe = json;
                string[] types = json.ItemTypes.Split(',', StringSplitOptions.RemoveEmptyEntries);
                if (original == null || original.ItemTypes != json.ItemTypes)
                {
                    ItemType [] oldTypes = Database.Query <ItemType>($"SELECT * FROM ItemType WHERE RepairCafeId = {json.idRepairCafe} ORDER BY SEQUENCE").ToArray();

                    for (int i = 0; i < oldTypes.Length; i++)
                    {
                        ItemType t = oldTypes[i];
                        if (i >= types.Length)
                        {
                            Database.Delete(t);
                            continue;
                        }
                        if (t.TypeOfItem == types[i])
                        {
                            continue;
                        }
                        t.TypeOfItem = "," + i;
                        Database.Update(t);
                    }
                    for (int i = 0; i < types.Length; i++)
                    {
                        ItemType t = i >= oldTypes.Length ? new ItemType()
                        {
                            Sequence     = i + 1,
                            RepairCafeId = Cafe,
                            TypeOfItem   = types[i]
                        } : oldTypes[i];
                        t.Sequence     = i + 1;
                        t.RepairCafeId = Cafe;
                        t.TypeOfItem   = types[i];
                        Database.Update(t);
                    }
                }
            }
            return(r);
        }
Beispiel #17
0
        public ActionResult CallSetDeskTime(string CallID, string EmployeeID)
        {
            var r = new AjaxReturn();

            try
            {
                Sphone_CallBLL.SetDeskTime(CallID, EmployeeID);
            }
            catch (Exception ex)
            {
                r.SetError(ex.Message);
            }
            return(Jsonp(r, JsonRequestBehavior.AllowGet));
        }
        public JsonResult Detalhe(Data model)
        {

            AjaxReturn ret = new AjaxReturn();

            FormDetalheProposta formModel = new FormDetalheProposta();
            formModel.UsuarioLogado = UsuarioLogado();

            if (formModel.UsuarioLogado.Id == 0)
            {
                ret.status = "false";
                ret.error = "Você precisa estar logado.";
                return Json(ret);

            }
            formModel.Proposta = new PropostaProcesso().BuscarPropostaDetalhes( model.id );

            MensagemProcesso processo = new MensagemProcesso();
            processo.CadastrarMensagem(formModel.Proposta.Id, formModel.UsuarioLogado.Id == formModel.Proposta.Desejo.Usuario.Id ? enumQuemPostou.PEDINTE : enumQuemPostou.PROPONENTE , model.msg);

            foreach (var item in formModel.Proposta.ListaMensagem)
            {
                item.Autor = (item.QuemPostou == enumQuemPostou.PROPONENTE ? formModel.Proposta.Usuario : formModel.Proposta.Desejo.Usuario);
            }

            JavaScriptSerializer json = new JavaScriptSerializer();

            ret.status = "true";


            return Json(ret);

            //return Json(String.Format("'Success':'false','Error':'{0}'", error));

            /*
            FormDetalheProposta model = new FormDetalheProposta();
            model.UsuarioLogado = UsuarioLogado();

            if (model.UsuarioLogado.Id == 0)
            {
                return redirectLoginForm();
            }

            model.Proposta = new PropostaProcesso().BuscarPropostaDetalhes(id);
            foreach (var item in model.Proposta.ListaMensagem)
            {
                item.Autor = item.QuemPostou ? model.Proposta.Usuario : model.Proposta.Desejo.Usuario;
            }
            return View("Detalhe", model);*/
        }
Beispiel #19
0
        /// <summary>
        /// 创建Chat记录
        /// </summary>
        /// <param name="enterID"></param>
        /// <param name="inneractionID"></param>
        /// <param name="fromQueue"></param>
        /// <param name="currentQueue"></param>
        /// <param name="customerID"></param>
        /// <param name="customerName"></param>
        /// <param name="machineNo"></param>
        /// <param name="mailAddress"></param>
        /// <param name="agentID"></param>
        /// <param name="isTransfer"></param>
        /// <param name="isRTO"></param>
        /// <param name="isMeeting"></param>
        /// <returns></returns>
        public ActionResult ChatCreate(string chatID, string enterID, string inneractionID, string fromQueue, string currentQueue
                                       , long?customerID, string customerName, string machineNo, string mailAddress
                                       , string agentID, long?beginDate, int isTransfer, int isMeeting)
        {
            var         result = new AjaxReturn();
            SPhone_Chat entity = new SPhone_Chat();

            entity.CreateBy = agentID;
            long ticks = Convert.ToInt64(beginDate);

            if (ticks == 0)
            {
                ticks = DateTime.Now.Ticks;
            }
            entity.CreateTime    = DateTime.MinValue.AddMilliseconds(ticks / 10000);
            entity.ChatBeginTime = entity.CreateTime;
            entity.ChatEndTime   = entity.CreateTime;

            entity.ChatID       = chatID;
            entity.ConnectionID = inneractionID;

            entity.CustomerID   = Convert.ToInt64(customerID);
            entity.CustomerName = customerName;
            entity.Enterid      = enterID;
            entity.MachineNo    = machineNo;
            entity.MailAddress  = mailAddress;
            //entity.ServicecardNo = "";
            //entity.WSISID = "";

            entity.EmployeeID       = agentID;
            entity.PlaceIP          = this.Request.UserHostAddress;
            entity.FromQueueName    = fromQueue;
            entity.CurrentQueueName = currentQueue;
            //entity.NextQueueName = "";
            entity.ContentText = string.Empty;

            entity.IsConference = isMeeting;
            entity.IsRTO        = 0;
            entity.IsTransfer   = isTransfer;
            try
            {
                SPhone_ChatBLL.AddNewChat(entity);
            }
            catch (Exception ex)
            {
                result.SetError(ex.Message);
            }
            return(Jsonp(result, JsonRequestBehavior.AllowGet));
        }
Beispiel #20
0
        public ActionResult CallCreate(string CallID, string EmployeeID, string ConnectionID, string ANI, string DNIS, int InOut, string CurrentQueueName, string FromQueueName)
        {
            var PlaceIP = Request.UserHostAddress;
            var r       = new AjaxReturn();

            try
            {
                Sphone_CallBLL.Create(CallID, EmployeeID, ConnectionID, ANI, DNIS, InOut, CurrentQueueName, FromQueueName, PlaceIP);
            }
            catch (Exception ex)
            {
                r.SetError(ex.Message);
            }
            return(Jsonp(r, JsonRequestBehavior.AllowGet));
        }
Beispiel #21
0
        /// <summary>
        /// Save a memorised transaction, then redirect to it for review
        /// </summary>
        public AjaxReturn StandingOrderSave(BankingDocument json, DateTime date)
        {
            json.header.idDocument   = null;
            json.header.DocumentDate = date;
            if (Utils.ExtractNumber(json.header.DocumentIdentifier) > 0)
            {
                json.header.DocumentIdentifier = "";
            }
            AjaxReturn result = DocumentSave(json);

            if (result.error == null && result.id > 0)
            {
                result.redirect = "/banking/document.html?message=" + json.header.DocType.UnCamel() + "+saved&id=" + result.id + "&type=" + json.header.DocumentTypeId;
            }
            return(result);
        }
Beispiel #22
0
        /// <summary>
        /// Save an arbitrary JObject to the database, optionally also saving an audit trail
        /// </summary>
        public AjaxReturn SaveRecord(JsonObject record, bool audit)
        {
            AjaxReturn retval = new AjaxReturn();

            try {
                if (record.Id <= 0)
                {
                    record.Id = null;
                }
                Database.Update(record, audit);
                retval.id = record.Id;
            } catch (Exception ex) {
                Message      = ex.Message;
                retval.error = ex.Message;
            }
            return(retval);
        }
Beispiel #23
0
        /// <summary>
        /// 3秒获取一次新数据
        /// </summary>
        /// <param name="Person"></param>
        /// <returns></returns>
        public ActionResult GetAgentStatisticResult(int personDBID)
        {
            var p      = Request.QueryString["person"];
            var person = SupportClass.StatServerHelper.ALLPersons.FirstOrDefault(x => x.DBID == personDBID);
            var r      = new AjaxReturn();
            var d      = new AgentStatisticResult();

            try
            {
                d = SupportClass.StatServerHelper.GetAgentStatisticResult(person);
            }
            catch
            {
            }
            r.d = d;
            return(Jsonp(r, JsonRequestBehavior.AllowGet));
        }
Beispiel #24
0
        public JsonResult WaitForService(string sessionID, string enterID)
        {
            if (!IsUserAgent() || !IsXMLRequest())
            {
                return(Json(new AjaxReturn()
                {
                    Code = -1, Message = ""
                }, JsonRequestBehavior.AllowGet));
            }
            string appServer = ConfigurationManager.AppSettings["appServer"];
            Uri    uri       = new Uri(string.Format("{0}ChatStat/GetQueneCountByEnterID?enterID={1}&ss={2}&jsoncallback?"
                                                     , appServer, enterID, DateTime.Now.Millisecond));

            AjaxReturn result = ChatHelper.RemoteRequest <AjaxReturn>(uri);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Beispiel #25
0
        public AjaxReturn DocumentDelete(SubscriptionJournal json)
        {
            Utils.Check(json.idDocument > 0, "No document to delete");
            Database.BeginTransaction();
            foreach (Journal j in Database.Query <Journal>("SELECT * FROM Journal WHERE DocumentId = " + json.idDocument + " AND JournalNum > 1"))
            {
                Database.Execute("UPDATE Member SET AmountDue = AmountDue - " + j.Amount + " WHERE NameAddressId = " + j.NameAddressId);
            }
            AjaxReturn r = deleteDocument((int)json.idDocument, DocType.Subscriptions);

            if (r.error == null)
            {
                Database.Commit();
                r.redirect = "/members/subscriptions.html";
            }
            return(r);
        }
Beispiel #26
0
        public ActionResult CallEnd(string CallID, string EmployeeID, string CustomerID, string NextQueueName, int IsConference, int IsTransfer, int IsTransferEPOS)
        {
            var r = new AjaxReturn();

            try
            {
                if (!string.IsNullOrEmpty(CallID))
                {
                    Sphone_CallBLL.CallEnd(CallID, EmployeeID, CustomerID, NextQueueName, IsConference, IsTransfer, IsTransferEPOS);
                }
            }
            catch (Exception ex)
            {
                r.SetError(ex.Message);
            }
            return(Jsonp(r, JsonRequestBehavior.AllowGet));
        }
Beispiel #27
0
        public ActionResult GetChatRightEnterID(int enterID, string machineNo)
        {
            AjaxReturn r = new AjaxReturn();

            try
            {
                if (!string.IsNullOrEmpty(machineNo))
                {
                    r.d = ProcBLL.Proc_GetChatRightEnterID(enterID, machineNo);
                }
                else
                {
                    r.SetError("machineNo是必须的");
                }
            }
            catch (Exception ex)
            {
                r.SetError(ex.Message);
            }
            return(Json(r, JsonRequestBehavior.AllowGet));
        }
Beispiel #28
0
        /// <summary>
        /// 获取聊天室信息
        /// </summary>
        /// <returns></returns>
        public JsonResult GetChatinfo(string tid, string interactionID, string queueName
                                      , string agentID, string placeID, string nickName, string host, string port, int isMeeting)
        {
            AjaxReturn result = new AjaxReturn();
            ChatRoom   Myroom = ChatRoomCache.GetInstance().GetRoom(tid, interactionID);

            if (Myroom != null)
            {
                result.Code = 1;
                result.d    = new
                {
                    ChatBeginTime    = Myroom.CreateDate.Ticks,
                    ChatID           = string.Format("{0}{1:yyyyMMddHHmmss}C", agentID, Myroom.CreateDate),
                    StrChatBeginTime = Myroom.CreateDate.ToString("yyyy-MM-dd HH:mm:ss")
                };
            }
            return(new JsonpResult()
            {
                Data = result, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Beispiel #29
0
        /// <summary>
        /// 坐席登录订阅
        /// </summary>
        /// <param name="Person">SoftPhone.Entity.Model.cfg.Person</param>
        /// <returns></returns>
        public ActionResult OpenAgentStatistic(Person person)
        {
            var p = Request.QueryString["person"];

            person = Tele.Common.Helper.JsonHelper.Deserialize <Person>(p);
            var r = new AjaxReturn();

            try
            {
                var query = SupportClass.StatServerHelper.ALLStatisticItems.Values.Where(x =>
                                                                                         x.Opened == false &&
                                                                                         x.TypeID == 2 &&
                                                                                         x.RequireOpen == false &&
                                                                                         x.DBID == person.DBID
                                                                                         );
                foreach (var item in query)
                {
                    item.LastDate    = DateTime.Now;
                    item.RequireOpen = true;
                }

                var cachePersonShort = SupportClass.StatServerHelper.ALLPersons.FirstOrDefault(x => x.DBID == person.DBID);
                if (cachePersonShort != null)//zhangsl:2013.05.03 update 人可能会换座位,每次都要重新赋值
                {
                    cachePersonShort.AgentInfo.IsInitAgentInfo = true;
                    cachePersonShort.DN        = person.DN;
                    cachePersonShort.Place     = person.Place;
                    cachePersonShort.VOICE     = person.VOICE;
                    cachePersonShort.CHAT      = person.CHAT;
                    cachePersonShort.AgentInfo = (AgentInfo)person.AgentInfo.Clone();
                }
            }
            catch (Exception err)
            {
                r.SetError("发生错误:" + err.Message);
            }

            return(Jsonp(r, JsonRequestBehavior.AllowGet));
        }
Beispiel #30
0
 private GetChatRightEnterID_Result GetChatRightEnterID(int enterID, string machineNo)
 {
     if (!string.IsNullOrEmpty(machineNo))
     {
         string appServer = ConfigurationManager.AppSettings["appServerDb"];
         Uri    uri       = new Uri(string.Format("{0}Db/GetChatRightEnterID?enterID={1}&machineNo={2}"
                                                  , appServer, enterID, machineNo));
         AjaxReturn result = ChatHelper.RemoteRequest <AjaxReturn>(uri);
         if (result.Code == 0)
         {
             return(new GetChatRightEnterID_Result()
             {
                 Return = result.d.Return.ToString(),
                 Type = result.d.Type
             });
         }
     }
     return(new GetChatRightEnterID_Result()
     {
         Return = enterID.ToString(), Type = 1
     });
 }
Beispiel #31
0
 public AjaxReturn BatchStatus(int id)
 {
     AjaxReturn result = new AjaxReturn();
     AppModule module = AppModule.GetBatchJob(id);
     if (module == null) {
         Log("Invalid batch id");
         result.error = "Invalid batch id";
     } else {
         BatchJob batch = module.Batch;
         if (batch == null) {
             Log("Invalid batch id");
             result.error = "Invalid batch id";
         } else {
             Log("Batch {0}:{1}%:{2}", batch.Id, batch.PercentComplete, batch.Status);
             result.data = batch;
             if (batch.Finished) {
                 result.error = batch.Error;
                 result.redirect = batch.Redirect;
                 Log("Batch finished - redirecting to {0}", batch.Redirect);
             }
         }
     }
     return result;
 }
Beispiel #32
0
        /// <summary>
        /// Update an account after editing.
        /// </summary>
        public AjaxReturn DetailSave(Account json)
        {
            Account existing = Database.Get(json);

            Utils.Check(!existing.Protected, "Cannot edit a protected account");
            Database.BeginTransaction();
            AjaxReturn result = SaveRecord(json, true);

            if (string.IsNullOrEmpty(result.error) && existing.idAccount > 0 && json.AccountName != existing.AccountName)
            {
                // This might be a parent account - if so change the name of subaccounts
                foreach (Account a in Database.Query <Account>("SELECT * FROM Account WHERE AccountName LIKE "
                                                               + Database.Quote(existing.AccountName + ":%")))
                {
                    if (a.AccountName.StartsWith(json.AccountName + ":"))
                    {
                        a.AccountName = json.AccountName + a.AccountName.Substring(json.AccountName.Length);
                        Database.Update(a);
                    }
                }
            }
            Database.Commit();
            return(result);
        }
Beispiel #33
0
 /// <summary>
 /// Action a job
 /// </summary>
 public AjaxReturn JobAction(int id)
 {
     AjaxReturn ret = new AjaxReturn();
     Schedule job = Database.Get<Schedule>(id);
     Utils.Check(job.idSchedule != null, "Job {0} not found", id);
     if (!string.IsNullOrWhiteSpace(job.Url)) {
         // Job actually does something
         if (job.Post) {
             // It posts a record
             string methodName = job.Url;
             string moduleName = Utils.NextToken(ref methodName, "/");
             Type type = AppModule.GetModule(moduleName);
             Utils.Check(type != null, "Invalid schedule job {0}", job.Url);
             AppModule module = (AppModule)Activator.CreateInstance(type);
             module.Context = Context;
             module.OriginalModule = module.Module = moduleName.ToLower();
             module.OriginalMethod = module.Method = (string.IsNullOrEmpty(methodName) ? "default" : Path.GetFileNameWithoutExtension(methodName)).ToLower();
             module.GetParameters = new NameValueCollection();
             module.Parameters["json"] = job.Parameters;
             module.Parameters["date"] = job.ActionDate;
             MethodInfo method;
             object o = module.CallMethod(out method);
             if (method == null) {
                 ret.error = "Job url not found " + job.Url;
             } else if (method.ReturnType == typeof(AjaxReturn)) {
                 ret = o as AjaxReturn;
                 if (ret.error == null && ret.redirect != null)
                     ret.redirect += "&from=" + HttpUtility.UrlEncode(Parameters.AsString("from"));
                 ret.id = null;
             } else {
                 throw new CheckException("Unexpected return type {0}", method.ReturnType.Name);
             }
         } else {
             // It just redirects somewhere
             ret.redirect = Path.ChangeExtension(job.Url, ".html") + "?id=" + id;
         }
     }
     if (string.IsNullOrEmpty(ret.error)) {
         // Update job to say it is done
         switch ((RepeatType)job.RepeatType) {
             case RepeatType.None:
                 // No repeat - delete job
                 Database.Delete(job);
                 ret.message = "Job deleted";
                 return ret;
             case RepeatType.Daily:
                 job.ActionDate = job.ActionDate.AddDays(1);
                 while (job.ActionDate.DayOfWeek == DayOfWeek.Saturday || job.ActionDate.DayOfWeek == DayOfWeek.Sunday)
                     job.ActionDate = job.ActionDate.AddDays(1);
                 break;
             case RepeatType.Weekly:
                 job.ActionDate = job.ActionDate.AddDays(7);
                 break;
             case RepeatType.Monthly:
                 job.ActionDate = job.ActionDate.AddMonths(1);
                 break;
             case RepeatType.Quarterly:
                 job.ActionDate = job.ActionDate.AddMonths(3);
                 break;
             case RepeatType.Yearly:
                 job.ActionDate = job.ActionDate.AddYears(1);
                 break;
             default:
                 throw new CheckException("Invalid repeat type {0}", job.RepeatType);
         }
         Database.Update(job);
     }
     ret.id = job.idSchedule;
     return ret;
 }
Beispiel #34
0
 public AjaxReturn JobDelete(int id)
 {
     AjaxReturn result = new AjaxReturn();
     try {
         Database.Delete("Schedule", id, false);
         result.message = "Job deleted";
     } catch {
         result.error = "Cannot delete";
     }
     return result;
 }
 public AjaxReturn VatCodeDelete(int id)
 {
     AjaxReturn result = new AjaxReturn();
     try {
         Database.Delete("VatCode", id, true);
         result.message = "VAT code deleted";
     } catch {
         result.error = "Cannot delete - VAT code in use";
     }
     return result;
 }
Beispiel #36
0
		public AjaxReturn ProductDelete(int id) {
			AjaxReturn result = new AjaxReturn();
			try {
				Database.Delete("Product", id, true);
				result.message = "Product deleted";
			} catch {
				result.error = "Cannot delete - Product in use";
			}
			return result;
		}