public void Process(SaveArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            // we had errors, and we got a post-back result of no, don't overwrite
            if (args.Result == "no" || args.Result == "undefined")
            {
                args.SaveAnimation = false;
                args.AbortPipeline();
                return;
            }

            // we had errors, and we got a post-back result of yes, allow overwrite
            if (args.IsPostBack) return;

            string error = GetErrorValue(args);

            // no errors detected, we're good
            if (string.IsNullOrEmpty(error)) return;

            // occasionally if you serialize an item "too fast" after changing it, the ShadowWriter's async operations
            // will be in process or have not yet begun to update the serialized item.
            // in these circumstances, we wish to treat a "conflict" or exception as a possible false positive, wait a bit for the ShadowWriter,
            // and try again. If it fails 4x in a row, 500ms apart, it's considered an unrecoverable conflict and we show the error.
            const int retries = 4;
            for (int retryCount = 0; retryCount < retries; retryCount++)
            {
                Thread.Sleep(500);
                error = GetErrorValue(args);
                if (string.IsNullOrEmpty(error)) return;
            }

            Sitecore.Web.UI.Sheer.SheerResponse.Confirm(error);
            args.WaitForPostBack();
        }
		public void Process(SaveArgs args)
		{
			Assert.ArgumentNotNull(args, "args");

			if (!args.HasSheerUI)
			{
				return;
			}

			// we had errors, and we got a post-back result of no, don't overwrite
			if (args.Result == "no" || args.Result == "undefined")
			{
				args.SaveAnimation = false;
				args.AbortPipeline();
				return;
			}

			// we had errors, and we got a post-back result of yes, allow overwrite
			if (args.IsPostBack) return;

			string error = GetDialogText(args);

			// no errors detected, we're good
			if (string.IsNullOrEmpty(error)) return;
			
			SheerResponse.Confirm(error);
			args.WaitForPostBack();
		}
        protected override string GetDialogText(SaveArgs args)
        {
            foreach (var item in args.Items)
            {
                Item existingItem = Client.ContentDatabase.GetItem(item.ID, item.Language, item.Version);

                Assert.IsNotNull(existingItem, "Existing item {0} did not exist! This should never occur.", item.ID);

                var existingSitecoreItem = new ItemData(existingItem);

                if (_configurations.Any(configuration =>
                {
                    if (!configuration.Resolve <IUnicornDataProviderConfiguration>().EnableTransparentSync&&
                        configuration.Resolve <IPredicate>().Includes(existingSitecoreItem).IsIncluded&&
                        configuration.Resolve <IEvaluator>().ShouldPerformConflictCheck(existingItem))
                    {
                        return(true);
                    }

                    return(false);
                }))
                {
                    return(GetMessage(existingSitecoreItem));
                }
            }

            return(null);
        }
Example #4
0
        private void Savebtn_Click(object sender, EventArgs e)
        {
            SaveArgs args;

            if (nametxtbox.Text == "")
            {
                MessageBox.Show("Введите название задачи", "Внимание", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                System.Media.SystemSounds.Exclamation.Play();
                return;
            }
            string type = "";

            if (StartTypeTask.Checked)
            {
                type = "start";
            }
            else if (endType.Checked)
            {
                type = "end";
            }
            else
            {
                type = "center";
            }
            args = new SaveArgs(nametxtbox.Text, descrtxtbox.Text, type, Convert.ToInt32(timenud.Value));
            SavingChanges?.Invoke(this, args);
            this.Close();
        }
        /// <summary>
        /// Makes all available content editor forms save their information to the sitecore item fields.
        /// </summary>
        private void SaveEditorFormData(bool alert, IEnumerable <FieldSuiteEditor> editors, string postAction)
        {
            foreach (FieldSuiteEditor editor in editors)
            {
                LockItem(editor.Item);

                Hashtable fieldInfo = editor.FieldInfo;
                SaveArgs  args      = new SaveArgs(GetSavePacket(fieldInfo).XmlDocument)
                {
                    SaveAnimation = false
                };
                if (!string.IsNullOrEmpty(postAction))
                {
                    args.PostAction = postAction;
                }
                Context.ClientPage.Start("saveUI", (ClientPipelineArgs)args);
                if (args.Error.Length > 0)
                {
                    SheerResponse.Alert(args.Error, new string[0]);
                    return;
                }

                editor.ClientPage.Modified = false;
            }

            if (alert)
            {
                SheerResponse.Alert("Content Saved", new string[0]);
            }
        }
        public void Process(SaveArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            // we had errors, and we got a post-back result of no, don't overwrite
            if (args.Result == "no" || args.Result == "undefined")
            {
                args.SaveAnimation = false;
                args.AbortPipeline();
                return;
            }

            // we had errors, and we got a post-back result of yes, allow overwrite
            if (args.IsPostBack)
            {
                return;
            }

            string error = GetErrorValue(args);

            // no errors detected, we're good
            if (string.IsNullOrEmpty(error))
            {
                return;
            }

            Sitecore.Web.UI.Sheer.SheerResponse.Confirm(error);
            args.WaitForPostBack();
        }
		protected override string GetDialogText(SaveArgs args)
		{
			foreach (var item in args.Items)
			{
				Item existingItem = Client.ContentDatabase.GetItem(item.ID, item.Language, item.Version);

				Assert.IsNotNull(existingItem, "Existing item {0} did not exist! This should never occur.", item.ID);

				var existingSitecoreItem = new ItemData(existingItem);

				if (_configurations.Any(configuration =>
				{
					if (!configuration.Resolve<IUnicornDataProviderConfiguration>().EnableTransparentSync &&
						configuration.Resolve<IPredicate>().Includes(existingSitecoreItem).IsIncluded &&
						configuration.Resolve<IEvaluator>().ShouldPerformConflictCheck(existingItem))
						return true;

					return false;
				}))
				{
					return GetMessage(existingSitecoreItem);
				}
			}

			return null;
		}
Example #8
0
        private void SaveInternal(SaveArgs saveArgs)
        {
            try
            {
                if (!saveArgs.SaveDataIsValid)
                {
                    throw new System.InvalidOperationException("Editor contains invalid data.");
                }

                if (saveArgs.DataWillOverwrite)
                {
                    var msg = MessageTemplate.GetConfirmationBox("Save",
                                                                 saveArgs.WillOverwriteMessage,
                                                                 () => saveArgs.WriteToFileDelegate() //on yes
                                                                 );

                    Game.MessageBox(msg);
                }
                else
                {
                    saveArgs.WriteToFileDelegate();

                    Game.MessageBox("Save", saveArgs.SuccessMessage);
                }
            }
            catch (System.Exception e)
            {
                Game.MessageBox("Editor Error", $"Unable to save editor session: {e}", new ButtonTemplate("Dang it, Eric"));
            }
        }
        /// <summary>
        /// Called when the item has saved.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public void OnItemSaved([NotNull] SaveArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            foreach (Item item in args.SavedItems)
            {
                this.RecalculateOrder(item);
            }
        }
