private Error Negotiate(Attach attach) { if (attach.MaxMessageSize() != (long)0) { this.settings.MaxMessageSize = new ulong?(Math.Min(this.settings.MaxMessageSize(), attach.MaxMessageSize())); } return(null); }
public static bool IncompleteUnsettled(this Attach attach) { if (!attach.IncompleteUnsettled.HasValue) { return(false); } return(attach.IncompleteUnsettled.Value); }
public static ulong MaxMessageSize(this Attach attach) { if (!attach.MaxMessageSize.HasValue) { return((ulong)-1); } return(attach.MaxMessageSize.Value); }
public static bool Dynamic(this Attach attach) { if (attach.IsReceiver()) { return(((Source)attach.Source).Dynamic()); } return(((Target)attach.Target).Dynamic()); }
public static void UpsertProperty(this Attach attach, AmqpSymbol symbol, object value) { if (attach.Properties == null) { attach.Properties = new Fields(); } attach.Properties[symbol] = value; }
public static Address Address(this Attach attach) { if (attach.IsReceiver()) { return(((Source)attach.Source).Address); } return(((Target)attach.Target).Address); }
internal override void OnAttach(Attach attach) { var connection = (ListenerConnection)this.Connection; Link link = connection.Listener.Container.CreateLink(connection, this, attach); this.AddRemoteLink(attach.Handle, link); link.OnAttach(attach.Handle, attach); }
private static Attach PopulateAttach(IDataReader dataReader) { Attach attach = new Attach(dataReader.GetInt32(0), dataReader.GetGuid(1), dataReader.IsDBNull(2) ? null : dataReader.GetString(2), dataReader.GetString(3), dataReader.GetString(4)); return(attach); }
public ActionResult DeleteConfirmed(int id) { Attach attach = db.Attaches.Find(id); db.Attaches.Remove(attach); db.SaveChanges(); return(RedirectToAction("Index")); }
public static void AddProperty(this Attach attach, AmqpSymbol symbol, object value) { if (attach.Properties == null) { attach.Properties = new Fields(); } attach.Properties.Add(symbol, value); }
private void AttachRemoteLink(Attach attach, AmqpLink link) { if (remoteLinks[attach.Handle] != null) { throw new AmqpException(ErrorCode.HandleInUse, $"The handle '{attach.Handle}' is already allocated for '{remoteLinks[attach.Handle].Name}'"); } remoteLinks[attach.Handle] = link; }
/// <summary> /// Initializes a receiver link. /// </summary> /// <param name="session">The session within which to create the link.</param> /// <param name="name">The link name.</param> /// <param name="attach">The attach frame to send for this link.</param> /// <param name="onAttached">The callback to invoke when an attach is received from peer.</param> public ReceiverLink(Session session, string name, Attach attach, OnAttached onAttached) : base(session, name, onAttached) { this.totalCredit = -1; this.receivedMessages = new LinkedList(); this.waiterList = new LinkedList(); this.SendAttach(true, 0, attach); }
protected void Bt_upload_Click(object sender, EventArgs e) { if (FileUpload1.HasFile) { string oldname = FileUpload1.FileName; string type = FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf(".") + 1); //获取上传文件的后缀 string filename = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + "." + type; if (type == "doc") { if (FileUpload1.FileName != "") { //更改上传文件名 String path = Server.MapPath("~/upfiles/" + filename); FileUpload1.PostedFile.SaveAs(path); } string author = Request.Cookies["userID"].Value.ToString(); string state = "0"; Hashtable docHt = new Hashtable(); docHt.Add("docTime", SQLString.GetQuotedString(DateTime.Now.ToString())); docHt.Add("docTitle", SQLString.GetQuotedString(Session["docTitle"].ToString())); docHt.Add("docTitleEn", SQLString.GetQuotedString(Session["docTitleEn"].ToString())); docHt.Add("docAbstract", SQLString.GetQuotedString(Session["docAbstract"].ToString())); docHt.Add("docAbstractEn", SQLString.GetQuotedString(Session["docAbstractEn"].ToString())); docHt.Add("docKeywords", SQLString.GetQuotedString(Session["docKeywords"].ToString())); docHt.Add("docKeywordsEn", SQLString.GetQuotedString(Session["docKeywordsEn"].ToString())); docHt.Add("docLetters", SQLString.GetQuotedString(Session["docLetters"].ToString())); docHt.Add("docAuthor", SQLString.GetQuotedString(Session["docAuthor"].ToString())); docHt.Add("docColumnID", SQLString.GetQuotedString(Session["docColumnID"].ToString())); docHt.Add("authorID", SQLString.GetQuotedString(author)); docHt.Add("docState", SQLString.GetQuotedString(state)); Doc dc = new Doc(); dc.Add(docHt); int docID = dc.GetID(author); Hashtable ht = new Hashtable(); ht.Add("attachFilename", SQLString.GetQuotedString(oldname)); ht.Add("attachName", SQLString.GetQuotedString(filename)); ht.Add("docID", SQLString.GetQuotedString(Convert.ToString(docID))); Attach attach = new Attach(); attach.Add(ht); Response.Write("<script language='javascript'>alert('投稿成功,谢谢您对本刊的支持!')</script>"); Response.Write("<script>window.location='contribution1.aspx';</script>"); } else { Response.Write("<script language='javascript'>alert('对不起,目前只接受.doc格式文档,请重新上传!')</script>"); } } }
Attach CreateAttachForClose() { Attach attach = new Attach(); attach.LinkName = this.settings.LinkName; attach.Role = this.settings.Role; attach.Handle = this.settings.Handle; return(attach); }
public async Task SendAsync(string eventType, string address, string data, string correlationId) { var messageId = Guid.NewGuid().ToString(); using (Logger.BeginScope(new Dictionary <string, object> { ["CorrelationId"] = correlationId, ["MessageId"] = messageId, ["MessageType"] = eventType })) { Logger.LogTrace($"Publishing message {messageId} to {address} with body: {data}"); var session = CreateSession(); var attach = new Attach() { Target = new Target() { Address = address, Durable = Settings.Durable }, Source = new Source() }; var sender = new SenderLink(session, Settings.AppName, attach, null); sender.Closed += OnClosed; var message = new Message(data) { Header = new Header { Durable = (Settings.Durable == 2) }, ApplicationProperties = new ApplicationProperties(), Properties = new Properties { MessageId = messageId, GroupId = eventType, CorrelationId = correlationId } }; message.ApplicationProperties[MESSAGE_TYPE_KEY] = eventType; try { await sender.SendAsync(message); Logger.LogInformation($"Published message {messageId}"); } finally { if (sender.Error != null) { Error = new DomainEventError(); Error.Condition = sender.Error.Condition.ToString(); Error.Description = sender.Error.Description; Closed?.Invoke(this, Error); } if (!sender.IsClosed) { await sender.CloseAsync(TimeSpan.FromSeconds(5)); } await session.CloseAsync(); await session.Connection.CloseAsync(); } } }
public void DeleteForm(string keyValue) { var id = Convert.ToInt64(keyValue); Attach attach = attachRepository.Get(id); attach.DeletedMark = true; attach.DeletionTime = DateTime.Now; attachRepository.Update(attach); }
protected virtual void OnAttachResponse(ILink link, Attach attachResponse) { Tracer.InfoFormat("Received Performative Attach response on Link: {0}, Response: {1}", ConsumerId, attachResponse.ToString()); OnResponse(); if (link.Error != null) { this.Session.OnException(ExceptionSupport.GetException(link, "Consumer {0} Attach Failure.", this.ConsumerId)); } }
public Guid Upload(String itemId) { var user = _userSvc.CurrentUser(); Attach file = _attach.GetById(Guid.Parse(itemId)); if (file != null && file.UserId != user.Id) { throw new Exception(); } if (HttpContext.Current.Request.Files["file"] == null) { throw new Exception(); } var encriptionKey = HttpContext.Current.Session["FILEKEY"].ToString(); using (var fileUploadStream = HttpContext.Current.Request.Files["file"].InputStream) { using (var ms = new MemoryStream()) { fileUploadStream.CopyTo(ms); var data = ms.ToArray(); var strData = Encoding.UTF8.GetString(data); var cry = (CryptoService)HttpContext.Current.Session["DATA"]; AuthLeaf ida = cry.FindById(itemId) as AuthLeaf; ida.HasAttachment = HttpContext.Current.Request.Files["file"].FileName; var id = _files.GetIdByIdUserAndLabel(user.Id, HttpContext.Current.Session["FILE"].ToString()); var encrypted = _crypt.Encrypt(data, encriptionKey); if (file == null) { file = new Attach { Id = Guid.Parse(itemId), Data = encrypted, FileId = id, Name = HttpContext.Current.Request.Files["file"].FileName, UserId = user.Id }; _attach.Add(file); } else { file.Data = encrypted; file.Name = HttpContext.Current.Request.Files["file"].FileName; _attach.Update(file); } Save(); return(file.Id); } } }
Error Negotiate(Attach attach) { if (attach.MaxMessageSize() != 0) { this.settings.MaxMessageSize = Math.Min(this.settings.MaxMessageSize(), attach.MaxMessageSize()); } return(null); }
protected override async Task Invoke(MapDocument document, CommandParameters parameters) { if (_clipboard.Value.CanPaste()) { var content = _clipboard.Value.GetPastedContent(document); var op = new Attach(document.Map.Root.ID, content); await MapDocumentOperation.Perform(document, op); } }
/// <summary> /// renews the cbs token /// </summary> /// <param name="sharedAccessToken">token to renew</param> /// <returns>Task to wait on</returns> private async Task RenewTokenAsync(string sharedAccessToken) { var session = new Session(m_connection); string cbsClientAddress = "cbs-client-reply-to"; var cbsSender = new SenderLink(session, "cbs-sender", "$cbs"); var receiverAttach = new Attach() { Source = new Source() { Address = "$cbs" }, Target = new Target() { Address = cbsClientAddress } }; var cbsReceiver = new ReceiverLink(session, "cbs-receiver", receiverAttach, null); // construct the put-token message var request = new Message(sharedAccessToken); request.Properties = new Properties(); request.Properties.MessageId = "1"; request.Properties.ReplyTo = cbsClientAddress; request.ApplicationProperties = new ApplicationProperties(); request.ApplicationProperties["operation"] = "put-token"; request.ApplicationProperties["type"] = TokenType; request.ApplicationProperties["name"] = TokenScope; await cbsSender.SendAsync(request); // receive the response var response = await cbsReceiver.ReceiveAsync(); if (response == null || response.Properties == null || response.ApplicationProperties == null) { throw new Exception("invalid response received"); } int statusCode = (int)response.ApplicationProperties["status-code"]; await cbsSender.CloseAsync(); await cbsReceiver.CloseAsync(); await session.CloseAsync(); if (statusCode != (int)HttpStatusCode.Accepted && statusCode != (int)HttpStatusCode.OK) { throw new Exception("put-token message was not accepted. Error code: " + statusCode); } // Now create new link await ResetLinkAsync(); }
protected override ILink CreateLink() { Attach frame = CreateAttachFrame(); string linkName = producerInfo.Id + ":" + UriUtil.GetAddress(Destination, Session.Connection); link = new SenderLink(Session.InnerSession as Amqp.Session, linkName, frame, OnAttachedResp); return(link); }
protected void OnAttachResponse(ILink sender, Attach attachResponse) { Tracer.InfoFormat("Attempting to close subscription {0}. Attach response {1}", this.Info.SubscriptionName, attachResponse); this.remoteSource = attachResponse.Source as Amqp.Framing.Source; if (this.remoteSource != null) { Tracer.InfoFormat("Found subscription {0} on remote with source {1}.", this.Info.SubscriptionName, this.remoteSource); this.OnResponse(); } }
public override void Draw(Graphics graphics, NodeViewData nvd, RectangleF boundingBox) { Attach evnt = (Attach)_attachment; //// use a different brush depending on if the event is reacted to or blocked. //_labelBrush= evnt.BlockEvent ? Brushes.Orange : Brushes.White; _labelBrush = Brushes.White; base.Draw(graphics, nvd, boundingBox); }
public Guid Upload(String fileLabel) { var user = _userSvc.CurrentUser(); Repos.File file = _files.GetByIdUserAndLabel(user.Id, HttpContext.Current.Request.Files["file"].FileName); var encriptionKey = HttpContext.Current.Request.Params["encryptionKey"]; using (var fileUploadStream = HttpContext.Current.Request.Files["file"].InputStream) { using (var ms = new MemoryStream()) { fileUploadStream.CopyTo(ms); var data = ms.ToArray(); var strData = Encoding.UTF8.GetString(data); var crys = new CryptoService(); var root = crys.Initialize(strData); strData = crys.Save(); var encrypted = Encoding.UTF8.GetBytes(_crypt.Encrypt(strData, encriptionKey)); if (file == null) { file = new Repos.File { Id = Guid.NewGuid(), Label = fileLabel, Name = HttpContext.Current.Request.Files["file"].FileName, UserId = user.Id, Content = encrypted }; _files.Add(file); } else { file.Content = encrypted; _files.Update(file); } _attach.DeleteFile(file.Id); foreach (var singleFile in root.Attachments) { //_attach.DeleteFile(Guid.Parse(singleFile.Id)); var toAdd = new Attach { Id = Guid.Parse(singleFile.Id), UserId = user.Id, FileId = file.Id, Name = file.Name, Data = singleFile.Data }; _attach.Add(toAdd); } return(file.Id); } } }
void RunOnce(int id) { Connection connection = this.CreateConnection(new Address(this.Args.Address)); connection.Closed += (o, e) => this.SetComplete(); Session session = new Session(connection); string clientId = "request-" + Guid.NewGuid().ToString().Substring(0, 6); Attach sendAttach = new Attach() { Source = new Source(), Target = new Target() { Address = this.Args.Node }, SndSettleMode = SenderSettleMode.Settled }; Attach recvAttach = new Attach() { Source = new Source() { Address = this.Args.Node }, Target = new Target() { Address = clientId }, SndSettleMode = SenderSettleMode.Settled }; SenderLink sender = new SenderLink(session, "s-" + clientId, sendAttach, null); ReceiverLink receiver = new ReceiverLink(session, "r-" + clientId, recvAttach, null); receiver.Start( 50000, (r, m) => { r.Accept(m); m.Dispose(); if (this.OnComplete()) { this.SendRequest(sender, clientId); } }); for (int i = 1; i <= this.Args.Queue; i++) { if (this.OnStart()) { this.SendRequest(sender, clientId); } } this.Wait(); connection.Close(); }
public ActionResult Edit(SysAgent SysAgent) { if (SysAgent.Id != 0) { SysAgent = Entity.SysAgent.FirstOrDefault(n => n.Id == SysAgent.Id); } if (SysAgent == null) { ViewBag.ErrorMsg = AgentLanguage.Empty; return(View("Error")); } if (!SysAgent.Id.IsNullOrEmpty()) { if (!IsBelongToAgent(SysAgent.Id)) { ViewBag.ErrorMsg = AgentLanguage.Surmount; return(View("Error")); } } ViewBag.SysAgent = SysAgent; if (Request.UrlReferrer != null) { Session["Url"] = Request.UrlReferrer.ToString(); } SysAdmin sysAdmin = null; if (SysAgent.AdminId != 0) { sysAdmin = Entity.SysAdmin.FirstOrNew(n => n.Id == SysAgent.AdminId); } ViewBag.SysAdmin = sysAdmin; var Contract = new List <Attach>(); var Certificate = new List <Attach>(); var IDCard_Front = new Attach(); var IDCard_Hand = new Attach(); var IDCard_Reverse = new Attach(); if (SysAgent.Id != 0) { var attachs = Entity.Attach.Where(o => o.AgentId == SysAgent.Id && o.State == 1).ToList(); Contract = attachs.Where(o => o.AType == (byte)AttachType.Contract).ToList(); Certificate = attachs.Where(o => o.AType == (byte)AttachType.Certificate).ToList(); IDCard_Front = attachs.FirstOrNew(o => o.AType == (byte)AttachType.IDCard_Front); IDCard_Hand = attachs.FirstOrNew(o => o.AType == (byte)AttachType.IDCard_Hand); IDCard_Reverse = attachs.FirstOrNew(o => o.AType == (byte)AttachType.IDCard_Reverse); } this.ViewBag.Contract = Contract; this.ViewBag.Certificate = Certificate; this.ViewBag.IDCard_Front = IDCard_Front; this.ViewBag.IDCard_Hand = IDCard_Hand; this.ViewBag.IDCard_Reverse = IDCard_Reverse; ViewBag.MySysAgentMoney = this.checkPower("MySysAgent", "MoneySave"); return(View()); }
private async Task InnerSendAsync(Message message, EventProperties properties) { using (Logger.BeginScope(new Dictionary <string, object> { ["CorrelationId"] = message.Properties.CorrelationId, ["MessageId"] = message.Properties.MessageId, ["MessageType"] = message.Properties.GroupId })) { Logger.LogTrace($"Publishing message {message.Properties.MessageId} to {properties.Address} with body: {message.Body}"); var disconnectAfter = false; if (conn == null) { Connect(); disconnectAfter = true; } var session = new Session(conn); var attach = new Attach() { Target = new Target() { Address = properties.Address, Durable = Settings.Durable }, Source = new Source() }; var sender = new SenderLink(session, Settings.AppName + Guid.NewGuid().ToString(), attach, null); sender.Closed += OnClosed; try { await sender.SendAsync(message).ConfigureAwait(false); Logger.LogInformation($"Published message {message.Properties.MessageId}"); } finally { if (sender.Error != null) { Error = new DomainEventError(); Error.Condition = sender.Error.Condition.ToString(); Error.Description = sender.Error.Description; Closed?.Invoke(this, Error); } if (disconnectAfter) { if (!sender.IsClosed) { await sender.CloseAsync(TimeSpan.FromSeconds(5)).ConfigureAwait(false); } await session.CloseAsync().ConfigureAwait(false); await session.Connection.CloseAsync().ConfigureAwait(false); } } } }
public ActionResult Edit([Bind(Include = "attachID,labelUPCID")] Attach attach) { if (ModelState.IsValid) { db.Entry(attach).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.labelUPCID = new SelectList(db.LabelUPCs, "labelUPCID", "nameUPC", attach.labelUPCID); return(View(attach)); }
Error Negotiate(Attach attach) { if (attach.MaxMessageSize.HasValue && attach.MaxMessageSize.Value != 0) { this.settings.MaxMessageSize = this.settings.MaxMessageSize.HasValue ? Math.Min(this.settings.MaxMessageSize.Value, attach.MaxMessageSize.Value) : attach.MaxMessageSize.Value; } return(null); }
public bool CanAttachLink(AmqpLink newLink, Attach attach) { var queueName = ""; if (attach.IsReceiver) queueName = attach.Source.Address.ToLowerInvariant(); if (!attach.IsReceiver) queueName = attach.Target.Address.ToLowerInvariant(); var queue = queues.GetOrAdd(queueName, x => new ConcurrentQueue(0, logWriter)); return true; }
protected void Bt_upload_Click(object sender, EventArgs e) { int docID = Convert.ToInt32(Request.QueryString["docID"]); if (FileUpload1.HasFile) { string name = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString(); string type = FileUpload1.FileName.Substring(FileUpload1.FileName.LastIndexOf(".") + 1); //获取上传文件的后缀 string filename = name + "." + type; if (type == "doc") { if (FileUpload1.FileName != "") { String path = Server.MapPath("~/upfiles/" + filename); FileUpload1.PostedFile.SaveAs(path); Attach attach = new Attach(); attach.Delete(docID); Hashtable ht = new Hashtable(); ht.Add("attachFilename", SQLString.GetQuotedString(FileUpload1.FileName)); ht.Add("attachName", SQLString.GetQuotedString(filename)); ht.Add("docID", SQLString.GetQuotedString(Convert.ToString(docID))); attach.Add(ht); Doc dc = new Doc(); dc.Docload(docID); string docState = dc.docState; string state = ""; if (docState == "12") { state = "11"; } if (docState == "22") { state = "25"; } dc.Update_attach(docID, state); } Response.Write("<script language='javascript'>alert('上传成功!');window.location='modifylist.aspx'</script>"); } else { Response.Write("<script language='javascript'>alert('对不起,目前只接受.doc格式文档,请重新上传!')</script>"); } } }
/// <summary> /// Creates a new instance of an existing item with the specified position and rotation. /// </summary> /// <param name="attach">Attach to use for this levelItem</param> /// <param name="position">Position in worldspace to place this LevelItem.</param> /// <param name="rotation">Rotation.</param> public LevelItem(Device dev, Attach attach, Vertex position, Rotation rotation, int index, EditorItemSelection selectionManager) : base(selectionManager) { this.index = index; COL = new COL { Model = new NJS_OBJECT { Attach = attach, Position = position, Rotation = rotation } }; Visible = true; Solid = true; COL.CalculateBounds(); Mesh = COL.Model.Attach.CreateD3DMesh(dev); Paste(); }
private void InterceptAttachFrame(Attach attach) { if (!State.CanReceiveFrames()) throw new AmqpException(ErrorCode.IllegalState, $"Received Attach frame but session state is {State.ToString()}."); if (State == SessionStateEnum.DISCARDING) return; if (attach.Handle > sessionMaxHandle) throw new AmqpException(ErrorCode.NotAllowed, $"Cannot allocate more handles. The maximum number of handles is {sessionMaxHandle}."); // is this for an existing locally attached frame? for (uint i = 0; i < localLinks.Length; i++) { var existingLink = localLinks[i]; if (existingLink != null && existingLink.State == LinkStateEnum.ATTACH_SENT && string.Compare(existingLink.Name, attach.Name, true) == 0) { AttachRemoteLink(attach, existingLink); // Link is expecting an attach frame existingLink.HandleLinkFrame(attach); return; // done } } // must be a new inbound attach var nextLocalHandle = localLinks.GetFirstNullIndexOrAdd(); // reuse existing handle, or just grab the next one var isLocalLinkReceiver = !attach.IsReceiver; var newLink = new AmqpLink(this, attach.Name, nextLocalHandle, isLocalLinkReceiver, false, attach.Handle); if (!Connection.Container.CanAttachLink(newLink, attach)) throw new AmqpException(ErrorCode.PreconditionFailed, "Cannot Attach Link"); var index = localLinks[nextLocalHandle] = newLink; AttachRemoteLink(attach, newLink); newLink.HandleLinkFrame(attach); }
public bool CanAttachLink(AmqpLink newLink, Attach attach) { throw new NotImplementedException(); }
public void Can_Encode_And_Decode_Nested_DescribedList() { var buffer = new ByteBuffer(1024, false); var value = new Attach(); value.Source = new Source(); value.Source.Durable = (uint)randNum.Next(0, 1000); AmqpCodec.EncodeObject(buffer, value); var decodedValue = AmqpCodec.DecodeObject<Attach>(buffer); Assert.NotNull(decodedValue.Source); Assert.AreEqual(value.Source.Durable, decodedValue.Source.Durable); }
private void HandleAttachFrame(Attach attach) { if (State != LinkStateEnum.DETACHED && State != LinkStateEnum.ATTACH_SENT) throw new AmqpException(ErrorCode.IllegalState, $"Received Attach frame but link state is {State.ToString()}."); if (!IsInitiatingLink && IsSenderLink) { senderSettlementMode = (LinkSenderSettlementModeEnum)attach.SenderSettlementMode; SourceAddress = attach.Source.Address; } if (!IsInitiatingLink && IsReceiverLink) { receiverSettlementMode = (LinkReceiverSettlementModeEnum)attach.ReceiverSettlementMode; TargetAddress = attach.Target.Address; } if (State == LinkStateEnum.DETACHED) { State = LinkStateEnum.ATTACH_RECEIVED; attach.Handle = this.LocalHandle; attach.IsReceiver = this.IsReceiverLink; attach.SenderSettlementMode = (byte)senderSettlementMode; attach.ReceiverSettlementMode = (byte)receiverSettlementMode; attach.InitialDelieveryCount = this.initialDeliveryCount; // send back a cooresponding attach frame Session.SendFrame(attach); } if (State == LinkStateEnum.ATTACH_SENT) { if (IsReceiverLink) { if (attach.InitialDelieveryCount == null) throw new AmqpException(ErrorCode.InvalidField, "initial-delivery-count must be set on attach from of sender."); // expecting initial delivery count DeliveryCount = attach.InitialDelieveryCount.Value; } } State = LinkStateEnum.ATTACHED; Session.Connection.Container.OnLinkAttached(this); }
public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID) { handlerOnAttach = OnAttach; if (handlerOnAttach != null) handlerOnAttach(localID, itemID, avatarID); }
bool IContainer.AttachLink(ListenerConnection connection, ListenerSession session, Link link, Attach attach) { Source source = attach.Source as Source; Target target = attach.Target as Target; bool dynamic = false; string address = null; if (attach.Role) { address = source.Address; dynamic = source.Dynamic; } else { if (target != null) { address = target.Address; dynamic = target.Dynamic; } else if (attach.Target is Coordinator) { this.txnManager.AddCoordinator((ListenerLink)link); return true; } } if (dynamic) { address = string.Format("$dynamic.{0}", Interlocked.Increment(ref this.dynamidId)); if (attach.Role) { source.Dynamic = false; source.Address = address; } else { target.Address = address; target.Dynamic = false; } } TestQueue queue; lock (this.queues) { if (!this.queues.TryGetValue(address, out queue)) { if (dynamic || this.implicitQueue) { queue = new TestQueue(this); this.queues.Add(address, queue); connection.Closed += (o, e) => this.RemoveQueue(address); } else { throw new AmqpException(ErrorCode.NotFound, string.Format("Node '{0}' not found", address)); } } } if (attach.Role) { queue.CreateConsumer((ListenerLink)link); } else { queue.CreatePublisher((ListenerLink)link); } return true; }
private void tsbAttachNew_Click(object sender, EventArgs e) { OpenFileDialog fd = new OpenFileDialog() { Title = "请选择需要上传的文件", ValidateNames = true, CheckFileExists = true, CheckPathExists = true }; if (fd.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { FileInfo fi = new FileInfo(fd.FileName); // 先保存到数据库里 Attach att = new Attach() { FileName = fi.Name, FileType = fi.Extension }; att.Save(); FTPClient ftp = INICustomer.GetFTPClient(); ftp.fileUpload(fi, @"\", att.ID + fi.Extension); m_contract.AttachList.Add(att); // 加入列表 lstFiles.Items.Add(String.Format("{0}.{1}", att.ID, fi.Name), 2); } }
public void Can_Encode_And_Decode_Multi_Nested_DescribedList() { var buffer = new ByteBuffer(1024, false); var value = new Attach(); value.Source = new Source(); value.Source.DefaultOutcome = new Rejected(); ((Rejected)value.Source.DefaultOutcome).Error = new Error(); ((Rejected)value.Source.DefaultOutcome).Error.Condition = Guid.NewGuid().ToString(); ((Rejected)value.Source.DefaultOutcome).Error.Description = Guid.NewGuid().ToString(); AmqpCodec.EncodeObject(buffer, value); var decodedValue = AmqpCodec.DecodeObject<Attach>(buffer); Assert.NotNull(decodedValue.Source); Assert.NotNull(decodedValue.Source.DefaultOutcome as Rejected); Assert.NotNull(((Rejected)decodedValue.Source.DefaultOutcome).Error); Assert.AreEqual(((Rejected)value.Source.DefaultOutcome).Error.Condition, ((Rejected)decodedValue.Source.DefaultOutcome).Error.Condition); Assert.AreEqual(((Rejected)value.Source.DefaultOutcome).Error.Description, ((Rejected)decodedValue.Source.DefaultOutcome).Error.Description); }
public bool CanAttachLink(AmqpLink newLink, Attach attach) { return true; }
Link IContainer.CreateLink(ListenerConnection connection, ListenerSession session, Attach attach) { return new ListenerLink(session, attach); }