public void CopyPooled() { var pool = new MockBufferPool(); BufferPool.SetCustomBufferPool(pool); var msg = new Msg(); msg.InitPool(100); Assert.IsFalse(msg.IsShared); var copy = new Msg(); copy.Copy(ref msg); Assert.IsTrue(msg.IsShared); Assert.IsTrue(copy.IsShared); msg.Close(); Assert.AreEqual(0, pool.ReturnCallCount); Assert.IsFalse(msg.IsInitialised); Assert.IsNull(msg.Data); copy.Close(); Assert.AreEqual(1, pool.ReturnCallCount); Assert.IsFalse(copy.IsInitialised); Assert.IsNull(copy.Data); }
private List<MsgRequest> FormRequest() { List<MsgRequest> ret = new List<MsgRequest> (); //if (elist.Count == 0) { // return null; //} var elist = EventReporter.ReportEvent (); foreach (var e in elist) { var req = new MsgRequest(); var head = new Head(); var content = new Content(); var msg = new Msg(); head.srcID = e.sponsorId; head.srcType = SRCType.UNITYC; head.dstIDs.InsertRange(0,e.targetIdList); msg.type = Support.MsgTypeConverter(e.type); msg.body = World.GetInstance().GetGameObject(e.sponsorId).GetComponent<EventGenerator>().SelfSerialize(e.type,e.rawContent); content.msg.Add(msg); req.content = content; req.head = head; ret.Add(req); } return ret; }
/// <summary> /// Set the specified option on this socket - which must be either a SubScribe or an Unsubscribe. /// </summary> /// <param name="option">which option to set</param> /// <param name="optionValue">the value to set the option to</param> /// <returns><c>true</c> if successful</returns> /// <exception cref="InvalidException">optionValue must be a String or a byte-array.</exception> protected override bool XSetSocketOption(ZmqSocketOption option, object optionValue) { // Only subscribe/unsubscribe options are supported if (option != ZmqSocketOption.Subscribe && option != ZmqSocketOption.Unsubscribe) return false; byte[] topic; if (optionValue is string) topic = Encoding.ASCII.GetBytes((string)optionValue); else if (optionValue is byte[]) topic = (byte[])optionValue; else throw new InvalidException($"In Sub.XSetSocketOption({option},{optionValue?.ToString() ?? "null"}), optionValue must be either a string or a byte-array."); // Create the subscription message. var msg = new Msg(); msg.InitPool(topic.Length + 1); msg.Put(option == ZmqSocketOption.Subscribe ? (byte)1 : (byte)0); msg.Put(topic, 1, topic.Length); try { // Pass it further on in the stack. var isMessageSent = base.XSend(ref msg); if (!isMessageSent) throw new Exception($"in Sub.XSetSocketOption({option}, {optionValue}), XSend returned false."); } finally { msg.Close(); } return true; }
/// <summary> /// 处理接收到的信息(包括大数据块信息)。 /// </summary> /// <param name="sourceUserID">发出信息的用户ID。如果为null,表示信息来自服务端。</param> /// <param name="informationType">自定义信息类型</param> /// <param name="info">信息</param> public void HandleInformation(string sourceUserID, int informationType, byte[] info) { MessageBox.Show("xxxxx"); if (sourceUserID != null) { switch (informationType) { case 1://普通文本消息 //取出收到的消息,接收者ID卍发送者ID卍消息内容卍发送时间卍发送人名字 string message = System.Text.Encoding.UTF8.GetString(info); string[] msgs = Regex.Split(message, Constant.SPLIT, RegexOptions.IgnoreCase);//得到含有5个元素的数组 Msg msg = new Msg(msgs, 1, 0);//消息存在msg对象中 ChatListSubItem[] items = chatListBox_contacts.GetSubItemsById(Convert.ToUInt32(sourceUserID));//按照ID查找listbox中的用户 string windowsName = items[0].NicName + ' ' + items[0].ID;//聊天窗口的标题 IntPtr handle = NativeMethods.FindWindow(null, windowsName);//查找是否已经存在窗口 if (handle != IntPtr.Zero)//如果聊天窗口已存在 { Form frm = (Form)Form.FromHandle(handle); frm.Activate();//激活 this.OnReceive(msg);//传送消息到聊天窗口 } else//聊天窗口不存在 { MsgDB db = MsgDB.OpenMsgDB(myInfo.ID.ToString()); //db.addMsg(msg); twinkle(chatListBox_contacts, Convert.ToUInt32(sourceUserID));//头像闪烁 } break; case 2: break; } } }
public void Plug(IOThread ioThread, SessionBase session) { m_session = session; m_encoder.SetMsgSource(session); // get the first message from the session because we don't want to send identities var msg = new Msg(); msg.InitEmpty(); bool ok = session.PullMsg(ref msg); if (ok) { msg.Close(); } AddSocket(m_socket); if (!m_delayedStart) { StartConnecting(); } else { m_state = State.Delaying; AddTimer(GetNewReconnectIvl(), ReconnectTimerId); } }
public static int constructor(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); Msg o; if(argc==1){ o=new Msg(); pushValue(l,true); pushValue(l,o); return 2; } else if(argc==2){ System.Byte[] a1; checkType(l,2,out a1); o=new Msg(a1); pushValue(l,true); pushValue(l,o); return 2; } return error(l,"New object failed."); } catch(Exception e) { return error(l,e); } }
static void Main(string[] args) { using (IRiakEndPoint endpoint = RiakCluster.FromConfig("riakConfig")) { IRiakClient client = endpoint.CreateClient(); UserRepository userRepo = new UserRepository(client); MsgRepository msgRepo = new MsgRepository(client); TimelineRepository timelineRepo = new TimelineRepository(client); TimelineManager timelineMgr = new TimelineManager(timelineRepo, msgRepo); // Create and save users var marleen = new User("marleenmgr", "Marleen Manager", "*****@*****.**"); var joe = new User("joeuser", "Joe User", "*****@*****.**"); userRepo.Save(marleen); userRepo.Save(joe); // Create new Msg, post to timelines Msg msg = new Msg(marleen.UserName, joe.UserName, "Welcome to the company!"); timelineMgr.PostMsg(msg); // Get Joe's inbox for today, get first message Timeline joesInboxToday = timelineMgr.GetTimeline(joe.UserName, Timeline.TimelineType.Inbox, DateTime.UtcNow); Msg joesFirstMsg = msgRepo.Get(joesInboxToday.MsgKeys.First()); Console.WriteLine("From: " + joesFirstMsg.Sender); Console.WriteLine("Msg : " + joesFirstMsg.Text); } }
public void Send(Msg msg) { if (client != null && client.Connected) Send(msg.ToCArray()); else sendQueue.Add(msg); }
private static int Main(string[] args) { if (args.Length != 3) { Console.WriteLine("usage: remote_thr <connect-to> <message-size> <message-count>"); return 1; } string connectTo = args[0]; int messageSize = int.Parse(args[1]); int messageCount = int.Parse(args[2]); using (var context = NetMQContext.Create()) using (var push = context.CreatePushSocket()) { push.Connect(connectTo); for (int i = 0; i != messageCount; i++) { var message = new Msg(); message.InitPool(messageSize); push.Send(ref message, SendReceiveOptions.None); message.Close(); } } return 0; }
protected override bool XRecv(ref Msg msg) { bool isMessageAvailable; // If we are in middle of sending a reply, we cannot receive next request. if (m_sendingReply) throw new FiniteStateMachineException("Rep.XRecv - cannot receive another request"); // First thing to do when receiving a request is to copy all the labels // to the reply pipe. if (m_requestBegins) { while (true) { isMessageAvailable = base.XRecv(ref msg); if (!isMessageAvailable) return false; if (msg.HasMore) { // Empty message part delimits the traceback stack. bool bottom = (msg.Size == 0); // Push it to the reply pipe. isMessageAvailable = base.XSend(ref msg); if (!isMessageAvailable) return false; if (bottom) break; } else { // If the traceback stack is malformed, discard anything // already sent to pipe (we're at end of invalid message). base.Rollback(); } } m_requestBegins = false; } // Get next message part to return to the user. isMessageAvailable = base.XRecv(ref msg); if (!isMessageAvailable) { return false; } // If whole request is read, flip the FSM to reply-sending state. if (!msg.HasMore) { m_sendingReply = true; m_requestBegins = true; } return true; }
/// <summary> /// Metoda pro registraci dalsich custom zprav /// </summary> /// <param name="msg"></param> /// <param name="strRepresentation"></param> /// <returns></returns> public static bool RegisterNewMessage(Msg msg, string strRepresentation ) { if( KnownMessages.ContainsKey( msg ) ) return false; else KnownMessages.Add( msg, strRepresentation ); return true; }
public V1Encoder(int bufferSize, Endianness endian) : base(bufferSize, endian) { m_inProgress = new Msg(); m_inProgress.InitEmpty(); // Write 0 bytes to the batch and go to message_ready state. NextStep(m_tmpbuf, 0, MessageReadyState, true); }
void OnGUI(){ GUI.TextArea (new Rect (10, 10, 500, 400), show_str); modelId =GUI.TextField (new Rect (520, 10, 80, 30), modelId); actionId=GUI.TextField (new Rect (600, 10, 80, 30), actionId); msg =GUI.TextField (new Rect (520, 50, 160, 30), msg); if (GUI.Button (new Rect (690, 10, 160, 30), "ADD_STR")) { } if (GUI.Button (new Rect (690, 50, 160, 30), "SEND")) { string str = modelId + "-" + actionId + " data =" + msg; string statc = "0,0,'538642', '1', '10002', '1', 99000000, 999999"; Msg data = new Msg (); data.Write (1); //data.Write ('a'); //data.Write ((byte)1.1f); //data.Write(11); data.Write (2L); byte[] b = data.Buffer; bool a0 = data.ReadBoolean (); //char a1 = (char)data.ReadByte (); long a2 = data.ReadInt64 (); //float a2 = float.Parse(data.ReadBytes (sizeof(float))); Debug.Log ("=sum length=="+(sizeof(int)+sizeof(long))+"============byte array===" + data.Length); Debug.Log ("=======a0=" + a0); //Debug.Log ("=======a1=" + a1); Debug.Log ("=======a2=" + a2); //Debug.Log ("encode code==================="+code); AppendShowString(str); } if (GUI.Button(new Rect(690, 90, 160, 30), "connect")) { try { network.connectServer(); AppendShowString("connect to server"); } catch (Exception e) { AppendShowString(e.ToString()); } } if (GUI.Button(new Rect(690,130,160,30),"disconnect")){ try { network.closeConnection(); AppendShowString("disconnect server"); }catch(Exception e) { AppendShowString(e.ToString()); } } }
public void CopyUninitialisedThrows() { var msg = new Msg(); Assert.IsFalse(msg.IsInitialised); var msgCopy = new Msg(); msgCopy.Copy(ref msg); }
public override bool MessageReadySize(int msgSize) { m_inProgress = new Msg(); m_inProgress.InitPool(msgSize); NextStep(m_inProgress.Data, m_inProgress.Size, RawMessageReadyState); return true; }
static void Main(string[] args) { DDSEntityManager mgr = new DDSEntityManager(); String partitionName = "HelloWorld example"; // create Domain Participant mgr.createParticipant(partitionName); mgr.setAutoDispose(true); // create Type MsgTypeSupport msgTS = new MsgTypeSupport(); mgr.registerType(msgTS); // create Topic mgr.createTopic("HelloWorldData_Msg", "HelloWorld"); // create Publisher mgr.createPublisher(); // create DataWriter mgr.createWriter(); // Publish Events IDataWriter dwriter = mgr.getWriter(); MsgDataWriter helloWorldWriter = dwriter as MsgDataWriter; Msg msgInstance = new Msg(); msgInstance.userID = 1; msgInstance.message = "Hello World"; InstanceHandle handle = helloWorldWriter.RegisterInstance(msgInstance); ErrorHandler.checkHandle(handle, "MsgDataWriter.RegisterInstance"); Console.WriteLine("=== [Publisher] writing a message containing :"); Console.WriteLine(" userID : {0}", msgInstance.userID); Console.WriteLine(" Message : \" {0} \"", msgInstance.message); ReturnCode status = helloWorldWriter.Write(msgInstance, handle); ErrorHandler.checkStatus(status, "MsgDataWriter.Write"); try { Thread.Sleep(2); } catch (ArgumentOutOfRangeException ex) { Console.WriteLine(ex.ToString()); Console.WriteLine(ex.StackTrace); } status = helloWorldWriter.UnregisterInstance(msgInstance, handle); // Clean up mgr.getPublisher().DeleteDataWriter(helloWorldWriter); mgr.deletePublisher(); mgr.deleteTopic(); mgr.deleteParticipant(); }
public void Flags() { var msg = new Msg(); Assert.AreEqual(MsgFlags.None, msg.Flags); msg.SetFlags(MsgFlags.Identity); Assert.IsTrue(msg.IsIdentity); Assert.IsFalse(msg.HasMore); Assert.IsFalse(msg.IsShared); Assert.AreEqual(MsgFlags.Identity, msg.Flags); msg.SetFlags(MsgFlags.More); Assert.IsTrue(msg.IsIdentity); Assert.IsTrue(msg.HasMore); Assert.IsFalse(msg.IsShared); Assert.AreEqual(MsgFlags.Identity | MsgFlags.More, msg.Flags); msg.SetFlags(MsgFlags.Shared); Assert.IsTrue(msg.IsIdentity); Assert.IsTrue(msg.HasMore); Assert.IsTrue(msg.IsShared); Assert.AreEqual(MsgFlags.Identity | MsgFlags.More | MsgFlags.Shared, msg.Flags); msg.SetFlags(MsgFlags.Identity); msg.SetFlags(MsgFlags.More); msg.SetFlags(MsgFlags.More); msg.SetFlags(MsgFlags.Shared); msg.SetFlags(MsgFlags.Shared); msg.SetFlags(MsgFlags.Shared); Assert.AreEqual(MsgFlags.Identity | MsgFlags.More | MsgFlags.Shared, msg.Flags); msg.ResetFlags(MsgFlags.Shared); Assert.IsTrue(msg.IsIdentity); Assert.IsTrue(msg.HasMore); Assert.IsFalse(msg.IsShared); Assert.AreEqual(MsgFlags.Identity | MsgFlags.More, msg.Flags); msg.ResetFlags(MsgFlags.More); Assert.IsTrue(msg.IsIdentity); Assert.IsFalse(msg.HasMore); Assert.IsFalse(msg.IsShared); Assert.AreEqual(MsgFlags.Identity, msg.Flags); msg.ResetFlags(MsgFlags.Identity); Assert.IsFalse(msg.IsIdentity); Assert.IsFalse(msg.HasMore); Assert.IsFalse(msg.IsShared); Assert.AreEqual(MsgFlags.None, msg.Flags); }
static void Main(string[] args) { DDSEntityManager mgr = new DDSEntityManager("WaitSet"); String partitionName = "WaitSet example"; // create Domain Participant mgr.createParticipant(partitionName); // create Type MsgTypeSupport msgTS = new MsgTypeSupport(); mgr.registerType(msgTS); // create Topic mgr.createTopic("WaitSetData_Msg"); // create Publisher mgr.createPublisher(); // create DataWriter mgr.createWriter(); // Publish Events IDataWriter dwriter = mgr.getWriter(); MsgDataWriter WaitSetWriter = dwriter as MsgDataWriter; // Write the first message Msg msgInstance = new Msg(); msgInstance.userID = 1; msgInstance.message = "First hello"; Console.WriteLine("=== [Publisher] writing a message containing :"); Console.WriteLine(" userID : {0}", msgInstance.userID); Console.WriteLine(" Message : \" {0} ", msgInstance.message); ReturnCode status = WaitSetWriter.Write(msgInstance, InstanceHandle.Nil); ErrorHandler.checkStatus(status, "MsgDataWriter.Write"); Thread.Sleep(500); // Write another message msgInstance.message = "Hello again"; status = WaitSetWriter.Write(msgInstance, InstanceHandle.Nil); ErrorHandler.checkStatus(status, "MsgDataWriter.Write"); Console.WriteLine("=== [Publisher] writing a message containing :"); Console.WriteLine(" userID : {0}", msgInstance.userID); Console.WriteLine(" Message : {0}", msgInstance.message); Thread.Sleep(500); // Clean up mgr.getPublisher().DeleteDataWriter(WaitSetWriter); mgr.deletePublisher(); mgr.deleteTopic(); mgr.deleteParticipant(); }
public RawEncoder(int bufferSize, [NotNull] IMsgSource msgSource, Endianness endianness) : base(bufferSize, endianness) { m_msgSource = msgSource; m_inProgress = new Msg(); m_inProgress.InitEmpty(); NextStep(null, 0, RawMessageReadyState, true); }
public void FillEpsilonSuffix(int prodId, int prefixSize, Msg[] buffer, int destIndex, IStackLookback<Msg> stackLookback) { var production = grammar.Productions[prodId]; int i = prefixSize; int end = production.PatternTokens.Length; while (i != end) { buffer[destIndex++] = GetDefault(production.PatternTokens[i++], stackLookback); } }
public void PostMsg(Msg msg) { string msgKey = msgRepository.Save(msg); // Post to recipient's Inbox timeline AddToTimeline(msg, Timeline.TimelineType.Inbox, msgKey); // Post to sender's Sent timeline AddToTimeline(msg, Timeline.TimelineType.Sent, msgKey); }
/// <summary> /// Transmit a byte-array of data over this socket. /// </summary> /// <param name="socket">the IOutgoingSocket to transmit on</param> /// <param name="data">the byte-array of data to send</param> /// <param name="length">the number of bytes to send from <paramref name="data"/>.</param> /// <param name="options">options to control how the data is sent</param> public static void Send([NotNull] this IOutgoingSocket socket, [NotNull] byte[] data, int length, SendReceiveOptions options) { var msg = new Msg(); msg.InitPool(length); Buffer.BlockCopy(data, 0, msg.Data, 0, length); socket.Send(ref msg, options); msg.Close(); }
public void Receive(ref Msg msg, SendReceiveOptions options) { LastOptions = options; byte[] bytes = m_frames.Dequeue(); msg.InitGC(bytes, bytes.Length); if (m_frames.Count != 0) msg.SetFlags(MsgFlags.More); }
public void CheckTryReceive() { using (var router = new RouterSocket()) { router.BindRandomPort("tcp://127.0.0.1"); var msg = new Msg(); msg.InitEmpty(); Assert.IsFalse(router.TryReceive(ref msg, TimeSpan.Zero)); } }
/// <summary> /// Root Process inbox /// </summary> public static State Inbox(State state, Msg msg) { switch (msg.Tag) { case MsgTag.Heartbeat: state = Heartbeat(state, ActorContext.Cluster); tellSelf(new Msg(MsgTag.Heartbeat), HeartbeatFreq + (random(1000)*milliseconds)); return state; } return state; }
private static string GetOwner(Msg msg, Timeline.TimelineType type) { switch (type) { case Timeline.TimelineType.Inbox: return msg.Recipient; case Timeline.TimelineType.Sent: return msg.Sender; } return msg.Recipient; }
public V2Encoder(int bufsize, IMsgSource session, Endianness endian) : base(bufsize, endian) { m_inProgress = new Msg(); m_inProgress.InitEmpty(); m_tmpbuf = new byte[9]; m_msgSource = session; // Write 0 bytes to the batch and go to message_ready state. NextStep(m_tmpbuf, 0, MessageReadyState, true); }
static void Main(string[] args) { DDSEntityManager mgr = new DDSEntityManager("Listener"); String partitionName = "Listener Example"; // create Domain Participant mgr.createParticipant(partitionName); // create Type MsgTypeSupport msgTS = new MsgTypeSupport(); mgr.registerType(msgTS); // create Topic mgr.createTopic("ListenerData_Msg"); // create Publisher mgr.createPublisher(); // create DataWriter mgr.createWriter(); // Publish Events IDataWriter dwriter = mgr.getWriter(); MsgDataWriter listenerWriter = dwriter as MsgDataWriter; ReturnCode status = ReturnCode.Error; Msg msgInstance = new Msg(); msgInstance.userID = 1; msgInstance.message = "Hello World"; Console.WriteLine("=== [ListenerDataPublisher] writing a message containing :"); Console.WriteLine(" userID : {0}", msgInstance.userID); Console.WriteLine(" Message : \"" + msgInstance.message + "\""); InstanceHandle msgHandle = listenerWriter.RegisterInstance(msgInstance); ErrorHandler.checkHandle(msgHandle, "DataWriter.RegisterInstance"); status = listenerWriter.Write(msgInstance, InstanceHandle.Nil); ErrorHandler.checkStatus(status, "DataWriter.Write"); Thread.Sleep(2); // clean up status = listenerWriter.Dispose(msgInstance, msgHandle); ErrorHandler.checkStatus(status, "DataWriter.Dispose"); status = listenerWriter.UnregisterInstance(msgInstance, msgHandle); ErrorHandler.checkStatus(status, "DataWriter.UnregisterInstance"); mgr.getPublisher().DeleteDataWriter(listenerWriter); mgr.deletePublisher(); mgr.deleteTopic(); mgr.deleteParticipant(); }
/// <summary> /// Create a new V1Decoder with the given buffer-size, maximum-message-size and Endian-ness. /// </summary> /// <param name="bufsize">the buffer-size to give the contained buffer</param> /// <param name="maxMessageSize">the maximum message size. -1 indicates no limit.</param> /// <param name="endian">the Endianness to specify for it - either Big or Little</param> public V1Decoder(int bufsize, long maxMessageSize, Endianness endian) : base(bufsize, endian) { m_maxMessageSize = maxMessageSize; m_tmpbuf = new ByteArraySegment(new byte[8]); // At the beginning, read one byte and go to one_byte_size_ready state. NextStep(m_tmpbuf, 1, OneByteSizeReadyState); m_inProgress = new Msg(); m_inProgress.InitEmpty(); }
/// <summary> /// 页面初始化 /// </summary> /// <param name="isTotal"></param> private void PageInit(int isTotal) { try { Msg msg = new Msg(); msg.SeqNo = int.Parse(Session["SEQNO"].ToString()); msg.PageIndex = AspNetPager1.CurrentPageIndex; msg.PageSize = AspNetPager1.PageSize; msg.IsTotal = isTotal; msg.MsgId = Request.QueryString["MsgId"].ToString(); int TotalRows = 0; DataSet ds = Query.GetDetailList(msg.MsgId, msg.PageIndex, msg.PageSize, out TotalRows); if (isTotal == 1) { this.hdTotalRows.Value = TotalRows.ToString(); } else { TotalRows = Convert.ToInt32(this.hdTotalRows.Value); } if (ds != null && ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { GroupSendDetailList.DataSource = ds.Tables[0].DefaultView; GroupSendDetailList.DataBind(); AspNetPager1.RecordCount = Convert.ToInt32(TotalRows); AspNetPager1.CustomInfoHTML = "记录总数:<font color=\"blue\"><b>" + AspNetPager1.RecordCount.ToString() + "</b></font>"; AspNetPager1.CustomInfoHTML += " 总页数:<font color=\"blue\"><b>" + AspNetPager1.PageCount.ToString() + "</b></font>"; AspNetPager1.CustomInfoHTML += " 当前页:<font color=\"red\"><b>" + AspNetPager1.CurrentPageIndex.ToString() + "</b></font>"; } else { GroupSendDetailList.DataSource = null; GroupSendDetailList.DataBind(); AspNetPager1.RecordCount = 0; AspNetPager1.DataBind(); message = "<div align=\"center\">没有任何记录!</div>"; TipDiv.Text = "没有任何记录!"; } } else { message = "<div align=\"center\">程序执行超时,请刷新重新加载!</div>"; } ds.Dispose(); } catch (Exception ex) { LogHelper.Error(ex.ToString()); } }
public bool Recv(ref Msg msg) { return(RecvPipe(ref msg, out Pipe _)); }
/// <summary> /// Get a message from FairQueuing data structure /// </summary> /// <param name="msg">a Msg to receive the message into</param> /// <returns><c>true</c> if the message was received successfully, <c>false</c> if there were no messages to receive</returns> protected override bool XRecv(ref Msg msg) { return(m_fairQueueing.Recv(ref msg)); }
/// <summary> /// Transmit the given message. The <c>Send</c> method calls this to do the actual sending. /// </summary> /// <param name="msg">the message to transmit</param> /// <returns><c>true</c> if the message was sent successfully</returns> protected override bool XSend(ref Msg msg) { return(m_loadBalancer.Send(ref msg)); }
public static extern int SendMessage(IntPtr hWnd, Msg msg, int wParam, int lParam);
public static extern IntPtr SendMessage(IntPtr hWnd, Msg msg, ref int wParam, ref int lParam);
public static extern int SendMessageW(IntPtr hWnd, Msg msg, int wParam, ref COPYDATASTRUCT lParam);
/** * Before Save * @param newRecord new * @return true */ protected override bool BeforeSave(bool newRecord) { // Check Storage if (!newRecord && // ((Is_ValueChanged("IsActive") && !IsActive()) || // now not active (Is_ValueChanged("IsStocked") && !IsStocked()) || // now not stocked (Is_ValueChanged("ProductType") && // from Item PRODUCTTYPE_Item.Equals(Get_ValueOld("ProductType"))))) { MStorage[] storages = MStorage.GetOfProduct(GetCtx(), Get_ID(), Get_TrxName()); Decimal OnHand = Env.ZERO; Decimal Ordered = Env.ZERO; Decimal Reserved = Env.ZERO; for (int i = 0; i < storages.Length; i++) { OnHand = Decimal.Add(OnHand, (storages[i].GetQtyOnHand())); Ordered = Decimal.Add(OnHand, (storages[i].GetQtyOrdered())); Reserved = Decimal.Add(OnHand, (storages[i].GetQtyReserved())); } String errMsg = ""; if (Env.Signum(OnHand) != 0) { errMsg = "@QtyOnHand@ = " + OnHand; } if (Env.Signum(Ordered) != 0) { errMsg += " - @QtyOrdered@ = " + Ordered; } if (Env.Signum(Reserved) != 0) { errMsg += " - @QtyReserved@" + Reserved; } if (errMsg.Length > 0) { log.SaveError("Error", Msg.ParseTranslation(GetCtx(), errMsg)); return(false); } } // storage // Reset Stocked if not Item if (IsStocked() && !PRODUCTTYPE_Item.Equals(GetProductType())) { SetIsStocked(false); } // UOM reset if (_precision != null && Is_ValueChanged("C_UOM_ID")) { _precision = null; } if (Util.GetValueOfInt(Env.GetCtx().GetContext("#AD_User_ID")) != 100) { if (Is_ValueChanged("C_UOM_ID") || Is_ValueChanged("M_AttributeSet_ID")) { string uqry = "SELECT SUM(cc) as count FROM (SELECT COUNT(*) AS cc FROM M_MovementLine WHERE M_Product_ID = " + GetM_Product_ID() + @" UNION SELECT COUNT(*) AS cc FROM M_InventoryLine WHERE M_Product_ID = " + GetM_Product_ID() + " UNION SELECT COUNT(*) AS cc FROM C_OrderLine WHERE M_Product_ID = " + GetM_Product_ID() + " UNION SELECT COUNT(*) AS cc FROM M_InOutLine WHERE M_Product_ID = " + GetM_Product_ID() + ")"; int no = Util.GetValueOfInt(DB.ExecuteScalar(uqry)); if (no == 0 || IsBOM()) { uqry = "SELECT count(*) FROM M_ProductionPlan WHERE M_Product_ID = " + GetM_Product_ID(); no = Util.GetValueOfInt(DB.ExecuteScalar(uqry)); } if (no > 0) { log.SaveError("Error", Msg.ParseTranslation(GetCtx(), "Could not Save Record. Transactions available in System.")); return(false); } } } if (newRecord) { string sql = "SELECT UPCUNIQUE('p','" + GetUPC() + "') as productID FROM Dual"; int manu_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql, null, null)); if (manu_ID > 0) { _log.SaveError("UPC is Unique", ""); return(false); } } else { if (!String.IsNullOrEmpty(GetUPC()) && Util.GetValueOfString(Get_ValueOld("UPC")) != GetUPC()) { string sql = "SELECT UPCUNIQUE('p','" + GetUPC() + "') as productID FROM Dual"; int manu_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql, null, null)); //if (manu_ID != 0 && manu_ID != GetM_Product_ID()) if (manu_ID > 0) { _log.SaveError("UPC is Unique", ""); return(false); } } } return(true); }
/// <summary> /// 处理键盘输入 /// </summary> /// <param name="args"></param> public void HandleKey(KeyEventArgs args) { // 动画效果时忽略按键 if (Animation.IsDisplay) { if (args.Key == Key.F10 || args.Key == Key.Tab) { args.Handled = true; } return; } // 弹出框处理 else if (Msg.AlertMsgMode) { Msg.HandleKey(args); if (args.Key == Key.F10 || args.Key == Key.Tab) { args.Handled = true; } } // 检查是不是功能键 else if ((args.Key >= Key.F1 && args.Key <= Key.F12) || args.Key == Key.Tab || args.Key == Key.System) { // F3查找产品 if (args.Key == Key.F3) { if (this.DisplayMode != 3 && !this.TakeoutCheckout.IsDisplay) { this.Products.SearchText = ""; this.Products.ProductList.Clear(); this.Products.ResetPage(); this.DisplayMode = 3; } } // F7 暂存 else if (args.Key == Key.F7 && this.DisplayMode == 2 && !this.TakeoutCheckout.IsDisplay && Selected.CurrentSelectedList.Count > 0) { // 保存到临时集合 TempSave.AddRange(this.Selected.CurrentSelectedList); // 清空原有的集合 foreach (var item in TempSave) { OperateDetails(1, item); } IsSave = true; _element.RaiseEvent(new PopupRoutedEventArgs(PublicEvents.PopupEvent, null, string.Format(Resources.GetRes().GetString("OperateSuccess"), Resources.GetRes().GetString("Save")), null, PopupType.Information)); } else if (args.Key == Key.F8 && this.DisplayMode == 2 && !this.TakeoutCheckout.IsDisplay && Selected.CurrentSelectedList.Count == 0 && TempSave.Count > 0) { // 重新选中暂存中的 foreach (var item in TempSave) { ProductChange(true, item.Product.ProductId, item.Count); } TempSave.Clear(); IsSave = false; _element.RaiseEvent(new PopupRoutedEventArgs(PublicEvents.PopupEvent, null, string.Format(Resources.GetRes().GetString("OperateSuccess"), Resources.GetRes().GetString("Restore")), null, PopupType.Information)); } // F12关闭 else if (args.Key == Key.F12 && this.DisplayMode == 2 && !this.TakeoutCheckout.IsDisplay) { (_element as Window).Close(); } else if (args.Key == Key.F10 || args.Key == Key.System) { if (this.TakeoutCheckout.IsDisplay) { this.TakeoutCheckout.HandleKey(args); } args.Handled = true; } // 切换语言 else if (args.Key == Key.Tab) { if (this.DisplayMode == 2) { this.ChangeOrderLanguageCommand.Execute(null); } args.Handled = true; } else { //if (args.Key == Key.F5) { // _element.RaiseEvent(new PopupRoutedEventArgs(PublicEvents.PopupEvent, null, Resources.GetRes().GetString("RefreshOrderFailed"), null, PopupType.Warn)); //}else if (args.Key == Key.F6) //{ // _element.RaiseEvent(new PopupRoutedEventArgs(PublicEvents.PopupEvent, null, Resources.GetRes().GetString("RefreshOrderFailed"), null, PopupType.Information)); //}else if (args.Key == Key.F7) //{ // _element.RaiseEvent(new PopupRoutedEventArgs(PublicEvents.PopupEvent, null, Resources.GetRes().GetString("RefreshOrderFailed"), null, PopupType.Question)); //}else if (args.Key == Key.F8) //{ // _element.RaiseEvent(new PopupRoutedEventArgs(PublicEvents.PopupEvent, null, Resources.GetRes().GetString("RefreshOrderFailed"), null, PopupType.Error)); //} } } // 结账处理 else if (this.TakeoutCheckout.IsDisplay) { this.TakeoutCheckout.HandleKey(args); } // 已选模式下 else if (this.DisplayMode == 2) { Selected.HandleKey(args); } // 搜索模式下 else if (this.DisplayMode == 3) { // 搜索指定内容 if (args.Key == Key.Enter && this.Products.SearchText.Length > 0) { long n = 0; bool isNumeric = long.TryParse(this.Products.SearchText, out n); this.DisplayMode = 1; AddProduct(isNumeric ? 1 : 2, this.Products.SearchText); } // 退回 else if (args.Key == Key.Escape) { this.DisplayMode = 2; this.Selected.CalcAndResetPage(); } else { this.Products.HandleSearchKey(args); } } // 产品模式 else if (this.DisplayMode == 1) { if (args.Key == Key.Escape) { this.DisplayMode = 3; } else { this.Products.HandleKey(args); } } }
public static extern int PostThreadMessage( int idThread, Msg msg, int wParam, int lParam );
public static extern int SendMessageW(IntPtr hWnd, Msg msg, int wParam, ref REBARBANDINFO lParam);
/// <summary> /// /// </summary> /// <param name="aMsg"></param> public virtual void Send(Msg aMsg) { }
public static extern int SendMessageW(IntPtr hWnd, Msg msg, int wParam, ref POINT lParam);
public static extern void SendMessageW(IntPtr hWnd, Msg msg, int wParam, ref HDITEM lParam);
public static extern void SendMessageW(IntPtr hWnd, Msg msg, int wParam, ref TBBUTTONINFO lParam);
protected void ibtnAdd_Click(object sender, EventArgs e) { //验证代码 try { StringBuilder strClassIds = new StringBuilder(); foreach (RepeaterItem rptParItem in this.rptClass.Items) { Repeater rplChild = (Repeater)rptParItem.FindControl("rptCheckList"); if (rplChild == null) { continue; } foreach (RepeaterItem rptItem in rplChild.Items) { HtmlInputCheckBox inputCheck = rptItem.FindControl("chkSubClass") as HtmlInputCheckBox; try { if (inputCheck.Checked) { int iid = int.Parse(inputCheck.Value); strClassIds.AppendFormat("{0},", iid); } } catch { break; } } } if (string.IsNullOrEmpty(txtTitle.Text.Trim())) { Msg.Show("请输入考级标题"); return; } if (string.IsNullOrEmpty(strClassIds + "")) { Msg.Show("请选择考试分类"); return; } if (string.IsNullOrEmpty(txtTotalCount.Text.Trim())) { Msg.Show("请输入计划人数"); return; } if (string.IsNullOrEmpty(txtNumberPrefx.Text.Trim() + "")) { Msg.Show("请输入固定编号"); return; } if (string.IsNullOrEmpty(txtNumberEnd.Text.Trim())) { Msg.Show("请输入结尾编号,数字自增"); return; } TFXK.Model.TestingPersonPlan model = new TFXK.Model.TestingPersonPlan(); try { int id = int.Parse(Request.QueryString["id"].ToString()); model = bll.GetModel(id); } catch { model.id = 0; } model.TestingSubClass = strClassIds.ToString().TrimEnd(','); model.TestingTitle = txtTitle.Text; model.Address = this.txtAddress.Text; model.OrderNum = int.Parse(this.txtOrderby.Text.Equals("") ? "0" : this.txtOrderby.Text); model.TestTimeAMStart = DateTime.Parse(this.txtStartTime.Value); model.TestTimeAMEnd = DateTime.Parse(this.txtEndTime.Value); model.TestTimePMStart = DateTime.Parse(this.txtCheckStartTime.Value); model.TestTimePMEnd = DateTime.Parse(this.txtCheckEndTime.Value); model.CreateTime = DateTime.Parse(this.txtCreateTime.Value); model.Description = this.txtContent.Value; model.Status = int.Parse(this.ddlState.SelectedValue); model.TotalCount = int.Parse(this.txtTotalCount.Text); model.NumberPrefx = this.txtNumberPrefx.Text; model.NumberStart = this.txtNumberEnd.Text; string type = this.hdfAction.Value.Trim(); // 判断动作 switch (type) { case "add": Add(model); model.NumberIndex = int.Parse(model.NumberStart.TrimStart('0')); break; case "modify": Modify(model); break; } } catch (Exception ex) { log.Error(ex.Message); Msg.Show("网络错误!原因:" + ex.Message); } }
private void Init() { BtnInput.Enabled = false; DgvOpt.SetRowBackColor(DgvPreDo); DgvOpt.SetColHeadMiddleCenter(DgvPreDo); DgvOpt.SetRowBackColor(DgvDone); DgvOpt.SetColHeadMiddleCenter(DgvDone); if (inputDt != null) { inputDt.Columns.Add("状态"); inputDt.Columns["状态"].SetOrdinal(0); if (inputDt.Columns.Contains("ERP订单数量")) { inputDt.Columns.Remove("ERP订单数量"); } inputDt.Columns.Add("ERP订单数量"); if (inputDt.Columns.Contains("已排数量")) { inputDt.Columns.Remove("已排数量"); } inputDt.Columns.Add("已排数量"); if (inputDt.Columns.Contains("品号")) { inputDt.Columns.Remove("品号"); } inputDt.Columns.Add("品号"); if (inputDt.Columns.Contains("品名")) { inputDt.Columns.Remove("品名"); } inputDt.Columns.Add("品名"); if (inputDt.Columns.Contains("规格")) { inputDt.Columns.Remove("规格"); } inputDt.Columns.Add("规格"); if (inputDt.Columns.Contains("客户配置")) { inputDt.Columns.Remove("客户配置"); } inputDt.Columns.Add("客户配置"); if (inputDt.Columns.Contains("客户名称")) { inputDt.Columns.Remove("客户名称"); } inputDt.Columns.Add("客户名称"); if (inputDt.Columns.Contains("交货日期")) { inputDt.Columns.Remove("交货日期"); } inputDt.Columns.Add("交货日期"); if (inputDt.Columns.Contains("已排行数")) { inputDt.Columns.Remove("已排行数"); } inputDt.Columns.Add("已排行数"); DtOpt.DtDateFormat(inputDt, "日期"); DgvPreDo.DataSource = inputDt; DgvOpt.SetColHeadMiddleCenter(DgvPreDo); DgvOpt.SetColReadonly(DgvPreDo); DgvOpt.SetColMiddleCenter(DgvPreDo, "状态"); DgvOpt.SetColMiddleCenter(DgvPreDo, "日期"); DgvOpt.SetColMiddleCenter(DgvPreDo, "数量"); DgvOpt.SetColWritable(DgvPreDo, "上线数量"); DgvOpt.SetColWidth(DgvPreDo, "生产单号", 150); } else { Msg.ShowErr("无传入的数据!"); } UI(); }
/** * Before Save - Check Calendar * @param newRecord new * @return true if it can be saved */ protected override Boolean BeforeSave(Boolean newRecord) { // Calendar if (BALANCEACCUMULATION_PeriodOfAViennaCalendar.Equals(GetBALANCEACCUMULATION())) { if (GetC_Calendar_ID() == 0) { log.SaveError("FillMandatory", Msg.GetElement(GetCtx(), "C_Calendar_ID")); return(false); } } else if (GetC_Calendar_ID() != 0) { SetC_Calendar_ID(0); } if (IsDefault()) { Boolean exists = false; String sql = "SELECT * FROM Fact_Accumulation " + " WHERE IsDefault = 'Y'" + " AND IsActive = 'Y' " + " AND AD_Client_ID = " + GetAD_Client_ID() + " AND Fact_Accumulation_ID <> " + GetFACT_ACCUMULATION_ID(); IDataReader idr = null; try { idr = DB.ExecuteReader(sql, null, Get_TrxName()); if (idr.Read()) { exists = true; } idr.Close(); } catch (Exception e) { log.Log(Level.SEVERE, sql, e); } finally { if (idr != null) { idr.Close(); idr = null; } } if (exists) { log.SaveError("DefaultExists", "Default Balance aggregation already exists"); return(false); } } if (!newRecord) { if (Is_ValueChanged("C_AcctSchema_ID") || Is_ValueChanged("BalanceAccumulation") || Is_ValueChanged("C_Calendar_ID") || Is_ValueChanged("IsActivity") || Is_ValueChanged("IsBudget") || Is_ValueChanged("IsBusinessPartner") || Is_ValueChanged("IsCampaign") || Is_ValueChanged("IsLocationFrom") || Is_ValueChanged("IsLocationTo") || Is_ValueChanged("IsProduct") || Is_ValueChanged("IsProject") || Is_ValueChanged("IsSalesRegion") || Is_ValueChanged("IsUserList1") || Is_ValueChanged("IsUserList2")) { Boolean exists = false; String sql = "SELECT * FROM Fact_Acct_Balance " + " WHERE Fact_Accumulation_ID = " + GetFACT_ACCUMULATION_ID(); IDataReader idr = null; try { idr = DB.ExecuteReader(sql, null, Get_TrxName()); if (idr.Read()) { exists = true; } idr.Close(); } catch (Exception e) { log.Log(Level.SEVERE, sql, e); } finally { if (idr != null) { idr.Close(); idr = null; } } if (exists) { log.SaveError("BalanceExists", "Updates not allowed when balances exists for the Aggregation"); return(false); } } } return(true); }
/// <summary> /// Ask pipe to terminate. The termination will happen asynchronously /// and user will be notified about actual deallocation by 'terminated' /// event. /// </summary> /// <param name="delay">if set to <c>true</c>, the pending messages will be processed /// before actual shutdown. </param> public void Terminate(bool delay) { // Overload the value specified at pipe creation. m_delay = delay; // If terminate was already called, we can ignore the duplicate invocation. if (m_state == State.Terminated || m_state == State.DoubleTerminated) { return; } // If the pipe is in the phase of async termination, it's going to // closed anyway. No need to do anything special here. if (m_state == State.Terminating) { return; } if (m_state == State.Active) { // The simple sync termination case. Ask the peer to terminate and wait // for the ack. SendPipeTerm(m_peer); m_state = State.Terminated; } else if (m_state == State.Pending && !m_delay) { // There are still pending messages available, but the user calls // 'terminate'. We can act as if all the pending messages were read. m_outboundPipe = null; SendPipeTermAck(m_peer); m_state = State.Terminating; } else if (m_state == State.Pending) { // If there are pending messages still available, do nothing. } else if (m_state == State.Delimited) { // We've already got delimiter, but not term command yet. We can ignore // the delimiter and ack synchronously terminate as if we were in // active state. SendPipeTerm(m_peer); m_state = State.Terminated; } else { // There are no other states. Debug.Assert(false); } // Stop outbound flow of messages. m_outActive = false; if (m_outboundPipe != null) { // Drop any unfinished outbound messages. Rollback(); // Write the delimiter into the pipe. Note that watermarks are not // checked; thus the delimiter can be written even when the pipe is full. var msg = new Msg(); msg.InitDelimiter(); m_outboundPipe.Write(ref msg, false); Flush(); } }
public bool Recv(ref Msg msg) { return(RecvPipe(null, ref msg)); }
public static extern int SendMessageW(IntPtr hWnd, Msg msg, int wParam, ref PARAFORMAT2 format);
/// <summary> /// 向指定终端异步发送数据 /// </summary> /// <param name="msg">消息类型</param> /// <param name="data">消息数据正文</param> /// <param name="end">指定终端</param> /// <param name="callback">回调方法</param> public void SendAsync(Msg msg, byte[] data, TCPEndPoint end, AsyncCallback callback) { TCPServer.TCPServers[_server_id].SendAsync(msg, data, end, callback); }
public static extern int SendMessage(IntPtr hWnd, Msg msg, int wParam, ref TOOLINFO lParam);
public static extern IntPtr SendMessageW(IntPtr hWnd, Msg msg, int wParam, IntPtr lParam);
private void Modify(TFXK.Model.TestingPersonPlan model) { bll.Update(model); hdfPid.Value = model.id + ""; Msg.ShowAndRedirect("修改信息成功!", "Default.aspx"); }
/// <summary> /// 向指定终端同步发送数据 /// </summary> /// <param name="msg">消息类型</param> /// <param name="data">消息数据正文</param> /// <param name="end">指定终端</param> public void Send(Msg msg, byte[] data, TCPEndPoint end) { TCPServer.TCPServers[_server_id].Send(msg, data, end); }
public static extern void SendMessage(IntPtr hWnd, Msg msg, int wParam, ref RECT lParam);
private void Tab02TextBoxB11_TextChanged(object sender, TextChangedEventArgs e) { Tab02TextBlockC11.Text = Tab02TextBoxB11.Text; Msg.Publication("Tab02TextBlockC11 -> texte modifié"); }
public static extern void SendMessageW(IntPtr hWnd, Msg msg, int wParam, ref HD_HITTESTINFO hti);
public ongletFormulaires() { InitializeComponent(); Msg.Publication("Initalisation de l'onglet 'Formulaires'..."); Tab02ComboBoxB06.SelectedIndex = 1; }
internal StreamInfo(Msg msg, bool throwOnError) : base(msg, throwOnError) { Init(JsonNode); }