public DataContractSerializerOperationFormatter(OperationDescription description, DataContractFormatAttribute dataContractFormatAttribute, DataContractSerializerOperationBehavior serializerFactory) : base(description, dataContractFormatAttribute.Style == OperationFormatStyle.Rpc, false)
 {
     if (description == null)
     {
         throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("description");
     }
     this.serializerFactory = serializerFactory ?? new DataContractSerializerOperationBehavior(description);
     foreach (System.Type type in description.KnownTypes)
     {
         if (this.knownTypes == null)
         {
             this.knownTypes = new List<System.Type>();
         }
         if (type == null)
         {
             throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxKnownTypeNull", new object[] { description.Name })));
         }
         this.ValidateDataContractType(type);
         this.knownTypes.Add(type);
     }
     this.requestMessageInfo = this.CreateMessageInfo(dataContractFormatAttribute, base.RequestDescription, this.serializerFactory);
     if (base.ReplyDescription != null)
     {
         this.replyMessageInfo = this.CreateMessageInfo(dataContractFormatAttribute, base.ReplyDescription, this.serializerFactory);
     }
 }
 public XmlSerializerOperationFormatter(OperationDescription description, XmlSerializerFormatAttribute xmlSerializerFormatAttribute,
     MessageInfo requestMessageInfo, MessageInfo replyMessageInfo) :
     base(description, xmlSerializerFormatAttribute.Style == OperationFormatStyle.Rpc, false/*isEncoded*/)
 {
     _requestMessageInfo = requestMessageInfo;
     _replyMessageInfo = replyMessageInfo;
 }
        public string PermanentlyDeleteMessage(Stream message)
        {
            try
            {

                MessageBox objInput = JSonHelper.JsonDeserialize<MessageBox>(new StreamReader(message).ReadToEnd());
                if (System.Configuration.ConfigurationManager.AppSettings[objInput.Pin] == null)
                {
                    return "Invalid PIN";
                }
                if (objInput.Pin != null && objInput.Pin.Length > 0)
                {
                    MessageBox obj2 = new MessageBox();
                    List<MessageInfo> objcol = new List<MessageInfo>();
                    MessageInfo obj = new MessageInfo();
                    MessageBLL objbll = new MessageBLL();

                    obj.MessageComposeId = objInput.MessageComposeId;
                    obj.Pin = System.Configuration.ConfigurationManager.AppSettings[objInput.Pin].ToString();
                    int i = objbll.DeleteMessages_DeletedItems(obj);
                    if (i > 0)
                        return "Delete sucessful";
                    else
                        return "Delete Unsucessful";
                }
                else
                {
                    return "Pin is a required field";
                }
            }
            catch (Exception ex)
            {
                return "Unable to delete. Please try again later";
            }
        }
 public void Callback(MessageInfo message)
 {
     //Note: This is for demo purposes only.
     //Note: It is not a good practice to call MessageBox.Show from a non-View class.
     //Note: Consider implementing a MessageBoxService.
     MessageBox.Show(message.Message, message.Title, MessageBoxButton.OK);
 }
Beispiel #5
0
 IEnumerator CreateTextDisplay(MessageInfo info)
 {
     textField.text = info.message;
     textField.color = info.color;
     yield return new WaitForSeconds(textTime);
     textField.text = "";
     yield break;
 }
Beispiel #6
0
 public Trigger(MessageInfo msg, TriggerType type)
 {
     this.OnlyOneUse = false;
     this.RunOnReceivedMsg = false;
     this.Conditions = new List<Condition>();
     this.Message = msg;
     this.Type = type;
 }
 public XmlSerializerOperationFormatter(OperationDescription description, XmlSerializerFormatAttribute xmlSerializerFormatAttribute, MessageInfo requestMessageInfo, MessageInfo replyMessageInfo) : base(description, xmlSerializerFormatAttribute.Style == OperationFormatStyle.Rpc, xmlSerializerFormatAttribute.IsEncoded)
 {
     if (xmlSerializerFormatAttribute.IsEncoded && (xmlSerializerFormatAttribute.Style != OperationFormatStyle.Rpc))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxDocEncodedNotSupported", new object[] { description.Name })));
     }
     this.isEncoded = xmlSerializerFormatAttribute.IsEncoded;
     this.requestMessageInfo = requestMessageInfo;
     this.replyMessageInfo = replyMessageInfo;
 }
 /// <summary>
 /// メッセージを連続送信。
 /// </summary>
 /// <param name="windowHandle">ウィンドウハンドル。</param>
 /// <param name="info">メッセージ情報。</param>
 public static void SendMessage(IntPtr windowHandle, MessageInfo[] info)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     for (int i = 0; i < info.Length; i++)
     {
         NativeMethods.SendMessage(windowHandle, info[i].Message, info[i].WParam, info[i].LParam);
     }
 }
 public IEnumerable<ISubscription> Shape(IEnumerable<ISubscription> subscriptions, object message)
 {
     var info = new MessageInfo(message);
     var resultingSubscriptions = subscriptions;
     for (int i = _shapeProviders.Count - 1; i >= 0; i--) //Backwards as we keep the default at index 0
     {
         if (!_shapeProviders[i].Handles(info))
             continue;
         resultingSubscriptions = _shapeProviders[i].Enhance(subscriptions);
         break;
     }
     return resultingSubscriptions;
 }
        protected override void Arrange()
        {
            Cleanup();

            _queueService = new QueueService();
            _queuePath = QueueTestHelper.CreateQueuePathForPrivateQueue(ComputerName, TestQueueName, _isTransactional);
            _queueService.CreateQueue(_queuePath, _isTransactional);

            _queueService.CreateMessage(_queuePath, new TestClass1 { StringValue1 = "Should not be deleted" }, TestMessagesLabelForMessageWhichShouldNotBeDeleted);

            _messageData = new TestClass1 { IntValue1 = 1, StringValue1 = "string1" };
            _queueService.CreateMessage(_queuePath, _messageData, TestMessagesLabel);
            
            _messageToDelete = _queueService.GetMessageInfos(_queuePath, TestMessagesLabel).Single();
        }
Beispiel #11
0
 internal static IEnumerable<Task> GetTasks()
 {
     IList<Task> tasks = new List<Task>();
     tasks.Add(new StartProcess("http://www.google.it"));
     Task task = new MessageInfo("Periodioco 30s", Task.TaskType.Periodic);
     task.Delay=new TimeSpan(0,0,0,30);
     tasks.Add(task);
     task = new MessageInfo("Delayed 10 s ", Task.TaskType.Delayed);
     task.Delay=new TimeSpan(0,0,0,10);
     tasks.Add(task);
     task = new MessageInfo("Periodic 60s",Task.TaskType.Periodic);
     task.Delay=new TimeSpan(0,0,1,0);
     tasks.Add(task);
     return tasks;
 }
Beispiel #12
0
        public virtual bool RunTrigger(MessageInfo msg, List<MessageInfo> Received, bool triggerFired)
        {
            if (msg == null)
                return false;

            var result = true;
            var xml = msg.xml;
            NpuToUse = msg.NPU;

            if (triggerFired && OnlyOneUse)
                return false;

            foreach (var cond in Conditions)
            {
                if (!cond.IsConditionTrue(xml))
                    result =  false;
            }

            if (!result && RunOnReceivedMsg)
            {
                foreach (var oldMsg in Received)
                {

                    var oldXml = oldMsg.xml;
                    result = true;
                    foreach (var cond in Conditions)
                    {
                        if (!cond.IsConditionTrue(oldXml))
                        {
                            result = false;
                            break;
                        }
                    }

                    if (result == true)
                    {
                        NpuToUse = oldMsg.NPU;
                        break;
                    }
                }

            }

            return result;
        }
Beispiel #13
0
 /// <summary>
 /// Converts the color of the resultant text
 /// </summary>
 /// <param name="message"></param>
 /// <param name="type"></param>
 public void ShowMessage(string message, MessageInfo type)
 {
     Label commonLabel = this.Page.Master.FindControl("CommonLabel") as Label;
     if (commonLabel != null)
     {
         switch (type)
         {
             case MessageInfo.Error:
                 commonLabel.ForeColor = Color.Red;
                 break;
             case MessageInfo.Information:
                 commonLabel.ForeColor = Color.Green;
                 commonLabel.Font.Bold = true;
                 break;
         }
         commonLabel.Text = message;
     }
 }
 private bool MSMouseMove(MessageInfo messageInfo)
 {
     return(this.m_OperationStyle > 0);
 }
