public void  Write(Message message, object obj)
    {
        PersonMessage person = null;

        if (obj is PersonMessage)
        {
            person = (PersonMessage)obj;
        }
        if (message == null)
        {
            throw new ArgumentNullException("message");
        }

        if (obj == null)
        {
            throw new ArgumentNullException("obj");
        }
        string Message = person.SimpleMessage;

        message.BodyStream = new MemoryStream(Encoding.UTF8.GetBytes(Message));

        //Need to reset the body type, in case the same message
        //is reused by some other formatter.
        message.BodyType = 0;
    }
Beispiel #2
0
        private void ReceiveMessage(IMClassLibrary.SingleChatDataPackage data)
        {
            PersonMessage msg;
            int           i = 0;

            for (; i < list.Count; i++)
            {
                msg = (PersonMessage)list[i];
                if (msg.Person == data.Sender)
                {
                    msg.Message += data;
                    break;
                }
            }             //存在此联系人,增加聊天数据
            if (i == list.Count)
            {
                msg          = new PersonMessage();
                msg.Person   = data.Sender;
                msg.Message += data;
                list.Add(msg);
                ListBoxItem item = new ListBoxItem();
                item.Content = msg.Person;
                listBox.Items.Add(item);
            }             //未存在此联系人,增加新联系人与聊天数据
        }
Beispiel #3
0
 public static Person toRecord(this PersonMessage message)
 {
     return(new Person()
     {
         sex = message.sex.toRecord(),
         name = message.name,
         phones = message.phones,
     });
 }
Beispiel #4
0
 void iPersonsService.add(PersonMessage msg)
 {
     using (var sess = sessionPool.GetSession())
         using (var trans = sess.BeginTransaction())
         {
             Cursor <Person> cur = sess.Cursor <Person>();
             cur.Add(msg.toRecord());
             trans.Commit();
         }
 }
Beispiel #5
0
		public void PersonMessage()
		{
			Person person = new Person ("identity");
			person.Nickname = "nickname";
			person.Status = Status.Away;

			var msg = new PersonMessage { Person = person };

			msg = msg.AssertLengthMatches();
			Assert.AreEqual (person.Identity, msg.Person.Identity);
			Assert.AreEqual (person.Nickname, msg.Person.Nickname);
			Assert.AreEqual (person.Status, msg.Person.Status);
		}
        public HttpResponseMessage Post(PersonMessage person)
        {
            using (DatabaseContext databaseContext = new DatabaseContext())
            {
                var personAggregate = PersonAggregate.Create(
                    person.FirstName, person.LastName);
                databaseContext.Set <PersonAggregate>().Add(personAggregate);

                databaseContext.SaveChanges();

                var response = Request.CreateResponse(HttpStatusCode.Created, personAggregate.Id);
                return(response);
            }
        }
        public object GetValue(CodedInputStream inputStream, Type type)
        {
            if (type == typeof(Person))
            {
                var value = new PersonMessage();
                inputStream.ReadMessage(value);

                return(new Person {
                    Name = value.Name, Age = value.Age
                });
            }

            throw new InvalidOperationException("(Deserialize) Unknown type.");
        }
