Exemple #1
0
        IHttpTask RebuildTask(SqlTaskConfiguration sqlTask, IList <SqlTaskConfigurationHeader> headers)
        {
            var config = new TaskConfiguration(sqlTask.Uri, sqlTask.LocalFilePath)
            {
                HttpMethod           = sqlTask.HttpMethod,
                PostData             = sqlTask.PostData,
                UseMeteredConnection = sqlTask.UseMeteredConnection
            };

            foreach (var header in headers)
            {
                config.Headers.Add(header.Key, header.Value);
            }

            var task = this.CreateTask(config, sqlTask.IsUpload, sqlTask.Id.ToString());

            return(task);
        }
Exemple #2
0
        IHttpTask CreateTaskAndPersist(TaskConfiguration config, bool upload)
        {
            try
            {
                this.conn.BeginTransaction();

                var sqlTask = new SqlTaskConfiguration
                {
                    HttpMethod           = config.HttpMethod,
                    Uri                  = config.Uri,
                    PostData             = config.PostData,
                    LocalFilePath        = config.LocalFilePath,
                    UseMeteredConnection = config.UseMeteredConnection,
                    IsUpload             = upload
                };
                this.conn.Insert(sqlTask);

                foreach (var header in config.Headers)
                {
                    this.conn.Insert(new SqlTaskConfigurationHeader
                    {
                        SqlTaskConfigurationId = sqlTask.Id,
                        Key   = header.Key,
                        Value = header.Value
                    });
                }
                var task = this.CreateTask(config, upload, sqlTask.Id.ToString());
                this.conn.Commit();

                return(task);
            }
            catch
            {
                this.conn.Rollback();
                throw;
            }
        }