int ScheduleViewEx::GetYOffset() const
{
	Periods& periods = static_cast<CScheduleApp*>(AfxGetApp())->m_periods;
	Period& period = periods.GetCurrentPeriod();
	CTimeSpan span = period.m_dateRange.GetEndDate() - 
		period.m_dateRange.GetStartDate();
	
	int numberOfXPages = (int)(span.GetDays() / xDelta);
	if (span.GetDays() % xDelta) // if a partial page, then add 1
		numberOfXPages++;

	int yOffset = m_offset / numberOfXPages;
	return yOffset;
}
Beispiel #2
0
void CTortoiseProcApp::EnableCrashHandler()
{
	// the crash handler is enabled by default, but we disable it
	// after 3 months after a release

#define YEAR ((((__DATE__ [7] - '0') * 10 + (__DATE__ [8] - '0')) * 10  \
              + (__DATE__ [9] - '0')) * 10 + (__DATE__ [10] - '0'))

#define MONTH (__DATE__ [2] == 'n' ? (__DATE__ [1] == 'a' ? 1 : 6)      \
                : __DATE__ [2] == 'b' ? 2                               \
                : __DATE__ [2] == 'r' ? (__DATE__ [0] == 'M' ? 3 : 4)   \
                : __DATE__ [2] == 'y' ? 5								\
                : __DATE__ [2] == 'l' ? 7                               \
                : __DATE__ [2] == 'g' ? 8                               \
                : __DATE__ [2] == 'p' ? 9                               \
                : __DATE__ [2] == 't' ? 10                               \
                : __DATE__ [2] == 'v' ? 11 : 12)

 #define DAY ((__DATE__ [4] == ' ' ? 0 : __DATE__ [4] - '0') * 10       \
              + (__DATE__ [5] - '0'))

 #define DATE_AS_INT (((YEAR - 2000) * 12 + MONTH) * 31 + DAY)

	CTime compiletime(YEAR, MONTH, DAY, 0, 0, 0);
	CTime now = CTime::GetCurrentTime();

	CTimeSpan timediff = now-compiletime;
	if (timediff.GetDays() > 3*31)
	{
//		crasher.Enable(FALSE);
	}
}
Beispiel #3
0
//
//  機能     : 古いログの削除
//  
//  機能説明 : LOG_EXPIRE 日以上前のログは削除
//  
//  返り値   : true  正常終了
//             false エラー発生
//  
//  備考     : 
//  
bool CTPerror::DelOldLog()
{
	CString str;
	CFileFind finder;
	CTime ntm;
	CTime tm;
	CTimeSpan tms;
	CFileSpec fs;

	/// LOG_EXPIRE期間以前のログファイルを削除
	if (!SetCurrentDirectory(LogDir)) return false;
	ntm = CTime::GetCurrentTime();
	BOOL bWorking = finder.FindFile(_T("*.log"));
	if (!bWorking) return false;
	str.Empty();
	while (bWorking)
	{
		bWorking = finder.FindNextFile();
		if (!finder.IsDirectory()) {
			str = finder.GetFileName();
			/// ログファイル作成日付と現在との差分
			finder.GetCreationTime(tm);
			tms = ntm - tm;
			if (tms.GetDays() > LOG_EXPIRE) {
				fs.SetFullSpec(str);
				if (!fs.Exist()) continue;
				fs.FileDelete();
			}
		}
	}
	finder.Close();

	return true;
}
int ScheduleViewEx::TotalPages() const
{
	Periods& periods = static_cast<CScheduleApp*>(AfxGetApp())->m_periods;
	Period& period = periods.GetCurrentPeriod();
	CTimeSpan span = period.m_dateRange.GetEndDate() - 
		period.m_dateRange.GetStartDate();
	
	int numberOfXPages = (int)(span.GetDays() / xDelta);
	if (span.GetDays() % xDelta) // if a partial page, then add 1
		numberOfXPages++;
	int numberOfYPages = period.m_data.m_nurses.Size() / yDelta;
	if (period.m_data.m_nurses.Size() % yDelta)
		numberOfYPages++;
	return numberOfXPages * numberOfYPages;

}
Beispiel #5
0
void CCenterServerDlg::CheckBanBen()
{
	return ;
	CString sn ="20071030";////截止日期
	
	long in=atol(sn.GetBuffer (sn.GetLength ()));
	if(in<=0)return ;
	int y1=atoi(sn.Mid (0,4)),
		m1   =atoi(sn.Mid (4,2)),
		d1=atoi(sn.Mid (6,2));

	CTime t1(y1,m1,d1,0,0,0);
	time_t ct;  
    time( &ct ) ;

	CTime t2(ct);

	CTimeSpan tsp;
	tsp=t2-t1;//// 当前日期  - 截止日期

	LONGLONG dd=tsp.GetDays ();

	if(t2>t1)//dd > 0)
	{
		KillTimer(1);
		KillTimer(2);
		KillTimer(3);
		m_CenterServerModule.StoptService();
		AfxMessageBox("本软件生命周期到期,请重新联系www.bzw.cn获取升级版本。(此提示并非时间限制,而是说明程序寿命已到,获取升级版本是免费的。)");
		CDialog::OnOK ();//theApp.m_pMainWnd->DestroyWindow ();
		return ;
	}
}
	std::string GetTimeSpanStr(CTimeSpan t)
	{
		std::string strTime;

		if (t.GetDays() > 0)
			strTime = UtilWin::ToUTF8(t.Format(_T("%D, %H:%M:%S")));
		else strTime = UtilWin::ToUTF8(t.Format(_T("%H:%M:%S")));

		return strTime;
	}
