Ejemplo n.º 1
0
        private void NotifySummaryTappedMethod(NotifyItem item)
        {
            if (item == null || MainStatus == null)
            {
                return;
            }

            HasReadNotifyItem(item);

            if (MainStatus.IsWide)
            {
                SystemNavigationManager.GetForCurrentView().BackRequested -= NotePage_BackRequested;
            }
            else
            {
                if (this.MainStatus.NavFrame.CanGoBack)
                {
                    this.MainStatus.NavFrame.GoBack();
                }
            }

            if ("question" == item.Target.Type && item.Answer != null)
            {
                NavHelper.NavToAnswerPage(item.Answer.Id, MainStatus.NavFrame);
            }
            if ("answer" == item.Target.Type)
            {
                NavHelper.NavToAnswerPage(item.Target.GetId(), MainStatus.NavFrame);
            }
        }
Ejemplo n.º 2
0
        private void notifyIcon1_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.ContextMenuStrip contextMenu = new ContextMenuStrip();


            var item1 = new ToolStripMenuItem("メイン画面を開く");

            item1.Click += notifyIcon1_MouseDoubleClick;

            var sepator = new ToolStripSeparator();

            foreach (string adapter in _adapters)
            {
                var it = new ToolStripMenuItem(adapter);
                for (int i = 0; i < ConfigList.GetInstance().GetNames().Length; i++)
                {
                    string name = ConfigList.GetInstance().GetNames()[i];
                    var    ni   = new NotifyItem(name)
                    {
                        Id = i, Nic = adapter
                    };
                    ni.Click += DropDownClick;
                    it.DropDownItems.Add(ni);
                }
                contextMenu.Items.Add(it);
            }

            contextMenu.Items.Add(sepator);
            contextMenu.Items.Add(item1);

            notifyIcon1.ContextMenuStrip = contextMenu;
        }
Ejemplo n.º 3
0
        public void SendNoticeToAsync(INotifyAction action, string objectID, IRecipient[] recipients, string[] senderNames, bool checkSubsciption, params ITagValue[] args)
        {
            var item = new NotifyItem
            {
                TenantId         = TenantManager.GetCurrentTenant().TenantId,
                UserId           = AuthContext.CurrentAccount.ID.ToString(),
                Action           = (NotifyAction)action,
                CheckSubsciption = checkSubsciption,
                BaseUrl          = CommonLinkUtility.GetFullAbsolutePath("")
            };

            if (objectID != null)
            {
                item.ObjectID = objectID;
            }

            if (recipients != null)
            {
                foreach (var r in recipients)
                {
                    var recipient = new Recipient {
                        ID = r.ID, Name = r.Name
                    };
                    if (r is IDirectRecipient d)
                    {
                        recipient.Addresses.AddRange(d.Addresses);
                        recipient.CheckActivation = d.CheckActivation;
                    }

                    if (r is IRecipientsGroup g)
                    {
                        recipient.IsGroup = true;
                    }

                    item.Recipients.Add(recipient);
                }
            }

            if (senderNames != null)
            {
                item.SenderNames.AddRange(senderNames);
            }

            if (args != null)
            {
                item.Tags.AddRange(args.Select(r => new Tag {
                    Tag_ = r.Tag, Value = r.Value.ToString()
                }));
            }

            Cache.Publish(item, CacheNotifyAction.Any);
        }
Ejemplo n.º 4
0
        private void NotifyTitleTappedMethod(NotifyItem item)
        {
            if (item == null || MainStatus == null)
            {
                return;
            }

            HasReadNotifyItem(item);

            if ("question" == item.Target.Type)
            {
                NavHelper.NavToQuestionPage(item.Target.GetId(), AppShellPage.AppFrame);
                SystemNavigationManager.GetForCurrentView().BackRequested -= NotePage_BackRequested;
            }
            else if ("answer" == item.Target.Type)
            {
                if (MainStatus.IsWide)
                {
                    SystemNavigationManager.GetForCurrentView().BackRequested -= NotePage_BackRequested;
                }
                else
                {
                    if (this.MainStatus.NavFrame.CanGoBack)
                    {
                        this.MainStatus.NavFrame.GoBack();
                    }
                }
                NavHelper.NavToQuestionPage(item.Target.Question.Id, MainStatus.NavFrame);
            }
            else if ("article" == item.Target.Type)
            {
                if (MainStatus.IsWide)
                {
                    SystemNavigationManager.GetForCurrentView().BackRequested -= NotePage_BackRequested;
                }
                else
                {
                    if (this.MainStatus.NavFrame.CanGoBack)
                    {
                        this.MainStatus.NavFrame.GoBack();
                    }
                }
                NavHelper.NavToArticlePage(item.Target.GetId(), MainStatus.NavFrame);
            }
            else if ("column" == item.Target.Type)
            {
                NavHelper.NavToColumnPage(item.Target.Id, AppShellPage.AppFrame);
                SystemNavigationManager.GetForCurrentView().BackRequested -= NotePage_BackRequested;
            }
        }
