Example #1
0
long CHSDownloadData::GetChangedBeginDate( CodeInfo *pCode,long lBeginDate,int nSpillDays,int nPeriod )
{
	if (nSpillDays <= 0)
	{
		return lBeginDate;
	}

	short nOneDayNums  = 240;
	short nGZIndex = MakeGZIndex(pCode->m_cCodeType);
	short nMainType  = MakeMarket(pCode->m_cCodeType);

	if (nGZIndex)
		nOneDayNums = 270;
	else
		nOneDayNums = 240;

	int nCount = 0,nGapDays =0, nYushu =0;
	CTimeSpan oneDay(1,0,0,0);
	CTime tmbg = GetTimeFromIntTime(lBeginDate,nPeriod);
	long lBeginMinite = lBeginDate%10000;
	switch(nPeriod)
	{
	case PERIOD_TYPE_DAY:
		while(nCount < nSpillDays)
		{
			tmbg += oneDay;
			int nWeekEnd = tmbg.GetDayOfWeek();
			if (nWeekEnd != 1 && nWeekEnd != 7)
			{
				nCount++;
			}
		}
		return GetIntTimeFromTime(tmbg,nPeriod);
	case PERIOD_TYPE_MINUTE1:
	case PERIOD_TYPE_MINUTE5:
		{
			int nIndex = 1,nQiHuoMorningBegin = 900,nQZQihuoMorningBegin = 915,nStockMorningBegin = 930;
			if (nPeriod == PERIOD_TYPE_MINUTE5)
			{
				nIndex = 5;
				nQiHuoMorningBegin = 905;
				nQZQihuoMorningBegin = 920;
				nStockMorningBegin = 935;
			}
			nGapDays = nSpillDays/(nOneDayNums/nIndex);
			nYushu = nSpillDays%(nOneDayNums/nIndex);
			while(nCount < nGapDays)
			{
				tmbg += oneDay;
				int nWeekEnd = tmbg.GetDayOfWeek();
				if (nWeekEnd != 1 && nWeekEnd != 7)
				{
					nCount++;
				}
			}

			CTime tmMoriningEnd;
			CTime tmNewTime;
			long lTmp = 0;
			CTimeSpan  tmTempSpan;
			CTimeSpan min1(0,(nYushu*nIndex)/60,(nYushu*nIndex)%60,0);
			CTime tmTemp = tmbg;
			tmTemp += min1;
			long lNewMini = GetIntTimeFromTime(tmTemp,nPeriod);
			tmNewTime = tmTemp;
			if (lBeginMinite < 1130)
			{	
				long ltailMini = lNewMini%10000;
				if (ltailMini <1130 )
				{
					return  lNewMini;
				}
				else
				{
					if (nMainType == STOCK_MARKET)
					{
						lTmp = (lNewMini/10000) * 10000 + 1300;
					}
					else
					{
						if (!nGZIndex)
							lTmp = (lNewMini/10000) * 10000 + 1330;
						else
							lTmp = (lNewMini/10000) * 10000 + 1300;
					}
					tmNewTime = GetTimeFromIntTime(lTmp,nPeriod);
					tmMoriningEnd = GetTimeFromIntTime((lNewMini/10000) * 10000 + 1130,nPeriod);
					tmTempSpan = tmTemp - tmMoriningEnd;
					tmNewTime += tmTempSpan;
					lNewMini = GetIntTimeFromTime(tmNewTime,nPeriod);
					goto minite1_5;
				}
			}
			else
			{
				goto minite1_5;
			}

minite1_5:
			if (nGZIndex)
			{
				if (lNewMini%10000 <= 1515)
				{
					return lNewMini;
				}
				else
				{
					lTmp = (lNewMini/10000) * 10000 + 1515;
					tmTemp = GetTimeFromIntTime(lTmp,nPeriod);
					tmTempSpan = tmNewTime - tmTemp;

					lNewMini = (lNewMini/10000) * 10000 + nQZQihuoMorningBegin;
					tmTemp =  GetTimeFromIntTime(lNewMini,nPeriod);
					tmTemp += oneDay;
					tmTemp += tmTempSpan;
					lNewMini = GetIntTimeFromTime(tmTemp,nPeriod);
					if (lNewMini%10000 <= 1130)
					{
						return lNewMini;
					}
					tmMoriningEnd = GetTimeFromIntTime((lNewMini/10000) * 10000 + 1130,nPeriod);
					tmTempSpan = tmTemp - tmMoriningEnd;
					lTmp = (lNewMini/10000) * 10000 + 1300;
					tmTemp = GetTimeFromIntTime(lTmp,nPeriod);
					tmTemp += tmTempSpan;
					return  GetIntTimeFromTime(tmTemp,nPeriod);
				}
			}
			else
			{
				if (lNewMini%10000 <= 1500)
				{
					return lNewMini;
				}
				else
				{
					lTmp = (lNewMini/10000) * 10000 + 1500;
					tmTemp = GetTimeFromIntTime(lTmp,nPeriod);
					tmTempSpan = tmNewTime - tmTemp;

					if (nMainType == STOCK_MARKET)						
						lNewMini = (lNewMini/10000) * 10000 + nStockMorningBegin;			
					else
						lNewMini = (lNewMini/10000) * 10000 + nQiHuoMorningBegin;

					tmTemp =  GetTimeFromIntTime(lNewMini,nPeriod);
					tmTemp += oneDay;
					tmTemp += tmTempSpan;
					lNewMini = GetIntTimeFromTime(tmTemp,nPeriod);
					if (lNewMini%10000 <= 1130)
					{
						return lNewMini;
					}
					tmMoriningEnd = GetTimeFromIntTime((lNewMini/10000) * 10000 + 1130,nPeriod);
					tmTempSpan = tmTemp - tmMoriningEnd;
					if (nMainType == STOCK_MARKET)	
						lTmp = (lNewMini/10000) * 10000 + 1300;
					else
						lTmp = (lNewMini/10000) * 10000 + 1330;

					tmTemp = GetTimeFromIntTime(lTmp,nPeriod);
					tmTemp += tmTempSpan;
					return  GetIntTimeFromTime(tmTemp,nPeriod);
				}
			}
		}
		break;
	default:
		return lBeginDate;
	}
}
void CTestCalIndexFileModifyEntryStep::ModifyEntryL()
	{
	TPtrC entryString;
	TBool readRes = EFalse;
	readRes = GetStringFromConfig(ConfigSection(), KModifyEntry, entryString);
	if (!readRes)
		{
		INFO_PRINTF1(_L("Error in CTestCalIndexFileModifyEntryStep::ModifyEntryL - entrytomodify not found in config file"));
		User::Leave(KErrNotFound);
		}
	CConfigTestEntryInfo* inf = new(ELeave)CConfigTestEntryInfo();
	CleanupStack::PushL(inf);
	ParseEntryStringL(*inf, entryString);
				
	//  see if we can find a match in the database using an instance view
		
		CCalProgress* progress = new(ELeave)CCalProgress;
		CleanupStack::PushL(progress);  
	
		CCalInstanceView* view = CCalInstanceView::NewL(*iSession, *progress);
		CleanupStack::PushL(view);
		
		CActiveScheduler::Start();
		
		CalCommon::TCalViewFilter filter = CalCommon::EIncludeAppts;
		switch (inf->iType)
			{
			case (CCalEntry::EAppt):
				filter = CalCommon::EIncludeAppts;
				break;
			case (CCalEntry::ETodo):
				filter = CalCommon::EIncludeCompletedTodos | CalCommon::EIncludeIncompletedTodos;
				break;
			case (CCalEntry::EEvent):
				filter = CalCommon::EIncludeEvents;
				break;
			case (CCalEntry::EReminder):
				filter = CalCommon::EIncludeReminder;
				break;
			case (CCalEntry::EAnniv):
				filter = CalCommon::EIncludeAnnivs;
				break;
			default:
				User::Leave(KErrCorrupt);
				break;
			}
		RPointerArray<CCalInstance> instances;
		CleanupClosePushL(instances);

		// look for instances between (startdate -1 day) and
		// (enddate + 1 day)
		TTimeIntervalDays oneDay(1);
		TTime beginTTime = (inf->iStartTime) - oneDay;
		TTime endTTime = (inf->iEndTime) + oneDay;
		TCalTime begin;
		begin.SetTimeUtcL(beginTTime);
		TCalTime end;
		end.SetTimeUtcL(endTTime);
		CalCommon::TCalTimeRange timerange(begin, end);	
		
		view->FindInstanceL(instances, filter, timerange);
		
		TInt counter = 0;
		TInt max = instances.Count();
		INFO_PRINTF2(_L("%d instances to compare against"),max);
		TBool found = EFalse;
		while ((found == EFalse) && (counter < max))
			{
			INFO_PRINTF2(_L("compare modify info to entry %d"), (counter+1));
			if (inf->CompareToEntryL((instances[counter])->Entry()))
				{
				INFO_PRINTF2(_L("Entry info matched instance %d"), (counter+1));
				found = ETrue;
				
				CCalProgress* progress1 = new(ELeave)CCalProgress;
				CleanupStack::PushL(progress1);  
				
				CCalEntryView* eView = CCalEntryView::NewL(*iSession, *progress);
				CleanupStack::PushL(eView);
				
				CActiveScheduler::Start();

				CCalEntry* eEntry = &((instances[counter])->Entry());
				eEntry->SetDescriptionL(KTCIModifiedText());
				RPointerArray<CCalEntry> eList;
				CleanupResetAndDestroyPushL(eList);
				eList.Reset();
				TInt numChanged = 0;
				eList.Append(eEntry);
				eView->UpdateL(eList, numChanged);
				if (numChanged != 1)
					{
					INFO_PRINTF1(_L("Error modifiying entry"));
					User::Leave(KErrGeneral);
					}
				CleanupStack::PopAndDestroy(&eList);
				CleanupStack::PopAndDestroy(2);
				}
			else
				{
				counter++;
				}
			}
		CleanupStack::PopAndDestroy(&instances);
		CleanupStack::PopAndDestroy(view);
		CleanupStack::PopAndDestroy(progress);
	
	CleanupStack::PopAndDestroy(inf);
	
	if (!found)
		{
		INFO_PRINTF1(_L("Could not find entrytomodify in database"));
		User::Leave(KErrNotFound);
		}
	}
