public IActionResult Wall(UserWallRequest request) { var userwall = _userservice.FindByName(request.UserName); var guest = _userservice.FindByName(request.GuestName); var wall = new WallResponse(); if (userwall.BlockedUserId.Contains(guest.UserId)) { return(BadRequest(new { Message = "This User has you blocked: " + userwall.Name })); } foreach (var circleIds in userwall.CircleId) { var circle = _circleService.Get(circleIds); if (circle.UserId.Contains(guest.UserId)) { foreach (var postId in circle.PostId) { var post = _postService.Get(postId); if (post.UserId == userwall.UserId) { wall.Responses.Add(_mapper.Map <PostResponse>(post)); } } } } foreach (var postId in userwall.PostId) { var post = _postService.Get(postId); if (post.Public) { wall.Responses.Add(_mapper.Map <PostResponse>(post)); } } return(Ok(wall.Responses)); }
public bool SaveWallpost(WallResponse wallData) { try { if (wallData == null) { return(false); } var chunk = new WallPostDataChunk { GroupId = wallData.GroupId, CompressedData = CompressFile(wallData) }; _saveQueue.Enqueue(chunk); return(true); } catch (Exception ex) { _log?.Error(ex, ex.Message); } return(false); }
private static byte[] CompressFile(WallResponse inStream) { using (var tg = new MemoryStream()) //using (var ms = new LZ4Stream(tg, LZ4StreamMode.Compress)) { Serializer.Serialize(tg, inStream); tg.Position = 0; return(LZ4Codec.Wrap(tg.ToArray())); } //Int32 dictionary = 1 << 23; //Int32 posStateBits = 2; //Int32 litContextBits = 3; // for normal files //// UInt32 litContextBits = 0; // for 32-bit data //Int32 litPosBits = 0; //// UInt32 litPosBits = 2; // for 32-bit data //Int32 algorithm = 2; //Int32 numFastBytes = 128; //string mf = "bt4"; //bool eos = true; //bool stdInMode = false; //CoderPropID[] propIDs = { // CoderPropID.DictionarySize, // CoderPropID.PosStateBits, // CoderPropID.LitContextBits, // CoderPropID.LitPosBits, // CoderPropID.Algorithm, // CoderPropID.NumFastBytes, // CoderPropID.MatchFinder, // CoderPropID.EndMarker //}; //object[] properties = { // (Int32)(dictionary), // (Int32)(posStateBits), // (Int32)(litContextBits), // (Int32)(litPosBits), // (Int32)(algorithm), // (Int32)(numFastBytes), // mf, // eos //}; //using (var outStream = new MemoryStream()) //{ // var encoder = new SevenZip.SDK.Compress.LZMA.Encoder(); // encoder.SetCoderProperties(propIDs, properties); // encoder.WriteCoderProperties(outStream); // Int64 fileSize; // if (eos || stdInMode) // fileSize = -1; // else // fileSize = inStream.Length; // for (int i = 0; i < 8; i++) // outStream.WriteByte((Byte)(fileSize >> (8 * i))); // encoder.Code(inStream, outStream, -1, -1, null); // return outStream.ToArray(); //} }