Exemplo n.º 1
0
            public void DeliverSerializedMessage(SerializedMessage message, ReturnAddress from)
            {
                lock (this)
                {
                    if (message.Header.SequenceNumber == this.nextSequenceNumbers[from.VertexID])
                    {
                        //Console.Error.WriteLine("Delivering message {0} L = {1} A = {2}", message.Header.SequenceNumber, message.Header.Length, message.Body.Available);
                        //foreach (Pair<Int64, Pointstamp> currentRecord in this.decoder.Elements(message))
                        //    Console.Error.WriteLine("-- {0}", currentRecord);

                        //this.nextSequenceNumber++;
                        this.nextSequenceNumbers[from.VertexID]++;

                        foreach (var typedMessage in this.decoder.AsTypedMessages(message))
                        {
                            this.consumer.ProcessCountChange(typedMessage);
                            typedMessage.Release();
                        }

                        this.Flush(from);
                    }
                    else
                    {
                        //Console.Error.WriteLine("Discarding message {0} (expecting {1}) L = {2} A = {3}", message.Header.SequenceNumber, this.nextSequenceNumber, message.Header.Length, message.Body.Available);
                        //foreach (Pair<Int64, Pointstamp> currentRecord in this.decoder.Elements(message))
                        //    Console.Error.WriteLine("-- {0}", currentRecord);
                    }
                }
            }
Exemplo n.º 2
0
 public void Send(Message <S, T> message, ReturnAddress from)
 {
     this.encodersFromLocalVertices[from.ThreadIndex].SetCurrentTime(message.time);
     this.encodersFromLocalVertices[from.ThreadIndex].Write(new ArraySegment <S>(message.payload, 0, message.length), from.VertexID);
     //for (int i = 0; i < message.length; ++i)
     //    this.encodersFromLocalVertices[from.ThreadIndex].Write(message.payload[i], from.VertexID);
 }
Exemplo n.º 3
0
        internal static Value Make(ReturnAddress ra)
        {
            Value result = value;

            result.Kind = Kinds.ReturnAddress;
            result.returnAddressValue = ra;
            return(result);
        }
Exemplo n.º 4
0
        public async Task <Result> ConfirmApply([FromBody] AdminRefundConfirmApplyRequest request)
        {
            var returnApply = await _returnApplyRepository.Query()
                              .Include(e => e.OrderItem)
                              .FirstOrDefaultAsync(e => e.Id == request.Id);

            if (returnApply == null)
            {
                return(Result.Fail(ResultCodes.IdInvalid));
            }
            if (returnApply.Status != ReturnAuditStatus.NotAudit)
            {
                return(Result.Fail(ResultCodes.RequestParamError, "当前申请不允许修改状态"));
            }

            var address = await _addressRepository.Query()
                          .Include(e => e.Province)
                          .Include(e => e.City)
                          .Include(e => e.Area)
                          .FirstOrDefaultAsync(e => e.Id == request.RefundAddressId);

            if (address == null)
            {
                return(Result.Fail(ResultCodes.RequestParamError, "无效地址"));
            }

            var returnAddress = new ReturnAddress
            {
                ReturnApplyId = returnApply.Id,
                AreaName      = address.Area.Name,
                CityName      = address.City.Name,
                Createat      = DateTime.Now,
                DetailInfo    = address.DetailInfo,
                PostalCode    = address.PostalCode.ToString(),
                ProvinceName  = address.Province.Name,
                Remarks       = request.Remarks,
                TelNumber     = address.TelNumber,
                UserName      = address.UserName,
            };

            returnApply.Status           = ReturnAuditStatus.Agree;
            returnApply.AuditMessage     = request.Remarks;
            returnApply.AuditTime        = DateTime.Now;
            returnApply.OrderItem.Status = OrderItemStatus.ConfirmApply;

            _returnApplyRepository.Update(returnApply, false);
            using (var transaction = _returnApplyRepository.BeginTransaction())
            {
                await _returnApplyRepository.SaveAsync();

                await _refundAddressRepository.InsertAsync(returnAddress);

                transaction.Commit();
            }

            return(Result.Ok());
        }
Exemplo n.º 5
0
            public void DeliverSerializedMessage(SerializedMessage message, ReturnAddress from)
            {
                foreach (var typedMessage in this.decoder.AsTypedMessages(message))
                {
                    this.consumer.ProcessCountChange(typedMessage);
                    typedMessage.Release();
                }

                this.Flush(from);
            }
