public ActionResult JiwangshiAdd()
        {
            var message = new Message();
            var json = new { message.MessageInfo, message.MessageStatus, message.MessageUrl };
            return Json(json, JsonRequestBehavior.AllowGet);

        }
示例#2
0
        static void Main(string[] args)
        {
            
            using (var advancedBus = RabbitHutch.CreateBus("host=localhost").Advanced)
            {
                var exchange = advancedBus.ExchangeDeclare("events", ExchangeType.Topic);
                var queue = advancedBus.QueueDeclare("clientQueueName"); // TODO: Generate unique name for clients or we might get races for events
                var binding = advancedBus.Bind(exchange, queue, "Have.Auth.*");

                advancedBus.Consume(queue, (x) => x
                    .Add<Event>((message, info) =>
                    {
                        Console.WriteLine("Got AuthResponse on Have.Auth, success: {0}", message.Body.Content.Success);
                    })
                );

                // Send request to get authentication
                var authReq = new AuthenticationRequest() {Username = "******", Password = "******"};
                var requestEvent = new Event();
                requestEvent.Type = Event.EventType.request;
                requestEvent.Content = authReq;
                var requestMessage = new Message<Event>(requestEvent);
                
                
                Console.WriteLine("Press enter to send message");
                while (true)
                {
                    Console.ReadLine();
                    advancedBus.Publish(exchange, "Need.Auth.v1", false, false, requestMessage);
                }
            }
            
        }
示例#3
0
 public void DisplayMessage(string text, MessageType type)
 {
     var message = new Message();
     message.Text = text;
     message.Type = type;
     TempData["DisplayMessage"] = message;
 }
        public ActionResult Create(CustomerAddViewModel model)
        {
            try
            {
                CustomerDto dto = new CustomerDto();

                dto.CustomerName = model.CustomerName;
                dto.CustomerNumber = model.CustomerNumber;
                dto.CustomerSex = CommonTools.GetSexByVerify(model.CustomerNumber);
                dto.CustomerBirthday = DateTime.Parse(CommonTools.GetBirthdyByVerify(model.CustomerNumber));

                string JsonString = JsonHelper.JsonSerializerBySingleData(dto);
                Message msg = CMSService.Insert("Customer", JsonString);
                return RedirectTo("/Customer/Index?category=全部&guidang=0", msg.MessageInfo);
            }
            catch
            {
                Message msg = new Message();
                msg.MessageStatus = "Error";
                msg.MessageInfo = "操作出错了";
                ViewBag.Status = msg.MessageStatus;
                ViewBag.msg = msg.MessageInfo;
                return View();
            }
        }
示例#5
0
        public ActionResult Create(UserAddViewModel model)
        {
            try
            {
                AddUserDto dto = new AddUserDto();

                dto.UserName = model.UserName;
                dto.UserPassword = CommonTools.ToMd5(model.UserPassword);
                dto.UserRoles = "45";
                dto.UserStatus = true;
                string userJsonString = JsonHelper.JsonSerializerBySingleData(dto);
                Message msg = CMSService.Insert("User", userJsonString);
                return RedirectTo("/User/Index", msg.MessageInfo);
            }

            catch
            {
                Message msg = new Message();
                msg.MessageStatus = "Error";
                msg.MessageInfo = "操作出错了";
                ViewBag.Status = msg.MessageStatus;
                ViewBag.msg = msg.MessageInfo;
                return View();
            }
        }
示例#6
0
文件: MainForm.cs 项目: ZAYEC77/HCI8
 private void button2_Click(object sender, EventArgs e)
 {
     Common.Message m = new Common.Message() { Text = textBox2.Text, User = textBox3.Text };
     string s = m.GetJSONString();
     client.Send(Tools.GetBytes(s));
     MyMsg(textBox2.Text);
 }
