private static TaxonomyItemData CheckForExistingTaxonomyDataItem( IEnumerable<TaxonomyItemData> existingDataItems, TaxonomyData tax, DataRow row) { TaxonomyItemData data = existingDataItems.FirstOrDefault(d => d.TaxonomyId == tax.Id); if (data != null) { row.LogContentInfo( "Found an existing taxonomy data item for taxonomy '{0}'", tax.Name); } else { data = new TaxonomyItemData(); row.LogContentInfo( "Did not find an existing taxonomy data item for taxonomy '{0}'", tax.Name); } return data; }
private void DoUpdate( TaxonomyItemData data, DataRow row, ContentData existingItem, short timeouts = 0, bool failOnFault = false) { try { if (HasAuthentication) { TaxItemManager.Add(data); row.LogContentInfo("updated successfully with id {0}.", existingItem.Id); } else { row.LogContentWarn("does not have authentication."); } } catch (TimeoutException te) { if (timeouts < 10) { row.LogContentInfo("update timed out. Trying again."); Thread.Sleep(TimeoutWait); DoUpdate(data, row, existingItem, ++timeouts); } else { LogUpdateError(row, te); } } catch (FaultException fe) { if (!failOnFault && fe.Message.Contains("The current user does not have permission to carry out this request")) { row.LogContentWarn("had authentication error. Re-authenticating then retrying."); Authenticate(); DoUpdate(data, row, existingItem, failOnFault: true); } else { LogUpdateError(row, fe); } } catch (CommunicationException ce) { if (!failOnFault) { row.LogContentWarn("had communication error. Waiting and then retrying."); Thread.Sleep(TimeoutWait); DoUpdate(data, row, existingItem, failOnFault: true); } else { LogUpdateError(row, ce); } } catch (Exception ex) { LogUpdateError(row, ex); } }
private DirectoryContentData[] StepTo(TaxonomyItemData[] taxitems) { System.Collections.Generic.List<DirectoryContentData> idList = new System.Collections.Generic.List<DirectoryContentData>(); if ((taxitems != null) && taxitems.Length > 0) { for (int i = 0; i <= (taxitems.Length - 1); i++) { DirectoryContentData dcFav = new DirectoryContentData(); dcFav.Id = taxitems[i].TaxonomyItemId; dcFav.Title = taxitems[i].TaxonomyItemTitle; dcFav.Html = taxitems[i].TaxonomyItemHtml; dcFav.LanguageId = taxitems[i].TaxonomyItemLanguage; dcFav.Image = taxitems[i].TaxonomyItemImage; dcFav.ImageThumbnail = taxitems[i].TaxonomyItemThumbnail; dcFav.Teaser = taxitems[i].TaxonomyItemTeaser; dcFav.Quicklink = taxitems[i].TaxonomyItemQuickLink; idList.Add(dcFav); } } return idList.ToArray(); }