void ClientPost(object Msg) { CounterSendMsg initMsgNow = (CounterSendMsg)Msg; string strEncCode = CryptoModule.encrypt(initMsgNow.strSendMsg.ToString().Trim()); string strReturnData = string.Empty; lock (lockerPost) { try { initMsgNow.strSendMsg = initMsgNow.bMultiFlag ? initMsgNow.strSendMsg : ""; strReturnData = Post(VarGlobal.ServerUrl.ToString().Trim(), strEncCode.ToString().Trim(), initMsgNow.strSendMsg.ToString().Trim()); LogHelper.WriteLog("SendResult " + strReturnData.Replace("\r\n", "-")); } catch (OutOfMemoryException ex) { LogHelper.WriteLog("OutOfMemoryException post " + initMsgNow.strSendMsg + ex.ToString()); } catch (Exception ex) { AppLog.Fatal("ClientPost " + ex.ToString()); LogHelper.WriteLog("Exception ClientPost " + ex.ToString()); } } }
void ClientPost(object Msg) { CounterSendMsg initMsgNow = (CounterSendMsg)Msg; string strEncCode = CryptoModule.encrypt(initMsgNow.strSendMsg.ToString().Trim()); string strReturnData = string.Empty; lock (lockerPost) { try { initMsgNow.strSendMsg = initMsgNow.bMultiFlag ? initMsgNow.strSendMsg : ""; strReturnData = Post(VarGlobal.ServerUrl.ToString().Trim(), strEncCode.ToString().Trim(), initMsgNow.strSendMsg.ToString().Trim()); LogHelper.WriteLog("SendResult " + strReturnData.Replace("\r\n", "-")); } catch (Exception ex) { //string bufret1 = (ex.Message.ToString() // + strReturnData + "/r/n" // + strEncCode + "/r/n" // + m_VtmUrl.ToString().Trim()); //string bufret = (ex.Message.ToString() + "/r/n" // + strReturnData + "/r/n" // + strEncCode + "/r/n" // + m_VtmUrl.ToString().Trim()); //showApiData(bufret, richApiLog); } } }
string Post(string url, string postStr, string inteStr = "", Encoding encode = null) { string result; string timeStamp = string.Empty; string nonce = string.Empty; try { var webClient = new WebClient { Encoding = Encoding.UTF8 }; webClient.Proxy = null; if (encode != null) { webClient.Encoding = encode; } if (!string.IsNullOrWhiteSpace(VarGlobal.TokenKey)) { webClient.Headers.Add("Authorization", VarGlobal.TokenKey); } ServicePointManager.ServerCertificateValidationCallback += delegate( object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); }; NameValueCollection markStatus = new NameValueCollection(); string[] values = null; if (string.IsNullOrWhiteSpace(inteStr)) { markStatus.Add("q", postStr); } else { string[] arryStrParam = inteStr.Split('#'); foreach (string istring in arryStrParam) { string strEn = CryptoModule.encrypt(istring.ToString().Trim()); markStatus.Add("q", strEn); } } ServicePointManager.SecurityProtocol = (SecurityProtocolType)192 | (SecurityProtocolType)768 | (SecurityProtocolType)3072; var readData = webClient.UploadValues(url, "POST", markStatus); result = Encoding.UTF8.GetString(readData); } catch (Exception ee) { string buf = ee.Message; throw new Exception(buf.ToString()); } return(result); }
public void setup() { bookingDB = new BookingDB(); advertisementDB = new AdvertisementDB(); userDB = new UserDB(); bicycleDB = new BicycleDB(); crypto = new CryptoModule(); // Seed Brands b1 = new Brand { Name = "Croissant" }; b2 = new Brand { Name = "Canondale" }; b3 = new Brand { Name = "Trek" }; // Seed Types bt1 = new BicycleType { TypeName = "Mountainbike" }; bt2 = new BicycleType { TypeName = "Racer" }; // Seed FrameSizes f1 = new Frame { Size = 30 }; f2 = new Frame { Size = 32 }; f3 = new Frame { Size = 34 }; f4 = new Frame { Size = 36 }; // Seed WheelSizes w1 = new Wheel { Size = 20 }; w2 = new Wheel { Size = 22 }; w3 = new Wheel { Size = 24 }; w4 = new Wheel { Size = 26 }; // Seed Users u1 = new User { Address = "test", Age = "1", Salt = crypto.GenerateSaltString(), Email = "test", Name = "test", PWord = "1", Phone = "1234", Zipcode = "9200" }; u2 = new User { Address = "Hobrovej", Age = "30", Salt = crypto.GenerateSaltString(), Email = "*****@*****.**", Name = "John", PWord = "123", Phone = "87654321", Zipcode = "9000" }; // Seed bicycles bike1 = new Bicycle { Brand = b1, FrameSize = f1, Type = bt1, User = u1, WheelSize = w1, Year = "2017" }; bike2 = new Bicycle { Brand = b2, FrameSize = f2, Type = bt2, User = u1, WheelSize = w2, Year = "2016" }; bike3 = new Bicycle { Brand = b3, FrameSize = f3, Type = bt1, User = u1, WheelSize = w3, Year = "2015" }; bike4 = new Bicycle { Brand = b3, FrameSize = f1, Type = bt1, User = u2, WheelSize = w1, Year = "2012" }; bike5 = new Bicycle { Brand = b3, FrameSize = f3, Type = bt1, User = u2, WheelSize = w3, Year = "2011" }; bike6 = new Bicycle { Brand = b3, FrameSize = f4, Type = bt1, User = u2, WheelSize = w4, Year = "2010" }; // Seed advertisements a1 = new Advertisement { Title = "lorem 2", Description = "K0WJZFWWZW VLL4262TZI 81CS84SUUR OCWPGNS3X2 66WJ5APZLR BDCHCU3WEC", Price = 18.90, StartDate = DateTime.ParseExact("01/05/2017", "dd/MM/yyyy", null), EndDate = DateTime.ParseExact("01/07/2017", "dd/MM/yyyy", null), User = u2, Bike = bike4 }; a2 = new Advertisement { Title = "lorem 1", Description = "K0WJZFWWZW VLL4262TZI 81CS84SUUR OCWPGNS3X2 66WJ5APZLR BDCHCU3WEC", Price = 18.90, StartDate = DateTime.ParseExact("01/05/2017", "dd/MM/yyyy", null), EndDate = DateTime.ParseExact("01/07/2017", "dd/MM/yyyy", null), User = u1, Bike = bike2 }; }
public void setup() { _mockBookingDB = new Mock <IBookingDB>(); // mocked database object _mockBookingDB.Setup(m => m.CreateBooking(It.IsAny <Booking>())); // createBooking på mock tager imod enhver booking _bCtrl = new BookingCtrl(_mockBookingDB.Object); // injection af mock i vores bookingCtrl CryptoModule crypto = new CryptoModule(); // Seed Brands b1 = new Brand { Name = "Croissant" }; b2 = new Brand { Name = "Canondale" }; b3 = new Brand { Name = "Trek" }; // Seed Types bt1 = new BicycleType { TypeName = "Mountainbike" }; bt2 = new BicycleType { TypeName = "Racer" }; // Seed FrameSizes f1 = new Frame { Size = 30 }; f2 = new Frame { Size = 32 }; f3 = new Frame { Size = 34 }; f4 = new Frame { Size = 36 }; // Seed WheelSizes w1 = new Wheel { Size = 20 }; w2 = new Wheel { Size = 22 }; w3 = new Wheel { Size = 24 }; w4 = new Wheel { Size = 26 }; // Seed Users u1 = new User { Address = "Sofiendalsvej", Age = "24", Salt = crypto.GenerateSaltString(), Email = "*****@*****.**", Name = "Brian", PWord = "123", Phone = "12345678", Zipcode = "9200" }; u2 = new User { Address = "Hobrovej", Age = "30", Salt = crypto.GenerateSaltString(), Email = "*****@*****.**", Name = "John", PWord = "123", Phone = "87654321", Zipcode = "9000" }; // Seed bicycles bike1 = new Bicycle { Brand = b1, FrameSize = f1, Type = bt1, User = u1, WheelSize = w1, Year = "2017" }; bike2 = new Bicycle { Brand = b2, FrameSize = f2, Type = bt2, User = u1, WheelSize = w2, Year = "2016" }; bike3 = new Bicycle { Brand = b3, FrameSize = f3, Type = bt1, User = u1, WheelSize = w3, Year = "2015" }; bike4 = new Bicycle { Brand = b3, FrameSize = f1, Type = bt1, User = u2, WheelSize = w1, Year = "2012" }; bike5 = new Bicycle { Brand = b3, FrameSize = f3, Type = bt1, User = u2, WheelSize = w3, Year = "2011" }; bike6 = new Bicycle { Brand = b3, FrameSize = f4, Type = bt1, User = u2, WheelSize = w4, Year = "2010" }; // Seed advertisements a1 = new Advertisement { Title = "lorem 2", Description = "K0WJZFWWZW VLL4262TZI 81CS84SUUR OCWPGNS3X2 66WJ5APZLR BDCHCU3WEC", Price = 18.90, StartDate = DateTime.ParseExact("01/05/2017", "dd/MM/yyyy", null), EndDate = DateTime.ParseExact("01/07/2017", "dd/MM/yyyy", null), User = u2, Bike = bike4 }; a2 = new Advertisement { Title = "lorem 1", Description = "K0WJZFWWZW VLL4262TZI 81CS84SUUR OCWPGNS3X2 66WJ5APZLR BDCHCU3WEC", Price = 18.90, StartDate = DateTime.ParseExact("01/05/2017", "dd/MM/yyyy", null), EndDate = DateTime.ParseExact("01/07/2017", "dd/MM/yyyy", null), User = u1, Bike = bike2 }; }
public bool CheckPassword(string attemptedPassword) { IStructuralEquatable hash = CryptoModule.Hash(Encoding.UTF8.GetBytes(attemptedPassword), PasswordSalt); return(hash.Equals(PasswordHash, StructuralComparisons.StructuralEqualityComparer)); }
public void CreatePassword(string newPassword) { PasswordSalt = CryptoModule.Salt(); PasswordHash = CryptoModule.Hash(Encoding.UTF8.GetBytes(newPassword), PasswordSalt); }
public UserCtrl() { userDb = new UserDB(); crypto = new CryptoModule(); }
public Configuration() { AutomaticMigrationsEnabled = true; crypto = new CryptoModule(); }