/// <summary> /// Initializes a new instance of the <see cref="BlockBlobServiceSideSyncCopyController"/> class. /// </summary> /// <param name="scheduler">Scheduler object which creates this object.</param> /// <param name="transferJob">Instance of job to start async copy.</param> /// <param name="userCancellationToken">Token user input to notify about cancellation.</param> internal BlockBlobServiceSideSyncCopyController( TransferScheduler scheduler, TransferJob transferJob, CancellationToken userCancellationToken) : base(scheduler, transferJob, userCancellationToken) { TransferLocation sourceLocation = transferJob.Source; if (sourceLocation.Type == TransferLocationType.AzureBlob) { var blobLocation = sourceLocation as AzureBlobLocation; this.SourceHandler = new ServiceSideSyncCopySource.BlobSourceHandler(blobLocation, transferJob); } else if (sourceLocation.Type == TransferLocationType.AzureFile) { this.SourceHandler = new ServiceSideSyncCopySource.FileSourceHandler(sourceLocation as AzureFileLocation, transferJob); } else { throw new ArgumentException( Resources.OnlySupportBlobAzureFileSource, "transferJob"); } this.destLocation = transferJob.Destination as AzureBlobLocation; this.destBlockBlob = this.destLocation.Blob as CloudBlockBlob; this.DestHandler = new ServiceSideSyncCopyDest.BlockBlobDestHandler(this.destLocation, transferJob); this.hasWork = true; }
public int InsertDetailsRecord(ref TransferLocation Entity_Trans, out string strError) { int iInsert = 0; strError = string.Empty; try { SqlParameter pAction = new SqlParameter("@Action", SqlDbType.BigInt); SqlParameter pTransferId = new SqlParameter(TransferLocation._TransId, SqlDbType.BigInt); SqlParameter pCategoryId = new SqlParameter(TransferLocation._CategoryId, SqlDbType.BigInt); SqlParameter pItemId = new SqlParameter(TransferLocation._ItemId, SqlDbType.BigInt); SqlParameter pTransFrom = new SqlParameter(TransferLocation._TransFrom, SqlDbType.BigInt); SqlParameter pQtyAtSource = new SqlParameter(TransferLocation._QtyAtSource, SqlDbType.Decimal); SqlParameter pTransTo = new SqlParameter(TransferLocation._TransTo, SqlDbType.BigInt); SqlParameter pQtyAtDest = new SqlParameter(TransferLocation._QtyAtDest, SqlDbType.Decimal); SqlParameter pTransferqTY = new SqlParameter(TransferLocation._TransQty, SqlDbType.Decimal); SqlParameter prate = new SqlParameter(TransferLocation._rate, SqlDbType.Decimal); SqlParameter pUnitConversionId = new SqlParameter(TransferLocation._UnitConversionId, SqlDbType.BigInt); SqlParameter pItemDescID = new SqlParameter(TransferLocation._ItemDescID, SqlDbType.BigInt); pAction.Value = 8; pTransferId.Value = Entity_Trans.TransId; pCategoryId.Value = Entity_Trans.CategoryId; pTransFrom.Value = Entity_Trans.TransFrom; pQtyAtSource.Value = Entity_Trans.QtyAtSource; pQtyAtDest.Value = Entity_Trans.QtyAtDest; pTransTo.Value = Entity_Trans.TransTo; pTransferqTY.Value = Entity_Trans.TransQty; pItemId.Value = Entity_Trans.ItemId; prate.Value = Entity_Trans.rate; pUnitConversionId.Value = Entity_Trans.UnitConversionId; pItemDescID.Value = Entity_Trans.ItemDescID; SqlParameter[] Param = new SqlParameter[] { pAction, pTransferId, pCategoryId, pTransFrom, pQtyAtSource, pQtyAtDest, pTransTo, pTransferqTY, pItemId, prate, pUnitConversionId, pItemDescID }; Open(CONNECTION_STRING); BeginTransaction(); iInsert = SQLHelper.ExecuteNonQuery(_Connection, _Transaction, CommandType.StoredProcedure, TransferLocation.SP_LocationTransfer, Param); if (iInsert > 0) { CommitTransaction(); } else { RollBackTransaction(); } } catch (Exception ex) { RollBackTransaction(); strError = ex.Message; } finally { Close(); } return(iInsert); }
// Summary: // Determines whether the specified transfer location is equal to the current transfer location. // // Parameters: // obj: // The transfer location to compare with the current transfer location. // // Returns: // true if the specified transfer location is equal to the current transfer location; otherwise, false. public override bool Equals(object obj) { TransferLocation location = obj as TransferLocation; if (location == null || this.Type != location.Type) { return(false); } return(this.ToString() == location.ToString()); }
public int InsertRecord(ref TransferLocation Entity_Trans, int LOCID, out string strError) { int iInsert = 0; strError = string.Empty; try { SqlParameter pAction = new SqlParameter(TransferLocation._Action, SqlDbType.BigInt); SqlParameter pTransferNo = new SqlParameter(TransferLocation._TransNo, SqlDbType.NVarChar); SqlParameter pTransferDate = new SqlParameter(TransferLocation._Date, SqlDbType.DateTime); SqlParameter pTransferBy = new SqlParameter(TransferLocation._TransBy, SqlDbType.BigInt); SqlParameter pNotes = new SqlParameter(TransferLocation._Notes, SqlDbType.NVarChar); SqlParameter pCreatedBy = new SqlParameter(TransferLocation._UserId, SqlDbType.BigInt); SqlParameter pCreatedDate = new SqlParameter(TransferLocation._LoginDate, SqlDbType.DateTime); SqlParameter pLOCID = new SqlParameter("@LOCID", SqlDbType.BigInt); pAction.Value = 1; pTransferNo.Value = Entity_Trans.TransNo; pTransferDate.Value = Entity_Trans.Date; pTransferBy.Value = Entity_Trans.TransBy; pNotes.Value = Entity_Trans.Notes; pCreatedBy.Value = Entity_Trans.UserID; pCreatedDate.Value = Entity_Trans.LoginDate; pLOCID.Value = LOCID; SqlParameter[] Param = new SqlParameter[] { pAction, pTransferNo, pTransferDate, pTransferBy, pNotes, pCreatedBy, pCreatedDate, pLOCID }; Open(CONNECTION_STRING); BeginTransaction(); iInsert = SQLHelper.ExecuteScalar(_Connection, _Transaction, CommandType.StoredProcedure, TransferLocation.SP_LocationTransfer, Param); if (iInsert > 0) { CommitTransaction(); } else { RollBackTransaction(); } } catch (Exception ex) { RollBackTransaction(); strError = ex.Message; } finally { Close(); } return(iInsert); }
private TransferReaderWriterBase GetWriter(TransferLocation destLocation, TransferContext transferContext) { switch (destLocation.Type) { case TransferLocationType.Stream: return(transferContext?.CreateWriterCallback?.Invoke(destLocation.Type, null, this.Scheduler, this, this.CancellationToken) ?? new StreamedWriter(this.Scheduler, this, this.CancellationToken)); case TransferLocationType.FilePath: return(transferContext?.CreateWriterCallback?.Invoke(destLocation.Type, null, this.Scheduler, this, this.CancellationToken) ?? new StreamedWriter(this.Scheduler, this, this.CancellationToken)); case TransferLocationType.AzureBlob: CloudBlob destBlob = (destLocation as AzureBlobLocation).Blob; var customWriter = transferContext?.CreateWriterCallback?.Invoke(destLocation.Type, destBlob, this.Scheduler, this, this.CancellationToken); if (customWriter != null) { return(customWriter); } if (destBlob is CloudPageBlob) { return(new PageBlobWriter(this.Scheduler, this, this.CancellationToken)); } else if (destBlob is CloudBlockBlob) { return(new BlockBlobWriter(this.Scheduler, this, this.CancellationToken)); } else if (destBlob is CloudAppendBlob) { return(new AppendBlobWriter(this.Scheduler, this, this.CancellationToken)); } else { throw new InvalidOperationException( string.Format( CultureInfo.CurrentCulture, Resources.UnsupportedBlobTypeException, destBlob.BlobType)); } case TransferLocationType.AzureFile: return(new CloudFileWriter(this.Scheduler, this, this.CancellationToken)); default: throw new InvalidOperationException( string.Format( CultureInfo.CurrentCulture, Resources.UnsupportedTransferLocationException, destLocation.Type)); } }
public AppendBlobWriter( TransferScheduler scheduler, SyncTransferController controller, CancellationToken cancellationToken) : base(scheduler, controller, cancellationToken) { this.location = this.SharedTransferData.TransferJob.Destination; this.appendBlob = this.location.Blob as CloudAppendBlob; Debug.Assert(null != this.appendBlob, "The destination is not an append blob while initializing a AppendBlobWriter instance."); this.state = State.FetchAttributes; this.hasWork = true; }
private TransferReaderWriterBase GetWriter(TransferLocation destLocation) { switch (destLocation.Type) { case TransferLocationType.Stream: var streamWriter = new StreamedWriter(this.Scheduler, this, this.CancellationToken); streamWriter.EnableSmallFileOptimization = true; return(streamWriter); case TransferLocationType.FilePath: var fileWriter = new StreamedWriter(this.Scheduler, this, this.CancellationToken); fileWriter.EnableSmallFileOptimization = true; return(fileWriter); case TransferLocationType.AzureBlob: CloudBlob destBlob = (destLocation as AzureBlobLocation).Blob; if (destBlob is CloudPageBlob) { return(new PageBlobWriter(this.Scheduler, this, this.CancellationToken)); } else if (destBlob is CloudBlockBlob) { var blobWriter = new BlockBlobWriter(this.Scheduler, this, this.CancellationToken); blobWriter.EnableSmallFileOptimization = true; return(blobWriter); } else if (destBlob is CloudAppendBlob) { return(new AppendBlobWriter(this.Scheduler, this, this.CancellationToken)); } else { throw new InvalidOperationException( string.Format( CultureInfo.CurrentCulture, Resources.UnsupportedBlobTypeException, destBlob.BlobType)); } case TransferLocationType.AzureFile: return(new CloudFileWriter(this.Scheduler, this, this.CancellationToken)); default: throw new InvalidOperationException( string.Format( CultureInfo.CurrentCulture, Resources.UnsupportedTransferLocationException, destLocation.Type)); } }
public int DeleteRecord(ref TransferLocation Entity_Trans, out string strError) { int iDelete = 0; strError = string.Empty; try { SqlParameter pAction = new SqlParameter(TransferLocation._Action, SqlDbType.BigInt); SqlParameter pTransId = new SqlParameter(TransferLocation._TransId, SqlDbType.BigInt); SqlParameter pDeletedBy = new SqlParameter(TransferLocation._UserId, SqlDbType.BigInt); SqlParameter pDeletedDate = new SqlParameter(TransferLocation._LoginDate, SqlDbType.DateTime); pAction.Value = 3; pTransId.Value = Entity_Trans.TransId; pDeletedBy.Value = Entity_Trans.UserID; pDeletedDate.Value = Entity_Trans.LoginDate; // pIsDeleted.Value = Entity_damage.IsDeleted; SqlParameter[] Param = new SqlParameter[] { pAction, pTransId, pDeletedBy, pDeletedDate }; Open(CONNECTION_STRING); BeginTransaction(); iDelete = SQLHelper.ExecuteNonQuery(_Connection, _Transaction, CommandType.StoredProcedure, TransferLocation.SP_LocationTransfer, Param); if (iDelete > 0) { CommitTransaction(); } else { RollBackTransaction(); } } catch (Exception ex) { RollBackTransaction(); strError = ex.Message; } finally { Close(); } return(iDelete); }
public BlockBasedBlobReader( TransferScheduler scheduler, SyncTransferController controller, CancellationToken cancellationToken) : base(scheduler, controller, cancellationToken) { this.transferLocation = this.SharedTransferData.TransferJob.Source; this.transferJob = this.SharedTransferData.TransferJob; this.blob = this.transferLocation.Blob; Debug.Assert( (this.blob is CloudBlockBlob) ||(this.blob is CloudAppendBlob), "Initializing BlockBlobReader while source location is not a block blob or an append blob."); this.hasWork = true; }
public BlockBasedBlobReader( TransferScheduler scheduler, SyncTransferController controller, CancellationToken cancellationToken) : base(scheduler, controller, cancellationToken) { this.transferLocation = this.SharedTransferData.TransferJob.Source; this.transferJob = this.SharedTransferData.TransferJob; this.blob = this.transferLocation.Blob; Debug.Assert( (this.blob is CloudBlockBlob) || (this.blob is CloudAppendBlob), "Initializing BlockBlobReader while source location is not a block blob or an append blob."); this.hasWork = true; }
private TransferReaderWriterBase GetReader(TransferLocation sourceLocation) { switch (sourceLocation.Type) { case TransferLocationType.Stream: return(new StreamedReader(this.Scheduler, this, this.CancellationToken)); case TransferLocationType.FilePath: return(new StreamedReader(this.Scheduler, this, this.CancellationToken)); case TransferLocationType.AzureBlob: CloudBlob sourceBlob = (sourceLocation as AzureBlobLocation).Blob; if (sourceBlob is CloudPageBlob) { return(new PageBlobReader(this.Scheduler, this, this.CancellationToken)); } else if (sourceBlob is CloudBlockBlob) { return(new BlockBasedBlobReader(this.Scheduler, this, this.CancellationToken)); } else if (sourceBlob is CloudAppendBlob) { return(new BlockBasedBlobReader(this.Scheduler, this, this.CancellationToken)); } else { throw new InvalidOperationException( string.Format( CultureInfo.CurrentCulture, Resources.UnsupportedBlobTypeException, sourceBlob.BlobType)); } case TransferLocationType.AzureFile: return(new CloudFileReader(this.Scheduler, this, this.CancellationToken)); default: throw new InvalidOperationException( string.Format( CultureInfo.CurrentCulture, Resources.UnsupportedTransferLocationException, sourceLocation.Type)); } }
protected void SetRequestOptions(TransferLocation location, BlobRequestOptions cmdletOptions) { BlobRequestOptions requestOptions = location.RequestOptions as BlobRequestOptions; if (null == requestOptions) { requestOptions = new BlobRequestOptions(); } if (cmdletOptions.MaximumExecutionTime != null) { requestOptions.MaximumExecutionTime = cmdletOptions.MaximumExecutionTime; } if (cmdletOptions.ServerTimeout != null) { requestOptions.ServerTimeout = cmdletOptions.ServerTimeout; } location.RequestOptions = requestOptions; }
private void SetRequestOptions(TransferLocation location, FileRequestOptions cmdletOptions) { FileRequestOptions requestOptions = location.RequestOptions as FileRequestOptions; if (null == requestOptions) { requestOptions = new FileRequestOptions(); } if (cmdletOptions.MaximumExecutionTime != null) { requestOptions.MaximumExecutionTime = cmdletOptions.MaximumExecutionTime; } if (cmdletOptions.ServerTimeout != null) { requestOptions.ServerTimeout = cmdletOptions.ServerTimeout; } requestOptions.DisableContentMD5Validation = true; location.RequestOptions = requestOptions; }
private TransferReaderWriterBase GetReader(TransferLocation sourceLocation) { switch (sourceLocation.Type) { case TransferLocationType.Stream: return new StreamedReader(this.Scheduler, this, this.CancellationToken); case TransferLocationType.FilePath: return new StreamedReader(this.Scheduler, this, this.CancellationToken); case TransferLocationType.AzureBlob: CloudBlob sourceBlob = (sourceLocation as AzureBlobLocation).Blob; if (sourceBlob is CloudPageBlob) { return new PageBlobReader(this.Scheduler, this, this.CancellationToken); } else if (sourceBlob is CloudBlockBlob) { return new BlockBasedBlobReader(this.Scheduler, this, this.CancellationToken); } else if (sourceBlob is CloudAppendBlob) { return new BlockBasedBlobReader(this.Scheduler, this, this.CancellationToken); } else { throw new InvalidOperationException( string.Format( CultureInfo.CurrentCulture, Resources.UnsupportedBlobTypeException, sourceBlob.BlobType)); } case TransferLocationType.AzureFile: return new CloudFileReader(this.Scheduler, this, this.CancellationToken); default: throw new InvalidOperationException( string.Format( CultureInfo.CurrentCulture, Resources.UnsupportedTransferLocationException, sourceLocation.Type)); } }