Example #1
0
void CMsgCallBack<transMsg::QUploadRes>::_Process( transMsg::QUploadRes& msg, uint64_t recvID, const mori::RecvFileList& files, SUserInfo& userInfo, soci::session& sql, SSendInfoSPtr& sendInfoPtr )
{
	auto retMsg = smartPtr::make_shared<transMsg::AUploadRes>();
	auto& retInfo = sendInfoPtr->Add();
	retInfo.MsgPtr_ = retMsg;
	retMsg->set_stats(transMsg::ERS_SERVER_ERROR);

	typedef	std::unordered_map<AStringType,mori::FilePath>	AddList;
	AddList	toAddList;

	if ( msg.fileshash_size() != files.size() )
	{
		ProcessorCommon::RemoveFiles(files);

		retMsg->set_stats(transMsg::ERS_WRONG_FILE);
		return;
	}

	try
	{
		std::unordered_set<AStringType> neededFiles;

		//查找缺失文件
		//********************************************************************************************************************	
		{
			std::vector<AStringType> tmp;

			SociAdaptor(Statement()
				.Select(SV_LibFileInfo("TmpTb").HashCode.Into(tmp))
				.From(Statement()
					.Select(JK_ResourceInfo.HASHCode)
					.From(JK_ResourceInfo)
					.Where(JK_ResourceInfo.HASHCode!="" && JK_ResourceInfo.FactoryID==*userInfo.UserInfo_.FactoryID_)
					.Union(Statement()
					.Select(JK_ModelInfo.HASHCode)
					.From(JK_ModelInfo)
					.Where(JK_ModelInfo.HASHCode!="" && JK_ModelInfo.FactoryID==*userInfo.UserInfo_.FactoryID_)),"TmpTb")
				.Where(SV_LibFileInfo("TmpTb").HashCode.NotIn(Statement()
					.Select(SV_LibFileInfo.HashCode)
					.From(SV_LibFileInfo)
					.Where(SV_LibFileInfo.DeptID==*userInfo.UserInfo_.FactoryID_ && SV_LibFileInfo.HashCode!="").GetString())), sql).Excute();

			std::copy(tmp.begin(), tmp.end(), std::inserter(neededFiles, neededFiles.end()));
		}
		//********************************************************************************************************************

		//检验文件
		//********************************************************************************************************************
		for ( auto i=0; i<msg.fileshash_size(); ++i )
		{
			const auto& curFileHash = msg.fileshash(i);
			const auto& curFilePath = files[i];
			ErrCodeType ec;

			if ( curFilePath.ChkFaild_ )
			{
				retMsg->add_lostfiles(curFileHash);

				ProcessorCommon::RemoveFile(curFilePath.Path_);
				continue;				
			}
			
			if ( neededFiles.end() == neededFiles.find(curFileHash) )
			{
				retMsg->add_rejectedfiles(curFileHash);

				ProcessorCommon::RemoveFile(curFilePath.Path_);
				continue;
			}
			
			auto newPt = MoveResFile(*userInfo.UserInfo_.FactoryID_, curFilePath.Path_, curFileHash, ec);
			if ( !ec )
			{
				toAddList.insert(std::make_pair(curFileHash,newPt));
			}
			else
			{
				LOG_INFO << ec << L", " << curFilePath.Path_;
			}
		}
		//********************************************************************************************************************


		//添加文件
		//********************************************************************************************************************
		{
			soci::transaction trans(sql);

			SV_LibFileInfo_Data info;
			info.DeptID_ = userInfo.UserInfo_.FactoryID_;
			info.DestPath_.reset(boost::initialized_value);
			info.HashCode_.reset(boost::initialized_value);

			SociAdaptor ada(Statement().Insert(SV_LibFileInfo.Use(info)), sql);
			
			for ( auto& perFile : toAddList )
			{
				info.DestPath_ = std::move(perFile.second.string());
				info.HashCode_ = perFile.first;

				ada.Excute();
			}

			trans.commit();
		}
		//********************************************************************************************************************

		//更新状态
		//********************************************************************************************************************
		{
			std::vector<int64_t>	toUpdateCodes;
			{
				SociAdaptor(Statement()
					.Select(GL_SugarVerInfo.VerCode.Into(toUpdateCodes))
					.From(GL_SugarVerInfo)
					.Where(GL_SugarVerInfo.UploadStatus!=DBValue::UploadStatus::Done &&
							GL_SugarVerInfo.DeptID==*userInfo.UserInfo_.FactoryID_ &&
							GL_SugarVerInfo.VerCode.NotIn(Statement()
													.Select(JK_ResourceInfo.VerCode)
													.From(JK_ResourceInfo)
													.InnerJoin(GL_SugarVerInfo).On(JK_ResourceInfo.VerCode==GL_SugarVerInfo.VerCode)
													.Where(GL_SugarVerInfo.UploadStatus!=DBValue::UploadStatus::Done &&
															JK_ResourceInfo.HASHCode!="" &&
															JK_ResourceInfo.HASHCode.NotIn(Statement()
																							.Select(SV_LibFileInfo.HashCode)
																							.From(SV_LibFileInfo)
																							.Where(SV_LibFileInfo.DeptID==*userInfo.UserInfo_.FactoryID_).GetString()))
													.Union(Statement()
													.Select(JK_ModelInfo.VerCode)
													.From(JK_ModelInfo)
													.InnerJoin(GL_SugarVerInfo).On(JK_ModelInfo.VerCode==GL_SugarVerInfo.VerCode)
													.Where(GL_SugarVerInfo.UploadStatus!=DBValue::UploadStatus::Done &&
															JK_ModelInfo.HASHCode!="" &&
															JK_ModelInfo.HASHCode.NotIn(Statement()
																						.Select(SV_LibFileInfo.HashCode)
																						.From(SV_LibFileInfo)
																						.Where(SV_LibFileInfo.DeptID==*userInfo.UserInfo_.FactoryID_).GetString()))
															).GetString()
															)
							), sql).Excute();
			}

			if ( toUpdateCodes.empty() )
			{
				retMsg->set_stats(transMsg::ERS_SUCCESS);
				return;
			}

			SociAdaptor(Statement()
				.Update(GL_SugarVerInfo.UploadStatus.Use(DBValue::UploadStatus::Done))
				.Where(GL_SugarVerInfo.VerCode.In(toUpdateCodes.begin(), toUpdateCodes.end())), sql).Excute();

			retMsg->set_stats(transMsg::ERS_SUCCESS);
		}
		//********************************************************************************************************************
	}
	catch (soci::soci_error& err)
	{
		for ( auto& perFile : toAddList )
		{
			ProcessorCommon::RemoveFile(perFile.second);
		}

		retMsg->set_stats(transMsg::ERS_SERVER_ERROR);

		LOG_ERROR << DataBase::GetSociErrorString(err) << userInfo.RemoteEP_;
	}
	
}
Example #2
0
bool SkBlurMask::BlurRect(SkScalar sigma, SkMask *dst,
                          const SkRect &src, SkBlurStyle style,
                          SkIPoint *margin, SkMask::CreateMode createMode) {
    int profile_size = SkScalarCeilToInt(6*sigma);

    int pad = profile_size/2;
    if (margin) {
        margin->set( pad, pad );
    }

    dst->fBounds.set(SkScalarRoundToInt(src.fLeft - pad),
                     SkScalarRoundToInt(src.fTop - pad),
                     SkScalarRoundToInt(src.fRight + pad),
                     SkScalarRoundToInt(src.fBottom + pad));

    dst->fRowBytes = dst->fBounds.width();
    dst->fFormat = SkMask::kA8_Format;
    dst->fImage = NULL;

    int             sw = SkScalarFloorToInt(src.width());
    int             sh = SkScalarFloorToInt(src.height());

    if (createMode == SkMask::kJustComputeBounds_CreateMode) {
        if (style == kInner_SkBlurStyle) {
            dst->fBounds.set(SkScalarRoundToInt(src.fLeft),
                             SkScalarRoundToInt(src.fTop),
                             SkScalarRoundToInt(src.fRight),
                             SkScalarRoundToInt(src.fBottom)); // restore trimmed bounds
            dst->fRowBytes = sw;
        }
        return true;
    }
    uint8_t *profile = NULL;

    ComputeBlurProfile(sigma, &profile);
    SkAutoTDeleteArray<uint8_t> ada(profile);

    size_t dstSize = dst->computeImageSize();
    if (0 == dstSize) {
        return false;   // too big to allocate, abort
    }

    uint8_t*        dp = SkMask::AllocImage(dstSize);

    dst->fImage = dp;

    int dstHeight = dst->fBounds.height();
    int dstWidth = dst->fBounds.width();

    uint8_t *outptr = dp;

    SkAutoTMalloc<uint8_t> horizontalScanline(dstWidth);
    SkAutoTMalloc<uint8_t> verticalScanline(dstHeight);

    ComputeBlurredScanline(horizontalScanline, profile, dstWidth, sigma);
    ComputeBlurredScanline(verticalScanline, profile, dstHeight, sigma);

    for (int y = 0 ; y < dstHeight ; ++y) {
        for (int x = 0 ; x < dstWidth ; x++) {
            unsigned int maskval = SkMulDiv255Round(horizontalScanline[x], verticalScanline[y]);
            *(outptr++) = maskval;
        }
    }

    if (style == kInner_SkBlurStyle) {
        // now we allocate the "real" dst, mirror the size of src
        size_t srcSize = (size_t)(src.width() * src.height());
        if (0 == srcSize) {
            return false;   // too big to allocate, abort
        }
        dst->fImage = SkMask::AllocImage(srcSize);
        for (int y = 0 ; y < sh ; y++) {
            uint8_t *blur_scanline = dp + (y+pad)*dstWidth + pad;
            uint8_t *inner_scanline = dst->fImage + y*sw;
            memcpy(inner_scanline, blur_scanline, sw);
        }
        SkMask::FreeImage(dp);

        dst->fBounds.set(SkScalarRoundToInt(src.fLeft),
                         SkScalarRoundToInt(src.fTop),
                         SkScalarRoundToInt(src.fRight),
                         SkScalarRoundToInt(src.fBottom)); // restore trimmed bounds
        dst->fRowBytes = sw;

    } else if (style == kOuter_SkBlurStyle) {
        for (int y = pad ; y < dstHeight-pad ; y++) {
            uint8_t *dst_scanline = dp + y*dstWidth + pad;
            memset(dst_scanline, 0, sw);
        }
    } else if (style == kSolid_SkBlurStyle) {
        for (int y = pad ; y < dstHeight-pad ; y++) {
            uint8_t *dst_scanline = dp + y*dstWidth + pad;
            memset(dst_scanline, 0xff, sw);
        }
    }
    // normal and solid styles are the same for analytic rect blurs, so don't
    // need to handle solid specially.

    return true;
}
bool SkBlurMask::BlurRect(SkMask *dst, const SkRect &src,
                          SkScalar provided_radius, Style style,
                          SkIPoint *margin, SkMask::CreateMode createMode) {
    int profile_size;

    float radius = SkScalarToFloat(SkScalarMul(provided_radius, kBlurRadiusFudgeFactor));

    // adjust blur radius to match interpretation from boxfilter code
    radius = (radius + .5f) * 2.f;

    profile_size = compute_profile_size(radius);

    int pad = profile_size/2;
    if (margin) {
        margin->set( pad, pad );
    }

    dst->fBounds.set(SkScalarRoundToInt(src.fLeft - pad),
                     SkScalarRoundToInt(src.fTop - pad),
                     SkScalarRoundToInt(src.fRight + pad),
                     SkScalarRoundToInt(src.fBottom + pad));

    dst->fRowBytes = dst->fBounds.width();
    dst->fFormat = SkMask::kA8_Format;
    dst->fImage = NULL;

    int             sw = SkScalarFloorToInt(src.width());
    int             sh = SkScalarFloorToInt(src.height());

    if (createMode == SkMask::kJustComputeBounds_CreateMode) {
        if (style == kInner_Style) {
            dst->fBounds.set(SkScalarRoundToInt(src.fLeft),
                             SkScalarRoundToInt(src.fTop),
                             SkScalarRoundToInt(src.fRight),
                             SkScalarRoundToInt(src.fBottom)); // restore trimmed bounds
            dst->fRowBytes = sw;
        }
        return true;
    }
    unsigned int *profile = NULL;

    compute_profile(radius, &profile);
    SkAutoTDeleteArray<unsigned int> ada(profile);

    size_t dstSize = dst->computeImageSize();
    if (0 == dstSize) {
        return false;   // too big to allocate, abort
    }

    uint8_t*        dp = SkMask::AllocImage(dstSize);

    dst->fImage = dp;

    int dstHeight = dst->fBounds.height();
    int dstWidth = dst->fBounds.width();

    // nearest odd number less than the profile size represents the center
    // of the (2x scaled) profile
    int center = ( profile_size & ~1 ) - 1;

    int w = sw - center;
    int h = sh - center;

    uint8_t *outptr = dp;

    SkAutoTMalloc<uint8_t> horizontalScanline(dstWidth);

    for (int x = 0 ; x < dstWidth ; ++x) {
        if (profile_size <= sw) {
            horizontalScanline[x] = profile_lookup(profile, x, dstWidth, w);
        } else {
            float span = float(sw)/radius;
            float giX = 1.5f - (x+.5f)/radius;
            horizontalScanline[x] = (uint8_t) (255 * (gaussianIntegral(giX) - gaussianIntegral(giX + span)));
        }
    }

    for (int y = 0 ; y < dstHeight ; ++y) {
        unsigned int profile_y;
        if (profile_size <= sh) {
            profile_y = profile_lookup(profile, y, dstHeight, h);
        } else {
            float span = float(sh)/radius;
            float giY = 1.5f - (y+.5f)/radius;
            profile_y = (uint8_t) (255 * (gaussianIntegral(giY) - gaussianIntegral(giY + span)));
        }

        for (int x = 0 ; x < dstWidth ; x++) {
            unsigned int maskval = SkMulDiv255Round(horizontalScanline[x], profile_y);
            *(outptr++) = maskval;
        }
    }

    if (style == kInner_Style) {
        // now we allocate the "real" dst, mirror the size of src
        size_t srcSize = (size_t)(src.width() * src.height());
        if (0 == srcSize) {
            return false;   // too big to allocate, abort
        }
        dst->fImage = SkMask::AllocImage(srcSize);
        for (int y = 0 ; y < sh ; y++) {
            uint8_t *blur_scanline = dp + (y+pad)*dstWidth + pad;
            uint8_t *inner_scanline = dst->fImage + y*sw;
            memcpy(inner_scanline, blur_scanline, sw);
        }
        SkMask::FreeImage(dp);

        dst->fBounds.set(SkScalarRoundToInt(src.fLeft),
                         SkScalarRoundToInt(src.fTop),
                         SkScalarRoundToInt(src.fRight),
                         SkScalarRoundToInt(src.fBottom)); // restore trimmed bounds
        dst->fRowBytes = sw;

    } else if (style == kOuter_Style) {
        for (int y = pad ; y < dstHeight-pad ; y++) {
            uint8_t *dst_scanline = dp + y*dstWidth + pad;
            memset(dst_scanline, 0, sw);
        }
    } else if (style == kSolid_Style) {
        for (int y = pad ; y < dstHeight-pad ; y++) {
            uint8_t *dst_scanline = dp + y*dstWidth + pad;
            memset(dst_scanline, 0xff, sw);
        }
    }
    // normal and solid styles are the same for analytic rect blurs, so don't
    // need to handle solid specially.

    return true;
}
Example #4
0
void renderScene(void) {
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glPushMatrix();
                   alas();
    glPopMatrix();
    
    //bianglala
    glPushMatrix();
                   
                   glTranslatef(-20,16,-20);
                   glScalef(3,3,3);
                   glRotatef(135,0,1,0);
                   ada();
                   ass();
                   kaki();
                   glPushMatrix();
                                  glRotatef(qwe,0,0,1);
                                  duduk();
                   glPopMatrix();
                   glColor3f(1.0,1.0,1.0);
   glPopMatrix();
   /////////////////bianglala////////////////////////
        
    //rajawali
    glPushMatrix();
                   
                   glTranslatef(20,17,-20);
                   glScalef(3,3,3);
                   glRotatef(0,1,0,0);
                   glPushMatrix();
                                  if(asd<70){
                                  glTranslatef( 0, asd/10, 0);}
                                  else {glTranslatef(0, fgh/10, 0);}
                                  donat();
                   glPopMatrix();
                   tiang();
                   glColor3f(1.0,1.0,1.0);
   glPopMatrix();
   /////////////rajawali//////////////
   
   //hysteria
   glPushMatrix();
                  
                  glTranslatef(20,13.5,20);
                  glScalef(3,3,3);
                  glPushMatrix();
                  if(ert<60){
                  glTranslatef( 0, ert/10, 0);}
                  else {glTranslatef(0, yui/10, 0);}
                  yangbiru();
                  glPopMatrix();
                  top();
   glPopMatrix();
   //////////hysteria////////////
   
  	
	//Menggambar Halaman
	glColor3f(0, 3, 0);
	glBegin(GL_QUADS);
		glVertex3f(-40.0, 0.1, -40.0);
		glVertex3f(-40.0, 0.1,  40.0);
		glVertex3f( 40.0, 0.1,  40.0);
		glVertex3f( 40.0, 0.1, -40.0);
	glEnd();
	
	
    glutSwapBuffers();
}