Example #10
0
        public virtual void Process(SaveArgs args)
        {
            Assert.ArgumentNotNull(args, nameof(args));

            if (args.IsPostBack)
            {
                if (args.Result == "no")
                {
                    args.AbortPipeline();
                }

                args.IsPostBack = false;

                return;
            }

            if (args.Items == null)
            {
                return;
            }

            foreach (var saveItem in args.Items)
            {
                if (!string.IsNullOrEmpty(saveItem.Revision))
                {
                    Item existingItem = Client.ContentDatabase.GetItem(saveItem.ID, saveItem.Language, saveItem.Version);
                    if (existingItem == null)
                    {
                        continue;
                    }

                    // added: ignore transparent synced items, whose revisions are randomly generated
                    if (existingItem.Statistics.UpdatedBy.Equals(UnicornDataProvider.TransparentSyncUpdatedByValue, StringComparison.Ordinal))
                    {
                        continue;
                    }

                    string cleanedExistingRevision = existingItem[FieldIDs.Revision].Replace("-", string.Empty);
                    string cleanedNewRevision      = saveItem.Revision.Replace("-", string.Empty);
                    if (cleanedExistingRevision.Equals(cleanedNewRevision, StringComparison.InvariantCultureIgnoreCase) || EditorConstants.IgnoreRevision.Equals(cleanedNewRevision, StringComparison.InvariantCultureIgnoreCase))
                    {
                        continue;
                    }

                    if (!args.HasSheerUI)
                    {
                        break;
                    }

                    SheerResponse.Confirm("One or more items have been changed.\n\nDo you want to overwrite these changes?");

                    args.WaitForPostBack();

                    break;
                }
            }
        }
 public void Process(SaveArgs args)
 {
     foreach (Sitecore.Pipelines.Save.SaveArgs.SaveItem saveItem in args.Items)
     {
         foreach(Sitecore.Pipelines.Save.SaveArgs.SaveField saveField in saveItem.Fields)
         {
             saveField.Value = saveField.Value.Replace("  ", " ").Replace("&nbsp;", " ");
         }
     }
 }
 public void Process(SaveArgs args)
 {
     foreach (Sitecore.Pipelines.Save.SaveArgs.SaveItem saveItem in args.Items)
     {
         foreach (Sitecore.Pipelines.Save.SaveArgs.SaveField saveField in saveItem.Fields)
         {
             // remove the &nbsp; characters
             saveField.Value = saveField.Value.Replace("&nbsp;", " ");
         }
     }
 }
Example #13
0
        public void isSave()
        {
            Directory.CreateDirectory("temp");
            string path = @"temp\1.txt";

            SaveArgs s = new SaveArgs();

            s.Save(path);

            Assert.IsTrue(File.Exists(path));
        }
 public void Process(SaveArgs args)
 {
     foreach (Sitecore.Pipelines.Save.SaveArgs.SaveItem saveItem in args.Items)
     {
         if (saveItem.ID == new ID("{47729EC5-14AA-4B1B-8BA9-EC0A3AEF2953}")) // The Global Setting Item Naming Item
         {
             Database master  = Factory.GetDatabase("master");
             Item     content = master.GetItem("/sitecore/content");
             Helper.RecursiveItemSave(content, false);
         }
     }
 }
Example #15
0
        public override void Save(Stream stream, CharacterDocument document)
        {
            var doc = document;

            if (doc != null)
            {
                var page = doc.Pages [0];
                var args = new SaveArgs(page.Canvas, page.Palette, stream);
                args.iCEColours = document.ICEColours;
                args.Save();
            }
        }
 public void Process(SaveArgs args)
 {
   foreach (Sitecore.Pipelines.Save.SaveArgs.SaveItem saveItem in args.Items)
   {
     if (saveItem.ID == new ID("{47729EC5-14AA-4B1B-8BA9-EC0A3AEF2953}"))  // The Global Setting Item Naming Item
     {
       Database master = Factory.GetDatabase("master");
       Item content = master.GetItem("/sitecore/content");
       Helper.RecursiveItemSave(content, false);
     }
   }
 }    
        private string GetErrorValue(SaveArgs args)
        {
            var results = new Dictionary <Item, IList <FieldDesynchronization> >();

            try
            {
                foreach (var item in args.Items)
                {
                    Item     existingItem      = Client.ContentDatabase.GetItem(item.ID);
                    SyncItem serializedVersion = ReadSerializedVersion(existingItem);

                    // not having an existing serialized version means no possibility of conflict here
                    if (serializedVersion == null)
                    {
                        continue;
                    }

                    var fieldIssues = GetFieldSyncStatus(existingItem, serializedVersion);

                    if (fieldIssues.Count == 0)
                    {
                        continue;
                    }

                    results.Add(existingItem, fieldIssues);
                }

                // no problems
                if (results.Count == 0)
                {
                    return(null);
                }

                var sb = new StringBuilder();
                sb.Append("CRITICAL:\n");
                sb.Append(
                    "Item state conflicted with existing serialized value. Chances are you need to sync your database with the filesystem. The following fields had problems:\n");
                foreach (var item in results)
                {
                    sb.AppendFormat("\n{0}: {1}", item.Key.DisplayName, string.Join(", ", item.Value.Select(x => x.FieldName)));
                }

                sb.Append("\n\nDo you want to overwrite anyway? You may cause someone else to lose committed work by doing this.");

                return(sb.ToString());
            }
            catch (Exception ex)
            {
                Log.Error("Exception occurred while performing serialization conflict check!", ex, this);
                return("Exception occurred: " + ex.Message);                // this will cause a few retries
            }
        }
