private string GetCommentValue(CommitCRM.Ticket ticket)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append(string.Format("Ticket Number: {0}", ticket.TicketNumber.Replace("-", string.Empty)));
            try
            {
                sb.AppendFormat(" , Cause: {0}", ticket.GetFieldValue("FLDTKTCAUSE"));
                sb.AppendFormat(" , Source: {0}", ticket.Source);
                sb.AppendFormat(" , Category: {0}", ticket.GetFieldValue("FLDTKTCATEGORY"));
                sb.AppendFormat(" , Note: {0}", ticket.Notes);
                sb.AppendFormat(" , Resolution : {0}", ticket.Resolution);

                CommitCRM.ObjectQuery<CommitCRM.Charge> ChargeSearch = new CommitCRM.ObjectQuery<CommitCRM.Charge>();
                ChargeSearch.AddCriteria(CommitCRM.Charge.Fields.TicketREC_ID, CommitCRM.OperatorEnum.opEqual, ticket.TicketREC_ID);
                List<CommitCRM.Charge> Charges = ChargeSearch.FetchObjects();
                foreach (CommitCRM.Charge Charge in Charges)
                {
                    sb.AppendFormat(", Charge :{0}", Charge.Description);
                    sb.AppendFormat(", Amount : {0}", Charge.GetFieldValue("FLDSLPBILLTOTAL"));
                    sb.AppendFormat(", Quantity: {0}", Charge.GetFieldValue("FLDSLPQUANTITY"));
                    sb.AppendFormat(", Date : {0}", Charge.Date);
                }

                CommitCRM.ObjectQuery<CommitCRM.HistoryNote> HistoryNoteSearch = new CommitCRM.ObjectQuery<CommitCRM.HistoryNote>();
                HistoryNoteSearch.AddCriteria(CommitCRM.HistoryNote.Fields.RelLinkREC_ID, CommitCRM.OperatorEnum.opEqual, ticket.TicketREC_ID);
                List<CommitCRM.HistoryNote> HistoryNotes = HistoryNoteSearch.FetchObjects();
                foreach (CommitCRM.HistoryNote HistoryNote in HistoryNotes)
                {
                    sb.AppendFormat(" History Note :{0}", HistoryNote.Description);
                    sb.AppendFormat(", Date : {0}", HistoryNote.Date);
                }
            }
            catch (Exception ex)
            {
                RepairShoprUtils.LogWriteLineinHTML(string.Format("Failed to get Charge, HistoryNote of Ticket : {0} . Due to {1}", ticket.Description, ex.Message), MessageSource.Ticket, ex.StackTrace, messageType.Warning);

            }
            return sb.ToString();
        }
        public string  CreateContactForMissingTicket(CommitCRM.Ticket ticket,SQLiteConnection conn)
        {
            string customerID = string.Empty;
            CommitCRM.ObjectQuery<CommitCRM.Account> AccountSearch = new CommitCRM.ObjectQuery<CommitCRM.Account>();
            AccountSearch.AddCriteria(CommitCRM.Account.Fields.AccountREC_ID, CommitCRM.OperatorEnum.opEqual, ticket.AccountREC_ID);
            List<CommitCRM.Account> Accounts = AccountSearch.FetchObjects();
            foreach (CommitCRM.Account account in Accounts)
            {
                try
                {
                    RepairShoprUtils.LogWriteLineinHTML(string.Format("Creating Account with last Name : {0}", account.LastName), MessageSource.Customer, "", messageType.Information);
                    NameValueCollection myNameValueCollection = new NameValueCollection();
                    string fullname = account.GetFieldValue("FLDCRDCONTACT");
                    myNameValueCollection.Add("business_name", account.CompanyName);
                    if (!string.IsNullOrEmpty(fullname) && !string.IsNullOrEmpty(account.LastName))
                        myNameValueCollection.Add("firstname", fullname.Replace(account.LastName, string.Empty));
                    else
                        myNameValueCollection.Add("firstname", fullname);
                    myNameValueCollection.Add("lastname", account.LastName);
                    if (account.EmailAddress1.Contains("@"))
                        myNameValueCollection.Add("email", account.EmailAddress1);
                    myNameValueCollection.Add("phone", account.Phone1);
                    myNameValueCollection.Add("mobile", account.Phone2);
                    myNameValueCollection.Add("address", account.AddressLine1);
                    myNameValueCollection.Add("address_2", account.AddressLine2);
                    myNameValueCollection.Add("city", account.City);
                    myNameValueCollection.Add("state", account.State);
                    myNameValueCollection.Add("zip", account.Zip);
                    myNameValueCollection.Add("notes", account.Notes);
                    var newCustomer = RepairShoprUtils.ExportCustomer(myNameValueCollection);
                    if (newCustomer != null)
                    {
                        using (SQLiteCommand cmdINewItem = new SQLiteCommand(string.Format("INSERT INTO  Account (AccountId,CustomerId) VALUES('{0}','{1}')", account.AccountREC_ID, newCustomer.Id), conn))
                            cmdINewItem.ExecuteNonQuery();
                        customerID = newCustomer.Id;
                        break;
                    }
                    else
                    {
                        RepairShoprUtils.LogWriteLineinHTML(string.Format("Faile to create account : {0} for Ticket : {1}", account.LastName,ticket.Description), MessageSource.Customer, "", messageType.Warning);
                    }
                }
                catch (Exception ex)
                {
                    RepairShoprUtils.LogWriteLineinHTML(string.Format("Faile to create account : {0} for Ticket : {1} dues to {3}", account.LastName, ticket.Description,ex.Message), MessageSource.Customer, ex.StackTrace, messageType.Error);
                }              

            }
            return customerID;
        }