Beispiel #15
0
        public ChatResult SendMessageToGroup(MessageInfo msg)
        {
            GroupInfo group = GetGroupByGroupId(msg.ReceiverId);
            string senderId = msg.SenderId;
            if (group.CustomerList.Contains(senderId))
            {
                List<string> customerConnectionIds = new List<string>();
                foreach (string customerId in group.CustomerList)
                    customerConnectionIds.AddRange(Manager.Instance.GetCustomerByCustomerId(customerId).ConnectionList);
                customerConnectionIds.Remove(Context.ConnectionId);
                Clients.Clients(customerConnectionIds).OnReceiveMessage(msg);

                ChatResult result = Manager.Instance.AddMessage(msg);
                return result;
            }
            return null;
        }
            public VideoLayerCollection[] OnPlay()
            {
                _playlistControl.LoadModelInfo();

                _playlistControl.trackBar1.PlayValue = 0;
                origPlayValue = _playlistControl.trackBar1.PlayValue;
                _playlistControl.playPanel.Visible = true;
                _msgs = new List <VideoLayerCollection>();
                foreach (PlaylistItemControl item in _playlistControl.dragDropControl.Controls)
                {
                    switch (item.PlaylistItem.Target.Type)
                    {
                    case LibraryType.Message:
                        //ProWrite.DES.DESHelper.CreateVideo(item.PlaylistItem.Target.Copy() as MessageInfo, "d:\\aaa.mpeg");
                        var msg = NewLayer(item.PlaylistItem.Target.Copy() as MessageInfo,
                                           item.PlaylistItem.Target.Length, "", true, null);
                        msg.Zoom = _playlistControl._Zoom;
                        _msgs.Add(msg);

                        //_msgs.Add(NewLayer(item.PlaylistItem.Target.Copy() as MessageInfo, item.PlaylistItem.Target.Length, "", true, null));
                        break;

                    case LibraryType.TimeSliceGroup:
                        TimeSliceGroupInfo group   = null;
                        MessageInfo        message = null;
                        group = LibraryGroup.Current.TimeSliceGroups.GetByName(item.PlaylistItem.Target.Name);
                        if (group.Items != null && group.Items.Length > 0)
                        {
                            for (int i = 0; i < group.Items.Length; i++)
                            {
                                if (group.Items[i].Name == ((TimeSliceGroupAdapterInfo)item.PlaylistItem).CurrentMessageAdapterName && group.Items[i].Target != null && group.Items[i].IsActive)
                                {
                                    message = group.Items[i].Target as MessageInfo;
                                    break;
                                }
                            }
                            if (message == null)
                            {
                                DataGate.SetPlaylistTimeSlieceGroupCurrentMessageAdapterName(_playlistControl._model, false);
                                for (int i = 0; i < group.Items.Length; i++)
                                {
                                    if (group.Items[i].Name == ((TimeSliceGroupAdapterInfo)item.PlaylistItem).CurrentMessageAdapterName && group.Items[i].Target != null && group.Items[i].IsActive)
                                    {
                                        message = group.Items[i].Target as MessageInfo;
                                        break;
                                    }
                                }
                            }
                        }

                        if (message != null)
                        {
                            _msgs.Add(NewLayer(message.Copy() as MessageInfo, group.Length, group.Name, true, LibraryType.TimeSliceGroup));
                        }
                        break;

                    case LibraryType.Playlist:
                        //add by michael 2008-12-8
                        // edit by Louis 2009-1-5
                        PlaylistInfo list = LibraryGroup.Current.Playlists.GetByName(item.PlaylistItem.Target.Name);
                        if (list != null && list.AllMessages.Length > 0)
                        {
                            _msgs.Add(NewLayer(list.AllMessages[0].Copy() as MessageInfo, list.AllMessages[0].Length, list.Name, true, LibraryType.Playlist));
                            for (int i = 1; i < list.AllMessages.Length; i++)
                            {
                                _msgs.Add(NewLayer(list.AllMessages[i].Copy() as MessageInfo, list.AllMessages[i].Length, list.Name, false, LibraryType.Playlist));
                            }
                        }
                        //foreach (MessageInfo mes in list.AllMessages)
                        //{
                        //    _msgs.Add(NewLayer(mes.Copy() as MessageInfo, mes.Length, list.Name, LibraryType.Playlist));
                        //}
                        break;
                    }
                }
                if (_msgs.Count > 0)
                {
                    _playlistControl.EnableControl(false);
                }
                return(_msgs.ToArray());
            }
Beispiel #17
0
 internal protected abstract ComponentResult OnPrepare(MessageInfo <TMessage> messageInfo, MessagingServiceBase <TMessage> service);
Beispiel #18
0
        /// <summary>
        ///     TestStepBase.Execute() implementation
        /// </summary>
        /// <param name='context'>The context for the test, this holds state that is passed beteen tests</param>
        public override void Execute(Context context)
        {
            if (DocSpecs.Count > 0)
            {
                var ds = new List <Type>(DocSpecs.Count);
                foreach (var docSpec in DocSpecs)
                {
                    var ass = AssemblyHelper.LoadAssembly(docSpec.AssemblyPath);
                    context.LogInfo("Loading DocumentSpec {0} from location {1}.", docSpec.TypeName, ass.Location);
                    var type = ass.GetType(docSpec.TypeName);

                    ds.Add(type);
                }
                _docSpecs = ds.ToArray();
            }

            context.LogInfo("Loading pipeline {0} from location {1}.", PipelineTypeName, PipelineAssemblyPath);
            var pipelineType = ObjectCreator.GetType(PipelineTypeName, PipelineAssemblyPath);

            var pipelineWrapper = PipelineFactory.CreateReceivePipeline(pipelineType);

            if (!string.IsNullOrEmpty(InstanceConfigFile))
            {
                pipelineWrapper.ApplyInstanceConfig(InstanceConfigFile);
            }

            if (null != _docSpecs)
            {
                foreach (var docSpec in _docSpecs)
                {
                    pipelineWrapper.AddDocSpec(docSpec);
                }
            }

            MessageCollection mc = null;

            using (Stream stream = new FileStream(Source, FileMode.Open, FileAccess.Read))
            {
                var inputMessage = MessageHelper.CreateFromStream(stream);
                if (!string.IsNullOrEmpty(SourceEncoding))
                {
                    inputMessage.BodyPart.Charset = SourceEncoding;
                }

                // Load context file, add to message context.
                if (!string.IsNullOrEmpty(InputContextFile) && new FileInfo(InputContextFile).Exists)
                {
                    var mi = MessageInfo.Deserialize(InputContextFile);
                    mi.MergeIntoMessage(inputMessage);
                }

                mc = pipelineWrapper.Execute(inputMessage);
            }

            for (var count = 0; count < mc.Count; count++)
            {
                string destination = null;
                if (!string.IsNullOrEmpty(DestinationFileFormat))
                {
                    destination = string.Format(DestinationFileFormat, count);
                    if (!string.IsNullOrEmpty(DestinationDir))
                    {
                        destination = Path.Combine(DestinationDir, destination);
                    }

                    PersistMessageHelper.PersistMessage(mc[count], destination);
                }

                if (!string.IsNullOrEmpty(OutputContextFileFormat))
                {
                    var contextDestination = string.Format(OutputContextFileFormat, count);
                    if (!string.IsNullOrEmpty(DestinationDir))
                    {
                        contextDestination = Path.Combine(DestinationDir, contextDestination);
                    }

                    var mi = BizTalkMessageInfoFactory.CreateMessageInfo(mc[count], destination);
                    MessageInfo.Serialize(mi, contextDestination);
                }
            }
        }