Example #18
0
        public void Execute(SaveArgs args)
        {
            Signature author = new Signature(Config.Username, Config.Email, DateTime.Now);

            using (var repo = new Repository(args.Repo))
            {
                LibGit2Sharp.Commands.Stage(repo, "*");
                try
                {
                    repo.Commit(args.Message, author, author);
                }
                catch (EmptyCommitException) { }
                repo.Network.Push(repo.Head);
            }
        }
        public void Process(SaveArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            // we had errors, and we got a post-back result of no, don't overwrite
            if (args.Result == "no" || args.Result == "undefined")
            {
                args.SaveAnimation = false;
                args.AbortPipeline();
                return;
            }

            // we had errors, and we got a post-back result of yes, allow overwrite
            if (args.IsPostBack) return;

            var results = new Dictionary<Item, IList<FieldDesynchronization>>();

            foreach (var item in args.Items)
            {
                Item existingItem = Client.ContentDatabase.GetItem(item.ID);
                SyncItem serializedVersion = ReadSerializedVersion(existingItem);

                // not having an existing serialized version means no possibility of conflict here
                if (serializedVersion == null) continue;

                var fieldIssues = GetFieldSyncStatus(existingItem, serializedVersion);

                if (fieldIssues.Count == 0) continue;

                results.Add(existingItem, fieldIssues);
            }

            // no problems
            if (results.Count == 0) return;

            var sb = new StringBuilder();
            sb.Append("CRITICAL:\n");
            sb.Append("Item state conflicted with existing serialized value. Chances are you need to sync your database with the filesystem. The following fields had problems:\n");
            foreach (var item in results)
            {
                sb.AppendFormat("\n{0}: {1}", item.Key.DisplayName, string.Join(", ", item.Value.Select(x => x.FieldName)));
            }

            sb.Append("\n\nDo you want to overwrite anyway? You may cause someone else to lose committed work by doing this.");

            Sitecore.Web.UI.Sheer.SheerResponse.Confirm(sb.ToString());
            args.WaitForPostBack();
        }
    public void Process(SaveArgs args)
    {
      foreach (SaveArgs.SaveItem item in args.Items)
      {
        Item item2 = Context.ContentDatabase.Items[item.ID, item.Language, item.Version];
        if (item2 != null)
        {
          item2.Editing.BeginEdit();
          string newValue = String.Empty;
          foreach (SaveArgs.SaveField field in item.Fields)
          {
            Field field2 = item2.Fields[field.ID];
            if (field2 != null && field2.Type.Equals("Classification", StringComparison.InvariantCultureIgnoreCase))
            { 
              HtmlDocument doc = new HtmlDocument();
              doc.LoadHtml(field2.Value);
              if (doc.DocumentNode.SelectSingleNode("//span[@class='tagSet' or @class='tagNotFound']") != null)
              {
                foreach (HtmlNode span in doc.DocumentNode.SelectNodes("//span[@class='tagSet' or @class='tagNotFound']"))
                {
                  string tagId = span.Attributes["tagid"].Value;
                  if ((tagId == "Null") || (tagId == ID.Null.ToString()))
                  {
                    continue;
                  }

                  string weightId = span.Attributes["weightid"].Value;
                  newValue = newValue + tagId + ":" + weightId + "|";
                }
                newValue = newValue.Trim('|');
              }
              else 
              {
                List<string> listValue = field2.Value.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList();
                listValue.RemoveAll(fielV => fielV.Contains(Sitecore.Data.ID.Null.ToString()));
                newValue = String.Join("|", listValue.ToArray<string>());
              }
              field2.Value = newValue;
              field.OriginalValue = newValue;
            }
          }
          item2.Editing.EndEdit();
          Log.Audit(this, "Save item: {0}", new[] { AuditFormatter.FormatItem(item2) });
          args.SavedItems.Add(item2);

        }
      }
    }
        public void Process(SaveArgs args)
        {
            foreach (SaveArgs.SaveItem item in args.Items)
            {
                Item item2 = Context.ContentDatabase.Items[item.ID, item.Language, item.Version];
                if (item2 != null)
                {
                    item2.Editing.BeginEdit();
                    string newValue = String.Empty;
                    foreach (SaveArgs.SaveField field in item.Fields)
                    {
                        Field field2 = item2.Fields[field.ID];
                        if (field2 != null && field2.Type.Equals("Classification", StringComparison.InvariantCultureIgnoreCase))
                        {
                            HtmlDocument doc = new HtmlDocument();
                            doc.LoadHtml(field2.Value);
                            if (doc.DocumentNode.SelectSingleNode("//span[@class='tagSet' or @class='tagNotFound']") != null)
                            {
                                foreach (HtmlNode span in doc.DocumentNode.SelectNodes("//span[@class='tagSet' or @class='tagNotFound']"))
                                {
                                    string tagId = span.Attributes["tagid"].Value;
                                    if ((tagId == "Null") || (tagId == ID.Null.ToString()))
                                    {
                                        continue;
                                    }

                                    string weightId = span.Attributes["weightid"].Value;
                                    newValue = newValue + tagId + ":" + weightId + "|";
                                }
                                newValue = newValue.Trim('|');
                            }
                            else
                            {
                                List <string> listValue = field2.Value.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList();
                                listValue.RemoveAll(fielV => fielV.Contains(Sitecore.Data.ID.Null.ToString()));
                                newValue = String.Join("|", listValue.ToArray <string>());
                            }
                            field2.Value        = newValue;
                            field.OriginalValue = newValue;
                        }
                    }
                    item2.Editing.EndEdit();
                    Log.Audit(this, "Save item: {0}", new[] { AuditFormatter.FormatItem(item2) });
                    args.SavedItems.Add(item2);
                }
            }
        }
        public void Process(SaveArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            // we had errors, and we got a post-back result of no, don't overwrite
            if (args.Result == "no" || args.Result == "undefined")
            {
                args.SaveAnimation = false;
                args.AbortPipeline();
                return;
            }

            // we had errors, and we got a post-back result of yes, allow overwrite
            if (args.IsPostBack)
            {
                return;
            }

            string error = GetErrorValue(args);

            // no errors detected, we're good
            if (string.IsNullOrEmpty(error))
            {
                return;
            }

            // occasionally if you serialize an item "too fast" after changing it, the ShadowWriter's async operations
            // will be in process or have not yet begun to update the serialized item.
            // in these circumstances, we wish to treat a "conflict" or exception as a possible false positive, wait a bit for the ShadowWriter,
            // and try again. If it fails 4x in a row, 500ms apart, it's considered an unrecoverable conflict and we show the error.
            const int retries = 4;

            for (int retryCount = 0; retryCount < retries; retryCount++)
            {
                Thread.Sleep(500);
                error = GetErrorValue(args);
                if (string.IsNullOrEmpty(error))
                {
                    return;
                }
            }

            Sitecore.Web.UI.Sheer.SheerResponse.Confirm(error);
            args.WaitForPostBack();
        }