Beispiel #7
0
void CKcsLogging::ClearLogFileByDays(int nDay /* = 7 */)
{
    CHAR szLogFileName[MAX_PATH * 2] = { 0 };
    WIN32_FIND_DATAA fd = { 0 };
    HANDLE hFile = INVALID_HANDLE_VALUE;

    SHGetSpecialFolderPathA(NULL, szLogFileName, CSIDL_LOCAL_APPDATA, FALSE);

    PathAppendA(szLogFileName, "KSafe\\KClear\\Logs");
    PathAppendA(szLogFileName, "*.*");


    hFile = FindFirstFileA(szLogFileName, &fd);
    if (INVALID_HANDLE_VALUE == hFile)
    {
        goto Clear0;
    }

    do 
    {
        if (0 == stricmp(".", fd.cFileName) || 0 == stricmp("..", fd.cFileName))
            continue;

        time_t lNow = 0;
        time(&lNow);  

        FILETIME localfiletime;    
        FileTimeToLocalFileTime(&(fd.ftLastWriteTime), &localfiletime);

        CTime stSys(lNow);
        CTime stFile(localfiletime);
        CTimeSpan stSPan;

        stSPan =  stSys - stFile;

        if (stSPan.GetDays() >= nDay)
        {           
            CStringA strtemp = szLogFileName ;
            CStringA strFileName = strtemp.Left(strtemp.ReverseFind(L'\\') + 1);
            strFileName += fd.cFileName;                 
            if (::PathFileExistsA(strFileName))
            {
                ::DeleteFileA(strFileName);
            }
        }

    } while (FindNextFileA(hFile, &fd));

Clear0:
    if (hFile != INVALID_HANDLE_VALUE)
    {
        FindClose(hFile);
        hFile = INVALID_HANDLE_VALUE;
    }   
}
Beispiel #8
0
int GetElapsedDays (int yy,int mm,int dd)
{
	CTime curr;
	curr =CTime::GetCurrentTime();
	
	CTime from(curr.GetYear(),curr.GetMonth(),curr.GetDay(),24,0,0);
	CTime to(yy,mm,dd,24,0,0);
	CTimeSpan elapsedTime = to - from;
	
	return elapsedTime.GetDays();
}
Beispiel #9
0
int GetDays(tm ToDay)
{
	CTime from;
	from =CTime::GetCurrentTime();

	CTime to(ToDay.tm_year,ToDay.tm_mon,ToDay.tm_mday,0,0,0);

	CTimeSpan elapsedTime = to - from;

	return elapsedTime.GetDays();
}
BOOL CFilterPasswordDlg::OnInitDialog()
{
  CFilterBaseDlg::OnInitDialog();

  CString cs_text;

  // NOTE: This ComboBox is NOT sorted by design !
  if (m_cbxRule.GetCount() == 0) {
    const PWSMatch::MatchRule mrx[] = {PWSMatch::MR_EQUALS,   PWSMatch::MR_NOTEQUAL,
                                       PWSMatch::MR_BEGINS,   PWSMatch::MR_NOTBEGIN,
                                       PWSMatch::MR_ENDS,     PWSMatch::MR_NOTEND,
                                       PWSMatch::MR_CONTAINS, PWSMatch::MR_NOTCONTAIN,
                                       PWSMatch::MR_CNTNANY,  PWSMatch::MR_NOTCNTNANY,
                                       PWSMatch::MR_CNTNALL,  PWSMatch::MR_NOTCNTNALL,
                                       PWSMatch::MR_EXPIRED,  PWSMatch::MR_WILLEXPIRE};

    for (size_t i = 0; i < _countof(mrx); i++) {
      UINT iumsg = PWSMatch::GetRule(mrx[i]);
      cs_text.LoadString(iumsg);
      int iItem = m_cbxRule.AddString(cs_text);
      m_cbxRule.SetItemData(iItem, mrx[i]);
      m_rule2selection[mrx[i]] = iItem;
    }
  }

  int isel = m_rule2selection[(int)m_rule];
  if (isel == -1)
    m_rule = PWSMatch::MR_INVALID;

  if (m_rule != PWSMatch::MR_INVALID) {
    m_cbxRule.SetCurSel(isel);

    EnableDialogItems();
  } else
    m_cbxRule.SetCurSel(-1);

  // Last 32-bit date is 03:14:07 UTC on Tuesday, January 19, 2038
  // Find number of days from now to 2038/01/18 = max value here
  const CTime ct_Latest(2038, 1, 18, 0, 0, 0);
  const CTime ct_Now(CTime::GetCurrentTime());
  CTimeSpan elapsedTime = ct_Latest - ct_Now;
  m_maxDays = (int)elapsedTime.GetDays();

  UpdateData(FALSE);

  return TRUE;
}
Beispiel #11
0
/*Delete the logfiles  two days ago */
BOOL CFileLogWriter::ClearSomeLogfile( )
{
     WCHAR szLogFileName[MAX_PATH] = { 0 };

     GetModuleFileName(NULL, szLogFileName, MAX_PATH);
     PathRemoveFileSpec(szLogFileName);
     PathAppend(szLogFileName, L"log\\*.*");
     WIN32_FIND_DATA fd = { 0 };

     HANDLE hFile  = FindFirstFile(szLogFileName, &fd);
     if (INVALID_HANDLE_VALUE == hFile)
     {
         return FALSE;
     }

     do 
     {
         if (0 == _wcsicmp(L".", fd.cFileName) || 0 == _wcsicmp(L"..", fd.cFileName))
             continue;
        
         time_t lNow = 0;
         time(&lNow);  

         FILETIME localfiletime;    
         FileTimeToLocalFileTime(&(fd.ftLastWriteTime), &localfiletime);

         CTime stSys(lNow);
         CTime stFile(localfiletime);
         CTimeSpan stSPan;

         stSPan =  stSys - stFile;

         if (stSPan.GetDays() > 6)
         {           
             CString strtemp = szLogFileName ;
             CString strFileName = strtemp.Left(strtemp.ReverseFind(L'\\') + 1);
             strFileName += fd.cFileName;                 
             ClearLog(strFileName);
         }
              
     } while (FindNextFile(hFile, &fd));

     FindClose(hFile);

     return TRUE; 
}
Beispiel #12
0
void CXfilterDlg::OnLoad() 
{
	IpFilterDriver.init(IP_FILTER_DRIVER_NAME, FILE_ATTRIBUTE_NORMAL);	
	CString s;
	CTime time = CTime::GetCurrentTime();
	CTimeSpan ts;
	CTime t(0);
	ts = time - t;
	s.Format("CurrentTime: %u, %s DayCount:%u, TotalSec:%u, Week: %u\n"
		, CTime::GetCurrentTime().GetTime()
		, time.Format("%Y-%m-%d %H:%M:%S")
		, ts.GetDays()
		, ts.GetTotalSeconds()
		, time.GetDayOfWeek());
//	OutputDebugString(s);

	if (IpFilterDriver.getError() != NO_ERROR) 
		AfxMessageBox(_T("Can't load IpFilter Driver"));
}
Beispiel #13
0
int CHttpRequest::DownloadNetCommand(BYTE bUpdateInterval, BOOL IsSyn)
{
	int iRet = XERR_UPDATE_INTERVAL_INVALID;
//	DWORD dwFlags;
//	if(!InternetGetConnectedState(&dwFlags, 0))
//		return XERR_CURRENT_NOT_ONLINE;

	if(bUpdateInterval >= 100)
		return XERR_UPDATE_INTERVAL_INVALID;

	memset(&m_CommandHeader, 0, sizeof(XNET_COMMAND_HEADER));
	m_Install.ReadReg(REG_NET_COMMAND_HEADER_ITEM
		, (BYTE*)&m_CommandHeader, sizeof(XNET_COMMAND_HEADER));

	//
	// 2002/12/20 Modify for v2.1.0
	//
	CTimeSpan ts = CTime::GetCurrentTime() - m_CommandHeader.tCheckTime;
	int IntervalDays = ts.GetDays();
	if( bUpdateInterval == 0 || m_CommandHeader.tCheckTime == 0
		|| IntervalDays >= bUpdateInterval) 
	{
		if(m_CommandHeader.tCheckTime != 0)
		{
			CString String, Message, Caption;
			Caption.LoadString(IDS_CAPTION);
			if(bUpdateInterval != 0)
			{
				String.LoadString(IDS_UPDATE_MESSAGE);
				Message.Format(String, IntervalDays);
				int iAsk = ::MessageBox(NULL, Message, Caption, MB_YESNO | MB_ICONQUESTION);
				if(iAsk == IDNO)
					return XERR_REGISTER_DLG_CANCEL;
			}
			CShell m_Shell;
			if(m_Shell.RunProgram(PROGRAM_UPDATE) != SHELL_ERROR_SUCCESS)
			{
				Message.LoadString(IDS_ERROR_CANT_RUN_FILUP);
				::MessageBox(NULL, Message, Caption, MB_OK | MB_ICONWARNING);
				return XERR_REGISTER_DLG_CANCEL;
			}
		}
		m_CommandHeader.tCheckTime = CTime::GetCurrentTime();
		m_Install.SaveReg(REG_NET_COMMAND_HEADER_ITEM, (BYTE*)&m_CommandHeader, sizeof(XNET_COMMAND_HEADER));
		iRet = XERR_SUCCESS;

		//
		// 2002/12/20 remove for v2.1.0
		//
		/*
		sprintf(m_pUrlRequest, NET_COMMAND_URL);

		if(IsSyn)
		{
			iRet = DownloadCommandFile(this);
		}
		else
		{
			DWORD dwThreadId;
			m_DownloadThread = ::CreateThread(NULL
				, 0, DownloadCommandFile, this, 0, &dwThreadId);
			m_CommandHeader.tCheckTime = CTime::GetCurrentTime();
			m_Install.SaveReg(REG_NET_COMMAND_HEADER_ITEM, 
				(BYTE*)&m_CommandHeader, sizeof(XNET_COMMAND_HEADER));
			iRet = XERR_STATUS_PENDING;
		}
		//*/
	}

	return iRet;
}
Beispiel #14
0
int CCaHtmlParse::ParseCaHtmlFlights(std::list<SCaLowPriceFlightDetail*> & listFlight, const std::string& strHtmlData, const CStringA & straDCode, const CStringA & straACode, const SCaLowPriceFlightInfo*	pLowPriceFlightInfo)
{
	TidyDoc doc = tidyCreate();
	tidySetCharEncoding(doc,"raw");
	tidyParseString(doc,strHtmlData.c_str());
	TidyNode tnRoot = tidyGetRoot(doc);

	TidyNode tFlightTab;
	TidyNode tdChild;
	int nIndexTd = 0;

	CTime tCurrent = CTime::GetCurrentTime();
	SCaLowPriceFlightDetail *pfindFlight = NULL;
	if (FindNode(tnRoot,"class","CA_table mt_10 clear",tFlightTab))
	{
		//循环解析结算价,tblPolicy下的每一个子节点即为一条结算价信息
		TidyNode trFlight;
		int nIndexTr = 0;
		BOOL bValid = FALSE;
		CStringA straDPortCode = straDCode;
		CStringA straAPortCode = straACode;
		CStringA straFlightNo("");
		CStringA straFlightStartDate("");
		CStringA straSaleEndDate("");
		CStringA straSaleEndTime("");
		CStringA straFlightStartTime("");

		UINT uPrice = 0;
		UINT uRemainTicket = 0;
		for ( trFlight = tidyGetChild(tFlightTab); trFlight; trFlight = tidyGetNext(trFlight) )
		{
			if (0 == nIndexTr)//跳过表头
			{
				nIndexTr++;
				continue;
			}

			nIndexTd = 0;
			bValid = FALSE;
			straFlightNo = "";
			straFlightStartDate = "";
			straSaleEndDate = "";
			straSaleEndTime = "";
			straFlightStartTime = "";
			uPrice = 0;
			uRemainTicket = 0;
			for ( tdChild = tidyGetChild(trFlight); tdChild; tdChild = tidyGetNext(tdChild) )
			{
				switch(nIndexTd)
				{
				case 0:
					{
						//选择,是否为disabled
						bValid = __IsFlightValid(tdChild);
						TRACE(_T("Flight valid:%d-"), bValid);
						
					}
					break;
				case 1:
					{
						//日期/航班号
						//dumpNode(tdChild, 0);
						//TRACE(_T("\r\n"));
						__GetFlightNoAndFlightStartDate(straFlightNo, straFlightStartDate, doc, tdChild);
						TRACE("date:%s, no:%s-", straFlightStartDate, straFlightNo);
						 //TRACE("%s\r\n", GetNodeContent(doc, tdChild));
					}
					break;
				case 2:
					{
						//起降时间
						//dumpNode(tdChild, 0);
						//TRACE(_T("\r\n"));
						 //TRACE("%s\r\n", GetNodeContent(doc, tdChild));
						__GetFlightStartTime(straFlightStartTime, doc, tdChild);
					}
					break;
				case 3:
					{
						//机场
						//dumpNode(tdChild, 0);
						//TRACE(_T("\r\n"));
						 //TRACE("%s\r\n", GetNodeContent(doc, tdChild));
						if (__IsTwoAirPort(straDCode, straACode))
						{
							__GetAirPortCode(straDPortCode, straAPortCode, doc, tdChild);
							if(straDPortCode.IsEmpty())
								straDPortCode = straDCode;
							if(straAPortCode.IsEmpty())
								straAPortCode = straACode;
							TRACE("%s->%s-", straDPortCode, straAPortCode);
						}

					}
					break;
				case 4:
					{
						//销售结束日期,时间
						//dumpNode(tdChild, 0);
						//TRACE(_T("\r\n"));
						//TRACE("%s\r\n", GetNodeContent(doc, tdChild));
						__GetSaleEndDate(straSaleEndDate, straSaleEndTime, doc, tdChild);
						TRACE("sale end date:%s, %s-", straSaleEndDate, straSaleEndTime);
					}
					break;
				case 5:
					{
						//团购价
						//dumpNode(tdChild, 0);
						//TRACE(_T("\r\n"));
						//TRACE("%s\r\n", GetNodeContent(doc, tdChild));
						//CStringA straSetPrice = GetNodeContent(doc, tdChild);

						//double fSetPrice = atof(straSetPrice.GetBuffer(0));
						//straSetPrice.ReleaseBuffer();
						//tidyRelease(doc);
						//return fSetPrice;
						__GetPriceAndRamainTicket(&uPrice, &uRemainTicket, doc, tdChild);
						TRACE("price:%d, remain %d seats", uPrice, uRemainTicket);
					}
					break;
				}

				nIndexTd++;
			}
			TRACE(_T("\r\n"));

			//截至日期之后的航班不抓取
			//得到起飞日期
			int nFlightStartYear = 2014;
			int nFlightStartMonth = 12;
			int nFlightStartDay = 12;
			GetYearMonthDay(straFlightStartDate, &nFlightStartYear, &nFlightStartMonth, &nFlightStartDay);
			
			CTime tStart(nFlightStartYear, nFlightStartMonth, nFlightStartDay, 0, 0, 0);
			//if (!m_bGetAllCaTuanFlight)
			//{
			//	if (tStart > m_tGetEndTime)
			//		continue;
			//}
			//
			
			//double d6 = pLowPriceFlightInfo->iMinHangPrice * 0.6;
			//UINT u6 = (UINT)d6;
			////6折以上普通团购退改签要收费(低价申请不受限制),所以不上
			//if (uPrice > d6 && CA_TUAN_PRODUCT == pLowPriceFlightInfo->iProductType)
			//{
			//	bValid = FALSE;
			//	uRemainTicket = 0;
			//	continue;
			//}
			//相同日期、时间、班次的航班,只取最低价
			BOOL bFind = __findCaFlight(&pfindFlight, straFlightStartDate, straDPortCode, straAPortCode, straFlightNo, listFlight);
			if (bFind)
			{
				int nCurPrice = (int)uPrice;
				//当前解析出的这个比上次解析出的便宜
				if(pfindFlight->nPrice > nCurPrice)
				{
					if (uRemainTicket > m_nMinTicketWarnNum)
					{
						//当前票的数量充足时,用当前票的数量更新上次解析出的数量
						pfindFlight->nRemainSeat = uRemainTicket;
						pfindFlight->nPrice = nCurPrice;
						pfindFlight = NULL;
					}
				}
				else //(pfindFlight->nPrice <= nCurPrice)
				{
					if(pfindFlight->nRemainSeat <= m_nMinTicketWarnNum)
					{
						pfindFlight->nRemainSeat = uRemainTicket;
						pfindFlight->nPrice = nCurPrice;
						pfindFlight = NULL;
					}
				}

				continue;
			}

			//保存解析出来的航班信息,调用者负责释放内存
			if (bValid)
			{
				SCaLowPriceFlightDetail* pDetail = new SCaLowPriceFlightDetail;
				pDetail->straCompany = "CA";	
				pDetail->straFromCityCode = straDPortCode;	
				pDetail->straToCityCode = straAPortCode;	
				pDetail->straFlightNo = straFlightNo;		
				pDetail->straFromDate = straFlightStartDate;	
				//由于携程订单进入需要一定的时间,国航下班16:00下班,所以当天的票,第2天12:00之前的票,销售结束时间提前30分钟,	
				//取销售间隔
				int nSaleEndYear = 2014;
				int nSaleEndMonth = 12;
				int nSaleEndDay = 12;
				GetYearMonthDay(straSaleEndDate, &nSaleEndYear, &nSaleEndMonth, &nSaleEndDay);
				int nSaleEndHour = 12;
				int nSaleEndMin = 0;
				GetHourMinSec(straSaleEndTime, &nSaleEndHour, &nSaleEndMin);
				CTime tSaleEndDate(nSaleEndYear, nSaleEndMonth, nSaleEndDay, nSaleEndHour, nSaleEndMin, 0);
				CTimeSpan tSpan = tSaleEndDate - tCurrent;
				//end 取销售间隔
				//得到起飞时间
				int nFlightStartHour = 12;
				int nFlightStartMin = 0;
				GetHourMinSec(straFlightStartTime, &nFlightStartHour, &nFlightStartMin);
				CTime tFlightStartTime(nFlightStartYear, nFlightStartMonth, nFlightStartDay, nFlightStartHour, nFlightStartMin, 0);
				CTime tTimeKey(nFlightStartYear, nFlightStartMonth, nFlightStartDay, 12, 0, 0);
				//end 得到起飞时间
	
				//今明两天的、起飞时间在12点之前、且是低价申请的,销售结束时间为 前一天的官网销售结束的前30分钟
				if ((CA_TUAN_LOW_PRICE_APPLY_PRODUT == pLowPriceFlightInfo->iProductType) && (1 == tSpan.GetDays()))//明天的的低价申请
				{	
					if(tFlightStartTime <= tTimeKey)//明天12起飞的低价申请, 今天下午3:25前有效(国航4点下班)
					{
						pDetail->straSaleEndDate.Format("%d-%02d-%02d", tCurrent.GetYear(), tCurrent.GetMonth(), tCurrent.GetDay());
						CTime tSaleEnd(tCurrent.GetYear(), tCurrent.GetMonth(), tCurrent.GetDay(), 15, 25, 0);
						pDetail->straSaleEndTime.Format("%02d:%02d:%02d", tSaleEnd.GetHour(), tSaleEnd.GetMinute(), 0);	
					}
					else//明天12后起飞的低价申请,明早可以出票
					{
						pDetail->straSaleEndDate = straSaleEndDate;
						pDetail->straSaleEndTime.Format("%02d:%02d:%02d", nSaleEndHour, nSaleEndMin, 0);
					}
				}
				else if ((CA_TUAN_LOW_PRICE_APPLY_PRODUT == pLowPriceFlightInfo->iProductType) && (tSpan.GetDays() < 1))//今天的的低价申请,今天下午3:30前有效(国航4点下班)
				{
					pDetail->straSaleEndDate.Format("%d-%02d-%02d", tCurrent.GetYear(), tCurrent.GetMonth(), tCurrent.GetDay());
					CTime tSaleEnd(tCurrent.GetYear(), tCurrent.GetMonth(), tCurrent.GetDay(), 15, 30, 0);
					pDetail->straSaleEndTime.Format("%02d:%02d:%02d", tSaleEnd.GetHour(), tSaleEnd.GetMinute(), 0);	
				}
				else//普通团购,后天及以后的低价申请
				{
					pDetail->straSaleEndDate = straSaleEndDate;
					pDetail->straSaleEndTime.Format("%02d:%02d:%02d", nSaleEndHour, nSaleEndMin, 0);
				}

				//政策销售时间到,删除政策
				GetYearMonthDay(pDetail->straSaleEndDate,  &nSaleEndYear, &nSaleEndMonth, &nSaleEndDay);
				int nSaleEndSec = 0;
				GetHourMinSec(pDetail->straSaleEndTime, &nSaleEndHour, &nSaleEndMin, &nSaleEndSec);
				CTime tPolicyDeleteTime(nSaleEndYear, nSaleEndMonth, nSaleEndDay, nSaleEndHour, nSaleEndMin, nSaleEndSec);
				if (tCurrent >= tPolicyDeleteTime)
					uRemainTicket = 0;

				pDetail->nPrice = uPrice;				
				pDetail->nProductId = pLowPriceFlightInfo->iProductId;			
				pDetail->nRemainSeat = uRemainTicket;	
				pDetail->nProductType = pLowPriceFlightInfo->iProductType;

				listFlight.push_back(pDetail);
			}
		}
	}

	tidyRelease(doc);	

	return -1.0;
}
Beispiel #15
0
CCustomerStatistics::CCustomerStatistics(long lAsID, CAuctionCtrl* pActl, CMC* pMC)  // oikea konstruktori
{
	m_pActl = pActl;

	::SetCursor(::LoadCursor(NULL, IDC_WAIT));

	double dM = 0;
	double dY = 0;
	double dA = 0;
	m_iLoansInAuction = 0;
	m_dAuctionDeficit = 0;
	m_dAuctionBalance = 0;
	m_dPayableAuctionBalance = 0;
	m_dAuctionSum = 0;

	CTime t = CTime::GetCurrentTime();
	CTime tNow((t.GetYear()), (t.GetMonth()), (t.GetDay()), 0,0,0);
	CTimeSpan ts;

	CHKLainatRS* pALrs =  pMC->m_pDB->getAuctionLoanRS();
	//pALrs->m_strFilter.Format("HKL_AsID = %ld and HKL_Kuittaus = 1 and HKL_YlijMaksuPv is null and HKL_YlijKuittausPv is null", lAsID);
	pALrs->m_strFilter.Format("HKL_AsID = %ld", lAsID);
	//pALrs->m_strFilter.Format("HKL_AsID = %ld", lAsID);
	try
	{
		pALrs->Open();
		while (!pALrs->IsEOF())
		{
			m_iLoansInAuction++;

			// kaikki huutokaupassa olevien lainojen summa
			if (!pALrs->IsFieldNull(&pALrs->m_HKL_Laina))
			{
				dM = pALrs->m_HKL_Laina;
				m_dAuctionSum = m_dAuctionSum + pALrs->m_HKL_Laina;
			}
			
			if (!pALrs->IsFieldNull(&pALrs->m_HKL_KorotKulut))
			{
				dM = dM + pALrs->m_HKL_KorotKulut;
			}
			
			if (!pALrs->IsFieldNull(&pALrs->m_HKL_HKkulut))
			{
				dM = dM + pALrs->m_HKL_HKkulut;
			}
			// -- ylijäämä ---
			if (!pALrs->IsFieldNull(&pALrs->m_HKL_Myyntihinta))
			{
				if (dM < pALrs->m_HKL_Myyntihinta)  // ylijäämä
				{
					dY = pALrs->m_HKL_Myyntihinta - dM;
					m_dAuctionBalance = m_dAuctionBalance + dY;
					
					//
					//
					//if (hklaina >1v ja maksamaton)
					ts = tNow - pALrs->m_HKL_MyyntiPv;
					//					
					/*TRACE("Myynnistä aikaa %ld vrk\n", ts.GetDays());
					if( pALrs->m_HKL_Kuittaus == TRUE)
						TRACE("pALrs->m_HKL_Kuittaus == TRUE\n");
					TRACE("Laina-kulut= %7.2f\n", dY);
					if( pALrs->IsFieldNull(&pALrs->m_HKL_YlijKuittausPv))
						TRACE("pALrs->m_HKL_YlijKuittausPv=NULL\n");
					if( pALrs->IsFieldNull(&pALrs->m_HKL_YlijMaksuPv))
						TRACE("m_HKL_YlijMaksuPv=NULL\n");
					*///
					//
					if ((pALrs->m_HKL_Kuittaus == TRUE) &&
						(dY > 0.01) &&
						(pALrs->IsFieldNull(&pALrs->m_HKL_YlijKuittausPv)) &&
						(pALrs->IsFieldNull(&pALrs->m_HKL_YlijMaksuPv))
					   )
					{
						if (ts.GetDays() <= theApp.GetAs()->m_AT_YlijKuitAikaraja)
						{
							m_dPayableAuctionBalance = m_dPayableAuctionBalance + pALrs->m_HKL_Ylij_Alij;
						}
					}
				}
				else  // alijäämä
				{
					dA = dM - pALrs->m_HKL_Myyntihinta;
					m_dAuctionDeficit = m_dAuctionDeficit + dA;
				}
			}

			pALrs->MoveNext();
		}
		pALrs->Close();
	}
	catch (CDBException* e)
	{
		AfxMessageBox(e->m_strError);
		e->Delete();
		pALrs->Close();
	}
}
Beispiel #16
0
void CActivityView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
bool bInserting = false;
POSITION pos;
int nDocCount;
CListCtrl & pList = GetListCtrl ();