Beispiel #19
0
        public ActionResult Create([Bind(Include = "ImageID,CompID,CardImage,Processed,Note,UserID,RoundDate,CourseID,TeeColour,SSS")] ScoreCardImage scoreCardImage)
        {
            if (ModelState.IsValid)
            {
                // Deal with uploaded Score Card Photo PENDING ******************************
                string             scorecardfileName = "";
                HttpPostedFileBase scorecard         = Request.Files["UploadScoreCard"];
                if (scorecard.FileName != "" && scoreCardImage.UserID != null)
                {
                    scorecardfileName = scoreCardImage.UserID + new FileInfo(scorecard.FileName).Name;
                    string path = Path.Combine(Server.MapPath("~/ScoreCards/Pending"), scorecardfileName);

                    //Reduce size of file if required and save in large folder
                    WebImage img = new WebImage(scorecard.InputStream);
                    if (img.Height > 1200)
                    {
                        img.Resize(1200, 1200, true);
                    }
                    img.Save(path);

                    TempData["FailUpload"]    = null;
                    TempData["SuccessUpload"] = "Score Card Image successfully Uploaded. You can edit this pending score card by selecting 'My Pending Score Cards' on the main menu ..";

                    // Save the Score Card Image
                    scoreCardImage.CardImage = "/ScoreCards/Pending/" + scorecardfileName;
                    scoreCardImage.Processed = false;
                    db.ScoreCardImages.Add(scoreCardImage);
                    db.SaveChanges();

                    // Remove the FIRST Upcoming Round Record
                    // List of Upcoming Rounds
                    int CompID       = scoreCardImage.CompID;
                    int compPlayerID = Convert.ToInt32(Session["CompPlayerID"]);
                    var FirstRnd     = (from rd in db.UpcomingRnds
                                        where rd.CompPlayerID == compPlayerID && rd.CompID == CompID
                                        orderby rd.RndDate
                                        select rd).First();

                    db.UpcomingRnds.Remove(FirstRnd);
                    db.SaveChanges();

                    // Send email to Admin to inform of new scorecard upload
                    MessageInfo messageInfo = new MessageInfo();
                    UserInfo    userInfo    = new UserInfo();

                    var AllAdmin = userInfo.GetAllAdmin();

                    string AdminEmail = "";
                    string Subject    = "";
                    string Body       = "";
                    string userName   = userInfo.GetUserName(Convert.ToInt32(scoreCardImage.UserID));

                    foreach (var item in AllAdmin)
                    {
                        // messageInfo.CreateMessage(newprofile.UserID, item.UserID, DateTime.Now, user.UserName + " has registered to join Tigerline Scores.");
                        AdminEmail = item.Email;
                        Subject    = "PLAYER SCORECARD IMAGE UPLOADED";
                        Body       = "<span style='font-family: Calibri; font-size: 24px; font-weight: bold; color: green'>TIGERLINE SCORES</span><br/><br/>";
                        Body      += "<span style='font-family: Calibri'>Player " + userName + " has uploaded a new scorecard image ..<br/><br/>";
                        Body      += "<a href='www.tigerlinescores.co.uk'>Tigerline Scores</a>";
                        messageInfo.SendEmail(AdminEmail, Subject, Body, null);
                    }

                    return(RedirectToAction("Index", "PLayerCompList"));
                }
                else
                {
                    TempData["FailUpload"]    = "Unable to upload the score card image ..";
                    TempData["SuccessUpload"] = null;
                }
            }
            return(RedirectToAction("Index", "PLayerCompList"));
        }
 public bool AddMsg(MessageInfo mi)
 {
     return(_ms.AddMessage(mi));
 }
 private bool MSMouseUp(MessageInfo messageInfo)
 {
     if (this.m_OperationStyle == 0)
     {
         IOwner pOwner = messageInfo.Sender as IOwner;
         if (pOwner != null)
         {
             MouseEventArgs mouseEventArgs = messageInfo.MessageParameter as MouseEventArgs;
             if (mouseEventArgs != null)
             {
                 this.Width += mouseEventArgs.Location.X - this.m_MouseDownPoint.X;
                 if (this.DisplayRectangle.Width >= this.Width)
                 {
                     pOwner.Invalidate(this.DisplayRectangle);
                 }
                 else
                 {
                     pOwner.Invalidate(new Rectangle(this.DisplayRectangle.X, this.DisplayRectangle.Y, this.DisplayRectangle.Width, this.Height));
                 }
             }
             //
             Control ctr = this.TryGetDependControl_DG(pOwner);
             if (ctr != null)
             {
                 ctr.Cursor = this.m_CursorDefault;
             }
             //
             this.m_OperationStyle = -1;
             this.m_MouseDownPoint = Point.Empty;
             this.m_CursorDefault  = Cursors.Default;
             //
             return(true);
         }
     }
     else if (this.m_OperationStyle == 1)//CanResizeItemHeight
     {
         IOwner pOwner = messageInfo.Sender as IOwner;
         if (pOwner != null)
         {
             MouseEventArgs mouseEventArgs = messageInfo.MessageParameter as MouseEventArgs;
             if (mouseEventArgs != null)
             {
                 this.Height += mouseEventArgs.Location.Y - this.m_MouseDownPoint.Y;
                 if (this.DisplayRectangle.Height >= this.Height)
                 {
                     pOwner.Invalidate(this.DisplayRectangle);
                 }
                 else
                 {
                     pOwner.Invalidate(new Rectangle(this.DisplayRectangle.X, this.DisplayRectangle.Y, this.DisplayRectangle.Width, this.Height));
                 }
             }
             //
             Control ctr = this.TryGetDependControl_DG(pOwner);
             if (ctr != null)
             {
                 ctr.Cursor = this.m_CursorDefault;
             }
             //
             this.m_OperationStyle = -1;
             this.m_MouseDownPoint = Point.Empty;
             this.m_CursorDefault  = Cursors.Default;
             //
             return(true);
         }
     }
     //
     this.m_OperationStyle = -1;
     this.m_MouseDownPoint = Point.Empty;
     this.m_CursorDefault  = Cursors.Default;
     //
     return(false);
 }
Beispiel #22
0
    public static void Update()
    {
        // 処理待ち中は無視
        if (!messageSyoriSitemoii)
        {
            return;
        }
        // メッセージ何もなかったら
        if (messageBox.Count == 0)
        {
            return;
        }
        if (!oulNetwork.s_Singleton.isNetworkActive)
        {
            return;
        }
        // 一定間隔(Remessage送りすぎないように)
        //if ((timer += Time.deltaTime) < kankaku)
        //{
        //    // 通信中UI表示
        //    sceneMain.uiManager.AppearConnectingUI();
        //    return;
        //}
        // 通信中UI非表示
        //sceneMain.uiManager.DisAppearConnectingUI();

        //timer = 0;

        bool ok = false;

        // ずれがないように順番通りに処理するようにする
        for (int i = 0; i < messageBox.Count; i++)
        {
            if (messageBox[i].number == receiveMessageNumber)
            {
                var message = messageBox[i];
                // 処理したのでリストから消去
                messageBox.Remove(message);
                // 次のメッセージ待機
                receiveMessageNumber++;
                // 受け取ったことにする
                networkScene.HandleMessage(message);
                // 見つかったフラグ
                ok = true;
                break;
            }
        }

        if (!ok)
        {
            Debug.LogError("メッセージずれてるクマ。前回のメッセージが受け取れてない可能性があるクマ");
            //oulFile.OutPutLog(Application.dataPath + "/log.txt", "メッセージずれてるクマ。前回のメッセージが受け取れてない可能性があるクマ\n");

            // もっかい送ってもらう
            ReMessageInfo info = new ReMessageInfo();
            info.messageNumber = receiveMessageNumber;
            MessageInfo re = new MessageInfo();
            re.messageType = MessageType.ReMessage;
            re.SetExtraInfo(info);
            oulNetwork.s_Singleton.SendMessage(re);

            //for (int i = receiveMessageNumber; i < mes.myMessageInfo.number; i++)
            //{
            //    ReMessageInfo info = new ReMessageInfo();
            //    info.messageNumber = i;
            //    MessageInfo re = new MessageInfo();
            //    re.messageType = MessageType.ReMessage;
            //    re.SetExtraInfo(info);
            //    SendMessage(re);
            //}
        }

        //if (messageBox[0].messageType == MessageType.ReceiveOK)
        //{
        //    Send(messageBox[0]);
        //    return;
        //}

        //if ((timer += Time.deltaTime) > kankaku)
        //{
        //    timer = 0;

        //    Send(messageBox[0]);
        //}
    }
 public ExampleSyncDomainEvent(MessageInfo info)
 {
     this.Seconds = info.DelayInSeconds;
 }
Beispiel #24
0
 public static void ReceiveOffline(MessageInfo message)
 {
     // 受診
     networkScene.HandleMessage(message);
 }
