Example #1
0
        public void UpdateEntity(int entityTypeId, int entityId, string entityName, int accountTypeId, int accountId, string entityCustomData)
        {
            var r = TicketEntities.SingleOrDefault(x => x.EntityTypeId == entityTypeId);

            if (r == null && entityId > 0)
            {
                TicketEntities.Add(new TicketEntity
                {
                    EntityId         = entityId,
                    EntityName       = entityName,
                    EntityTypeId     = entityTypeId,
                    AccountTypeId    = accountTypeId,
                    AccountId        = accountId,
                    EntityCustomData = entityCustomData
                });
            }
            else if (r != null && entityId > 0)
            {
                r.AccountId        = accountId;
                r.AccountTypeId    = accountTypeId;
                r.EntityId         = entityId;
                r.EntityName       = entityName;
                r.EntityTypeId     = entityTypeId;
                r.EntityCustomData = entityCustomData;
            }
            else if (r != null && entityId == 0)
            {
                TicketEntities.Remove(r);
            }
        }
 public TicketEntities TrackChanges(TicketEntities TicketEntities, TicketEntities currentTicketEntities)
 {
     TicketEntities.Changes.ForAction  = (TicketEntities.Contact.ForAction ?? "").ToLower().Trim() != (currentTicketEntities.Contact.ForAction ?? "").ToLower().Trim();
     TicketEntities.Changes.AssignedTo = (TicketEntities.Contact.AssignedTo ?? "").ToLower().Trim() != (currentTicketEntities.Contact.AssignedTo ?? "").ToLower().Trim();
     TicketEntities.Changes.Priority   = TicketEntities.Contact.Priority != currentTicketEntities.Contact.Priority;
     return(TicketEntities);
 }
        public TicketEntities ManageChanges(TicketEntities TicketEntities)
        {
            log.Debug(string.Format("Begin ManageChanges({0})", TicketEntities.Contact.FileNum));
            try
            {
                if (TicketEntities.Contact.FileNum < 1)
                {
                    return(TicketEntities);
                }
                var currentTicketEntities = Get(TicketEntities.Contact.FileNum);
                var contact = TicketEntities.Contact;

                // Preserve deprecated columns
                contact.ForInfos          = currentTicketEntities.Contact.ForInfos;
                contact.Resolution        = currentTicketEntities.Contact.Resolution;
                contact.ResolutionComment = currentTicketEntities.Contact.ResolutionComment;
                contact.SeniorComplaint   = currentTicketEntities.Contact.SeniorComplaint;
                contact.HomePhone         = currentTicketEntities.Contact.HomePhone;
                contact.WorkPhone         = currentTicketEntities.Contact.WorkPhone;

                // Handle change tracking
                return(TrackChanges(TicketEntities, currentTicketEntities));
            }
            finally
            {
                log.Debug(string.Format("End ManageChanges({0})", TicketEntities.Contact.FileNum));
            }
        }
        private TicketEntities Fill(tblContacts contact)
        {
            log.Debug(string.Format("Begin Fill({0})", contact.FileNum));
            try
            {
                var Id     = contact.FileNum;
                var result = new TicketEntities
                {
                    Contact               = contact,
                    Attachments           = context.tblAttachments.Where(a => a.FileNum == Id).ToList(),
                    ResponseHistory       = context.tblContactHistory.Where(a => a.FileNum == Id).ToList(),
                    ResearchHistory       = context.tblResearchHistory.Where(a => a.FileNum == Id).ToList(),
                    IncidentUpdateHistory = context.tblIncidentUpdateHistory.Where(a => a.FileNum == Id).ToList(),
                    LinkedContacts        = context.tblLinkedContacts.Where(a => a.FileNum == Id).ToList(),
                    ChangeHistory         = context.tblUpdateLog.Where(a => a.FileNum == Id).ToList(),
                };
                if (DetachGet)
                {
                    log.Debug(string.Format("Detaching new TicketEntities"));
                    result.Detach(context);
                }

                return(result);
            }
            finally
            {
                log.Debug(string.Format("End Fill({0})", contact.FileNum));
            }
        }
    /* Module Name: Signin_Click;
     * Student: Mayank Yadav
     * Modification Date: 23-April-2018
     * Description: Create the sesssion of the client username
     * Input/Outputs: Staff username and password
     * Globals: No global changes.
     */
    protected void Signin_Click(object sender, EventArgs e)
    {
        TicketEntities te       = new TicketEntities();
        Client         st       = new Client();
        string         username = firstname.Text;
        string         password = pass_word.Text;

        if (username != null && password != null)
        {
            bool result = te.Clients.Any(x => x.Email.Equals(username) && x.Password.Equals(password));
            if (result == true)
            {
                Session["ClientUser"] = username;
                Server.Transfer("ClientDashboard.aspx", true);
            }
            else
            {
                Response.Redirect(Request.RawUrl);
            }
        }
        else
        {
            Response.Redirect(Request.RawUrl);
        }
    }
