public SubCopy(Int32 id)
 {
     subCopyID     = id;
     count         = 0;
     copyState     = CopyState.UNOPEN;
     tblCopyDetail = TableManager.GetCopydetailByID(subCopyID);
 }
Example #2
0
 public override Expression CopyExpression(CopyState state)
 {
     return(new NewVertexAttrib(Source, state.GetType(_dt),
                                VertexAttributeType.CopyNullable(state), VertexBuffer.CopyNullable(state),
                                VertexBufferStride.CopyNullable(state), VertexBufferOffset.CopyNullable(state),
                                OptionalIndexType.CopyNullable(state), OptionalIndexBuffer.CopyNullable(state)));
 }
 private void SwitchState(CopyState cs)
 {
     copystate = cs;
     if (cs == CopyState.copying)
     {
         GetComponent <ShapeMenu>().StateSwitch(SelectionState.NOSELECTION);
         FormMenu.SetActive(false);
         MarkerBounds.SetActive(false);
         PastingModeSwitch.gameObject.SetActive(true);
         EnterCopyPasteMenu.interactable = true;
         FormPanel.GetComponent <Form>().FormSlider.GetComponent <FormSlider>().SwitchTextStatus("TAB/LMB/RMB/Q/I/ESC/DEL");
     }
     else
     {
         HeightSlider.gameObject.SetActive(true);
         MarkerBounds.SetActive(true);
         FormPanel.GetComponent <Form>().FormSlider.GetComponent <FormSlider>().SwitchTextStatus("Shape forming");
         if (cs == CopyState.empty)
         {
             PastingModeSwitch.gameObject.SetActive(false);
             RemoveCopyPoints();
             CopyClipboard.Clear();
             EnterCopyPasteMenu.interactable = false;
         }
         else if (cs == CopyState.non_empty)
         {
             PastingModeSwitch.gameObject.SetActive(false);
             RemoveCopyPoints();
         }
     }
 }
Example #4
0
        void LoadCopy(Player p, string file)
        {
            string path = FindCopy(p.name, file);

            if (path == null)
            {
                Player.Message(p, "No such copy exists"); return;
            }

            using (FileStream fs = File.OpenRead(path))
                using (GZipStream gs = new GZipStream(fs, CompressionMode.Decompress))
                {
                    CopyState state = new CopyState(0, 0, 0, 0, 0, 0, null, null);
                    if (path.CaselessEnds(".cpb"))
                    {
                        state.LoadFrom(gs);
                    }
                    else
                    {
                        state.LoadFromOld(gs, fs);
                    }
                    p.CopyBuffer = state;
                }
            Player.Message(p, "Loaded copy as " + file);
        }
        /// <summary>
        /// Creates an archived copy of the original package blob if it doesn't already exist.
        /// </summary>
        private void ArchiveOriginalPackageBlob(CloudBlockBlob originalPackageBlob, CloudBlockBlob latestPackageBlob)
        {
            // Copy the blob to backup only if it isn't already successfully copied
            if ((!originalPackageBlob.Exists()) || (originalPackageBlob.CopyState != null && originalPackageBlob.CopyState.Status != CopyStatus.Success))
            {
                if (!WhatIf)
                {
                    Log.Info("Backing up blob: {0} to {1}", latestPackageBlob.Name, originalPackageBlob.Name);
                    originalPackageBlob.StartCopyFromBlob(latestPackageBlob);
                    CopyState state = originalPackageBlob.CopyState;

                    for (int i = 0; (state == null || state.Status == CopyStatus.Pending) && i < SleepTimes.Length; i++)
                    {
                        Log.Info("(sleeping for a copy completion)");
                        Thread.Sleep(SleepTimes[i]);
                        originalPackageBlob.FetchAttributes(); // To get a refreshed CopyState

                        //refresh state
                        state = originalPackageBlob.CopyState;
                    }

                    if (state.Status != CopyStatus.Success)
                    {
                        string msg = $"Blob copy failed: CopyState={state.StatusDescription}";
                        Log.Error("(error) " + msg);
                        throw new BlobBackupFailedException(msg);
                    }
                }
            }
        }