Beispiel #25
0
 /// <summary>
 /// Réception d'un message d'information
 /// </summary>
 /// <param name="msg">Le message d'information</param>
 public virtual void RecevoirMessageInformation(MessageInfo msg)
 {
 }
        protected override void GetHeadersFromMessage(Message message, MessageDescription messageDescription, object[] parameters, bool isRequest)
        {
            MessageInfo messageInfo = isRequest ? requestMessageInfo : replyMessageInfo;

            if (!messageInfo.AnyHeaders)
            {
                return;
            }
            MessageHeaders headers = message.Headers;

            KeyValuePair <Type, ArrayList>[] multipleHeaderValues = null;
            ArrayList elementList = null;

            if (messageInfo.UnknownHeaderDescription != null)
            {
                elementList = new ArrayList();
            }

            for (int i = 0; i < headers.Count; i++)
            {
                MessageHeaderInfo        header            = headers[i];
                MessageHeaderDescription headerDescription = messageInfo.HeaderDescriptionTable.Get(header.Name, header.Namespace);
                if (headerDescription != null)
                {
                    if (header.MustUnderstand)
                    {
                        headers.UnderstoodHeaders.Add(header);
                    }

                    object item = null;
                    XmlDictionaryReader headerReader = headers.GetReaderAtHeader(i);
                    try
                    {
                        object dataValue = DeserializeHeaderContents(headerReader, messageDescription, headerDescription);
                        if (headerDescription.TypedHeader)
                        {
                            item = TypedHeaderManager.Create(headerDescription.Type, dataValue, headers[i].MustUnderstand, headers[i].Relay, headers[i].Actor);
                        }
                        else
                        {
                            item = dataValue;
                        }
                    }
                    finally
                    {
                        headerReader.Dispose();
                    }

                    if (headerDescription.Multiple)
                    {
                        if (multipleHeaderValues == null)
                        {
                            multipleHeaderValues = new KeyValuePair <Type, ArrayList> [parameters.Length];
                        }
                        if (multipleHeaderValues[headerDescription.Index].Key == null)
                        {
                            multipleHeaderValues[headerDescription.Index] = new KeyValuePair <System.Type, System.Collections.ArrayList>(headerDescription.TypedHeader ? TypedHeaderManager.GetMessageHeaderType(headerDescription.Type) : headerDescription.Type, new ArrayList());
                        }
                        multipleHeaderValues[headerDescription.Index].Value.Add(item);
                    }
                    else
                    {
                        parameters[headerDescription.Index] = item;
                    }
                }
                else if (messageInfo.UnknownHeaderDescription != null)
                {
#if FEATURE_CORECLR
                    MessageHeaderDescription unknownHeaderDescription = messageInfo.UnknownHeaderDescription;
                    XmlDictionaryReader      headerReader             = headers.GetReaderAtHeader(i);
                    try
                    {
                        XmlDocument doc       = new XmlDocument();
                        object      dataValue = doc.ReadNode(headerReader);
                        if (dataValue != null && unknownHeaderDescription.TypedHeader)
                        {
                            dataValue = TypedHeaderManager.Create(unknownHeaderDescription.Type, dataValue, headers[i].MustUnderstand, headers[i].Relay, headers[i].Actor);
                        }
                        elementList.Add(dataValue);
                    }
                    finally
                    {
                        headerReader.Dispose();
                    }
#else
                    throw ExceptionHelper.PlatformNotSupported(); // XmlDocument not available in native
#endif
                }
            }
            if (multipleHeaderValues != null)
            {
                for (int i = 0; i < parameters.Length; i++)
                {
                    if (multipleHeaderValues[i].Key != null)
                    {
                        parameters[i] = multipleHeaderValues[i].Value.ToArray(multipleHeaderValues[i].Key);
                    }
                }
            }
        }
    protected void btnSendMessage_Click(object sender, EventArgs e)
    {
        // This is because of ASP.NET default behaviour
        // The first empty line was trimmed after each postback
        if (BBEditor.Text.StartsWith("\n"))
        {
            BBEditor.Text = "\n" + BBEditor.Text;
        }
        // Flood protection
        if (!FloodProtectionHelper.CheckFlooding(CMSContext.CurrentSiteName, CMSContext.CurrentUser))
        {
            CurrentUserInfo currentUser = CMSContext.CurrentUser;

            // Check banned IP
            if (BannedIPInfoProvider.IsAllowed(CMSContext.CurrentSiteName, BanControlEnum.AllNonComplete))
            {
                int recipientId = ucMessageUserSelector.Visible
                                      ? ucMessageUserSelector.SelectedUserID
                                      : ValidationHelper.GetInteger(hdnUserId.Value, 0);
                string message = string.Empty;
                string nickName = HTMLHelper.HTMLEncode(txtFrom.Text.Trim());
                if (!ValidateBody(DiscussionMacroHelper.RemoveTags(ucBBEditor.Text)))
                {
                    message = GetString("SendMessage.EmptyBody");
                }

                // Check sender nick name if anonymous
                if (isAnonymousUser && (nickName == string.Empty))
                {
                    message = GetString("SendMesage.NoNickName");
                }

                UserInfo recipient = null;

                // Check recipient
                if (recipientId == 0)
                {
                    if (string.IsNullOrEmpty(ucMessageUserSelector.UserNameTextBox.Text.Trim()))
                    {
                        message = GetString("SendMesage.NoRecipient");
                    }
                    else
                    {
                        message = GetString("SendMesage.UserDoesntExists");
                    }
                }
                else
                {
                    recipient = UserInfoProvider.GetUserInfo(recipientId);

                    // Normal users can't send message to user from other site except for global admin
                    if (!recipient.IsInSite(CMSContext.CurrentSiteName) && !currentUser.IsGlobalAdministrator)
                    {
                        message = GetString("SendMesage.UserDoesntExists");
                    }

                    int defRecipientId = ValidationHelper.GetInteger(DefaultRecipient, 0);

                    // If default recipient selected and is same as message recipient, skip check on hidden users
                    if (recipient.UserID != defRecipientId)
                    {
                        // Hide hidden, disabled and not approved user for all users except for global admins and public user for all users
                        if ((IsLiveSite && (!recipient.Enabled || recipient.UserIsHidden || recipient.UserSettings.UserWaitingForApproval) && !currentUser.IsGlobalAdministrator) || (recipient.UserName.ToLower() == "public"))
                        {
                            message = GetString("SendMesage.UserDoesntExists");
                        }
                    }
                }

                if (message == string.Empty)
                {
                    // Send message
                    try
                    {
                        // Check if current user is in recipient's ignore list
                        bool isIgnored = IgnoreListInfoProvider.IsInIgnoreList(recipientId, currentUser.UserID);

                        Message = new MessageInfo();
                        Message.MessageBody = ucBBEditor.Text;
                        string subject = (txtSubject.Text.Trim() == string.Empty) ? GetString("Messaging.NoSubject") : txtSubject.Text.Trim();
                        Message.MessageSubject = TextHelper.LimitLength(subject, 200);
                        Message.MessageRecipientUserID = recipientId;
                        Message.MessageRecipientNickName = TextHelper.LimitLength(Functions.GetFormattedUserName(recipient.UserName, recipient.FullName, recipient.UserNickName, IsLiveSite), 200);
                        Message.MessageSent = DateTime.Now;

                        // Anonymous user
                        if (isAnonymousUser)
                        {
                            Message.MessageSenderNickName = TextHelper.LimitLength(nickName, 200);
                            Message.MessageSenderDeleted = true;
                        }
                        else
                        {
                            Message.MessageSenderUserID = currentUser.UserID;
                            Message.MessageSenderNickName = TextHelper.LimitLength(Functions.GetFormattedUserName(currentUser.UserName, currentUser.FullName, currentUser.UserNickName, IsLiveSite), 200);

                            // If the user is ignored, delete message automatically
                            if (isIgnored)
                            {
                                Message.MessageRecipientDeleted = true;
                            }
                        }

                        string error = string.Empty;

                        // Check bad words
                        if (!BadWordInfoProvider.CanUseBadWords(currentUser, CMSContext.CurrentSiteName))
                        {
                            // Prepare columns to check
                            Dictionary<string, int> columns = new Dictionary<string, int>();
                            columns.Add("MessageSubject", 200);
                            columns.Add("MessageBody", 0);
                            columns.Add("MessageSenderNickName", 200);
                            columns.Add("MessageRecipientNickName", 200);

                            // Perform bad word check
                            error = BadWordsHelper.CheckBadWords(Message, columns, currentUser.UserID);
                        }

                        if (error != string.Empty)
                        {
                            lblSendError.Visible = true;
                            lblSendError.Text = error;
                        }
                        else
                        {
                            // Check message subject, if empty set no subject text
                            if (Message.MessageSubject.Trim() == string.Empty)
                            {
                                Message.MessageSubject = GetString("Messaging.NoSubject");
                            }

                            // Whole text has been removed
                            if (!ValidateBody(Message.MessageBody))
                            {
                                lblSendError.Visible = true;
                                lblSendError.Text = GetString("SendMessage.EmptyBodyBadWords");
                            }
                            else
                            {
                                // Save the message
                                MessageInfoProvider.SetMessageInfo(Message);

                                // Send notification email, if not ignored
                                if (!isIgnored)
                                {
                                    MessageInfoProvider.SendNotificationEmail(Message, recipient, currentUser, CMSContext.CurrentSiteName);
                                }

                                lblSendInfo.Visible = true;
                                lblSendInfo.Text = GetString("SendMesage.MessageSent");
                                MessageId = 0;
                                ucMessageUserSelector.SelectedUserID = 0;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        lblSendError.Visible = true;
                        lblSendError.Text = ex.Message;
                        ErrorMessage = ex.Message;
                    }
                }
                // Error in the form
                else
                {
                    lblSendError.Visible = true;
                    lblSendError.Text = message;
                    ErrorMessage = message;
                }
            }
            else
            {
                lblSendError.Visible = true;
                lblSendError.Text = GetString("General.BannedIP");
            }
        }
        else
        {
            lblSendError.Visible = true;
            lblSendError.Text = GetString("General.FloodProtection");
        }

        // External event
        if (SendButtonClick != null)
        {
            SendButtonClick(sender, e);
        }
    }
 public bool Reply(MessageInfo mi)
 {
     return(_ms.Reply(mi));
 }
 private MessageInfo CreateMessageInfo(MessageDescription message, string key)
 {
     if (message.IsUntypedMessage)
         return null;
     MessageInfo info = new MessageInfo();
     bool isEncoded = false;
     if (message.IsTypedMessage)
         key = message.MessageType.FullName + ":" + isEncoded + ":" + IsRpc;
     XmlMembersMapping headersMapping = LoadHeadersMapping(message, key + ":Headers");
     info.SetHeaders(_parent._generation.AddSerializer(headersMapping));
     MessagePartDescriptionCollection rpcEncodedTypedMessgeBodyParts;
     info.SetBody(_parent._generation.AddSerializer(LoadBodyMapping(message, key, out rpcEncodedTypedMessgeBodyParts)), rpcEncodedTypedMessgeBodyParts);
     CreateHeaderDescriptionTable(message, info, headersMapping);
     return info;
 }
Beispiel #30
0
        private void DoRecvMessage()
        {
            try
            {
                if (m_client.Available >= MessageHeadSize)
                {
                    var buffer = new byte[MessageHeadSize];
                    var stream = m_client.GetStream();
                    if (stream.Read(buffer, 0, MessageHeadSize) == MessageHeadSize)
                    {
                        Marshal.Copy(buffer, 0, m_recvHeadBuffer, MessageHeadSize);
                        m_recvHead = (MessageHead)Marshal.PtrToStructure(m_recvHeadBuffer, typeof(MessageHead));


                        KeyValuePair <UInt32, ConstructorInfo> ret;

                        MessageLua ret_lua = null;

                        if (m_messages.TryGetValue(m_recvHead.id, out ret) == false &&
                            m_luaMessages.TryGetValue(m_recvHead.id, out ret_lua) == false)
                        {
                            DispatchSocketEvent(Event.kErrorMessage, "no find message id:" + m_recvHead.id);
                            return;
                        }

                        Message message = null;
                        if (ret_lua != null)
                        {
                            if (ret_lua.SignId != m_recvHead.signatureId)
                            {
                                DispatchSocketEvent(Event.kErrorMessage, "signId check error,message id:" + m_recvHead.id);
                                return;
                            }

                            message = new FastNet.LocalMessage(ret_lua.Create());
                        }
                        else if (ret.Value != null)
                        {
                            if (ret.Key != m_recvHead.signatureId)
                            {
                                DispatchSocketEvent(Event.kErrorMessage, "signId check error,message id:" + m_recvHead.id);
                                return;
                            }


                            message = ret.Value.Invoke(new object[] { }) as Message;
                        }


                        if (m_recvHead.size > 0)
                        {
                            buffer = new byte[m_recvHead.size];
                            if (stream.Read(buffer, 0, (int)m_recvHead.size) != m_recvHead.size)
                            {
                                DoClose("recv size error,message id:" + m_recvHead.id, true);
                                return;
                            }

                            var memoryStream = new MemoryStream(buffer);
                            var binaryReader = new BinaryReader(memoryStream);
                            message.Deserialize(binaryReader);

                            binaryReader.Close();
                            memoryStream.Close();
                        }

                        if (message != null && message.ClsId != pkt.protocols.SocketHeartbeat.sClsId)
                        {
                            if (message.ClsId == pkt.protocols.RoomMessageRes.sClsId)
                            {
                                var roomMessageRes = (pkt.protocols.RoomMessageRes)message;
                                KeyValuePair <UInt32, ConstructorInfo> ret_roomMessage;
                                MessageLua ret_luaRoomMessage = null;

                                if (false == m_messages.TryGetValue(roomMessageRes.clsId, out ret_roomMessage) &&
                                    m_luaMessages.TryGetValue(roomMessageRes.clsId, out ret_luaRoomMessage) == false)
                                {
                                    DispatchSocketEvent(Event.kErrorMessage, "no find room message id:" + roomMessageRes.clsId);
                                }
                                else
                                {
                                    Message roomMessage = null;
                                    if (ret_lua != null)
                                    {
                                        if (ret_lua.SignId != m_recvHead.signatureId)
                                        {
                                            DispatchSocketEvent(Event.kErrorMessage, "signId check error,room message id:" + roomMessageRes.clsId);
                                            return;
                                        }

                                        roomMessage = new FastNet.LocalMessage(ret_luaRoomMessage.Create());
                                    }
                                    else if (ret.Value != null)
                                    {
                                        if (ret.Key != m_recvHead.signatureId)
                                        {
                                            DispatchSocketEvent(Event.kErrorMessage, "signId check error,room message id:" + roomMessageRes.clsId);
                                            return;
                                        }

                                        roomMessage = ret_roomMessage.Value.Invoke(new object[] { }) as Message;
                                    }

                                    if (roomMessageRes.data.Length > 0)
                                    {
                                        byte[] byteArray    = System.Text.Encoding.Default.GetBytes(roomMessageRes.data);
                                        var    memoryStream = new MemoryStream(byteArray);
                                        var    binaryReader = new BinaryReader(memoryStream);
                                        message.Deserialize(binaryReader);
                                        binaryReader.Close();
                                        memoryStream.Close();
                                    }

                                    lock (m_recvMessages)
                                    {
                                        var mi = new MessageInfo();
                                        mi.message = roomMessage;
                                        mi.roleId  = roomMessageRes.roleId;
                                        mi.roomId  = roomMessageRes.roomId;
                                        m_recvMessages.Enqueue(mi);
                                    }
                                }
                            }
                            else if (message.ClsId == pkt.protocols.SocketConnect.sClsId)
                            {
                                var socketConnect = (pkt.protocols.SocketConnect)message;
                                m_serverId  = socketConnect.serverId;
                                m_sessionId = socketConnect.sessionId;

                                lock (m_md5Values)
                                {
                                    m_md5Values = socketConnect.md5Values;
                                }
                                DispatchSocketEvent(Event.kCheckUpdate, "");
                            }
                            else
                            {
                                lock (m_recvMessages)
                                {
                                    var mi = new MessageInfo();
                                    mi.message = message;
                                    m_recvMessages.Enqueue(mi);
                                }
                            }
                        }

                        m_timerHeartbeat = 10000;
                    }
                }
            }
            catch (Exception e)
            {
                DoClose(e.ToString(), true);
            }
        }
Beispiel #31
0
 private SharpMimeMessage( anmar.SharpMimeTools.SharpMimeMessageStream message, long startpoint, long endpoint )
 {
     this.message = message;
     this.mi = new MessageInfo ( this.message, startpoint );
     this.mi.end = endpoint;
 }
Beispiel #32
0
        private static StringBuilder ReplaceValueWithMacro(StringBuilder idBuilder, Match match, Attachment attachment, MessageInfo userMessage)
        {
            string valueToReplace = match.Groups[0].Value;
            string macroName      = match.Groups[1].Value;

            if (NamingMacros.ContainsKey(macroName))
            {
                idBuilder = idBuilder.Replace(valueToReplace, NamingMacros[macroName](attachment, userMessage));
            }

            return(idBuilder);
        }
Beispiel #33
0
 public override bool OnMessage(Player player, MessageInfo message)
 {
     return(false);
 }
Beispiel #34
0
    protected void Page_Load(object sender, EventArgs e)
    {
        switch (_catalogType)
        {
        case CatalogType.Widgets:
            LiHyperLink.SetNameToCompare(Context, "presentation");
            PageBreadcrumbs.SectionName = Breadcrumbs.Section.WidgetMarketplace;
            break;

        case CatalogType.Themes:
            LiHyperLink.SetNameToCompare(Context, "presentation");
            PageBreadcrumbs.SectionName = Breadcrumbs.Section.ThemeMarketplace;
            break;

        case CatalogType.Plugins:
            LiHyperLink.SetNameToCompare(Context, "settings");
            PageBreadcrumbs.SectionName = Breadcrumbs.Section.PluginMarketplace;
            break;

        case CatalogType.All:
            Response.Redirect(new Urls().AdminMarketplaceHome);
            break;
        }


        if (!IsPostBack)
        {
            try
            {
                CatalogInfo catalog = null;

                if (Marketplace.Catalogs.ContainsKey(_catalogType))
                {
                    catalog = Marketplace.Catalogs[_catalogType];
                }

                MessageInfo messageInfo = null;
                if (catalog.Messages.Count > 0)
                {
                    messageInfo = catalog.Messages[0];
                }
                else if (Marketplace.Messages.Count > 0)
                {
                    messageInfo = Marketplace.Messages[0];
                }

                if (messageInfo != null)
                {
                    MarketplaceMessage.Visible = true;
                    MarketplaceMessage.Type    = StatusType.Information;
                    MarketplaceMessage.Text    = messageInfo.Text;
                }

                categoryList.DataSource = catalog.Categories.Values;
                categoryList.DataBind();

                itemList.DataSource = catalog.Items.Values;
                if (_categoryId > 0)
                {
                    CategoryInfo category = catalog.Categories[_categoryId];
                    itemList.DataSource = category.Items.Values;
                }
                else if (!string.IsNullOrEmpty(_creatorId))
                {
                    CreatorInfo creator = Marketplace.Creators[_creatorId];
                    itemList.DataSource = creator.GetItems(_catalogType).Values;
                }

                itemList.DataBind();
            }
            catch (Exception ex)
            {
                string messageText = "An unexpected error has occurred connecting to the marketplace. The <a href=\"http://extendgraffiti.com/\" target=\"_blank\">Graffiti Marketplace</a> is where you can find new themes, widgets, and plugins. Please try again later.";
                if (ex is System.Security.SecurityException)
                {
                    messageText = "Your security settings do not allow you to access the marketplace from within the Control Panel. To find new themes, widgets, and plugins, please visit the <a href=\"http://extendgraffiti.com/\" target=\"_blank\">Graffiti Marketplace</a>.";
                }

                Message.Type             = StatusType.Error;
                Message.Text             = messageText;
                Message.Visible          = true;
                MarketplaceImage.Visible = true;
                PageBreadcrumbs.Visible  = false;
                categoryList.Visible     = false;
                itemList.Visible         = false;
            }
        }
    }
Beispiel #35
0
        public ActionResult Edit([Bind(Include = "ImageID,CompID,CardImage,Processed,Note,UserID,RoundDate,CourseID,TeeColour,SSS")] ScoreCardImage scoreCardImage)
        {
            if (ModelState.IsValid)
            {
                string             scorecardfileName = "";
                HttpPostedFileBase scorecard         = Request.Files["UploadScoreCard"];
                if (scorecard.FileName != "" && scoreCardImage.UserID != null)  //Deal with New Score Card Image
                {
                    scorecardfileName = scoreCardImage.UserID + new FileInfo(scorecard.FileName).Name;
                    string path = Path.Combine(Server.MapPath("~/ScoreCards/Pending"), scorecardfileName);

                    //Reduce size of file if required and save in large folder
                    WebImage img = new WebImage(scorecard.InputStream);
                    if (img.Height > 1200)
                    {
                        img.Resize(1200, 1200, true);
                    }
                    img.Save(path);

                    TempData["FailUpload"]    = null;
                    TempData["SuccessUpload"] = "Your NEW score card image has been successfully uploaded";

                    // Save the Score Card Image
                    scoreCardImage.CardImage = "/ScoreCards/Pending/" + scorecardfileName;
                }
                else
                {
                    TempData["SuccessUpload"] = "Your pending score card has been successfully edited";
                }


                db.Entry(scoreCardImage).State = EntityState.Modified;
                db.SaveChanges();

                // Send email to Admin to inform of edited score card image.
                MessageInfo messageInfo = new MessageInfo();
                UserInfo    userInfo    = new UserInfo();

                var AllAdmin = userInfo.GetAllAdmin();

                string AdminEmail = "";
                string Subject    = "";
                string Body       = "";
                string userName   = userInfo.GetUserName(Convert.ToInt32(scoreCardImage.UserID));

                foreach (var item in AllAdmin)
                {
                    // messageInfo.CreateMessage(newprofile.UserID, item.UserID, DateTime.Now, user.UserName + " has registered to join Tigerline Scores.");
                    AdminEmail = item.Email;
                    Subject    = "PLAYER PENDING SCORECARD EDITED";
                    Body       = "<span style='font-family: Calibri; font-size: 24px; font-weight: bold; color: green'>TIGERLINE SCORES</span><br/><br/>";
                    Body      += "<span style='font-family: Calibri'>Player " + userName + " has edited their pending scorecard ..<br/><br/>";
                    Body      += "<a href='www.tigerlinescores.co.uk'>Tigerline Scores</a>";
                    messageInfo.SendEmail(AdminEmail, Subject, Body, null);
                }

                // Get Club Names For Drop Down List
                var courseInfo = new CourseInfo();
                ViewBag.CourseList = courseInfo.GetCourseList();

                // Tee Colour List
                List <SelectListItem> teecolor = new List <SelectListItem>();
                teecolor.Add(new SelectListItem()
                {
                    Text = "White", Value = "White"
                });
                teecolor.Add(new SelectListItem()
                {
                    Text = "Yellow", Value = "Yellow"
                });
                teecolor.Add(new SelectListItem()
                {
                    Text = "Red", Value = "Red"
                });
                ViewBag.TeeColour = teecolor;
            }
            return(View(scoreCardImage));
        }
Beispiel #36
0
 /// <summary>
 /// 给多个客户端发送文件
 /// </summary>
 /// <param name="messageInfo"></param>
 public static void SendFileToMutilClient(Dictionary <string, GGUserInfo> onLineUser, MessageInfo messageInfo)
 {
     if (false)
     {
         foreach (GGUserInfo user in onLineUser.Values)
         {
             MessageInfo toInfo = new MessageInfo()
             {
                 msgType = messageInfo.msgType, buffer = messageInfo.buffer, fileType = messageInfo.fileType, dateTime = DateTime.Now
             };
             string info = SerializerUtil.ObjectToJson <MessageInfo>(messageInfo);
             info = SerializerUtil.ObjectToJson <byte[]>(messageInfo.buffer);
             byte[] bytes = Encoding.UTF8.GetBytes(info);
             user.socket.Send(bytes);
         }
     }
     else
     {
         List <byte> list = new List <byte>();
         list.Add(Convert.ToByte(messageInfo.msgType));  //标记为:信息类型
         list.Add(Convert.ToByte(messageInfo.fileType)); //标记位:文件类型
         list.AddRange(messageInfo.buffer);              //发送的是文件字节
         byte[] sendMsg = list.ToArray();
         //发送文件
         foreach (GGUserInfo user in onLineUser.Values)
         {
             user.socket.Send(sendMsg, 0, messageInfo.fileLength + 2, SocketFlags.None);
             //user.socket.Send(messageInfo.buffer, 0, messageInfo.fileLength  , SocketFlags.None);
         }
     }
 }
Beispiel #37
0
 public override void PackageRecieve(RequestPackage package, MessageInfo info)
 {
     throw new LoggableException("Recieved a request package but a client cannot handle such a package.", null, LogType.Error);
 }
    protected void outboxGrid_OnAction(string actionName, object actionArgument)
    {
        CurrentMessageId = ValidationHelper.GetInteger(actionArgument, 0);

        // Force reinitialization of message object if differs from currently processed message
        if ((Message != null) && (Message.MessageID != CurrentMessageId))
        {
            mMessage = null;
        }

        // Check permissions - user has to be sender
        if ((Message == null) || (Message.MessageSenderUserID != MembershipContext.AuthenticatedUser.UserID))
        {
            return;
        }

        switch (actionName)
        {
            // Delete message
            case "delete":
                DeleteMessage();
                break;

            // View message
            case "view":
                ViewMessage();
                break;

            // Forward message
            case "forward":
                ForwardMesssage();
                break;
        }
    }
 protected override void MessageMonitor(MessageInfo messageInfo)
 {
     base.MessageMonitor(messageInfo);
     //
     ((IMessageChain)this.m_DockPanelFloatFormButtonStackItemEx).SendMessage(messageInfo);
 }
Beispiel #40
0
 protected virtual void RunRequest(MessageInfo message, CommandInfo command)
 {
     Client.SendMessage(message.Chat.Id, command.StaticAcceptMessage);
 }
Beispiel #41
0
        public ChatResult SendMessageToFriend(MessageInfo msg)
        {
            CustomerInfo myCustomer = Manager.Instance.GetCustomerByConnectionId(Context.ConnectionId);
            CustomerInfo friendCustomer = Manager.Instance.GetCustomerByCustomerId(msg.ReceiverId);
            //send message to friend
            List<string> friendConnectionIds = friendCustomer.ConnectionList;
            Clients.Clients(friendConnectionIds).OnReceiveMessage(msg);
            //send message to myCustomer(#connectionId)
            List<string> myConnectionIds = new List<string>(myCustomer.ConnectionList);
            myConnectionIds.Remove(Context.ConnectionId);
            Clients.Clients(myConnectionIds).OnReceiveMessage(msg);

            ChatResult result = Manager.Instance.AddMessage(msg);
            return result;
        }
Beispiel #42
0
 protected virtual void GetFirstParameter(MessageInfo message, CommandInfo command)
 {
     var parameter = command.Parameters.First();
     Data.SetCommand(message.From.Id, message.Chat.Id, command.Text);
     Client.SendMessage(message.Chat.Id, parameter.StaticPrompt);
 }
Beispiel #43
0
        public ChatResult BroadcastMessage(MessageInfo message)
        {
            CustomerInfo myCustomer = Manager.Instance.GetCustomerByConnectionId(Context.ConnectionId);
            if (myCustomer.Role.Equals(CustomerRole.Admin))
            {
                List<CustomerInfo> customerList = Manager.Instance.GetCustomerListByRole(message.ReceiverId);
                customerList.Remove(myCustomer);
                foreach (CustomerInfo customer in customerList)
                    Clients.Clients(customer.ConnectionList).OnReceiveMessage(message);
                Manager.Instance.AddMessage(message);

                return new ChatResult(true, null);
            } return null;
        }
Beispiel #44
0
 protected virtual void OnUnknownCommandReceived(MessageInfo message)
 {
     if (UnknownCommandReceived != null)
         UnknownCommandReceived(this, new MessageEventArgs(message));
 }
                internal void EnsureMessageInfos()
                {
                    if (_request == null)
                    {
                        foreach (Type knownType in Operation.KnownTypes)
                        {
                            if (knownType == null)
                                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxKnownTypeNull, Operation.Name)));
                            _parent._importer.IncludeType(knownType);
                        }
                        _request = CreateMessageInfo(this.Operation.Messages[0], ":Request");
                        // We don't do the following check at Net Native runtime because XmlMapping.XsdElementName 
                        // is not available at that time.
                        bool skipVerifyXsdElementName = false;
#if FEATURE_NETNATIVE
                        skipVerifyXsdElementName = GeneratedXmlSerializers.IsInitialized;
#endif
                        if (_request != null && this.IsRpc && this.Operation.IsValidateRpcWrapperName && !skipVerifyXsdElementName && _request.BodyMapping.XsdElementName != this.Operation.Name)
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxRpcMessageBodyPartNameInvalid, Operation.Name, this.Operation.Messages[0].MessageName, _request.BodyMapping.XsdElementName, this.Operation.Name)));
                        if (!this.IsOneWay)
                        {
                            _reply = CreateMessageInfo(this.Operation.Messages[1], ":Response");
                            XmlName responseName = TypeLoader.GetBodyWrapperResponseName(this.Operation.Name);
                            if (_reply != null && this.IsRpc && this.Operation.IsValidateRpcWrapperName && !skipVerifyXsdElementName && _reply.BodyMapping.XsdElementName != responseName.EncodedName)
                                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxRpcMessageBodyPartNameInvalid, Operation.Name, this.Operation.Messages[1].MessageName, _reply.BodyMapping.XsdElementName, responseName.EncodedName)));
                        }
                        if (this.Attribute.SupportFaults)
                        {
                            GenerateXmlSerializerFaultContractInfos();
                        }
                    }
                }
