public void Process()
        {
            importRunning = true;
            try
            {
                BookXmlTransformHelper         _xmlHelper          = new BookXmlTransformHelper();
                BookSitecoreItemCreationHelper _bookSitecoreHelper = new BookSitecoreItemCreationHelper();
                List <string> newFtpFiles = new List <string>();
                bool          loadFromLocal;
                bool.TryParse(Sitecore.Configuration.Settings.GetSetting("LoadOnixFeedFromLocal"), out loadFromLocal);
                if (loadFromLocal)
                {
                    string localXmlFilePath = System.Web.Hosting.HostingEnvironment.MapPath("~/upload/" + xmlFilePathLocal);
                    newFtpFiles.Add(localXmlFilePath);
                }
                else
                {
                    List <string> ftpFiles = _xmlHelper.GetListOfExistingFilesNames();
                    newFtpFiles = _xmlHelper.GetNewFtpFiles(isImportFullVersion, ftpFiles);
                }

                if (newFtpFiles != null && newFtpFiles.Count > 0)
                {
                    foreach (string newFtpFile in newFtpFiles)
                    {
                        BooksImportLog.Info("----------------START BOOK FULL IMPORT SERVICE---------------");

                        BooksImportLog.Info("Start getting books' data.....");
                        XmlNodeList data  = _xmlHelper.ReadBookDataFromXmlFeed(newFtpFile, loadFromLocal);
                        List <Book> books = _xmlHelper.ConvertXmlNodeListToObjects(data);
                        BooksImportLog.Info("End getting books' data.....");

                        BooksImportLog.Info("Start creating books' items in Sitecore.....");
                        _bookSitecoreHelper.ImportBookItemsToSitecore(books);
                        BooksImportLog.Info("End creating books' items in Sitecore.....");
                        //_xmlHelper.DeleteProcessFtpFiles(newFtpFile);
                        //_xmlHelper.MoveProcessedFtpFiles(newFtpFile, FTPFullVersionArchivesFolderName);
                    }
                }



                BooksImportLog.Info("Start updating authors' active statuses.....");
                AuthorSitecoreItemCreationHelper.UpdateAuthorActiveStatus();
                BooksImportLog.Info("End updating authors' active statuses.....");
                BooksImportLog.Info("-----------------END BOOK FULL IMPORT SERVICE---------------");
            }
            catch (Exception ex)
            {
                BooksImportLog.Error(ex.Message);
            }
            importRunning = false;
        }
Exemple #2
0
        public void Process()
        {
            importRunning = true;
            try
            {
                BookXmlTransformHelper         _xmlHelper          = new BookXmlTransformHelper();
                BookSitecoreItemCreationHelper _bookSitecoreHelper = new BookSitecoreItemCreationHelper();

                List <string> ftpFiles    = _xmlHelper.GetListOfExistingFilesNames();
                List <string> newFtpFiles = _xmlHelper.GetNewFtpFiles(isImportFullVersion, ftpFiles);
                if (newFtpFiles != null && newFtpFiles.Count > 0)
                {
                    BooksImportLog.Info("----------------START BOOK CHANGED FILE IMPORT SERVICE---------------");
                    foreach (string newFtpFile in newFtpFiles)
                    {
                        BooksImportLog.Info("Start getting books' data.....");
                        XmlNodeList data  = _xmlHelper.ReadBookDataFromXmlFeed(newFtpFile, false);
                        List <Book> books = _xmlHelper.ConvertXmlNodeListToObjects(data);
                        BooksImportLog.Info("End getting books' data.....");

                        BooksImportLog.Info("Start creating books' items in Sitecore.....");
                        _bookSitecoreHelper.ImportBookItemsToSitecore(books);
                        BooksImportLog.Info("End creating books' items in Sitecore.....");
                        //_xmlHelper.DeleteProcessFtpFiles(newFtpFile);
                        //_xmlHelper.MoveProcessedFtpFiles(newFtpFile, FTPChangingVersionArchivesFolderName);
                    }
                }

                BooksImportLog.Info("Start updating authors' active statuses.....");
                AuthorSitecoreItemCreationHelper.UpdateAuthorActiveStatus();
                BooksImportLog.Info("End updating authors' active statuses.....");
                BooksImportLog.Info("-----------------END BOOK CHANGED FILE IMPORT SERVICE---------------");
            }
            catch (Exception ex)
            {
                BooksImportLog.Error(ex.Message);
            }
            importRunning = false;
        }