Ejemplo n.º 5
0
        public void OnMessage(NotifyItem item)
        {
            using var scope = ServiceProvider.CreateScope();
            var tenantManager       = scope.ServiceProvider.GetService <TenantManager>();
            var userManager         = scope.ServiceProvider.GetService <UserManager>();
            var securityContext     = scope.ServiceProvider.GetService <SecurityContext>();
            var authContext         = scope.ServiceProvider.GetService <AuthContext>();
            var studioNotifyHelper  = scope.ServiceProvider.GetService <StudioNotifyHelper>();
            var displayUserSettings = scope.ServiceProvider.GetService <DisplayUserSettings>();

            tenantManager.SetCurrentTenant(item.TenantId);
            CultureInfo culture = null;

            var client = WorkContext.NotifyContext.NotifyService.RegisterClient(studioNotifyHelper.NotifySource, scope);

            var tenant = tenantManager.GetCurrentTenant(false);

            if (tenant != null)
            {
                culture = tenant.GetCulture();
            }

            if (Guid.TryParse(item.UserId, out var userId) && !userId.Equals(Constants.Guest.ID) && !userId.Equals(Guid.Empty))
            {
                securityContext.AuthenticateMe(Guid.Parse(item.UserId));
                var user = userManager.GetUsers(userId);
                if (!string.IsNullOrEmpty(user.CultureName))
                {
                    culture = CultureInfo.GetCultureInfo(user.CultureName);
                }
            }

            if (culture != null && !Equals(Thread.CurrentThread.CurrentCulture, culture))
            {
                Thread.CurrentThread.CurrentCulture = culture;
            }
            if (culture != null && !Equals(Thread.CurrentThread.CurrentUICulture, culture))
            {
                Thread.CurrentThread.CurrentUICulture = culture;
            }

            client.SendNoticeToAsync(
                (NotifyAction)item.Action,
                item.ObjectID,
                item.Recipients?.Select(r => r.IsGroup ? new RecipientsGroup(r.ID, r.Name) : (IRecipient) new DirectRecipient(r.ID, r.Name, r.Addresses.ToArray(), r.CheckActivation)).ToArray(),
                item.SenderNames.Any() ? item.SenderNames.ToArray() : null,
                item.CheckSubsciption,
                item.Tags.Select(r => new TagValue(r.Tag_, r.Value)).ToArray());
        }
Ejemplo n.º 6
0
        internal void ShowPlaceholder(NotifyItem notify)
        {
            Notify = notify;

            this.Author.Opacity = 0;

            this.Verb.Opacity = 0;

            this.Title.Opacity = 0;

            this.SummaryContainer.Visibility = Visibility.Collapsed;
            //this.BackgroundBorder.Visibility = _notify.IsRead == true ? Visibility.Collapsed : Visibility.Visible;

            this.DataContext = this;
        }
Ejemplo n.º 7
0
        public void OnMessageGenerated(MessageCat messageCat, NotifyItem item)
        {
            object obj;

            switch (messageCat)
            {
            case MessageCat.NewTaskNormal:
            case MessageCat.TimeoutNotify:
            case MessageCat.RecedeBack:
            case MessageCat.IndicateTask:
            case MessageCat.InformTask:
            case MessageCat.ManualRemind:
                obj = new
                {
                    Version    = 1.0,
                    MessageCat = messageCat,
                    Type       = "Task.Process",
                    StepID     = Context.Current.Step.StepID
                };
                break;

            case MessageCat.Approved:
            case MessageCat.Rejected:
            case MessageCat.Aborted:
            case MessageCat.Deleted:
            case MessageCat.StepStopHumanOpt:
            case MessageCat.StepStopVoteFinished:
            case MessageCat.NoParticipantException:
                obj = new
                {
                    Version    = 1.0,
                    MessageCat = messageCat,
                    Type       = "Task.Read",
                    TaskID     = Context.Current.Task.TaskID
                };
                break;

            default:
                obj = null;
                break;
            }
            if (obj == null)
            {
                item.Extra = null;
                return;
            }
            item.Extra = JObject.FromObject(obj).ToString(Newtonsoft.Json.Formatting.None, null);
        }