Beispiel #46
0
                private void CreateHeaderDescriptionTable(MessageDescription message, MessageInfo info, XmlMembersMapping headersMapping)
                {
                    int headerNameIndex = 0;

                    OperationFormatter.MessageHeaderDescriptionTable headerDescriptionTable = new OperationFormatter.MessageHeaderDescriptionTable();
                    info.SetHeaderDescriptionTable(headerDescriptionTable);
                    foreach (MessageHeaderDescription header in message.Headers)
                    {
                        if (header.IsUnknownHeaderCollection)
                        {
                            info.SetUnknownHeaderDescription(header);
                        }
                        else if (headersMapping != null)
                        {
                            XmlMemberMapping memberMapping = headersMapping[headerNameIndex++];
                            string           headerName, headerNs;
                            headerName = memberMapping.XsdElementName;
                            headerNs   = memberMapping.Namespace;
                            if (headerName != header.Name)
                            {
                                if (message.MessageType != null)
                                {
                                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRServiceModel.SFxHeaderNameMismatchInMessageContract, message.MessageType, header.MemberInfo.Name, header.Name, headerName)));
                                }
                                else
                                {
                                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRServiceModel.SFxHeaderNameMismatchInOperation, this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, header.Name, headerName)));
                                }
                            }
                            if (headerNs != header.Namespace)
                            {
                                if (message.MessageType != null)
                                {
                                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRServiceModel.SFxHeaderNamespaceMismatchInMessageContract, message.MessageType, header.MemberInfo.Name, header.Namespace, headerNs)));
                                }
                                else
                                {
                                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(SRServiceModel.SFxHeaderNamespaceMismatchInOperation, this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, header.Namespace, headerNs)));
                                }
                            }

                            headerDescriptionTable.Add(headerName, headerNs, header);
                        }
                    }
                }
                private void CreateHeaderDescriptionTable(MessageDescription message, MessageInfo info, XmlMembersMapping headersMapping)
                {
                    int headerNameIndex = 0;
                    OperationFormatter.MessageHeaderDescriptionTable headerDescriptionTable = new OperationFormatter.MessageHeaderDescriptionTable();
                    info.SetHeaderDescriptionTable(headerDescriptionTable);
                    foreach (MessageHeaderDescription header in message.Headers)
                    {
                        if (header.IsUnknownHeaderCollection)
                            info.SetUnknownHeaderDescription(header);
                        else if (headersMapping != null)
                        {
                            XmlMemberMapping memberMapping = headersMapping[headerNameIndex++];

                            if (GeneratedXmlSerializers.IsInitialized)
                            {
                                // If GeneratedXmlSerializers has been initialized, we would use the 
                                // mappings generated by .Net Native tools. In that case, the mappings
                                // we genrated at Runtime are just fake mapping instance which have
                                // no valid name/namespace. Therefore we cannot do the checks in the
                                // else block. Those checks should have been done during NET Native 
                                // precompilation.
                                headerDescriptionTable.Add(header.Name, header.Namespace, header);
                            }
                            else
                            {
                                string headerName, headerNs;
                                headerName = memberMapping.XsdElementName;
                                headerNs = memberMapping.Namespace;
                                if (headerName != header.Name)
                                {
                                    if (message.MessageType != null)
                                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxHeaderNameMismatchInMessageContract, message.MessageType, header.MemberInfo.Name, header.Name, headerName)));
                                    else
                                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxHeaderNameMismatchInOperation, this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, header.Name, headerName)));
                                }
                                if (headerNs != header.Namespace)
                                {
                                    if (message.MessageType != null)
                                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxHeaderNamespaceMismatchInMessageContract, message.MessageType, header.MemberInfo.Name, header.Namespace, headerNs)));
                                    else
                                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.Format(SR.SFxHeaderNamespaceMismatchInOperation, this.Operation.Name, this.Operation.DeclaringContract.Name, this.Operation.DeclaringContract.Namespace, header.Namespace, headerNs)));
                                }

                                headerDescriptionTable.Add(headerName, headerNs, header);
                            }
                        }
                    }
                }