Example #6
0
        /// <summary>
        /// Callback method to be called when the corresponding write operation completes.
        /// </summary>
        /// <param name="asyncResult">The result of the asynchronous operation.</param>
        private void FastCopyToCallback(IAsyncResult asyncResult)
        {
            if (asyncResult.CompletedSynchronously)
            {
                return;
            }

            StorageAsyncResult <NullType> result = (StorageAsyncResult <NullType>)asyncResult.AsyncState;

            result.UpdateCompletedSynchronously(asyncResult.CompletedSynchronously);

            CopyState copyState = (CopyState)result.OperationState;

            try
            {
                copyState.Destination.EndWrite(asyncResult);
                this.FastCopyToInternal(result);
            }
            catch (Exception e)
            {
                if (copyState.ExpiryTime.HasValue && DateTime.Now.CompareTo(copyState.ExpiryTime.Value) > 0)
                {
                    result.OnComplete(new TimeoutException());
                }
                else
                {
                    result.OnComplete(e);
                }
            }
        }
Example #7
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            if (p.CurrentCopy == null)
            {
                p.Message("You haven't copied anything yet"); return;
            }

            CopyState cState = p.CurrentCopy;

            BlockDefinition[] defs = p.level.CustomBlockDefs;

            foreach (string arg in message.SplitSpaces())
            {
                if (arg.CaselessEq("x"))
                {
                    Flip.MirrorX(cState, defs);
                    p.Message("Flipped copy across the X (east/west) axis.");
                }
                else if (arg.CaselessEq("y") || arg.CaselessEq("u"))
                {
                    Flip.MirrorY(cState, defs);
                    p.Message("Flipped copy across the Y (vertical) axis.");
                }
                else if (arg.CaselessEq("z"))
                {
                    Flip.MirrorZ(cState, defs);
                    p.Message("Flipped copy across the Z (north/south) axis.");
                }
            }
        }
        private async Task GetCopyStateAsync()
        {
            Debug.Assert(
                this.state == State.GetCopyState,
                "GetCopyStateAsync called, but state isn't GetCopyState");

            this.hasWork = false;
            this.StartCallbackHandler();

            CopyState copyState = null;

            try
            {
                copyState = await this.FetchCopyStateAsync();
            }
            catch (StorageException se)
            {
                if (null != se.RequestInformation &&
                    se.RequestInformation.HttpStatusCode == (int)HttpStatusCode.NotFound)
                {
                    // The reason of 404 (Not Found) may be that the destination blob has not been created yet.
                    this.RestartTimer();
                }
                else
                {
                    throw;
                }
            }

            this.HandleFetchCopyStateResult(copyState);
        }
Example #9
0
        void LoadCopy(Player p, string file)
        {
            string path = FindCopy(p.name, file);

            if (path == null)
            {
                p.Message("No such copy exists"); return;
            }

            using (FileStream fs = File.OpenRead(path))
                using (GZipStream gs = new GZipStream(fs, CompressionMode.Decompress))
                {
                    CopyState state = new CopyState(0, 0, 0, 0, 0, 0);
                    if (path.CaselessEnds(".cpb"))
                    {
                        state.LoadFrom(gs);
                    }
                    else
                    {
                        state.LoadFromOld(gs, fs);
                    }

                    state.CopySource = "file " + file;
                    p.CurrentCopy    = state;
                }
            p.Message("Loaded copy from " + file);
        }
Example #10
0
        public override Brush Construct(BrushArgs args)
        {
            CopyState cState = args.Player.CurrentCopy;

            if (cState == null)
            {
                args.Player.Message("You haven't copied anything yet.");
                return(null);
            }

            if (args.Message.Length == 0)
            {
                return(new SimplePasteBrush(cState));
            }
            string[] parts = args.Message.SplitSpaces();

            if (parts[0].CaselessEq("not"))
            {
                PasteNotBrush brush = new PasteNotBrush(cState);
                brush.Exclude = ReplaceBrushFactory.GetBlocks(args.Player, 1, parts.Length, parts);
                return(brush.Exclude == null ? null : brush);
            }
            else
            {
                PasteBrush brush = new PasteBrush(cState);
                brush.Include = ReplaceBrushFactory.GetBlocks(args.Player, 0, parts.Length, parts);
                return(brush.Include == null ? null : brush);
            }
        }
