Example #1
0
        public Int32 Insert(BOL.customers obj)
        {
            if (obj != null)
            {
                try
                {
                    conn = new MySqlConnection(ConnectionString);
                    conn.Open();
                    trans = conn.BeginTransaction();

                    bll_objCustomer.Insert(obj, conn, trans);
                    Int32 customerid = bll_utility.GetMaxId("customers", "Customerid", conn, trans);

                    trans.Commit();
                    conn.Close();
                    return(customerid);
                }
                catch
                {
                    trans.Rollback();
                    conn.Close();
                }
            }
            return(0);
        }
Example #2
0
        public Int32 ProcessTickets(List <BOL.customers> customersList, Int32 userid)
        {
            try
            {
                Initialize();
                conn = new MySqlConnection(ConnectionString);
                conn.Open();
                trans = conn.BeginTransaction();

                //bll_objCustomer.Insert(obj, conn, trans);
                //Int32 customerid = bll_utility.GetMaxId("customers", "Customerid", conn, trans);

                if (customersList != null && customersList.Count > 0)
                {
                    this.bol_customerses = customersList;
                    if (this.bol_customerses != null && this.bol_customerses.Count > 0)
                    {
                        foreach (BOL.customers c in this.bol_customerses)
                        {
                            if (!string.IsNullOrEmpty(c.Mobile))
                            {
                                bol_customer = VerifyCustomerbyMobile(c);
                                if (bol_customer.Customerid == 0)
                                {
                                    bol_customer.Status    = StatusEnum.firstcall.GetHashCode();
                                    bol_customer.Isdeleted = "F";
                                    bol_customer.Createdby = userid;
                                    bol_customer.Createdon = DateTime.Now;
                                    bol_customer.Modifyby  = userid;
                                    bol_customer.Modifyon  = DateTime.Now;
                                    bll_customer.Insert(c, conn, trans);
                                    bol_customer.Customerid = bll_utility.GetMaxId("customers", "Customerid", conn, trans);
                                }
                                if (c.Ticketses != null && c.Ticketses[0].Ticketattachments != null)
                                {
                                    bol_ticket.Customerid = bol_customer.Customerid;
                                    bol_ticket.Ticketid   = VerifyOpenAnonymousTicketbyCustomerid(bol_ticket);
                                }
                                if (bol_ticket.Ticketid == 0)
                                {
                                    bol_ticket.Ticketstatusid = TicketStatusEnum.Open.GetHashCode();
                                    bol_ticket.Description    = "Open ticket";
                                    bol_ticket.Title          = "Open ticket";
                                    if (bol_customer.Status == StatusEnum.firstcall.GetHashCode())
                                    {
                                        bol_ticket.Ticketstatusid = TicketStatusEnum.Anonymous.GetHashCode();
                                        bol_ticket.Description    = "Anonymous ticket";
                                        bol_ticket.Title          = "Anonymous ticket";
                                    }
                                    bol_ticket.Customerid = bol_customer.Customerid;
                                    bol_ticket.Isdeleted  = "F";
                                    bol_ticket.Createdby  = userid;
                                    bol_ticket.Createdon  = DateTime.Now;
                                    bol_ticket.Modifiedby = userid;
                                    bol_ticket.Modifiedon = DateTime.Now;
                                    bol_ticket.Userid     = userid;

                                    bll_tickets.Insert(bol_ticket, conn, trans);
                                    bol_ticket.Ticketid = bll_utility.GetMaxId("tickets", "Ticketid", conn, trans);
                                }
                                if (c.Ticketses != null && c.Ticketses[0].Ticketattachments != null &&
                                    c.Ticketses.Count > 0)
                                {
                                    foreach (BOL.ticketattachment tattch in c.Ticketses[0].Ticketattachments)
                                    {
                                        if (!string.IsNullOrEmpty(tattch.Link))
                                        {
                                            tattch.Isdeleted = "F";
                                            tattch.Ticketid  = bol_ticket.Ticketid;

                                            tattch.Ticketattachmentid = bll_ticketattach.Insert(tattch, conn, trans);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                trans.Commit();
                conn.Close();
                return(1);
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (trans != null)
                {
                    trans.Rollback();
                }
                if (conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }
            return(0);
        }