示例#7
0
        /// <summary>
        /// 解析邮件文件为邮件对象
        /// </summary>
        /// <param name="FilePath"></param>
        /// <returns></returns>
        public Message ResolveMailByLSoft(String FilePath)
        {
            Message oMsg = new Message();
            ADODB.Stream stm = null;
            //读取EML文件到CDO.MESSAGE,做分析的话,实际是用了下面的部分

            try
            {
                stm = new ADODB.Stream();
                stm.Open(System.Reflection.Missing.Value,
                ADODB.ConnectModeEnum.adModeUnknown,
                ADODB.StreamOpenOptionsEnum.adOpenStreamUnspecified, "", "");
                stm.Type = ADODB.StreamTypeEnum.adTypeBinary;//二进制方式读入

                stm.LoadFromFile(FilePath); //将EML读入数据流

                oMsg.DataSource.OpenObject(stm, "_stream"); //将EML数据流载入到CDO.Message,要做解析的话,后面就可以了。

            }
            catch (IOException)
            {

            }
            finally
            {
                stm.Close();
            }
            return oMsg;
        }
示例#8
0
        private void button2_Click(object sender, EventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.Multiselect = false;
            if (dialog.ShowDialog().Equals(DialogResult.OK))
            {
                try
                {
                    string filename = dialog.FileName;
                    byte[] file     = File.ReadAllBytes(filename);
                    var    ans      = MessageBox.Show("Add the file " + Path.GetFileName(filename) + " to be sent", "Confirm", MessageBoxButtons.YesNo);
                    if (ans == DialogResult.Yes)
                    {
                        Task t = Task.Factory.StartNew(() => {
                            Message message = new Message(ClientApp.GetLoggedUser(), "Sent file " + Path.GetFileName(filename), _chatName);
                            message.AddFile(file, Path.GetFileName(filename));
                            _chat.WriteMessage(message);
                        });
                    }
                }
                catch (Exception error)
                {
                    MessageBox.Show("Unable to upload the file", "Error", MessageBoxButtons.OK);
                    Console.WriteLine(error.Message);
                }
            }
        }
示例#9
0
        static void Main(string[] args)
        {
            var exchg = "socketIOdemo";

            Console.WriteLine("Creating factory...");
            var factory = new ConnectionFactory();

            Console.WriteLine("Creating connection...");
            factory.Protocol = Protocols.FromEnvironment();
            factory.HostName = "localhost";

            var ser = new JavaScriptSerializer();

            using (var conn = factory.CreateConnection())
            using (IModel ch = conn.CreateModel())
            {
                Console.WriteLine("Creating exchange...");
                ch.ExchangeDeclare(exchg, ExchangeType.Fanout, true);
                var props = new BasicProperties()
                {
                    ContentType = "application/json"
                };

                while (true)
                {
                    Console.Write("> ");
                    var txt=Console.ReadLine();
                    var msg = new Message{ body = txt };
                    var serMsg = ser.Serialize(msg);
                    var messageBody = Encoding.UTF8.GetBytes(serMsg);
                    ch.BasicPublish(exchg, string.Empty, props, messageBody);                }
            }
        }
示例#10
0
        // 删除Category
        public ActionResult Delete(int id,string CategoryName)
        {
            try
            {
                CategoryDto dto = new CategoryDto();
                DataTable dt = CMSService.SelectOne("Category", "CMSCategory", "CategoryId=" + id);
                foreach (DataRow dr in dt.Rows)
                {
                    dto = CategoryMapping.getDTO(dr);
                }
                string strwhere = "CategoryParentId="+id;
                DataTable categorydt = CMSService.SelectSome("Category", "CMSCategory", strwhere);

                Message msg = new Message();
                if (categorydt.Rows.Count > 0)
                {
                    msg.MessageInfo = "此角色还有" + categorydt.Rows.Count + "条相关数据,不允许删除";
                    return RedirectTo("/Category/Index/" + dto.CategoryParentId + "?CategoryName=" + CategoryName, msg.MessageInfo);
                }
                else
                {
                    msg = CMSService.Delete("Category", "CMSCategory", "CategoryId=" + id);
                    msg.MessageInfo = "数据删除操作成功";
                    return RedirectTo("/Category/Index/" + dto.CategoryParentId + "?CategoryName=" + CategoryName, msg.MessageInfo);
                }

            }
            catch
            {
                return View();
            }
        }