// if we don't want list updated right now, then exit

  if (m_bUpdateLockout)
    return;

//  TRACE ("Activity window being updated\n");

  m_bUpdateLockout = TRUE;

  App.m_bUpdateActivity = FALSE;

  App.m_timeLastActivityUpdate = CTime::GetCurrentTime();

// if the list has the same number of worlds (and they are the same
// worlds), then we can not bother deleting the list and re-adding it

// first, count worlds

 	pos = App.m_pWorldDocTemplate->GetFirstDocPosition();
  for (nDocCount = 0; pos; nDocCount++)
       App.m_pWorldDocTemplate->GetNextDoc(pos);

// if count is the same, check world is the same as in the list

  if (nDocCount == pList.GetItemCount ())
    {
   	pos = App.m_pWorldDocTemplate->GetFirstDocPosition();
    while (pos)
      {
       CMUSHclientDoc* pDoc = (CMUSHclientDoc*) App.m_pWorldDocTemplate->GetNextDoc(pos);
       int nItem = pDoc->m_view_number - 1;
       if (nItem < 0)
         {
         bInserting = true;
         break;
         }
       if ((DWORD) pDoc != pList.GetItemData (nItem))
         {
         bInserting = true;
         break;
         }
      }   // end of looping through each world
    }     // end of world count being same as list count
  else
    bInserting = true;    // different counts, must re-do list

  if (bInserting)
    pList.DeleteAllItems ();