Example #23
0
        protected override string GetDialogText(SaveArgs args)
        {
            foreach (var item in args.Items)
            {
                Item existingItem = Client.ContentDatabase.GetItem(item.ID, item.Language, item.Version);

                Assert.IsNotNull(existingItem, "Existing item {0} did not exist! This should never occur.", item.ID);

                var existingSitecoreItem = new ItemData(existingItem);

                if (_configurations.Any(configuration => configuration.Resolve <IPredicate>().Includes(existingSitecoreItem).IsIncluded))
                {
                    return(GetMessage(existingSitecoreItem));
                }
            }

            return(null);
        }
        protected override string GetDialogText(SaveArgs args)
        {
            foreach (var item in args.Items)
            {
                Item existingItem = Client.ContentDatabase.GetItem(item.ID, item.Language, item.Version);

                Assert.IsNotNull(existingItem, "Existing item {0} did not exist! This should never occur.", item.ID);

                var existingSitecoreItem = new ItemData(existingItem);

                if (_configurations.Any(configuration => configuration.Resolve<IPredicate>().Includes(existingSitecoreItem).IsIncluded))
                {
                    return GetMessage(existingSitecoreItem);
                }
            }

            return null;
        }
        public virtual void Process(SaveArgs args)
        {
            Assert.ArgumentNotNull(args, nameof(args));

            if (args.IsPostBack)
            {
                if (args.Result == "no")
                    args.AbortPipeline();

                args.IsPostBack = false;

                return;
            }

            if (args.Items == null)
                return;

            foreach (var saveItem in args.Items)
            {
                if (!string.IsNullOrEmpty(saveItem.Revision))
                {
                    Item existingItem = Client.ContentDatabase.GetItem(saveItem.ID, saveItem.Language, saveItem.Version);
                    if (existingItem == null) continue;

                    // added: ignore transparent synced items, whose revisions are randomly generated
                    if (existingItem.Statistics.UpdatedBy.Equals(UnicornDataProvider.TransparentSyncUpdatedByValue, StringComparison.Ordinal)) continue;

                    string cleanedExistingRevision = existingItem[FieldIDs.Revision].Replace("-", string.Empty);
                    string cleanedNewRevision = saveItem.Revision.Replace("-", string.Empty);
                    if (cleanedExistingRevision.Equals(cleanedNewRevision, StringComparison.InvariantCultureIgnoreCase) || EditorConstants.IgnoreRevision.Equals(cleanedNewRevision, StringComparison.InvariantCultureIgnoreCase))
                        continue;

                    if (!args.HasSheerUI)
                        break;

                    SheerResponse.Confirm("One or more items have been changed.\n\nDo you want to overwrite these changes?");

                    args.WaitForPostBack();

                    break;
                }
            }
        }
        private string GetErrorValue(SaveArgs args)
        {
            var results = new Dictionary<Item, IList<FieldDesynchronization>>();

            try
            {
                foreach (var item in args.Items)
                {
                    Item existingItem = Client.ContentDatabase.GetItem(item.ID);
                    SyncItem serializedVersion = ReadSerializedVersion(existingItem);

                    // not having an existing serialized version means no possibility of conflict here
                    if (serializedVersion == null) continue;

                    var fieldIssues = GetFieldSyncStatus(existingItem, serializedVersion);

                    if (fieldIssues.Count == 0) continue;

                    results.Add(existingItem, fieldIssues);
                }

                // no problems
                if (results.Count == 0) return null;

                var sb = new StringBuilder();
                sb.Append("CRITICAL:\n");
                sb.Append(
                    "Item state conflicted with existing serialized value. Chances are you need to sync your database with the filesystem. The following fields had problems:\n");
                foreach (var item in results)
                {
                    sb.AppendFormat("\n{0}: {1}", item.Key.DisplayName, string.Join(", ", item.Value.Select(x => x.FieldName)));
                }

                sb.Append("\n\nDo you want to overwrite anyway? You may cause someone else to lose committed work by doing this.");

                return sb.ToString();
            }
            catch (Exception ex)
            {
                Log.Error("Exception occurred while performing serialization conflict check!", ex, this);
                return "Exception occurred: " + ex.Message; // this will cause a few retries
            }
        }
        public void Process(SaveArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            Assert.ArgumentNotNull(args.Items, "args.Items");

            var database = Context.ContentDatabase;

            if (!MediaFrameworkContext.IsExportAllowed(database.Name))
            {
                return;
            }

            foreach (SaveArgs.SaveItem saveItem in args.Items)
            {
                Item item = database.Items[saveItem.ID, saveItem.Language, saveItem.Version];

                item.ExportUpdate(saveItem);
            }
        }
        /// <summary>Runs the processor.</summary>
        /// <param name="args">The arguments.</param>
        public void Process(SaveArgs args)
        {
            if (!args.HasSheerUI)
            {
                return;
            }
            Assert.ArgumentNotNull((object)args, nameof(args));
            Assert.IsNotNull((object)args.Items, "args.Items");
            foreach (SaveArgs.SaveItem saveItem in args.Items)
            {
                Item obj = Client.ContentDatabase.GetItem(saveItem.ID, saveItem.Language);
                if (obj != null && obj.Database.Engines.TemplateEngine.IsTemplate(obj))
                {
                    Template             template       = TemplateManager.GetTemplate(obj.ID, Client.ContentDatabase);
                    List <TemplateField> templateFields = template.GetFields(false).ToList();
                    templateFields.AddRange(GetTemplateFields(saveItem, obj));

                    if (templateFields == null || templateFields.Count == 0)
                    {
                        return;
                    }

                    List <string> fieldNames          = new List <string>();
                    List <string> duplicateFieldNames = new List <string>();
                    foreach (TemplateField templateField in templateFields)
                    {
                        if (fieldNames.Contains(templateField.Name.ToLower()))
                        {
                            duplicateFieldNames.Add(templateField.Name);
                        }
                        fieldNames.Add(templateField.Name.ToLower());
                    }
                    if (duplicateFieldNames.Count != 0)
                    {
                        CheckTemplateFieldNames.ShowDialog(obj, duplicateFieldNames);
                        return;
                    }
                }
            }
        }
    public void Process(SaveArgs args)
    {
        foreach (var saveItem in args.Items)                                                                       //loop through item(s) being saved
        {
            var item = Sitecore.Context.ContentDatabase.GetItem(saveItem.ID, saveItem.Language, saveItem.Version); //get the actual item being saved
            if (item == null)
            {
                continue;
            }

            foreach (var saveField in saveItem.Fields)                       //loop through the fields being saved
            {
                var field      = item.Fields[saveField.ID];                  //retrieve the Field from the actual item
                var isModified = saveField.OriginalValue != saveField.Value; //determine if the field has been modified, we only want to log modified fields
                if (field == null || !isModified)
                {
                    continue;
                }

                Log.Audit(string.Format("SaveUI - Item field {0} was modified at: {1}, by user: {2}", field.DisplayName, item.Statistics.Updated.ToString(CultureInfo.InvariantCulture), item.Statistics.UpdatedBy), this);
            }
        }
    }
