private void UpdateItemMetadata(ContentData item, DataRow row) { foreach (DataColumn column in MetadataColumns) { ContentMetaData metaData = item.MetaData.SingleOrDefault(cmd => cmd.Name == column.ColumnName); if (metaData == null) { row.LogContentWarn( "metadata named '{0}' not found", column.ColumnName); continue; } row.LogContentInfo("setting metadata field '{0}' to '{1}'", metaData.Name, row[column]); metaData.Text = row[column].ToString(); } DoContentUpdate(row, item); }
protected void DoContentAdd(DataRow row, ContentData content, short timeouts = 0, bool failOnFault = false) { try { if (HasAuthentication) { DoAPIAddCall(content); row.LogContentInfo("saved successfully with id {0}.", content.Id); } else { row.LogContentWarn("does not have authentication."); } } catch (TimeoutException te) { if (timeouts < 10) { row.LogContentInfo("save timed out. Trying again."); Thread.Sleep(TimeoutWait); DoContentAdd(row, content, ++timeouts); } else { row.LogContentError("failed to save.", 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(); DoContentAdd(row, content, failOnFault: true); } else { row.LogContentError("failed to save.", fe); } } catch (CommunicationException ce) { if (!failOnFault) { row.LogContentWarn("had communication error. Waiting and then retrying."); Thread.Sleep(TimeoutWait); DoContentAdd(row, content, failOnFault: true); } else { LogUpdateError(row, ce); } } catch (Exception ex) { row.LogContentError("failed to save.", ex); } }
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); } }
/// <summary> /// Saves a new content item with the values from the data row. /// The 'title' and 'html' fields are saved. The item is placed /// in the folder found using the 'folderPath' column value in the data row. /// </summary> /// <param name="row">Row with content data.</param> protected virtual void SaveContent(DataRow row) { row.LogContentInfo("saving in folder '{0}'", row["folderPath"]); long folderId = _folderUtil.GetFolderId(row); if (folderId <= 0) { row.LogContentWarn("can't save item because no folder was found for it."); return; } ContentData content = GetNewContentDataObject(); SetContentFields(row, content); content.FolderId = folderId; DoContentAdd(row, content); }