Пример #1
0
SVAPI_API
bool EditTask(OBJECT taskobj,string taskname,string user,string addr)
{
	if(taskobj==INVALID_VALUE)
		return false;
	if(user.empty()||addr.empty())
		return false;

	if(taskname.empty())
		return SubmitTask(taskobj,user,addr);

	try{
		Section *pmtp=reinterpret_cast<Section *>(taskobj);
		if(taskname.compare(pmtp->GetSection().getword())==0)
			return SubmitTask(taskobj,user,addr);
		if(pmtp->Find("$newtaskname3721$"))
			return false;
		if(!pmtp->Push("$newsection3721$",taskname))
			return false;
		S_UINT len=pmtp->GetRawDataSize();
		svutil::buffer buf;
		if(!buf.checksize(len))
		{
			pmtp->Delete("$newsection3721$");
			return false;
		}
		if(pmtp->GetRawData(buf,len)==NULL)
		{
			pmtp->Delete("$newsection3721$");
			return false;
		}

		pmtp->Delete("$newsection3721$");

		SVDBQUERY querybuf={0};
		querybuf.len = sizeof(SVDBQUERY);
		querybuf.querytype=QUERY_EDIT;
		querybuf.datatype=S_TASK;
		strcpy(querybuf.qstr,pmtp->GetSection().getword());
		querybuf.datalen=len;
		strcpy(querybuf.idcuser,user.c_str());

		QueryData qd;
		SVDBRESULT ret={0};
		return qd.Update(&querybuf,buf,len,&ret,addr);
	}catch(...)
	{
		return false;
	}
	return false;

}
Пример #2
0
void CSVAddPlan::Save()
{
	bool bEnd = false;	
	string strUserID = GetWebUserID();

	HitLog LogItem;
	LogItem.sUserName = strUserID;
	LogItem.sHitPro = "Plan Set";
	LogItem.sHitFunc = "Save";
	LogItem.sDesc = szSaveAddInPlan;

	DWORD dcalBegin=GetTickCount();
	InsertHitRecord(LogItem.sUserName, LogItem.sHitPro, LogItem.sHitFunc, LogItem.sDesc, 0, 0);

OPEnd:
	if(bEnd)
	{
		DWORD dcalEnd=GetTickCount();
		InsertHitRecord(LogItem.sUserName, LogItem.sHitPro, LogItem.sHitFunc, LogItem.sDesc, 1, dcalEnd -dcalBegin);
		return;
	}
	
	ADD_PLAN_OK addPlan;
    bool bCheck = 0;

    addPlan.szName = m_pName->text();

	std::list<string> errorMsgList;

	
    if (addPlan.szName.empty())
    {
		errorMsgList.push_back(m_FormShowText.szErrorMsg);
		AddRangeTable->ShowErrorMsg(errorMsgList);
		//m_pPlanNameError->show();
		bEnd = true;	
		goto OPEnd;
    }
	//else
	//{
	//	AddRangeTable -> HideAllErrorMsg();
	//	//m_pPlanNameError-> hide();
	//}

	std::string str1 = m_pTasklist->m_pStart[1]->text();
	//Jansion.zhou 2006-12-25
    //m_pErrMsg->setText("");
    //m_pErrMsg->hide();

    addPlan.nIndex = m_nIndex;

	std::list<string> tasknamelist;
	std::list<string>::iterator m_pItem;
	bool IsSave = false;
	bool IsConn = GetAllTaskName(tasknamelist);
	
	if(IsConn)
	{
		OutputDebugString("----------------isconn true------------------\n");
		for(m_pItem = tasknamelist.begin(); m_pItem != tasknamelist.end(); m_pItem++)
		{
			std::string str = *m_pItem;
			if(strcmp(str.c_str(), addPlan.szName.c_str()) == 0)
			{
				IsSave = true;
				break;
			}
		}
		
		
		if(strcmp(chgstr.c_str(), "") == 0)
		{
			if(!IsSave)
			{
				OutputDebugString("----------------Issave false------------------\n");
				OBJECT hTask = CreateTask(addPlan.szName);
				
				SetTaskValue("Type", m_FormShowText.szPlanTypeRel, hTask);
				char buf[256];
				for(int i = 0; i < 7; i++)
				{

					itoa(i, buf, 10);
					std::string temp = m_pTasklist->m_pStart[i]->text();
					std::string temp1 = "start";
					temp1 += buf;
					SetTaskValue(temp1, temp, hTask);
					
					temp = m_pTasklist->m_pEnd[i]->text();
					temp1 = "end";
					temp1 += buf;
					SetTaskValue(temp1, temp, hTask);
					
					temp1 = "Allow";
					temp1 += buf;

					std::string temp3 = m_pTasklist->m_pCombo[i]->currentText();
					if(strcmp(temp3.c_str(), strAllown.c_str()) == 0)
					{
						SetTaskValue(temp1, m_FormShowText.szStatusAllow, hTask);
					}
					else
					{
						SetTaskValue(temp1, m_FormShowText.szStatusDeny, hTask);
					}
				}
				SetTaskValue("Description", textarea->text(), hTask);
				SubmitTask(hTask);

				//Jansion.zhou 2006-12-25
				//m_pErrMsg->setText("");
				//m_pErrMsg->hide();
				addPlan.nIndex = m_nIndex;

				//插记录到UserOperateLog表
				string strUserID = GetWebUserID();
				TTime mNowTime = TTime::GetCurrentTimeEx();
				OperateLog m_pOperateLog;
				m_pOperateLog.InsertOperateRecord("UserOperateLog",strUserID,mNowTime.Format(),strTypeAdd,strTimeTaskPlan,m_pName->text());

				emit Successful(addPlan);
			}
			else
			{
OutputDebugString("----------------Issave true------------------\n");
				//Jansion.zhou 2006-12-25
				//m_pErrMsg->setText(m_FormShowText.szErrorMsg1);
				//m_pErrMsg->show();

				errorMsgList.push_back(m_FormShowText.szErrorMsg1);
				AddRangeTable->ShowErrorMsg(errorMsgList);
			}
		}
		else
		{

			std::string str;
			for(m_pItem = tasknamelist.begin(); m_pItem != tasknamelist.end(); m_pItem++)
			{
				str = *m_pItem;
				if(strcmp(str.c_str(), addPlan.szName.c_str()) == 0)
				{
					if(strcmp(str.c_str(), chgstr.c_str()) != 0)
					{
						IsSave = true;
						break;
					}
					else
					{				
						IsSave = false;
						break;
					}
				}
			}

			
			if(!IsSave)
			{
				OutputDebugString("----------------Issave00 false------------------\n");
				OBJECT hTask = GetTask(chgstr);
				
				SetTaskValue("Type", m_FormShowText.szPlanTypeRel, hTask);
				char buf[256];
				for(int i = 0; i < 7; i++)
				{
					itoa(i, buf, 10);
					std::string temp = m_pTasklist->m_pStart[i]->text();
					std::string temp1 = "start";
					temp1 += buf;
					SetTaskValue(temp1, temp, hTask);
					
					temp = m_pTasklist->m_pEnd[i]->text();
					temp1 = "end";
					temp1 += buf;
					SetTaskValue(temp1, temp, hTask);

					temp1 = "Allow";
					temp1 += buf;

					std::string temp3 = m_pTasklist->m_pCombo[i]->currentText();
					if(strcmp(temp3.c_str(), strAllown.c_str()) == 0)
					{
						SetTaskValue(temp1, m_FormShowText.szStatusAllow, hTask);
					}
					else
					{
						SetTaskValue(temp1, m_FormShowText.szStatusDeny, hTask);
					}
				}
				SetTaskValue("Description", textarea->text(), hTask);
				EditTask(hTask,addPlan.szName);

				//Jansion.zhou 2006-12-25
				//m_pErrMsg->setText("");
				//m_pErrMsg->hide();

				addPlan.nIndex = m_nIndex;

				//插记录到UserOperateLog表
				string strUserID = GetWebUserID();
				TTime mNowTime = TTime::GetCurrentTimeEx();
				OperateLog m_pOperateLog;
				m_pOperateLog.InsertOperateRecord("UserOperateLog",strUserID,mNowTime.Format(),strTypeEdit,strTimeTaskPlan,m_pName->text());

				chgstr = "";
				emit Successful(addPlan);
			}
			else
			{
				OutputDebugString("----------------Issave000 true------------------\n");
				//Jansion.zhou 2006-12-25
				//m_pErrMsg->setText(m_FormShowText.szErrorMsg1);
				//m_pErrMsg->show();

				errorMsgList.push_back(m_FormShowText.szErrorMsg1);
				AddRangeTable->ShowErrorMsg(errorMsgList);
			}
		}
	}
	else
	{

	}

	DWORD dcalEnd1=GetTickCount();
	InsertHitRecord(LogItem.sUserName, LogItem.sHitPro, LogItem.sHitFunc, LogItem.sDesc, 1, dcalEnd1 - dcalBegin);
}