Esempio n. 1
0
        public void XliteHistory()
        {
            using (var dbConn = Helpers.OrmliteConnection.openConn())
            {
                var    lastDate    = dbConn.GetScalar <DateTime>("SELECT TOP 1 CallDate FROM DC_Telesales_Xlite Order By Id DESC").ToString("yyyy-MM-dd HH:mm:ss");
                string currentDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                var data = RestfulClient.POST(ConfigurationManager.AppSettings["XliteAPIHistory"].ToString().Trim() + "?action=outbound&date_from=" + lastDate + "&date_to=" + currentDate + "&user=deca_report&password="******"1811HoaSao@@"), "");
                DC_Telesales_Xlite_API listHistory = new DC_Telesales_Xlite_API();
                if (!String.IsNullOrEmpty(data))
                {
                    JavaScriptSerializer objJavascript = new JavaScriptSerializer {
                        MaxJsonLength = Int32.MaxValue, RecursionLimit = 100
                    };
                    listHistory = objJavascript.Deserialize <DC_Telesales_Xlite_API>(data);
                    listHistory.data.ForEach(s => { s.CreatedAt = DateTime.Now; s.CreatedBy = "cronXLite"; });
                    foreach (var item in listHistory.data)
                    {
                        var exist = dbConn.Select <DC_Telesales_Xlite_API>("SELECT * FROM DC_Telesales_Xlite where RecordingFile = {0}", item.recordingfile);
                        if (exist.Count() == 0)
                        {
                            dbConn.Insert(item);
                        }
                    }
                }
            }
        }