示例#1
0
 //        private static void CreateMediaContentTable(Repository repository)
 //        {
 //            string ddl = string.Format(@"CREATE TABLE [{0}] (
 //    Id int IDENTITY (100,1),
 //	UUID nvarchar(36) NOT NULL PRIMARY KEY,
 //    UserKey nvarchar(526),
 //    UtcCreationDate datetime,
 //	UtcLastModificationDate datetime,
 //	Published bit,
 //	OriginalUUID nvarchar(36),
 //	FolderName nvarchar(256),
 //	FileName nvarchar(256),
 //    VirtualPath nvarchar(256),
 //    UserId nvarchar(256)
 //    );", repository.GetMediaContentTableName());
 //            ExecuteDDL(repository, ddl);
 //        }
 protected static void ExecuteDDL(Repository repository, string ddl)
 {
     if (!string.IsNullOrEmpty(ddl))
     {
         SQLCeHelper.ExecuteNonQuery(repository.GetConnectionString(),
                                     ddl.Split(';').Where(it => !string.IsNullOrEmpty(it)).Select(it => new SqlCeCommand(it, null)).ToArray());
     }
 }
示例#2
0
        public void Delete(Models.MediaContent content)
        {
            string       sql     = string.Format("DELETE FROM {0} WHERE UUID=@UUID", content.GetRepository().GetMediaContentTableName());
            SqlCeCommand command = new SqlCeCommand();

            command.CommandText = sql;
            command.Parameters.Add(new SqlCeParameter("UUID", content.UUID));
            SQLCeHelper.ExecuteNonQuery(content.GetRepository().GetConnectionString(), command);
        }
示例#3
0
        public void Delete(Models.TextContent content)
        {
            var command = dbCommands.Delete(content);

            if (SQLCeTransactionUnit.Current != null)
            {
                SQLCeTransactionUnit.Current.RegisterCommand(command);
                SQLCeTransactionUnit.Current.RegisterPostAction(delegate() { TextContentFileHelper.DeleteFiles(content); });
            }
            else
            {
                SQLCeHelper.ExecuteNonQuery(content.GetRepository().GetConnectionString(), command);
                TextContentFileHelper.DeleteFiles(content);
            }
        }
示例#4
0
        public void Update(Models.MediaContent @new, Models.MediaContent old)
        {
            ((IPersistable)@new).OnSaving();
            string sql = string.Format("UPDATE {0} SET FolderName = @FolderName,FileName = @FileName,VirtualPath=@VirtualPath) WHERE UUID=@UUID"
                                       , @new.GetRepository().GetMediaContentTableName());
            SqlCeCommand command = new SqlCeCommand();

            command.CommandText = sql;
            command.Parameters.Add(new SqlCeParameter("UUID", @new.UUID));
            command.Parameters.Add(new SqlCeParameter("FolderName", @new.FolderName));
            command.Parameters.Add(new SqlCeParameter("FileName", @new.FileName));
            command.Parameters.Add(new SqlCeParameter("VirtualPath", @new.VirtualPath));
            SQLCeHelper.ExecuteNonQuery(@new.GetRepository().GetConnectionString(), command);
            ((IPersistable)@new).OnSaved();
        }
示例#5
0
        public void ExecuteNonQuery(Repository repository, string queryText, params KeyValuePair <string, object>[] parameters)
        {
            var connectionString = repository.GetConnectionString();

            var command = new System.Data.SqlServerCe.SqlCeCommand(queryText);

            if (parameters != null && parameters.Length > 0)
            {
                command.Parameters.AddRange(parameters.Select(it => new System.Data.SqlServerCe.SqlCeParameter()
                {
                    ParameterName = it.Key, Value = it.Value
                }).ToArray());
            }

            SQLCeHelper.ExecuteNonQuery(connectionString, command);
        }
示例#6
0
        public void Add(Models.MediaContent content)
        {
            ((IPersistable)content).OnSaving();
            string sql = string.Format("INSERT INTO {0}(UUID,FolderName,FileName,VirtualPath,UserId) VALUES(@UUID,@FolderName,@FileName,@VirtualPath,@UserId)"
                                       , content.GetRepository().GetMediaContentTableName());
            SqlCeCommand command = new SqlCeCommand();

            command.CommandText = sql;
            command.Parameters.Add(new SqlCeParameter("UUID", content.UUID));
            command.Parameters.Add(new SqlCeParameter("FolderName", content.FolderName));
            command.Parameters.Add(new SqlCeParameter("FileName", content.FileName));
            command.Parameters.Add(new SqlCeParameter("VirtualPath", content.VirtualPath));
            command.Parameters.Add(new SqlCeParameter("UserId", content.UserId));
            SQLCeHelper.ExecuteNonQuery(content.GetRepository().GetConnectionString(), command);
            ((IPersistable)content).OnSaved();
        }
示例#7
0
        public void Update(Models.TextContent @new, Models.TextContent old)
        {
            @new.StoreFiles();

            ((IPersistable)@new).OnSaving();
            var command = dbCommands.Update(@new);

            if (SQLCeTransactionUnit.Current != null)
            {
                SQLCeTransactionUnit.Current.RegisterCommand(command);
                SQLCeTransactionUnit.Current.RegisterPostAction(delegate() { ((IPersistable)@new).OnSaved(); });
            }
            else
            {
                SQLCeHelper.ExecuteNonQuery(@new.GetRepository().GetConnectionString(), command);
                ((IPersistable)@new).OnSaved();
            }
        }
示例#8
0
        public void Add(Models.TextContent content)
        {
            content.StoreFiles();

            ((IPersistable)content).OnSaving();
            var command = dbCommands.Add(content);

            if (command != null)
            {
                if (SQLCeTransactionUnit.Current != null)
                {
                    SQLCeTransactionUnit.Current.RegisterCommand(command);
                    SQLCeTransactionUnit.Current.RegisterPostAction(delegate() { ((IPersistable)content).OnSaved(); });
                }
                else
                {
                    SQLCeHelper.ExecuteNonQuery(content.GetRepository().GetConnectionString(), command);
                    ((IPersistable)content).OnSaved();
                }
            }
        }
示例#9
0
 public void ImportCategoryData(Repository repository, IEnumerable <Category> data)
 {
     SQLCeHelper.ExecuteNonQuery(repository.GetConnectionString(),
                                 data.Select(it => dbCommands.AddCategory(repository, it)).ToArray());
 }
示例#10
0
 public void ImportSchemaData(Schema schema, IEnumerable <IDictionary <string, object> > data)
 {
     SQLCeHelper.ExecuteNonQuery(schema.Repository.GetConnectionString(),
                                 data.Select(it => dbCommands.Add(GetContent(schema, it))).Where(it => it != null).ToArray());
 }
示例#11
0
 public void ClearCategories(TextContent content)
 {
     SQLCeHelper.ExecuteNonQuery(content.GetRepository().GetConnectionString(), dbCommands.ClearCategoreis(content));
 }
示例#12
0
 public void DeleteCategories(Models.TextContent content, params Models.Category[] categories)
 {
     SQLCeHelper.ExecuteNonQuery(content.GetRepository().GetConnectionString(),
                                 categories.Select(it => dbCommands.DeleteCategory(content.GetRepository(), it)).ToArray());
 }