using System;
using System.Linq;
using MySystem.PxcModels;
using Library;

namespace MySystem
{
    public class DeleteMySqlDataService
    {
        public readonly static DeleteMySqlDataService Instance = new DeleteMySqlDataService();
        private DeleteMySqlDataService()
        { }

        public void Start(string TableString)
        {
            WebCMSEntities db = new WebCMSEntities();
            try
            {
                string[] data = TableString.Split(':');
                int Id = int.Parse(function.CheckInt(data[1]));
                string Table = data[0];
                dbconn.op("delete from " + Table + " where Id=" + Id);
                OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["Pxc1SqlConnStr"].ToString();
                OtherMySqlConn.op("delete from " + Table + " where Id=" + Id);
                // OtherMySqlConn.connstr = ;
            }
            catch (Exception ex)
            {
                ErrorMsg msg = new ErrorMsg();
                msg.Time = DateTime.Now;
                msg.ErrorContent = ex.ToString();
                function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(msg), "Pop:MerchantInfo:Error");
            }
            db.Dispose();
        }
    }
}