internal UsuarioViewModel GetAuthData() { var id = (ClaimsIdentity)System.Web.HttpContext.Current.User.Identity; if (id.IsAuthenticated) { try { var user = StringCompressor.DecompressString(id.Name); loggedUser = user.DeserializarToJson <UsuarioViewModel>(); if (loggedUser != null && loggedUser.Id != 0) { return(loggedUser); } } catch { } string[] substrings = id.Name.Split('|'); loggedUser.Id = long.Parse(substrings[1]); loggedUser.DatosPersonaId = long.Parse(substrings[1]); loggedUser.Mail = substrings[0].ToString(); return(loggedUser); } else { return(loggedUser); } }
public ActionResult LoginPost(UsuarioViewModel loginModel) { ILoginBusiness login = DependencyFactory.Resolve<ILoginBusiness>(); try { var user = login.LoginUser(loginModel.Mail, loginModel.Password); var keyToken = StringCompressor.CompressString(user.SerializarToJson()); FormsAuthentication.SetAuthCookie(keyToken, true); Response.StatusCode = 200; return new JsonResult { Data = user, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } catch (ExceptionBusiness ex) { Response.StatusCode = 404; return new JsonResult { Data = ex.Message, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } catch (Exception) { Response.StatusCode = 500; return new JsonResult { Data = "Error del servidor", JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } }
void OnWizardCreate() { string Allfile = ""; foreach (PuzzleComponent puzzle in Selection.activeGameObject.GetComponentsInChildren <PuzzleComponent>()) { Dictionary <Vector2, string> letterPos = new Dictionary <Vector2, string>(); WordSet wordset = new WordSet(); JsonUtility.FromJsonOverwrite(StringCompressor.DecompressString(puzzle.Content), wordset); foreach (SWord word in wordset.Words) { for (int i = 0; i < word.LocationList.Count; i++) { Vector2 l = word.LocationList[i]; if (letterPos.ContainsKey(l)) { if (letterPos[l] != word.Name[i].ToString()) { Allfile += $"کلمه : {word.Name} در جدول : {puzzle.Clue}+{puzzle.PuzzleData.Row} در مجموعه : {puzzle.transform.parent.GetComponent<CategoryComponent>().CategoryData.Name} \n"; break; } } else { letterPos.Add(l, word.Name[i].ToString()); } } } } System.IO.File.WriteAllText(FileAddress, Allfile); }
private static int GetWordCount(PuzzleComponent p) { WordSet ws = new WordSet(); JsonUtility.FromJsonOverwrite(StringCompressor.DecompressString(p.Content), ws); return(ws.Words.Count); }
void OnWizardCreate() { foreach (PuzzleComponent puzzle in Selection.activeTransform.GetComponentsInChildren <PuzzleComponent>()) { string c = puzzle.Clue; WordSet ws = new WordSet(); JsonUtility.FromJsonOverwrite(StringCompressor.DecompressString(puzzle.PuzzleData.Content), ws); foreach (SWord word in ws.Words) { List <string> list = new List <string>(); if (_allWords.ContainsKey(word.Name)) { list.AddRange(_allWords[word.Name]); } list.Add(c); _allWords[word.Name] = list; } string export = ""; foreach (string word in _allWords.Keys) { List <string> cats = _allWords[word]; if (cats.Count > 1) { if (CheckSameCetegoryName) { CheckSameCat: for (var i = 0; i < cats.Count - 1; i++) { for (var j = i + 1; j < cats.Count; j++) { if (cats[i].Replace(cats[j], "").Length != cats[i].Length || cats[j].Replace(cats[i], "").Length != cats[j].Length) { cats.RemoveAt(i); goto CheckSameCat; } } } } if (cats.Count < 2) { continue; } export += "\n:\t" + word + "\t"; foreach (string cat in cats) { export += "," + cat; } } } System.IO.File.WriteAllText(FileAddress, export); } }
public void Compress(string input, string expected) { var solution = new StringCompressor(); var actual = solution.Compress(input); Assert.Equal(expected, actual); }
public void LoadFromCode() { string inp = InputCode.GetComponent <InputField> ().text; LoadSharing(StringCompressor.Decompress(inp)); HideLoadFromPanel(); HideLoadDialoge(); }
protected void Page_PreInit(object sender, EventArgs e) { if (Request.QueryString ["data"] != null) { this.PageData = StringCompressor.DecompressString(Request.QueryString ["data"]); this.ExtractPageData( ); } }
public void Share() { string buf = StringCompressor.Compress(SaveSharing()); print(buf); print(StringCompressor.Decompress(buf)); StartCoroutine(ShareAndRate.ShareAndroidText(buf)); }
public WordSet GetWordSet() { WordSet wordSet = new WordSet(); string decompressString = StringCompressor.DecompressString(Content); string replace = decompressString.Replace("\"Direction\"", "\"WordDirection\""); JsonUtility.FromJsonOverwrite(replace, wordSet); return(wordSet); }
public void TestMethod1() { StringCompressor sc = new StringCompressor(); Assert.AreEqual <string>("2a1b5c3b", sc.Compress("aabcccccbbb")); Assert.AreEqual <string>("aa", sc.Compress("aa")); Assert.AreEqual <string>("", sc.Compress("")); Assert.AreEqual <string>("", sc.Compress(null)); Assert.AreEqual <string>("abccdefg", sc.Compress("abccdefg")); Assert.AreEqual <string>("3a3b1g1c3t3s2f", sc.Compress("aaabbbgctttsssff")); }
public void Save() { WordSet wordSet = GameController.Instance.GetWordSet(); var puzzle = new UserPuzzle { Clue = wordSet.Clue, Content = StringCompressor.CompressString(JsonUtility.ToJson(wordSet)) }; LocalDBController.Instance.UserPuzzles.AddPuzzle(puzzle); }
internal Byte[] EncodeImpl(Log log) { String logObjectStr = null; if (log.LogObject is String str) { if (log.IsRawString) { // String을 그대로 저장하면 Athena에서 다른 JSON로그와 문제가 되므로 변환한다. log.LogObject = new StringLogObject { raw = str }; // { "raw" : "로그문자열" } } else { // String이지만 JSON으로 변환된 상태이므로 그대로 전송한다. logObjectStr = str; } } logObjectStr = logObjectStr ?? _jsonSerializer.Serialize(log.LogObject); String compressedLog = null; String plainLog = null; if (_compressLogThresholdByte < logObjectStr.Length) { compressedLog = StringCompressor.Compress(logObjectStr); } else { plainLog = logObjectStr; } var putString = new StringBuilder(_jsonSerializer.Serialize(new PutData { ID = _id, InstanceID = _instanceID, Sequence = log.Sequence, TimeStamp = log.TimeStamp, TimeStampNS = log.TimeStampNS, LogType = log.LogType, CompressedLog = compressedLog, Log = plainLog })); putString.Append(Const.LOG_DELIMITER); Byte[] encodedLog = Encoding.UTF8.GetBytes(putString.ToString()); return(encodedLog); }
public static string GetSettingsFromCollection(string collectionId) { var nameValue = new Dictionary <string, string>(); var retStr = string.Empty; try { var wmiQuery = $"SELECT * FROM SMS_CollectionSettings WHERE CollectionID='{collectionId}'"; var result = Globals.Sccm.QueryProcessor.ExecuteQuery(wmiQuery) as WqlQueryResultsObject; foreach (WqlResultObject setting in result) { setting.Get(); var collVars = setting.GetArrayItems("CollectionVariables"); foreach (var v in collVars) { if (v["Name"].StringValue.Contains("DPLSCH")) { nameValue.Add(v["Name"].StringValue, v["Value"].StringValue); } } if (nameValue.Count() == 0) { return(retStr); } var sortedVars = nameValue.OrderBy(x => x.Key).ToList(); foreach (var pair in sortedVars) { retStr += pair.Value.Trim().TrimEnd('\0'); } } } catch (SmsQueryException ex) { Logger.Log(ex.Details, LogType.Error); } catch (SmsException ex) { Logger.Log(ex.Details, LogType.Error); } catch (Exception ex) { Logger.Log(ex.Message, LogType.Error); } return(StringCompressor.DecompressString(retStr)); }
public void 압축_테스트() { const String ORIGIN_TEXT = "Test text..... test test test !!!!!!!!!!! 1234567890"; String compressed = StringCompressor.Compress(ORIGIN_TEXT); String decompressed = StringCompressor.Decompress(compressed); Assert.IsTrue(decompressed == ORIGIN_TEXT); Assert.IsTrue(StringCompressor.Compress(null) == String.Empty); Assert.IsTrue(StringCompressor.Decompress(null) == String.Empty); }
public void updateKinectImages(string imageData) { if (!MainWindow.getUpdateGUI()) { return; } if (this.rgbImg.Dispatcher.Thread != Thread.CurrentThread) { this.rgbImg.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new updateKinectImagesCallback(this.updateKinectImages), imageData); } else { try { string[] imageDatas = imageData.Split('*'); StringCompressor s = new StringCompressor(); byte[] rgbData = s.DecompressByteArray(imageDatas[0]); byte[] depthDataByte = s.DecompressByteArray(imageDatas[1]); if (rgbData == null || depthDataByte == null) { this.infoTextBlock.Text = "Image reading ERROR!!" + Environment.NewLine + this.infoTextBlock.Text; return; } /* Transfer Byte Array Data back to WriteableBitmap*/ this.colorImageWritableBitmap.WritePixels( new Int32Rect(0, 0, 1920, 1080), rgbData, 7680, 0); this.depthImageWritableBitmap.WritePixels( new Int32Rect(0, 0, 512, 424), depthDataByte, 512, 0); this.rgbImg.Source = this.colorImageWritableBitmap; this.depthImg.Source = this.depthImageWritableBitmap; byte[] point3DDataByte = s.DecompressByteArray(imageDatas[2]); point3DArray = new float[point3DDataByte.Length * 3]; Buffer.BlockCopy(point3DDataByte, 0, point3DArray, 0, point3DDataByte.Length); if (parentGUI.cali != null) { parentGUI.cali.updateImages(); } } catch { this.infoTextBlock.Text = "Image reading ERROR!!" + Environment.NewLine + this.infoTextBlock.Text; } } }
public void SampleTest1() { //Arrange string s1 = "abcdefghijklmnop"; //Act string compressed = StringCompressor.CompressString(s1); string uncompressed = StringCompressor.DecompressString(compressed); //Artifacts mTestHelper.CreateTestArtifact("Stringcompression", s1 + Environment.NewLine + compressed); //Assert Assert.AreEqual(uncompressed, s1, "uncompressed=s1"); }
public void CompressDecompressTest() { var text = " asd fdghfg d werwse uyiy uyui bn cvgbh dfgd fg"; var bytes = Encoding.UTF8.GetBytes(text); var base64 = Convert.ToBase64String(bytes); var textLength = text.Length; var base64Length = base64.Length; var compressedText = StringCompressor.CompressString(text); var decompressedText = StringCompressor.DecompressString(compressedText); Assert.AreEqual(text, decompressedText); }
public static object Decode(IBinaryInputStream data) { byte type = data.ReadByte(); switch (type) { case 42: return(new LowLevelConnectMessage()); case APlayCodec.MSGTYPE_PAYLOAD: APlayStringMessage msg = new APlayStringMessage(); msg.SetDataAsString(data.ReadString()); return(msg); case APlayCodec.MSGTYPE_PAYLOAD_BINARY_JSON: GameContext.Logger.LogDebug($"Package [MSGTYPE_PAYLOAD_BINARY_JSON] received: {data.ReadInt()} byte(s)"); APlayStringMessage msg2 = new APlayStringMessage(); msg2.SetDataAsJson(APlayBinaryMessage.ReadJsonEncoded(data)); return(msg2); case APlayCodec.MSGTYPE_PAYLOAD_GZIP: // this even used? APlayStringMessage msg3 = new APlayStringMessage(); msg3.SetDataAsString(StringCompressor.Decompress(data.ReadBytes())); return(msg3); case APlayCodec.MSGTYPE_LOWLEVEL_PING: GameContext.Logger.LogDebug($"Package [MSGTYPE_LOWLEVEL_PING] received: {data.ReadInt()} byte(s)"); return(new LowLevelPingMessage { PingTime = data.ReadLong(), LastRTT = data.ReadInt() }); case APlayCodec.MSGTYPE_LOWLEVEL_PONG: GameContext.Logger.LogDebug($"Package [MSGTYPE_LOWLEVEL_PONG] received: {data.ReadInt()} byte(s)"); return(new LowLevelPongMessage { PingTime = data.ReadLong() }); case APlayCodec.MSGTYPE_LOWLEVEL_INTRODUCTION: return(new LowLevelIntroductionMessage { AddressString = data.ReadString() }); } return(null); }
public static string SerializeDataStructure(ISerializable serializableDataStructure) { MemoryStream ms = new MemoryStream(); MemoryStream ms2 = new MemoryStream(); StringCompressor sc = new StringCompressor(); BinaryFormatter formatter = new BinaryFormatter(); try { formatter.Serialize(ms, serializableDataStructure); sc.Compress(ms, ms2); return(Convert.ToBase64String(ms2.ToArray())); } catch { return(null); } }
public void SpawnInvitedPuzzle() { var json = StringCompressor.DecompressString(ServerRespond["Content"].ToString()); WordSet wordSet = new WordSet(); JsonUtility.FromJsonOverwrite(json, wordSet); Singleton.Instance.WordSpawner.WordSet = wordSet; Singleton.Instance.WordSpawner.Clue = ServerRespond["Clue"].ToString(); Singleton.Instance.WordSpawner.PuzzleID = -1; Singleton.Instance.WordSpawner.PuzzleRow = ServerRespond["Creator"].ToString(); Singleton.Instance.WordSpawner.EditorInstatiate = null; FollowMachine.SetOutput("Success"); }
public async Task <IActionResult> SearchInMain(MainModelView mainModelView) { if (mainModelView.Search != null) { long id; if (long.TryParse(mainModelView.Search, out id)) { var q = await appDbContext.MainTable.Where(i => i.Id == id).ToListAsync(); var f = await appDbContext.MainTable.ToListAsync(); var filt = f.Select(i => i._IPinfo.CompanyName).Distinct().ToList(); MainModelView mainModelView1 = new MainModelView() { MainTables = q }; TempData["MainData"] = JsonConvert.SerializeObject(mainModelView1); return(RedirectToAction("MainTable", "Home")); } else if (mainModelView.Search.Length != 0) { //var tmp = await appDbContext.MainTable.Where(i => i.FilesInfo.Path.Contains(mainModelView.Search)).ToListAsync(); var cmp = await appDbContext.MainTable.Where(i => i._IPinfo.CompanyName.Contains(mainModelView.Search)).ToListAsync(); //tmp.AddRange(cmp); // var f = await appDbContext.MainTable.ToListAsync(); // var filt = f.Select(i => i._IPinfo.CompanyName).Distinct().ToList(); MainModelView mainModelView11 = new MainModelView() { MainTables = cmp, }; string str = JsonConvert.SerializeObject(cmp); byte[] arr = Encoding.ASCII.GetBytes(str); var tq = StringCompressor.CompressString(str); // string h = "hello"; TempData["MainData"] = tq; //return RedirectToAction("MainTable", "Home"); } } return(RedirectToAction("MainTable", "Home")); }
public IEnumerator SetForSpawn(int ID) { UserPuzzle selectedPuzzle = null; _pID = ID; // Ask command center to connect to account /* * yield return ServerController * .Get<UserPuzzle>($@"UserPuzzles/{ID}", * puzzle => { selectedPuzzle = (UserPuzzle)puzzle; }); */ ServerRespond = null; yield return(ServerController .Post <string>($@"UserPuzzles/GetInviteData?puzzleID={ID}&senderID={Singleton.Instance.PlayerController.PlayerID}", null, r => { ServerRespond = JObject.Parse(r); }, request => { FollowMachine.SetOutput("Fail"); } )); if (ServerRespond == null) { FollowMachine.SetOutput("Fail"); yield break; } var json = StringCompressor.DecompressString(ServerRespond["Content"].ToString()); WordSet wordSet = new WordSet(); JsonUtility.FromJsonOverwrite(json, wordSet); Singleton.Instance.WordSpawner.WordSet = wordSet; Singleton.Instance.WordSpawner.Clue = ServerRespond["Clue"].ToString(); Singleton.Instance.WordSpawner.PuzzleID = -1; Singleton.Instance.WordSpawner.PuzzleRow = ServerRespond["Creator"].ToString(); Singleton.Instance.WordSpawner.EditorInstatiate = null; FollowMachine.SetOutput("Success"); }
public void SetForSpawn() { var selectedPuzzle = PuzzleSelectionWindow.SelectedPuzzle; var json = StringCompressor.DecompressString(selectedPuzzle.Content); WordSet wordSet = new WordSet(); JsonUtility.FromJsonOverwrite(json, wordSet); Singleton.Instance.WordSpawner.WordSet = wordSet; Singleton.Instance.WordSpawner.Clue = selectedPuzzle.Clue; Singleton.Instance.WordSpawner.PuzzleID = -1; Singleton.Instance.WordSpawner.PuzzleRow = ""; Singleton.Instance.WordSpawner.EditorInstatiate = null; }
void OnWizardCreate() { string Allfile = ""; foreach (PuzzleComponent puzzle in Selection.activeGameObject.GetComponentsInChildren <PuzzleComponent>()) { string p = "اشاره: " + puzzle.Clue + ","; WordSet ws = new WordSet(); JsonUtility.FromJsonOverwrite(StringCompressor.DecompressString(puzzle.PuzzleData.Content), ws); foreach (SWord word in ws.Words) { p += word.Name + ","; } p += "\n"; Allfile += p; } System.IO.File.WriteAllText(FileAddress, Allfile); }
public static object DeSerializeDataStructure(string serializationString) { byte[] serializationData = Convert.FromBase64String(serializationString); MemoryStream ms = new MemoryStream(); MemoryStream ms2 = new MemoryStream(); StringCompressor sc = new StringCompressor(); BinaryFormatter formatter = new BinaryFormatter(); try { ms.Write(serializationData, 0, serializationData.Length); sc.Decompress(ms, ms2); ms2.Position = 0; return(formatter.Deserialize(ms2)); } catch { return(null); } }
public UsuarioViewModel LoginPost(UsuarioViewModel loginModel) { ILoginBusiness login = DependencyFactory.Resolve <ILoginBusiness>(); try { var user = login.LoginUser(loginModel.Mail, loginModel.Password); var keyToken = StringCompressor.CompressString(user.SerializarToJson()); FormsAuthentication.SetAuthCookie(keyToken, true); return(user); } catch (ExceptionBusiness) { throw; } catch (Exception ex) { throw new Exception("Error del servidor", ex); } }
private void LookForNewSettings() { var settingFile = string.Empty; var collVars = CcmUtils.GetSettingsVariables(); if (collVars.Count() < 2) { return; } collVars = collVars.OrderBy(x => x.Name).ToList(); foreach (var collVar in collVars) { var tmp = GetCDataFromString(collVar.Value); if (tmp == null) { return; } settingFile += DecryptVariableValue(tmp).Trim().TrimEnd('\0'); } if (!string.IsNullOrEmpty(settingFile)) { settingFile = StringCompressor.DecompressString(settingFile); } if (settingFile.StartsWith("<?xml") && settingFile.EndsWith("</Settings>") && !settingFile.Equals(_oldSettings)) { SettingsUtils.WriteStringToSettingsFile(settingFile); Globals.Log.Information("Wrote new settings to 'Settings.xml'"); _oldSettings = settingFile; } else { Globals.Log.Information("No new settings found in Policy"); } }
/// <summary> /// Load the data contained in a file at the specified path /// </summary> public void Load(string path) { // Read the data byte[] raw = File.ReadAllBytes(path); // Re-encode the text to utf8 string compressed = Encoding.UTF8.GetString(raw); // Uncompress the file and split the line delimeter string[] data = StringCompressor.DecompressString(compressed).Split("*"); // Clear the file array files.Clear(); // Loop through the lines and re-construct each file foreach (string file in data) { string[] chunks = file.Split("|"); // Convert each chunk back into the original type files.Add(new Scanning.File(long.Parse(chunks[1]), chunks[0], Convert.ToBoolean(Convert.ToInt16(chunks[2])), Convert.ToBoolean(Convert.ToInt16(chunks[3])))); } }
public void CompressDecomPressString() { // Arrange var subject = StringEncryptor.Instance; var originalString = "Testing 123: Add some special characters &é@#'öçà!£$<ù}"; // Act var encryptedString1 = subject.Encrypt(originalString); var compressedString1 = StringCompressor.CompressString(encryptedString1); var decompressedString1 = StringCompressor.DecompressString(compressedString1); var decryptedString1 = subject.Decrypt(decompressedString1); var compressedString2 = StringCompressor.CompressString(originalString); var decompressedString2 = StringCompressor.DecompressString(compressedString2); // Assert Assert.AreEqual(originalString, decryptedString1, "Compressed and Decrypted string should match original string"); //Assert.IsTrue((compressedString1.Length <= encryptedString1.Length), "Compressed Encrypted String should be smaller than the Encrypted string"); Assert.AreEqual(originalString, decompressedString2, "Decompressed string should match original string"); //Assert.IsTrue((compressedString2.Length <= originalString.Length), "Compressed String should be smaller than the original"); }