public void NotifierCompleted_SendNoReply() { var notification = new Notification(); var send = new SendRecord(); notification.SendRecords.Add(send); Assert.That(notification.Complete(), Is.False); }
public void ThatTheReplyWorflowRunsAndHasCorrectInput(bool workflowHasInput) { var dummyrunner = new DummyWorkflowRunner(); using (var scope = Factory.Current.BeginLifetimeScope(builder => { builder.Register(ctx => dummyrunner).As <IWorkflowRunner>(); })) using (Factory.SetCurrentScope(scope)) { var workflow = new Workflow { WorkflowRunAsOwner = true }; if (workflowHasInput) { var inputArg = new ResourceArgument { Name = "myInput", ConformsToType = ReplyRecord.ReplyRecord_Type }; workflow.InputArguments.Add(inputArg.As <ActivityArgument>()); } var notification = new Notification(); notification.NReplyMapCopy.Add(new ReplyMapEntry { Name = "Reply", RmeWorkflow = workflow }); var send = new SendRecord(); notification.SendRecords.Add(send); notification.Save(); int runs = 0; var reply = new ReplyRecord { RrToSend = send, RrReply = "Reply to anything", RrReplyDate = DateTime.UtcNow }; dummyrunner.StartWorkflowAsyncFn = (startEvent) => { runs++; if (workflowHasInput) { Assert.That(startEvent.Arguments.Keys, Has.Member("myInput")); Assert.That(startEvent.Arguments["myInput"] is IEntity, Is.True); Assert.That(((IEntity)startEvent.Arguments["myInput"]).Id, Is.EqualTo(reply.Id)); } return("1"); }; reply.Save(); Assert.That(runs, Is.EqualTo(1)); } }
public void Send(Notification notification, IEnumerable <IEntity> people, bool expectReply) { foreach (var p in people) { var record = new SendRecord { SrToPerson = p.As <Person>(), SrSendDate = DateTime.Now, SendToNotification = notification }; record.Save(); } }
public void NotifierCompleted_SendWithError() { var notification = new Notification(); var send = new SendRecord(); notification.SendRecords.Add(send); send.SrErrorMessage = "Failed"; Assert.That(notification.Complete(), Is.True); }
public void NotifierCompleted_SendWithJustReplyDate() { var notification = new Notification(); var send = new SendRecord(); notification.SendRecords.Add(send); send.SrToReply.Add(new ReplyRecord { RrReplyDate = DateTime.Now }); Assert.That(notification.Complete(), Is.True); }
private SendRecord ComputeData() { SendRecord entity = new SendRecord(); entity.So = this.txt_SO.Text.Trim(); entity.OtherSo = this.txt_MoreSO.Text.Trim(); entity.CarNo = this.txt_CarNo.Text.Trim(); entity.QuFen = this.txt_Different.Text.Trim(); entity.Status = 0; entity.CpQuFen = string.Empty; entity.PnNo = string.Empty; entity.Scaner = Program.UserID; entity.date = System.DateTime.Now; return(entity); }
private void SaveData() { SendRecord entity = this.ComputeData(); this.current = entity; /*if (SendRecordManager.CheckExists(entity)) * { * MessageBox.Show("您已经扫描过该产品!"); * } * else * { * SendRecordManager.Save(entity); * DataTable dt = SqliteDbFactory.GetSqliteDbOperator().SelectFromSql("select max(id) from sendrecord"); * entity.Id = int.Parse(dt.Rows[0][0].ToString()); * this.current = entity; * } */ }
public AckListMessage(long connId, List <int> ackList, int lastRead, //ArrayList ackList Dictionary <int, SendRecord> sendRecordTable, int timeId, int connectId, int clientId) { this.clientId = clientId; this.connectId = connectId; this.ackList = ackList; this.lastRead = lastRead; int len1 = 4 + 4 + 10 + 4 * ackList.Count; dpData = new byte[len1 + 24 + 9]; sType = MessageType.sType_AckListMessage; ByteShortConvert.toByteArray(ver, dpData, 0); //add: ver ByteShortConvert.toByteArray(sType, dpData, 2); //add: service type ByteIntConvert.toByteArray(connectId, dpData, 4); //add: sequence ByteIntConvert.toByteArray(clientId, dpData, 8); //add: sequence ByteIntConvert.toByteArray(lastRead, dpData, 4 + 8); //dpData[8]=(byte) ackList.size(); ByteShortConvert.toByteArray((short)ackList.Count, dpData, 8 + 8); //add: service type for (int i = 0; i < ackList.Count; i++) { int sequence = (int)ackList[i]; ByteIntConvert.toByteArray(sequence, dpData, 10 + 4 * i + 8); //add: sequence ////#MLog.println("发送确认 "+sequence); } int u1 = timeId - 2; ByteIntConvert.toByteArray(u1, dpData, len1 + 8); SendRecord r1 = sendRecordTable[u1]; int s1 = 0; if (r1 != null) { s1 = r1.getSendSize(); } ByteIntConvert.toByteArray(s1, dpData, len1 + 4 + 8); int u2 = timeId - 1; ByteIntConvert.toByteArray(u2, dpData, len1 + 8 + 8); SendRecord r2 = sendRecordTable[u2]; int s2 = 0; if (r2 != null) { s2 = r2.getSendSize(); } ByteIntConvert.toByteArray(s2, dpData, len1 + 12 + 8); int u3 = timeId; ByteIntConvert.toByteArray(u3, dpData, len1 + 16 + 8); SendRecord r3 = sendRecordTable[u3]; int s3 = 0; if (r3 != null) { s3 = r3.getSendSize(); } ByteIntConvert.toByteArray(s3, dpData, len1 + 20 + 8); dp = new DatagramPacket(dpData, dpData.Length); }
public PickDetailHadTray(SendRecord record) { this.record = record; InitializeComponent(); }
public void OnReceivePacket(DatagramPacket datagramPacket) { DataPacket dataPacket; if (datagramPacket != null) { if (Conn.IsConnected) { int ver = PacketCheck.CheckVer(datagramPacket); int sType = PacketCheck.CheckSType(datagramPacket); if (ver == RUDPConfig.ProtocalVer) { Conn.Live(); if (sType == PacketType.DataPacket) { dataPacket = new DataPacket(datagramPacket); int timeId = dataPacket.TimeId; SendRecord record = Conn.MyClientControl.SendRecordTableRemote[timeId]; if (record == null) { record = new SendRecord(); record.TimeId = timeId; Conn.MyClientControl.SendRecordTableRemote.Add(timeId, record); } record.AddSent(dataPacket.Data.Length); if (timeId > CurrentRemoteTimeId) { CurrentRemoteTimeId = timeId; } int sequence = dataPacket.Sequence; Conn.MySender.SendAckDelay(dataPacket.Sequence); if (sequence > LastRead) { lock (AvailOb) { ReceiveTable.Add(sequence, dataPacket); if (ReceiveTable.ContainsKey(LastRead + 1)) { Monitor.Pulse(AvailOb); } } } } else if (sType == PacketType.AckListPacket) { AckListPacket ackListPacket = new AckListPacket(datagramPacket); int lastRead3 = ackListPacket.LastRead; if (lastRead3 > LastRead2) { LastRead2 = lastRead3; } List<int> ackList = ackListPacket.AckList; foreach (int sequence in ackList) { Conn.MySender.RemoveSentAck(sequence); } SendRecord rc1 = Conn.MyClientControl.GetSendRecord(ackListPacket.R1); if (rc1 != null && ackListPacket.S1 > rc1.AckedSize) { rc1.AckedSize = ackListPacket.S1; } SendRecord rc2 = Conn.MyClientControl.GetSendRecord(ackListPacket.R2); if (rc2 != null && ackListPacket.S2 > rc2.AckedSize) { rc2.AckedSize = ackListPacket.S2; } SendRecord rc3 = Conn.MyClientControl.GetSendRecord(ackListPacket.R3); if (rc3 != null && ackListPacket.S3 > rc3.AckedSize) { rc3.AckedSize = ackListPacket.S3; } if (CheckWin()) { Conn.MySender.Play(); } } else if (sType == PacketType.CloseStreamPacket) { CloseStreamPacket closeStreamPacket = new CloseStreamPacket(datagramPacket); ReceviedClose = true; int n = closeStreamPacket.CloseOffset; CloseRemoteStream(n); } else if (sType == PacketType.CloseConnPacket) { CloseConnPacket closeConnPacket = new CloseConnPacket(datagramPacket); Conn.CloseRemote(); } else { throw new Exception("Unknown packet type"); } } } } }
void Start() { send = gameObject.GetComponent <SendRecord>(); }
public AckListPacket(List <int> ackList, int lastRead, Dictionary <int, SendRecord> sendRecordTable, int timeId, int connectId, int clientId) { ClientId = clientId; ConnectId = connectId; AckList = ackList; LastRead = lastRead; int len1 = 4 + 4 + 10 + 4 * AckList.Count; DatagramData = new byte[len1 + 24 + 9]; SType = PacketType.AckListPacket; BitConverter.GetBytes(Ver).CopyTo(DatagramData, 0); BitConverter.GetBytes(SType).CopyTo(DatagramData, 2); BitConverter.GetBytes(ConnectId).CopyTo(DatagramData, 4); BitConverter.GetBytes(ClientId).CopyTo(DatagramData, 8); BitConverter.GetBytes(LastRead).CopyTo(DatagramData, 12); BitConverter.GetBytes((short)AckList.Count).CopyTo(DatagramData, 16); for (int i = 0; i < AckList.Count; i += 1) { int sequence = AckList[i]; BitConverter.GetBytes(sequence).CopyTo(DatagramData, 18 + 4 * i); } int u1 = timeId - 2; BitConverter.GetBytes(u1).CopyTo(DatagramData, len1 + 8); SendRecord r1 = sendRecordTable[u1]; if (r1 != null) { S1 = r1.SendSize; } BitConverter.GetBytes(S1).CopyTo(DatagramData, len1 + 4 + 8); int u2 = timeId - 1; BitConverter.GetBytes(u2).CopyTo(DatagramData, len1 + 8 + 8); SendRecord r2 = sendRecordTable[u2]; if (r2 != null) { S2 = r2.SendSize; } BitConverter.GetBytes(S2).CopyTo(DatagramData, len1 + 12 + 8); int u3 = timeId; BitConverter.GetBytes(u3).CopyTo(DatagramData, len1 + 16 + 8); SendRecord r3 = sendRecordTable[u3]; if (r3 != null) { S3 = r3.SendSize; } BitConverter.GetBytes(S3).CopyTo(DatagramData, len1 + 20 + 8); MyDatagramPacket = new DatagramPacket(DatagramData, DatagramData.Length); }
[RunWithoutTransaction] // As we are calling back into IIS, this can not run in a transaction public void Send(string terminalDigit, string expectedReply) { Random rand = new Random(); TwilioNotifier notifier = null; Person person = null; SendRecord result = null; Notification notification = null; try { notifier = new TwilioNotifier() { Name = "LoopbackApiTest.Notify " + DateTime.UtcNow, TpAccountSid = rand.Next().ToString(), TpAuthToken = rand.Next().ToString(), TpSendingNumber = rand.Next().ToString(), TpEnableTestMode = true }; notifier.Save(); person = new Person { Name = "LoopbackApiTest.Notify " + DateTime.UtcNow }; var mobilePhoneField = Factory.ScriptNameResolver.GetInstance("Mobile phone", StringField.StringField_Type.Id); var mobileNumber = rand.Next().ToString() + terminalDigit; person.SetField(mobilePhoneField, mobileNumber); person.Save(); notification = new Notification { NMessage = "TestMessage", NAcceptRepliesUntil = DateTime.UtcNow.AddDays(1) }; notification.Save(); TwilioRouter.Instance.Send(notifier, notification, person.ToEnumerable(), true); var results = Entity.Get <Notification>(notification.Id).SendRecords; Assert.That(results, Is.Not.Null); Assert.That(results.Count, Is.EqualTo(1)); result = results.First(); Assert.That(result.SrErrorMessage, Is.Null); // It can take a while for the second thread's update to work its way through. SendRecord result2 = null; for (int i = 0; i < 50; i++) { result2 = Entity.Get <SendRecord>(result.Id); if (result2.SrToReply.Count() == 1) { break; } } Assert.That(result2.SrToReply.Count(), Is.EqualTo(1)); Assert.That(result2.SrToReply.First().RrReply, Is.EqualTo(expectedReply)); } finally { notifier?.Delete(); person?.Delete(); notification?.Delete(); } }