Example #11
0
        public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush)
        {
            Vec3U16   p1       = marks[0];
            CopyState state    = CopyState;
            bool      pasteAir = state.PasteAir;
            // Adjust for the fact that paste origin may be outside the map.
            short offX = (short)p1.X, offY = (short)p1.Y, offZ = (short)p1.Z;

            for (int i = 0; i < state.Blocks.Length; i++)
            {
                ushort locX, locY, locZ;
                byte   b = state.Blocks[i], extB = state.ExtBlocks[i];
                state.GetCoords(i, out locX, out locY, out locZ);

                ushort x = (ushort)(locX + offX), y = (ushort)(locY + offY), z = (ushort)(locZ + offZ);
                byte   type = lvl.GetTile(x, y, z), extType = 0;
                if (type == Block.custom_block)
                {
                    extType = lvl.GetExtTile(x, y, z);
                }

                bool place = lvl.InBound(x, y, z) && (b != type || (b == Block.custom_block && extB != extType));
                if ((b != Block.air || pasteAir) && place)
                {
                    PlaceBlock(p, lvl, x, y, z, b, extB);
                }
            }
        }
Example #12
0
        void LoadCopy(Player p, string file)
        {
            string path      = "extra/savecopy/" + p.name + "/" + file;
            bool   existsNew = File.Exists(path + ".cpb");
            bool   existsOld = File.Exists(path + ".cpy");

            if (!existsNew && !existsOld)
            {
                Player.SendMessage(p, "No such copy exists"); return;
            }
            path = existsNew ? path + ".cpb" : path + ".cpy";

            using (FileStream fs = new FileStream(path, FileMode.Open))
                using (GZipStream gs = new GZipStream(fs, CompressionMode.Decompress))
                {
                    CopyState state = new CopyState(0, 0, 0, 0, 0, 0, null, null);
                    if (existsNew)
                    {
                        state.LoadFrom(gs);
                    }
                    else
                    {
                        state.LoadFromOld(gs, fs);
                    }
                    p.CopyBuffer = state;
                }
            Player.SendMessage(p, "Loaded copy as " + file);
        }
Example #13
0
        static void CopyCallback([NotNull] Player player, [NotNull] Vector3I[] marks, [NotNull] object tag)
        {
            int         sx     = Math.Min(marks[0].X, marks[1].X);
            int         ex     = Math.Max(marks[0].X, marks[1].X);
            int         sy     = Math.Min(marks[0].Y, marks[1].Y);
            int         ey     = Math.Max(marks[0].Y, marks[1].Y);
            int         sz     = Math.Min(marks[0].Z, marks[1].Z);
            int         ez     = Math.Max(marks[0].Z, marks[1].Z);
            BoundingBox bounds = new BoundingBox(sx, sy, sz, ex, ey, ez);

            int volume = bounds.Volume;

            if (!player.CanDraw(volume))
            {
                player.MessageNow(
                    "You are only allowed to run commands that affect up to {0} blocks. This one would affect {1} blocks.",
                    player.Info.Rank.DrawLimit,
                    volume);
                return;
            }

            // remember dimensions and orientation
            CopyState copyInfo = new CopyState(marks[0], marks[1]);

            Map   map         = player.WorldMap;
            World playerWorld = player.World;

            if (playerWorld == null)
            {
                PlayerOpException.ThrowNoWorld(player);
            }

            for (int x = sx; x <= ex; x++)
            {
                for (int y = sy; y <= ey; y++)
                {
                    for (int z = sz; z <= ez; z++)
                    {
                        copyInfo.Blocks[x - sx, y - sy, z - sz] = map.GetBlock(x, y, z);
                    }
                }
            }

            copyInfo.OriginWorld = playerWorld.Name;
            copyInfo.CopyTime    = DateTime.UtcNow;
            player.SetCopyState(copyInfo);

            player.MessageNow("{0} blocks copied into slot #{1}, origin at {2} corner. You can now &H/Paste",
                              volume,
                              player.CopySlot + 1,
                              copyInfo.OriginCorner);

            Logger.Log(LogType.UserActivity,
                       "{0} copied {1} blocks from world {2} (between {3} and {4}).",
                       player.Name,
                       volume,
                       playerWorld.Name,
                       bounds.MinVertex,
                       bounds.MaxVertex);
        }