// add all documents to the list

 	pos = App.m_pWorldDocTemplate->GetFirstDocPosition();

	for (int nItem = 0; pos != NULL; nItem++)
	{
    CMUSHclientDoc* pDoc = (CMUSHclientDoc*) App.m_pWorldDocTemplate->GetNextDoc(pos);

    if (bInserting)
      pDoc->m_view_number = nItem + 1;    // so we can use Ctrl+1 etc.
    else
      nItem = pDoc->m_view_number - 1;    // use existing item number

    CString strSeq;
    CString strLines;
    CString strNewLines;
    CString strStatus;
    CString strSince;
    CString strDuration;

    strSeq.Format   ("%ld", pDoc->m_view_number);
    strNewLines.Format ("%ld", pDoc->m_new_lines);
    strLines.Format ("%ld", pDoc->m_total_lines);

// work out world status

    strStatus = GetConnectionStatus (pDoc->m_iConnectPhase);

// when they connected

    if (pDoc->m_iConnectPhase == eConnectConnectedToMud)
      strSince = pDoc->FormatTime (pDoc->m_tConnectTime, "%#I:%M %p, %d %b");
    else
      strSince.Empty ();

// work out world connection duration

    // first time spent in previous connections
    CTimeSpan ts = pDoc->m_tsConnectDuration;
    
    // now time spent connected in this session, if we are connected
    if (pDoc->m_iConnectPhase == eConnectConnectedToMud)
      ts += CTime::GetCurrentTime() - pDoc->m_tConnectTime;
  
    if (ts.GetDays () > 0)
      strDuration = ts.Format ("%Dd %Hh %Mm %Ss");
    else
      if (ts.GetHours () > 0)
        strDuration = ts.Format ("%Hh %Mm %Ss");
      else
        if (ts.GetMinutes () > 0)
          strDuration = ts.Format ("%Mm %Ss");
        else
          strDuration = ts.Format ("%Ss");
	
    // sequence
    if (bInserting)
      pList.InsertItem (nItem, strSeq);  //  eColumnSeq
	  pList.SetItemText(nItem, eColumnMush, pDoc->m_mush_name);
		pList.SetItemText(nItem, eColumnNew, strNewLines);
 		pList.SetItemText(nItem, eColumnLines, strLines);
  	pList.SetItemText(nItem, eColumnStatus, strStatus);
		pList.SetItemText(nItem, eColumnSince, strSince);
		pList.SetItemText(nItem, eColumnDuration, strDuration);

    if (bInserting)
      pList.SetItemData(nItem, (DWORD) pDoc);

    LVITEM lvitem;

    memset (&lvitem, 0, sizeof lvitem);

    // update where tick goes
    lvitem.iImage = 0;
    
    if (pDoc->m_pActiveCommandView || pDoc->m_pActiveOutputView)
      lvitem.iImage = 1;  // show the tick

    lvitem.mask = LVIF_IMAGE;
    lvitem.iItem = nItem;

    pList.SetItem (&lvitem);



   }    // end of searching for all documents

