public void SendMessage(SendMessageType message, List <DrivingInfraction> infractions)
    {
        string msg = "{\"messageType\" : \"" + message.ToString() + "\", \"messageArgs\" : [";

        for (int i = 0; i < infractions.Count; i++)
        {
            var    inf = infractions[i];
            string obj = "{";
            obj += "\"id\" : " + inf.id;
            obj += ",\"type\" : \"" + inf.type + "\"";
            obj += ",\"sysTime\" : " + inf.systemTime.ToJavaScriptMilliseconds();
            obj += ",\"sessionTime\" : " + inf.sessionTime;
            obj += ",\"speed\" : " + (inf.speed * NetworkedCarConsole.MPSTOMPH).ToString("F2");
            obj += "}";

            if (i < infractions.Count - 1)
            {
                obj += ",";
            }

            msg += obj;
        }
        msg += "]}";
        server.WebSocketServices.Broadcast(msg);
    }
 public SendMessageEngine(SendMessageType sendMessageType, IMessageSender sendMessageSender, IDatabase database, string sendMessageTableName)
 {
     this.sendMessageType      = sendMessageType;
     this.sendMessageSender    = sendMessageSender;
     this.database             = database;
     this.sendMessageTableName = sendMessageTableName;
 }
Example #3
0
        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="hostname">远程IP或机器名</param>
        /// <param name="port">远程机器端口</param>
        /// <param name="content">发送内容(主题)</param>
        /// <param name="sType">内容类型(消息、通知)</param>
        public static void SendMeg(string hostname, int port, string content, SendMessageType sType)
        {
            TcpClient tempTpc;

            try
            {
                tempTpc = new TcpClient(hostname, port);
            }
            catch (Exception le)
            {
                le.GetType();
                //				MessageBox.Show("连接被拒绝!\n"+le.Message,"提示:",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                return;
            }
            try
            {
                //				DateTime NowTime=XcDate.ServerDateTime;
                string strDateLine = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(); //得到发送时客户端时间
                netStream = tempTpc.GetStream();                                                               //得到网络流
                sw        = new StreamWriter(netStream);                                                       //创建TextWriter,向流中写字符
                string words      = content;                                                                   //待发送的内容
                string contentStr = sType.ToString() + System.Environment.NewLine +
                                    strDateLine + " " + System.Environment.NewLine + words;                    //待发送内容

                sw.Write(contentStr);                                                                          //写入流
                sw.Close();                                                                                    //关闭流写入器
                netStream.Close();                                                                             //关闭网络流
                tempTpc.Close();                                                                               //关闭客户端连接
            }
            catch (Exception ex)
            {
                MessageBox.Show("发送消息失败!" + ex.Message, "提示:", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
    public void SendMessage(SendMessageType message, int arg)
    {
        Debug.Log(message.ToString() + " message and argument" + arg.ToString());
        string msg = "{\"messageType\" : \"" + message.ToString() + "\", \"messageArgs\" : { \"int\" : " + arg + "}}";

        server.WebSocketServices.Broadcast(msg);
    }
    private static void dialogFunctions()
    {
        try{
            String projectName = null;

            String idToken = CollaborationTool.login("", "");
            if (idToken != null)
            {
                //Open projects list
                try {
                    List <ProjectType> prjList = CollaborationTool.getProjectList(idToken);
                    foreach (ProjectType prj in prjList)
                    {
                        if (prj.name.Equals("CAD1"))
                        {
                            projectName = prj.name;
                            break;
                        }
                    }
                } catch (Exception e) {
                    projectName = null;
                }
            }

            CollaborationTool.startCollaborate(idToken, projectName);

            // Setup done
            // ----------------------
            // Test message excange

            if (idToken == null)
            {
                return;
            }
            if (projectName == null)
            {
                return;
            }

            CollabMessageType msg = new CollabMessageType(projectName, "PROVA");
            msg.contents.Add("KEY1", "VAL1");
            msg.contents.Add("KEY2", "VAL2");
            msg.contents.Add("KEY3", "VAL3");
            SendMessageType msg_out = new SendMessageType(idToken, msg);
            CollaborationTool.sendMessage(msg_out);

            ReadMessageType msgReturn = CollaborationTool.readMessages(idToken, projectName);
            foreach (CollabMessageType m in msgReturn.messages)
            {
                Debug.Print(m.uniqueID + "-" + m.projectName + "-" + m.title);
            }
        } catch (Exception e) {
            logError(e);
        }
    }
 public static void sendMessage(SendMessageType msg)
 {
     try
     {
         sendPostCommand("/sendMessage", msg.ToString());
     }
     catch (Exception ex)
     {
         logError(ex);
     }
 }
Example #7
0
 public ChatMessage(Player sender, string msg, MessageType msgType, SendMessageType sendType)
 {
     Sender   = sender;
     Message  = msg;
     MsgType  = msgType;
     SendType = sendType;
     if (MsgType == MessageType.WHISPER)
     {
         SendType = SendMessageType.PRIVATE;
     }
 }
Example #8
0
        private DataTable selMessage(SendMessageType sType)
        {
            DataTable myTb = new DataTable();
            string    sSql = "";

            try
            {
                sSql = "SELECT A.Title 主题, Content 内容,inform 通知内容 ,case flag when 0 then '未读' else '已读' end 状态 , A.ID,Bdate 发布时间, edate 结束时间 " +
                       "FROM MZ_MESSAGE A INNER JOIN MZ_MESSAGE_DEPT B ON B.P_ID = A.ID AND mtype in (0," + mtype.ToString() + ") AND bdate<'" + DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00' AND edate >'" + DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59' ";
                switch (sType.ToString())
                {
                case "消息":
                    if (this.WardID.Trim() == "")
                    {
                        sSql += "WHERE XTYPE=0 and (B.dept_id = 0 OR B.dept_id = " + DeptID.ToString() + ") order by Bdate";
                    }
                    else
                    {
                        sSql += "WHERE XTYPE=0 and (B.dept_id = 0 OR B.dept_id in (select dept_id from base_wardrdept where ward_id='" + WardID.Trim() + "')) order by Bdate";
                    }
                    break;

                case "通知":
                    if (this.WardID.Trim() == "")
                    {
                        sSql += "WHERE XTYPE=1 and (B.dept_id = 0 OR B.dept_id = " + DeptID.ToString() + ") order by Bdate";
                    }
                    else
                    {
                        sSql += "WHERE XTYPE=1 and (B.dept_id = 0 OR B.dept_id in (select dept_id from base_wardrdept where ward_id='" + WardID.Trim() + "')) order by Bdate";
                    }
                    break;

                default:
                    sSql += "WHERE B.dept_id = 0 order by Bdate";
                    break;
                }
                myTb = TrasenFrame.Forms.FrmMdiMain.Database.GetDataTable(sSql);
                return(myTb);
            }
            catch (System.Exception err)
            {
                MessageBox.Show(err.ToString(), "错误提示:", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
        }
Example #9
0
        /// <summary>
        /// Server Sided Network Messages while Main Game is running
        /// </summary>
        /// <param name="pSendMsgType"></param>
        /// <param name="pReceiver"></param>
        public void SendMainGameMsg(SendMessageType pSendMsgType)
        {
            var msg = _client.CreateMessage();
            {
                switch (pSendMsgType)
                {
                case SendMessageType.INPUT_LEFT:
                    msg.Write("LEFT");
                    break;

                case SendMessageType.INPUT_RIGHT:
                    msg.Write("RIGHT");
                    break;
                }
                _client.SendMessage(msg, NetDeliveryMethod.Unreliable);
            }
        }
Example #10
0
 /// <summary>
 /// Server Sided Network Messages while Main Game is running
 /// </summary>
 /// <param name="pSendMsgType"></param>
 /// <param name="pReceiver"></param>
 public void SendMainGameMsg(SendMessageType pSendMsgType, NetConnection pReceiver, PlayerComponent pPlayerComponent, PlayerComponent pEnemyComponent, int player1Score, int player2Score)
 {
     var msg = _server.CreateMessage();
     {
         switch (pSendMsgType)
         {
         case SendMessageType.MOVE:
             msg.Write("MOVE");
             msg.WriteVariableInt32((int)pPlayerComponent.CurrentPosition.X);
             msg.WriteVariableInt32((int)pPlayerComponent.CurrentPosition.Y);
             msg.Write(pPlayerComponent.Rotation);
             msg.WriteVariableInt32((int)pEnemyComponent.CurrentPosition.X);
             msg.WriteVariableInt32((int)pEnemyComponent.CurrentPosition.Y);
             msg.Write(pEnemyComponent.Rotation);
             msg.WriteVariableInt32(player1Score);
             msg.WriteVariableInt32(player2Score);
             break;
         }
         _server.SendMessage(msg, pReceiver, NetDeliveryMethod.Unreliable);
     }
 }
Example #11
0
        public void SendMsg(SendMessageType pSendMsgType)
        {
            var message = _client.CreateMessage();

            switch (pSendMsgType)
            {
            case SendMessageType.CONNECT_TO_GAME:
                message.Write("Connect To Game");
                break;

            case SendMessageType.GET_NUMBER_PLAYER_IN_GAME:
                message.Write("Get number of players in Game");
                break;

            case SendMessageType.JOIN_SERVER:
                break;

            case SendMessageType.ENTER_GAME:
                message.Write("ENTER_GAME");
                break;
            }
            _client.SendMessage(message, NetDeliveryMethod.ReliableOrdered);
        }
Example #12
0
        public void sendMsg(SendMessageType pSendMsgType, NetConnection pReceiver)
        {
            var msg = _server.CreateMessage();

            switch (pSendMsgType)
            {
            case SendMessageType.GET_NUMBER_PLAYER_IN_GAME:
                msg.Write("Numbers of players in Game: " + netGame1.numberOfPlayer.ToString());
                break;

            case SendMessageType.JOINED_GAME_SUCCESS_PLAYER_1:
                msg.Write("JOINED_GAME_SUCCESS_PLAYER_1");
                break;

            case SendMessageType.JOINED_GAME_SUCCESS_PLAYER_2:
                msg.Write("JOINED_GAME_SUCCESS_PLAYER_2");
                break;

            case SendMessageType.JOINED_GAME_FAILURE:
                msg.Write("JOINED_GAME_FAILURE");
                break;
            }
            _server.SendMessage(msg, pReceiver, NetDeliveryMethod.ReliableOrdered);
        }
Example #13
0
        /// <summary>
        /// 获取消息列表
        /// </summary>
        /// <param name="sType">消息类型(通知、消息)</param>
        /// <param name="MessageType">消息的归属类型(0=所有模块 1= 2=  3= 系统模块ID)</param>
        /// <param name="deptID">消息归属的科室ID</param>
        /// <param name="ipAddress">消息归属的机器IP地址</param>
        /// <returns></returns>
        public static DataTable selMessage(SendMessageType sType, int MessageType, long deptID)
        {
            DataTable myTb = new DataTable();
            string    sSql = "";

            try
            {
                sSql = "SELECT A.Title 主题, Content 内容,inform 通知内容,case flag when 0 then '未读' else '已读' end 状态 , A.ID,Bdate 发布时间, edate 结束时间,A.tlsj " +
                       "FROM MZ_MESSAGE A INNER JOIN MZ_MESSAGE_DEPT B ON B.P_ID = A.ID AND mtype in (0," + MessageType.ToString() + ") AND bdate< '" + DateTime.Now.ToString("yyyy-MM-dd") + "  00:00:00' AND edate > '" + DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59' ";
                switch (sType.ToString())
                {
                case "消息":

                    sSql += "WHERE XTYPE=0 and (B.dept_id = 0 OR B.dept_id = " + deptID.ToString() + ") and (B.ip_address='' OR B.ip_address='" + AddressIP + "') order by book_date";

                    break;

                case "通知":

                    sSql += "WHERE XTYPE=1 and (B.dept_id = 0 OR B.dept_id = " + deptID.ToString() + ") and (B.ip_address='' OR B.ip_address='" + AddressIP + "') order by book_date";

                    break;

                default:
                    sSql += "WHERE B.dept_id = 0 order by book_date";
                    break;
                }
                myTb = TrasenFrame.Forms.FrmMdiMain.Database.GetDataTable(sSql);
                return(myTb);
            }
            catch (System.Exception err)
            {
                MessageBox.Show(err.ToString(), "错误提示:", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
        }
Example #14
0
        /// <summary>
        /// 在 GetDeliveryReport 之後,更新大表 SendMessageHistory
        /// </summary>
        public void UpdateSendMessageHistory(int sendMessageQueueId)
        {
            var sendMessageRuleRepository    = this.unitOfWork.Repository <SendMessageRule>();
            var sendMessageQueueRepository   = this.unitOfWork.Repository <SendMessageQueue>();
            var sendMessageHistoryRepository = this.unitOfWork.Repository <SendMessageHistory>();

            SendMessageQueue sendMessageQueue = sendMessageQueueRepository.GetById(sendMessageQueueId);

            SendMessageRule sendMessageRule = sendMessageRuleRepository.GetById(sendMessageQueue.SendMessageRuleId);

            var clientTimezoneOffset = sendMessageRule.ClientTimezoneOffset;

            var messageReceivers = this.unitOfWork.Repository <MessageReceiver>().GetMany(p =>
                                                                                          p.SendMessageRuleId == sendMessageQueue.SendMessageRuleId &&
                                                                                          p.SendBody == sendMessageQueue.SendBody).ToList();

            Every8d_SendMessageResult sendMessageResult = this.unitOfWork.Repository <Every8d_SendMessageResult>().Get(p => p.SourceTable == SourceTable.SendMessageQueue && p.SourceTableId == sendMessageQueueId);
            // if (SendMessageResult == null) return; 不應該為 null

            int?DepartmentId = null;

            if (sendMessageRule.CreatedUser.Department != null)
            {
                DepartmentId = sendMessageRule.CreatedUser.Department.Id;
            }
            string          CreatedUserId     = sendMessageRule.CreatedUser.Id;
            int             SendMessageRuleId = sendMessageQueue.SendMessageRuleId;
            SendMessageType SendMessageType   = sendMessageQueue.SendMessageType;

            DateTime     SendTime     = sendMessageQueue.SendTime;
            string       SendTitle    = sendMessageQueue.SendTitle;
            string       SendBody     = sendMessageQueue.SendBody;
            SendCustType SendCustType = sendMessageQueue.SendCustType;
            string       RequestId    = sendMessageResult.BATCH_ID;

            string ProviderName = this.Name;

            DateTime SendMessageResultCreatedTime = sendMessageResult.CreatedTime;

            List <Every8d_DeliveryReport> DeliveryReports = sendMessageResult.DeliveryReports.ToList();

            //foreach (var DeliveryReport in DeliveryReports)
            for (var i = 0; i < DeliveryReports.Count; i++)
            {
                var DeliveryReport  = DeliveryReports[i];
                var messageReceiver = (0 <= i && i < messageReceivers.Count) ? messageReceivers[i] : null;

                string DestinationName = DeliveryReport.NAME;

                var entity = new SendMessageHistory();

                ////////////////////////////////////////
                // 01 ~ 05

                entity.DepartmentId       = DepartmentId;
                entity.CreatedUserId      = CreatedUserId;
                entity.SendMessageRuleId  = SendMessageRuleId;
                entity.SendMessageQueueId = sendMessageQueueId;
                entity.SendMessageType    = SendMessageType;

                ////////////////////////////////////////
                // 06 ~ 10

                entity.SendTime     = SendTime;
                entity.SendTitle    = SendTitle;
                entity.SendBody     = SendBody;
                entity.SendCustType = SendCustType;
                entity.RequestId    = RequestId;

                ////////////////////////////////////////
                // 11 ~ 15

                entity.ProviderName        = ProviderName;
                entity.MessageId           = null;
                entity.MessageStatus       = MessageStatus.Unknown;
                entity.MessageStatusString = entity.MessageStatus.ToString();
                entity.SenderAddress       = sendMessageRule.SenderAddress;

                ////////////////////////////////////////
                // 16 ~ 20

                // 20151106 Norman, Infobip 給的手機門號是 E164格式,但是沒有加上 "+",使用 【MobileUtil.GetE164PhoneNumber】會導致誤判
                var destinationAddress = DeliveryReport.MOBILE;
                if (!destinationAddress.StartsWith("+", StringComparison.OrdinalIgnoreCase))
                {
                    destinationAddress = "+" + destinationAddress;
                }

                entity.DestinationAddress           = MobileUtil.GetE164PhoneNumber(destinationAddress);
                entity.SendMessageResultCreatedTime = SendMessageResultCreatedTime;

                // TODO: 驗證 Every8d 回傳發送時間轉成 UTC 時間是否正確
                //entity.SentDate = Converter.ToDateTime(DeliveryReport.SENT_TIME, Converter.Every8d_SentTime).Value; // 2010/03/23 12:05:29
                //entity.DoneDate = Converter.ToDateTime(DeliveryReport.SENT_TIME, Converter.Every8d_SentTime).Value; // 2010/03/23 12:05:29,簡訊供應商沒有提供此資訊,因此設定與SentDate一致
                entity.SentDate = Converter.ToDateTime(DeliveryReport.SENT_TIME, Converter.Every8d_SentTime).Value.ToUniversalTime(); // 2010/03/23 12:05:29
                entity.DoneDate = Converter.ToDateTime(DeliveryReport.SENT_TIME, Converter.Every8d_SentTime).Value.ToUniversalTime(); // 2010/03/23 12:05:29,簡訊供應商沒有提供此資訊,因此設定與SentDate一致

                entity.DeliveryStatus = (DeliveryReportStatus)Convert.ToInt32(DeliveryReport.STATUS);

                ////////////////////////////////////////
                // 21 ~ 25

                entity.DeliveryStatusString = entity.DeliveryStatus.ToString();
                entity.Price = Convert.ToDecimal(DeliveryReport.COST);
                entity.DeliveryReportCreatedTime = DeliveryReport.CreatedTime;
                entity.MessageCost = (new MessageCostInfo(entity.SendBody, entity.DestinationAddress).MessageCost);
                entity.Delivered   = IsDelivered(entity.DeliveryStatus);

                ////////////////////////////////////////
                // 26
                entity.DestinationName           = DestinationName;
                entity.Region                    = MobileUtil.GetRegionName(entity.DestinationAddress);
                entity.CreatedTime               = DateTime.UtcNow;
                entity.RetryMaxTimes             = systemParameters.RetryMaxTimes;
                entity.RetryTotalTimes           = 0;
                entity.SendMessageRetryHistoryId = null;
                entity.Email = messageReceiver != null ? messageReceiver.Email : string.Empty;

                entity = sendMessageHistoryRepository.Insert(entity);

                // 如果發送失敗,就回補點數
                // 20151123 Norman, Eric 要求發送失敗不回補點數
                //this.tradeService.HandleSendMessageHistory(sendMessageRule, sendMessageQueue, entity);
            }

            // (6) 出統計表
            this.sendMessageStatisticService.AddOrUpdateSendMessageStatistic(sendMessageQueueId);
        }
    public void SendMessageRaw(SendMessageType message, string args)
    {
        string msg = "{\"messageType\" : \"" + message.ToString() + "\", \"messageArgs\" : " + args + "}";

        server.WebSocketServices.Broadcast(msg);
    }
Example #16
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="messageType"></param>
 protected MessageObjectBase(SendMessageType messageType)
 {
     type = messageType;
 }
Example #17
0
 public static void SendMessage(Player senderPlayer, string msg, MessageType msgType = MessageType.GENERAL, SendMessageType sendType = SendMessageType.BROADCAST)
 {
     SendMessage(new ChatMessage(senderPlayer, msg, msgType, sendType));
 }
Example #18
0
 public ChatMessage(Player sender, string msg, SendMessageType sendType = SendMessageType.BROADCAST)
     : this(sender, msg, MessageType.GENERAL, sendType)
 {
 }
Example #19
0
 /// <summary>
 /// Send personal message
 /// </summary>
 /// <param name="userId">to user</param>
 /// <param name="message">message body</param>
 /// <param name="title">message title. null allowed</param>
 /// <param name="type">message type. null allowed</param>
 /// <returns>sent message id</returns>
 public int Send(int userId, string message, string title, SendMessageType? type)
 {
     this.Manager.Method("messages.send");
     this.Manager.Params("uid", userId);//((type == MessageType.Outgoing) ? "1" : "0"));
     this.Manager.Params("message", message);
     if (title != null)
     {
         this.Manager.Params("title", title);
     }
     if (type != null)
     {
         this.Manager.Params("type", (int)type);
     }
     string resp = this.Manager.Execute().GetResponseString();
     if (this.Manager.MethodSuccessed)
     {
         XmlDocument x = this.Manager.GetXmlDocument(resp);
         return Convert.ToInt32(x.SelectSingleNode("/response").InnerText);
     }
     return -1;
 }
Example #20
0
    /// <summary>
    /// <para>name : ShowMessage</para>
    /// <para>parameter : Hashtable</para>
    /// <para>return : void</para>
    /// <para>describe : Parsing (Hashtable)parameter and show message.</para>
    /// </summary>
    void ShowMessage(Hashtable resultHash)
    {
        int pno = 0;

        if (resultHash.ContainsKey("pno"))
        {
            int.TryParse(resultHash["pno"].ToString(), out pno);
        }

        SendMessageType messageType = (SendMessageType)pno;

        switch (messageType)
        {
        case SendMessageType.Type_UserConnect:
        case SendMessageType.Type_ChangeChannel: {
            if (resultHash.ContainsKey("roomNo"))
            {
                int.TryParse(resultHash["roomNo"].ToString(), out channel);
                switch (ClientDataManager.Instance.SelectSceneMode)
                {
                case ClientDataManager.SceneMode.Lobby:
                    if (LobbySceneScriptManager.Instance == null)
                    {
                        break;
                    }

                    if (LobbySceneScriptManager.Instance.m_ChatEvent != null)
                    {
                        LobbySceneScriptManager.Instance.m_ChatEvent.ChangeChannel(channel);
                    }

                    break;

                case ClientDataManager.SceneMode.Dungeon:
                    if (DungeonSceneScriptManager.Instance == null)
                    {
                        break;
                    }

                    if (DungeonSceneScriptManager.Instance.m_ChatEvent != null)
                    {
                        DungeonSceneScriptManager.Instance.m_ChatEvent.ChangeChannel(channel);
                    }

                    break;
                }
            }
        }

        break;

        case SendMessageType.Type_GetMessage: {
            string szMessage = "";
            string nickName  = "";

            if (resultHash.ContainsKey("Msg"))
            {
                szMessage = resultHash["Msg"].ToString();
            }
            if (resultHash.ContainsKey("Nickname"))
            {
                nickName = resultHash["Nickname"].ToString();
            }

            UIMessage uiMessage = new UIMessage();
            uiMessage.type    = messageType;
            uiMessage.message = MagiStringUtil.GetReplaceString(nickName.Equals(ClientDataManager.Instance.OwnName) ? 10005006 : 10005007, "#@Name@#", nickName,
                                                                "#@Message@#", MagiUtil.MessageCutByte(szMessage, 80));

            switch (ClientDataManager.Instance.SelectSceneMode)
            {
            case ClientDataManager.SceneMode.Lobby:
                if (LobbySceneScriptManager.Instance == null)
                {
                    break;
                }

                if (LobbySceneScriptManager.Instance.m_ChatEvent != null)
                {
                    LobbySceneScriptManager.Instance.m_ChatEvent.AddUserMessage(uiMessage);
                }
                else
                {
                    AddMessage(uiMessage);
                }

                if (LobbySceneScriptManager.Instance.m_LobbyEvent != null && LobbySceneScriptManager.Instance.m_LobbyEvent.GetLobbyMenuFrame != null)
                {
                    uiMessage.message = MagiStringUtil.GetReplaceString(nickName.Equals(ClientDataManager.Instance.OwnName) ? 10005006 : 10005007, "#@Name@#", nickName,
                                                                        "#@Message@#", MagiUtil.MessageCutByte(szMessage, 35));
                    LobbySceneScriptManager.Instance.m_LobbyEvent.GetLobbyMenuFrame.UpdateLobbyChat(uiMessage);
                }

                break;

            case ClientDataManager.SceneMode.Dungeon:
                if (DungeonSceneScriptManager.Instance == null)
                {
                    break;
                }

                if (DungeonSceneScriptManager.Instance.m_ChatEvent != null)
                {
                    DungeonSceneScriptManager.Instance.m_ChatEvent.AddUserMessage(uiMessage);
                }
                else
                {
                    AddMessage(uiMessage);
                }

                if (DungeonSceneScriptManager.Instance.m_DungeonPlayEvent != null)
                {
                    uiMessage.message = MagiStringUtil.GetReplaceString(nickName.Equals(ClientDataManager.Instance.OwnName) ? 10005006 : 10005007, "#@Name@#", nickName,
                                                                        "#@Message@#", MagiUtil.MessageCutByte(szMessage, 25));
                    DungeonSceneScriptManager.Instance.m_DungeonPlayEvent.UpdateInGameChat(uiMessage);
                }

                break;

            default:
                AddMessage(uiMessage);
                break;
            }
        }

        break;

        case SendMessageType.Type_GetItemMessage: {
            int    from     = 0;
            int    what     = 0;
            string nickName = "";

            if (resultHash.ContainsKey("From"))
            {
                int.TryParse(resultHash["From"].ToString(), out from);
            }
            if (resultHash.ContainsKey("What"))
            {
                int.TryParse(resultHash["What"].ToString(), out what);
            }
            if (resultHash.ContainsKey("Nickname"))
            {
                nickName = resultHash["Nickname"].ToString();
            }

            UIMessage uiMessage = new UIMessage();
            uiMessage.type    = messageType;
            uiMessage.message = MagiStringUtil.GetReplaceString(10005010, "#@Name@#", nickName, "#@Where@#", GetFromTypeText(from), "#@ItemName@#", GetItemNameText(what));

            switch (ClientDataManager.Instance.SelectSceneMode)
            {
            case ClientDataManager.SceneMode.Lobby:
                if (LobbySceneScriptManager.Instance == null)
                {
                    break;
                }

                if (LobbySceneScriptManager.Instance.m_ChatEvent != null)
                {
                    LobbySceneScriptManager.Instance.m_ChatEvent.AddMessage(uiMessage);
                }
                else
                {
                    AddMessage(uiMessage);
                }

                break;

            case ClientDataManager.SceneMode.Dungeon:
                if (DungeonSceneScriptManager.Instance == null)
                {
                    break;
                }

                if (DungeonSceneScriptManager.Instance.m_ChatEvent != null)
                {
                    DungeonSceneScriptManager.Instance.m_ChatEvent.AddMessage(uiMessage);
                }
                else
                {
                    AddMessage(uiMessage);
                }

                break;

            default:
                AddMessage(uiMessage);
                break;
            }
        }

        break;

        case SendMessageType.Type_GetNoticeMessage: {
            string szMessage = "";

            if (resultHash.ContainsKey("Msg"))
            {
                szMessage = resultHash["Msg"].ToString();
            }

            UIMessage uiMessage = new UIMessage();
            uiMessage.type    = messageType;
            uiMessage.message = MagiStringUtil.GetReplaceString(10005009, "#@Message@#", MagiUtil.MessageCutByte(szMessage, 80));

            switch (ClientDataManager.Instance.SelectSceneMode)
            {
            case ClientDataManager.SceneMode.Lobby:
                if (LobbySceneScriptManager.Instance == null)
                {
                    break;
                }

                if (LobbySceneScriptManager.Instance.m_ChatEvent != null)
                {
                    LobbySceneScriptManager.Instance.m_ChatEvent.AddUserMessage(uiMessage);
                }
                else
                {
                    AddMessage(uiMessage);
                }

                if (LobbySceneScriptManager.Instance.m_LobbyEvent != null && LobbySceneScriptManager.Instance.m_LobbyEvent.GetLobbyMenuFrame != null)
                {
                    uiMessage.message = MagiStringUtil.GetReplaceString(10005009, "#@Message@#", MagiUtil.MessageCutByte(szMessage, 35));
                    LobbySceneScriptManager.Instance.m_LobbyEvent.GetLobbyMenuFrame.UpdateLobbyChat(uiMessage);
                }

                break;

            case ClientDataManager.SceneMode.Dungeon:
                if (DungeonSceneScriptManager.Instance == null)
                {
                    break;
                }

                if (DungeonSceneScriptManager.Instance.m_ChatEvent != null)
                {
                    DungeonSceneScriptManager.Instance.m_ChatEvent.AddUserMessage(uiMessage);
                }
                else
                {
                    AddMessage(uiMessage);
                }

                if (DungeonSceneScriptManager.Instance.m_DungeonPlayEvent != null)
                {
                    uiMessage.message = MagiStringUtil.GetReplaceString(10005009, "#@Message@#", MagiUtil.MessageCutByte(szMessage, 25));
                    DungeonSceneScriptManager.Instance.m_DungeonPlayEvent.UpdateInGameChat(uiMessage);
                }

                break;

            default:
                AddMessage(uiMessage);
                break;
            }
        }

        break;
        }
    }
Example #21
0
 /// <summary>
 /// Send personal message
 /// </summary>
 /// <param name="userId">to user</param>
 /// <param name="message">message body</param>
 /// <param name="title">message title. null allowed</param>
 /// <param name="type">message type. null allowed</param>
 /// <returns>sent message id</returns>
 public int Send(int userId, string message, string title, SendMessageType type)
 {
     return this.Send(userId, null, title, message, null, null, type);
 }
Example #22
0
        /// <summary>
        /// Send personal message
        /// </summary>
        /// <param name="userId">user id if no chat id presented</param>
        /// <param name="chatId">chat id if no user id presented</param>
        /// <param name="title">message title</param>
        /// <param name="message">message body</param>
        /// <param name="attachment">attachment</param>
        /// <param name="forwardMessages">list of messages ids to forwarding</param>
        /// <param name="type">message type</param>
        /// <returns>id of message that was sended</returns>
        public int Send(int? userId, int? chatId, string title, string message, MessageAttachment[] attachment, int?[] forwardMessages, SendMessageType? type)
        {
            this.Manager.Method("messages.send",
                                    new object[] { "uid", userId,
                                        "chat_id", chatId,
                                        "title", title,
                                        "message", message,
                                        "attachment", attachment,
                                        "forward_messages", forwardMessages,
                                        "type", (int)type });

            XmlDocument x = this.Manager.Execute().GetResponseXml();
            return Convert.ToInt32(x.InnerText);
        }
Example #23
0
        /// <summary>
        /// 在 SendSMS 之後,建立大表 SendMessageHistory
        /// </summary>
        public void CreateSendMessageHistory(SendMessageQueue sendMessageQueue)
        {
            int sendMessageQueueId = sendMessageQueue.Id;

            var sendMessageRuleRepository    = this.unitOfWork.Repository <SendMessageRule>();
            var sendMessageQueueRepository   = this.unitOfWork.Repository <SendMessageQueue>();
            var sendMessageHistoryRepository = this.unitOfWork.Repository <SendMessageHistory>();

            SendMessageRule sendMessageRule = sendMessageRuleRepository.GetById(sendMessageQueue.SendMessageRuleId);

            Infobip_SendMessageResult sendMessageResult = this.unitOfWork.Repository <Infobip_SendMessageResult>().Get(p => p.SourceTable == SourceTable.SendMessageQueue && p.SourceTableId == sendMessageQueueId);

            if (sendMessageResult == null)
            {
                throw new Exception(string.Format("InfobipSmsProvider(smsProviderType = {0}),無法取得 Infobip_SendMessageResult(SendMessageQueueId:{1})", smsProviderType.ToString(), sendMessageQueueId));
            }

            int?DepartmentId = null;

            if (sendMessageRule.CreatedUser.Department != null)
            {
                DepartmentId = sendMessageRule.CreatedUser.Department.Id;
            }
            string          CreatedUserId     = sendMessageRule.CreatedUser.Id;
            int             SendMessageRuleId = sendMessageQueue.SendMessageRuleId;
            SendMessageType SendMessageType   = sendMessageQueue.SendMessageType;

            DateTime     SendTime     = sendMessageQueue.SendTime;
            string       SendTitle    = sendMessageQueue.SendTitle;
            string       SendBody     = sendMessageQueue.SendBody;
            SendCustType SendCustType = sendMessageQueue.SendCustType;
            string       RequestId    = sendMessageResult.ClientCorrelator;

            string ProviderName = this.Name;

            DateTime SendMessageResultCreatedTime = sendMessageResult.CreatedTime;

            List <Infobip_SendMessageResultItem> SendMessageResults = sendMessageResult.SendMessageResults.ToList();

            foreach (var SendMessageResult in SendMessageResults)
            {
                string DestinationName = SendMessageResult.DestinationName;

                var entity = new SendMessageHistory();

                ////////////////////////////////////////
                // 01 ~ 05

                entity.DepartmentId       = DepartmentId;
                entity.CreatedUserId      = CreatedUserId;
                entity.SendMessageRuleId  = SendMessageRuleId;
                entity.SendMessageQueueId = sendMessageQueueId;
                entity.SendMessageType    = SendMessageType;

                ////////////////////////////////////////
                // 06 ~ 10

                entity.SendTime     = SendTime;
                entity.SendTitle    = SendTitle;
                entity.SendBody     = SendBody;
                entity.SendCustType = SendCustType;
                entity.RequestId    = RequestId;

                ////////////////////////////////////////
                // 11 ~ 15

                entity.ProviderName        = ProviderName;
                entity.MessageId           = SendMessageResult.MessageId;
                entity.MessageStatus       = (EFunTech.Sms.Schema.MessageStatus)((int)SendMessageResult.MessageStatus);
                entity.MessageStatusString = entity.MessageStatus.ToString();
                entity.SenderAddress       = SendMessageResult.SenderAddress;

                ////////////////////////////////////////
                // 16 ~ 20

                // 20151106 Norman, Infobip 給的手機門號是 E164格式,但是沒有加上 "+",使用 【MobileUtil.GetE164PhoneNumber】會導致誤判
                var destinationAddress = SendMessageResult.DestinationAddress;
                if (!destinationAddress.StartsWith("+", StringComparison.OrdinalIgnoreCase))
                {
                    destinationAddress = "+" + destinationAddress;
                }

                entity.DestinationAddress           = MobileUtil.GetE164PhoneNumber(destinationAddress);
                entity.SendMessageResultCreatedTime = SendMessageResultCreatedTime;
                entity.SentDate       = null;
                entity.DoneDate       = null;
                entity.DeliveryStatus = DeliveryReportStatus.MessageAccepted;

                ////////////////////////////////////////
                // 21 ~ 25

                entity.DeliveryStatusString = entity.DeliveryStatus.ToString();
                entity.Price = (decimal)0.0; // 尚未傳送完成
                entity.DeliveryReportCreatedTime = null;
                entity.MessageCost = (new MessageCostInfo(entity.SendBody, entity.DestinationAddress).MessageCost);
                entity.Delivered   = IsDelivered(entity.DeliveryStatus);

                ////////////////////////////////////////
                // 26
                entity.DestinationName           = DestinationName;
                entity.Region                    = MobileUtil.GetRegionName(entity.DestinationAddress);
                entity.CreatedTime               = DateTime.UtcNow;
                entity.RetryMaxTimes             = systemParameters.RetryMaxTimes;
                entity.RetryTotalTimes           = 0;
                entity.SendMessageRetryHistoryId = null;
                entity.Email = SendMessageResult.Email;

                entity = sendMessageHistoryRepository.Insert(entity);
            }

            // (6) 出統計表
            this.sendMessageStatisticService.AddOrUpdateSendMessageStatistic(sendMessageQueueId);
        }
Example #24
0
 private extern static IntPtr SendMessage(
     IntPtr hwnd,
     SendMessageType wMsg,
     IntPtr wParam,
     IntPtr lParam);
Example #25
0
 public SendMessage(SendMessageType messageType)
 {
     MessageType = messageType;
 }
Example #26
0
 public static void SendMessage(Player senderPlayer, string msg, MessageType msgType = MessageType.GENERAL, SendMessageType sendType = SendMessageType.BROADCAST)
 {
     SendMessage(new ChatMessage(senderPlayer, msg, msgType, sendType));
 }
Example #27
0
 public ChatMessage(Player sender, string msg, MessageType msgType, SendMessageType sendType)
 {
     Sender = sender;
     Message = msg;
     MsgType = msgType;
     SendType = sendType;
     if(MsgType == MessageType.WHISPER)
         SendType = SendMessageType.PRIVATE;
 }
Example #28
0
        public void SendJSON(SendMessageType type, string json)
        {
            string sendjson = $"{{\"typeText\":\"update\", \"detail\":{{\"msgType\":\"{type}\", \"data\":{json}}}}}";

            core.Broadcast("/MiniParse", sendjson);
        }
Example #29
0
    public void SendMessage(SocketManager socket, SendMessageType type, string data)
    {
        string buffer = (int)type + "," + data + ",";

        socket.socket.Send(Encoding.ASCII.GetBytes(buffer));
    }
Example #30
0
        /// <summary>
        /// 在 GetDeliveryReport 之後,更新大表 SendMessageHistory
        /// </summary>
        public void UpdateSendMessageHistory(int sendMessageQueueId)
        {
            var sendMessageRuleRepository    = this.unitOfWork.Repository <SendMessageRule>();
            var sendMessageQueueRepository   = this.unitOfWork.Repository <SendMessageQueue>();
            var sendMessageHistoryRepository = this.unitOfWork.Repository <SendMessageHistory>();

            SendMessageQueue sendMessageQueue = sendMessageQueueRepository.GetById(sendMessageQueueId);

            SendMessageRule sendMessageRule = sendMessageRuleRepository.GetById(sendMessageQueue.SendMessageRuleId);

            Infobip_SendMessageResult sendMessageResult = this.unitOfWork.Repository <Infobip_SendMessageResult>().Get(p => p.SourceTable == SourceTable.SendMessageQueue && p.SourceTableId == sendMessageQueueId);

            if (sendMessageResult == null)
            {
                throw new Exception(string.Format("InfobipSmsProvider(smsProviderType = {0}),無法取得 Infobip_SendMessageResult(SendMessageQueueId:{1})", smsProviderType.ToString(), sendMessageQueueId));
            }

            int?DepartmentId = null;

            if (sendMessageRule.CreatedUser.Department != null)
            {
                DepartmentId = sendMessageRule.CreatedUser.Department.Id;
            }
            string          CreatedUserId     = sendMessageRule.CreatedUser.Id;
            int             SendMessageRuleId = sendMessageQueue.SendMessageRuleId;
            SendMessageType SendMessageType   = sendMessageQueue.SendMessageType;

            DateTime     SendTime     = sendMessageQueue.SendTime;
            string       SendTitle    = sendMessageQueue.SendTitle;
            string       SendBody     = sendMessageQueue.SendBody;
            SendCustType SendCustType = sendMessageQueue.SendCustType;
            string       RequestId    = sendMessageResult.ClientCorrelator;

            string ProviderName = this.Name;

            DateTime SendMessageResultCreatedTime = sendMessageResult.CreatedTime;

            List <Infobip_SendMessageResultItem> SendMessageResults = sendMessageResult.SendMessageResults.ToList();

            foreach (var SendMessageResult in SendMessageResults)
            {
                Infobip_DeliveryReport DeliveryReport = SendMessageResult.DeliveryReport;
                if (DeliveryReport == null)
                {
                    continue;                         // 如果尚未取得派送報表,就忽略
                }
                SendMessageHistory entity = this.unitOfWork.Repository <SendMessageHistory>().Get(p => p.MessageId == SendMessageResult.MessageId);
                if (entity == null)
                {
                    continue;                 // 如果找不到對應 MessageId,就忽略
                }
                string DestinationName = SendMessageResult.DestinationName;

                ////////////////////////////////////////
                // 01 ~ 05

                entity.DepartmentId       = DepartmentId;
                entity.CreatedUserId      = CreatedUserId;
                entity.SendMessageRuleId  = SendMessageRuleId;
                entity.SendMessageQueueId = sendMessageQueueId;
                entity.SendMessageType    = SendMessageType;

                ////////////////////////////////////////
                // 06 ~ 10

                entity.SendTime     = SendTime;
                entity.SendTitle    = SendTitle;
                entity.SendBody     = SendBody;
                entity.SendCustType = SendCustType;
                entity.RequestId    = RequestId;

                ////////////////////////////////////////
                // 11 ~ 15

                entity.ProviderName        = ProviderName;
                entity.MessageId           = SendMessageResult.MessageId;
                entity.MessageStatus       = (EFunTech.Sms.Schema.MessageStatus)((int)SendMessageResult.MessageStatus);
                entity.MessageStatusString = entity.MessageStatus.ToString();
                entity.SenderAddress       = SendMessageResult.SenderAddress;

                ////////////////////////////////////////
                // 16 ~ 20

                // 20151106 Norman, Infobip 給的手機門號是 E164格式,但是沒有加上 "+",使用 【MobileUtil.GetE164PhoneNumber】會導致誤判
                var destinationAddress = SendMessageResult.DestinationAddress;
                if (!destinationAddress.StartsWith("+", StringComparison.OrdinalIgnoreCase))
                {
                    destinationAddress = "+" + destinationAddress;
                }

                entity.DestinationAddress           = MobileUtil.GetE164PhoneNumber(destinationAddress);
                entity.SendMessageResultCreatedTime = SendMessageResultCreatedTime;
                entity.SentDate       = DeliveryReport.SentDate;
                entity.DoneDate       = DeliveryReport.DoneDate;
                entity.DeliveryStatus = DeliveryReport.Status;

                ////////////////////////////////////////
                // 21 ~ 25

                entity.DeliveryStatusString = entity.DeliveryStatus.ToString();
                entity.Price = DeliveryReport.Price ?? (decimal)0.0;
                entity.DeliveryReportCreatedTime = DeliveryReport.CreatedTime;
                entity.MessageCost = (new MessageCostInfo(entity.SendBody, entity.DestinationAddress).MessageCost);
                entity.Delivered   = IsDelivered(entity.DeliveryStatus);

                ////////////////////////////////////////
                // 26
                entity.DestinationName = DestinationName;

                entity.Region = MobileUtil.GetRegionName(entity.DestinationAddress);

                sendMessageHistoryRepository.Update(entity);

                // 如果發送失敗,就回補點數
                // 20151123 Norman, Eric 要求發送失敗不回補點數
                //this.tradeService.HandleSendMessageHistory(sendMessageRule, sendMessageQueue, entity);
            }

            // (6) 出統計表
            this.sendMessageStatisticService.AddOrUpdateSendMessageStatistic(sendMessageQueueId);
        }
Example #31
0
 public ChatMessage(Player sender, string msg, SendMessageType sendType = SendMessageType.BROADCAST) : this(sender, msg, MessageType.GENERAL, sendType)
 {
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="transaction"></param>
        /// <param name="sendMessages"></param>
        /// <returns></returns>
        public async Task Queue(ITransaction transaction, params SendMessage[] sendMessages)
        {
            bool emailQueued     = false;
            bool phoneTextQueued = false;

            foreach (var sendMessage in sendMessages)
            {
                if (sendMessage == null)
                {
                    continue;
                }

                if (string.IsNullOrEmpty(sendMessage.from))
                {
                    throw new Exception("From address cannot be blank");
                }
                string scrubbedFrom = Validate(sendMessage.from);

                if (string.IsNullOrEmpty(sendMessage.to))
                {
                    throw new Exception("To address cannot be blank");
                }
                string scrubbedTo = Validate(sendMessage.to);

                SendMessageType sendMessageType = this.DetectSendMessageType(scrubbedTo);
                switch (sendMessageType)
                {
                case SendMessageType.Email:
                    if (this.emailSendMessageEngine == null)
                    {
                        throw new Exception("No email message sender configured");
                    }
                    await this.emailSendMessageEngine.Queue(transaction, scrubbedFrom, scrubbedTo, sendMessage.subject, sendMessage.bodyText, sendMessage.bodyHtml, sendMessage.priority, sendMessage.extraData);

                    emailQueued = true;
                    break;

                case SendMessageType.Text:
                    if (this.textSendMessageEngine == null)
                    {
                        throw new Exception("No phone text message sender configured");
                    }
                    await this.textSendMessageEngine.Queue(transaction, scrubbedFrom, scrubbedTo, sendMessage.subject, sendMessage.bodyText, sendMessage.bodyHtml, sendMessage.priority, sendMessage.extraData);

                    phoneTextQueued = true;
                    break;
                }
            }

            transaction.OnCommit(() => {
                if (emailQueued)
                {
                    this.emailSendMessageEngine.Pulse();
                }
                if (phoneTextQueued)
                {
                    this.textSendMessageEngine.Pulse();
                }
                return(Task.FromResult(0));
            });
        }
Example #33
0
 private extern static IntPtr SendMessage(
     IntPtr hwnd,
     SendMessageType wMsg,
     IntPtr wParam,
     ref LVITEM lParam);
Example #34
0
 public extern static IntPtr SendMessage(
     IntPtr hwnd,
     SendMessageType wMsg,
     IntPtr wParam,
     IntPtr lParam);
        public static readonly TimeSpan updateStringCacheExpireInterval = new TimeSpan(0, 0, 0, 0, 500); // 500 msec

        /// <summary>
        /// 클라이언트(들)로 메세지를 전송합니다.
        /// </summary>
        /// <param name="type">전송될 Enum 타입입니다.</param>
        /// <param name="json">전송될 JSON 입니다. JSON을 감싸는 중괄호를 포함해 작성합니다.</param>
        public void SendJSON(SendMessageType type, JToken json)
        {
            core.Broadcast("/MiniParse", type.ToString(), json);
        }
    public void SendMessage(SendMessageType message)
    {
        string msg = "{\"messageType\" : \"" + message.ToString() + "\", \"messageArgs\" : {}}";

        server.WebSocketServices.Broadcast(msg);
    }