Example #14
0
        public void UpdateState()
        {
            //update subcoyt first
            if (tblCopy.GetCopyTypebyIndex(0) == (int)CopyType.NORMAL)
            {
                foreach (SubCopy copy in subCopys)
                {
                    if (copy.count > 0)
                    {
                        copy.copyState = CopyState.PASSED;
                    }
                    else
                    {
                        copy.copyState = CopyState.UNOPEN;
                    }
                }
            }

            CopyState state = CopyState.UNOPEN;

            foreach (SubCopy copy in subCopys)
            {
                state = copy.copyState;
                if (state == CopyState.OPENED)
                {
                    copyState = CopyState.OPENED;
                    return;
                }
            }
            copyState = state;
        }
Example #15
0
        private String CopyStateText(CopyState state)
        {
            if (state == null)
            {
                return(String.Empty);
            }
            else
            {
                switch (state.Status)
                {
                case CopyStatus.Pending:
                    return("Pending");

                case CopyStatus.Success:
                    return("Success");

                case CopyStatus.Aborted:
                    return("Aborted");

                case CopyStatus.Failed:
                    return("Failed");

                case CopyStatus.Invalid:
                    return("Invalid");

                default:
                    return("Other");
                }
            }
        }
Example #16
0
        void SaveCopy(Player p, string file)
        {
            if (!Directory.Exists("extra/savecopy"))
            {
                Directory.CreateDirectory("extra/savecopy");
            }
            if (!Directory.Exists("extra/savecopy/" + p.name))
            {
                Directory.CreateDirectory("extra/savecopy/" + p.name);
            }
            if (Directory.GetFiles("extra/savecopy/" + p.name).Length > 15)
            {
                p.Message("You can only save a maxmium of 15 copies. /copy delete some.");
                return;
            }

            CopyState cState = p.CurrentCopy;

            if (cState == null)
            {
                p.Message("You haven't copied anything yet"); return;
            }

            string path = "extra/savecopy/" + p.name + "/" + file + ".cpb";

            using (FileStream fs = File.Create(path))
                using (GZipStream gs = new GZipStream(fs, CompressionMode.Compress))
                {
                    cState.SaveTo(gs);
                }
            p.Message("Saved copy as " + file);
        }
Example #17
0
        public override void Perform(Vec3U16[] marks, Player p, Level lvl, Brush brush)
        {
            Vec3U16   p1       = marks[0];
            CopyState state    = CopyState;
            bool      pasteAir = state.PasteAir;

            ExtBlock[] include = Include, exclude = Exclude;
            // Adjust for the fact that paste origin may be outside the map.
            short offX = (short)p1.X, offY = (short)p1.Y, offZ = (short)p1.Z;

            for (int i = 0; i < state.Blocks.Length; i++)
            {
                ushort locX, locY, locZ;
                byte   b = state.Blocks[i], extB = state.ExtBlocks[i];
                state.GetCoords(i, out locX, out locY, out locZ);

                ushort x = (ushort)(locX + offX), y = (ushort)(locY + offY), z = (ushort)(locZ + offZ);
                byte   type = lvl.GetTile(x, y, z), extType = 0;
                if (type == Block.custom_block)
                {
                    extType = lvl.GetExtTile(x, y, z);
                }

                bool place = lvl.InBound(x, y, z) && (b != type || (b == Block.custom_block && extB != extType));
                if (!place || (b == Block.air && !pasteAir))
                {
                    continue;
                }

                if (exclude != null)
                {
                    for (int j = 0; j < exclude.Length; j++)
                    {
                        ExtBlock block = exclude[j];
                        if (b == block.Type && (b != Block.custom_block || extB == block.ExtType))
                        {
                            place = false; break;
                        }
                    }
                    if (!place)
                    {
                        continue;
                    }
                    PlaceBlock(p, lvl, x, y, z, b, extB);
                }

                if (include != null)
                {
                    for (int j = 0; j < include.Length; j++)
                    {
                        ExtBlock block = include[j];
                        if (b == block.Type && (b != Block.custom_block || extB == block.ExtType))
                        {
                            PlaceBlock(p, lvl, x, y, z, b, extB); break;
                        }
                    }
                }
            }
        }