// make sure in same order that we left them

  pList.SortItems (CompareFunc, m_reverse << 8 | m_last_col); 

  m_bUpdateLockout = FALSE;

}     // end of CActivityView::OnUpdate
Beispiel #17
0
void COscillogram::DrawGrid(CDC *dc)
{
	//_DrawGrid(dc);

	CString tempStr;
	CSize	tempSzie;
	int		tempPos;
	CFont	m_cFont, *oldFont;
	CPen	pen(PS_SOLID,6,m_GridColor);

	m_cFont.CreatePointFont(260,"宋体");//"Arial");
	oldFont = dc->SelectObject(&m_cFont);
	dc->SelectObject(&pen);
	dc->SetTextColor(m_xyTextColor);

	float m_xTemp = (float)m_GridRect.Width() / (m_xShowCount-1);
	float m_yTemp = (float)m_GridRect.Height() / (m_yShowCount-1);
	CTimeSpan m_xTimeSpan = 0;

	if(m_showTime)
	{
		CTimeSpan sc    = m_endTime - m_beginTime;

		double secCount = (sc.GetDays()*86400) + (sc.GetHours()*3600) + 
						  (sc.GetMinutes()*60) + sc.GetSeconds();
		secCount = secCount / (m_xShowCount-1);

		int day    = (int)secCount/86400;	//天
		secCount  -= day*86400;
		int hour   = (int)secCount/3600;	//小时
		secCount  -= hour*3600;
		int minute = (int)secCount/60;		//分钟
		secCount  -= minute*60;
		int second = (int)secCount;			//秒

		m_xTimeSpan = CTimeSpan(day,hour,minute,second);
	}
	
	for(int i=0;i<m_xShowCount;i++)
	{
		tempPos =   m_GridRect.left + (int)(m_xTemp*i);
		
		DotLine(dc, tempPos, 
			        m_GridRect.top ,
				    tempPos , 
				    m_GridRect.bottom ,
				    m_GridColor );
		
		if(!m_showTime)
			tempStr.Format("%.2f", 
					(m_xMaxVal-m_xMinVal)/(m_xShowCount-1) 
					* i	+ m_xMinVal );
		else
		{
			CTime cnTime = m_beginTime;;

			for(int j=0;j<i;j++)
				cnTime += m_xTimeSpan;

			tempStr = cnTime.Format("%H:%M:%S");//%Y/%m/%d 
		}

		tempSzie =  dc->GetTextExtent(tempStr);
		dc->TextOut(tempPos - tempSzie.cx/2 , 
					m_GridRect.bottom - 15 ,
					tempStr );
	}

	for(int j=0;j<m_yShowCount;j++)
	{
		tempPos = m_GridRect.top + (int)(m_yTemp*j);

		DotLine(dc, m_GridRect.left , 
			        tempPos ,
				    m_GridRect.right ,
				    tempPos ,
				    m_GridColor );
	
		tempStr.Format("%.2f",
					(m_yMaxVal-m_yMinVal)/(m_yShowCount-1)
					* (m_yShowCount-1-j) + m_yMinVal );

		tempSzie =  dc->GetTextExtent(tempStr);

		dc->TextOut(m_GridRect.left - tempSzie.cx-15 , 
					tempPos + tempSzie.cy/2 ,
					tempStr );
	}
	
	//X轴文本
	tempSzie = dc->GetTextExtent(m_xText);
	dc->TextOut(m_GridRect.right + 15,m_GridRect.bottom + tempSzie.cy/2,m_xText);
	//Y轴文本
	tempSzie = dc->GetTextExtent(m_yText);
	dc->TextOut(m_GridRect.left - tempSzie.cx/2,m_GridRect.top + tempSzie.cy + 15,m_yText);

	//XY轴线
	dc->MoveTo(m_GridRect.left,m_GridRect.top);
	dc->LineTo(m_GridRect.left,m_GridRect.bottom);
	dc->MoveTo(m_GridRect.left,m_GridRect.bottom);
	dc->LineTo(m_GridRect.right,m_GridRect.bottom);
	//上面小三角
	int i;
	for(i=1;i<12;i++)
	{
		dc->MoveTo(m_GridRect.left-i-3,m_GridRect.top-i);
		dc->LineTo(m_GridRect.left+i-3,m_GridRect.top-i);
	}
	//上面小三角
	for(i=1;i<12;i++)
	{
		dc->MoveTo(m_GridRect.right-i,m_GridRect.bottom-i);
		dc->LineTo(m_GridRect.right-i,m_GridRect.bottom+i);
	}
	
	dc->SelectObject(oldFont);
}
Beispiel #18
0
void CDlgSetStockAndTime::OnOK() 
{
	// TODO: Add extra validation here
	
	if( m_curSelStockCondition != NULL )
	{
		// 日期范围
		
		// 计算终止日期
		CString str;
		CTime timeEnd;
		if (m_curSelStockCondition->m_dStyle & SelectStock_HisDate)
		{
			m_wndEndDate.GetTime( timeEnd );
			str.Format("%04d%02d%02d",timeEnd.GetYear(),timeEnd.GetMonth(),timeEnd.GetDay());
		}
		else//yulx add 20091207
		{
			SYSTEMTIME   tm;
			GetLocalTime(&tm);
			str.Format("%04d%02d%02d",tm.wYear,tm.wMonth,tm.wDay);
		}
		
		m_curSelStockCondition->m_lEndDate = atol(str);   

		// 计算日期长度
		if( m_curSelStockCondition->m_dStyle & SelectStock_HisDate )
		{
			CTime timeBegin;
			m_wndBeginDate.GetTime( timeBegin );
			CTimeSpan nSpan = timeEnd - timeBegin;

			if( (nSpan.GetDays() + 1) <= 0 )
			{
				//AfxMessageBox(CDlgSetStockAndTime_Begin_End_Date_Error);
				MessageBox(CDlgSetStockAndTime_Begin_End_Date_Error,_T(" 提示 "), MB_OK);
				m_wndBeginDate.SetFocus();
				return;
			}

			str.Format("%04d%02d%02d",timeBegin.GetYear(),timeBegin.GetMonth(),timeBegin.GetDay());
			m_curSelStockCondition->m_lDateCount = atol(str);//nSpan.GetDays();
		}
		else
		{
			m_curSelStockCondition->m_lDateCount = 0;
		}
	}

	// save - begin
	CWinApp* pApp = AfxGetApp();

	// 时间
	CString str;
	if( m_curSelStockCondition )
	{
		str.Format("%i;%i",m_curSelStockCondition->m_lDateCount,m_curSelStockCondition->m_lEndDate);
	}
	pApp->WriteProfileString(CDlgSetStockAndTime_Section,
		CDlgSetStockAndTime_Time,str);

	// 股票范围
	str = "";
	CString strTemp;
	StockArea* pCheckData;
	for( int i = 0; m_ayCheck && i < m_ayCheck->GetSize(); i++ )
	{
		pCheckData = m_ayCheck->GetAt(i);
		strTemp.Format("%i,%s",pCheckData->lData,pCheckData->strText);

		str += strTemp;
		str += ";";
	}
	pApp->WriteProfileString(CDlgSetStockAndTime_Section,
		CDlgSetStockAndTime_Stock,str);

	// 选项
	if( m_curSelStockCondition )
	{
		pApp->WriteProfileInt(CDlgSetStockAndTime_Section,
			CDlgSetStockAndTime_Option,m_curSelStockCondition->m_dStyle);
	}
	// save - end

	CDialog::OnOK();
}
Beispiel #19
0
void COscillogram::OnMouseMove(UINT nFlags, CPoint point) 
{
	CStringArray valArray;
	CDWordArray colArray;
	CString     strVal;
	CRect		mRect;
	CClientDC	dc(this);
	float		length;		//鼠标位置绝对象素数
	float		gValue;
	int			oldMode;
	int			curCell;	//所在单元格
	CPen pen(PS_SOLID,0,RGB(0,0,0));
	BOOL		PtState = FALSE;

	//(整个函数过程的功能)计算所有线所在单元格的数值
	oldMode = dc.SetMapMode(MM_LOMETRIC);
	SetOscillogramRect(&dc);
	dc.SelectObject(&pen);
	dc.SetROP2(R2_NOTXORPEN);
	dc.DPtoLP(&point);

	//如果 鼠标不在波形图内 或者 没有曲线 不做处理返回
	if(!(point.x >= m_GridRect.left  && point.x <= m_GridRect.right+3
		&& point.y <= m_GridRect.top && point.y >= m_GridRect.bottom)
		|| GetCurveCount() < 1 || m_showTitle == FALSE)
	{
		if(m_bPt.x != -1)
		{
			DrawMouseLine(&dc,m_bPt);
			m_bPt =-1;
		}
		m_TitleTip.ShowWindow(SW_HIDE);
		return;
	}
	
	//绘画跟随鼠标的十字线
	if(m_bPt.x == -1)
	{
		m_bPt = point;
		DrawMouseLine(&dc,point);
	}
	else
	{	
		DrawMouseLine(&dc,m_bPt);
		m_bPt = point;
		DrawMouseLine(&dc,point);
	}

	//计算个单元格数值
	length  = (float)( point.x - m_GridRect.left );
	curCell = (int)( length / m_xSpan );
	
	if(!m_showTime)
	{
		float n1 = (m_xMaxVal - m_xMinVal)/(m_xCount-1);
		float n2 = m_xMinVal + curCell*n1;
		strVal.Format("%s: %.2f",m_xText,n2);
	}
	else
	{
		CTimeSpan m_xTimeSpan = 0;
		CTimeSpan sc    = m_endTime - m_beginTime;
		CTime	cnTime  = m_beginTime;
		
		double secCount = (sc.GetDays()*86400) + (sc.GetHours()*3600) + 
			(sc.GetMinutes()*60) + sc.GetSeconds();
		secCount = secCount / (m_xCount-1);
		
		int day    = (int)secCount/86400;	//天
		secCount  -= day*86400;
		int hour   = (int)secCount/3600;	//小时
		secCount  -= hour*3600;
		int minute = (int)secCount/60;		//分钟
		secCount  -= minute*60;
		int second = (int)secCount;			//秒
		m_xTimeSpan = CTimeSpan(day,hour,minute,second);

		for(int j=0;j<curCell;j++)
			cnTime += m_xTimeSpan;
		strVal.Format("%s: %s",m_xText,cnTime.Format("%Y/%m/%d  %H:%M:%S"));
	}
	colArray.Add(RGB(0,0,0));
	valArray.Add(strVal);

	for(int i=0;i<GetCurveCount();i++)
	{
		gValue = GetCurve(i)->ptVal.GetPointValue(curCell,PtState);
		
		if(PtState)
			strVal.Format("%s: %.2f",GetCurveName(i),gValue);
		else
			strVal.Format("%s: ",GetCurveName(i));
		colArray.Add(GetCurve(i)->lColor);
		valArray.Add(strVal);
	}

	//显示浮动窗体
	dc.LPtoDP(&point);
	dc.SetMapMode(oldMode);

	//窗口跟随鼠标位置移动
	GetClientRect(mRect);
	mRect.left   += CS_LMARGIN;
	mRect.top    += CS_LMARGIN;
	mRect.right  -= CS_LMARGIN;
	mRect.bottom -= CS_LMARGIN;
	ClientToScreen(&point);
	ClientToScreen(&mRect);

	m_TitleTip.SetParentRect(mRect);
	m_TitleTip.SetStrArray(valArray,colArray);
	m_TitleTip.SetPos(&point);
	ScreenToClient(&point);
	
	CWnd::OnMouseMove(nFlags, point);
}
Beispiel #20
0
void CBook::OnBnClickedBookBook()
{
	// TODO: 在此添加控件通知处理程序代码
	char in[10000];
	CString note, num;
	string which;

	if (info.user == 'c')
		GetDlgItemText(IDC_BOOK_NUM, num);
	else
		num = "1";

	if (num == "")
	{
		MessageBox(L"还未填写需要机票数", L"ERROR!", MB_OK | MB_ICONWARNING);
		return;
	}

	if (num > m_list.GetItemText(row, tickets - 1))
	{
		MessageBox(L"超出能预定的张数", L"ERROR!", MB_OK | MB_ICONWARNING);
		return;
	}

	if (tickets == 4)
		which = "Business";
	else
		which = "Normal";

	GetDlgItemText(IDC_BOOK_SHOW, note);
	if (MessageBox(L"即将预定 " + num + L"枚 " +  note, L"Option", MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL)
		return;

	ClientSocket *client = new ClientSocket;
	Deal *deal = new Deal;
	string str;
	CTime now = CTime::GetCurrentTime();

	DWORD dwNum = WideCharToMultiByte(CP_OEMCP, NULL, note, -1, NULL, NULL, 0, NULL);
	char *infor = new char[dwNum];
	WideCharToMultiByte(CP_OEMCP, NULL, note, -1, infor, dwNum, 0, NULL);

	dwNum = WideCharToMultiByte(CP_OEMCP, NULL, num, -1, NULL, NULL, 0, NULL);
	char *n = new char[dwNum];
	WideCharToMultiByte(CP_OEMCP, NULL, num, -1, n, dwNum, 0, NULL);

	dwNum = WideCharToMultiByte(CP_OEMCP, NULL, m_list.GetItemText(row, 1), -1, NULL, NULL, 0, NULL);
	char *tm = new char[dwNum];
	WideCharToMultiByte(CP_OEMCP, NULL, m_list.GetItemText(row, 1), -1, tm, dwNum, 0, NULL);
	str = tm;

	//int year, mon, day, hour, min, sec;
	//year = strtol(str.substr(0, 4).c_str(), NULL, 10);
	CTime setoff(strtol(str.substr(0, 4).c_str(), NULL, 10), strtol(str.substr(5, 2).c_str(), NULL, 10) + 1, strtol(str.substr(8, 2).c_str(), NULL, 10), 0, 0, 0);
	CTimeSpan span = setoff - now;

	str = infor;
	if (info.user != 'c')
		sprintf(in, "1;s;select Pos from GiveUp where Num = '%s';", str.substr(0, 3).c_str());
	else
		sprintf(in, "2;c;%s;u;update RealNum set %s = %s - %d where Num = '%s';",
			str.substr(0, 3).c_str(), which.c_str(), which.c_str(), atoi(n), str.substr(0, 3).c_str());
	str = in;

	try
	{
		client->init();
		client->Connect();
		client->Send(deal->RepaceSpace(str));
		str = client->Recv();
		client->closeclient();
	}
	catch (SocketFail e)
	{
		delete deal;
		delete client;
		MessageBox(L"网络连接错误,预定失败", L"ERROR!", MB_OK | MB_ICONWARNING);
		return;
	}

	if (str == "Fail")
	{
		delete deal;
		delete client;
		MessageBox(L"预定失败", L"ERROR!", MB_OK | MB_ICONWARNING);
		return;
	}

	span.GetDays();

	if (str != "")
	{//表明有,已被退回的位置
		int pos;
		if ((pos = str.find("|")) == str.npos)
			pos = str.find(";");

		string Num(infor, 3);

		sprintf(in, "2;d;delete from GiveUp where Num = '%s' and Pos = '%s';u;update RealNum set %s = %s + 1 where Num = '%s';",
					Num.c_str(), str.substr(0, pos).c_str(), which.c_str(), which.c_str(), Num.c_str());
		str = in;
	}
	else
	{
		str = infor;
		sprintf(in, "3;b;%s|%.2d;i;insert into Tickets values('&r', '%s', 0, %s);u;update RealNum set %s = %s + 1 where Num = '%s';",
					str.substr(0, 3).c_str(), (int)span.GetDays(), info.id.c_str(), str.substr(str.find("¥") + 2).c_str(), 
					which.c_str(), which.c_str(), str.substr(0, 3).c_str());
		str = in;
	}

	try
	{
		client->init();
		client->Connect();
		client->Send(deal->RepaceSpace(str));
		str = client->Recv();
		client->closeclient();
	}
	catch (SocketFail e)
	{
		delete deal;
		delete client;
		MessageBox(L"网络连接错误,预定失败", L"ERROR!", MB_OK | MB_ICONWARNING);
		return;
	}

	if (str.substr(str.find("|") + 1, 2) == "OK")
	{
		CString t;
		t = str.substr(0, 18).c_str();
		MessageBox(L"票号为 " + t, L"预定成功\n票号已复制到剪贴板", MB_OK | MB_ICONASTERISK);

		if (OpenClipboard())
		{
			HGLOBAL clipbuffer;
			char   *buffer;
			EmptyClipboard();
			clipbuffer = GlobalAlloc(GMEM_DDESHARE, str.substr(0, 18).size() + 1);
			buffer = (char*)GlobalLock(clipbuffer);
			strcpy(buffer, LPCSTR(str.substr(0, 18).c_str()));
			GlobalUnlock(clipbuffer);
			SetClipboardData(CF_TEXT, clipbuffer);
			CloseClipboard();
		}
	}
	else
		MessageBox(L"预定失败", L"ERROR!", MB_OK | MB_ICONWARNING);

	delete deal;
	delete client;
}
Beispiel #21
0
unsigned long GetLimitDate(CodeInfo *pCode,short nPeriod,int nDays)
{
	static int min1_download_limit_day = 0;
	static int min5_download_limit_day = 0;

	if(min1_download_limit_day == 0 || min5_download_limit_day == 0) 
	{
		CString strConfigFile = CGeneralHelper::GetSpecifyPath(CGeneralHelper::SETTING_PATH) + "sysconfig.ini";
		min1_download_limit_day = ::GetPrivateProfileInt("data_download","min1_download_limit_day",33000,strConfigFile);
		min5_download_limit_day = ::GetPrivateProfileInt("data_download","min15_download_limit_day",33000,strConfigFile);

	}

	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;
		}
	}

	CTime tm20(2000,1,5,0,0,0);
	CTime t = GetNowTime(nPeriod);
	CTimeSpan tmSpan = t - tm20;
	long lCurTime = t.GetYear()*10000 + t.GetMonth()*100 + t.GetDay();
	long nLimitedTime = 0;
	switch(nPeriod)
	{
	case PERIOD_TYPE_DAY:
		{
			if (nDays == 0)
				nLimitedTime =  19900101;
			else
			{
				CTimeSpan tSpanDay(nDays,0,0,0);
				nLimitedTime = GetIntTimeFromTime(t - tSpanDay,nPeriod);
			}
			break;
		}	
	case PERIOD_TYPE_MINUTE5:
		{
			int nLimit = 10;
			if (nDays != 0)
				nLimit = nDays < min5_download_limit_day ? nDays : min5_download_limit_day;
			else
				nLimit = tmSpan.GetDays();

			CTimeSpan tSpan5(nLimit,0,0,0);
			CTime nLimitTm = t - tSpan5;
			nLimitedTime = nBegin5min+ nLimitTm.GetDay()* 10000 + nLimitTm.GetMonth() * 1000000 + (nLimitTm.GetYear() - 1990)* 100000000;
			//nLimitedTime =  GetIntTimeFromTime(t - tSpan5,nPeriod);
			break;
		}
	case PERIOD_TYPE_MINUTE1:
		{
			int nLimit = 10;
			if (nDays != 0)
				nLimit = nDays < min1_download_limit_day ? nDays : min1_download_limit_day;
			else
				nLimit = tmSpan.GetDays();

			CTimeSpan tSpan1(nLimit,0,0,0);
			CTime nLimitTm = t - tSpan1;
			nLimitedTime = nBeing1min + nLimitTm.GetDay()* 10000 + nLimitTm.GetMonth() * 1000000 + (nLimitTm.GetYear() - 1990)* 100000000;
			break;
		}
	}
	return nLimitedTime;
}
Beispiel #22
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
#ifdef __EXPIRATION__
	// Program Expiration routines
	CTime expirationTime(2010,	// year
		2,					// month
		30,					// date
		23,					// hour 24
		59,					// minute
		59);				// second
	CTime currentTime = CTime::GetCurrentTime();

    CTimeSpan leftTime = expirationTime - currentTime;   

	// 사용 기간이 남았을 경우
	if(leftTime.GetTotalSeconds() > 0)
    {
		 CString msg;
		 msg = L"";
		 msg += L"This is a trial version of BTools2\n";
		 msg += expirationTime.Format(L"Expiration date :\n %Y-%m-%d  %H:%M:%S\n\n");
		 msg += leftTime.Format(L"%D day(s) and\n %H:%M:%S left" );
     
		 // 사용 기간이 3일 미만 남았을 경우
		 if(leftTime.GetDays() < 7)
		 {
			 msg = leftTime.Format(L"This software will expire after %D day(s)");// %H Hour(s) %M Minute(s)");
			 //AtlMessageBox(NULL, msg.GetBuffer(), L"Expiration Warning");
		 }
		 //AfxMessageBox(msg);
    }
    else // 사용 기간이 만료된 경우
    {
		CString msg("This is a trial version of BTools2\n"
				"If you want to use this software more\n"
				"Please contact to me.\[email protected]\n"
				"Thank you for your interest\n");

		msg += expirationTime.Format(L"Expiration date :\n %Y-%m-%d  %H:%M\n\n");
		msg += leftTime.Format(L"%D day(s) and\n %H:%M:%S passed" );
        //msg.Format(L"This software is submitted for the Windows Mobile Contest");
		//AtlMessageBox(NULL, msg.GetBuffer(), L"Warning");
		return FALSE;
	 }