Exemplo n.º 6
0
        public void OnReceive(Message <string, IterationIn <T> > message, ReturnAddress sender)
        {
            var stripped = new Pair <string, T> [message.length];

            for (int i = 0; i < message.length; i++)
            {
                stripped[i].First  = message.payload[i];
                stripped[i].Second = message.time.outerTime;
            }

            Context.Reporting.ForwardLog(stripped);
        }
Exemplo n.º 7
0
        ReturnAddress RebuildReturnAddress(
            object[] objects, int index, Composite composite, Func <int, object> reader)
        {
            var result = new ReturnAddress();

            objects [index] = result;

            result.Environment    = (VmEnvironment)reader(composite.Elements [0]);
            result.ProgramCounter = (int)(long)reader(composite.Elements [1]);

            return(result);
        }
Exemplo n.º 8
0
        int SerializeReturnAddress(ReturnAddress returnAddress, object obj)
        {
            var composite = new Composite {
                Kind     = ObjectTypes.ReturnAddress,
                Elements = new int[2]
            };
            var result = SerializeOneHashed(composite, obj);

            composite.Elements [0] = Serialize(returnAddress.Environment);
            composite.Elements [1] = SerializeOne(returnAddress.ProgramCounter);
            return(result);
        }
Exemplo n.º 9
0
 /// <summary>
 ///     Returns a hash code for this instance.
 /// </summary>
 /// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns>
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = StackPointer.GetHashCode();
         hashCode = (hashCode * 397) ^ ReturnAddress.GetHashCode();
         hashCode = (hashCode * 397) ^ (Module != null ? Module.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (FunctionName != null ? FunctionName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (int)Offset;
         return(hashCode);
     }
 }
 public Postbox(int channelID, VertexOutput <S, T> sender, StageInput <S, T> receiverBundle, Mailbox <S, T>[] mailboxes, Action <S[], int[], int> routingHashcodeFunction, NetworkChannel networkChannel)
 {
     this.threadindex              = sender.Vertex.Scheduler.Index;
     this.channelID                = channelID;
     this.sender                   = sender;
     this.vertexid                 = sender.Vertex.VertexId;
     this.receiverBundle           = receiverBundle;
     this.routingHashcodesFunction = routingHashcodeFunction;
     this.networkChannel           = networkChannel;
     this.mailboxes                = mailboxes;
     this.returnAddress            = new ReturnAddress(this.ProcessID, this.vertexid, this.threadindex);
 }
Exemplo n.º 11
0
        public ActionResult Back()
        {
            ReturnAddress WhereToGo = Session.PopReturnAddress();

            if (WhereToGo.Controller == null)
            {
                return(RedirectToAction(WhereToGo.Module));
            }
            else
            {
                return(RedirectToAction(WhereToGo.Module, WhereToGo.Controller));
            }
        }
Exemplo n.º 12
0
        private void PostBufferAndPossiblyCutThrough(ReturnAddress from)
        {
            // no matter what, post the buffer and refresh local storage.
            this.Post(this.messagesFromLocalVertices[from.ThreadIndex]);
            this.messagesFromLocalVertices[from.ThreadIndex] = new Message <S, T>();

            // we may want to cut-through.
            if (this.endpoint.Vertex.Scheduler.Index == from.ThreadIndex && this.endpoint.AvailableEntrancy >= 0)
            {
                this.endpoint.AvailableEntrancy = this.endpoint.AvailableEntrancy - 1;
                this.Drain();
                this.endpoint.AvailableEntrancy = this.endpoint.AvailableEntrancy + 1;
            }
        }
Exemplo n.º 13
0
        public Postbox(int channelID, VertexOutput <S, T> sender, StageInput <S, T> receiverBundle, Mailbox <S, T>[] mailboxes, Func <S, int> routingHashcodeFunction, NetworkChannel networkChannel)
        {
            this.threadindex             = sender.Vertex.Scheduler.Index;
            this.channelID               = channelID;
            this.sender                  = sender;
            this.vertexid                = sender.Vertex.VertexId;
            this.receiverBundle          = receiverBundle;
            this.routingHashcodeFunction = routingHashcodeFunction;
            this.networkChannel          = networkChannel;
            this.mailboxes               = mailboxes;
            this.returnAddress           = new ReturnAddress(this.ProcessID, this.vertexid, this.threadindex);

            this.localTempBuffer = new Message <S, T>();

            //this.sendSequenceNumbers = new int[Naiad.Processes, this.receiverBundle.LocalParallelism];
        }
