UINT CMemberSearch::GetTaobaoSellerMember() { CString szShopListURL = szTaobaoAddress; // 关键字 if (!condition.szKeyword.IsEmpty()) { szShopListURL.AppendFormat("k-%s_", URLEncodeGBK(condition.szKeyword)); } // 类别 if (condition.nCategoryId > 0) { szShopListURL.AppendFormat("biztype-%d_", condition.nCategoryId); } // 地区 if (!condition.szLocation.IsEmpty() && condition.szLocation != "所有省份") { szShopListURL.AppendFormat("province-%s_", URLEncodeGBK(condition.szLocation)); } // 是否在线 if (condition.bIsOnline) { szShopListURL.Append("onlineStatus-yes_"); } szShopListURL.Append("n-y.html"); // 将找到个数初始化为0 nFoundCount=0; BOOL bFound = TRUE; for (int pageIndex = 1;bFound && nFoundCount < condition.nLimit; pageIndex++) { CString szShopListHTML = GetPageDirect(szShopListURL); CString szCurPageFlag = "<span class=\"page-cur\">"; //if (szShopListHTML.Find(szCurPageFlag) < 0) //{ // bFound = FALSE; //} //else //{ bFound = ParseShopListForSeller(szShopListHTML); szShopListURL = GetNextPageUrl(szShopListHTML); if (szShopListURL.IsEmpty()) { break; } //} } ::SendMessage(this->m_hMainWnd, WM_FOUND_MEMBER, (WPARAM)FALSE, NULL); return 1; }
static void do_alarm(mongoc_collection_t *sensorcoll,char * se_id,char * alarmType,char * upperBoundC,char *lowerBoundC, char *duration,char *target,char * contactId,char* addr,mongoc_collection_t *alarmlogcoll,char* userId,char *device_name,char * de_id){ mongoc_cursor_t *cursor; bson_t *doc; bson_t *query; char *str; query = bson_new (); bson_oid_t se_oid; bson_oid_init_from_string(&se_oid, se_id); BSON_APPEND_OID (query, "_id",&se_oid); cursor = mongoc_collection_find (sensorcoll, MONGOC_QUERY_NONE, 0, 0, 0, query, NULL, NULL); double ivalue=0; double dalarmtime=0; int interval=0; int balarm=0; int buse=0; char name[1024]; memset(name,0,1024); while (mongoc_cursor_next (cursor, &doc)) { str = bson_as_json (doc, NULL); printf ("%s\n", str); bson_free (str); bson_iter_t iter; bson_iter_t sub_iter; if (bson_iter_init (&iter, doc)) { while (bson_iter_next (&iter)) { //printf ("Found a field named: %s\n", bson_iter_key (&iter)); bson_value_t *value; value = bson_iter_value (&iter); //printf("type %d\n",value->value_type); if (value->value_type == BSON_TYPE_INT32) { if(strcmp(bson_iter_key (&iter),"value")==0){ printf("value %d\n", value->value.v_int32); ivalue=value->value.v_double; buse =1; }else if(strcmp(bson_iter_key (&iter),"interval")==0){ interval=value->value.v_int32; }else if(strcmp(bson_iter_key (&iter),"balarm")==0){ balarm=value->value.v_int32; } } if(strcmp(bson_iter_key (&iter),"value")==0){ printf("value type %d,%d\n",value->value_type,BSON_TYPE_INT32); } if (value->value_type == BSON_TYPE_DOUBLE) { if(strcmp(bson_iter_key (&iter),"value")==0){ //printf("value %d\n", (int)value->value.v_double); buse =1; ivalue=value->value.v_double; } if(strcmp(bson_iter_key (&iter),"alarmtime")==0){ dalarmtime=value->value.v_double; } } if (value->value_type == BSON_TYPE_UTF8) { if(strcmp(bson_iter_key (&iter),"name")==0){ //printf("value %d\n", (int)value->value.v_double); strcpy(name,value->value.v_utf8.str); } if(strcmp(bson_iter_key (&iter),"value")==0){ //printf("value %d\n", (int)value->value.v_double); ivalue=atof(value->value.v_utf8.str); buse =1; } } } } } bson_destroy (query); printf("se_id:%s,buse:%d\n",se_id,buse); printf("alarmType:%s,%f : %s,%s",alarmType,ivalue,upperBoundC,lowerBoundC); time_t t; t = time(NULL); struct tm *lt; int ii = time(&t); int bdoalarm=1; if(balarm==1){ bdoalarm=1; if(dalarmtime>0 &&interval>0){ if((ii-dalarmtime)<3600){ bdoalarm=0; } } } if(buse ==1){ if(strcmp(alarmType,"val_above")==0){ int iupper=atoi(upperBoundC); if(iupper<ivalue){ printf("val_above %d value\n",iupper,ivalue); char msg[2048]; memset(msg,0,2048); snprintf(msg, sizeof(msg) - 1, "故障报警:%s的%s数值高于%d,位置是%s,请及时处理!", device_name, name, iupper, addr); char buf[1024]; URLEncodeGBK(msg, strlen(msg), buf,sizeof(buf)); printf("%s\n",buf); printf("alarm info: %s\n",msg); if(bdoalarm>0){ int code=sendsms_c(buf,contactId); saveAlarmLog(alarmlogcoll,se_id,code,contactId,msg,userId,device_name,name,de_id); updateAlarm(sensorcoll,se_id,interval+1,1); printf("send sms \n"); } }else { updateAlarm(sensorcoll,se_id,0,0); } }else if(strcmp(alarmType,"val_below")==0){ int iupper=atoi(lowerBoundC); if(iupper>ivalue){ printf("val_below %d value %d\n",iupper,ivalue); char msg[2048]; memset(msg,0,2048); snprintf(msg, sizeof(msg) - 1, "故障报警:%s的%s数值低于%d,位置是%s,请及时处理!", device_name, name, iupper, addr); char buf[1024]; URLEncodeGBK(msg, strlen(msg), buf,sizeof(buf)); printf("%s\n",buf); printf("alarm info: %s\n",msg); if(bdoalarm>0){ int code=sendsms_c(buf,contactId); saveAlarmLog(alarmlogcoll,se_id,code,contactId,msg,userId,device_name,name,de_id); updateAlarm(sensorcoll,se_id,interval+1,1); printf("send sms \n"); } }else { updateAlarm(sensorcoll,se_id,0,0); } }else if(strcmp(alarmType,"switch_on")==0){ if(ivalue==1){ char msg[2048]; memset(msg,0,2048); snprintf(msg, sizeof(msg) - 1, "故障报警:%s,%s,位置是%s,请及时处理!", device_name, name, addr); char buf[1024]; URLEncodeGBK(msg, strlen(msg), buf,sizeof(buf)); printf("%s\n",buf); printf("alarm info: %s\n",msg); if(bdoalarm>0){ int code=sendsms_c(buf,contactId); saveAlarmLog(alarmlogcoll,se_id,code,contactId,msg,userId,device_name,name,de_id); updateAlarm(sensorcoll,se_id,interval+1,1); printf("send sms \n"); } }else { updateAlarm(sensorcoll,se_id,0,0); } }else if(strcmp(alarmType,"offline")==0){ if(ivalue==1){ char msg[2048]; memset(msg,0,2048); snprintf(msg, sizeof(msg) - 1, "故障报警:%s,%s,位置是%s,请及时处理!", device_name, name, addr); char buf[1024]; URLEncodeGBK(msg, strlen(msg), buf,sizeof(buf)); printf("%s\n",buf); printf("alarm info: %s\n",msg); if(bdoalarm>0){ int code=sendsms_c(buf,contactId); saveAlarmLog(alarmlogcoll,se_id,code,contactId,msg,userId,device_name,name,de_id); updateAlarm(sensorcoll,se_id,interval+1,1); printf("send sms \n"); } }else { updateAlarm(sensorcoll,se_id,0,0); } } } }