示例#11
0
        public ActionResult Create(FankuiAddViewModel model)
        {
            try
            {
                FankuiDto dto = new FankuiDto();
                dto.FankuiResult = model.FankuiResult;
                dto.FankuiSource = model.FankuiSource;
                dto.FankuiDescription = model.FankuiDescription;
                dto.FankuiSendTime = System.DateTime.Now;
                dto.FankuiTime = System.DateTime.Now;
                dto.FankuiStatus = "已查看";
                dto.FankuiCustomerId = model.FankuiCustomerId;
                dto.FankuiDoctor = int.Parse(System.Web.HttpContext.Current.Request.Cookies["UserId"].Value);
                // TODO: Add insert logic here
                string JsonString = JsonHelper.JsonSerializerBySingleData(dto);
                Message msg = CMSService.Insert("Fankui", JsonString);
                return RedirectTo("/Fankui/Index/" + model.FankuiCustomerId, msg.MessageInfo);
               // return RedirectToAction("Index");
            }
            catch
            {
                Message msg = new Message();
                msg.MessageInfo = "插入操作失败了,请检查是否输入错误";

                return RedirectTo("/Fankui/Create/" + model.FankuiCustomerId, msg.MessageInfo);
            }
        }
示例#12
0
 public static Message Delete(string DtoName, string table, string strWhere)
 {
     Message msg = new Message();
     IMapping Mapping = MappingFactory.CreatMapping(DtoName);
     msg.MessageInfo = CommonDal.Delete(table, strWhere);
     return msg;
 }
示例#13
0
        public ActionResult Create(ChufangAddViewModel model)
        {
            try
            {
                ChufangDto dto = new ChufangDto();
                dto.ChufangChuzhi = model.ChufangChuzhi;
                dto.ChufangZhenduan = model.ChufangZhenduan;
                dto.ChufangYongyao=model.ChufangYongyao;
                dto.ChufangCustomerId = model.ChufangCustomerId;
                dto.ChufangTime = System.DateTime.Now;
                if (string.IsNullOrEmpty(model.ChufangImg))
                {
                    dto.ChufangImg = "";
                }
                else
                {
                dto.ChufangImg = model.ChufangImg;
                }

                dto.ChufangDoctor = int.Parse(System.Web.HttpContext.Current.Request.Cookies["UserId"].Value);
                string JsonString = JsonHelper.JsonSerializerBySingleData(dto);
                Message msg = CMSService.Insert("Chufang", JsonString);
                return RedirectTo("/Chufang/Index/" + dto.ChufangCustomerId, msg.MessageInfo);

            }
            catch
            {
                Message msg = new Message();
                msg.MessageInfo = "上传图片好像出错了";

                return RedirectTo("/Chufang/Create/" + model.ChufangCustomerId, msg.MessageInfo);
            }
        }
示例#14
0
        //
        // GET: /Role/Delete/5
        public ActionResult Delete(int id)
        {
            try{
            RoleDto dto = new RoleDto();
            DataTable dt = CMSService.SelectOne("Role", "CMSRole", "RoleId=" + id);
            foreach(DataRow dr in dt.Rows)
            {
                dto = RoleMapping.getDTO(dr);
            }
            string strwhere = "CHARINDEX('"+dto.RoleName+"', UserRoles)>0";
            DataTable userdt = CMSService.SelectSome("User", "CMSUser", strwhere);

            Message msg = new Message();
            if (userdt.Rows.Count > 0)
            {
                msg.MessageInfo = "此角色还有"+userdt.Rows.Count+"条相关数据,不允许删除";
                return RedirectTo("/Role/Index", msg.MessageInfo);
            }
            else
            {
            msg=CMSService.Delete("Role", "CMSRole", "RoleId=" + id);
            msg.MessageInfo = "数据删除操作成功" ;
            return RedirectTo("/Role/Index", msg.MessageInfo);
            }
             }
            catch
            {
                Message msg = new Message();
                msg.MessageStatus = "Error";
                msg.MessageInfo = "操作出错了";
                ViewBag.Status = msg.MessageStatus;
                ViewBag.msg = msg.MessageInfo;
                return View();
            }
        }
        public object BeforeSendRequest(ref Message request, IClientChannel channel)
        {
            Console.WriteLine( "Sending the following request: '{0}'", request.ToString());

            LogMessage("BeforeSendRequest", request);
            
            return null;
        }
        public ActionResult Messages_Destroy(Message message)
        {
            this.messageService.Delete(message.Id);

            var routeValues = this.GridRouteValues();

            return this.RedirectToAction("Index", routeValues);
        }
示例#17
0
 public void UpdateFirend(Common.Message _player)
 {
     if (_player == null)
     {
         return;
     }
     Debug.Log("receive");
     friend.SetActive(true);
     //friend.transform.position = new Vector3 (_player.position.x, _player.position.y, _player.position.z);
 }