Exemplo n.º 14
0
        /// <summary>
        /// Enqueues the incoming network message on the shared queue, called by the network channel.
        /// </summary>
        /// <param name="message">message</param>
        /// <param name="from">sender</param>
        public override void DeliverSerializedMessage(SerializedMessage message, ReturnAddress from)
        {
            this.sharedSerializedQueue.Enqueue(message);

            if (this.sharedSerializedQueue.Count > SerializedQueueHighWatermark)
            {
                SerializedQueueHighWatermark *= 2;
            }

            if (!this.dirty)
            {
                this.dirty = true;
            }

            this.postOffice.Signal();
        }
Exemplo n.º 15
0
        /// <summary>
        /// Compare addresses to see if they have the same delivery point and carrier route.
        /// Returns address provided by the US Postal Service with the delivery point and carrier route
        /// </summary>
        /// <param name="addr1">Address 1</param>
        /// <param name="addr2">Address 1</param>
        /// <param name="returnAddr1">USPS Address 1</param>
        /// <param name="returnAddr2">USPS Address 2</param>
        /// <returns>boolean</returns>
        public bool Compare(Address addr1, Address addr2, out ReturnAddress returnAddr1, out ReturnAddress returnAddr2)
        {
            bool retVal = false;

            //Normalize the addresses
            returnAddr1 = Normalize(addr1);
            returnAddr2 = Normalize(addr2);

            //Compare the data
            if (returnAddr1 != null && returnAddr2 != null)
            {
                if (returnAddr1.DeliveryPoint == returnAddr2.DeliveryPoint && returnAddr1.CarrierRoute == returnAddr2.CarrierRoute)
                    retVal = true;
            }

            return retVal;
        }
