public Order Insert() { var files = HttpContext.Current.Request.Files; if (!Request.Content.IsMimeMultipartContent() || files.Count == 0 || HttpContext.Current.Request.Form.Count == 0) { return(null); } var orderFile = files["Order"]; var orderOrigin = files["OrderOrigin"]; var agreement = files["Agreement"]; if (orderFile == null) { return(null); } var currentDate = DateTime.Now; var form = new FormOrder(); form.siteId = int.Parse(HttpContext.Current.Request.Form.Get("siteId")); form.number = HttpContext.Current.Request.Form.Get("number"); //form.customerid = int.Parse(HttpContext.Current.Request.Form.Get("customerId")); var filesListId = ArchiveManager.CreateFilesList("Заявки от заказчика"); if (ArchiveManager.PutDocument(orderFile.InputStream, new DocumentRequisite() { date = currentDate, fileName = orderFile.FileName, market = (MarketPlaceEnum)form.siteId, number = form.number, section = DocumentSectionEnum.Order, type = DocumentTypeEnum.OrderSource }, filesListId) < 1) { return(null); } if (orderOrigin != null) { if (ArchiveManager.PutDocument(orderOrigin.InputStream, new DocumentRequisite() { date = currentDate, fileName = orderOrigin.FileName, market = (MarketPlaceEnum)form.siteId, number = form.number, section = DocumentSectionEnum.Order, type = DocumentTypeEnum.OrderOriginal }, filesListId) < 1) { return(null); } } if (agreement != null) { if (ArchiveManager.PutDocument(agreement.InputStream, new DocumentRequisite() { date = currentDate, fileName = agreement.FileName, market = (MarketPlaceEnum)form.siteId, number = form.number, section = DocumentSectionEnum.Order, type = DocumentTypeEnum.AgreementSource }, filesListId) < 1) { return(null); } } var countShemes = HttpContext.Current.Request.Form.Get("count_shemes"); if (countShemes != null) { var countShemesFiles = int.Parse(countShemes); if (countShemesFiles > 0) { for (var i = 0; i < countShemesFiles; i++) { var sheme = files[string.Format("Sheme{0}", i)]; if (sheme != null) { if (ArchiveManager.PutDocument(sheme.InputStream, new DocumentRequisite() { date = currentDate, fileName = sheme.FileName, market = (MarketPlaceEnum)form.siteId, number = form.number, section = DocumentSectionEnum.Order, type = DocumentTypeEnum.Scheme }, filesListId) < 1) { return(null); } } } } } var order = new Order(); order.Date = currentDate; order.Deadline = currentDate; order.Number = form.number; order.statusId = 1; //order.customerid = form.customerid; order.customerid = CurrentUser.CustomerId; order.siteId = form.siteId; order.filesListId = filesListId; var orderId = DataManager.CreateOrder(order, CurrentUser.Id); if (orderId != default(int)) { return(order); } return(null); #endregion }
public static bool AppendProcuratory(IDataManager dataManager, ArchiveManager archiveManager, List <Procuratory> procuratories, string pathToTemplate, string pathToScan) { var procuratory = procuratories.First(); if (procuratory == null) { return(false); } var auction = dataManager.GetAuction((int)procuratory.auctionId); if (auction == null) { return(false); } var supplierOrder = dataManager.GetSupplierOrder(auction.Id, procuratory.SupplierId); if (supplierOrder == null) { return(false); } var supplierJournal = dataManager.GetSupplierJournal(supplierOrder.brokerid, procuratory.SupplierId); if (supplierJournal == null) { return(false); } var filelistId = archiveManager.CreateFilesList("Списко поручений"); var scanId = archiveManager.PutDocument(pathToScan, new DocumentRequisite() { date = auction.Date, market = (MarketPlaceEnum)auction.SiteId, number = auction.Number, fileName = Path.GetFileName(pathToScan), section = DocumentSectionEnum.Auction, type = DocumentTypeEnum.Procuratory }, filelistId); if (scanId < 1) { return(false); } var templateId = archiveManager.PutDocument(pathToTemplate, new DocumentRequisite() { date = auction.Date, market = (MarketPlaceEnum)auction.SiteId, number = auction.Number, fileName = Path.GetFileName(pathToScan), section = DocumentSectionEnum.Auction, type = DocumentTypeEnum.ProcuratorySource }, filelistId); if (templateId < 1) { return(false); } procuratories.ForEach(p => p.fileListId = filelistId); return(dataManager.AddProcuratories(auction.Id, procuratories)); }
public Order KaspyInsert() { var files = HttpContext.Current.Request.Files; if (!Request.Content.IsMimeMultipartContent() || files.Count == 0 || HttpContext.Current.Request.Form.Count == 0) { return(null); } var assignment = files["assignment"]; var specification = files["specification"]; var suppliers = files["suppliers"]; if (assignment == null) { return(null); } var currentDate = DateTime.Now; var form = new FormOrder(); form.siteId = int.Parse(HttpContext.Current.Request.Form.Get("siteId")); form.number = HttpContext.Current.Request.Form.Get("number"); //form.customerid = int.Parse(HttpContext.Current.Request.Form.Get("customerId")); var filesListId = ArchiveManager.CreateFilesList("Заявки от заказчика"); if (ArchiveManager.PutDocument(assignment.InputStream, new DocumentRequisite() { date = currentDate, fileName = assignment.FileName, market = (MarketPlaceEnum)form.siteId, number = form.number, section = DocumentSectionEnum.Order, type = DocumentTypeEnum.OrderSource }, filesListId) < 1) { return(null); } if (specification != null) { if (ArchiveManager.PutDocument(specification.InputStream, new DocumentRequisite() { date = currentDate, fileName = specification.FileName, market = (MarketPlaceEnum)form.siteId, number = form.number, section = DocumentSectionEnum.Order, type = DocumentTypeEnum.TechSpecs }, filesListId) < 1) { return(null); } } if (suppliers != null) { if (ArchiveManager.PutDocument(suppliers.InputStream, new DocumentRequisite() { date = currentDate, fileName = suppliers.FileName, market = (MarketPlaceEnum)form.siteId, number = form.number, section = DocumentSectionEnum.Order, type = DocumentTypeEnum.ApplicantsFromCustomer, }, filesListId) < 1) { return(null); } } var order = new Order(); order.Date = currentDate; order.Deadline = currentDate; order.Number = form.number; order.statusId = 1; order.customerid = CurrentUser.CustomerId; order.siteId = form.siteId; order.filesListId = filesListId; var orderId = DataManager.CreateOrder(order, CurrentUser.Id); if (orderId != default(int)) { return(order); } return(null); }
public HttpStatusCode CreateSupplierOrder() { if (!Request.Content.IsMimeMultipartContent()) { throw new HttpResponseException(HttpStatusCode.MethodNotAllowed); } var files = HttpContext.Current.Request.Files; var form = HttpContext.Current.Request.Form; if (files == null || files["file"] == null || files.Count == 0 || form == null || form.Count == 0) { throw new HttpResponseException(HttpStatusCode.BadRequest); } var scanOrder = files["file"]; var formData = JObject.Parse(form.Get("form")); var auction = DataManager.GetAuction((int)formData["auctionId"]); var supplier = DataManager.GetSupplier((int)formData["supplierId"]); var contract = DataManager.GetContractsByCompany(supplier.companyId, (int)formData["brokerId"], auction.SiteId); if (auction == null || auction.StatusId != 4 || supplier == null || contract.Count == 0) { throw new HttpResponseException(HttpStatusCode.NotFound); } var archive = new ArchiveManager(DataManager); var fileListId = archive.CreateFilesList("Заявка от поставщика"); if (archive.PutDocument(scanOrder.InputStream, new DocumentRequisite() { date = auction.Date, market = (MarketPlaceEnum)auction.SiteId, filesListId = fileListId, number = auction.Number, fileName = scanOrder.FileName, section = DocumentSectionEnum.Auction, type = DocumentTypeEnum.SupplierOrder }) < 1) { throw new HttpResponseException(HttpStatusCode.InternalServerError); } var supplierOrder = new SupplierOrder() { fileListId = fileListId, contractId = contract[0].id, status = new Status() { Id = (int)StatusEnum.Declared }, lots = new List <Lot>(), SupplierId = (int)formData["supplierId"] }; foreach (var lotId in formData["lots"].ToList()) { supplierOrder.lots.Add(DataManager.GetLot((int)lotId)); } if (!DataManager.AddSupllierOrder((int)formData["auctionId"], supplierOrder)) { throw new HttpResponseException(HttpStatusCode.InternalServerError); } return(HttpStatusCode.Created); }