Exemple #1
0
//结合剧目Play.dat,统计销售数据,构建销售分析salesanalysis_list_t list链表,返回list链表长度
int Salesanalysis_Srv_StaticSale(salesanalysis_list_t list) {
	
	int count=0;
	int sold;	//已售票数 
	int total;	//总票数 
	assert(NULL!=list) ;
	play_list_t playList,pos;
	
	salesanalysis_node_t *newNode;
	

	List_Free(list,salesanalysis_node_t);//释放所有数据结点 
	List_Init(playList,play_node_t);//初始化 
	Play_Srv_FetchAll(playList);//载入剧目信息,构建链表
	
	List_ForEach(playList,pos){ 
		 
		newNode=(salesanalysis_node_t *)malloc(sizeof(salesanalysis_node_t));
		if(!newNode){
			break;
		}
		newNode->data.play_id=pos->data.id;	//剧目信息 
		newNode->data.start_date=pos->data.start_date;
		newNode->data.end_date=pos->data.end_date;
		
		newNode->data.sales=Schedule_Srv_StatRevByPlay(pos->data.id,&sold,&total);
		newNode->data.totaltickets=sold;
		List_AddTail(list,newNode);
		count++;
	}
/*
 * Function:    Play_Perst_SelectByName
 * Function ID:	TTMS_SCU_Play_Perst_SelByName
 * Description: 按照剧目名称查找剧目的信息
 * Input:       list为查找到的剧目信息链表,condt为模糊查询的关键字
 * Output:      提示建立链表时,申请空间失败
 * Return:      返回查找到的记录数目
 */
int Play_Perst_SelectByName(play_list_t list, char condt[]) {
    play_t      data;
    play_node_t *newNode;
    int         iCount = 0;
    FILE        *fp;
    fp = fopen(PLAY_DATA_FILE,"rb");
    if(fp == NULL)
    {
        printf("Failed to open file %s!\n[Enter] to return!",PLAY_DATA_FILE);
        getchar();
        return 0;
    }
    
    List_Free(list,play_node_t);
    
    while (!feof(fp))
    {
        if (fread( &data, sizeof(play_t), 1, fp))
        {
            if (strcmp(condt,data.name) == 0)
            {
                newNode->data = data;
                List_AddTail(list,newNode);
                iCount++;
            }
        }
    }
    return iCount;
}
void AsyncList_Uninitialize(AsyncList* self) {
	assert(self != NULL);

	List_Free(self->BaseList);
	SAL_Mutex_Free(self->Lock);
	Free(self->DefaultIterator);
}
Exemple #4
0
int Play_Perst_SelectAll(play_list_t list) {
	// Çë²¹³äÍêÕû
	play_node_t *newNode;
	play_t data;
	int recCount = 0;

	assert (NULL != list);
		
	List_Free (list, play_node_t);
		
	FILE *fp = fopen (PLAY_DATA_FILE, "rb");
	if (NULL == fp)
	{
		return 0;
	}

	while (!feof (fp))
	{	
		if(fread (&data, sizeof (play_t), 1, fp))
		{
			newNode = (play_node_t *) malloc (sizeof (play_node_t));
			if (!newNode)
			{
				printf ("Memory Load fail!\n");
				break;
			}
			newNode->data = data;
			List_AddTail (list, newNode);
			recCount ++;
		}
	}
	fclose (fp);
	return recCount;	
}
Exemple #5
0
static void List_Clear(var self) {
    struct List* l = self;
    var item = l->head;
    while (item) {
        var next = *List_Next(l, item);
        destruct(item);
        List_Free(l, item);
        item = next;
    }
    l->tail = NULL;
    l->head = NULL;
    l->nitems = 0;
}
static AwaError ClientSubscription_Free(AwaClientSubscription ** subscription)
{
    AwaError result = AwaError_SubscriptionInvalid;

    if ((subscription != NULL) && (*subscription != NULL))
    {
        List_ForEach((*subscription)->Operations, RemoveSubscriptionFromOperation, *subscription);
        List_Free(&(*subscription)->Operations);

        if ((*subscription)->Session != NULL)
        {
            Map_Remove(ClientSession_GetSubscribers((*subscription)->Session), (*subscription)->Path);
        }

        free((void *)(*subscription)->Path);
        Awa_MemSafeFree(*subscription);
        *subscription = NULL;

        result = AwaError_Success;
    }
    return result;
}
/*
 * Function:    Play_Perst_SelectAll
 * Function ID:	TTMS_SCU_Play_Perst_SelAll
 * Description: 将所有剧目信息建立成一条链表
 * Input:       list剧目信息链表的头指针
 * Output:      提示建立链表时,申请空间失败
 * Return:      返回查找到的记录数目
 */
int Play_Perst_SelectAll(play_list_t list) {
   play_t          data;
    play_node_t     *newNode;
    int             recCount = 0;
    FILE            *fp;
    fp = fopen(PLAY_DATA_FILE,"rb");
    if(fp == NULL)
    {
        //printf("Failed to open file %s!\n[Enter] to return!",STUDIO_FILE);
        //getchar();
        return 0;
    }
    
    List_Free(list,play_node_t);
    
    while(!feof(fp))
    {
        if(fread( &data, sizeof(play_t), 1, fp))
        {
            newNode = (play_node_t *)malloc(sizeof(play_node_t));
            if(newNode)
            {
                newNode->data = data;
                List_AddTail(list,newNode);
                recCount++;
            }
            else
            {
                printf("Memory application failure!!\n[Enter] to continue!");
                getchar();
                break;
            }
        }
    }
    fclose(fp);
    return recCount;
}