Exemplo n.º 1
0
        public void SendTest()
        {
            //var notificationMsg = new NotificationMsg()
            //{
            //    FlowCode = FlowCode.Reimage_ConsInfo,
            //    ProjectId = "Reimage14111201",
            //    SenderCode = "E5004654",
            //    RefId = Guid.NewGuid(),
            //    IsSendEmail = false
            //};

            var notificationMsg = new NotificationMsg()
            {
                FlowCode    = FlowCode.Closure_LegalReview,
                ProjectId   = "Closure14111103",
                SenderCode  = "E5016672",
                RefId       = Guid.NewGuid(),
                IsSendEmail = false
            };

            notificationMsg.ReceiverCodeList = new List <string>()
            {
                "E5001301"
            };

            Notification.Send(notificationMsg);
        }
Exemplo n.º 2
0
        public static IQueryable <Notification> List(NotificationMsg message)
        {
            var predicate = PredicateBuilder.True <Notification>();

            if (!string.IsNullOrEmpty(message.FlowCode))
            {
                predicate = predicate.And(e => e.FlowCode == message.FlowCode);
            }

            if (!string.IsNullOrEmpty(message.ProjectId))
            {
                predicate = predicate.And(e => e.ProjectId == message.ProjectId);
            }

            if (!string.IsNullOrEmpty(message.SenderCode))
            {
                predicate = predicate.And(e => e.SenderCode == message.SenderCode);
            }

            if (message.ReceiverCodeList.Count > 0)
            {
                predicate = predicate.And(e => message.ReceiverCodeList.Contains(e.ReceiverCode));
            }

            if (message.RefId != Guid.Empty)
            {
                predicate = predicate.And(e => e.RefId == message.RefId);
            }

            var notifications = Search(predicate);

            return(notifications);
        }
        protected virtual void OprateNotificationMsg(NotificationMsg msg)
        {
            NRNotificationWindow prefab           = null;
            Notification         notification_obj = msg.notification;
            Level notification_level = msg.level;
            float duration           = TipsLastTime[notification_level];

            // Notification window will not be destroyed automatic when lowpower and high level warning
            // Set it's duration to -1
            if (notification_obj is LowPowerNotification)
            {
                prefab = LowPowerNotificationPrefab;
                if (notification_level == Level.High)
                {
                    duration = -1f;
                }
            }
            else if (notification_obj is SlamStateNotification)
            {
                prefab = SlamStateNotificationPrefab;
            }
            else if (notification_obj is TemperatureLevelNotification)
            {
                prefab = HighTempNotificationPrefab;
            }

            if (prefab != null)
            {
                NRDebugger.Log("[NRNotificationListener] Dispath:" + notification_obj.GetType().ToString());
                NRNotificationWindow notification = Instantiate(prefab);
                notification.gameObject.SetActive(true);
                notification.transform.SetParent(transform);
                notification.FillData(notification_level, duration);
            }
        }
        public NotificationBoxF(string label, NotificationMsg message)
        {
            InitializeComponent();

            color(message);
            lbl.Text = label;
        }
        public static DialogResult Show(Form owner, string text, int delay, NotificationMsg message, Position pos)
        {
            _owner = owner;

            PopupForm(_owner, text, delay, message, pos);
            return(DialogResult.OK);
        }
Exemplo n.º 6
0
        public static async Task PopupDelay(string label, int delay, NotificationMsg message)
        {
            NotificationBoxF box = new NotificationBoxF(label, message);

            box.Show();
            await Task.Delay(delay);

            box.Close();
        }
Exemplo n.º 7
0
        public static void Read(NotificationMsg message)
        {
            var notifications = List(message);

            foreach (var notification in notifications)
            {
                notification.HasRead = true;
            }
        }
        public NotificationBoxF(Form _owner, string label, NotificationMsg message, Position pos)
        {
            InitializeComponent();

            Owner = _owner;

            color(message, pos);

            lbl.Text = label;
        }
        public static async Task PopupDelay(Form _owner, string label, int delay, NotificationMsg message, Position pos)
        {
            NotificationBoxF box = new NotificationBoxF(_owner, label, message, pos);

            box.Show();

            await Task.Delay(delay);

            box.Close();
        }