Beispiel #48
0
 public bool Handles(MessageInfo msgInfo)
 {
     return(_match(msgInfo));
 }
Beispiel #49
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SharpMimeMessage"/> class from a <see cref="System.IO.Stream"/>
 /// </summary>
 /// <param name="message"><see cref="System.IO.Stream" /> to read the message from</param>
 public SharpMimeMessage( System.IO.Stream message )
 {
     this.message = new anmar.SharpMimeTools.SharpMimeMessageStream (message);
     this.mi = new MessageInfo ( this.message, this.message.Stream.Position );
 }
        private void ShowCustomControls()
        {
            Panel p1 = (Panel)GetControltByMaster("Panel1");

            p1.Controls.Add(this.spgvQualifiedMaterial);

            Panel p2 = (Panel)GetControltByMaster("Panel2");

            p2.Controls.Add(this.spgvRepairMaterial);

            Panel p3 = (Panel)GetControltByMaster("Panel3");

            p3.Controls.Add(this.spgvRejectMaterial);

            if (this.spgvQualifiedMaterial.Rows.Count == 0)
            {
                GetControltByMaster("tblQualified").Visible = false;
            }
            if (this.spgvRepairMaterial.Rows.Count == 0)
            {
                GetControltByMaster("tblRepair").Visible = false;
            }
            if (this.spgvRejectMaterial.Rows.Count == 0)
            {
                GetControltByMaster("tblReject").Visible = false;
            }

            this.spgvQualifiedMaterial.Columns[11].Visible = false;
            this.spgvRepairMaterial.Columns[11].Visible    = false;

            this.spgvRejectMaterial.Columns[11].Visible = false;
            this.spgvRejectMaterial.Columns[12].Visible = false;
            this.spgvRejectMaterial.Columns[13].Visible = false;
            this.spgvRejectMaterial.Columns[14].Visible = false;
            this.spgvRejectMaterial.Columns[15].Visible = false;

            //分支流程--质检结果已经处理的情况
            using (MMSProDBDataContext db = new MMSProDBDataContext(ConfigurationManager.ConnectionStrings["mmsConString"].ConnectionString))
            {
                TaskStorageIn tsi;
                tsi = db.TaskStorageIn.SingleOrDefault(u => u.PreviousTaskID.Equals(_taskid) && u.StorageInID.Equals(_transferid) && u.TaskType.Equals("资产组处理合格物资") && u.StorageInType.Equals("回收入库"));
                if (tsi != null)//合格物资已经处理的情况
                {
                    btnQualified.Visible = false;
                    string strMaterial = string.Format("<font style=\"font-size:x-small;font-weight:bold;color:red\">{0}</font>", tsi.EmpInfo1.EmpName);
                    (GetControltByMaster("ltrQualified") as Literal).Text = string.Format("<font style=\"font-size:x-small;font-weight:bold;color:green\">合格物资已经发送资产管理员{0}处理. . .</font>", strMaterial);
                }

                tsi = db.TaskStorageIn.SingleOrDefault(u => u.PreviousTaskID.Equals(_taskid) && u.StorageInID.Equals(_transferid) && u.TaskType.Equals("生产组申请维修") && u.StorageInType.Equals("回收入库"));
                if (tsi != null)//待维修物资已经处理的情况
                {
                    btnRepair.Visible = false;
                    string strProduce = string.Format("<font style=\"font-size:x-small;font-weight:bold;color:red\">{0}</font>", tsi.EmpInfo1.EmpName);
                    (GetControltByMaster("ltrRepair") as Literal).Text = string.Format("<font style=\"font-size:x-small;font-weight:bold;color:green\">待修复物资已经发送物资管理员{0}处理. . .</font>", strProduce);
                }

                MessageInfo mi = db.MessageInfo.SingleOrDefault(u => u.TaskID.Equals(_taskid));
                if (mi != null)//已经发送报废通知的情况
                {
                    btnReject.Visible = false;
                    var receivers = from r in db.MessageReceiver
                                    where r.MessageInfoID.Equals(mi.MessageInfoID)
                                    select r;
                    string strMaterial = string.Empty;
                    foreach (MessageReceiver receiver in receivers)
                    {
                        strMaterial = string.Format("{0}、{1}", strMaterial, receiver.EmpInfo.EmpName);
                    }
                    strMaterial = strMaterial.Substring(1, strMaterial.Length - 1);
                    strMaterial = string.Format("<font style=\"font-size:x-small;font-weight:bold;color:red\">{0}</font>", strMaterial);
                    (GetControltByMaster("ltrReject") as Literal).Text = string.Format("<font style=\"font-size:x-small;font-weight:bold;color:green\">已经通知{0}处理待报废物资. . .</font>", strMaterial);
                }

                if (btnQualified.Visible == false || btnRepair.Visible == false || btnReject.Visible == false)//已经存在处理质检后物资的情况
                {
                    strBackUrl = "../../default-old.aspx";
                }

                //分支流程--任务已经完成的情况
                if (db.TaskStorageIn.SingleOrDefault(u => u.TaskStorageID.Equals(_taskid)).TaskState.Equals("已完成"))
                {
                    btnOK.Visible = false;
                    (GetControltByMaster("lblInfo") as Label).Text = "该任务已完成,您正在查看质检处理结果. . .";
                }
            }
        }