Example #18
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                message = "y";
            }
            if (p.CurrentCopy == null)
            {
                p.Message("You haven't copied anything yet"); return;
            }

            CopyState cState = p.CurrentCopy;
            string    opt    = message.ToLower();

            BlockDefinition[] defs = p.level.CustomBlockDefs;

            // /Mirror used to be part of spin
            if (opt.CaselessStarts("mirror"))
            {
                p.Message("&T/Spin {0} &Sis deprecated. Use &T/Mirror &Sinstead", opt);
                return;
            }

            string[] args  = opt.SplitSpaces();
            char     axis  = 'Y';
            int      angle = 90;

            if (!Handle(ref axis, ref angle, args[0]))
            {
                Help(p); return;
            }
            if (args.Length > 1 && !Handle(ref axis, ref angle, args[1]))
            {
                Help(p); return;
            }

            CopyState newState = cState;

            if (angle == 0)
            {
            }
            else if (axis == 'X')
            {
                newState = Flip.RotateX(cState, angle, defs);
            }
            else if (axis == 'Y')
            {
                newState = Flip.RotateY(cState, angle, defs);
            }
            else if (axis == 'Z')
            {
                newState = Flip.RotateZ(cState, angle, defs);
            }

            newState.CopySource = cState.CopySource;
            newState.CopyTime   = cState.CopyTime;
            p.CurrentCopy       = newState;
            p.Message("Rotated copy {0} degrees around the {1} axis", angle, axis);
        }
Example #19
0
 public void SetCurrentCopy(CopyState state)
 {
     while (CurrentCopySlot >= CopySlots.Count)
     {
         CopySlots.Add(null);
     }
     CopySlots[CurrentCopySlot] = state;
 }
Example #20
0
File: For.cs Project: mortend/uno
 public override Statement CopyStatement(CopyState state)
 {
     return(new For(Source,
                    OptionalInitializer.CopyNullable(state),
                    OptionalCondition.CopyNullable(state),
                    OptionalIncrement.CopyNullable(state),
                    OptionalBody.CopyNullable(state)));
 }
        public async Task refreshCopyJobAsync()
        {
            TableStorage <CopyJob> copyJobTableStorage                   = new TableStorage <CopyJob>(masterStorageAccount, "jobs");
            TableStorage <CopyJob> copyCompleteJobTableStorage           = new TableStorage <CopyJob>(masterStorageAccount, "completejobs");
            TableStorage <ReplicationStorageAccount> accountTableStorage = new TableStorage <ReplicationStorageAccount>(masterStorageAccount, "accounts");
            List <ReplicationStorageAccount>         accounts            = await accountTableStorage.GetAllAsync();

            List <Task> tasks = new List <Task>();

            Parallel.ForEach <ReplicationStorageAccount>(accounts, async(account) =>
            {
                TableContinuationToken continuationToken = null;
                TableQuery <CopyJob> query = new TableQuery <CopyJob>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, account.RowKey));
                CloudStorageAccount targetStorageAccount = CloudStorageAccount.Parse(account.connectionString);
                CloudBlobClient blobClient = targetStorageAccount.CreateCloudBlobClient();
                do
                {
                    var response      = await copyJobTableStorage.table.ExecuteQuerySegmentedAsync(query, continuationToken);
                    continuationToken = response.ContinuationToken;

                    tasks.Add(Task.Run(async() =>
                    {
                        foreach (var job in response.Results)
                        {
                            CloudBlobContainer container = blobClient.GetContainerReference(job.targetContainer);
                            CloudBlockBlob blob          = container.GetBlockBlobReference(job.targetBlobName);

                            await blob.FetchAttributesAsync();
                            CopyState state = blob.CopyState;
                            job.Update(state);

                            //log.Info($"Updated {job.copyId} -  status {job.copyStatus}");


                            if (job.copyStatus == "Success")
                            {
                                try
                                {
                                    await copyCompleteJobTableStorage.InsertOrReplaceAsync(job);
                                    await copyJobTableStorage.Delete(job);
                                    //log.Info($"Deleted completed job {job.copyId}");
                                }
                                catch (StorageException ex)
                                {
                                    // log.Info($"Exception deleting CopyJob {job.copyId}: {ex.Message}");
                                }
                            }
                            else
                            {
                                await copyJobTableStorage.InsertOrReplaceAsync(job);
                            }
                        }
                    }));
                }while (continuationToken != null);
            });

            Task.WaitAll(tasks.ToArray());
        }