Exemplo n.º 16
0
        /// <summary>
        /// Flushes the queue of local messages.
        /// Called by the postbox.
        /// </summary>
        /// <param name="from">Postbox of the upstream operator</param>
        public override void Flush(ReturnAddress from)
        {
            if (this.messagesFromLocalVertices[from.ThreadIndex].length > 0)
            {
                this.PostBufferAndPossiblyCutThrough(from);
            }

            // XXX : Assumes placement is the same, which is brittle
            if (this.VertexId == from.VertexID)
            {
                if (this.endpoint.AvailableEntrancy >= 0)
                {
                    this.endpoint.AvailableEntrancy = this.endpoint.AvailableEntrancy - 1;
                    endpoint.Flush();
                    this.endpoint.AvailableEntrancy = this.endpoint.AvailableEntrancy + 1;
                }

                this.progressBuffer.Flush();
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Flushes the queue of local messages.
        /// Called by the postbox.
        /// </summary>
        /// <param name="from">Postbox of the upstream operator</param>
        public override void Flush(ReturnAddress from)
        {
            if (this.messagesFromLocalVertices[from.ThreadIndex].length > 0)
            {
                this.PostBufferAndPossiblyCutThrough(from);
            }

            // If we are running on the same thread, the flush can be delivered directly.
            if (this.endpoint.Vertex.Scheduler.Index == from.ThreadIndex)
            {
                if (this.endpoint.AvailableEntrancy >= 0)
                {
                    this.endpoint.AvailableEntrancy = this.endpoint.AvailableEntrancy - 1;
                    endpoint.Flush();
                    this.endpoint.AvailableEntrancy = this.endpoint.AvailableEntrancy + 1;
                }

                this.progressBuffer.Flush();
            }
        }
Exemplo n.º 18
0
        private bool run(LabelInst label)
        {
            if (InitStack == null)
            {
                MessageBox.Show("Initial stack has not been set yet!", "StackFish", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }

            // Recreate return address to rename callee to current label & set return address -1
            StackItem lastItem = InitStack[InitStack.Count - 1];

            if (lastItem is ReturnAddress)
            {
                ReturnAddress ra = lastItem as ReturnAddress;
                InitStack[InitStack.Count - 1] = new ReturnAddress(ra.CallerName, label.Name, -1);
            }

            // Create simulator
            this.simulator = new Simulator(file, InitStack); // TODO initial registers
            simulator.OnInstructionReady          += Simulator_OnInstructionReady;
            simulator.Registers.OnRegisterChanged += Registers_OnRegisterChanged;
            simulator.Registers.OnPointerChanged  += Registers_OnPointerChanged;
            simulator.Registers.OnFlagChanged     += Registers_OnFlagChanged;
            simulator.Stack.OnStackChanged        += Stack_OnStackChanged;
            simulator.Start(label.Index);

            // Update controls
            startToolStripMenuItem.Visible   = false;
            runningToolStripMenuItem.Visible = true;
            updateRegisters();
            updateFlags();
            drawStack();
            executed = 0;
            updateExecuted();
            setStatus("Started at " + label.Name + "! Press F5 to step forward, Shift+F5 to step backward");
            return(true);
        }
Exemplo n.º 19
0
        public override void Send(Message <S, T> records, ReturnAddress from)
        {
            for (int i = 0; i < records.length; i++)
            {
                // Message has been disabled to conserve memory.
                if (this.messagesFromLocalVertices[from.ThreadIndex].Unallocated)
                {
                    this.messagesFromLocalVertices[from.ThreadIndex].Allocate();
                    this.messagesFromLocalVertices[from.ThreadIndex].time = records.time;
                }

                // we may need to flush the buffered message because it has a different time.
                if (!this.messagesFromLocalVertices[from.ThreadIndex].time.Equals(records.time))
                {
                    PostBufferAndPossiblyCutThrough(from);

                    // it is possible that cut through (and re-entrancy) results in records still present here.
                    if (!this.messagesFromLocalVertices[from.ThreadIndex].Unallocated)
                    {
                        this.Post(this.messagesFromLocalVertices[from.ThreadIndex]);
                        this.messagesFromLocalVertices[from.ThreadIndex] = new Message <S, T>();
                    }

                    this.messagesFromLocalVertices[from.ThreadIndex].Allocate();
                    this.messagesFromLocalVertices[from.ThreadIndex].time = records.time;
                }

                // actually put the record into the buffer
                this.messagesFromLocalVertices[from.ThreadIndex].payload[this.messagesFromLocalVertices[from.ThreadIndex].length++] = records.payload[i];

                // if the buffer is now full, might as well ship the data [and consider cutting through to other dataflow vertices]
                if (this.messagesFromLocalVertices[from.ThreadIndex].length == this.messagesFromLocalVertices[from.ThreadIndex].payload.Length)
                {
                    PostBufferAndPossiblyCutThrough(from);
                }
            }
        }
Exemplo n.º 20
0
 public void Flush(ReturnAddress from)
 {
     this.encodersFromLocalVertices[from.ThreadIndex].Flush();
 }
Exemplo n.º 21
0
 public void Send(Message <Update, Empty> message, ReturnAddress from)
 {
     this.recordsReceived += message.length;
     this.consumer.scheduler.statistics[(int)RuntimeStatistic.ProgressLocalRecords] += message.length;
     this.consumer.ProcessCountChange(message);
 }
Exemplo n.º 22
0
 public void Send(Pair <S, T> record, ReturnAddress from)
 {
     this.encodersFromLocalVertices[from.ThreadIndex].Write(record, from.VertexID);
 }
Exemplo n.º 23
0
 public void Flush(ReturnAddress from)
 {
 }
 public void RequestFlush(ReturnAddress from)
 {
 }
Exemplo n.º 25
0
 public void ForwardDoubleAggregate(Message <Pair <string, ReportingRecord <double> >, IterationIn <T> > message, ReturnAddress sender)
 {
     for (int i = 0; i < message.length; ++i)
     {
         ReportingRecord <double> r = message.payload[i].Second;
         Context.Reporting.LogAggregate(message.payload[i].First, r.type, r.payload, r.count, message.time.outerTime);
     }
 }
Exemplo n.º 26
0
 public abstract void DeliverSerializedMessage(SerializedMessage message, ReturnAddress from);
        /// <summary>
        /// Create a new job in the Windows Azure Import/Export service.
        /// </summary>
        /// <param name="jobName">Name of the job.</param>
        /// <param name="configFilePath"></param>
        public void CreateJob(string jobName, string configFilePath)
        {
            var XConf = XDocument.Load(configFilePath);

            // ReturnAddress: Specifies the return address information for the job.
            var XReturnAddress = XConf.Descendants("ReturnAddress").First();
            var returnAddress  = new ReturnAddress(
                XReturnAddress.Element("Name").Value,
                XReturnAddress.Element("Address").Value,
                XReturnAddress.Element("Phone").Value,
                XReturnAddress.Element("Email").Value
                );

            // ReturnShipping: Specifies the return carrier and customer’s account with the carrier
            var XReturnShipping = XConf.Descendants("ReturnShipping").First();
            var returnShipping  = new ReturnShipping(
                XReturnShipping.Element("CarrierName").Value,
                XReturnShipping.Element("CarrierAccountNumber").Value
                );

            // Properties: The list of properties for the job.
            // refer to https://msdn.microsoft.com/en-us/library/azure/dn529110.aspx for more details
            var XJobProperty     = XConf.Descendants("JobProperty").First();
            var putJobProperties = new PutJobProperties(
                backupDriveManifest: bool.Parse(XJobProperty.Element("BackupDriveManifest").Value),
                description: XJobProperty.Element("Description").Value,
                enableVerboseLog: bool.Parse(XJobProperty.Element("EnableVerboseLog").Value),
                friendlyName: XJobProperty.Element("FriendlyName").Value,
                type: (XJobProperty.Element("JobType").Value.Equals("Import", StringComparison.InvariantCultureIgnoreCase)? JobType.Import: JobType.Export),
                location: XJobProperty.Element("Location").Value,
                storageAccountKey: XJobProperty.Element("StorageAccountKey").Value,
                storageAccountName: XJobProperty.Element("StorageAccountName").Value,
                importExportStatesPath: XJobProperty.Element("ImportExportStatesPath").Value,
                returnAddress: returnAddress,
                returnShipping: returnShipping
                );

            // must include either StorageAccountKey or ContainerSas in the request
            if (string.IsNullOrEmpty(XJobProperty.Element("StorageAccountKey").Value))
            {
                putJobProperties.StorageAccountKey = null;
                putJobProperties.ContainerSas      = XJobProperty.Element("ContainerSas").Value;
            }

            var putJobParameters = new PutJobParameters(jobName, putJobProperties);

            if (putJobProperties.Type == JobType.Export)
            {
                // BlobList: contain information about the blobs to be exported for an export job.
                var XBlobList = XConf.Descendants("BlobList").First().Elements();
                var blobList  = new BlobList(new List <string>(), new List <string>());
                foreach (var XBlob in XBlobList)
                {
                    if (!String.IsNullOrWhiteSpace(XBlob.Attribute("BlobPaths").Value))
                    {
                        blobList.BlobPath.Add(XBlob.Attribute("BlobPaths").Value);
                    }
                    if (!String.IsNullOrWhiteSpace(XBlob.Attribute("BlobPathPrefixes").Value))
                    {
                        blobList.BlobPathPrefix.Add(XBlob.Attribute("BlobPathPrefixes").Value);
                    }
                }
                putJobParameters.Export = new Export(blobList: blobList);
            }
            else
            {
                // DriveList: List of up to ten drives that comprise the job.
                var XDriveList = XConf.Descendants("DriveList").First().Elements();
                var driveList  = new List <Drive>();
                foreach (var XDrive in XDriveList)
                {
                    driveList.Add(new Drive(
                                      driveId: XDrive.Element("DriveId").Value,
                                      bitLockerKey: XDrive.Element("BitLockerKey").Value,
                                      manifestFile: XDrive.Element("ManifestFile").Value,
                                      manifestHash: XDrive.Element("ManifestHash").Value
                                      ));
                }
                putJobParameters.DriveList = driveList;
            }

            client.PutJob(XJobProperty.Element("StorageAccountName").Value, jobName, putJobParameters);
        }
Exemplo n.º 28
0
 public abstract void Flush(ReturnAddress from);
Exemplo n.º 29
0
 public abstract void Send(Message <S, T> message, ReturnAddress from);
Exemplo n.º 30
0
 public Val(ReturnAddress value) : this()
 {
     type = Type.ReturnAddress; vreturn = value;
 }
Exemplo n.º 31
0
 public void DeliverSerializedMessage(SerializedMessage message, ReturnAddress from)
 {
     throw new NotImplementedException("Attempted to deliver message from a remote sender to a remote recipient, which is not currently supported.");
 }