示例#18
0
        public void DisplayMessage(CallResult result, bool mergeModelState = true)
        {
            var message = new Message();
            message.Text = result.Message;
            message.Type = result.Type;
            TempData["DisplayMessage"] = message;

            if(!result.Success && mergeModelState)
                TempData["ModelState"] = ModelState;
        }
        public string GetMessageString(Message message)
        {
            MessageBuffer buffer = message.CreateBufferedCopy(Int32.MaxValue);

            string str = ReplaceLineBreaks(buffer.CreateMessage().ToString(), "");

            buffer.Close();

            return str;
        }
示例#20
0
文件: MainForm.cs 项目: ZAYEC77/HCI8
 void ConnectClient(int clientId)
 {
     String msg = clientId.ToString();
     Common.Message m = new Common.Message() { User = "******", Text = "New user add" };
     AddToLog(m);
     foreach (Common.Message item in log)
     {
         server.SendDataToClient(clientId, Tools.GetBytes(item.GetJSONString()));
     }
     server.SendDataToAllClientExpect(clientId, Tools.GetBytes(m.GetJSONString()));
 }
示例#21
0
 public JsonResult SetModelByAjax(string table, string strwhere, string columnname, string columnvalue)
 {
     CommonBll.SetModelBitByAjax(table, strwhere, columnname, columnvalue);
     var message = new Message();
     var json = new
     {
         message.MessageInfo,
         message.MessageStatus,
         message.MessageUrl
     };
     return Json(json, JsonRequestBehavior.AllowGet);
 }
示例#22
0
 private void GvMessages_CustomRowCellEdit(object sender, CustomRowCellEditEventArgs e)
 {
     Common.Message m = (Common.Message)gvMessages.GetRow(e.RowHandle);
     if (m != null && m.Type == MessageType.Photo)
     {
         e.RepositoryItem = riPictureEdit;
     }
     else
     {
         e.RepositoryItem = riMemoEdit;
     }
 }
        private static void SendAuthResponse(IAdvancedBus advancedBus, IExchange exchange)
        {
            // Send auth success
            // TODO: Check the actual authentication stuff
            var responseEvent = new Event();
            responseEvent.Type = Event.EventType.response;
            var response = new AuthenticationResponse();
            response.Success = true;
            responseEvent.Content = response;
            var responseMessage = new Message<Event>(responseEvent);

            advancedBus.Publish(exchange, "Have.Auth.v1", false, false, responseMessage);
        }
        public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
        {            
            //Console.WriteLine( "Received the following reply: '{0}'", reply.ToString());
                                 
            //MemoryStream requestStream = new MemoryStream();
            //MessageBuffer requestBuffer = request.CreateBufferedCopy(Int32.MaxValue);
            //requestBuffer.WriteMessage(requestStream);
            //byte[] requestArr = requestStream.ToArray();

            //requestBuffer.Close();

            //string requestString = request.ToString(); //System.Text.Encoding.ASCII.GetString(requestArr);

            //WriteMessageToFile("AfterReceiveRequest-Original", requestString);

            //MessageBuffer buffer = request.CreateBufferedCopy(Int32.MaxValue);


//            string modifiedRequestString = GetMessageString(request); // ReplaceLineBreaks(requestString, "");


//            WriteMessageToFile("AfterReceiveRequest-ModifiedStr", modifiedRequestString);

            //byte[] modifedRequestMessageInBytes = System.Text.Encoding.UTF8.GetBytes(modifiedRequestString);

            
            //XmlWriterSettings settings = new XmlWriterSettings();
            //settings.Encoding = System.Text.Encoding.UTF8;

            //XmlDictionaryReaderQuotas quotas = new XmlDictionaryReaderQuotas();

            //XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(modifedRequestMessageInBytes, quotas);

            //Message newRequestMessage = Message.CreateMessage(reader, 2147483647, request.Version);

            //MessageBuffer modifiedRequestBuffer = newRequestMessage.CreateBufferedCopy(Int32.MaxValue);

//            request = ReplaceMessageString(request, modifiedRequestString); //modifiedRequestBuffer.CreateMessage();

            //MessageBuffer nbuffer = requestCopy.CreateBufferedCopy(Int32.MaxValue);

            //WriteMessageToFile("AfterReceiveRequest-Original", nbuffer.ToString());

            //buffer.Close();

            LogMessage("AfterReceiveRequest-ModifiedMsg", request);

            //modifiedRequestBuffer.Close();

            return null;
        }