Beispiel #8
0
        public void PersonMessage()
        {
            Person person = new Person("identity");

            person.Nickname = "nickname";
            person.Status   = Status.Away;

            var msg = new PersonMessage {
                Person = person
            };

            msg = msg.AssertLengthMatches();
            Assert.AreEqual(person.Identity, msg.Person.Identity);
            Assert.AreEqual(person.Nickname, msg.Person.Nickname);
            Assert.AreEqual(person.Status, msg.Person.Status);
        }
        public ActionResult Create(PersonMessage personMessage)
        {
            try
            {
                using (var dbModel = new OneSmallStepContext())
                {
                    dbModel.PersonMessage.Add(personMessage);
                    dbModel.SaveChanges();
                }
                // TODO: Add insert logic here

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #10
0
        public void PersonController_Post_ReturnOK()
        {
            var personMessage = new PersonMessage
            {
                FirstName = "John",
                LastName  = "Smith"
            };

            using (WebApp.Start <Startup>(url: iisAddress))
            {
                HttpClient client = new HttpClient();
                client.DefaultRequestHeaders.Accept.Add(
                    new MediaTypeWithQualityHeaderValue("application/json"));
                var response = client.PostAsJsonAsync(String.Format("{0}PersonWrite", iisAddress), personMessage).Result;
                response.StatusCode.Should().Be(HttpStatusCode.Created);

                Debug.WriteLine(response.Content.ReadAsStringAsync().Result);
            }
        }
Beispiel #11
0
 /// <summary>
 /// 员工工作状态修改
 /// </summary>
 /// <param name="workState"></param>
 /// <returns></returns>
 public static int Update(WorkState workState)
 {
     using (EFContext Context = new EFContext())
     {
         try
         {
             PersonMessage work = new PersonMessage()
             {
                 PID = workState.PID
             };
             PersonMessage person = Context.PersonMessage.Attach(work);
             person.PeEndwork = workState.PeEndwork;
             person.Pstatic   = Convert.ToBoolean(0);
             return(Context.SaveChanges());
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
        public override void PersonShowMessage(Person person, PersonMessage message)
        {
            if (((base.Scenario.CurrentPlayer == null) || base.Scenario.IsCurrentPlayer(person.BelongedFaction)) && (message is SpyMessage))
            {
                SpyMessage gameObject = message as SpyMessage;
                switch (gameObject.Kind)
                {
                case SpyMessageKind.NewMilitary:
                    this.Plugins.PersonTextDialogPlugin.SetGameObjectBranch(person, gameObject, "SpyMessageNewMilitary");
                    this.Plugins.PersonTextDialogPlugin.SetPosition(ShowPosition.Bottom);
                    this.Plugins.PersonTextDialogPlugin.IsShowing = true;
                    break;

                case SpyMessageKind.MilitaryScale:
                    this.Plugins.PersonTextDialogPlugin.SetGameObjectBranch(person, gameObject, "SpyMessageMilitaryScale");
                    this.Plugins.PersonTextDialogPlugin.SetPosition(ShowPosition.Bottom);
                    this.Plugins.PersonTextDialogPlugin.IsShowing = true;
                    break;

                case SpyMessageKind.NewFacility:
                    this.Plugins.PersonTextDialogPlugin.SetGameObjectBranch(person, gameObject, "SpyMessageNewFacility");
                    this.Plugins.PersonTextDialogPlugin.SetPosition(ShowPosition.Bottom);
                    this.Plugins.PersonTextDialogPlugin.IsShowing = true;
                    break;

                case SpyMessageKind.NewTroop:
                    this.Plugins.PersonTextDialogPlugin.SetGameObjectBranch(person, gameObject, "SpyMessageNewTroop");
                    this.Plugins.PersonTextDialogPlugin.SetPosition(ShowPosition.Bottom);
                    this.Plugins.PersonTextDialogPlugin.IsShowing = true;
                    break;

                case SpyMessageKind.HireNewPerson:
                    this.Plugins.PersonTextDialogPlugin.SetGameObjectBranch(person, gameObject, "SpyMessageHireNewPerson");
                    this.Plugins.PersonTextDialogPlugin.SetPosition(ShowPosition.Bottom);
                    this.Plugins.PersonTextDialogPlugin.IsShowing = true;
                    break;
                }
            }
        }
Beispiel #13
0
        public App()
        {
            //InitializeComponent();

            UriChanger   = new PicUriChanger();
            SettingTheme = new Theme();
            DataCatcherE = new DataCatcher();

            //LoginPerson = new PersonMessage(-1);
            //TempClear();
            CCat = new PersonMessage(-1);
            //PP = new PersonMessage(-2);
            DisplayPerson = CCat;   //temp, Change After taking Log in
            //DemoActivity = new ActivityMessage("", "", "", "", 10, BlackCat.App.CCat, -1);
            //Demo2 = new ActivityMessage("", "", "", "", 4, BlackCat.App.CCat, -2);


            DisplayActivity = new ActivityMessage();
            MainP           = new MainPage();
            PageInfo        = new NavigationPage(new LoginPage("", ""));


            MainPage = PageInfo;
        }
Beispiel #14
0
 public virtual void PersonShowMessage(Person person, PersonMessage message)
 {
 }
Beispiel #15
0
 private void person_OnShowMessage(Person person, PersonMessage personMessage)
 {
     person.Scenario.GameScreen.PersonShowMessage(person, personMessage);
 }
        public override void PersonShowMessage(Person person, PersonMessage message)
        {
            if (((base.Scenario.CurrentPlayer == null) || base.Scenario.IsCurrentPlayer(person.BelongedFaction)) && (message is SpyMessage))
            {
                SpyMessage gameObject = message as SpyMessage;
                switch (gameObject.Kind)
                {
                    case SpyMessageKind.NewMilitary:
                        this.Plugins.tupianwenziPlugin.SetGameObjectBranch(person, gameObject, "SpyMessageNewMilitary");
                        this.Plugins.tupianwenziPlugin.SetPosition(ShowPosition.Bottom);
                        this.Plugins.tupianwenziPlugin.IsShowing = true;
                        break;

                    case SpyMessageKind.MilitaryScale:
                        this.Plugins.tupianwenziPlugin.SetGameObjectBranch(person, gameObject, "SpyMessageMilitaryScale");
                        this.Plugins.tupianwenziPlugin.SetPosition(ShowPosition.Bottom);
                        this.Plugins.tupianwenziPlugin.IsShowing = true;
                        break;

                    case SpyMessageKind.NewFacility:
                        this.Plugins.tupianwenziPlugin.SetGameObjectBranch(person, gameObject, "SpyMessageNewFacility");
                        this.Plugins.tupianwenziPlugin.SetPosition(ShowPosition.Bottom);
                        this.Plugins.tupianwenziPlugin.IsShowing = true;
                        break;

                    case SpyMessageKind.NewTroop:
                        this.Plugins.tupianwenziPlugin.SetGameObjectBranch(person, gameObject, "SpyMessageNewTroop");
                        this.Plugins.tupianwenziPlugin.SetPosition(ShowPosition.Bottom);
                        this.Plugins.tupianwenziPlugin.IsShowing = true;
                        break;

                    case SpyMessageKind.HireNewPerson:
                        this.Plugins.tupianwenziPlugin.SetGameObjectBranch(person, gameObject, "SpyMessageHireNewPerson");
                        this.Plugins.tupianwenziPlugin.SetPosition(ShowPosition.Bottom);
                        this.Plugins.tupianwenziPlugin.IsShowing = true;
                        break;
                }
            }
        }
 public WelcomeMessage Hello([FromBody] PersonMessage person)
 {
     return(new WelcomeMessage {
         Text = $"Hello {person.Name}"
     });
 }
 /// <summary>
 /// Acknowledges this instance.
 /// </summary>
 /// <param name="message">The message.</param>
 private void Acknowledge(PersonMessage message)
 {
     var task = Task.Run(() => PersonsService.AcknowledgePersonMessages(message, this.SelectedPerson));
     task.Wait();
 }
Beispiel #19
0
 public void IdCounter()
 {
     PersonMessage?.Invoke(ID);
 }
 /// <summary>
 /// Acknowledges the person message.
 /// </summary>
 /// <param name="message">The message.</param>
 private void AcknowledgePersonMessage(PersonMessage message)
 {
     Messenger.Instance.Notify(MessengerMessage.ShowSpinWheel, true);
     ObservableManager.RunObservable(() => this.Acknowledge(message), () => this.OnAcknowledgementCompleted(message));
 }
Beispiel #21
0
 public virtual void PersonShowMessage(Person person, PersonMessage message)
 {
 }
        /// <summary>
        /// Function to acknowledge person messages.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="person">Instance of PersonBase</param>
        /// <returns>
        /// IObservable of list of Alert
        /// </returns>
        public static async Task<PersonMessage> AcknowledgePersonMessages(PersonMessage message, PersonBase person)
        {
            var workstation = DIContainer.Instance.Resolve<Workstation>();
            var clearAlertMessage = new ClearAlertMessage()
            {
                PersonMessageId = message.AlertId,
                PersonId = person.PersonId,
                PersonTypeId = person.PersonTypeId,
                StatusId = AlertMessageStatusType.ClearAlert.RetrieveStatusId(),
                ShipId = workstation.Ship.ShipId,
                StatusUpdateDate = workstation.CurrentDateTime,
                StatusUpdatedBy = workstation.User.UserId,
                VoyageId = workstation.Voyage.VoyageId
            };

            var personEvent = CreateEventService.MapPersonEvent(person, message.AlertId, GangwayEventType.MessageRemoved, null, clearAlertMessage, null, null);
            if (workstation.ConnectionMode != ConnectionMode.Offline)
            {
                clearAlertMessage.PersonEvent = personEvent;
            }

            await GangwayRepositoryFactory.Retrieve().ClearPersonAlertAndMessageAsync(clearAlertMessage, AlertMessageStatusType.AcknowledgeMessage, personEvent);

            return await Task.FromResult(message);
        }
 private void person_OnShowMessage(Person person, PersonMessage personMessage)
 {
     person.Scenario.GameScreen.PersonShowMessage(person, personMessage);
 }
Beispiel #24
0
 public IResult Add(Person person)
 {
     _personDal.Add(person);
     return(new SuccessResult(PersonMessage.PersonAdd(person.FirstName)));
 }
Beispiel #25
0
 public IResult Delete(Person person)
 {
     _personDal.Delete(person);
     return(new SuccessResult(PersonMessage.PersonDelete(person.FirstName)));
 }
        /// <summary>
        ///登录
        /// </summary>
        /// <param name="ENo">员工号</param>
        /// <param name="Rpassword">密码</param>
        /// <returns></returns>
        public static LoginResult Login(string ENo, string Rpassword)
        {
            using (EFContext Context = new EFContext())
            {
                var jieguo = from s in Context.EmployeeInfo
                             select s;
                if (jieguo.FirstOrDefault() == null)
                {
                    EmployeeInfo employee = new EmployeeInfo()
                    {
                        ENo       = ENo,
                        EName     = "管理员",
                        Esex      = true,
                        Ephone    = "",
                        Eemail    = "",
                        EcardID   = Rpassword,
                        Ppassword = Rpassword.Substring(12),
                        Eheart    = "",
                        Pid       = 1
                    };
                    PositionInfo positionInfo = new PositionInfo()
                    {
                        PoName     = "超级管理员",
                        PoLeave    = 1,
                        PoMinMoney = 0,
                        Permission = "ALL"
                    };
                    PersonMessage personMessage = new PersonMessage()
                    {
                        EID         = 1,
                        PeBeginWork = DateTime.Now.ToString(),
                        PeEndwork   = "",
                        Pstatic     = true
                    };
                    DbEntityEntry <EmployeeInfo> entityEntry = Context.Entry <EmployeeInfo>(employee);
                    entityEntry.State = System.Data.Entity.EntityState.Added;
                    DbEntityEntry <PositionInfo> entityEn = Context.Entry <PositionInfo>(positionInfo);
                    entityEn.State = System.Data.Entity.EntityState.Added;
                    DbEntityEntry <PersonMessage> person = Context.Entry <PersonMessage>(personMessage);
                    person.State = System.Data.Entity.EntityState.Added;
                    Context.SaveChanges();
                    Rpassword = Rpassword.Substring(12);
                    //"create trigger trigger_insert on employeeinfo for insert as insert into PersonMessage values(@@IDENTITY,CONVERT(varchar(12) , getdate(), 111 ),'',1)"
                }

                var result = (from a in Context.EmployeeInfo
                              join b in Context.PositionInfo
                              on a.Pid equals b.PoID
                              join c in Context.PersonMessage
                              on a.EID equals c.EID
                              where a.ENo.Equals(ENo) && a.Ppassword.Equals(Rpassword)
                              select new
                {
                    name = a.EName,
                    Eid = a.EID,
                    Pstats = c.Pstatic,
                    ENo = a.ENo,
                    PoName = b.PoName,
                    permissins = b.Permission
                }).ToList().FirstOrDefault();
                LoginResult loginResult = new LoginResult();
                if (result == null)
                {
                    loginResult.Result = false;
                }
                else
                {
                    if (result.Pstats)
                    {
                        loginResult.Result     = true;
                        loginResult.EID        = result.Eid;
                        loginResult.EName      = result.name.ToString();
                        loginResult.ENo        = result.ENo.ToString();
                        loginResult.PoName     = result.PoName.ToString();
                        loginResult.Permissins = result.permissins.ToString();
                    }
                    else
                    {
                        loginResult.Result = false;
                    }
                }
                return(loginResult);
            }
        }
 public void Handle(PersonMessage message)
 {
     throw new NotSupportedException();
 }
        /// <summary>
        /// Called when [acknowledgement completed].
        /// </summary>
        /// <param name="message">The message.</param>
        private void OnAcknowledgementCompleted(PersonMessage message)
        {
            this.IsBusy = false;
            message.StatusId = CommonConstants.MessageAcknowledgeStatusId;

            this.RefreshMessages();
            message.NotifyPropertyChange(StatusIdText);
            if (this.SelectedPerson.AreAllMessagesGotAcknowledged)
            {
                this.CloseView();
            }
        }
        /// <summary>
        /// Maps the message data.
        /// </summary>
        /// <param name="alertCollection">The alert collection.</param>
        /// <returns>Message data</returns>
        private static Message MapMessageData(AlertTypeCollection alertCollection)
        {
            var messageData = new Message();

            foreach (var message in alertCollection)
            {
                messageData.Description = message.Description;
                messageData.DueDate = message.DueDate;
                messageData.Name = message.Description;
                messageData.ExpiryDate = message.ExpiryDate;
                messageData.MessageFrom = message.MessageFrom;
                messageData.IsSoundEnable = message.IsSoundEnable;

                foreach (var personMessage in message.Alerts)
                {
                    var personMessageData = new PersonMessage();
                    personMessageData.MessageId = personMessage.AlertTypeId;
                    personMessageData.PersonId = personMessage.PersonId;
                    personMessageData.PersonTypeId = personMessage.PersonTypeId;
                    personMessageData.ShipId = personMessage.ShipId;
                    personMessageData.VoyageId = personMessage.VoyageId;

                    if (!string.IsNullOrEmpty(personMessage.StatusId) && personMessage.StatusId.Equals("2"))
                    {
                        personMessageData.StatusId = personMessage.StatusId;
                    }
                    else
                    {
                        personMessageData.StatusId = "1";
                    }

                    messageData.PersonMessages.Add(personMessageData);
                }

                var applicationId = new AlertTargetApplication();

                applicationId.ApplicationId = message.ApplicationId;

                messageData.AlertTargetApplications.Add(applicationId);

                if (!string.IsNullOrEmpty(message.AlertTypeId))
                {
                    messageData.MessageId = message.AlertTypeId;
                    messageData.LastModifiedBy = message.ModifiedBy;
                }
                else
                {
                    messageData.AddedBy = message.AddedBy;
                }
            }

            return messageData;
        }
 /// <summary>
 /// Acknowledges the person message.
 /// </summary>
 /// <param name="message">The message.</param>
 private void AcknowledgePersonMessage(PersonMessage message)
 {
     this.IsBusy = true;
     ObservableManager.RunObservable(() => this.Acknowledge(message), () => this.OnAcknowledgementCompleted(message), () => { this.IsBusy = false; });
 }
Beispiel #31
0
 public void ShowPersonMessage(PersonMessage personMessage)
 {
     bool flag = true;
     if ((this.BelongedFaction != null) && (personMessage is SpyMessage))
     {
         SpyMessage sm = personMessage as SpyMessage;
         Point key = new Point(sm.MessageArchitecture.ID, (int) sm.Kind);
         if (!this.BelongedFaction.SpyMessageCloseList.ContainsKey(key))
         {
             this.HandleSpyMessage(sm);
             this.BelongedFaction.SpyMessageCloseList.Add(key, null);
         }
         else
         {
             flag = false;
         }
     }
     if (flag && (this.OnShowMessage != null))
     {
         this.OnShowMessage(this, personMessage);
     }
 }
 /// <summary>
 /// Called when [acknowledgment completed].
 /// </summary>
 /// <param name="message">The message.</param>
 private void OnAcknowledgementCompleted(PersonMessage message)
 {
     Messenger.Instance.Notify(MessengerMessage.ShowSpinWheel, false);
     
     message.StatusId = SuccessStatusId;
     message.NotifyPropertyChange(StatusIdText);
     this.RefreshMessages();
 }