Beispiel #1
0
        public FileResult ChatImage()
        {
            if (!IsDatabaseCreated)
            {
                ViewBag.notinstalled = true;
                return(null);
            }

            try
            {
                RequestService.LogRequest(new WebRequest()
                {
                    DomainName       = Request.Url.Host,
                    PageRequested    = Request.UrlReferrer.AbsolutePath,
                    Referrer         = Request.QueryString["r"] != null ? Server.UrlDecode(Request.QueryString["r"].ToString()) : "",
                    Requested        = DateTime.Now,
                    VisitorIp        = Request.UserHostAddress,
                    VisitorUserAgent = Request.UserAgent
                });

                string file = Server.MapPath("/Content/LCSK/" + (OperatorService.GetOperatorStatus() ? "online.jpg" : "offline.jpg"));
                return(new FileStreamResult(new FileStream(file, FileMode.Open), "image/jpg"));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
    /// <summary>
    /// 跟据域名更新快捷回复
    /// </summary>
    /// <param name="operatorId"></param>
    /// <param name="response"></param>
    public static void SaveQuickResponseByDomainName(string operatorId, string domainName, List <QuickResponseCategory> response)
    {
        string accountId = OperatorService.GetOperatorById(operatorId).AccountId;

        DBProvider.DeleteQuickResponseByDomainName(domainName);
        foreach (var item in response)
        {
            QuickResponse qr = new QuickResponse();
            qr.DomainName = domainName;
            qr.AccountId  = accountId;
            qr.Submenu    = item.Name;
            qr.OperatorId = operatorId;
            string node = string.Empty;
            foreach (var n in item.Responses)
            {
                node += n.ToString() + "|";
            }
            if (node.Length > 0 && node[node.Length - 1] == '|')
            {
                node = node.Substring(0, node.Length - 1);
            }
            qr.Node = node;
            DBProvider.NewQuickResponse(qr);
        }
    }
            public bool LockResult()
            {
                OperatorService opServ = new OperatorService();
                bool            f      = opServ.Lock(username, flag);

                return(f);
            }
Beispiel #4
0
        public LoginResult IsValid()
        {
            OperatorService opServ = new OperatorService();
            Operator        op     = opServ.GetOperator(username);

            if (op == null)
            {
                return(LoginResult.UserNameError);
            }
            else if (op.Password != password)
            {
                return(LoginResult.PasswordError);
            }
            else if (op.IsDeleted)
            {
                return(LoginResult.DeletedError);
            }
            else if (op.IsLocked)
            {
                return(LoginResult.LockedError);
            }
            else
            {
                return(LoginResult.OK);
            }
        }
Beispiel #5
0
    public void SendFile(string fileName, string chatId, object action)
    {
        checkAuthentication();
        string saveFilePath = Server.MapPath("~/upload/" + chatId + "/");

        OperatorService.SendFile(fileName, chatId, saveFilePath, action);
    }
Beispiel #6
0
    public void UploadFile(byte[] bs, string fileName, string chatId)
    {
        checkAuthentication();
        string saveFilePath = Server.MapPath("~/upload/" + chatId + "/");

        OperatorService.UploadFile(bs, fileName, chatId, saveFilePath);
    }
        public async void 管理ユーザー認証ユーザーの新規登録招待メールの送信を行う()
        {
            // Arrange
            var roleName                  = "Administrator";
            var name                      = "管理太郎";
            var emailAddress              = "*****@*****.**";
            var loginId                   = "loginID";
            var mockOperatorUseCase       = new Mock <IOperatorUseCase>();
            var mockaAuthorizationUseCase = new Mock <IAuthorizationUseCase>();

            mockaAuthorizationUseCase.Setup(o => o.AddAuthorizationLink(loginId))
            .ReturnsAsync(new AuthorizationLink(loginId, DateTime.Now))
            .Verifiable();
            var mockUserManager = this.GetMockUserManager();
            var service         = new OperatorService(mockOperatorUseCase.Object, mockaAuthorizationUseCase.Object, mockUserManager.Object);

            // Act
            await service.RegisterOperator(roleName, name, emailAddress, loginId, "https://example.com");

            // Assert
            mockOperatorUseCase.Verify(m => m.RegisterOperator(name, emailAddress, loginId), Times.Once());
            mockOperatorUseCase.Verify(m => m.SendOperatorInvitaionMail(emailAddress, It.IsAny <string>()), Times.Once());
            mockaAuthorizationUseCase.Verify();
            mockUserManager.Verify(m => m.GenerateEmailConfirmationTokenAsync(It.IsAny <ApplicationUser>()), Times.Once());
            mockUserManager.Verify(m => m.CreateAsync(It.IsAny <ApplicationUser>()), Times.Once());
            mockUserManager.Verify(m => m.AddToRoleAsync(It.IsAny <ApplicationUser>(), roleName), Times.Once());
        }
Beispiel #8
0
        public JsonResult LoginX(string username, string password)
        {
            AjaxMsgResult   result    = new AjaxMsgResult();
            OperatorService omService = new OperatorService();

            password = MD5Helper.Md5(password);
            var op = omService.GetbyPwd(username, password);

            if (op != null)
            {
                if (op.Isvalid == 1)
                {
                    Authentication.Instance.SetAuth(op, false);
                    result.Success = true;
                    result.Msg     = "登录成功!";
                }
                else
                {
                    result.Success = false;
                    result.Msg     = "帐号已被禁用,请联系管理员!";
                }
            }
            else
            {
                result.Success = false;
                result.Msg     = "帐号或密码错误!";
            }
            return(Json(result));
        }
        public IActionResult AddNumbers([FromBody] NumberReq req)
        {
            try
            {
                var number1 = req.number1;
                var number2 = req.number2;

                OperatorService osService = new OperatorService(number1, number2);

                Calculation calculation = new Calculation();
                calculation.Number1 = number1;
                calculation.Number2 = number2;
                calculation.LogTime = DateTime.Now;
                calculation.Operand = osService.OperandString;
                calculation.Result  = new OperatorService(number1, number2).Calculate();

                calcRepo.AddCalculationResult(calculation);
            }
            catch (Exception ex)
            {
                filer.LogError(ex.Message);
            }

            return(Ok());
        }
        public async Task <IHttpActionResult> PostOperatorInfo(OperatorInfoViewModel operatorInfo)
        {
            if (operatorInfo == null)
            {
                return(NotFound());
            }
            var logService = new LogService();

            if (string.IsNullOrWhiteSpace(operatorInfo.Badge) || !int.TryParse(operatorInfo.Badge, out _))
            {
                return(BadRequest("Invalid badge number"));
            }

            using (var operatorService = new OperatorService())
            {
                var employee = operatorService.GetOperatorByBadge(operatorInfo.Badge.PadLeft(6, '0'));
                if (employee != null)
                {
                    await logService.WriteLogAsync(operatorInfo, "PostOperatorInfo. Employee found.");

                    if (!operatorInfo.Validating)  // just save the confirmation in the database if it is not for validation purposes.
                    {
                        operatorService.SaveOperatorAcknowledgementToDisclaimer(employee.Badge, operatorInfo.Agreed, operatorInfo.DeviceGuid, "", operatorInfo.IncidentDateTime);
                    }
                }
                else
                {
                    await logService.WriteLogAsync(operatorInfo, "PostOperatorInfo. Employee not found.");
                }
                return(employee != null
                    ? Ok(employee)
                    : (IHttpActionResult)NotFound());
            }
        }
            public bool AddResult()
            {
                OperatorService opServ = new OperatorService();
                bool            f      = opServ.Add(id, username, password, isdeleted, realname, islocked);

                return(f);
            }
Beispiel #12
0
        /// <summary>
        /// 保存管理员信息
        /// </summary>
        /// <param name="opInfo"></param>
        /// <returns></returns>
        public JsonResult EditSave(OperatorInfo opInfo)
        {
            AjaxMsgResult   result      = new AjaxMsgResult();
            OperatorService x_opService = new OperatorService();

            if (opInfo.Id > 0)  //更新
            {
                int i = x_opService.Update(() => new OperatorInfo()
                {
                    Username = opInfo.Username, Loginname = opInfo.Loginname
                }, a => a.Id == opInfo.Id);
                if (i > 0)
                {
                    result.Success = true;
                }
                else
                {
                    result.Msg = "更新失败,没有找到该用户!";
                }
            }
            else
            {
                opInfo.Isvalid       = 1;
                opInfo.Createtime    = DateTime.Now;
                opInfo.Lastlogintime = ConstHelper.SqlServerMinTime;
                opInfo.Userpass      = MD5Helper.Md5small(opInfo.Userpass);
                x_opService.Insert(opInfo);
                result.Success = true;
            }
            return(Json(result));
        }
            public bool DeleteResult()
            {
                OperatorService opServ = new OperatorService();
                bool            f      = opServ.Delete(username, flag);

                return(f);
            }
Beispiel #14
0
        public void TestLogin2()
        {
            // 测试多个客服端用同一个客服帐号登录
            LiveSupport.LiveSupportDAL.SqlProviders.DBHelper.ConnectionString = "Server=rd01;Database=LiveSupport;User ID=sa;Password=;Trusted_Connection=False;";
            Account a = new Account();

            a.LoginName = Util.RandLetter(10);
            a.Password  = "******";

            AccountsManager.AddAccount(a);
            Operator op = OperatorService.Login(a.LoginName, a.LoginName, a.Password);

            Assert.AreEqual(a.AccountId, op.OperatorId);
            Assert.AreEqual(op.LoginName, a.LoginName);
            Account ac = AccountService.FindAccountByLoginName(a.LoginName);

            Assert.AreEqual(op.AccountId, ac.AccountId);
            Assert.AreEqual(op.Password, a.Password);
            Assert.AreEqual(op.Status, OperatorStatus.Idle);

            Operator op2 = OperatorService.Login(a.LoginName, a.LoginName, a.Password);

            Assert.IsNull(op2);

            OperatorService.Logout(op.OperatorId);

            op = OperatorService.Login(a.LoginName, a.LoginName, a.Password);
            Assert.IsNotNull(op);
        }
Beispiel #15
0
        private VisitorInitViewModel InitRequest()
        {
            VisitorInitViewModel vm = new VisitorInitViewModel();

            var onlineOps = OperatorService.GetOnlineOperator();

            List <string> departments = new List <string>();

            foreach (var op in onlineOps)
            {
                foreach (string d in op.Department.Split(','))
                {
                    if (!departments.Contains(d.ToLower()))
                    {
                        departments.Add(d.ToLower());
                    }
                }
            }

            vm.Departments    = departments;
            vm.ChatOnline     = onlineOps.Count() > 0;
            vm.NewChatRequest = new ChatRequest();

            return(vm);
        }
Beispiel #16
0
    /// <summary>
    /// 客服接受访客对话请求
    /// </summary>
    /// <param name="operatorId"></param>
    /// <param name="chatId"></param>
    /// <returns></returns>
    public static int AcceptChatRequest(string operatorId, string chatId)
    {
        Trace.WriteLine(string.Format("ChatService.AcceptChatRequest(OperatorId={0},ChatId={1})", operatorId, chatId));

        Chat chat = GetChatById(chatId);

        if (chat == null)
        {
            Trace.WriteLine(string.Format("Error: AcceptChatRequest(OperatorId={0},ChatId={1}) error, can't find this chat", operatorId, chatId));
            return(AcceptChatRequestReturn_Error_Others);
        }

        if (chat.Status == ChatStatus.Accepted)
        {
            return(AcceptChatRequestReturn_Error_AcceptedByOthers);
        }
        else if (chat.Status == ChatStatus.Requested)
        {
            chat.Status     = ChatStatus.Accepted;
            chat.OperatorId = operatorId;
            chat.AcceptTime = DateTime.Now;

            if (VisitorChatRequestAccepted != null)
            {
                VisitorChatRequestAccepted(null, new VisitorChatRequestAcceptedEventArgs(new VisitorChatRequestEventArgs(chat.VisitorId, chat)));
            }
            Message m1 = new Message();
            m1.ChatId   = chat.ChatId;
            m1.SentDate = DateTime.Now;
            m1.Type     = MessageType.SystemMessage_ToVisitor;
            m1.Text     = string.Format("客服:{0}已经接受您的对话请求", OperatorService.GetOperatorById(operatorId).NickName);
            SendMessage(m1);

            Message m2 = new Message();
            m2.ChatId   = chat.ChatId;
            m2.SentDate = DateTime.Now;
            m2.Type     = MessageType.SystemMessage_ToOperator;
            m2.Text     = string.Format("你已经接受访客{0}的对话请求", VisitorService.GetVisitorById(chat.VisitorId).Name);
            SendMessage(m2);

            OperatorService.SetOperatorStatus(operatorId, OperatorStatus.Chatting);

            VisitSession s = VisitSessionService.GetSessionById(VisitorService.GetVisitorById(chat.VisitorId).CurrentSessionId);
            s.OperatorId  = operatorId;
            s.Status      = VisitSessionStatus.Chatting;
            s.ChatingTime = DateTime.Now;

            return(AcceptChatRequestReturn_OK);
        }
        else if (chat.Status == ChatStatus.Closed)
        {
            return(AcceptChatRequestReturn_Error_ChatRequestCanceled);
        }
        else
        {
            Trace.WriteLine(string.Format("ChatService.AccpetChatRequest({0},{1}) error,status illegal: ChatStatus={2}", operatorId, chatId, chat.Status));
            return(AcceptChatRequestReturn_Error_Others);
        }
    }
Beispiel #17
0
 public List <ChatRequest> GetChatRequests(Guid key, Operator op)
 {
     if (!IsAuthenticated(key))
     {
         throw new Exception("The key is not authenticated");
     }
     return(OperatorService.GetChatRequests(op.OperatorId, op.DepartmentList()));
 }
Beispiel #18
0
 public ChatRequest Invite(Guid key, int operatorId, string visitorIp, string prompt)
 {
     if (!IsAuthenticated(key))
     {
         throw new Exception("The key is not authenticated");
     }
     return(OperatorService.InviteVisitor(operatorId, visitorIp, prompt));
 }
Beispiel #19
0
 public bool Delete(Guid key, Operator op)
 {
     if (!IsAuthenticated(key))
     {
         throw new Exception("The key is not authenticated");
     }
     return(OperatorService.Delete(op));
 }
Beispiel #20
0
 public List <Operator> GetOperators(Guid key)
 {
     if (!IsAuthenticated(key))
     {
         throw new Exception("The key is not authenticated");
     }
     return(OperatorService.List());
 }
Beispiel #21
0
 public ActionResult InstallDatabase(string id)
 {
     if (OperatorService.CreateDatabase(id))
     {
         return(RedirectToAction("InstallCompleted"));
     }
     return(RedirectToAction("InstallError"));
 }
Beispiel #22
0
        public void SetOperatorStatus(Guid key, int operatorId, bool isOnline)
        {
            if (!IsAuthenticated(key))
            {
                throw new Exception("The key is not authenticated");
            }

            OperatorService.UpdateStatus(operatorId, isOnline);
        }
Beispiel #23
0
        /// <summary>
        /// 客脑主动邀请 to-all
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void ChatService_OperatorChatRequest(object sender, OperatorChatRequestEventArgs e)//wang-ok
        {
            Operator op = OperatorService.GetOperatorById(e.OperatorId);

            foreach (var item in GetOnlineOperatorSockets(op.AccountId))
            {
                sh.SendPacket(item, e);
            }
        }
Beispiel #24
0
        private void FmLogin_Load(object sender, EventArgs e)
        {
            OperatorService os = new OperatorService();

            operatorData              = os.LoadEntities(c => true).ToList();
            cbxOperator.DataSource    = operatorData;
            cbxOperator.DisplayMember = "CODENO";
            cbxOperator.ValueMember   = "OPERATORID";
            cbxOperator.Focus();
        }
Beispiel #25
0
        public Operator LogIn(string userName, string password)
        {
            var op = OperatorService.LogIn(userName, password);

            if (op != null)
            {
                op.Password = SetAuthentication(op.OperatorId).ToString();
            }
            return(op);
        }
Beispiel #26
0
        public ActionResult Index(string pass)
        {
            var op = OperatorService.LogIn("admin", pass);

            if (op != null)
            {
                ViewBag.isadmin = HttpContext.Session["lcsk_isadmin"] = true;
            }
            return(View());
        }
Beispiel #27
0
 protected void Timer1_Tick(object sender, EventArgs e)
 {
     this.GridView5.DataSource = AccountService.getAllaccount();
     this.GridView1.DataSource = OperatorService.GetAllOperators();
     this.GridView2.DataSource = ChatService.GetAllChat();
     LiveSupport.BLL.Utils.Util.SysDateStates li = LiveSupport.BLL.Utils.Util.GetSysInfo();
     this.Label4.Text = li.StartApplicationDate.ToString();
     this.Label5.Text = li.StartSessionDate.ToString();
     DataBind();
 }
        public async void LoadOperators()
        {
            using (IUnitOfWork uow = UnitOfWorkFactory.Create())
            {
                OperatorService operatorService = new OperatorService(uow);
                List <Operator> ops             = await operatorService.GetOperatorsAsync();

                //List<Operator> op2 = operatorService.GetOperatorsAsync2().Result;
            }
        }
Beispiel #29
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            Operator op = new Operator(nameTextBox.Text, contactNoTextBox.Text, emailTextBox.Text, addressTextBox.Text, Convert.ToDouble(initialSalaryTextBox.Text), Convert.ToDateTime(joinDatePicker.Text));

            OperatorService operatorService = new OperatorService();

            operatorService.AddOperator(op);
            MessageBox.Show("Operator Added Successfully \nID : " + op.Id + " \nPassword : "******" \n *Please Keep Id and Password in mind", "Successful", MessageBoxButton.OK, MessageBoxImage.Information);
            LoadData();
        }
            public bool UpdateResult(string newpwd, string renewpwd)
            {
                OperatorService opServ = new OperatorService();
                bool            f      = opServ.Update(username, newpwd);

                if (f && newpwd == renewpwd)
                {
                    return(true);
                }
                return(false);
            }