统计不在线设备

/************************************************************************/
/* 解析配置文件                                                         */
/************************************************************************/
void config_the_end(char *buf)
{
	int i;
	for(i=0;i<99;++i)
	{
		if(buf[i]=='\n')
		{
			buf[i]='\0';
			break;
		}
	}
}
void read_config()
{


	char DeviceName1[512];
	FILE *fp;
	fp = fopen("DeviceList.txt","r");
	if(fp==NULL)
	{
		printf("打开文件错误\n");
		
	}
	//解析IP地址
	fgets(DeviceName1,256,fp);
	config_the_end(DeviceName1);
	sscanf(DeviceName1,"%*[^:]:%s",DeviceName);
	printf("DeviceName=%s\n",DeviceName);


	fclose(fp);
}
//分割字符串
void SplitString(CString strArr , LPCTSTR strSplit , CStringArray& arr , BOOL bDeleteFirst)
{
	if(bDeleteFirst)
		arr.RemoveAll();
	int iStart = 0 , iFind = 0;
	do
	{
		iFind = strArr.Find(strSplit , iStart);
		if(iFind == -1)
			arr.Add(strArr.Mid(iStart));
		else
			arr.Add(strArr.Mid(iStart , iFind - iStart));
		iStart = iFind + 1;
	}while(iFind != -1);
}
// 深度优先递归遍历目录中所有的文件   返回遍历的ID号
BOOL  DirectoryList( CStringArray & saResult)  
{  	
	WIN32_FIND_DATA FindData;  	
	HANDLE hError; 
	int FileCount = 0;  	
	char FilePathName[LEN];  	
	char FullPathName[LEN]; 
	CStringArray strArray[128];
	CTime tmToday; //今天的日期 
 	CTime tmPreDay; //前两天的日期 
	CTimeSpan tmspanTwoDay(1,0,0,0); //两天的时间距离 
	CString DayTime;
 
	for(int i=0;i<3;i++)
	{
		tmToday=CTime::GetCurrentTime();//获得当前日期 
		CTimeSpan tmspanTwoDay(i,0,0,0); //两天的时间距离 
		tmPreDay=tmToday-tmspanTwoDay; 
		DayTime.Format("%04d-%02d-%02d",tmPreDay.GetYear(),tmPreDay.GetMonth(),tmPreDay.GetDay());
		printf("%s\n",DayTime);
		char* path = (char*)malloc(150*sizeof(char));  //分配空间		
		memset(path,0,150*sizeof(char));   //初始化				
		path = strcat(path,"E:\\GPSTrack\\");      
		path = strcat(path,DayTime.GetBuffer(0));
		path = strcat(path,"\\");
		strcpy(FilePathName, path);  	
		strcat(FilePathName, "\\*.*");
		hError = FindFirstFile(FilePathName, &FindData);  	
		if (hError == INVALID_HANDLE_VALUE)  		
		{  		
			printf("搜索失败!");
			continue;
		}  	
		while(::FindNextFile(hError, &FindData))  		
		{  			
			if (strcmp(FindData.cFileName, ".") == 0   		
				|| strcmp(FindData.cFileName, "..") == 0 )  		
			{  		
				continue;  
			}  			
			wsprintf(FullPathName, "%s", FindData.cFileName);
			FileCount++;
			printf("\n%d  %s  ", FileCount, FullPathName);
			printf("\n");
			saResult.Add(FullPathName);
			
		}
		printf("\n");
	}
		
	return 0;  	
}
// 该函数模板使用冒泡法对集合元素进行排序,参数说明:
//     collection       集合对象,集合对象必须提供 [] 操作。
//     element          集合元素,该参数的作用仅仅是确定集合元素类型,
//                      参数的值没有用,建议取集合的第一个元素。集合
//                      元素必须提供复制、赋值和比较操作。
//     count            集合元素的数目
//     ascend           表明排序时使用升序(true)还是降序(false)
// 该函数模板支持C++数组以及MFC集合CStringArray、CArray。


void BubbleSort(CStringArray & collection, CString element, int count, bool ascend)
{
	for (int i = 0; i < count-1; i++)
		for (int j = 0; j < count-1-i; j++)
			if (ascend)
			{
				// 升序
				if (collection[j] > collection[j+1])
				{
					CString temp = collection[j];
					collection[j] = collection[j+1];
					collection[j+1] = temp;
				}
			}
			else
			{
				// 降序
				if (collection[j] < collection[j+1])
				{
					CString temp = collection[j];
					collection[j] = collection[j+1];
					collection[j+1] = temp;
				}
			}
 }
//去掉字符串数组中相同的字符串
void  DelSame(CStringArray *src,CStringArray *dest)
{
	CString tmp;
	
	
	
	volatile int realcnt = 0;
	volatile int j = 0;
	
	dest->Add(src->GetAt(0));
	realcnt = 1;
	for(int i = 1 ; i < src->GetSize();++i)
	{
		
		for(j = 0; j < realcnt;++j)
		{
			if(src->GetAt(i) == dest->GetAt(j))
			{
				break;
			}
		}
		if(j == realcnt)
		{
			dest->Add(src->GetAt(i));
			realcnt++;
		}
	}
}
	BOOL isInclude = FALSE;
			for (int count=0;count<DeviceList.GetSize();++count)
			{	
				for (int j=0;j<DayDevcie.GetSize();++j)
				{
					if (strcmp(DeviceList[count].GetBuffer(0),DayDevcie[j].GetBuffer(0))==0)
					{
						isInclude = TRUE;
						break;
					}
				}
				if (isInclude==FALSE)
				{
				//	printf("不在里面的设备%s\n",DeviceList[count].GetBuffer(0));
					tmp.Add(DeviceList[count].GetBuffer(0));
				}
				isInclude =FALSE;
			}

=================================================================================================================

程序猿和程序媛必备的咖啡-OneDay咖啡生活-https://shop110384469.taobao.com/




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值