#endif

#ifdef __TSTORE_ARM__0
	// ARM
	T_RETURN ret;
	TAPPID *APPID = TSTORE_APPLICATION_ID;

	bool aSuccess=true;

	T_RETURN res; 
	ARM_PLUGIN_Initialize(&res,APPID);
	if (res.code == ARM_SUCCESS) 
	{
		ARM_PLUGIN_CheckLicense(&res); 
		if (res.code == ARM_SUCCESS) 
		{ 
			ARM_PLUGIN_RequestLicense(&res); 
			if (res.code !=ARM_SUCCESS) 
			{ //실패시 구현 
				aSuccess=false;
				TCHAR wszMsg[1024];
				if(ret.pMsg)
				{
					ansi_to_unicode(ret.pMsg, strlen(ret.pMsg), wszMsg, 1024);
					::AtlMessageBox(NULL, wszMsg, L"[ARM]Request License");
				}
			}
		
		} 
		else 
		{//실패시 메시 구현 
			aSuccess=false;

			TCHAR wszMsg[1024];

			switch(res.code)
			{
			case CLICENSE_DENY:
			case CLICENSE_NOT_EXIST:
			case CLICENSE_EXPIRED:
			case CLICENSE_INVALID:
				{
					if(ret.pMsg)
					{
						ansi_to_unicode(ret.pMsg, strlen(ret.pMsg), wszMsg, 1024);
						::AtlMessageBox(NULL, wszMsg, L"[ARM]Check License");
					}
				}

			default:
				;
			}
		} 
	} 
	else 
	{ 
		aSuccess=false; 
	} 
	ARM_PLUGIN_Uninitialize(&res); 


	//if (! aSuccess) return 0;//PostQuitMessage(0); 