Example #30
0
        private void ProcessDirtyBit(NameValueCollection args)
        {
            ClientPipelineArgs pipelineArgs = new ClientPipelineArgs(args);

            FieldSuiteEditor[] editors = new FieldSuiteEditor[CurrentEditors.Count];
            CurrentEditors.CopyTo(editors);
            DirtyEditors = editors.ToList();

            DirtySargs = new List <SaveArgs>();
            foreach (FieldSuiteEditor editor in CurrentEditors)
            {
                Hashtable fieldInfo = editor.FieldInfo;
                SaveArgs  sargs     = new SaveArgs(GetSavePacket(fieldInfo).XmlDocument)
                {
                    SaveAnimation = false
                };
                DirtySargs.Add(sargs);
            }

            Sitecore.Pipelines.Pipeline pipe = Context.ClientPage.Start(this, "ShowSaveMessage", pipelineArgs);

            LoadCurrentItem();
        }
        /// <summary>
        /// Makes all available content editor forms save their information to the sitecore item fields.
        /// </summary>
        private void SaveEditorFormData(bool alert, IEnumerable<FieldSuiteEditor> editors, string postAction)
        {
            foreach (FieldSuiteEditor editor in editors)
            {
                LockItem(editor.Item);

                Hashtable fieldInfo = editor.FieldInfo;
                SaveArgs args = new SaveArgs(GetSavePacket(fieldInfo).XmlDocument) { SaveAnimation = false };
                if (!string.IsNullOrEmpty(postAction))
                    args.PostAction = postAction;
                Context.ClientPage.Start("saveUI", (ClientPipelineArgs)args);
                if (args.Error.Length > 0)
                {
                    SheerResponse.Alert(args.Error, new string[0]);
                    return;
                }

                editor.ClientPage.Modified = false;
            }

            if (alert) SheerResponse.Alert("Content Saved", new string[0]);
        }
        private void ProcessDirtyBit(NameValueCollection args)
        {
            ClientPipelineArgs pipelineArgs = new ClientPipelineArgs(args);

            FieldSuiteEditor[] editors = new FieldSuiteEditor[CurrentEditors.Count];
            CurrentEditors.CopyTo(editors);
            DirtyEditors = editors.ToList();

            DirtySargs = new List<SaveArgs>();
            foreach (FieldSuiteEditor editor in CurrentEditors)
            {
                Hashtable fieldInfo = editor.FieldInfo;
                SaveArgs sargs = new SaveArgs(GetSavePacket(fieldInfo).XmlDocument) { SaveAnimation = false };
                DirtySargs.Add(sargs);
            }

            Sitecore.Pipelines.Pipeline pipe = Context.ClientPage.Start(this, "ShowSaveMessage", pipelineArgs);

            LoadCurrentItem();
        }
Example #33
0
 public void Process(SaveArgs args)
 {
     Reload();
 }
		protected override string GetDialogText(SaveArgs args)
		{
			var results = new Dictionary<Item, IList<string>>();

			foreach (var item in args.Items)
			{
				// we grab the existing item from the database. This will NOT include the changed values we're saving.
				// this is because we want to verify that the base state of the item matches serialized, NOT the state we're saving.
				// if the base state and the serialized state match we can be pretty sure that the changes we are writing won't clobber anything serialized but not synced
				Item existingItem = Client.ContentDatabase.GetItem(item.ID, item.Language, item.Version);

				Assert.IsNotNull(existingItem, "Existing item {0} did not exist! This should never occur.", item.ID);

				var existingSitecoreItem = new ItemData(existingItem);

				foreach (var configuration in _configurations)
				{
					// ignore conflict checks if Transparent Sync is turned on (in which case this is a tautology - 'get from database' would be 'get from disk' so it always matches
					if (configuration.Resolve<IUnicornDataProviderConfiguration>().EnableTransparentSync) continue;

					// ignore conflicts on items that Unicorn is not managing
					if (!configuration.Resolve<IPredicate>().Includes(existingSitecoreItem).IsIncluded) continue;

					// evaluator signals that it does not care about conflicts (e.g. NIO)
					if (!configuration.Resolve<IEvaluator>().ShouldPerformConflictCheck(existingItem)) continue;

					IItemData serializedItemData = configuration.Resolve<ITargetDataStore>().GetByPathAndId(existingSitecoreItem.Path, existingSitecoreItem.Id, existingSitecoreItem.DatabaseName);

					// not having an existing serialized version means no possibility of conflict here
					if (serializedItemData == null) continue;

					var fieldFilter = configuration.Resolve<IFieldFilter>();
					var itemComparer = configuration.Resolve<IItemComparer>();

					var fieldIssues = GetFieldSyncStatus(existingSitecoreItem, serializedItemData, fieldFilter, itemComparer);

					if (fieldIssues.Count == 0) continue;

					results[existingItem] = fieldIssues;
				}
			}

			// no problems
			if (results.Count == 0) return null;

			var sb = new StringBuilder();

			if (About.Version.StartsWith("7") || About.Version.StartsWith("6"))
			{
				// older Sitecores used \n to format dialog text

				sb.Append("CRITICAL MESSAGE FROM UNICORN:\n");
				sb.Append("You need to run a Unicorn sync. The following fields did not match the serialized version:\n");

				foreach (var item in results)
				{
					if (results.Count > 1)
						sb.AppendFormat("\n{0}: {1}", item.Key.DisplayName, string.Join(", ", item.Value));
					else
						sb.AppendFormat("\n{0}", string.Join(", ", item.Value));
				}

				sb.Append("\n\nDo you want to overwrite anyway?\nTHIS MAY CAUSE LOST WORK.");
			}
			else
			{
				// Sitecore 8.x+ uses HTML to format dialog text
				sb.Append("<p style=\"font-weight: bold; margin-bottom: 1em;\">CRITICAL MESSAGE FROM UNICORN:</p>");
				sb.Append("<p>You need to run a Unicorn sync. The following fields did not match the serialized version:</p><ul style=\"margin: 1em 0\">");

				foreach (var item in results)
				{
					if (results.Count > 1)
						sb.AppendFormat("<li>{0}: {1}</li>", item.Key.DisplayName, string.Join(", ", item.Value));
					else
						sb.AppendFormat("<li>{0}</li>", string.Join(", ", item.Value));
				}

				sb.Append("</ul><p>Do you want to overwrite anyway?<br>THIS MAY CAUSE LOST WORK.</p>");
			}

			return sb.ToString();
		}