示例#25
0
        public JsonResult updateCusField()
        {
            Message msg = new Message();
               string DtoName = Request.Params["DtoName"];
               string table = Request.Params["table"];
               string strWhere = Request.Params["strWhere"];
               string columnname = Request.Params["columnname"];
               string columnvalue = Request.Params["columnvalue"];
               if (columnname != "CustomerTelephone" && columnname != "CustomerEmail" && columnname != "CustomerLianxirenTel")
               {
               msg = CMSService.UpdateFieldOneByOne(DtoName, table, strWhere, columnname, columnvalue);
               msg.MessageStatus = "true";

               }

               else
               {
               if (columnname == "CustomerTelephone" || columnname == "CustomerLianxirenTel")
               {
               if (CommonValidate.IsTelephone(columnvalue))
               {
                   msg = CMSService.UpdateFieldOneByOne(DtoName, table, strWhere, columnname, columnvalue);
                   msg.MessageStatus = "true";
               }
               else
               {
                   msg.MessageStatus = "false";
                   msg.MessageInfo = "手机格式不正确";
               }
               }
               if (columnname == "CustomerEmail")
               {
                   if (CommonValidate.IsEmail(columnvalue))
                   {
                       msg = CMSService.UpdateFieldOneByOne(DtoName, table, strWhere, columnname, columnvalue);
                       msg.MessageStatus = "true";

                   }
                   else
                   {
                       msg.MessageStatus = "false";
                       msg.MessageInfo = "邮箱格式不正确";
                   }
               }

               }

               var result = msg;

               return Json(result, JsonRequestBehavior.AllowGet);
        }
示例#26
0
        public static Message Update(string DtoName, string JsonString)
        {
            Message msg = new Message();
            SqlParameter[] arParames = null;
            string StoredProcedure = "";

            IMapping Mapping = MappingFactory.CreatMapping(DtoName);

            arParames = Mapping.JsonStringToSqlParameter(JsonString);
            StoredProcedure = Mapping.GetStoredProcedure("Update");
            msg.MessageInfo = CommonDal.Update(arParames, StoredProcedure);

            return msg;
        }
        void WriteMessageToLog(string methodName, Message msg)
        {
            CustomTextTraceSource ts = new CustomTextTraceSource("WebServiceProvider.WspServiceAuthorizationManager." + methodName,
                "MyTraceSource", SourceLevels.Information);

            if (msg != null)
            {
                ts.TraceInformation("Message:");
                ts.TraceInformation(msg.ToString());
            }
            else
            {
                ts.TraceInformation("Message == NULL");
            }
        }
        void LogMessage(string methodName, Message msg)
        {
            CustomTextTraceSource ts = new CustomTextTraceSource("Common.CustomMessageInspector." + methodName,
                "MyTraceSource", SourceLevels.Information);

            if (msg != null)
            {
                ts.TraceInformation("Message:");
                ts.TraceInformation(msg.ToString());
            }
            else
            {
                ts.TraceInformation("Message is NULL");
            }
        }
        public JsonResult Logon(string username, string password)
        {
            string table = "QxsqEditor";
            string strwhere = "EditorUsername='******' and EditorPassword='******'";

                EditorDto editorDto = EditorBll.GetOneEditorDto(table, strwhere);

                if (String.IsNullOrEmpty(editorDto.EditorUserName))
                {
                    var message = new Message();
                    message.MessageInfo = "用户名或密码错误";
                    message.MessageStatus = "0";
                    message.MessageUrl = "";
                    var json = new { message.MessageInfo, message.MessageStatus, message.MessageUrl };
                    return Json(json, JsonRequestBehavior.AllowGet);

                }
                else
                {
                    var message = new Message();
                    message.MessageInfo = "登录成功";
                    message.MessageStatus = "1";
                    message.MessageUrl = "";

                    var json = new { message.MessageInfo, message.MessageStatus, message.MessageUrl };
                    CommonBll.SetSessions(editorDto);

                    HttpCookie cookie = new HttpCookie("Editor");
                    cookie.Value = username;
                    System.Web.HttpContext.Current.Response.Cookies.Add(cookie);

                   // HttpCookie cookieRealName = new HttpCookie("EditorRealName");
                   // cookieRealName.Value = editorDto.EditorRealName;
                  //  System.Web.HttpContext.Current.Response.Cookies.Add(cookieRealName);

                    //cookie["ManagerName"] = username;
                    // cookie["ManagerRole"] = managerDto.ManagerRole;

                   // var cookie = new HttpCookie("Editor", "Success");
                   // var cookieId = new HttpCookie("EditorId", editorDto.EditorId.ToString());
                   // var cookieUserName = new HttpCookie("EditorUserName", editorDto.EditorUserName.ToString());
                   // var cookieRealName = new HttpCookie("EditorRealName", editorDto.EditorRealName.ToString());
                   // System.Web.HttpContext.Current.Response.SetCookie(cookie);
                   // System.Web.HttpContext.Current.Response.SetCookie(cookieId);

                    return Json(json, JsonRequestBehavior.AllowGet);
                }
        }
        public Message ReplaceMessageString(Message oldMessage, string to)
        {
            MemoryStream ms = new MemoryStream();
            XmlWriter xw = XmlWriter.Create(ms);
            oldMessage.WriteMessage(xw);
            xw.Flush();
            string body = Encoding.UTF8.GetString(ms.ToArray());
            xw.Close();

            body = to;

            ms = new MemoryStream(Encoding.UTF8.GetBytes(body));
            XmlDictionaryReader xdr = XmlDictionaryReader.CreateTextReader(ms, new XmlDictionaryReaderQuotas());
            Message newMessage = Message.CreateMessage(xdr, int.MaxValue, oldMessage.Version);
            newMessage.Properties.CopyProperties(oldMessage.Properties);
            return newMessage;
        }