Exemplo n.º 10
0
        public static void Send(NotificationMsg message)
        {
            using (var scope = new TransactionScope())
            {
                Guid?msgId = null;
                if (!string.IsNullOrEmpty(message.Message))
                {
                    var msg = new NotificationMessage {
                        Id = Guid.Empty, MessageContent = message.Message
                    };
                    msgId = msg.SaveMessage();
                }
                Mapper.CreateMap <NotificationMsg, Notification>();

                var notification = Mapper.Map <Notification>(message);
                notification.Title             = string.IsNullOrEmpty(message.Title) ? "无主题" : message.Title;
                notification.CreateTime        = DateTime.Now;
                notification.CreateUserAccount = ClientCookie.UserCode;
                notification.HasRead           = false;
                if (msgId.HasValue)
                {
                    notification.ContentId = msgId;
                }
                notification.IsSendEmail = message.IsSendEmail;

                //var flowOwnerCode = BaseWFEntity.GetProcessOwnerCode(message.FlowCode, message.ProjectId);

                if (message.ReceiverCodeList != null && message.ReceiverCodeList.Count != 0)
                {
                    //if (!string.IsNullOrEmpty(flowOwnerCode) && !message.ReceiverCodeList.Contains(flowOwnerCode))
                    //{
                    //    message.ReceiverCodeList.Add(flowOwnerCode);
                    //}
                    foreach (var receiverCode in message.ReceiverCodeList)
                    {
                        if (string.IsNullOrEmpty(receiverCode))
                        {
                            continue;
                        }
                        notification.ReceiverCode = receiverCode;
                        notification.Add();
                    }
                }

                scope.Complete();
            }
        }
Exemplo n.º 11
0
        public void color(NotificationMsg backgcl)
        {
            switch (backgcl)
            {
            case NotificationMsg.OK:
                this.BackColor = System.Drawing.Color.DarkGreen;
                break;

            case NotificationMsg.ERROR:
                this.BackColor = System.Drawing.Color.DarkRed;
                break;

            case NotificationMsg.DONE:
                this.BackColor = System.Drawing.Color.IndianRed;
                break;
            }
        }
Exemplo n.º 12
0
        private void NoticeToActor(string strAssetActorAccount, string usCode)
        {
            //通知Asset Actor
            var consinfo = FirstOrDefault(i => i.ProjectId == ProjectId && i.IsHistory);

            if (consinfo != null)
            {
                List <string> receiverList = new List <string>();
                receiverList.Add(strAssetActorAccount);
                var notificationMsg = new NotificationMsg()
                {
                    FlowCode         = FlowCode.Renewal_ConsInfo,
                    ProjectId        = ProjectId,
                    SenderCode       = ClientCookie.UserCode,
                    Title            = "Renewal ConsInfo已经重新编辑",
                    RefId            = consinfo.Id,
                    UsCode           = usCode,
                    IsSendEmail      = false,
                    ReceiverCodeList = receiverList
                };
                Notification.Send(notificationMsg);
            }
        }
        public void color(NotificationMsg backgcl, Position screenpos)
        {
            switch (backgcl)
            {
            case NotificationMsg.OK:
                this.BackColor = System.Drawing.Color.DarkGreen;
                break;

            case NotificationMsg.ERROR:
                this.BackColor = System.Drawing.Color.DarkRed;
                break;

            case NotificationMsg.DONE:
                this.BackColor = System.Drawing.Color.IndianRed;
                break;
            }

            switch (screenpos)
            {
            case Position.Center:
                this.StartPosition = FormStartPosition.CenterScreen;
                break;

            case Position.Parent:
                this.StartPosition = FormStartPosition.Manual;

                if (Owner != null)
                {
                    Location = new Point(Owner.Location.X + Owner.Width / 2 - Width / 2,
                                         Owner.Location.Y + Owner.Height / 2 - Height / 2);
                }

                //this.StartPosition = FormStartPosition.CenterParent;
                break;
            }
        }
