public async Task Click2(SocketReaction reaction, IUserMessage msg) { string emote = reaction.Emote.ToString(); if (emote == help) { await AllHelp(reaction, msg); } else if (type != MsgType.SpecSelection && ArrayM.IsInArray(emote, specs)) { await player.Specialization.MainMenu(player, reaction.Channel); } else if (options.Contains(emote)) { string function = type.ToString(); try { await reflectionCache.Run <Task>(function, this, reaction, msg); } catch (Exception e) { if (!await NeitsilliaError.SpecialExceptions(e, reaction.Channel, player)) { ReactionHandler.LogReactionError(this, e, reaction.Emote, msg.Channel); } } } }
public XElement BuildXML(QuickFix.Message msg, MsgType msgType, DateTime? logTimeStamp = null, string origChkSum = null) { //Debug.WriteLine(" ~~~> " + msg.GetType().ToString()); SessionID sessionID = msg.GetSessionID(msg); FIXClassInfo fixClass = null; if (msg.GetType() == typeof(QuickFix.Message)) { var classes = fixClasses[msgType.ToString(), Utils.NormalizeFIXNameSpace(sessionID.BeginString)]; if(classes != null && classes.Count>0) fixClass = classes[0]; } //var root = new XElement(msg.GetType().ToString()); var root = new XElement((fixClass!=null) ? fixClass.type.FullName : msg.GetType().ToString()); root.Add(new XAttribute("MessageType", msgType.ToString())); root.Add(new XAttribute("Session", sessionID.ToString())); if(logTimeStamp.HasValue) root.Add(new XAttribute("LogTimeStamp", logTimeStamp.Value)); var header = new XElement(msg.Header.GetType().ToString()); ProcessFieldMapToXML(header, msg.Header); root.Add(header); var body = new XElement(msg.GetType().ToString() + ".Body"); ProcessFieldMapToXML(body, msg); root.Add(body); var trailer = new XElement(msg.Trailer.GetType().ToString()); ProcessFieldMapToXML(trailer, msg.Trailer, origChkSum); root.Add(trailer); return root; }
public static string GetMessage(MsgType msgType, string messageID) { XmlNode nodex = null; try { switch (lang) { case AppLanguage.CN: if (docCN == null) { docCN = new XmlDocument(); docCN.Load(ApplicationConfiguration.AppRoot + @"\LanguageMessage\zh-CN.xml"); } nodex = docCN.SelectSingleNode("//root/" + msgType.ToString() + "/" + messageID); break; case AppLanguage.EN: if (docEN == null) { docEN = new XmlDocument(); docEN.Load(ApplicationConfiguration.AppRoot + @"\LanguageMessage\EN.xml"); } nodex = docEN.SelectSingleNode("//root/" + msgType.ToString() + "/" + messageID); break; } } catch (Exception) { } if (nodex != null) return nodex.InnerText; return ""; }
public string LogGet(MsgType type, string hr) { if (string.IsNullOrEmpty(hr)) { hr = Environment.NewLine; } string s = ""; if (type != MsgType.SYSTEM) { lock (_lock) { var a = m_log.Where(x => x.Contains(" " + type.ToString() + ": ")).ToArray(); s = string.Join(hr, a); } } else { lock (_lock) s = string.Join(hr, m_log.ToArray()); } return(s); }
public AudioMessageBubble(FileShareMiddleController fsmc, string time, MsgType messageType) { InitializeComponent(); inPath = Path.GetFullPath(settings.Default.audioInPath); outPath = Path.GetFullPath(settings.Default.audioPath); fsmiddleController = fsmc; setControllerSubscriptions(fsmc); this.bubbleTime.Text = time; type = messageType; if (messageType.ToString() == "IN") { //incomming Message this.BackColor = inMsgColor; // this.bubbleText.ForeColor = inMsgTextColor; this.bubbleTime.ForeColor = inMsgTimeColor; } else { //outGoing this.BackColor = outMsgColor; // this.bubbleText.ForeColor = outMsgTextColor; this.bubbleTime.ForeColor = outMsgTimeColor; } }
public void ShowMessage(string msg, MsgType msgType) { string title; switch (msgType) { case MsgType.Info: title = "Bilgi"; break; case MsgType.Warning: title = "Uyarı"; break; case MsgType.Error: title = "Hata"; break; default: title = null; break; }; var script = String.Format(@"$.msgBox({{ title: '{2}', content: '{0}', type: '{1}', buttons: [{{ value: 'Ok' }}], }});", msg, msgType.ToString().ToLower(), title); ClientScript += script + "\r\n"; }
public string Serialize() { var xml = new XElement("xml", new XElement("ToUserName", ToUserName), new XElement("FromUserName", FromUserName), new XElement("CreateTime", CreateTime), new XElement("MsgType", MsgType.ToString("G")) ); var children = SerializeElements(); if (children != null) { foreach (var child in children) { // 清除没有值的 XElement child.Descendants() .Reverse() .Where(x => !x.HasElements && string.IsNullOrEmpty(x.Value)) .Remove(); if (!child.HasElements && string.IsNullOrEmpty(child.Value)) { continue; } xml.Add(child); } } return(xml.ToString(SaveOptions.DisableFormatting)); }
public FileMessageBubble(FileShareMiddleController fsmc, string time, MsgType messageType) { InitializeComponent(); fsmiddleController = fsmc; setControllerSubscriptions(fsmc); this.bubbleTime.Text = time; if (messageType.ToString() == "IN") { //incomming Message this.BackColor = inMsgColor; // this.bubbleText.ForeColor = inMsgTextColor; this.bubbleTime.ForeColor = inMsgTimeColor; } else { //outGoing this.BackColor = outMsgColor; // this.bubbleText.ForeColor = outMsgTextColor; this.bubbleTime.ForeColor = outMsgTimeColor; } }
/// <summary> /// 返回JSON格式的客服消息 /// 注意:目前微信不支持将“转发客服消息”发送为客服消息,实现ToJson是为了该系列类的一致性 /// </summary> /// <returns></returns> public override string ToJson() { if (!string.IsNullOrWhiteSpace(KfAccount)) { var customerService = new { touser = ToUserName, msgtype = MsgType.ToString("g"), TransInfo = new { KfAccount = KfAccount } }; return(JsonConvert.SerializeObject(customerService)); } else { var customerService = new { touser = ToUserName, msgtype = MsgType.ToString("g") }; return(JsonConvert.SerializeObject(customerService)); } }
/// <summary> /// 转换为 XML /// </summary> /// <returns></returns> public string ToXml() { XmlDocument doc = new XmlDocument(); XmlElement e = doc.CreateElement("TelMsg"); doc.AppendChild(e); XmlElement eFrom = doc.CreateElement("From"); eFrom.InnerText = From.ToString(); e.AppendChild(eFrom); XmlElement eTo = doc.CreateElement("To"); eTo.InnerText = To.ToString(); e.AppendChild(eTo); XmlElement eMsgType = doc.CreateElement("MsgType"); eMsgType.InnerText = MsgType.ToString(); e.AppendChild(eMsgType); XmlElement eContent = doc.CreateElement("XmlContent"); eContent.InnerXml = XmlContent; e.AppendChild(eContent); return(doc.InnerXml); }
public static DialogResult Show(string text, MsgType type, FormStartPosition startPosition = FormStartPosition.CenterParent) { using (MessageBoxEx msgBox = new MessageBoxEx(text, type.ToString(), type, startPosition)) { DialogResult rs = msgBox.ShowDialog(); return(rs); } }
public static string GetMsgType(this MsgType value) { DescriptionAttribute[] attributes = (DescriptionAttribute[])value .GetType() .GetField(value.ToString()) .GetCustomAttributes(typeof(DescriptionAttribute), false); return(attributes.Length > 0 ? attributes[0].Description : string.Empty); }
/// <summary> /// 输出信息 /// </summary> /// <param name="output"></param> public static void WriteLine(MsgType type, string output) { if (ConsoleShow == false) { return; } Console.ForegroundColor = GetConsoleColor(type, output); Console.WriteLine(@"[{0}]{1}", DateTimeOffset.Now, type.ToString() + " " + output); }
public virtual string Encode(bool pRSAEncrypt = false, string pPartnerPublicKey = null) { StringBuilder sb = new StringBuilder(); if (pRSAEncrypt) { sb.Append("RSA"); } sb.Append("{"); if (MsgType != MessageType.NONE) { sb.Append($"[MESSAGETYPE:{B64E(MsgType.ToString())}],"); } if (Username != null) { sb.Append($"[USERNAME:{B64E(Username)}],"); } if (Password != null) { if (pRSAEncrypt) { sb.Append($"[PASSWORD:{NetComUser.LocalUser.RSA.Encrypt(B64E(Password), pPartnerPublicKey)}],"); } else { sb.Append($"[PASSWORD:{B64E(Password)}],"); } } if (Instruction != null) { sb.Append($"[INSTRUCTION:{B64E(Instruction.ToString())}],"); } if (Value != null) { sb.Append($"[VALUE:{B64E(Value)}],"); } if (Parameters != null) { sb.Append($"[PARAMETERS:"); foreach (object param in Parameters) { sb.Append($"<{B64E(param.GetType().ToString())}#{B64E(param.ToString())}>|"); } sb.Append($"],"); } if (ReplyRequest != null) { sb.Append($"[REPREQ:{B64E(ReplyRequest)}],"); } sb.Append("};"); return(sb.ToString()); }
/// <summary> /// 保存消息体 /// </summary> /// <param name="title">标题</param> /// <param name="text">内容</param> /// <param name="msgType">消息类型</param> /// <param name="targetId">参数值</param> /// <returns></returns> private string SaveListBody(string title, string text, MsgType msgType, int targetId) { var url = $"https://restapi.getui.com/v1/{_appId}/save_list_body"; var authToken = GetAuthToken(); var data = new JObject(); var msgObj = new JObject(); msgObj.Add("appkey", _appKey); msgObj.Add("is_offline", true); //是否离线推送 msgObj.Add("msgtype", "transmission"); //消息应用类型,可选项:notification(点击通知打开应用模板)、link(点击通知打开网页模 var transmissionObj = new JObject(); var pushInfoObj = new JObject(); var apsObj = new JObject(); var alertObj = new JObject(); alertObj.Add("title", title); alertObj.Add("body", text); apsObj.Add("alert", alertObj); var payLoad = new JObject(); payLoad.Add("id", 1); payLoad.Add("msgType", msgType.ToString()); payLoad.Add("targetId", targetId); var contentObj = new JObject(); contentObj.Add("title", title); contentObj.Add("content", text); contentObj.Add("payload", payLoad); transmissionObj.Add("transmission_content", contentObj.ToString());//透传内容 pushInfoObj.Add("aps", apsObj); pushInfoObj.Add("payload", payLoad.ToString()); data.Add("message", msgObj); data.Add("transmission", transmissionObj); data.Add("push_info", pushInfoObj); HttpHelper httpHelper = new HttpHelper(url, "application/json"); httpHelper.RequestHeaders.Add("authtoken", authToken); string result = httpHelper.SendPost(data.ToString()); JObject json = JObject.Parse(result); string taskId = string.Empty; if (json["result"].ToString() == "ok") { taskId = json["taskid"].ToString(); } return(taskId); }
protected override string GetResponseInternal() { return(string.Format("<xml>" + Environment.NewLine + "<ToUserName><![CDATA[{0}]]></ToUserName>" + Environment.NewLine + "<FromUserName><![CDATA[{1}]]></FromUserName>" + Environment.NewLine + "<CreateTime>{2}</CreateTime>" + Environment.NewLine + "<MsgType><![CDATA[{3}]]></MsgType>" + Environment.NewLine + "<Content><![CDATA[{4}]]></Content>" + Environment.NewLine + "<MsgId>{5}</MsgId>" + Environment.NewLine + "</xml>", ToUserName, FromUserName, CreateTime, MsgType.ToString().ToLower(), Content, MsgId)); }
public void UnRegister(MsgType type) { if (handlers.ContainsKey(type)) { handlers.Remove(type); } else { Log.logWarning("{0}类型的消息未注册!!", type.ToString()); } }
public override string ToString() { string s = hitTime.ToLongTimeString() + "." + hitTime.Millisecond + ", " + type.ToString() + ", "; switch (type) { case MsgType.REGISTER: s += name; break; } return(s); }
/// <summary> /// Prettier logging method /// </summary> /// <param name="msg">The message</param> /// <param name="msgType">Message type or severity</param> /// <param name="logToFile">Log to file as well.</param> public static void Log(string msg, MsgType msgType = MsgType.info, bool logToFile = true) { ConsoleColor fgcolor = ConsoleColor.White; string theTime = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss"); if (msgType == MsgType.error) { fgcolor = ConsoleColor.Red; } else if (msgType == MsgType.warning) { fgcolor = ConsoleColor.Yellow; } if (logToFile) { File.AppendAllText(LOG_FILE, theTime + " [" + msgType.ToString() + "] :: " + msg + Environment.NewLine); } Console.ForegroundColor = fgcolor; Console.WriteLine(theTime + " [" + msgType.ToString() + "] :: " + msg); Console.ResetColor(); }
/// <summary> /// 返回JSON格式的客服消息 /// </summary> /// <returns></returns> public override string ToJson() { var customerService = new { touser = ToUserName, msgtype = MsgType.ToString("g"), text = new { content = Content } }; return(JsonConvert.SerializeObject(customerService)); }
/// <summary> /// 返回JSON格式的客服消息 /// </summary> /// <returns></returns> public override string ToJson() { var customerService = new { touser = ToUserName, msgtype = MsgType.ToString("g"), image = new { media_id = MediaId } }; return(JsonConvert.SerializeObject(customerService)); }
private void playButton_Click(object sender, EventArgs e) { string path = settings.Default.audioPath + "\\" + fileName; if (type.ToString() == "IN") { path = Path.GetFullPath(filePath); } var player = new System.Media.SoundPlayer(path); player.Play(); }
/// <summary> /// Writes the class fields. /// </summary> /// <param name="writer">The writer to which to write</param> public override void Write(IDataWriter writer) { writer.WriteString(GroupName); writer.WriteString(OperatorName); writer.WriteString(Source); writer.WriteString(Destination); writer.WriteInt32(Data.Length); writer.WriteString(MsgType.ToString()); foreach (var data in Data) { _codec.Write(data, writer); } }
static internal string HTMLMessage(string message, MsgType icon) { StringBuilder myHTML = new StringBuilder(); string css = "Msg" + icon.ToString("G"); myHTML.Append("<div id=\"Msg\" class=\"Msg bg").Append(css).Append("\">"); if (icon != MsgType.x) { myHTML.Append("<div class=\"Ico ").Append(css).Append("\"> </div>"); } myHTML.Append(message.Replace("\n", tag_BR)); //leave < and > myHTML.Append("</div><div class=\"clear\"></div>"); return(myHTML.ToString()); }
// for debug only public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append(id.ToString()).Append(" "); foreach (Field f in fields) { if (f == null) { continue; } sb.Append(f.ToString()); sb.Append(" ~ "); } return(sb.ToString()); }
public void Register(MsgType type, Action <Socket, DataPack <NormalProtocol> > func) { if (!initOK) { Common.Log.logError("HandlerCenter 消息处理中心为初始化 或者 初始化失败!!\t注册失败"); return; } if (handlers.ContainsKey(type)) { Common.Log.logWarning("{0}类型的消息回调已经注册", type.ToString()); } else { handlers.Add(type, func); } }
public MessageRecord(MessageHolder messageHolder) { MsgText = messageHolder.Message.ToString().Replace(QuickFix.Message.SOH, " "); Direction = messageHolder.IsIncoming ? "IN" : "OUT"; Timestamp = messageHolder.Message.Header.GetDateTime(QuickFix.Fields.Tags.SendingTime); MsgType msgType = new MsgType(); messageHolder.Message.Header.GetField(msgType); _msgType = msgType.ToString(); string name = messageHolder.Message.GetType().ToString(); int index = name.LastIndexOf('.'); _msgName = name.Substring(index + 1); }
/// <summary> /// 返回JSON格式的客服消息 /// </summary> /// <returns></returns> public override string ToJson() { var customerService = new { touser = ToUserName, msgtype = MsgType.ToString("g"), voice = new { media_id = MediaId, title = Title, description = Description } }; return(JsonConvert.SerializeObject(customerService)); }
/// <summary> /// 返回JSON格式的客服消息 /// </summary> /// <returns></returns> public override string ToJson() { var customerService = new { touser = ToUserName, msgtype = MsgType.ToString("g"), music = new { title = Title, description = Description, musicurl = MusicUrl, hqmusicurl = HQMusicUrl, thumb_media_id = ThumbMediaId } }; return(JsonConvert.SerializeObject(customerService)); }
public void toAdmin(Message message, SessionID sessionID) { // This is only for the TT dev environment. The production FIX Adapter does not require a password MsgType msgType = new MsgType(); message.getHeader().getField(msgType); TargetCompID targetCompID = new TargetCompID(); message.getHeader().getField(targetCompID); if (msgType.ToString() == MsgType.Logon && (targetCompID.ToString() == "TTDEV9P" || targetCompID.ToString() == "TTDEV9O")) { const string password = "******"; RawData rawData = new RawData(password); message.getHeader().setField(rawData); } // End TT Dev environment case }
public static bool Log(string FilePath, MsgType type, string message) { string formatted = "L "; bool time, msgtype, name, text; time = msgtype = name = text = false; foreach (KeyValuePair <string, int> item in dictionary) { if (item.Value != 1) { continue; } if (item.Key == "Time" && !time) { formatted += DateTime.Now + " "; } else if (item.Key == "MsgType" && !msgtype) { formatted += $"[{type.ToString()}] "; } else if (item.Key == "UserName" && !name) { formatted += $"{Environment.UserName} "; } else if (item.Key == "Text" && !text) { formatted += $": {message}"; } } if (formatted.Length < 5) { return(false); } using (FileStream fs = new FileStream("LogFile.log", FileMode.Append)) { using (StreamWriter sr = new StreamWriter(fs, Encoding.Unicode)) { sr.WriteLine(formatted); } } return(true); }
/// <summary> /// Writes the class fields. /// </summary> /// <param name="writer">The writer to which to write</param> /// <param name="token">The cancellation token</param> public override async System.Threading.Tasks.Task WriteAsync(IDataWriter writer, CancellationToken token) { await writer.WriteStringAsync(GroupName, token); await writer.WriteStringAsync(OperatorName, token); await writer.WriteStringAsync(Source, token); await writer.WriteStringAsync(Destination, token); await writer.WriteInt32Async(Data.Length, token); await writer.WriteStringAsync(MsgType.ToString(), token); foreach (var data in Data) { await _codec.WriteAsync(data, writer, token); } }
public BubbleMessage(string message, string time, MsgType messageType) { InitializeComponent(); this.labelMessage.Text = message; this.labelTime.Text = time; if (messageType.ToString() == "In") { // incoming message this.BackColor = Color.FromKnownColor(KnownColor.White); this.labelMessage.ForeColor = Color.FromKnownColor(KnownColor.Black); } else { // outgoing message } SetBubbleHeight(); }
/// <summary> /// 发送待办(默认消息需要公司ID) /// </summary> /// <param name="UserAndForm">接收用户与FormID</param> /// <param name="SystemCode">系统代号</param> /// <param name="ModelCode">模块代号</param> /// <param name="strCompanyID">公司ID</param> /// <param name="strXml">业务数据XML</param> /// <param name="msgType">消息类型</param> public void ApplicationEngineTrigger(List<CustomUserMsg> UserAndForm, string SystemCode, string ModelCode, string strCompanyID, string strXml, MsgType msgType) { string ss = ""; foreach (CustomUserMsg list in UserAndForm) { ss += "FormID:" + list.FormID + "UserID:" + list.UserID; } Record.WriteLogFunction("ApplicationEngineTrigger()UserAndForm:" + ss + "SystemCode:" + SystemCode + "ModelCode:" + ModelCode + "strCompanyID:" + strCompanyID + "strXml:" + strXml + "msgType:" + msgType.ToString() + ""); EngineServicesBLL bll = new EngineServicesBLL(); bll.ApplicationEngineTrigger(UserAndForm, SystemCode, ModelCode, strCompanyID, strXml, msgType); }
/// <summary> /// 发送待办(根据生成的待办提醒消息不能自定义-新增) /// </summary> /// <param name="UserAndForm">用户ID和FORMID</param> /// <param name="SystemCode">系统代码</param> /// <param name="ModelCode">模块代码</param> /// <param name="strXml">将业务数据XM</param> /// <param name="msgType">消息类型: Msg消息 ; Task代办任务; Cancel撤消 </param> /// <param name="messageBody">用户自定义的消息实体,由业务系统确定,不再用数据库表的默认消息</param> public void ApplicationMsgTriggerCustom(List<CustomUserMsg> UserAndForm, string SystemCode, string ModelCode, string strXml, MsgType msgType, string messageBody) { string ss = ""; foreach (CustomUserMsg list in UserAndForm) { ss += "FormID:" + list.FormID + "UserID:" + list.UserID; } Tracer.Debug("ApplicationMsgTriggerCustom()UserAndForm:" + ss + "SystemCode:" + SystemCode + "ModelCode:" + ModelCode + "strXml:" + strXml + "msgType:" + msgType.ToString() + ""); EngineServicesBLL bll = new EngineServicesBLL(); bll.ApplicationMsgTriggerCustom(UserAndForm, SystemCode, ModelCode, strXml, msgType, messageBody); }
/// <summary> /// 输出消息 /// </summary> /// <param name="msgType"></param> /// <param name="msg"></param> /// <param name="args"></param> public static void OutPutMsg(MsgType msgType, string msg, params object[] args) { var msgTxt = string.Format(string.Concat("[", msgType.ToString(), "][", DateTime.Now, "]", msg), args); Console.Out.WriteLine(msgTxt); var logFile = string.Concat(msgType.ToString(), "_", DateTime.Now.ToString("yyyyMMddHHmm"), ".log"); WriteLog(logFile, msgTxt); }
public AjaxMessge Set(MsgType msgtype, string message) { code = msgtype.ToString().ToLower(); text = message; return this; }
public static Dictionary<string, string> GetMessageList(AppLanguage Language, MsgType msgType) { XmlNode nodex = null; Dictionary<string, string> dic = new Dictionary<string, string>(); switch (Language) { case AppLanguage.CN: if (docCN == null) { docCN = new XmlDocument(); docCN.Load(ApplicationConfiguration.AppRoot + @"\LanguageMessage\zh-CN.xml"); } nodex = docCN.SelectSingleNode("//root/" + msgType.ToString()); break; } if (nodex != null && nodex.ChildNodes != null) { foreach (XmlNode node in nodex.ChildNodes) { dic.Add(node.Attributes["value"].Value, node.InnerText); } } return dic; }