Example #6
0
 // GET api/<controller>
 public IEnumerable <tTicket> Get()
 {
     using (var ctx = new TicketEntities())
     {
         return(ctx.tTicket);
     }
 }
        /// <summary>
        /// 根据Token获取用户详细信息
        /// </summary>
        /// <param name="token"></param>
        /// <returns>用户详细信息</returns>
        public UserModel GetUserDetailByToken(string token)
        {
            using (var dbContext = new TicketEntities())
            {
                if (string.IsNullOrEmpty(token))
                {
                    return(null);
                }

                var member = dbContext.N_User.FirstOrDefault(item => item.Token.Equals(token, StringComparison.OrdinalIgnoreCase));

                if (member == null)
                {
                    //Log.Debug("登录用户无效");
                    return(null);
                }

                if (member.IsTokenExpired())
                {
                    member.Token = string.Empty;
                    SaveDbChanges(dbContext);

                    Log.Debug("登录凭证过期");
                    return(null);
                }

                var model = member.ToModel();

                return(model);
            }
        }
Example #8
0
 // POST api/<controller>
 public void Post([FromBody] tTicket value)
 {
     using (var ctx = new TicketEntities())
     {
         value.TicketId = 0;//TODO:追加処理
         ctx.tTicket.Add(value);
     }
 }
Example #9
0
 // GET api/<controller>/5
 public tTicket Get(int id)
 {
     using (var ctx = new TicketEntities())
     {
         var entity = ctx.tTicket.SingleOrDefault(p => p.TicketId == id);
         return(entity);
     }
 }
        /// <summary>
        /// 代理商登录
        /// </summary>
        /// <param name="model">登录信息</param>
        /// <returns>用户登录Token</returns>
        public string GetUserToken(UserAddModel model)
        {
            using (var dbContext = new TicketEntities())
            {
                if (string.IsNullOrEmpty(model.MerchantId) && string.IsNullOrEmpty(model.UserName) && string.IsNullOrEmpty(model.SignKey))
                {
                    throw new KeyNotFoundException("无效的用户登录信息");
                }

                //1, 判断用户是否存在
                var merchantEntity = dbContext.N_Merchant.FirstOrDefault(it => (it.MerchantId.Equals(model.MerchantId, StringComparison.OrdinalIgnoreCase)));

                if (merchantEntity == null)
                {
                    Log.Error("商户不存在");
                    throw new KeyNotFoundException("商户不存在");
                }

                if (string.IsNullOrEmpty(merchantEntity.Code))
                {
                    Log.Error("无效的商户");
                    throw new KeyNotFoundException("无效的商户");
                }

                //2, 验证加密串
                var signKey = MD5Cryptology.GetMD5(string.Format("{0}&{1}&{2}", model.MerchantId, model.UserName, merchantEntity.Code), "gb2312");
                if (string.Compare(signKey, model.SignKey, true) != 0)
                {
                    Log.Error("无效的商户安全码:" + signKey);
                    throw new KeyNotFoundException("无效的商户安全码:" + signKey);
                }

                //3,验证用户
                var userEntity = dbContext.N_User.FirstOrDefault(it => it.UserName.Equals(model.UserName, StringComparison.OrdinalIgnoreCase));

                if (userEntity == null)
                {
                    Log.Error("用户不存在");
                    throw new KeyNotFoundException("用户不存在");
                }

                var token = this.GenerateToken();                    // 获取用户登录Token
                userEntity.Token          = token;
                userEntity.ExpirationTime = DateTime.Now.AddDays(2); // 设置Token有效期
                SaveDbChanges(dbContext);

                string message = null;

                if (string.IsNullOrEmpty(token))
                {
                    message = "登录失败,请重新登录!";
                }

                message = "恭喜你,登陆成功!";

                return(token + "@" + message);
            }
        }
