Ejemplo n.º 1
0
        internal int preyAllClientBaseInfo()
        {
            PhotographerAdapter adapter = new PhotographerAdapter();
            DataTable dt = adapter.getAllPhotographers(true);
            int totalClient = 0;
            int total = 0;

            foreach(DataRow row in dt.Rows)
            {
                int pid = (int)row["PhtgphrId"];
                int pageNum = (int)row["PageNum"];

                totalClient = preyClientBaseInfo(pid, pageNum+1, 100);
                total += totalClient;

                LogHelper.info(string.Format("Parse photographer(id={0}) pageNum={1} with totally {2} clients.", pid, pageNum, totalClient));
                adapter.setClientCount(pid, totalClient, true); // Set photographer row to 'completed'
            }

            return totalClient;
        }
Ejemplo n.º 2
0
 private int savePhotographerInfo(string ptgphrName, string ptgphrId, string gender)
 {
     PhotographerAdapter adapter = new PhotographerAdapter();
     int count = adapter.insert(ptgphrName, ptgphrId, gender);
     if (count==1)
     {
         Debug.WriteLine(string.Format("[{0}, {1}, {2}]", ptgphrName, ptgphrId, gender));
     }
     return count;
 }
Ejemplo n.º 3
0
        public int preyClientBaseInfo(int pid, int startIdx, int maxPageNum)
        {
            int cliCount = 0;
            int total = 0;
            WebClient wc = getWebClient();
            string trgUrlTmpl = _appSetting.clientBaseUrl;
            string trgUrl = string.Empty;
            string rspData = string.Empty;
            PhotographerAdapter adapter = new PhotographerAdapter();

            for(int i = startIdx; i < maxPageNum; i++)
            {
                waitRandomTime();
                trgUrl = string.Format(trgUrlTmpl, pid, i);

                try
                {
                    rspData = wc.DownloadString(trgUrl);
                    cliCount = parseClientBaseInfo(rspData);
                    total += cliCount;

                    adapter.setPageNum(pid, i);

                    Debug.WriteLine("Parse potographer (id={0}) , page = {1},  records = {2} ", pid, i, cliCount);
                    LogHelper.info(string.Format("Parse potographer (id={0}) , pageIndex = {1} with {2} clients.", pid, i, cliCount));

                    if (isLastPage(rspData)) {
                        Debug.WriteLine("Parse photographer (id={0}) {1} pages completed.", pid, i);
                        break; // it has reached last page
                    }
                }
                catch (WebException wex)
                {
                    Debug.WriteLine(string.Format("ERROR >> Parse potographer (id={0}) , pageIndex = {1} with Error {2}", pid, i, cliCount) + wex.Message);
                    LogHelper.error(string.Format("Parse potographer (id={0}) , pageIndex = {1} with ERROR {2}", pid, i, wex.Message));
                }

            }

            return total;
        }