public static void preAuthorizationTokenGeneration(string username, out string id, out long?internalId, out byte[] password, out byte[] salt) { id = string.Empty; internalId = -1; System.Data.Linq.Binary _password = null; System.Data.Linq.Binary _salt = null; password = new byte[] { }; salt = new byte[] { }; if (username == "saharmerheb") { password = new byte[64] { 137, 193, 82, 93, 47, 180, 86, 24, 157, 189, 86, 207, 197, 109, 122, 4, 199, 217, 164, 97, 68, 43, 24, 85, 252, 179, 79, 19, 9, 219, 147, 214, 38, 133, 76, 168, 157, 213, 91, 210, 146, 133, 58, 248, 157, 244, 171, 187, 162, 114, 178, 88, 7, 37, 76, 85, 75, 243, 129, 11, 219, 123, 245, 60 }; salt = new byte[256] { 48, 12, 100, 9, 136, 224, 44, 9, 244, 252, 44, 63, 183, 66, 249, 110, 147, 65, 153, 232, 138, 0, 222, 164, 108, 57, 226, 100, 56, 236, 61, 12, 231, 178, 8, 56, 115, 187, 16, 255, 1, 150, 91, 206, 238, 173, 180, 120, 114, 2, 121, 196, 48, 196, 227, 93, 210, 232, 148, 54, 241, 135, 172, 136, 236, 50, 87, 101, 150, 19, 226, 60, 198, 9, 98, 106, 29, 137, 28, 202, 22, 57, 156, 33, 122, 222, 241, 46, 51, 174, 73, 215, 187, 0, 246, 107, 197, 37, 247, 17, 214, 224, 167, 172, 103, 205, 125, 57, 87, 245, 201, 102, 171, 245, 18, 121, 211, 126, 207, 245, 231, 96, 169, 156, 246, 112, 191, 87, 67, 185, 211, 139, 175, 116, 26, 40, 192, 62, 152, 92, 64, 110, 97, 140, 49, 86, 251, 220, 92, 191, 217, 1, 58, 155, 75, 174, 123, 182, 198, 29, 157, 190, 131, 199, 116, 187, 211, 72, 60, 136, 0, 58, 192, 26, 119, 223, 108, 202, 51, 208, 139, 135, 17, 95, 193, 18, 148, 130, 156, 166, 55, 109, 61, 178, 25, 219, 1, 194, 163, 198, 33, 179, 77, 153, 127, 7, 20, 122, 103, 102, 60, 165, 56, 186, 6, 202, 243, 240, 225, 206, 174, 205, 6, 249, 84, 162, 149, 240, 123, 200, 67, 31, 181, 28, 164, 175, 51, 20, 42, 111, 22, 197, 125, 211, 67, 49, 64, 198, 159, 232, 200, 251, 58, 84, 2, 201 }; id = "5D8108B2-EEC2-4759-999B-2790909535E8"; internalId = 1; return; } using (var dc = new DataClassesDataContext(ConnectionString)) { dc.preAuthorizationTokenGeneration(username, ref id, ref internalId, ref _password, ref _salt); password = _password.ToArray(); salt = _salt.ToArray(); } }
public static Image dbImgaeToImage(System.Data.Linq.Binary image) { byte[] b = image.ToArray(); MemoryStream ms = new MemoryStream(b); Image img = Image.FromStream(ms); return(img); }
private object NormalizeDbType(object value) { System.Data.Linq.Binary b = value as System.Data.Linq.Binary; // Mono 2.4.2.3's Binary.operator!= is bad; avoid it. if (!object.ReferenceEquals(b, null)) { return(b.ToArray()); } return(value); }
private byte[] convertirVarBinary(System.Data.Linq.Binary miVarBinary) { if (miVarBinary != null) { byte[] Foto = miVarBinary.ToArray(); return(Foto); } else { return(null); } }
public static string TimestampToString(this System.Data.Linq.Binary binary) { byte[] binarybytes = binary.ToArray(); string result = ""; foreach (byte b in binarybytes) { result += b.ToString() + "|"; } result = result.Substring(0, result.Length - 1); return(result); }
public static Image BinaryToImage(System.Data.Linq.Binary binaryData) { if (binaryData == null) { return(null); } byte[] buffer = binaryData.ToArray(); MemoryStream memStream = new MemoryStream(); memStream.Write(buffer, 0, buffer.Length); return(Image.FromStream(memStream)); }
public static System.Drawing.Image BinaryToImage(System.Data.Linq.Binary binary) { if (binary.Length > 0) { byte[] b = binary.ToArray(); MemoryStream ms = new MemoryStream(b); System.Drawing.Image img = System.Drawing.Image.FromStream(ms); return(img); } else { return(null); } }
public CheckImageModel GetImageForContribution(int imgId) { System.Data.Linq.Binary iBinary = (from i in CurrentImageDatabase.Others where i.Id == imgId select i.First).FirstOrDefault(); CheckImageModel chkModel = new CheckImageModel { ImageId = imgId, checkImageBytes = iBinary.ToArray() }; return(chkModel); }
public void ProcessRequest(HttpContext context) { Guid brokerID = new Guid(context.Request.QueryString["id"]); ElectronicAppStorageDBDataContext stor = new ElectronicAppStorageDBDataContext(); uspGetBrokerImageByOwnerIDResult attachment = stor.uspGetBrokerImageByOwnerID(brokerID).Single <uspGetBrokerImageByOwnerIDResult>(); System.Data.Linq.Binary file = attachment.Attachment; if (attachment.Extension.ToLower().Equals("jpg")) { attachment.Extension = "jpeg"; } context.Response.ContentType = "image/" + attachment.Extension; context.Response.BinaryWrite(file.ToArray()); }
public CheckImageModel GetImageForContribution(int contributionId) { int imgId = (from c in CurrentDatabase.Contributions where c.ContributionId == contributionId select c.ImageID).FirstOrDefault(); CheckImageModel chkModel = null; if (imgId != 0) { System.Data.Linq.Binary iBinary = (from i in CurrentImageDatabase.Others where i.Id == imgId select i.First).FirstOrDefault(); chkModel = new CheckImageModel { ImageId = imgId, checkImageBytes = iBinary.ToArray() }; } return(chkModel ?? new CheckImageModel()); }
public static SvgImage GetSvgImageFromBinary(System.Data.Linq.Binary binary) { if (binary == null) { return(null); } SvgImage returnImage = null; using (MemoryStream ms = new MemoryStream(binary.ToArray())) { try { returnImage = SvgImage.FromStream(ms); } catch { returnImage = null; } } return(returnImage); }
public static void ComparePrimitiveValuesObjectAndString(object expected, Type expectedType, string actual, bool valueUri, SerializationFormatKind serializationKind, bool throwOnError) { object actualObject = DeserializeStringToObject(actual, expectedType, valueUri, serializationKind); string expectedStr = "null"; if (expected != null) { expectedStr = AstoriaUnitTests.Data.TypeData.XmlValueFromObject(expected); } string errorMessage = String.Format("Error Primitive Value of type:{0} not equal: \r\n\tExpected:\t{1} \r\n\tActual:\t{2}", expectedType.Name, expectedStr, actual); //Fixups if (expected != null && expectedType.Equals(typeof(string))) { if (actualObject != null) { actualObject = (actualObject as string).Trim(); } expected = (expected as string).Trim(); } if (expectedType == typeof(System.Xml.Linq.XElement)) { expectedStr = null; if (expected != null) { System.Xml.Linq.XElement xElement = expected as System.Xml.Linq.XElement; expectedStr = xElement.ToString(); } AstoriaTestLog.AreEqual(expectedStr, actual, errorMessage); } else if (expectedType == typeof(Single) || expectedType == typeof(Double)) { if (serializationKind == SerializationFormatKind.JSON) { if (expectedType == typeof(Double)) { Double d; if (expected != null) { d = Convert.ToDouble(expected); expectedStr = d.ToString("r", System.Globalization.CultureInfo.InvariantCulture); } if (actual != null) { if (double.TryParse(actual, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out d)) { actual = d.ToString("r", CultureInfo.InvariantCulture.NumberFormat); } } } else if (expectedType == typeof(Single)) { Single s; if (expected != null) { s = Convert.ToSingle(expected); expectedStr = s.ToString("r", System.Globalization.CultureInfo.InvariantCulture); } if (actual != null) { if (Single.TryParse(actual, NumberStyles.Any, CultureInfo.InvariantCulture.NumberFormat, out s)) { actual = s.ToString("r", CultureInfo.InvariantCulture.NumberFormat); } } } } //Fixup if (expectedStr == "null") { expectedStr = null; } if (expectedStr != null && actual != null) { expectedStr = expectedStr.Trim(); actual = actual.Trim(); } if (throwOnError) { if (expectedStr != null) { AstoriaTestLog.Compare(expectedStr.Equals(actual), errorMessage); } else { AstoriaTestLog.Compare(actual == null, errorMessage); } } else { AstoriaTestLog.AreEqual(expectedStr, actual, errorMessage); } } #if !ClientSKUFramework //For some reason byte[] comparision is not working correctly else if ((expectedType == typeof(byte[]) || expectedType == typeof(System.Data.Linq.Binary)) && valueUri) { string expectedBytesStr = null; if (expected == null) { expectedBytesStr = null; } else if (expectedType == typeof(byte[])) { expectedBytesStr = (new System.Text.UTF8Encoding()).GetString((byte[])expected); } else if (expectedType == typeof(System.Data.Linq.Binary)) { System.Data.Linq.Binary binary = expected as System.Data.Linq.Binary; expectedBytesStr = (new System.Text.UTF8Encoding()).GetString((byte[])binary.ToArray()); } if (throwOnError) { if (expected == null) { AstoriaTestLog.Compare(null == actual, errorMessage); } else { AstoriaTestLog.Compare(expectedBytesStr.Equals(actual), errorMessage); } } else { AstoriaTestLog.AreEqual(expectedBytesStr, actual, errorMessage); } } #endif else if (expectedType == typeof(byte[]) && valueUri == false) { AreBytesEqual((byte[])expected, (byte[])actualObject, throwOnError); } else { if (throwOnError) { bool objectsEqual = true; if (expected == null) { if (actualObject != null) { objectsEqual = false; } } else { objectsEqual = expected.Equals(actualObject); } AstoriaTestLog.Compare(objectsEqual, errorMessage); } else { AstoriaTestLog.AreEqual(expected, actualObject, errorMessage); } } }