Example #11
0
        public string GetEntityName(int entityTypeId)
        {
            var tr = TicketEntities.FirstOrDefault(x => x.EntityTypeId == entityTypeId);

            if (tr != null)
            {
                return(tr.EntityName);
            }
            return("");
        }
Example #12
0
 // DELETE api/<controller>/5
 public void Delete(int id)
 {
     using (var ctx = new TicketEntities())
     {
         var entity = ctx.tTicket.SingleOrDefault(p => p.TicketId == id);
         if (entity != null)
         {
             ctx.tTicket.Remove(entity);
             ctx.SaveChanges();
         }
     }
 }
Example #13
0
 public ActionResult AdminLogin()
 {
     if (Session["AdminId"] != null)
     {
         TicketEntities tktdb = new TicketEntities();
         return(View(tktdb.Ticket.AsEnumerable()));
     }
     else
     {
         return(RedirectToAction("Login"));
     }
 }
Example #14
0
        public ActionResult Details(int?id)
        {
            TicketEntities ticketdb = new TicketEntities();

            foreach (var item in ticketdb.Ticket)
            {
                if (item.id == id)
                {
                    return(View(item));
                }
            }
            return(View("error"));
        }
        public TicketEntities GetContact(int Id)
        {
            var result = new TicketEntities
            {
                Contact = context.tblContacts.FirstOrDefault(c => c.FileNum == Id)
            };

            if (!DetachGet)
            {
                return(result);
            }
            log.Debug(string.Format("Detaching {0}", result.Contact.FileNum));
            result.Detach(context);
            return(result);
        }