Example #35
0
        public void Recontextualize(SaveArgs s)
        {
            //quando se está a fechar a aplicação, o timer da pxlistview pode disparar depois de os contextos estarem limpos (e consequentemente lançar uma excepção; só ocorre quando o timer dispara quando a execução está dentro do método que trata o fecho da aplicação)
            if (((frmMain)TopLevelControl) == null || ((frmMain)TopLevelControl).ActiveControl is MasterPanelAdminGlobal || ((frmMain)TopLevelControl).ActiveControl is MasterPanelEstatisticas)
            {
                return;
            }

            ((frmMain)TopLevelControl).EnterWaitMode();
            try
            {
                if (isInnerContextValid())
                {
                    ViewToModel();
                    if (s != null)
                    {
                        if (s.psAction != null)
                        {
                            s.save = Save(s.psAction, true);
                        }
                        else
                        {
                            s.save = Save(true);
                        }
                    }
                    else
                    {
                        Save();
                    }
                }

                if (s != null && s.save == PersistencyHelper.SaveResult.unsuccessful)
                {
                    ((frmMain)TopLevelControl).LeaveWaitMode();
                    return;
                }

                Deactivate();

                //Remove-se de memória todas as linhas marcadas com isDeleted=true na BD
                //esta chamada não se encontra imediatamente a seguir ao save pois existem
                //situações que o método recontextualize é chamado propositadamente
                PersistencyHelper.cleanDeletedData();

                if (!(isOuterContextValid()))
                {
                    PanelMensagem panel = GetNoContextMessage();
                    if (panel != null)
                    {
                        this.Visible = true;
                        ActivateMessagePanel(panel);
                    }
                }
                else
                {
                    PanelMensagem panel = null;
                    if (isOuterContextDeleted())
                    {
                        panel = GetDeletedContextMessage();
                        ActivateMessagePanel(panel);
                        this.Visible = true;
                    }
                    else if (!(hasReadPermission()))
                    {
                        panel = GetNoReadPermissionMessage();
                        ActivateMessagePanel(panel);
                        this.Visible = true;
                    }
                    else if (!(isConnected()))
                    {
                        panel = GetNoConnectionMessage();
                        if (panel != null)
                        {
                            this.Visible = true;
                            ActivateMessagePanel(panel);
                        }
                    }
                    else
                    {
                        DeactivateMessagePanel(GetNoContextMessage());

                        try
                        {
                            RefreshPanelSelection();
                            long start = DateTime.Now.Ticks;
                            LoadData();
                            Trace.WriteLine("LoadData: " + new TimeSpan(DateTime.Now.Ticks - start).ToString());
                            start = DateTime.Now.Ticks;
                            ModelToView();
                            Trace.WriteLine("ModelToView: " + new TimeSpan(DateTime.Now.Ticks - start).ToString());
                        }
                        catch (Exception ex)
                        {
                            Trace.WriteLine(ex);
                            throw;
                        }

                        this.Visible = true;
                    }
                }
            }
            finally
            {
                ((frmMain)TopLevelControl).LeaveWaitMode();
            }
        }
        protected override string GetDialogText(SaveArgs args)
        {
            var results = new Dictionary<Item, IList<string>>();

            try
            {
                foreach (var item in args.Items)
                {
                    Item existingItem = Client.ContentDatabase.GetItem(item.ID, item.Language, item.Version);

                    Assert.IsNotNull(existingItem, "Existing item {0} did not exist! This should never occur.", item.ID);

                    var existingSitecoreItem = new ItemData(existingItem);

                    foreach (var configuration in _configurations)
                    {
                        // ignore conflicts on items that Unicorn is not managing
                        if (!configuration.Resolve<IPredicate>().Includes(existingSitecoreItem).IsIncluded) continue;

                        IItemData serializedItemData = configuration.Resolve<ITargetDataStore>().GetByPathAndId(existingSitecoreItem.Path, existingSitecoreItem.Id, existingSitecoreItem.DatabaseName);

                        // not having an existing serialized version means no possibility of conflict here
                        if (serializedItemData == null) continue;

                        var fieldFilter = configuration.Resolve<IFieldFilter>();
                        var itemComparer = configuration.Resolve<IItemComparer>();

                        var fieldIssues = GetFieldSyncStatus(existingSitecoreItem, serializedItemData, fieldFilter, itemComparer);

                        if (fieldIssues.Count == 0) continue;

                        results.Add(existingItem, fieldIssues);
                    }

                }

                // no problems
                if (results.Count == 0) return null;

                var sb = new StringBuilder();
                sb.Append("CRITICAL MESSAGE FROM UNICORN:\n");
                sb.Append("You need to run a Unicorn sync. The following fields did not match the serialized version:\n");

                foreach (var item in results)
                {
                    if(results.Count > 1)
                        sb.AppendFormat("\n{0}: {1}", item.Key.DisplayName, string.Join(", ", item.Value));
                    else
                        sb.AppendFormat("\n{0}", string.Join(", ", item.Value));
                }

                sb.Append("\n\nDo you want to overwrite anyway?\nTHIS MAY CAUSE LOST WORK.");

                return sb.ToString();
            }
            catch (Exception ex)
            {
                Log.Error("Exception occurred while performing serialization conflict check!", ex, this);
                return "Exception occurred: " + ex.Message; // this will cause a few retries
            }
        }