Beispiel #51
0
        /// <summary>
        /// 服务端将字节发送信息给好友客户端
        /// </summary>
        /// <param name="onLineUser"></param>
        /// <param name="messageInfo"></param>
        public static void SendToOnlineFriendClients(Dictionary <string, GGUserInfo> onLineUser, List <GGUserInfo> friendList, MessageInfo messageInfo)
        {
            try
            {
                List <GGUserInfo> onlineList = onLineUser.Values.ToList <GGUserInfo>();

                List <GGUserInfo> clientList = new List <GGUserInfo>();
                foreach (GGUserInfo item in onlineList)
                {
                    GGUserInfo tmpUser = friendList.Where(i => i.userId == item.userId).SingleOrDefault();
                    if (tmpUser != null)
                    {
                        clientList.Add(item);
                    }
                }

                string info  = SerializerUtil.ObjectToJson <MessageInfo>(messageInfo);
                byte[] bytes = Encoding.UTF8.GetBytes(info);
                foreach (GGUserInfo user in clientList)
                {
                    user.socket.Send(bytes);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("服务端将字节发送信息给客户端," + ex.Message);
            }
        }
Beispiel #52
0
 private void AddMessage(MessageInfo messageInfo)
 {
     messages.Add(messageInfo);
     debug_window.AddMessage(messageInfo);
 }
Beispiel #53
0
 protected virtual void ProcessCommand(MessageInfo message)
 {
     var commandInfo = FindCommand(message.Text);
     if (commandInfo != null)
     {
         Process(message, commandInfo);
     }
     else
     {
         OnUnknownCommandReceived(message);
         if (!string.IsNullOrEmpty(Configuration.StaticUnknownCommandMessage))
         {
             Client.SendMessage(message.Chat.Id, Configuration.StaticUnknownCommandMessage);
         }
     }
 }
Beispiel #54
0
        /// <summary>
        /// 服务端将字节发送信息给客户端
        /// </summary>
        /// <param name="onLineUser"></param>
        /// <param name="messageInfo"></param>
        public static void SendToMultiClients(Dictionary <string, GGUserInfo> onLineUser, MessageInfo messageInfo)
        {
            try
            {
                messageInfo.excludeUserIds = messageInfo.excludeUserIds == null ? "" : messageInfo.excludeUserIds;
                List <string> excludeUserList = messageInfo.excludeUserIds.Split('|').ToList <string>();

                foreach (GGUserInfo user in onLineUser.Values)
                {
                    if (excludeUserList.Contains(user.userId))
                    {
                        continue;
                    }

                    messageInfo.toUser = user;
                    string info  = SerializerUtil.ObjectToJson <MessageInfo>(messageInfo);
                    byte[] bytes = Encoding.UTF8.GetBytes(info);
                    user.socket.Send(bytes);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("服务端将字节发送信息给客户端," + ex.Message);
            }
        }
Beispiel #55
0
 private void ProcessParameter(MessageInfo message)
 {
     var commandState = Data.GetCommandState(message.From.Id, message.Chat.Id);
     if(commandState!=null)
     {
     }
     else
     {
         OnUnknownCommandReceived(message);
     }
 }
Beispiel #56
0
        public async Task <MessageView> BuildView(TranslatedSearchResult <T> item)
        {
            IReadOnlyList <ItemMatch <T> > matches = item.Matches;

            if (matches.Count == 0)
            {
                return(new MessageView($"No results found."));
            }

            string?didYouMean = null;

            if (matches.Count > 1)
            {
                IEnumerable <string?> names = matches.Skip(1).Select(m => $"**{GetItemName(m.Item)}**");
                string namesOutput          = string.Join(" | ", names);
                didYouMean = $"Did you mean: {namesOutput}";
                if (didYouMean.Length > 2048)
                {
                    string s = matches.Count == 2 ? "" : "s";
                    didYouMean = $"*{matches.Count - 1} other result{s}*";
                }
            }

            T uItem = matches[0].Item;

            item.TranslationMap.TryGetValue(uItem, out T? tItem);
            IEnumerable <T> expansion = await ExpandItem(tItem ?? uItem);

            MessageView[] views = await Task.WhenAll(expansion.Select(BuildItemView));

            var messages = new List <MessageInfo>();

            if (didYouMean is null)
            {
                // Just render all item views
                foreach (MessageView view in views)
                {
                    messages.AddRange(view.Messages);
                }
            }
            else if (views.Length == 1 && views[0].Messages.Count == 1)
            {
                // Send the text reply in the same message as the single item message if possible
                MessageInfo itemMessage = views[0].Messages[0];
                if (itemMessage.Text is null)
                {
                    messages.Add(new MessageInfo {
                        Text = didYouMean, Embed = itemMessage.Embed
                    });
                }
                else
                {
                    messages.Add(didYouMean);
                    messages.Add(itemMessage);
                }
            }
            else
            {
                // Send the text reply separately from the multiple item messages
                messages.Add(didYouMean);
                foreach (MessageView view in views)
                {
                    messages.AddRange(view.Messages);
                }
            }

            return(new MessageView(messages));
        }
Beispiel #57
0
 protected virtual void OnMessageReceived(MessageInfo message)
 {
     if (MessageReceived != null)
         MessageReceived(this, new MessageEventArgs(message));
 }
Beispiel #58
0
        //public void GetData(Action<DataItem, Exception> callback)
        //{
        //    // Use this to create design time data

        //    var item = new DataItem("Welcome to MVVM Light [design]");
        //    callback(item, null);
        //}
        public void GetMessage(MessageInfo messageResult)
        {
            throw new NotImplementedException();
        }
Beispiel #59
0
 protected virtual void Process(MessageInfo message, CommandInfo command)
 {
     if (command.Parameters.Any())
     {
         GetFirstParameter(message, command);
     }
     else
     {
         Data.DeleteCommandState(message.From.Id, message.Chat.Id);
         RunRequest(message, command);
     }
 }
Beispiel #60
0
 public XmlSerializerOperationFormatter(OperationDescription description, XmlSerializerFormatAttribute xmlSerializerFormatAttribute, MessageInfo requestMessageInfo, MessageInfo replyMessageInfo) : base(description, xmlSerializerFormatAttribute.Style == OperationFormatStyle.Rpc, xmlSerializerFormatAttribute.IsEncoded)
 {
     if (xmlSerializerFormatAttribute.IsEncoded && (xmlSerializerFormatAttribute.Style != OperationFormatStyle.Rpc))
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxDocEncodedNotSupported", new object[] { description.Name })));
     }
     this.isEncoded          = xmlSerializerFormatAttribute.IsEncoded;
     this.requestMessageInfo = requestMessageInfo;
     this.replyMessageInfo   = replyMessageInfo;
 }