Example #3
0
long CHSDownloadData::GetPreDataDate( CodeInfo *pCode,long nCurrentDate,int nPeriod )
{
	CTimeSpan oneDay(1,0,0,0);
	CTimeSpan tSpan = GetTimeStep(nPeriod);
	CTime tm =  GetTimeFromIntTime(nCurrentDate,nPeriod);

	short nGZIndex = MakeGZIndex(pCode->m_cCodeType);
	short nMainType  = MakeMarket(pCode->m_cCodeType);
	int nBeing1min = 931;
	int nBegin5min = 935;
	if (nMainType != STOCK_MARKET)
	{
		if (nGZIndex)
		{
			nBeing1min = 916;
			nBegin5min = 920;
		}
		else
		{
			nBeing1min = 901;
			nBegin5min = 905;
		}
	}

	switch(nPeriod)
	{
	case PERIOD_TYPE_DAY:
		tm -= tSpan;
		while(tm.GetDayOfWeek() == 1 || tm.GetDayOfWeek() ==7)
		{
			tm -= tSpan;
		}
		return GetIntTimeFromTime(tm,nPeriod);

	case PERIOD_TYPE_MINUTE1:
	case PERIOD_TYPE_MINUTE5:
		{
			int nMinute = nCurrentDate%10000;
			if (nPeriod == PERIOD_TYPE_MINUTE1)
			{
				if (nMinute != nBeing1min)
				{
					tm -= tSpan;
					return GetIntTimeFromTime(tm,nPeriod);
				}
			}
			if (nPeriod == PERIOD_TYPE_MINUTE5)
			{
				if (nMinute != nBegin5min)
				{
					tm -= tSpan;
					return GetIntTimeFromTime(tm,nPeriod);
				}
			}

			tm -= oneDay;
			while(tm.GetDayOfWeek() == 1 || tm.GetDayOfWeek() == 7)
			{
				tm -= oneDay;
			}
			long lPreDate = (tm.GetYear() - 1990)* 100000000 + tm.GetMonth() * 1000000 + tm.GetDay() * 10000;
			if (nGZIndex)
			{
				lPreDate += 1515;
			}
			else
			{
				lPreDate += 1500;
			}

			return lPreDate;
		}
	default:
		return nCurrentDate;
	}
}