示例#31
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting TestSocketIOClient Example...");

            var socket = new Client("http://192.168.80.1:3000/"); // url to nodejs
            socket.Opened += (a, b) => { Console.WriteLine("Opened"); };
            socket.Message += (a, b) => { Console.WriteLine("Message"); };
            socket.SocketConnectionClosed +=  (a, b) => { Console.WriteLine("SocketConnectionClosed"); };
            socket.Error +=  (a, b) => { Console.WriteLine("Error"); };

            // register for 'connect' event with io server
            socket.On("connect", (fn) =>
            {
                Console.WriteLine("socket.On(connect)");
                // emit Json Serializable object, anonymous types, or strings
                var msg = new Message() { body = "Hello world!" };
                socket.Emit("msg", msg);
            });

            // register for 'update' events - message is a json 'Part' object
            socket.On("msg", (data) =>
            {
                //Console.WriteLine("recv [socket].[update] event");
                //Console.WriteLine("  raw message:      {0}", data.RawMessage);
                //Console.WriteLine("  string message:   {0}", data.MessageText);
                //Console.WriteLine("  json data string: {0}", data.Json.ToJsonString());
                //Console.WriteLine("  json raw:         {0}", data.Json.Args[0]);

                // cast message as Part - use type cast helper
                var msg = data.Json.GetFirstArgAs<Message>();
                Console.WriteLine(">> {0}", msg.body);
            });

            // make the socket.io connection
            socket.Connect();

            while (true) {
                Console.Write("> ");
                var txt = Console.ReadLine();
                var msg = new Message { body = txt };

                socket.Emit("msg", msg);
            }
        }
示例#32
0
        private void sendButton_Click(object sender, EventArgs e)
        {
            char[] charsToTrim = { ' ' };
            string test        = inputMessage.Text.Trim(charsToTrim);

            if (!test.Equals(""))
            {
                Message m = new Message(ClientApp.GetLoggedUser(), inputMessage.Text, _chatName);
                _messages.Add(m);

                Thread t = new Thread(() =>
                {
                    _chat.WriteMessage(m);
                });
                t.Start();

                inputMessage.Text = "";
            }
        }
示例#33
0
 public void Message(string text, List <User> users)
 {
     if (Settings.CurrentUser != null)
     {
         Message msg = new Common.Message()
         {
             Sender = Settings.CurrentUser, UserList = users, Text = text
         };
         DataPackage cmd = new DataPackage()
         {
             Type = PackageTypeEnum.Message, Content = msg
         };
         Communication.Send(cmd);
     }
     else
     {
         Console.WriteLine("Sorry, You are not logged...");
     }
 }
