Example #1
0
        private HtmlUploadCollection GetHtmlUploadCollection(HtmlSettings settings)
        {
            HtmlUploadCollection htmlUploadCollection = new HtmlUploadCollection();

            foreach (HtmlUpload htmlUpload in settings.Uploads)
            {
                htmlUploadCollection.Add(htmlUpload);
            }
            return(htmlUploadCollection);
        }
Example #2
0
        public void Update(HtmlSettings settings, IUnitOfWork unitOfWork = null)
        {
            HtmlUploadCollection htmlUploadCollection = GetHtmlUploadCollection(settings);
            IUnitOfWork          localUnitOfWork      = unitOfWork == null?_unitOfWorkFactory.CreateUnitOfWork() : null;

            try
            {
                IDatabaseManager dbm = _databaseManagerFactory.GetDatabaseManager(unitOfWork ?? localUnitOfWork);
                string           sql = _sqlManager.GetSql("Sql.UpdateHtml.sql");
                dbm.SetSQL(sql);
                dbm.AddParameter("@TenantId", FieldType.BigInt, settings.TenantId);
                dbm.AddParameter("@ElementId", FieldType.BigInt, settings.ElementId);
                dbm.AddParameter("@Html", FieldType.NVarChar, -1, settings.Html);
                dbm.AddTypedParameter("@HtmlUploads", FieldType.Structured, htmlUploadCollection.Count == 0 ? null : htmlUploadCollection, "element.HtmlUploadTableType");
                dbm.ExecuteNonQuery();
                if (localUnitOfWork != null)
                {
                    localUnitOfWork.Commit();
                }
            }
            catch
            {
                if (localUnitOfWork != null)
                {
                    localUnitOfWork.Rollback();
                }
                throw;
            }
            finally
            {
                if (localUnitOfWork != null)
                {
                    localUnitOfWork.Dispose();
                }
            }
        }