public void PackageDownloadControllerGetTest() { const string suffix = "/package/{0}/{1}"; string responseData; Package pkgV000 = PackageDAO.Read(NugetSamplePackages.nugetoryV000.Title, NugetSamplePackages.nugetoryV000.Version).Result; string pkgV000File; using (StreamReader sr = new StreamReader(FileStore.GetFile(pkgV000.Id, pkgV000.PackageHash))) pkgV000File = sr.ReadToEnd(); string url = InvokeUrl + string.Format(suffix, pkgV000.Title, pkgV000.Version); HttpClient.Invoke(url, "GET", out responseData); Assert.AreEqual(pkgV000File, responseData); Package pkgV003 = PackageDAO.Read(NugetSamplePackages.nugetoryV003.Title, NugetSamplePackages.nugetoryV003.Version).Result; string pkgV003File; using (StreamReader sr = new StreamReader(FileStore.GetFile(pkgV003.Id, pkgV003.PackageHash))) pkgV003File = sr.ReadToEnd(); url = InvokeUrl + string.Format(suffix, pkgV003.Title, pkgV003.Version); HttpClient.Invoke(url, "GET", out responseData); Assert.AreEqual(pkgV003File, responseData); }
[Category("nugetory.Integration.PackageDetailsControllerDelete"), Test]//, Timeout(1000)] public void PackageDetailsControllerDeleteApiKeyFailTest() { ClearAllPackages(); LoadAllPackages(); long originalCount = PackageDAO.Count().Result; ValidateAuthenticationAttribute.ApiKey = Path.GetRandomFileName().Replace(".", ""); HttpClient.ApiKey = null; const string suffix = "/Packages(Id='{0}',Version='{1}')"; Package pkgV000 = PackageDAO.Read(NugetSamplePackages.nugetoryV000.Title, NugetSamplePackages.nugetoryV000.Version).Result; string urlSuffix = string.Format(suffix, pkgV000.Title, pkgV000.Version); string url = InvokeUrl + urlSuffix; HttpStatusCode resultCode = HttpClient.Invoke(url, "DELETE"); Assert.AreEqual(HttpStatusCode.Unauthorized, resultCode); Assert.AreEqual(originalCount, PackageDAO.Count().Result); HttpClient.ApiKey = Path.GetRandomFileName().Replace(".", ""); Assert.AreNotEqual(ValidateAuthenticationAttribute.ApiKey, HttpClient.ApiKey); resultCode = HttpClient.Invoke(url, "DELETE"); Assert.AreEqual(HttpStatusCode.Unauthorized, resultCode); Assert.AreEqual(originalCount, PackageDAO.Count().Result); }
public ActionResult Packages(string ordenar_por, int?preco_inicial, int?preco_final) { ordenar_por = ordenar_por ?? "Relevancia"; string[] orderByString = { "Relevancia", "Menor Para Maior", "Maior Para Menor" }; int index = orderByString.ToList().IndexOf(orderByString.ToList().Where(i => i == ordenar_por).First()); return(View(PackageDAO.GetList(index, preco_inicial, preco_final))); }
public ActionResult Package(ushort?id) { if (id == null) { return(RedirectToAction("Packages")); } return(View(PackageDAO.GetById(Convert.ToUInt16(id)))); }
public ActionResult RemoveService(ushort id, ushort servId) { if (!Authentication.IsValid()) { return(Json(new { Error = "Not Authenticated" })); } PackageDAO.RemoveService(id, servId); return(Json(new { Success = "Success" })); }
public static void UploadAllPackages(PackageDAO packageDAO, string invokeUrl) { NugetPackage packageV000 = NugetSamplePackages.nugetoryV000; byte[] request = Convert.FromBase64String(packageV000.Base64Post); HttpStatusCode responseCode = HttpClient.Invoke(invokeUrl, "PUT", request, packageV000.ContentType, packageV000.ContentLength); Assert.AreEqual(HttpStatusCode.Created, responseCode); Assert.AreEqual(1, packageDAO.Count().Result); NugetPackage packageV001 = NugetSamplePackages.nugetoryV001; request = Convert.FromBase64String(packageV001.Base64Post); responseCode = HttpClient.Invoke(invokeUrl, "PUT", request, packageV001.ContentType, packageV001.ContentLength); Assert.AreEqual(HttpStatusCode.Created, responseCode); Assert.AreEqual(2, packageDAO.Count().Result); NugetPackage packageV002 = NugetSamplePackages.nugetoryV002; request = Convert.FromBase64String(packageV002.Base64Post); responseCode = HttpClient.Invoke(invokeUrl, "PUT", request, packageV002.ContentType, packageV002.ContentLength); Assert.AreEqual(HttpStatusCode.Created, responseCode); Assert.AreEqual(3, packageDAO.Count().Result); NugetPackage packageV003 = NugetSamplePackages.nugetoryV003; request = Convert.FromBase64String(packageV003.Base64Post); responseCode = HttpClient.Invoke(invokeUrl, "PUT", request, packageV003.ContentType, packageV003.ContentLength); Assert.AreEqual(HttpStatusCode.Created, responseCode); Assert.AreEqual(4, packageDAO.Count().Result); NugetPackage bookstoreV000 = NugetSamplePackages.bookstoreV000; request = Convert.FromBase64String(bookstoreV000.Base64Post); responseCode = HttpClient.Invoke(invokeUrl, "PUT", request, bookstoreV000.ContentType, bookstoreV000.ContentLength); Assert.AreEqual(HttpStatusCode.Created, responseCode); Assert.AreEqual(5, packageDAO.Count().Result); NugetPackage bookstoreV001 = NugetSamplePackages.bookstoreV001; request = Convert.FromBase64String(bookstoreV001.Base64Post); responseCode = HttpClient.Invoke(invokeUrl, "PUT", request, bookstoreV001.ContentType, bookstoreV001.ContentLength); Assert.AreEqual(HttpStatusCode.Created, responseCode); Assert.AreEqual(6, packageDAO.Count().Result); }
private static void ClearAllPackages() { List <Package> packages = PackageDAO.Read(p => true).Result; packages.ForEach(p => { PackageDAO.Delete(p.Id); FileStore.DeleteFile(p.Id); }); }
public void OneTimeTearDown() { List <Package> packages = PackageDAO.Read(p => true).Result; packages.ForEach(p => { PackageDAO.Delete(p.Id); FileStore.DeleteFile(p.Id); }); }
private DataTable createMyCartTable() { DataTable table = new DataTable(); //订单号 DataColumn dc = new DataColumn("order_number", typeof(string)); table.Columns.Add(dc); //重量 dc = new DataColumn("quantity", typeof(int)); table.Columns.Add(dc); //发件人 dc = new DataColumn("sender", typeof(string)); table.Columns.Add(dc); //收件人 dc = new DataColumn("receiver", typeof(string)); table.Columns.Add(dc); //服务方式 dc = new DataColumn("postway", typeof(string)); table.Columns.Add(dc); //付款金额 dc = new DataColumn("pay", typeof(string)); table.Columns.Add(dc); //下单时间 dc = new DataColumn("time", typeof(string)); table.Columns.Add(dc); ArrayList orders = new OrderDAO().getOrders(Session["name"].ToString(), "failed"); for (int i = 0; i < orders.Count; i++) { Order order = (Order)orders[i]; DataRow dr = table.NewRow(); dr["order_number"] = order.Order_number; dr["quantity"] = order.Quantity; dr["sender"] = order.CollectionContactName; dr["receiver"] = order.RecipientContactName; dr["postway"] = order.Post_way; dr["pay"] = new PackageDAO().getSumMoney(order.Order_number); dr["time"] = order.Order_time.ToString("yy-MM-dd hh:mm"); table.Rows.Add(dr); } return(table); }
public ActionResult Get(ushort id) { if (!Authentication.IsValid()) { return(Json(new { Error = "Not Authenticated" })); } JsonResult json = Json(new { Object = PackageDAO.GetById(id) }); json.MaxJsonLength = int.MaxValue; return(json); }
public static async Task <PackageList> Execute(SearchPackageRequest request) { try { return(await PackageDAO.SearchPackages(request)); } catch (Exception e) { throw; } }
public void FetchAllTest() { var test_data = new PackageDAO(); test_data.FetchAll(); if (test_data == null) { Assert.IsNull(test_data); } Assert.IsNotNull(test_data); }
public static async Task Execute(string id, PackageUpdate update) { try { await PackageDAO.UpdatePackage(id, update); } catch (Exception e) { throw e; } }
public ActionResult GetServices(ushort id) { if (!Authentication.IsValid()) { return(Json(new { Error = "Not Authenticated" })); } JsonResult json = Json(new { services = PackageDAO.GetServicesFromPackage(id) }); json.MaxJsonLength = int.MaxValue; return(json);; }
public PackageTest() { packageService = new PackageService(); packageDao = new PackageDAO(); testPack = new Package(); testPack.UserId = 1; testPack.MedicalID = 1; testPack.ExpiryDate = DateTime.Today; testPack.DistributionCenterID = 1; testPack.ReceivingCenterID = null; testPack.TransactionDate = DateTime.Today; }
public static async Task <Package> Execute(string id) { try { await PackageEntity.ValidatePackageId(id); return(await PackageDAO.GetPackage(id)); } catch (Exception e) { throw e; } }
public static async Task Execute(string id) { try { await PackageEntity.ValidatePackageId(id); await PackageDAO.HardDeletePackage(id); } catch (Exception e) { throw; } }
internal void Start() { if (DataInMemory) { FileStore = new FileStoreMemory(); PackageCollection = new JSONMemoryStore<Package>(); } else { //TODO: allow different types of stores (e.g.: mongodb) FileStore = new FileStoreFilesystem(ConfigurationStore); PackageCollection = new JSONStore<Package>(ConfigurationStore.DatabaseFile.Value); } PackageDAO = new PackageDAO(PackageCollection, FileStore); }
internal void Start() { if (DataInMemory) { FileStore = new FileStoreMemory(); PackageCollection = new JSONMemoryStore <Package>(); } else { //TODO: allow different types of stores (e.g.: mongodb) FileStore = new FileStoreFilesystem(ConfigurationStore); PackageCollection = new JSONStore <Package>(ConfigurationStore.DatabaseFile.Value); } PackageDAO = new PackageDAO(PackageCollection, FileStore); }
public static async Task ValidatePackageId(string id) { try { var idExist = await PackageDAO.CheckIdPackageIdExist(id); if (!idExist) { throw new ValidationException("Id", "Esse pacote nao existe."); } } catch (Exception e) { throw e; } }
[Category("nugetory.Integration.FindPackageControllerGet"), Test]//, Timeout(1000)] public void FindPackageControllerGetTest() { string responseData; Package pkgV003 = PackageDAO.Read(NugetSamplePackages.nugetoryV003.Title, NugetSamplePackages.nugetoryV003.Version).Result; string url = InvokeUrl + GetQuery("IsLatestVersion", "", pkgV003.Title, ""); HttpClient.Invoke(url, "GET", out responseData); string result = GetFindPackageResult(url, new List <Package> { pkgV003 }, true); Assert.AreEqual(result, responseData); }
public static HttpResponseMessage Delete(HttpRequestMessage request, string id, string version) { Package package = PackageDAO.Read(id, version).Result; if (package == null) { throw new PackageNotFoundException(); } if (!FileStore.DeleteFile(package.Id)) { throw new InternalServerErrorException(); } if (!PackageDAO.Delete(package.Id).Result) { throw new InternalServerErrorException(); } return(request.CreateResponse(HttpStatusCode.OK)); }
public void CreateOneTest() { var package = new Package(); package.ID = -1; package.Weight = 2.0; package.Height = 2.0; package.Length = 2.0; package.Weight = 2.0; package.RecordedPackage = 1; package.LiveAnimals = 1; package.CautiousParcel = 1; package.RefregiatedGoods = 1; var test_data = new PackageDAO(); test_data.CreateOne(package); Clean(); Assert.IsNotNull(test_data); }
public void PackageDetailsControllerGetTest() { const string suffix = "/Packages(Id='{0}',Version='{1}')"; string responseData; Package pkgV000 = PackageDAO.Read(NugetSamplePackages.nugetoryV000.Title, NugetSamplePackages.nugetoryV000.Version).Result; string urlSuffix = string.Format(suffix, pkgV000.Title, pkgV000.Version); string url = InvokeUrl + urlSuffix; HttpClient.Invoke(url, "GET", out responseData); Uri uri = new Uri(InvokeUrl + EscapeSuffix(urlSuffix)); string expected = GetDetailsResult(pkgV000, uri); Assert.AreEqual(expected, responseData); }
public static HttpResponseMessage BuildResponse(HttpRequestMessage request, string id, string version) { Package package = PackageDAO.Read(id, version).Result; if (package == null) { throw new PackageNotFoundException(); } HttpResponseMessage res = request.CreateResponse(HttpStatusCode.OK); res.Content = new StringContent(GetDetails(request, package)); res.Content.Headers.Remove("Content-Type"); res.Content.Headers.Add("Content-Type", "application/atom+xml;type=entry;charset=utf-8"); res.Headers.Add("DataServiceVersion", "2.0;"); return(res); }
public ActionResult Insert(string name, string minified_desc, string desc, System.Web.HttpPostedFileWrapper image, string price, string services) { if (!Authentication.IsValid()) { return(Json(new { Error = "Not Authenticated" })); } string base64Image = null; if (image != null) { BinaryReader br = new BinaryReader(image.InputStream); byte[] bytes = br.ReadBytes((Int32)image.InputStream.Length); base64Image = Convert.ToBase64String(bytes); } PackageDAO.Insert(name, minified_desc, desc, base64Image, price, services); Package p = PackageDAO.GetByName(name); return(Json(new { p.Id, Package = CustomHtmlHelper.CustomHtmlHelper.RenderPartialToString("Profile/TableItem/_Package", p, ControllerContext) })); }
public static HttpResponseMessage Download(HttpRequestMessage request, string id, string version) { Package package = PackageDAO.Read(id, version).Result; if (package == null) { throw new PackageNotFoundException(); } Stream fileStream = FileStore.GetFile(package.Id, package.PackageHash); HttpResponseMessage res = request.CreateResponse(HttpStatusCode.OK); res.Content = new StreamContent(fileStream); res.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); return(res); }
public void PackageDetailsControllerDeleteNoApiKeySuccessTest() { ClearAllPackages(); LoadAllPackages(); long originalCount = PackageDAO.Count().Result; ValidateAuthenticationAttribute.ApiKey = null; HttpClient.ApiKey = null; const string suffix = "/Packages(Id='{0}',Version='{1}')"; Package pkgV000 = PackageDAO.Read(NugetSamplePackages.nugetoryV000.Title, NugetSamplePackages.nugetoryV000.Version).Result; string urlSuffix = string.Format(suffix, pkgV000.Title, pkgV000.Version); string url = InvokeUrl + urlSuffix; HttpStatusCode resultCode = HttpClient.Invoke(url, "DELETE"); Assert.AreEqual(HttpStatusCode.OK, resultCode); Assert.AreEqual(originalCount - 1, PackageDAO.Count().Result); }
public void SearchControllerGetTest() { string responseData; string targetFramework = ""; Package pkgV003 = PackageDAO.Read(NugetSamplePackages.nugetoryV003.Title, NugetSamplePackages.nugetoryV003.Version).Result; if (pkgV003.FrameworkAssemblies != null && pkgV003.FrameworkAssemblies.Any()) { targetFramework = pkgV003.FrameworkAssemblies[0].TargetFramework; } string url = InvokeUrl + GetQuery("IsLatestVersion", "", pkgV003.Title, targetFramework, "false", "0", "1"); HttpClient.Invoke(url, "GET", out responseData); string result = GetSearchResult(new List <Package> { pkgV003 }); Assert.AreEqual(result, responseData); }
/// <summary> /// 根据订单号查找订单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_query_order_Click(object sender, EventArgs e) { string track_no = txt_number.Text; // 首先查找 Excel 下单的订单 AutoOrderList autolist = new AutoOrderList(); autolist = new AutoOrderListDAO().getAutoOrderListByTrackNo(track_no); if (autolist.Ea_track_no != track_no) { Package package = new PackageDAO().getPackageByTrackNo(track_no); if (package.Ea_track_no != track_no) { alert("不存在该订单!!"); } else { Order order = new OrderDAO().getOrder(package.Order_number); autolist.Order_no = package.Wp_track_no; autolist.Ea_track_no = track_no; autolist.CollectionContactName = order.CollectionContactName; autolist.RecipientContactName = order.RecipientContactName; autolist.Weight = package.Weight; autolist.Pay_after_discount = package.Pay; autolist.Pay_time = order.Pay_time; packages.Add(autolist); } } else { packages.Add(autolist); } }
public List <Service> GetServicesFromPackage(ushort id) { return(PackageDAO.GetServicesFromPackage(id)); }
public int GetMinPrice() { return(PackageDAO.GetMinPrice()); }