Example #22
0
        void BlockchangeOffset(Player p, ushort x, ushort y, ushort z, byte type, byte extType)
        {
            RevertAndClearState(p, x, y, z);
            CopyState state = p.CopyBuffer;

            state.Offset.X = state.OriginX - x;
            state.Offset.Y = state.OriginY - y;
            state.Offset.Z = state.OriginZ - z;
        }
        private void HandleFetchCopyStateResult(CopyState copyState)
        {
            if (null == copyState)
            {
                // Reach here, the destination should already exist.
                string exceptionMessage = string.Format(
                    CultureInfo.CurrentCulture,
                    Resources.FailedToRetrieveCopyStateForObjectException,
                    this.DestUri.ToString());

                throw new TransferException(
                          TransferErrorCode.FailToRetrieveCopyStateForObject,
                          exceptionMessage);
            }
            else
            {
                // Verify we are monitoring the right blob copying process.
                if (!this.TransferJob.CopyId.Equals(copyState.CopyId))
                {
                    throw new TransferException(
                              TransferErrorCode.MismatchCopyId,
                              Resources.MismatchFoundBetweenLocalAndServerCopyIdsException);
                }

                if (CopyStatus.Success == copyState.Status)
                {
                    this.UpdateTransferProgress(copyState);

                    this.DisposeStatusRefreshTimer();

                    this.SetFinished();
                }
                else if (CopyStatus.Pending == copyState.Status)
                {
                    this.UpdateTransferProgress(copyState);

                    // Wait a period to restart refresh the status.
                    this.RestartTimer();
                }
                else
                {
                    string exceptionMessage = string.Format(
                        CultureInfo.CurrentCulture,
                        Resources.FailedToAsyncCopyObjectException,
                        this.GetSourceUri().ToString(),
                        this.DestUri.ToString(),
                        copyState.Status.ToString(),
                        copyState.StatusDescription);

                    // CopyStatus.Invalid | Failed | Aborted
                    throw new TransferException(
                              TransferErrorCode.AsyncCopyFailed,
                              exceptionMessage);
                }
            }
        }
        /// <summary>
        /// Builds a <see cref="CopyState"/> object from the given strings containing formatted copy information.
        /// </summary>
        /// <param name="copyStatusString">The copy status, as a string.</param>
        /// <param name="copyId">The copy ID.</param>
        /// <param name="copySourceString">The source URI of the copy, as a string.</param>
        /// <param name="copyProgressString">A string formatted as progressBytes/TotalBytes.</param>
        /// <param name="copyCompletionTimeString">The copy completion time, as a string, or null.</param>
        /// <param name="copyStatusDescription">The copy status description, if any.</param>
        /// <returns>A <see cref="CopyState"/> object populated from the given strings.</returns>
        internal static CopyState GetCopyAttributes(
            string copyStatusString,
            string copyId,
            string copySourceString,
            string copyProgressString,
            string copyCompletionTimeString,
            string copyStatusDescription)
        {
            CopyState copyAttributes = new CopyState
            {
                CopyId            = copyId,
                StatusDescription = copyStatusDescription
            };

            switch (copyStatusString)
            {
            case Constants.CopySuccessValue:
                copyAttributes.Status = CopyStatus.Success;
                break;

            case Constants.CopyPendingValue:
                copyAttributes.Status = CopyStatus.Pending;
                break;

            case Constants.CopyAbortedValue:
                copyAttributes.Status = CopyStatus.Aborted;
                break;

            case Constants.CopyFailedValue:
                copyAttributes.Status = CopyStatus.Failed;
                break;

            default:
                copyAttributes.Status = CopyStatus.Invalid;
                break;
            }

            if (!string.IsNullOrEmpty(copyProgressString))
            {
                string[] progressSequence = copyProgressString.Split('/');
                copyAttributes.BytesCopied = long.Parse(progressSequence[0], CultureInfo.InvariantCulture);
                copyAttributes.TotalBytes  = long.Parse(progressSequence[1], CultureInfo.InvariantCulture);
            }

            if (!string.IsNullOrEmpty(copySourceString))
            {
                copyAttributes.Source = new Uri(copySourceString);
            }

            if (!string.IsNullOrEmpty(copyCompletionTimeString))
            {
                copyAttributes.CompletionTime = copyCompletionTimeString.ToUTCTime();
            }

            return(copyAttributes);
        }
