public Stream GetTemplateStream(DocumentTemplateEnum docTemplateType, MarketPlaceEnum marketType, string extension) { return(archiveManager.GetTemplateStream(archiveManager.GetPath(new AltaBO.DocumentRequisite() { section = DocumentSectionEnum.Template, market = marketType, fileName = string.Format("{0}.{1}", docTemplateType, extension), }))); }
public DocumentRequisite GetTemplateRequisite(MarketPlaceEnum market, DocumentTemplateEnum documentTemplate) { if (templateRequisities[documentTemplate] == null) { return(null); } var templateRequisite = templateRequisities[documentTemplate].FirstOrDefault(t => t.market == market); return(templateRequisite); }
private void AddRule(DocumentTemplateEnum documentTemplate, MarketPlaceEnum market, string fileName, string exstension) { if (!templateRequisities.Any(t => t.Key == documentTemplate)) { templateRequisities.Add(documentTemplate, new List <DocumentRequisite>()); } templateRequisities[documentTemplate].Add(new DocumentRequisite() { section = DocumentSectionEnum.Template, fileName = string.Format("{0}.{1}", fileName, exstension), market = market, extension = exstension }); }
private void AddRule(DocumentTemplateEnum documentTemplate, MarketPlaceEnum market, string exstension) { AddRule(documentTemplate, market, documentTemplate.ToString(), exstension); }
public string GetTemplate(DocumentRequisite documentRequisite, DocumentTemplateEnum documentTemplate) { string extension = ".docx"; switch (documentRequisite.market) { case MarketPlaceEnum.UTB: if (documentTemplate == DocumentTemplateEnum.Order) { extension = ".xlsx"; } break; case MarketPlaceEnum.ETS: if (documentRequisite.type == DocumentTypeEnum.TechSpecs || documentTemplate == DocumentTemplateEnum.Procuratory) { extension = ".xlsx"; } break; case MarketPlaceEnum.KazETS: if (documentTemplate == DocumentTemplateEnum.SupplierOrderKorund || documentTemplate == DocumentTemplateEnum.SupplierOrderAkAltyn || documentTemplate == DocumentTemplateEnum.TechSpec || documentTemplate == DocumentTemplateEnum.CoverLetter || documentTemplate == DocumentTemplateEnum.CoverLetterAkAltyn || documentTemplate == DocumentTemplateEnum.CoverLetterKorund) { extension = ".xlsx"; } break; case MarketPlaceEnum.Caspy: if (documentTemplate == DocumentTemplateEnum.Order) { extension = ".xlsx"; } break; } if (documentRequisite.type == DocumentTypeEnum.CompanyProfile) { extension = ".xlsx"; } var templateFileName = ipPath + archiveRootPath.Replace("/", "") + "\\Templates\\" + documentRequisite.market + "\\" + documentTemplate + extension; var dateFolder = ipPath + archiveRootPath.Replace("/", "") + "\\Auctions\\" + documentRequisite.market + "\\" + documentRequisite.date.ToShortDateString(); var endFolder = dateFolder + "\\" + documentRequisite.number.Replace("/", "_"); var oldEndFolder = dateFolder + "\\" + (documentRequisite.market == MarketPlaceEnum.ETS ? documentRequisite.number.Length > 4 ? documentRequisite.number.Substring(documentRequisite.number.Length - 4) : documentRequisite.number : documentRequisite.number).Replace("/", "_"); if (!Directory.Exists(dateFolder)) { Directory.CreateDirectory(dateFolder); } if (Directory.Exists(oldEndFolder)) { endFolder = oldEndFolder; } if (!Directory.Exists(endFolder)) { Directory.CreateDirectory(endFolder); } try { File.Copy(templateFileName, endFolder + "\\" + documentRequisite.fileName, true); return(endFolder + "\\" + documentRequisite.fileName); } catch (Exception ex) { AppJournal.Write("Template copy", "Err: " + ex.ToString(), true); return(null); } }