protected override void Process() { foreach (Connector connector in base.Connectors.Where(x => ((ConnectorType)x.ConnectorType).Has(ConnectorType.FileExport))) { if (connector.ConnectorID != 666) { continue; } //#region Assortiment string path = "F:/tmp/BEX"; //if (!string.IsNullOrEmpty(path)) //{ // #region ProductGroups // using (var unit = GetUnitOfWork()) // { // var repoContentProductGroup = unit.Scope.Repository<ContentProductGroup>().Include(c => c.ProductGroupMapping); // var repoProductGroupMapping = unit.Scope.Repository<ProductGroupMapping>().Include(c => c.ProductGroup); // var pra = repoContentProductGroup.GetAll(x => x.ConnectorID == 666).ToList(); // List<ProductGroupMapping> mappingslist = repoProductGroupMapping.GetAll(x => x.ConnectorID == 666).ToList(); // List<int> pgList = new List<int>(); // //foreach(var a in assortment){ // // var el = GetProductGroupHierarchy(a, 2, unit.Scope.Repository<ProductGroupLanguage>(), mappingslist); // //} // XElement element = new XElement("ProductGroupHierarchy"); // foreach (var mapping in pra) // { // if (!pgList.Contains(mapping.ProductGroupMappingID)) // { // var map = mappingslist.Where(x => x.ProductGroupMappingID == mapping.ProductGroupMappingID && mapping.ConnectorID == 666).FirstOrDefault(); // if (map == null) // continue; // GetProductGroupHierarchy(map, element, 2, unit.Scope.Repository<ProductGroupLanguage>(), mappingslist); // pgList.Add(mapping.ProductGroupMappingID); // } // } // var elements = (from e in element.Elements("ProductGroup") // select e).Distinct(); // XElement element2 = new XElement("ProductGroupHierarchy"); // element2.Add(elements); // XDocument productGroupsDoc = new XDocument(); // productGroupsDoc.Add(element2); // string fileName2 = string.Format("ProductGroups_{0}_{1}.xml", connector.ConnectorID, DateTime.Now.ToString("yyyyMMddHHmmss")); // productGroupsDoc.Save(Path.Combine(path, fileName2)); // using (var stream = new MemoryStream()) // { // productGroupsDoc.Save(stream, SaveOptions.DisableFormatting); // //DmisUtilty.UploadFiles(connector, stream, fileName2, log); // } // } // #endregion // AssortmentServiceSoapClient soap = new AssortmentServiceSoapClient(); // XDocument products; // products = XDocument.Parse(soap.GetAdvancedPricingAssortment(connector.ConnectorID, false, false, null, null, true, 2)); // #region Products // string fileName = string.Format("Assortment_{0}_{1}.xml", connector.ConnectorID, DateTime.Now.ToString("yyyyMMddHHmmss")); // products.Save(Path.Combine(path, fileName)); // using (var stream = new MemoryStream()) // { // products.Save(stream, SaveOptions.DisableFormatting); // DmisUtilty.UploadFiles(connector, stream, fileName, log); // } // #endregion //} //else //{ // log.AuditCritical(string.Format("Export XML failed for {0}, XmlExportPath not set", connector.Name)); //} //log.DebugFormat("Finish Process XML Assortment import for {0}", connector.Name); //#endregion #region Images log.DebugFormat("Start Process XML Image export for {0}", connector.Name); if (!string.IsNullOrEmpty(path)) { AssortmentServiceSoapClient soap = new AssortmentServiceSoapClient(); XDocument products; products = XDocument.Parse(soap.GetFTPAssortmentImages(connector.ConnectorID)); string file = Path.Combine(path, string.Format("Images_{0}.xml", connector.ConnectorID)); if (File.Exists(file)) { File.Delete(file); } products.Save(file, SaveOptions.DisableFormatting); } else { log.AuditCritical(string.Format("Export XML failed for {0}, XmlExportPath not set", connector.Name)); } log.DebugFormat("Finish Process XML Image import for {0}", connector.Name); #endregion log.DebugFormat("Start Process XML Content export for {0} language {1}", connector.Name, 2); if (!string.IsNullOrEmpty(path)) { AssortmentServiceSoapClient soap = new AssortmentServiceSoapClient(); XDocument content = XDocument.Parse(soap.GetAssortmentContentDescriptionsByLanguage(connector.ConnectorID, null, 2)); string contentFile = Path.Combine(path, string.Format("Content_{0}_{1}.xml", connector.ConnectorID, 2)); if (File.Exists(contentFile)) { File.Delete(contentFile); } content.Save(contentFile, SaveOptions.DisableFormatting); XDocument attributes = XDocument.Parse(soap.GetAttributesAssortmentByLanguage(connector.ConnectorID, null, null, 2)); string attributeFile = Path.Combine(path, string.Format("Attribute_{0}_{1}.xml", connector.ConnectorID, 2)); if (File.Exists(attributeFile)) { File.Delete(attributeFile); } attributes.Save(attributeFile, SaveOptions.DisableFormatting); } else { log.AuditCritical(string.Format("Export XML failed for {0}, XmlExportPath not set", connector.Name)); } log.DebugFormat("Finish Process XML Content import for {0} language {1}", connector.Name, 2); } }
protected override void Process() { using(var unit = GetUnitOfWork()){ foreach (ConnectorRelation connectorRelation in unit.Scope.Repository<ConnectorRelation>().GetAll(x => x.IsActive && ) { string drive = connector.ConnectorSettings.GetValueByKey("XmlExportPath", string.Empty); bool networkDrive = false; //string drive = @"\\SOL\Company_Shares\Database Backup"; bool.TryParse(connector.ConnectorSettings.GetValueByKey("IsNetorkDrive", "false"), out networkDrive); NetworkExportUtility util = new NetworkExportUtility(); if (networkDrive) { drive = util.ConnectorNetworkPath(drive); } string path = drive; #region Assortiment if (((ConnectorType)connector.ConnectorType).Has(ConnectorType.ShopAssortment) || ((ConnectorType)connector.ConnectorType).Has(ConnectorType.WebAssortment)) { foreach (var language in connector.ConnectorLanguages) { log.DebugFormat("Start Process XML Assortment export for {0} language {1}", connector.Name, language.Language.Name); if (!string.IsNullOrEmpty(path)) { AssortmentServiceSoapClient soap = new AssortmentServiceSoapClient(); XDocument products; products = XDocument.Parse(soap.GetAdvancedPricingAssortment(connector.ConnectorID, false, false, null, null, true, language.LanguageID)); string file = Path.Combine(path, string.Format("products_{0}_{1}.xml", connector.ConnectorID, language.LanguageID)); if (File.Exists(file)) File.Delete(file); products.Save(file, SaveOptions.DisableFormatting); } else { log.AuditCritical(string.Format("Export XML failed for {0}, XmlExportPath not set", connector.Name)); } log.DebugFormat("Finish Process XML Assortment import for {0}", connector.Name); } } #endregion #region Images if (((ConnectorType)connector.ConnectorType).Has(ConnectorType.Images)) { log.DebugFormat("Start Process XML Image export for {0}", connector.Name); if (!string.IsNullOrEmpty(path)) { AssortmentServiceSoapClient soap = new AssortmentServiceSoapClient(); XDocument products; products = XDocument.Parse(soap.GetFTPAssortmentImages(connector.ConnectorID)); string file = Path.Combine(path, string.Format("Images_{0}.xml", connector.ConnectorID)); if (File.Exists(file)) File.Delete(file); products.Save(file, SaveOptions.DisableFormatting); } else { log.AuditCritical(string.Format("Export XML failed for {0}, XmlExportPath not set", connector.Name)); } log.DebugFormat("Finish Process XML Image import for {0}", connector.Name); } #endregion #region content if (((ConnectorType)connector.ConnectorType).Has(ConnectorType.Content)) { foreach (var language in connector.ConnectorLanguages) { log.DebugFormat("Start Process XML Content export for {0} language {1}", connector.Name, language.Language.Name); if (!string.IsNullOrEmpty(path)) { AssortmentServiceSoapClient soap = new AssortmentServiceSoapClient(); XDocument content = XDocument.Parse(soap.GetAssortmentContentDescriptionsByLanguage(connector.ConnectorID, null, language.LanguageID)); string contentFile = Path.Combine(path, string.Format("Content_{0}_{1}.xml", connector.ConnectorID, language.LanguageID)); if (File.Exists(contentFile)) File.Delete(contentFile); content.Save(contentFile, SaveOptions.DisableFormatting); XDocument attributes = XDocument.Parse(soap.GetAttributesAssortmentByLanguage(connector.ConnectorID, null, null, language.LanguageID)); string attributeFile = Path.Combine(path, string.Format("Attribute_{0}_{1}.xml", connector.ConnectorID, language.LanguageID)); if (File.Exists(attributeFile)) File.Delete(attributeFile); attributes.Save(attributeFile, SaveOptions.DisableFormatting); } else { log.AuditCritical(string.Format("Export XML failed for {0}, XmlExportPath not set", connector.Name)); } log.DebugFormat("Finish Process XML Content import for {0} language {1}", connector.Name, language.Language.Name); } } #endregion if (networkDrive) { util.DisconnectNetworkPath(drive); } } } }