Example #37
0
		public void Recontextualize(SaveArgs s)
		{
			//quando se está a fechar a aplicação, o timer da pxlistview pode disparar depois de os contextos estarem limpos (e consequentemente lançar uma excepção; só ocorre quando o timer dispara quando a execução está dentro do método que trata o fecho da aplicação)
            if (((frmMain)TopLevelControl) == null || ((frmMain)TopLevelControl).ActiveControl is MasterPanelAdminGlobal || ((frmMain)TopLevelControl).ActiveControl is MasterPanelEstatisticas)
				return;

			((frmMain)TopLevelControl).EnterWaitMode();
			try
			{
				if (isInnerContextValid())
				{
					ViewToModel();
					if (s != null)
					{
                        if (s.psAction != null)
                            s.save = Save(s.psAction, true);
                        else
                            s.save = Save(true);
					}
					else
						Save();
				}

                if (s != null && s.save == PersistencyHelper.SaveResult.unsuccessful)
				{
					((frmMain)TopLevelControl).LeaveWaitMode();
					return;
				}

				Deactivate();

				//Remove-se de memória todas as linhas marcadas com isDeleted=true na BD
				//esta chamada não se encontra imediatamente a seguir ao save pois existem
				//situações que o método recontextualize é chamado propositadamente
				PersistencyHelper.cleanDeletedData();

				if (! (isOuterContextValid()))
				{
					PanelMensagem panel = GetNoContextMessage();
					if (panel != null)
					{
                        this.Visible = true;
						ActivateMessagePanel(panel);
					}                    
				}                
				else
				{
					PanelMensagem panel = null;
					if (isOuterContextDeleted())
					{
						panel = GetDeletedContextMessage();
						ActivateMessagePanel(panel);
						this.Visible = true;
					}
					else if (! (hasReadPermission()))
					{
						panel = GetNoReadPermissionMessage();
						ActivateMessagePanel(panel);
						this.Visible = true;
					}
                    else if (!(isConnected()))
                    {
                        panel = GetNoConnectionMessage();
                        if (panel != null)
                        {
                            this.Visible = true;
                            ActivateMessagePanel(panel);
                        }
                    }
					else
					{
						DeactivateMessagePanel(GetNoContextMessage());

						try
						{
                            RefreshPanelSelection();
							long start = DateTime.Now.Ticks;
							LoadData();
							Trace.WriteLine("LoadData: " + new TimeSpan(DateTime.Now.Ticks - start).ToString());
							start = DateTime.Now.Ticks;
							ModelToView();
							Trace.WriteLine("ModelToView: " + new TimeSpan(DateTime.Now.Ticks - start).ToString());
						}
						catch (Exception ex)
						{
							Trace.WriteLine(ex);
							throw;
						}

						this.Visible = true;
					}
				}
			}
			finally
			{
				((frmMain)TopLevelControl).LeaveWaitMode();
			}
		}
 protected void Save(Message message)
 {
     Assert.ArgumentNotNull(message, "message");
     SaveArgs args = new SaveArgs(GetSavePacket(this.FieldInfo).XmlDocument);
     if (message["loadid"] != null)
     {
         args.PostAction = "item:load(id=" + message["loadid"] + ",language=" + message["language"] + ",version=" + message["version"] + ",force=" + message["force"] + ")";
     }
     else if (message["postaction"] != null)
     {
         args.PostAction = message["postaction"];
     }
     Context.ClientPage.Start("saveUI", (ClientPipelineArgs)args);
     if (args.Error.Length > 0)
     {
         SheerResponse.Alert(args.Error, new string[0]);
     }
 }
        private string GetErrorValue(SaveArgs args)
        {
            var results = new Dictionary <Item, IList <FieldDesynchronization> >();

            try
            {
                foreach (var item in args.Items)
                {
                    Item existingItem = Client.ContentDatabase.GetItem(item.ID, item.Language, item.Version);

                    Assert.IsNotNull(existingItem, "Existing item {0} did not exist! This should never occur.", item.ID);

                    var existingSitecoreItem = new SitecoreSourceItem(existingItem);

                    foreach (var configuration in _configurations)
                    {
                        // ignore conflicts on items that Unicorn is not managing
                        if (!configuration.Resolve <IPredicate>().Includes(existingSitecoreItem).IsIncluded)
                        {
                            continue;
                        }

                        ISerializedReference serializedReference = configuration.Resolve <ISerializationProvider>().GetReference(existingSitecoreItem);

                        if (serializedReference == null)
                        {
                            continue;
                        }

                        // not having an existing serialized version means no possibility of conflict here
                        ISerializedItem serializedItem = serializedReference.GetItem();

                        if (serializedItem == null)
                        {
                            continue;
                        }

                        var fieldPredicate = configuration.Resolve <IFieldPredicate>();

                        var fieldIssues = GetFieldSyncStatus(existingSitecoreItem, serializedItem, fieldPredicate);

                        if (fieldIssues.Count == 0)
                        {
                            continue;
                        }

                        results.Add(existingItem, fieldIssues);
                    }
                }

                // no problems
                if (results.Count == 0)
                {
                    return(null);
                }

                var sb = new StringBuilder();
                sb.Append("CRITICAL MESSAGE FROM UNICORN:\n");
                sb.Append("You need to run a Unicorn sync. The following fields did not match the serialized version:\n");

                foreach (var item in results)
                {
                    if (results.Count > 1)
                    {
                        sb.AppendFormat("\n{0}: {1}", item.Key.DisplayName, string.Join(", ", item.Value.Select(x => x.FieldName)));
                    }
                    else
                    {
                        sb.AppendFormat("\n{0}", string.Join(", ", item.Value.Select(x => x.FieldName)));
                    }
                }

                sb.Append("\n\nDo you want to overwrite anyway?\nTHIS MAY CAUSE LOST WORK.");

                return(sb.ToString());
            }
            catch (Exception ex)
            {
                Log.Error("Exception occurred while performing serialization conflict check!", ex, this);
                return("Exception occurred: " + ex.Message);                // this will cause a few retries
            }
        }