Example #16
0
        // PUT api/<controller>/5
        public void Put(int id, [FromBody] tTicket value)
        {
            using (var ctx = new TicketEntities())
            {
                var entity = ctx.tTicket.SingleOrDefault(p => p.TicketId == id);

                if (entity == null)
                {
                    return;
                }

                ctx.tTicket.Attach(value);
                ctx.Entry(value).State = System.Data.Entity.EntityState.Modified;
                ctx.SaveChanges();
            }
        }
 /// <summary>
 /// 提交数据库变更
 /// </summary>
 /// <param name="dbContext">数据库上下文</param>
 /// <returns></returns>
 protected virtual int SaveDbChanges(TicketEntities dbContext)
 {
     try
     {
         return(dbContext.SaveChanges());
     }
     catch (DbEntityValidationException ex)
     {
         LogDatabaseError(ex);
         throw;
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Example #18
0
    /* Module Name: Signup_Click;
     * Student: Mayank Yadav
     * Modification Date: 23-April-2018
     * Description: Insert the record in CLient Table
     * Input/Outputs: Fullname, Username , password, confirm password and other details
     * Globals: No global changes.
     */
    protected void Signup_Click(object sender, EventArgs e)
    {
        TicketEntities te               = new TicketEntities();
        string         fullname         = Fullname.Text;
        string         gender           = Gender.Text;
        string         email            = username.Text;
        string         password         = pass_word.Text;
        string         confirm_password = confirmpassword.Text;
        string         streetaddress1   = StreetAddress1.Text;
        string         streetaddress2   = StreetAddress2.Text;
        string         city             = City.Text;
        string         state            = State.Text;
        string         country          = Country.Text;
        string         zip              = Zip.Text;

        if (fullname != null && email != null && password != null && confirm_password != null && password.Equals(confirm_password))
        {
            Client st = new Client()
            {
                FullName       = fullname,
                Gender         = gender,
                Email          = email,
                Password       = password,
                StreetAddress1 = streetaddress1,
                StreetAddress2 = streetaddress2,
                City           = city,
                State          = state,
                Country        = country,
                Zip            = zip
            };

            te.Clients.Add(st);
            try
            {
                te.SaveChanges();
                Response.Redirect("ClientLogin.aspx");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
        else
        {
            Response.Redirect(Request.RawUrl);
        }
    }
 public TicketEntities Fill(TicketEntities TicketEntities, CusRelDbContext context)
 {
     if (IncludeContactHistory)
     {
         TicketEntities.ResponseHistory =
             (from rh in context.tblContactHistory
              where rh.FileNum == TicketEntities.Contact.FileNum
              select rh).ToList();
     }
     if (IncludeResearchHistory)
     {
         TicketEntities.ResearchHistory =
             (from rh in context.tblResearchHistory
              where rh.FileNum == TicketEntities.Contact.FileNum
              select rh).ToList();
     }
     return(TicketEntities);
 }
Example #20
0
 public ActionResult CustomerLogin()
 {
     if (Session["UserId"] != null)
     {
         TicketEntities ticketdb = new TicketEntities();
         List <Ticket>  tkt      = new List <Ticket>();
         foreach (var item in ticketdb.Ticket)
         {
             if (item.SenderId == (int)Session["UserId"])
             {
                 tkt.Add(item);
             }
         }
         return(View(tkt.AsEnumerable()));
     }
     else
     {
         return(RedirectToAction("Login"));
     }
 }
Example #21
0
        public ActionResult Create(Ticket tkt)
        {
            if (ModelState.IsValid)
            {
                MailSender.SendMail("*****@*****.**", tkt.konu, tkt.problem);

                using (TicketEntities TicketDb = new TicketEntities())
                {
                    tkt.name     = Session["Username"].ToString();;
                    tkt.surname  = Session["Surname"].ToString();
                    tkt.SenderId = (int)Session["UserId"];
                    tkt.tarih    = DateTime.Now;
                    tkt.okundu   = 0;
                    TicketDb.Ticket.Add(tkt);
                    TicketDb.SaveChanges();
                }
                ModelState.Clear();
                return(RedirectToAction("CustomerLogin"));
            }
            else
            {
                return(View("CustomerLogin"));
            }
        }
Example #22
0
        /// <summary>
        /// 会员充值
        /// </summary>
        /// <param name="model">充值信息</param>
        /// <returns>账户余额</returns>
        public UserChargeResultModel Charge(UserChargeModel model)
        {
            using (var dbContext = new TicketEntities())
            {
                if (string.IsNullOrEmpty(model.MerchantId) && string.IsNullOrEmpty(model.UserName) && string.IsNullOrEmpty(model.SignKey))
                {
                    throw new InvalidOperationException("无效的用户登录信息");
                }

                if (model.Amount <= 0)
                {
                    throw new InvalidOperationException("无效的充值金额");
                }

                //1, 判断用户是否存在
                var merchantEntity = dbContext.N_Merchant.FirstOrDefault(it => (it.MerchantId.Equals(model.MerchantId, StringComparison.OrdinalIgnoreCase)));

                if (merchantEntity == null)
                {
                    Log.Error("商户不存在");
                    throw new InvalidOperationException("商户不存在");
                }

                if (string.IsNullOrEmpty(merchantEntity.Code))
                {
                    Log.Error("无效的商户信息");
                    throw new InvalidOperationException("无效的商户信息");
                }

                //2,验证用户
                var userEntity = dbContext.N_User.FirstOrDefault(it => it.UserName.Equals(model.UserName, StringComparison.OrdinalIgnoreCase));

                if (userEntity == null)
                {
                    Log.Error("用户不存在");
                    throw new InvalidOperationException("用户不存在");
                }

                //3, 验证加密串
                //按顺序(商户Id&会员用户名&商户安全码)MD5加密串
                var signKey = MD5Cryptology.GetMD5(string.Format("{0}&{1}&{2}&{3}&{4}", model.OrderId, model.MerchantId, model.UserName, model.Amount.ToString("f4"), merchantEntity.Code), "gb2312");
                if (string.Compare(signKey, model.SignKey, true) != 0)
                {
                    Log.Error("无效的商户安全码");
                    throw new InvalidOperationException("无效的商户安全码");
                }

                //4, 支付
                string orderId = SsId.Charge;
                UserChargeResultModel result = new UserChargeResultModel()
                {
                    SsId        = orderId,
                    OrderId     = model.OrderId,
                    MerchantId  = model.MerchantId,
                    UserName    = model.UserName,
                    Money       = userEntity.Money ?? 0M + model.Amount,
                    BeforeMoney = userEntity.Money ?? 0M
                };

                int num = (new DAL.UserChargeDAL()).Save3(orderId, model.OrderId, userEntity.Id.ToString(), model.MerchantId, model.Amount);

                if (new DAL.Flex.UserChargeDAL().Update(orderId) == false)
                {
                    Log.ErrorFormat("充值失败,订单号: {0}", orderId);
                    throw new InvalidOperationException("充值失败");
                }
                else
                {
                    Log.InfoFormat("充值成功,订单号: {0}", orderId);
                }

                return(result);
            }
        }
Example #23
0
        /// <summary>
        /// 会员投注
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public UserBetResultModel Betting(UserBetModel model)
        {
            using (var dbContext = new TicketEntities())
            {
                if (string.IsNullOrEmpty(model.MerchantId) && string.IsNullOrEmpty(model.UserName) && string.IsNullOrEmpty(model.SignKey))
                {
                    throw new InvalidOperationException("无效的用户登录信息");
                }

                //1, 判断商户是否存在
                var merchantEntity = dbContext.N_Merchant.FirstOrDefault(it => (it.MerchantId.Equals(model.MerchantId, StringComparison.OrdinalIgnoreCase)));

                if (merchantEntity == null)
                {
                    Log.Error("商户不存在");
                    throw new InvalidOperationException("商户不存在");
                }

                if (string.IsNullOrEmpty(merchantEntity.Code))
                {
                    Log.Error("无效的商户信息");
                    throw new InvalidOperationException("无效的商户信息");
                }

                //2,验证用户,此处通过userId查询
                var userEntity = dbContext.N_User.FirstOrDefault(it => it.Id.ToString().Equals(model.UserName, StringComparison.OrdinalIgnoreCase));

                if (userEntity == null)
                {
                    Log.Error("此商户下不存在此用户");
                    throw new InvalidOperationException("此商户下不存在此用户");
                }

                //3, 验证加密串
                //按顺序(商户Id&会员用户名&商户安全码)MD5加密串
                var signKey = MD5Cryptology.GetMD5(string.Format("{0}&{1}&{2}", model.MerchantId, userEntity.UserName, merchantEntity.Code), "gb2312");
                if (string.Compare(signKey, model.SignKey, true) != 0)
                {
                    Log.Error("无效的商户安全码");
                    throw new InvalidOperationException("无效的商户安全码");
                }

                string orderId = SsId.Bet;
                model.SsId = orderId;
                UserBetResultModel result = new UserBetResultModel()
                {
                    SsId       = orderId,
                    OrderId    = model.OrderId,
                    MerchantId = model.MerchantId,
                    UserName   = userEntity.UserName,
                    Balls      = model.Balls
                };

                // 获取玩法
                var playSmallTypeEntity = dbContext.Sys_PlaySmallType.FirstOrDefault(it => it.Id.ToString().Equals(model.PlayId.ToString(), StringComparison.OrdinalIgnoreCase));
                if (playSmallTypeEntity == null)
                {
                    Log.Error("无效的彩种玩法");
                    throw new InvalidOperationException("无效的彩种玩法");
                }

                MerchantUserBetDAL betDal = new MerchantUserBetDAL();
                int      num2             = 0;
                DateTime STime            = DateTime.Now;

                num2 = !model.StrPos.Equals("") ?
                       betDal.InsertBetPos(model, "Web端", STime, userEntity.Id.ToString(), playSmallTypeEntity.Title2) :
                       (playSmallTypeEntity.Title2.Equals("P_5ZH") || playSmallTypeEntity.Title2.Equals("P_4ZH_L") || (playSmallTypeEntity.Title2.Equals("P_4ZH_R") || playSmallTypeEntity.Title2.Equals("P_3ZH_L")) || (playSmallTypeEntity.Title2.Equals("P_3ZH_C") || playSmallTypeEntity.Title2.Equals("P_3ZH_R")) ?
                        betDal.InsertBetZH(model, "Web端", STime, userEntity.Id.ToString(), playSmallTypeEntity.Title2) :
                        betDal.InsertBet(model, "Web端", STime, userEntity.Id.ToString(), playSmallTypeEntity.Title2));

                string[] issueTimeAndSn = betDal.GetIssueTimeAndSN(model.LotteryId);
                if (issueTimeAndSn.Length <= 0)
                {
                    Log.ErrorFormat("无效的彩种");
                    throw new InvalidOperationException("无效的彩种");
                }
                string str1 = issueTimeAndSn[0];

                if (num2 > 0)
                {
                    Log.InfoFormat("第{0}期投注成功,请期待开奖!订单号: {1}", str1, orderId);
                }
                else
                {
                    Log.ErrorFormat("对不起,投注失败!");
                    throw new InvalidOperationException("对不起,投注失败!");
                }

                return(result);
            }
        }
Example #24
0
        /// <summary>
        /// 会员取现
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public UserWithdrawResultModel Withdraw(UserWithdrawModel model)
        {
            using (var dbContext = new TicketEntities())
            {
                if (string.IsNullOrEmpty(model.MerchantId) && string.IsNullOrEmpty(model.UserName) && string.IsNullOrEmpty(model.SignKey))
                {
                    throw new InvalidOperationException("无效的用户登录信息");
                }

                if (model.Amount <= 0)
                {
                    throw new InvalidOperationException("无效的取现金额");
                }

                //1, 判断用户是否存在
                var merchantEntity = dbContext.N_Merchant.FirstOrDefault(it => (it.MerchantId.Equals(model.MerchantId, StringComparison.OrdinalIgnoreCase)));

                if (merchantEntity == null)
                {
                    Log.Error("商户不存在");
                    throw new InvalidOperationException("商户不存在");
                }

                if (string.IsNullOrEmpty(merchantEntity.Code))
                {
                    Log.Error("无效的商户信息");
                    throw new InvalidOperationException("无效的商户信息");
                }

                //2,验证用户
                var userEntity = dbContext.N_User.FirstOrDefault(it => it.UserName.Equals(model.UserName, StringComparison.OrdinalIgnoreCase));

                if (userEntity == null)
                {
                    Log.Error("用户不存在");
                    throw new InvalidOperationException("用户不存在");
                }

                //3, 验证加密串
                //按顺序(商户Id&会员用户名&商户安全码)MD5加密串
                var signKey = MD5Cryptology.GetMD5(string.Format("{0}&{1}&{2}&{3}&{4}", model.OrderId, model.MerchantId, model.UserName, model.Amount.ToString("f4"), merchantEntity.Code), "gb2312");
                if (string.Compare(signKey, model.SignKey, true) != 0)
                {
                    Log.Error("无效的商户安全码");
                    throw new InvalidOperationException("无效的商户安全码");
                }

                //4, 取现
                string orderId = SsId.GetCash;
                UserWithdrawResultModel result = new UserWithdrawResultModel()
                {
                    SsId        = orderId,
                    OrderId     = model.OrderId,
                    MerchantId  = model.MerchantId,
                    UserName    = model.UserName,
                    Money       = (userEntity.Money - model.Amount) ?? 0M,
                    BeforeMoney = userEntity.Money ?? 0M
                };

                // 获取user bank id
                var userBank = dbContext.N_UserBank.FirstOrDefault(it => it.PayAccount.Equals(userEntity.PayAccount, StringComparison.OrdinalIgnoreCase));
                if (userBank == null)
                {
                    Log.Error("无效的银行账号");
                    throw new InvalidOperationException("无效的银行账号");
                }

                int num = (new UserGetCashDAL()).Save3Withdraw(orderId, userEntity.Id.ToString(), model.OrderId, userBank.Id.ToString(), userEntity.PayBank, userEntity.PayAccount, userEntity.PayName, model.Amount);

                if (num == 0)
                {
                    Log.ErrorFormat("取现失败,订单号: {0}", orderId);
                    throw new InvalidOperationException("取现失败");
                }
                else
                {
                    new LogSysDAL().Save("会员管理", "Id为" + userEntity.Id.ToString() + "的会员申请提现!");
                    Log.InfoFormat("取现成功,订单号: {0}", orderId);
                }
                return(result);
            }
        }
Example #25
0
        public string GetEntityFieldValue(string fieldName)
        {
            var tr = TicketEntities.FirstOrDefault(x => x.HasCustomData(fieldName));

            return(tr != null?tr.GetCustomData(fieldName) : "");
        }
Example #26
0
        public string GetEntityFieldValue(int entityTypeId, string fieldName)
        {
            var tr = TicketEntities.FirstOrDefault(x => x.EntityTypeId == entityTypeId);

            return(tr != null?tr.GetCustomData(fieldName) : "");
        }
 public Audit(TicketEntities ticketEntities)
 {
     TicketId = ticketEntities.Contact.FileNum;
     Username = ticketEntities.Contact.updatedBy;
 }
Example #28
0
 public IEnumerable <AccountData> GetTicketAccounts(params Account[] includes)
 {
     return(TicketEntities.Select(x => new AccountData(x.AccountTypeId, x.AccountId)).Union(includes.Select(x => new AccountData(x.AccountTypeId, x.Id))));
 }
    /* Module Name: LinkButtonCreate_Click;
     * Student: Mayank Yadav
     * Modification Date: 23-April-2018
     * Description: Creates a ticket and store the value in database (Ticket_Master and Ticket_Activity)
     * Input/Outputs: Takes all the required values from form and if successful redirect you to Client Dashboard
     * Globals: No global changes.
     */
    protected void LinkButtonCreate_Click(object sender, EventArgs e)
    {
        string         username = Session["ClientUser"].ToString();
        TicketEntities te       = new TicketEntities();

        Console.WriteLine("Username: "******"Web";
            string Cate_gory     = category.Text;
            string Sub_ject      = subject.Text;
            int    Prior         = 2;;
            string Descript_ion  = Request.Form["description"].ToString();
            if (Full_name != null && Ticket_source != null && Cate_gory != null && Sub_ject != null &&
                Prior != 0 && Descript_ion != null && notBlocked == true)
            {
                byte[]        Byte_prior  = BitConverter.GetBytes(Prior);
                byte          Single_byte = Byte_prior[0];
                Ticket_Master tm          = new Ticket_Master()
                {
                    Email        = E_mail,
                    FullName     = Full_name,
                    CreatedBy    = clientid,
                    CreationDate = DateTime.Now,
                    TicketSource = Ticket_source,
                    Category     = Cate_gory,
                    Subject      = Sub_ject,
                    TicketStatus = "New",
                    Priority     = Single_byte,
                    IsDeleted    = false
                };

                te.Ticket_Master.Add(tm);

                Ticket_Activity ta = new Ticket_Activity()
                {
                    ActivityType = "Create",
                    Summary      = Sub_ject,
                    Description  = Descript_ion,
                    ActivityDate = DateTime.Now,
                    ActedBy      = clientid,
                    ActorName    = "End User",
                    Unread       = false
                };


                tm.Ticket_Activity.Add(ta);
                try
                {
                    te.SaveChanges();
                    Response.Redirect("ClientDashboard.aspx");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
        }
        else
        {
            Response.Redirect("ClientLogin.aspx");
        }
    }
        /// <summary>
        /// 注册会员
        /// </summary>
        /// <param name="model">注册信息</param>
        /// <returns>用户登录凭证Token</returns>
        public string RegiterUser(UserRegModel model)
        {
            using (var dbContext = new TicketEntities())
            {
                if (string.IsNullOrEmpty(model.MerchantId) && string.IsNullOrEmpty(model.UserName) && string.IsNullOrEmpty(model.SignKey))
                {
                    throw new InvalidOperationException("无效的用户登录信息");
                }

                //1, 判断用户是否存在
                var merchantEntity = dbContext.N_Merchant.FirstOrDefault(it => (it.MerchantId.Equals(model.MerchantId, StringComparison.OrdinalIgnoreCase)));

                if (merchantEntity == null)
                {
                    Log.Error("商户不存在");
                    throw new InvalidOperationException("商户不存在");
                }

                if (string.IsNullOrEmpty(merchantEntity.Code))
                {
                    Log.Error("无效的商户信息");
                    throw new InvalidOperationException("无效的商户信息");
                }

                //2, 验证加密串
                //按顺序(商户Id&会员用户名&商户安全码)MD5加密串
                var signKey = MD5Cryptology.GetMD5(string.Format("{0}&{1}&{2}", model.MerchantId, model.UserName, merchantEntity.Code), "gb2312");
                if (string.Compare(signKey, model.SignKey, true) != 0)
                {
                    Log.Error("无效的商户安全码" + signKey);
                    throw new InvalidOperationException("无效的商户安全码" + signKey);
                }

                var result = ajaxRegiter(model);
                if (!string.IsNullOrEmpty(result))
                {
                    Log.ErrorFormat("注册失败: {0}", result);
                    throw new InvalidOperationException(result);
                }

                //3,验证用户
                var userEntity = dbContext.N_User.FirstOrDefault(it => it.UserName.Equals(model.UserName, StringComparison.OrdinalIgnoreCase));

                if (userEntity == null)
                {
                    Log.Error("新用户注册失败");
                    throw new InvalidOperationException("新用户注册失败");
                }

                var token = this.GenerateToken();                    // 获取用户登录Token
                userEntity.Token          = token;
                userEntity.ExpirationTime = DateTime.Now.AddDays(2); // 设置Token有效期
                SaveDbChanges(dbContext);
                string message = null;

                if (string.IsNullOrEmpty(token))
                {
                    message = "新用户注册失败,请重新注册!";
                }

                message = "恭喜你,新用户注册成功!";

                return(token + "@" + message);
            }
        }