Example #25
0
        public static Method[] Copy(this IReadOnlyList <Method> candidates, CopyState state)
        {
            var result = new Method[candidates.Count];

            for (int i = 0; i < candidates.Count; i++)
            {
                result[i] = state.GetMember(candidates[i]);
            }
            return(result);
        }
Example #26
0
        public override Expression CopyExpression(CopyState state)
        {
            var result = new Lambda(Source, Parameters.Copy(state), state.GetType(DelegateType), null);

            state.AddLambda(this, result);
            var body = Body.CopyStatement(state);

            result.SetBody(body);
            return(result);
        }
Example #27
0
        public override Statement CopyStatement(CopyState state)
        {
            var r = new Scope(Source);

            foreach (var s in Statements)
            {
                r.Statements.Add(s.CopyStatement(state));
            }

            return(r);
        }
Example #28
0
        public static CatchBlock[] Copy(this CatchBlock[] c, CopyState state)
        {
            var r = new CatchBlock[c.Length];

            for (var i = 0; i < c.Length; i++)
            {
                r[i] = c[i].Copy(state);
            }

            return(r);
        }
Example #29
0
 public CopyJob(CopyState state, string lTargetContainer, string lTargetBlobName, string lTargetUri, string targetStorageAccountId)
 {
     RowKey               = state.CopyId;
     PartitionKey         = targetStorageAccountId;
     targetStorageAccount = targetStorageAccountId;
     targetContainer      = lTargetContainer;
     targetBlobName       = lTargetBlobName;
     targetUri            = lTargetUri;
     sourceUri            = state.Source.ToString();
     Update(state);
 }
Example #30
0
        public static Statement[] CopyStatements(this Statement[] list, CopyState s)
        {
            var result = new Statement[list.Length];

            for (var i = 0; i < list.Length; i++)
            {
                result[i] = list[i].CopyStatement(s);
            }

            return(result);
        }
        /// <summary>
        /// Builds a <see cref="CopyState"/> object from the given strings containing formatted copy information.
        /// </summary>
        /// <param name="copyStatusString">The copy status, as a string.</param>
        /// <param name="copyId">The copy ID.</param>
        /// <param name="copySourceString">The source URI of the copy, as a string.</param>
        /// <param name="copyProgressString">A string formatted as progressBytes/TotalBytes.</param>
        /// <param name="copyCompletionTimeString">The copy completion time, as a string, or null.</param>
        /// <param name="copyStatusDescription">The copy status description, if any.</param>
        /// <returns>A <see cref="CopyState"/> object populated from the given strings.</returns>
        internal static CopyState GetCopyAttributes(
            string copyStatusString,
            string copyId,
            string copySourceString,
            string copyProgressString,
            string copyCompletionTimeString,
            string copyStatusDescription)
        {
            CopyState copyAttributes = new CopyState
            {
                CopyId = copyId,
                StatusDescription = copyStatusDescription
            };

            switch (copyStatusString)
            {
                case Constants.CopySuccessValue:
                    copyAttributes.Status = CopyStatus.Success;
                    break;
                
                case Constants.CopyPendingValue:
                    copyAttributes.Status = CopyStatus.Pending;
                    break;
                
                case Constants.CopyAbortedValue:
                    copyAttributes.Status = CopyStatus.Aborted;
                    break;
                
                case Constants.CopyFailedValue:
                    copyAttributes.Status = CopyStatus.Failed;
                    break;
                
                default:
                    copyAttributes.Status = CopyStatus.Invalid;
                    break;
            }

            if (!string.IsNullOrEmpty(copyProgressString))
            {
                string[] progressSequence = copyProgressString.Split('/');
                copyAttributes.BytesCopied = long.Parse(progressSequence[0]);
                copyAttributes.TotalBytes = long.Parse(progressSequence[1]);
            }

            if (!string.IsNullOrEmpty(copySourceString))
            {
                copyAttributes.Source = new Uri(copySourceString);
            }

            if (!string.IsNullOrEmpty(copyCompletionTimeString))
            {
                copyAttributes.CompletionTime = copyCompletionTimeString.ToUTCTime();
            }

            return copyAttributes;
        }