Example #40
0
 public void Process(SaveArgs args)
 {
     Assert.ArgumentNotNull(args, "args");
     ReloadControl();
 }
 public void Process(SaveArgs args)
 {
 }
        protected override string GetDialogText(SaveArgs args)
        {
            var results = new Dictionary <Item, IList <string> >();

            try
            {
                foreach (var item in args.Items)
                {
                    // we grab the existing item from the database. This will NOT include the changed values we're saving.
                    // this is because we want to verify that the base state of the item matches serialized, NOT the state we're saving.
                    // if the base state and the serialized state match we can be pretty sure that the changes we are writing won't clobber anything serialized but not synced
                    Item existingItem = Client.ContentDatabase.GetItem(item.ID, item.Language, item.Version);

                    Assert.IsNotNull(existingItem, "Existing item {0} did not exist! This should never occur.", item.ID);

                    var existingSitecoreItem = new ItemData(existingItem);

                    foreach (var configuration in _configurations)
                    {
                        // ignore conflicts on items that Unicorn is not managing
                        if (!configuration.Resolve <IPredicate>().Includes(existingSitecoreItem).IsIncluded)
                        {
                            continue;
                        }

                        IItemData serializedItemData = configuration.Resolve <ITargetDataStore>().GetByPathAndId(existingSitecoreItem.Path, existingSitecoreItem.Id, existingSitecoreItem.DatabaseName);

                        // not having an existing serialized version means no possibility of conflict here
                        if (serializedItemData == null)
                        {
                            continue;
                        }

                        var fieldFilter  = configuration.Resolve <IFieldFilter>();
                        var itemComparer = configuration.Resolve <IItemComparer>();

                        var fieldIssues = GetFieldSyncStatus(existingSitecoreItem, serializedItemData, fieldFilter, itemComparer);

                        if (fieldIssues.Count == 0)
                        {
                            continue;
                        }

                        results.Add(existingItem, fieldIssues);
                    }
                }

                // no problems
                if (results.Count == 0)
                {
                    return(null);
                }

                var sb = new StringBuilder();
                sb.Append("CRITICAL MESSAGE FROM UNICORN:\n");
                sb.Append("You need to run a Unicorn sync. The following fields did not match the serialized version:\n");

                foreach (var item in results)
                {
                    if (results.Count > 1)
                    {
                        sb.AppendFormat("\n{0}: {1}", item.Key.DisplayName, string.Join(", ", item.Value));
                    }
                    else
                    {
                        sb.AppendFormat("\n{0}", string.Join(", ", item.Value));
                    }
                }

                sb.Append("\n\nDo you want to overwrite anyway?\nTHIS MAY CAUSE LOST WORK.");

                return(sb.ToString());
            }
            catch (Exception ex)
            {
                Log.Error("Exception occurred while performing serialization conflict check!", ex, this);
                return("Exception occurred: " + ex.Message);                // this will cause a few retries
            }
        }
		protected abstract string GetDialogText(SaveArgs args);
Example #44
0
        public void Save()
        {
            SaveArgs saveArgs = PrepareSave();

            SaveInternal(saveArgs);
        }
Example #45
0
 protected abstract string GetDialogText(SaveArgs args);
Example #46
0
        protected override string GetDialogText(SaveArgs args)
        {
            var results = new Dictionary <Item, IList <string> >();

            foreach (var item in args.Items)
            {
                // we grab the existing item from the database. This will NOT include the changed values we're saving.
                // this is because we want to verify that the base state of the item matches serialized, NOT the state we're saving.
                // if the base state and the serialized state match we can be pretty sure that the changes we are writing won't clobber anything serialized but not synced
                Item existingItem = Client.ContentDatabase.GetItem(item.ID, item.Language, item.Version);

                Assert.IsNotNull(existingItem, "Existing item {0} did not exist! This should never occur.", item.ID);

                var existingSitecoreItem = new ItemData(existingItem);

                foreach (var configuration in _configurations)
                {
                    // ignore conflict checks if Transparent Sync is turned on (in which case this is a tautology - 'get from database' would be 'get from disk' so it always matches
                    if (configuration.Resolve <IUnicornDataProviderConfiguration>().EnableTransparentSync)
                    {
                        continue;
                    }

                    var result = configuration.Resolve <IPredicate>().Includes(existingSitecoreItem);
                    // ignore conflicts on items that Unicorn is not managing
                    if (!result.IsIncluded)
                    {
                        continue;
                    }

                    // If a Field Value Manipulator is attached to the predicate, we _expect_ Serialized content to be different from what is in Sitecore
                    if (result.FieldValueManipulator != null)
                    {
                        continue;
                    }

                    // evaluator signals that it does not care about conflicts (e.g. NIO)
                    if (!configuration.Resolve <IEvaluator>().ShouldPerformConflictCheck(existingItem))
                    {
                        continue;
                    }

                    IItemData serializedItemData = configuration.Resolve <ITargetDataStore>().GetByPathAndId(existingSitecoreItem.Path, existingSitecoreItem.Id, existingSitecoreItem.DatabaseName);

                    // not having an existing serialized version means no possibility of conflict here
                    if (serializedItemData == null)
                    {
                        continue;
                    }

                    var fieldFilter  = configuration.Resolve <IFieldFilter>();
                    var itemComparer = configuration.Resolve <IItemComparer>();

                    var fieldIssues = GetFieldSyncStatus(existingSitecoreItem, serializedItemData, fieldFilter, itemComparer);

                    if (fieldIssues.Count == 0)
                    {
                        continue;
                    }

                    results[existingItem] = fieldIssues;
                }
            }

            // no problems
            if (results.Count == 0)
            {
                return(null);
            }

            var sb = new StringBuilder();

            if (About.Version.StartsWith("7") || About.Version.StartsWith("6"))
            {
                // older Sitecores used \n to format dialog text

                sb.Append("CRITICAL MESSAGE FROM UNICORN:\n");
                sb.Append("You need to run a Unicorn sync. The following fields did not match the serialized version:\n");

                foreach (var item in results)
                {
                    if (results.Count > 1)
                    {
                        sb.AppendFormat("\n{0}: {1}", item.Key.DisplayName, string.Join(", ", item.Value));
                    }
                    else
                    {
                        sb.AppendFormat("\n{0}", string.Join(", ", item.Value));
                    }
                }

                sb.Append("\n\nDo you want to overwrite anyway?\nTHIS MAY CAUSE LOST WORK.");
            }
            else
            {
                // Sitecore 8.x+ uses HTML to format dialog text
                sb.Append("<p style=\"font-weight: bold; margin-bottom: 1em;\">CRITICAL MESSAGE FROM UNICORN:</p>");
                sb.Append("<p>You need to run a Unicorn sync. The following fields did not match the serialized version:</p><ul style=\"margin: 1em 0\">");

                foreach (var item in results)
                {
                    if (results.Count > 1)
                    {
                        sb.AppendFormat("<li>{0}: {1}</li>", item.Key.DisplayName, string.Join(", ", item.Value));
                    }
                    else
                    {
                        sb.AppendFormat("<li>{0}</li>", string.Join(", ", item.Value));
                    }
                }

                sb.Append("</ul><p>Do you want to overwrite anyway?<br>THIS MAY CAUSE LOST WORK.</p>");
            }

            return(sb.ToString());
        }
Example #47
0
        public virtual void Save(Stream stream, Canvas canvas, Palette palette)
        {
            var args = new SaveArgs(canvas, palette, stream);

            args.Save();
        }