コード例 #1
0
        public static bool checkUserInfo(UserVisitInfo v)
        {
            bool flag = true;
            try
            {

                if (v.Guid.Length > 50 || v.Url.Length > 2000 || v.Action.Length > 50 || v.PageTitle.Length > 500 || (v.Referurl != null && v.Referurl.Length > 2000) || (v.Event_action != null && v.Event_action.Length > 1000) || v.VisitIp.Length > 30 || v.Location.Length > 100)
                    flag = false;

                return flag;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
コード例 #2
0
        public static bool checkUserInfo(UserVisitInfo v)
        {
            bool flag = true;

            try
            {
                if (v.Guid.Length > 50 || v.Url.Length > 2000 || v.Action.Length > 50 || v.PageTitle.Length > 500 || (v.Referurl != null && v.Referurl.Length > 2000) || (v.Event_action != null && v.Event_action.Length > 1000) || v.VisitIp.Length > 30 || v.Location.Length > 100)
                {
                    flag = false;
                }

                return(flag);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            string errr = "";

            Console.WriteLine("开始分析数据:");

            List <string> uids = new List <string>();

            for (int d = int.Parse(dfrom); d < 0; d++)
            {
                string writeFile1 = string.Format("{0}\\result{1}.txt", System.Threading.Thread.GetDomain().BaseDirectory, DateTime.Now.ToFileTimeUtc().ToString());

                List <UserVisitInfo> userList = new List <UserVisitInfo>();

                string dt = DateTime.Now.AddDays(d).ToString("yyyy-MM-dd");

                int pageType1 = 31;
                if (!DataFarm.ExistGaData(pageType1, DateTime.Parse(dt), DateTime.Parse(dt)))
                {
                    //数据读取完毕退出
                    bool  exitFlag   = false;
                    Int64 maxVisitID = 0;

                    try
                    {
                        #region 循环拉取
                        for (int mi = 0; mi < int.MaxValue; mi++)
                        {
                            if (exitFlag)
                            {
                                break;
                            }

                            #region 循环读取数据

                            int filter_limit  = intent; // intent * (mi + 1);
                            int filter_offset = intent * mi;



                            string url = string.Format("http://10.0.0.131:922/index.php?module=API&filter_limit={0}&method=Live.getLastVisitsDetails&format=json&idSite=1&period=day&date={1}&expanded=1&token_auth={2}", filter_limit, dt, token);

                            if (maxVisitID > 0)
                            {
                                url = url + "&maxIdVisit=" + maxVisitID;
                            }

                            string xml = Boodoll.PageBL.ProductSearch.ProductSearchBLL.GetHtml(url, Encoding.GetEncoding("GB2312"));
                            xml = xml.Replace("\\u", "\\\\u");

                            if (xml == null || xml.Length < 10)
                            {
                                exitFlag = true;
                                continue;
                            }
                            Newtonsoft.Json.JavaScriptArray jsonObject = (Newtonsoft.Json.JavaScriptArray)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(xml);

                            int count = 0;
                            if (jsonObject != null && xml.Length > 5)
                            {
                                count = jsonObject.Count();
                            }
                            else
                            {
                                continue;
                            }


                            for (int i = 0; i < count; i++)
                            {
                                JavaScriptObject qcount = (JavaScriptObject)jsonObject[i];

                                JavaScriptArray actionDetails = (JavaScriptArray)qcount["actionDetails"];


                                string lastActionDateTime = qcount["serverDate"].ToString() + " " + qcount["serverTimePretty"].ToString();
                                string visitIp            = qcount["visitIp"].ToString();
                                string location           = ConvertUnicodeStringToChinese(qcount["location"].ToString());
                                string locationsina       = updateLocation(visitIp, location);

                                if (Convert.ToDateTime(lastActionDateTime) < Convert.ToDateTime(dt))
                                {
                                    exitFlag = true;
                                    continue;
                                }

                                //Console.WriteLine(visitIp+",time,"+lastActionDateTime);
                                if (i == 0)
                                {
                                    maxVisitID = Convert.ToInt64(qcount["idVisit"]);
                                }
                                else
                                {
                                    maxVisitID = Convert.ToInt64(qcount["idVisit"]) > maxVisitID ? maxVisitID : Convert.ToInt64(qcount["idVisit"]);
                                }

                                if (actionDetails.Count > 0)
                                {
                                    string userid   = "-1";
                                    string guid     = "";
                                    string referurl = "";

                                    JavaScriptObject customVariables = null;
                                    try
                                    {
                                        if (qcount.Keys.Contains("referrerUrl"))
                                        {
                                            referurl = Converter.ParseString(qcount["referrerUrl"], "");

                                            if (referurl.Length > 0)
                                            {
                                                if (referurl.Length > 2000)
                                                {
                                                    referurl = referurl.Substring(0, 2000);
                                                }
                                            }
                                        }

                                        customVariables = (JavaScriptObject)qcount["customVariables"];
                                        userid          = ((new Dictionary <string, object>(((Newtonsoft.Json.JavaScriptObject)((new Dictionary <string, object>(customVariables)).ElementAt(0).Value)))).ElementAt(1).Value.ToString());
                                        guid            = (new Dictionary <string, object>(((Newtonsoft.Json.JavaScriptObject)((new Dictionary <string, object>(customVariables)).ElementAt(1).Value)))).ElementAt(1).Value.ToString();
                                        if (!uids.Any(u => u.ToString() == guid))
                                        {
                                            uids.Add(guid);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        userid = "-1";
                                        guid   = "";
                                        continue;
                                    }

                                    actionDetails.ForEach(item =>
                                    {
                                        JavaScriptObject itemobject = (JavaScriptObject)item;


                                        string tmpUrl = "";
                                        if (itemobject.Keys.Contains("url") && itemobject["url"] != null)
                                        {
                                            tmpUrl = itemobject["url"].ToString();
                                        }
                                        UserVisitInfo vinfo = new UserVisitInfo();
                                        if (vinfo != null)
                                        {
                                            vinfo.Guid   = guid;
                                            vinfo.Userid = userid;
                                            if (itemobject.Keys.Contains("timeSpent"))
                                            {
                                                vinfo.Spent = Converter.ParseString(itemobject["timeSpent"], "");
                                            }

                                            vinfo.Url           = tmpUrl;
                                            vinfo.LastVisitTime = lastActionDateTime;

                                            if (itemobject.Keys.Contains("pageTitle"))
                                            {
                                                vinfo.PageTitle = UnicodeToString(Converter.ParseString(itemobject["pageTitle"], ""));
                                            }
                                            else
                                            {
                                                vinfo.PageTitle = "";
                                            }

                                            if (itemobject.Keys.Contains("type"))
                                            {
                                                vinfo.Action = Converter.ParseString(itemobject["type"], "");
                                            }
                                            else
                                            {
                                                vinfo.Action = "";
                                            }

                                            vinfo.VisitIp      = visitIp;
                                            vinfo.Location     = location;
                                            vinfo.Locationsina = locationsina;



                                            if (itemobject.Keys.Contains("customVariables"))
                                            {
                                                JavaScriptObject customerDetail = (JavaScriptObject)itemobject["customVariables"];

                                                //  var q = customerDetail.Values.First();
                                                string q1 = (new Dictionary <string, object>(((Newtonsoft.Json.JavaScriptObject)((new Dictionary <string, object>(customerDetail)).ElementAt(0).Value)))).ElementAt(1).Value.ToString();
                                                string q2 = (new Dictionary <string, object>(((Newtonsoft.Json.JavaScriptObject)((new Dictionary <string, object>(customerDetail)).ElementAt(0).Value)))).ElementAt(0).Value.ToString();

                                                vinfo.Event_action = UnicodeToString(q2);

                                                if (vinfo.Event_action.Length >= 1000)
                                                {
                                                    vinfo.Event_action = vinfo.Event_action.Substring(0, 1000);
                                                }
                                            }



                                            vinfo.Referurl = referurl;

                                            userList.Add(vinfo);
                                            string tmpmsg = "";
                                            try
                                            {
                                                tmpmsg = "1";
                                                if (DataFarm.insert_piwiklog(userList, out tmpmsg))
                                                {
                                                    tmpmsg = "2";
                                                }
                                                else
                                                {
                                                    tmpmsg = "3";
                                                }
                                                userList = new List <UserVisitInfo>();
                                            }
                                            catch (Exception ex)
                                            {
                                                string sss = ex.Message;
                                            }
                                        }
                                    });
                                }
                            }

                            Console.WriteLine(dt + "," + mi + "," + "finish." + uids.Distinct().Count() + "," + maxVisitID + "," + DateTime.Now);
                            #endregion
                        }


                        #endregion 结束循环
                    }
                    catch (Exception ex)
                    {
                        errr += ex.Message;
                        Console.WriteLine(ex.ToString());
                    }

                    userList = userList.Distinct().ToList();
                    if (userList.Count > 0 || true)
                    {
                        string msg = "";
                        Console.WriteLine(DateTime.Now + "," + pageType1 + "," + dt + "," + "update piwik_log DB.");
                        if (DataFarm.insert_piwiklog(userList, out msg))
                        {
                            Console.WriteLine(DateTime.Now + "," + pageType1 + "," + dt + "," + "update piwik_log_reffer DB.");
                            DataFarm.UpdateGaBaseData(pageType1, DateTime.Parse(dt), DateTime.Parse(dt));

                            Console.WriteLine(DateTime.Now + "," + pageType1 + "," + dt + "," + "finish.");
                        }

                        if (!string.IsNullOrEmpty(msg))
                        {
                            errr += msg;
                        }
                    }

                    writeLog(writeFile1, userList, errr);
                }

                int pageType2 = 32;


                if (!DataFarm.ExistGaData(pageType2, DateTime.Parse(dt), DateTime.Parse(dt)))
                {
                    List <Piwik_CustomerAction> customerActionList = new List <Piwik_CustomerAction>();
                    string url = "http://10.0.0.131:920/index.php?module=API&method=CustomVariables.getCustomVariables&format=JSON&idSite=1&period=day&date=" + dt + "&expanded=1&filter_limit=500&token_auth=453170c79e8f0ad5dcd1f0b2ce1ecf23";

                    string xml = Boodoll.PageBL.ProductSearch.ProductSearchBLL.GetHtml(url, System.Text.Encoding.UTF8);

                    try
                    {
                        xml = xml.Replace("\\u", "\\\\u");
                        Newtonsoft.Json.JavaScriptArray jsonObject = (Newtonsoft.Json.JavaScriptArray)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(xml);


                        int count = jsonObject.Count;
                        for (int i = 0; i < count; i++)
                        {
                            JavaScriptObject qcount = (JavaScriptObject)jsonObject[i];


                            // qcount["actionDetails"];

                            int nb_actions = 0;
                            if (qcount.Keys.Contains("nb_uniq_visitors"))
                            {
                                nb_actions = Converter.ParseInt(qcount["nb_uniq_visitors"], 0);
                            }
                            else
                            {
                                nb_actions = Converter.ParseInt(qcount["nb_actions"], 0);
                            }

                            customerActionList.Add(
                                new Piwik_CustomerAction()
                            {
                                dt             = DateTime.Parse(dt),
                                idsubdatatable = Converter.ParseInt(qcount["idsubdatatable"], 1),
                                label          = UnicodeToString(qcount["label"].ToString()),
                                nb_actions     = nb_actions
                            }
                                );
                        }

                        string msg = "";
                        if (DataFarm.insert_piwikCsAction(customerActionList, out msg))
                        {
                            DataFarm.UpdateGaBaseData(pageType2, DateTime.Parse(dt), DateTime.Parse(dt));
                            Console.WriteLine(DateTime.Now + "," + pageType2 + "," + dt + "," + "finish.");
                        }
                    }
                    catch (Exception ex)
                    {
                        string exx = ex.Message;
                    }
                }
            }

            Console.WriteLine("数据生成完毕");
        }
コード例 #4
0
        static void Main(string[] args)
        {
            string errr = "";
            Console.WriteLine("开始分析数据:");

            List<string> uids = new List<string>();
            for (int d = int.Parse(dfrom); d < 0; d++)
            {
                string writeFile1 = string.Format("{0}\\result{1}.txt", System.Threading.Thread.GetDomain().BaseDirectory, DateTime.Now.ToFileTimeUtc().ToString());

                List<UserVisitInfo> userList = new List<UserVisitInfo>();

                string dt = DateTime.Now.AddDays(d).ToString("yyyy-MM-dd");

                int pageType1 = 31;
                if (!DataFarm.ExistGaData(pageType1, DateTime.Parse(dt), DateTime.Parse(dt)))
                {
                    //数据读取完毕退出
                    bool exitFlag = false;
                    Int64 maxVisitID = 0;

                    try
                    {
                        #region 循环拉取
                        for (int mi = 0; mi < int.MaxValue; mi++)
                        {

                            if (exitFlag)
                                break;

                            #region 循环读取数据

                            int filter_limit = intent; // intent * (mi + 1);
                            int filter_offset = intent * mi;

                            string url = string.Format("http://10.0.0.131:922/index.php?module=API&filter_limit={0}&method=Live.getLastVisitsDetails&format=json&idSite=1&period=day&date={1}&expanded=1&token_auth={2}", filter_limit, dt, token);

                            if (maxVisitID > 0)
                                url = url + "&maxIdVisit=" + maxVisitID;

                            string xml = Boodoll.PageBL.ProductSearch.ProductSearchBLL.GetHtml(url, Encoding.GetEncoding("GB2312"));
                            xml = xml.Replace("\\u", "\\\\u");

                            if (xml == null || xml.Length < 10)
                            {
                                exitFlag = true;
                                continue;

                            }
                            Newtonsoft.Json.JavaScriptArray jsonObject = (Newtonsoft.Json.JavaScriptArray)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(xml);

                            int count = 0;
                            if (jsonObject != null && xml.Length > 5)
                            {
                                count = jsonObject.Count();
                            }
                            else
                            {
                                continue;
                            }

                            for (int i = 0; i < count; i++)
                            {

                                JavaScriptObject qcount = (JavaScriptObject)jsonObject[i];

                                JavaScriptArray actionDetails = (JavaScriptArray)qcount["actionDetails"];

                                string lastActionDateTime = qcount["serverDate"].ToString() + " " + qcount["serverTimePretty"].ToString();
                                string visitIp = qcount["visitIp"].ToString();
                                string location = ConvertUnicodeStringToChinese(qcount["location"].ToString());
                                string locationsina = updateLocation(visitIp, location);

                                if (Convert.ToDateTime(lastActionDateTime) < Convert.ToDateTime(dt))
                                {
                                    exitFlag = true;
                                    continue;
                                }

                                //Console.WriteLine(visitIp+",time,"+lastActionDateTime);
                                if (i == 0)
                                    maxVisitID = Convert.ToInt64(qcount["idVisit"]);
                                else
                                    maxVisitID = Convert.ToInt64(qcount["idVisit"]) > maxVisitID ? maxVisitID : Convert.ToInt64(qcount["idVisit"]);

                                if (actionDetails.Count > 0)
                                {
                                    string userid = "-1";
                                    string guid = "";
                                    string referurl = "";

                                    JavaScriptObject customVariables = null;
                                    try
                                    {

                                        if (qcount.Keys.Contains("referrerUrl"))
                                        {
                                            referurl = Converter.ParseString(qcount["referrerUrl"], "");

                                            if (referurl.Length > 0)
                                            {
                                                if (referurl.Length > 2000)
                                                    referurl = referurl.Substring(0, 2000);
                                            }
                                        }

                                        customVariables = (JavaScriptObject)qcount["customVariables"];
                                        userid = ((new Dictionary<string, object>(((Newtonsoft.Json.JavaScriptObject)((new Dictionary<string, object>(customVariables)).ElementAt(0).Value)))).ElementAt(1).Value.ToString());
                                        guid = (new Dictionary<string, object>(((Newtonsoft.Json.JavaScriptObject)((new Dictionary<string, object>(customVariables)).ElementAt(1).Value)))).ElementAt(1).Value.ToString();
                                        if (!uids.Any(u => u.ToString() == guid))
                                            uids.Add(guid);

                                    }
                                    catch (Exception ex)
                                    {
                                        userid = "-1";
                                        guid = "";
                                        continue;
                                    }

                                    actionDetails.ForEach(item =>
                                    {
                                        JavaScriptObject itemobject = (JavaScriptObject)item;

                                        string tmpUrl = "";
                                        if (itemobject.Keys.Contains("url") && itemobject["url"] != null)
                                        {
                                            tmpUrl = itemobject["url"].ToString();

                                        }
                                        UserVisitInfo vinfo = new UserVisitInfo();
                                        if (vinfo != null)
                                        {
                                            vinfo.Guid = guid;
                                            vinfo.Userid = userid;
                                            if (itemobject.Keys.Contains("timeSpent"))
                                                vinfo.Spent = Converter.ParseString(itemobject["timeSpent"], "");

                                            vinfo.Url = tmpUrl;
                                            vinfo.LastVisitTime = lastActionDateTime;

                                            if (itemobject.Keys.Contains("pageTitle"))
                                                vinfo.PageTitle = UnicodeToString(Converter.ParseString(itemobject["pageTitle"], ""));
                                            else
                                                vinfo.PageTitle = "";

                                            if (itemobject.Keys.Contains("type"))
                                                vinfo.Action = Converter.ParseString(itemobject["type"], "");
                                            else
                                                vinfo.Action = "";

                                            vinfo.VisitIp = visitIp;
                                            vinfo.Location = location;
                                            vinfo.Locationsina = locationsina;

                                            if (itemobject.Keys.Contains("customVariables"))
                                            {
                                                JavaScriptObject customerDetail = (JavaScriptObject)itemobject["customVariables"];

                                                //  var q = customerDetail.Values.First();
                                                string q1 = (new Dictionary<string, object>(((Newtonsoft.Json.JavaScriptObject)((new Dictionary<string, object>(customerDetail)).ElementAt(0).Value)))).ElementAt(1).Value.ToString();
                                                string q2 = (new Dictionary<string, object>(((Newtonsoft.Json.JavaScriptObject)((new Dictionary<string, object>(customerDetail)).ElementAt(0).Value)))).ElementAt(0).Value.ToString();

                                                vinfo.Event_action = UnicodeToString(q2);

                                                if (vinfo.Event_action.Length >= 1000)
                                                {
                                                    vinfo.Event_action = vinfo.Event_action.Substring(0, 1000);
                                                }
                                            }

                                            vinfo.Referurl = referurl;

                                            userList.Add(vinfo);
                                            string tmpmsg = "";
                                            try
                                            {
                                                tmpmsg = "1";
                                                if (DataFarm.insert_piwiklog(userList, out tmpmsg))
                                                {
                                                    tmpmsg = "2";
                                                }
                                                else
                                                {
                                                    tmpmsg = "3";
                                                }
                                                userList = new List<UserVisitInfo>();
                                            }
                                            catch (Exception ex)
                                            {
                                                string sss = ex.Message;
                                            }
                                        }
                                    });
                                }
                            }

                            Console.WriteLine(dt + "," + mi + "," + "finish." + uids.Distinct().Count() + "," + maxVisitID + "," + DateTime.Now);
                            #endregion
                        }

                        #endregion 结束循环
                    }
                    catch (Exception ex)
                    {
                        errr += ex.Message;
                        Console.WriteLine(ex.ToString());
                    }

                    userList = userList.Distinct().ToList();
                    if (userList.Count > 0||true)
                    {
                        string msg = "";
                        Console.WriteLine(DateTime.Now + "," + pageType1 + "," + dt + "," + "update piwik_log DB.");
                        if (DataFarm.insert_piwiklog(userList, out msg))
                        {
                            Console.WriteLine(DateTime.Now + "," + pageType1 + "," + dt + "," + "update piwik_log_reffer DB.");
                            DataFarm.UpdateGaBaseData(pageType1, DateTime.Parse(dt), DateTime.Parse(dt));

                            Console.WriteLine(DateTime.Now + "," + pageType1 + "," + dt + "," + "finish.");
                        }

                        if (!string.IsNullOrEmpty(msg))
                            errr += msg;
                    }

                    writeLog(writeFile1, userList, errr);

                }

                int pageType2 = 32;

                if (!DataFarm.ExistGaData(pageType2, DateTime.Parse(dt), DateTime.Parse(dt)))
                {
                    List<Piwik_CustomerAction> customerActionList = new List<Piwik_CustomerAction>();
                    string url = "http://10.0.0.131:920/index.php?module=API&method=CustomVariables.getCustomVariables&format=JSON&idSite=1&period=day&date=" + dt + "&expanded=1&filter_limit=500&token_auth=453170c79e8f0ad5dcd1f0b2ce1ecf23";

                    string xml = Boodoll.PageBL.ProductSearch.ProductSearchBLL.GetHtml(url, System.Text.Encoding.UTF8);

                    try
                    {
                        xml = xml.Replace("\\u", "\\\\u");
                        Newtonsoft.Json.JavaScriptArray jsonObject = (Newtonsoft.Json.JavaScriptArray)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(xml);

                        int count = jsonObject.Count;
                        for (int i = 0; i < count; i++)
                        {
                            JavaScriptObject qcount = (JavaScriptObject)jsonObject[i];

                            // qcount["actionDetails"];

                            int nb_actions = 0;
                            if (qcount.Keys.Contains("nb_uniq_visitors"))
                            {
                                nb_actions = Converter.ParseInt(qcount["nb_uniq_visitors"], 0);
                            }
                            else
                            {
                                nb_actions = Converter.ParseInt(qcount["nb_actions"], 0);

                            }

                            customerActionList.Add(
                                 new Piwik_CustomerAction()
                                 {

                                     dt = DateTime.Parse(dt),
                                     idsubdatatable = Converter.ParseInt(qcount["idsubdatatable"], 1),
                                     label = UnicodeToString(qcount["label"].ToString()),
                                     nb_actions = nb_actions
                                 }
                              );

                        }

                        string msg = "";
                        if (DataFarm.insert_piwikCsAction(customerActionList, out msg))
                        {
                            DataFarm.UpdateGaBaseData(pageType2, DateTime.Parse(dt), DateTime.Parse(dt));
                            Console.WriteLine(DateTime.Now + "," + pageType2 + "," + dt + "," + "finish.");
                        }

                    }
                    catch (Exception ex)
                    {
                        string exx = ex.Message;
                    }
                }
            }

            Console.WriteLine("数据生成完毕");
        }
コード例 #5
0
        static void Main(string[] args)
        {
            string errr = "";
            Console.WriteLine("开始分析数据:");

             int pageType = 31;
             for (int d = int.Parse(dfrom); d < 0; d++)
             {
                 string writeFile = string.Format("{0}\\result{1}.txt", System.Threading.Thread.GetDomain().BaseDirectory, DateTime.Now.ToFileTimeUtc().ToString());

                 List<UserVisitInfo> userList = new List<UserVisitInfo>();

                 string dt = DateTime.Now.AddDays(d).ToString("yyyy-MM-dd");

                 if (!DataFarm.ExistGaData(pageType, DateTime.Parse(dt), DateTime.Parse(dt)))
                 {
                     //数据读取完毕退出
                     bool exitFlag = false;
                     Int64 maxVisitID = 0;

                     try
                     {

                         for (int mi = 0; mi < int.MaxValue; mi++)
                         {
                             if (exitFlag)
                                 break;

                             #region 循环读取数据

                             // string url = "http://click.muyingzhijia.com/index.php?module=API&filter_limit=100&method=Live.getLastVisitsDetails&format=json&idSite=1&period=day&date=" + dtStr + "&expanded=1&token_auth=453170c79e8f0ad5dcd1f0b2ce1ecf23";
                             string url = "http://click.muyingzhijia.com/index.php?module=API&filter_limit=100&method=Live.getLastVisitsDetails&format=json&idSite=1&period=day&date=" + dt + "&expanded=1&token_auth=" + token;
                             ;

                             if (maxVisitID > 0)
                                 url = url + "&maxIdVisit=" + maxVisitID;

                             string xml = Boodoll.PageBL.ProductSearch.ProductSearchBLL.GetHtml(url, Encoding.GetEncoding("GB2312"));

                             Newtonsoft.Json.JavaScriptArray jsonObject = (Newtonsoft.Json.JavaScriptArray)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(xml);

                             int count = jsonObject.Count();

                             for (int i = 0; i < count; i++)
                             {

                                 JavaScriptObject qcount = (JavaScriptObject)jsonObject[i];

                                 // qcount["actionDetails"];
                                 JavaScriptArray actionDetails = (JavaScriptArray)qcount["actionDetails"];

                                 string lastActionDateTime = qcount["serverDate"].ToString() + " " + qcount["serverTimePretty"].ToString();
                                 if (Convert.ToDateTime(lastActionDateTime) < Convert.ToDateTime(dt))
                                 {
                                     exitFlag = true;
                                     continue;

                                 }
                                 //if(userList.Count>5)
                                 //{
                                 //    exitFlag = true;
                                 //    break;

                                 //}

                                 //if (Convert.ToDateTime(lastActionDateTime) < DateTime.Now.AddHours(-1))
                                 //{
                                 //    exitFlag = true;
                                 //    break;

                                 //}

                                 if (i == 0)
                                     maxVisitID = Convert.ToInt64(qcount["idVisit"]);
                                 else
                                     maxVisitID = Convert.ToInt64(qcount["idVisit"]) > maxVisitID ? maxVisitID : Convert.ToInt64(qcount["idVisit"]);

                                 if (actionDetails.Count > 0)
                                 {
                                     string userid = "";
                                     string guid = "";
                                     string referurl = "";

                                     JavaScriptObject customVariables = null;
                                     try
                                     {
                                         customVariables = (JavaScriptObject)qcount["customVariables"];
                                         userid = ((new Dictionary<string, object>(((Newtonsoft.Json.JavaScriptObject)((new Dictionary<string, object>(customVariables)).ElementAt(0).Value)))).ElementAt(1).Value.ToString());
                                         guid = (new Dictionary<string, object>(((Newtonsoft.Json.JavaScriptObject)((new Dictionary<string, object>(customVariables)).ElementAt(1).Value)))).ElementAt(1).Value.ToString();

                                         if (qcount.Keys.Contains("referrerUrl"))
                                        referurl=Converter.ParseString(qcount["referrerUrl"],"");
                                         // [43] = {[referrerUrl, http://open.union.360.cn/go?bid=2000311&cid=3&qihoo_id=36110&url=http%3A%2F%2Fwww.muyingzhijia.com%2FPromotion%2Factivities.aspx%3Faction%3DDiapers1015&sign=9e3beae85e&aname=mall_list&asign=ef49dae593&fname=mall_list&fsign=40e9a54cce]}

                                     }
                                     catch (Exception ex)
                                     {
                                         continue;
                                     }

                                     //message = getUserInfo(guid, userid);

                                     actionDetails.ForEach(item =>
                                     {
                                         JavaScriptObject itemobject = (JavaScriptObject)item;

                                         string tmpUrl = "";
                                         if (itemobject.Keys.Contains("url") && itemobject["url"] != null)
                                         {
                                             tmpUrl = itemobject["url"].ToString();

                                         }
                                             UserVisitInfo vinfo = new UserVisitInfo();
                                             if (vinfo != null)
                                             {
                                                 vinfo.Guid = guid;
                                                 vinfo.Userid = userid;
                                                 if (itemobject.Keys.Contains("timeSpent"))
                                                     vinfo.Spent = Converter.ParseString(itemobject["timeSpent"], "");

                                                 vinfo.Url = tmpUrl;
                                                 vinfo.LastVisitTime = lastActionDateTime;

                                                 if (itemobject.Keys.Contains("pageTitle"))
                                                     vinfo.PageTitle = Converter.ParseString(itemobject["pageTitle"], "");
                                                 else
                                                     vinfo.PageTitle = "";
                                                     // ConvertUnicodeStringToChinese(Converter.ParseString(itemobject["pageTitle"], ""));
                                                 if (itemobject.Keys.Contains("type"))
                                                     vinfo.Action = Converter.ParseString(itemobject["type"], "");
                                                 else
                                                     vinfo.Action = "";

                                                 vinfo.Referurl = referurl;
                                                 userList.Add(vinfo);

                                                 //List<UserVisitInfo> vt = new List<UserVisitInfo>();
                                                 //vt.Add(vinfo);
                                                 //DataFarm.insert_piwiklog(vt);

                                             }

                                     });
                                 }

                                 Console.WriteLine(lastActionDateTime + "," + dt + "," + i + "," + mi+ "," + "finish.");

                             }

                             #endregion
                         }
                         }
                          catch (Exception ex)
                         {
                             errr += ex.Message;
                             Console.WriteLine(ex.Message);
                         }

                     userList = userList.Distinct().ToList();
                     if (userList.Count > 0)
                     {
                         string msg = "";
                         if (DataFarm.insert_piwiklog(userList,out msg))
                         {
                             DataFarm.UpdateGaBaseData(pageType, DateTime.Parse(dt), DateTime.Parse(dt));
                             Console.WriteLine(DateTime.Now + "," + pageType + "," + dt + "," + "finish.");
                         }

                         if (!string.IsNullOrEmpty(msg))
                             errr += msg;
                     }

                    // CreateReport(userList);
                     writeLog(writeFile, userList,errr);

                 }
             }

            Console.WriteLine("数据生成完毕");
        }