Beispiel #1
0
        public bool DeleteSnippets(string[] ids)
        {
            if (ids == null || ids.Length < 1)
            {
                return(true);
            }

            var           busSnippet = new busCodeSnippet();
            StringBuilder errors     = new StringBuilder();

            foreach (string id in ids)
            {
                if (!busSnippet.Delete(id))
                {
                    errors.AppendLine(busSnippet.ErrorMessage);
                }
            }

            if (errors.Length > 0)
            {
                this.SetError(errors.ToString());
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        public bool UpdateFormattedCode()
        {
            var pks = Context.CodeSnippets
                      .Where(snip => snip.FormattedCode == null || snip.FormattedCode == "")
                      .Select(snip => snip.Id);

            try
            {
                foreach (var pk in pks)
                {
                    var snippet = new busCodeSnippet();
                    snippet.Load(pk);

                    // save forces snippet to save format
                    if (!snippet.Save())
                    {
                        SetError(snippet.ErrorMessage);
                        return(false);
                    }
                    Thread.Sleep(1);
                }
            }
            catch (Exception ex)
            {
                SetError(ex);
                return(false);
            }

            return(true);
        }