Ejemplo n.º 8
0
        internal void Clear()
        {
            this.Notify = null;

            this.Author.ClearValue(TextBlock.TextProperty);
            this.Verb.ClearValue(TextBlock.TextProperty);

            this.Title.ClearValue(TextBlock.TextProperty);

            this.VoteCount.ClearValue(TextBlock.TextProperty);
            this.Summary.ClearValue(TextBlock.TextProperty);

            this._authorTapped  = null;
            this._titleTapped   = null;
            this._summaryTapped = null;
        }
Ejemplo n.º 9
0
        public static string CmdCallCodeByServer(NotifyItem item)
        {
            return($@"
/** 
* @brief {item.Caption}
* @param {{PNetCommand}} cmd_arg 命令对象
* @return 无
*/
void GbsNotify::{item.Name}(const PNetCommand cmd_arg)
{{
	COMMAND_STATE state = NET_COMMAND_STATE_SUCCEED;
	try
	{{
        {item.Name}Business business;
		state = business.initialization(cmd_arg);
		if (state != NET_COMMAND_STATE_SUCCEED)
		{{
            publish_command_state(cmd_arg, state);
			return;
		}}
		state = business.verify();
		if (state != NET_COMMAND_STATE_SUCCEED)
		{{
            publish_command_state(cmd_arg, state);
			return;
		}}
		state = business.prepare();
		if (state != NET_COMMAND_STATE_SUCCEED)
		{{
            publish_command_state(cmd_arg, state);
			return;
		}}
		state = business.doit();
		business.doit();
		if (state != NET_COMMAND_STATE_SUCCEED)
		{{
            publish_command_state(cmd_arg, state);
			return;
		}}
	}}
	catch (...)
	{{
        state = NET_COMMAND_STATE_SERVER_UNKNOW;
	}}
	publish_command_state(cmd_arg, state);
}}");
        }
Ejemplo n.º 10
0
        private async void DismissContentNotifyMethod(NotifyItem notifyItem)
        {
            if (null == _notify)
            {
                return;
            }

            var result = await _notify.DismissContentNotifyAsync(LoginUser.Current.Token, notifyItem.Id);

            if (result.Error != null)
            {
                ToasteIndicator.Instance.Show(String.Empty, result.Error.Message, null, 3);
                return;
            }

            notifyItem.IsRead = result.Result.IsRead;
        }
Ejemplo n.º 11
0
        private void HasReadNotifyItem(NotifyItem item)
        {
            var mainVm = this.DataContext as MainViewModel;

            if (mainVm == null)
            {
                return;
            }

            var notifyVm = mainVm.Notify as NotifyViewModel;

            if (notifyVm == null)
            {
                return;
            }

            if (notifyVm.DismissContentNotify.CanExecute(item))
            {
                notifyVm.DismissContentNotify.Execute(item);
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Odesle postupne vsechny notifikace co jsou ve fronte.
        /// </summary>
        /// <returns></returns>
        public async Task SendAllNotifications()
        {
            NotifyItem notifyItem = await queue.PopAsync <NotifyItem>(QueueType.Notification);

            while (notifyItem != null)
            {
                switch (notifyItem.ChannelType)
                {
                case ChannelType.Email:
                    await emailNotificator.SendEmailAsync(notifyItem.Contact, notifyItem.Subject, notifyItem.Message);

                    break;

                default:
                    logger.LogError($"Notificaiton sending for '{notifyItem.ChannelType}' not implemented yet.");
                    break;
                }

                notifyItem = await queue.PopAsync <NotifyItem>(QueueType.Notification);
            }
        }
Ejemplo n.º 13
0
        private void NotifyAuthorTappedMethod(NotifyItem item)
        {
            if (item == null || MainStatus == null)
            {
                return;
            }

            if (MainStatus.IsWide)
            {
                SystemNavigationManager.GetForCurrentView().BackRequested -= NotePage_BackRequested;
            }
            else
            {
                if (this.MainStatus.NavFrame.CanGoBack)
                {
                    this.MainStatus.NavFrame.GoBack();
                }
            }

            NavHelper.NavToProfilePage(item.Operators[0].Id, MainStatus.NavFrame);
        }
        private NotifyItem CheckNotifyItem(string line)
        {
            NotifyItem item = new NotifyItem();
            var        strs = line.Split(new[] { '(' }, 2, StringSplitOptions.RemoveEmptyEntries);

            //检查API名称
            item.Name = strs[0].Split(CoderBase.EmptyChar, StringSplitOptions.RemoveEmptyEntries).Last();
            //参数检查(第一个)
            var words = strs[1].Split(CoderBase.NoneLanguageChar, StringSplitOptions.RemoveEmptyEntries);

            foreach (var word in words)
            {
                switch (word)
                {
                case "virtual":
                case "void":
                case "__cdecl":
                case "const":
                case "int":
                case "ESForeign":
                case "TEsIsLastType":
                    continue;

                case "islast":
                    item.IsMulit = true;
                    continue;

                case "errCode":
                case "iReqID":
                    item.IsCommandResult = true;
                    continue;
                }
                if (item.NotifyEntity == null)
                {
                    item.NotifyEntity = word;
                }
            }
            return(item);
        }
Ejemplo n.º 15
0
        public void OnMessage(NotifyItem item)
        {
            CoreContext.TenantManager.SetCurrentTenant(item.TenantId);
            CultureInfo culture = null;

            var tenant = CoreContext.TenantManager.GetCurrentTenant(false);

            if (tenant != null)
            {
                culture = tenant.GetCulture();
            }

            if (Guid.TryParse(item.UserId, out var userId) && !userId.Equals(Constants.Guest.ID) && !userId.Equals(Guid.Empty))
            {
                SecurityContext.AuthenticateMe(item.TenantId, userId);
                var user = CoreContext.UserManager.GetUsers(item.TenantId, userId);
                if (!string.IsNullOrEmpty(user.CultureName))
                {
                    culture = CultureInfo.GetCultureInfo(user.CultureName);
                }
            }

            if (culture != null && !Equals(Thread.CurrentThread.CurrentCulture, culture))
            {
                Thread.CurrentThread.CurrentCulture = culture;
            }
            if (culture != null && !Equals(Thread.CurrentThread.CurrentUICulture, culture))
            {
                Thread.CurrentThread.CurrentUICulture = culture;
            }

            client.SendNoticeToAsync(
                (NotifyAction)item.Action,
                item.ObjectID,
                item.Recipients?.Select(r => r.IsGroup ? new RecipientsGroup(r.ID, r.Name) : (IRecipient) new DirectRecipient(r.ID, r.Name, r.Addresses.ToArray(), r.CheckActivation)).ToArray(),
                item.SenderNames.Any() ? item.SenderNames.ToArray() : null,
                item.CheckSubsciption,
                item.Tags.Select(r => new TagValue(r.Tag_, r.Value)).ToArray());
        }
        private void AddNotification(RequestActionEventArgs args)
        {
            List <KeyValuePair <string, string> > parms = Utility.SplitLines(args.Data, CurrentContext, localSessionManager);
            string     text         = Utility.GetAndRemoveParameter(parms, "text");
            string     milliseconds = Utility.GetAndRemoveParameter(parms, "milliseconds");
            NotifyItem item         = new NotifyItem();
            TextBlock  tb           = new TextBlock();

            tb.Text             = text;
            item.animatedObject = tb;
            int result;

            if (int.TryParse(milliseconds, out result))
            {
                item.timeout = DateTime.Now + TimeSpan.FromMilliseconds(result);
            }
            lock (notifyItems)
                notifyItems.Add(item);
            if (notifyItems.Count == 1)
            {
                SetMarqueeText();
            }
        }
Ejemplo n.º 17
0
 public NotifyItemResult(NotifyItem answer)
 {
     Result = answer;
 }
Ejemplo n.º 18
0
        private static void NotifyBusinessCppCode(NotifyItem item)
        {
            var           entity = item.LocalEntity;
            StringBuilder code   = new StringBuilder();

            code.Append($@"#include ""stdafx.h""
#include ""{item.Name}Business.h""
namespace GBS
{{
    namespace Futures
    {{
        namespace TradeManagement
        {{
            /** 
            * @brief 构造
            */
		    {item.Name}Business::{item.Name}Business()
			:m_call_arg(nullptr)
            {{
            }}

            /** 
            * @brief 析构
            */
            {item.Name}Business::~{item.Name}Business()
            {{
            }}

            /** 
            * @brief 初始化
            * @return 错误代号,NET_COMMAND_STATE_SUCCEED表示成功
            */
            COMMAND_STATE {item.Name}Business::initialization(PNetCommand cmd_arg)
            {{
                m_call_arg = cmd_arg;");
            if (entity != null)
            {
                code.Append(@"
                cmd_arg >> m_field;
                save_to_redis(&m_field);");
            }
            code.Append($@"
                return NET_COMMAND_STATE_SUCCEED;
            }}

            /** 
            * @brief 数据校验
            * @return 错误代号,NET_COMMAND_STATE_SUCCEED表示成功
            */
            COMMAND_STATE {item.Name}Business::verify()
            {{
                return NET_COMMAND_STATE_SUCCEED;
            }}

            /** 
            * @brief 准备执行
            * @return 错误代号,NET_COMMAND_STATE_SUCCEED表示成功
            */
            COMMAND_STATE {item.Name}Business::prepare()
            {{
                return NET_COMMAND_STATE_SUCCEED;
            }}

            /** 
            * @brief 执行动作(默认实现原样发到交易端)
            * @return 错误代号,NET_COMMAND_STATE_SUCCEED表示成功
            */
            COMMAND_STATE {item.Name}Business::doit()
            {{
                PNetCommand es_cmd_arg = new NetCommand();");
            if (entity != null)
            {
                code.Append(@"
                es_cmd_arg << m_field;");
            }
            code.Append(@"
                memcpy(es_cmd_arg, m_call_arg, NETCOMMAND_HEAD_LEN);
                server_message_send(es_cmd_arg);
                return NET_COMMAND_STATE_SUCCEED;
            }
        }
    }
}");
            FileCoder.WriteFile($@"c:\work\SharpCode\GbsNotify\{item.Name}Business.cpp", code.ToString());
        }
Ejemplo n.º 19
0
        private static void NotifyBusinessHCode(NotifyItem item)
        {
            var entity = item.LocalEntity;
            var code   = new StringBuilder();

            code.Append($@"#ifndef _{item.Name.ToUpper()}_BUSINESS_H
#define _{item.Name.ToUpper()}_BUSINESS_H
#pragma once
#include <stdafx.h>
#include <GbsBusiness/entity_redis.h>");

            if (entity != null)
            {
                code.Append($@"
#include <{entity.Parent.Name}/{entity.Name}.h>
using namespace {entity.Parent.NameSpace.Replace(".", "::")};");
            }

            code.Append($@"
namespace GBS
{{
	namespace Futures
	{{
		namespace TradeManagement
		{{
            /** 
            * @brief {item.Caption}逻辑处理类
            * @return 无
            */
			class {item.Name}Business
			{{"            );
            if (entity != null)
            {
                code.Append($@"
                //解析后的参数
				{entity.Name} m_field;"                );
            }
            code.Append($@"
                //原始调用参数
				PNetCommand m_call_arg;
			public:
                /** 
                * @brief 构造
                */
				{item.Name}Business();
                /** 
                * @brief 析构
                */
				~{item.Name}Business();
                /** 
                * @brief 初始化
                * @return 错误代号,NET_COMMAND_STATE_SUCCEED表示成功
                */
				COMMAND_STATE initialization(PNetCommand cmd_arg);
                /** 
                * @brief 数据校验
                * @return 错误代号,NET_COMMAND_STATE_SUCCEED表示成功
                */
				COMMAND_STATE verify();
                /** 
                * @brief 准备执行
                * @return 错误代号,NET_COMMAND_STATE_SUCCEED表示成功
                */
				COMMAND_STATE prepare();
                /** 
                * @brief 执行动作
                * @return 错误代号,NET_COMMAND_STATE_SUCCEED表示成功
                */
				COMMAND_STATE doit();
			}};
		}}
	}}
}}
#endif");
            FileCoder.WriteFile($@"c:\work\SharpCode\GbsNotify\{item.Name}Business.h", code.ToString());
        }