#endif

	//CAboutDlg aboutDlg;	aboutDlg.DoModal();
    //
	HRESULT hRes = CBTools2Frame::ActivatePreviousInstance(hInstance, lpstrCmdLine);

	if(FAILED(hRes) || S_FALSE == hRes)
	{
		return hRes;
	}

	hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
	ATLASSERT(SUCCEEDED(hRes));

	AtlInitCommonControls(ICC_DATE_CLASSES);
	SHInitExtraControls();

	hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));

	int nRet = CBTools2Frame::AppRun(lpstrCmdLine, nCmdShow);

	_Module.Term();
	::CoUninitialize();

	return nRet;
}
Beispiel #23
0
void CWorldSocket::OnClose(int nErrorCode)
  {

bool bWasClosed = m_pDoc->m_iConnectPhase == eConnectNotConnected;

  TRACE1 ("CWorldSocket::OnClose, error code %i\n", nErrorCode);

  m_pDoc->m_iConnectPhase = eConnectDisconnecting;

  m_pDoc->UpdateAllViews (NULL);

  m_pDoc->MXP_Off (true);   // turn off MXP now

  // update button bar - make button red
  if (m_pDoc->m_view_number >= 1 &&
      m_pDoc->m_view_number <= 10)
    Frame.OnUpdateBtnWorlds (m_pDoc->m_view_number, NULL);

  // execute "disconnect" script
  if (m_pDoc->m_ScriptEngine)
    {
    if (m_pDoc->SeeIfHandlerCanExecute (m_pDoc->m_strWorldDisconnect))
      {
      DISPPARAMS params = { NULL, NULL, 0, 0 };
      long nInvocationCount = 0;

      m_pDoc->ExecuteScript (m_pDoc->m_dispidWorldDisconnect,  
                             m_pDoc->m_strWorldDisconnect,
                             eWorldAction,
                             "world disconnect", 
                             "disconnecting from world",
                             params, 
                             nInvocationCount); 
      }
    } // end of executing disconnect script

  m_pDoc->SendToAllPluginCallbacks (ON_PLUGIN_DISCONNECT);

  // close log file if we auto-opened it
  if (!m_pDoc->m_strAutoLogFileName.IsEmpty ())
    m_pDoc->CloseLog ();

  if (m_pDoc->m_bShowConnectDisconnect && !bWasClosed)
    {
    CTime theTime;
    theTime = CTime::GetCurrentTime();

    CString strConnected;
    strConnected = theTime.Format (TranslateTime ("--- Disconnected on %A, %B %d, %Y, %#I:%M %p ---"));

    m_pDoc->Note (strConnected);  

    // find time spent connected
    CTimeSpan ts = CTime::GetCurrentTime() - m_pDoc->m_tConnectTime;
      
    CString strDuration = TFormat ("--- Connected for %i day%s, %i hour%s, %i minute%s, %i second%s. ---",
                  PLURAL ((long) ts.GetDays()),
                  PLURAL ((long) ts.GetHours()),
                  PLURAL ((long) ts.GetMinutes()),
                  PLURAL ((long) ts.GetSeconds()));

    m_pDoc->Note (strDuration);  

    // and a horizontal rule

    m_pDoc->m_pCurrentLine->flags = HORIZ_RULE;  
    m_pDoc->StartNewLine (true, 0); 
    }  // end of message in world window wanted

  CString strInfo = TFormat ("--- Received %i line%s, sent %i line%s.",
                PLURAL (m_pDoc->m_nTotalLinesReceived),
                PLURAL (m_pDoc->m_nTotalLinesSent)
                );
  
  m_pDoc->Note (strInfo);  

  strInfo = TFormat ("--- Output buffer has %i/%i line%s in it (%.1f%% full).",
                m_pDoc->m_LineList.GetCount (),
                m_pDoc->m_maxlines,
                (m_pDoc->m_LineList.GetCount ()) == 1 ? "" : "s",
                (double) m_pDoc->m_LineList.GetCount () / (double) m_pDoc->m_maxlines * 100.0
                );

  m_pDoc->Note (strInfo);  

  strInfo = TFormat ("--- Matched %i trigger%s, %i alias%s, and %i timer%s fired.",
                PLURAL (m_pDoc->m_iTriggersMatchedThisSessionCount),   
                PLURALES (m_pDoc->m_iAliasesMatchedThisSessionCount),    
                PLURAL (m_pDoc->m_iTimersFiredThisSessionCount)       
                );

  m_pDoc->Note (strInfo);  

CString str;

  str = TFormat ("The \"%s\" server has closed the connection", 
              (const char *) m_pDoc->m_mush_name);

  if (App.m_bNotifyOnDisconnect && !m_pDoc->m_bDisconnectOK)
    {
    if (App.m_bErrorNotificationToOutputWindow)
      m_pDoc->Note (str);
    else
      ::UMessageBox (str, MB_ICONEXCLAMATION);
    }
  else
    Frame.SetStatusMessage (str);
  m_pDoc->m_iConnectPhase = eConnectNotConnected;

  m_pDoc->UpdateAllViews  (NULL);     // force window title to be redrawn

  } // end of OnClose