示例#34
0
        private static void Send(object startParam)
        {
            var message = new Message
            {
                Title = "title",
                Body = "Body"
            };

            using (var sender = new Producer<Message>("localhost", string.Empty, "add", routing))
            {
                var token = (CancellationToken)startParam;
                var random = new Random(DateTime.Now.Millisecond);
                while (!token.IsCancellationRequested)
                {
                    message.Complexity = random.Next(10);
                    sender.Send(message);
                    Thread.Sleep(1000);
                }
            }
        }
示例#35
0
        /// <summary>
        ///  Transmits a message
        /// </summary>
        /// <param name="msg"></param>
        public void Tx(Message msg)
        {
            // Serialize to a json message
            string data = JsonConvert.SerializeObject(msg, Formatting.None);

            try
            {
                // Send the message and terminate it with an 0x02
                _socket.Send(Encoding.UTF8.GetBytes(data));
                _socket.Send(new byte[] { 0x02 });
            }
            catch (SocketException)
            {
                OnDisconnected();
            }
            catch (ObjectDisposedException)
            {
                OnDisconnected();
            }
        }
示例#36
0
        void InsertMessage(Message m)
        {
            string dateTime = m.MessageDate.ToString("g", CultureInfo.CreateSpecificCulture("fr-FR"));


            if (m.GetFiles().Count > 0)
            {
                for (int i = 0; i < m.GetFiles().Count; i++)
                {
                    ListViewItem s = new ListViewItem();
                    s.Text = m.GetFilesName()[i];
                    files.Add(m.GetFiles()[i]);
                    filesShared.Items.Add(s);
                }
            }
            string message = "";

            if (m.MessageSent == null)
            {
                return;
            }

            if (m.Sender.Username == ClientApp.GetLoggedUser().Username)
            {
                chatMessages.SelectionAlignment = HorizontalAlignment.Right;
                message += m.Sender.Username + " (Me)";
            }
            else
            {
                chatMessages.SelectionAlignment = HorizontalAlignment.Left;
                message += m.Sender.Username;
            }

            message += " - " + dateTime + Environment.NewLine + m.MessageSent + Environment.NewLine + Environment.NewLine;

            chatMessages.SelectionFont = new Font(chatMessages.Font, FontStyle.Regular);
            chatMessages.AppendText(message);
        }
示例#37
0
        //void TileView_ItemCustomize(object sender, DevExpress.XtraGrid.Views.Tile.TileViewItemCustomizeEventArgs e)
        //{
        //    if ((bool)this.tileView.GetRowCellValue(e.RowHandle, "LoggedIn"))
        //    {
        //        e.Item.Elements[2].Image = icLogStates.Images[0];
        //        e.Item.Elements[2].Text = string.Empty;
        //    }
        //    else
        //    {
        //        e.Item.Elements[2].Image = icLogStates.Images[1];
        //        e.Item.Elements[2].Text = string.Empty;
        //    }

        //    int ndx = (int)this.tileView.GetRowCellValue(e.RowHandle, "Avatar");
        //    e.Item.Elements[3].Image = icAvatars.Images[ndx];
        //    e.Item.Elements[3].Text = string.Empty;
        //}

        private void GvMessages_RowCellStyle(object sender, RowCellStyleEventArgs e)
        {
            Common.Message m = (Common.Message)gvMessages.GetRow(e.RowHandle);
            if (m != null)
            {
                switch (m.Type)
                {
                case MessageType.Message:
                    e.Appearance.FontStyleDelta = FontStyle.Bold;
                    break;

                case MessageType.Info:
                    e.Appearance.FontStyleDelta = FontStyle.Regular;
                    break;

                case MessageType.Photo:
                    e.Appearance.FontStyleDelta = FontStyle.Regular;
                    break;

                case MessageType.Sound:
                    e.Appearance.FontStyleDelta = FontStyle.Regular;
                    break;
                }

                e.Appearance.ForeColor = m.Color;

                if (m.Sender == clientId)
                {
                    e.Appearance.TextOptions.HAlignment = HorzAlignment.Far;
                }
                else
                {
                    e.Appearance.TextOptions.HAlignment = HorzAlignment.Near;
                }
            }
        }