Exemplo n.º 14
0
 public static async void PopupForm(string label, int delay = 4000, NotificationMsg message = NotificationMsg.OK)
 {
     await PopupDelay(label, delay, message);
 }
        public IHttpActionResult SendMsg(NotificationMsg msg)
        {
            using (var scope = new TransactionScope())
            {
                Notification.Send(msg);
                if (msg.IsSendEmail)
                {
                    //邮件模板中的数据
                    Dictionary <string, string> bodyValues = new Dictionary <string, string>();
                    if (string.IsNullOrEmpty(msg.UsCode))
                    {
                        var projectInfo = ProjectInfo.FirstOrDefault(e => e.ProjectId == msg.ProjectId);
                        if (projectInfo != null)
                        {
                            msg.UsCode = projectInfo.USCode;
                        }
                    }
                    var stor = StoreBasicInfo.GetStorInfo(msg.UsCode);
                    bodyValues.Add("ApplicantName", ClientCookie.UserNameENUS);//--提交人
                    bodyValues.Add("StoreCode", stor.StoreCode);
                    bodyValues.Add("StoreName", stor.NameENUS);
                    bodyValues.Add("Comments", msg.Message);
                    var actor = ProjectUsers.GetProjectUser(msg.ProjectId, ProjectUserRoleCode.AssetActor);
                    bodyValues.Add("Actor", actor.RoleNameENUS);////--呈递人
                    var flow = FlowInfo.Get(msg.FlowCode);
                    if (flow != null)
                    {
                        bodyValues.Add("WorkflowName", flow.NameENUS); ////--流程名称
                    }
                    if (msg.ProjectId.ToLower().IndexOf("rebuild") >= 0)
                    {
                        bodyValues.Add("ProjectName", Constants.Rebuild); //项目名称
                    }
                    else if (msg.ProjectId.ToLower().IndexOf("reimage") >= 0)
                    {
                        bodyValues.Add("ProjectName", Constants.Reimage); //项目名称
                    }
                    else if (msg.ProjectId.ToLower().IndexOf("closure") >= 0)
                    {
                        bodyValues.Add("ProjectName", Constants.Closure); //项目名称
                    }
                    else if (msg.ProjectId.ToLower().IndexOf("renewal") >= 0)
                    {
                        bodyValues.Add("ProjectName", "Renewal"); //项目名称
                    }
                    else if (msg.ProjectId.ToLower().IndexOf("majorlease") >= 0)
                    {
                        bodyValues.Add("ProjectName", "MajorLease"); //项目名称
                    }
                    else
                    {
                        bodyValues.Add("ProjectName", Constants.TempClosure);//项目名称
                    }
                    string viewPage = "";
                    if (!string.IsNullOrEmpty(msg.FlowCode))
                    {
                        var tmp = msg.FlowCode.Split('_');
                        if (tmp[0] == "Rebuild" && tmp[1] == "Package")
                        {
                            tmp[1] = "RebuildPackage";
                        }
                        viewPage = string.Format("{0}/{1}/Main#/{2}/Process/View?projectId={3}",
                                                 ConfigurationManager.AppSettings["webHost"], tmp[0], tmp[1], msg.ProjectId);
                    }

                    bodyValues.Add("FormUrl", viewPage);

                    var Receivers = Employee.GetSimpleEmployeeByCodes(msg.ReceiverCodeList.ToArray());
                    //调用邮件服务发送邮件
                    EmailSendingResultType result;
                    using (EmailServiceClient client = new EmailServiceClient())
                    {
                        EmailMessage  message = new EmailMessage();
                        StringBuilder sbTo    = new StringBuilder();
                        Dictionary <string, string> attachments = new Dictionary <string, string>();
                        foreach (var emp in Receivers)
                        {
                            if (sbTo.Length > 0)
                            {
                                sbTo.Append(";");
                            }
                            if (!string.IsNullOrEmpty(emp.Mail))
                            {
                                sbTo.Append(emp.Mail);
                            }
                        }
                        if (sbTo.Length > 0)
                        {
                            sbTo.Append(";");
                        }
                        message.EmailBodyValues = bodyValues;
                        message.To           = sbTo.ToString();
                        message.TemplateCode = EmailTemplateCode.Notification;
                        result = client.SendNotificationEmail(message);
                    }

                    if (!result.Successful)
                    {
                        return(BadRequest(result.ErrorMessage));
                    }
                }
                scope.Complete();
            }
            return(Ok());
        }
Exemplo n.º 16
0
 public Task SendAsync(NotificationMsg message)
 {
     return(Task.CompletedTask);
 }
Exemplo n.º 17
0
 public static DialogResult Show(string text, int delay, NotificationMsg message)
 {
     PopupForm(text, delay, message);
     return(DialogResult.OK);
 }
 public static async void PopupForm(Form _owner, string label, int delay = 4000, NotificationMsg message = NotificationMsg.OK, Position pos = Position.Center)
 {
     await PopupDelay(_owner, label, delay, message, pos);
 }
 public static DialogResult Show(string text, int delay, NotificationMsg message)
 {
     PopupForm(null, text, delay, message, Position.Center);
     return(DialogResult.OK);
 }