예제 #1
0
 public Task AddMsgInfo(long id, MsgTypes msgType, UserMsgInfo info)
 {
     return(Task.WhenAll(_redis.AddZsetValueAsync(KeyGenHelper.GenUserKey(id, "MsgIds", msgType.ToString()),
                                                  info.MsgId, DateTime.Now.ToTimeStamp(), TimeSpan.FromDays(30)),
                         _redis.AddHashValueAsync(KeyGenHelper.GenUserKey(id, "Msgs", msgType.ToString()),
                                                  info.MsgId, info, TimeSpan.FromDays(30)), DeleteExpiredMsgs(id, msgType)));
 }
 public SubscriptionCallbackHelper(MsgTypes t, CallbackDelegate <M> cb)
 {
     //EDB.WriteLine("SubscriptionCallbackHelper: type and callbackdelegate constructor");
     type = t;
     base.callback(new Callback <M>(cb));
     //if you think about this one too hard, you might die.
 }
예제 #3
0
        public void MsgWriteLine(MsgTypes type, string format, params object[] args)
        {
            string line = String.Format(format, args);
            var    r    = new Run()
            {
                Text = line, FontSize = 12
            };

            switch (type)
            {
            case MsgTypes.Normal:
                break;

            case MsgTypes.Error:
                r.Background = Brushes.Red;
                r.Foreground = Brushes.White;
                break;

            case MsgTypes.Warning:
                r.Background = Brushes.Yellow;
                r.Foreground = Brushes.Black;
                break;
            }

            //text.Inlines.Add(r);
            //text.Inlines.Add(new LineBreak());

            //Paragraph p = new Paragraph();
            //p.Inlines.Add(r);
            Paragraph p = text.Document.Blocks.FirstBlock as Paragraph;

            p.Inlines.Add(r);
            p.Inlines.Add(new LineBreak());
        }
예제 #4
0
        /// <summary>
        /// Handles registration response.
        /// </summary>
        private void MessageHandler(int typeValue, object message)
        {
            MsgTypes msgType = (MsgTypes)typeValue;

            if (!regFail)
            {
                if (!Registered)
                {
                    if ((msgType == MsgTypes.RegistrationSuccessful) && message is ServerData)
                    {
                        var data = (ServerData)message;
                        UnregisterAction = data.Item1;
                        GetApiDataFunc   = data.Item2;

                        registered = true;

                        ExceptionHandler.Run(InitAction);
                        ExceptionHandler.WriteToLog($"[RHF] Successfully registered with Rich HUD Master.");
                    }
                    else if (msgType == MsgTypes.RegistrationFailed)
                    {
                        if (message is string)
                        {
                            ExceptionHandler.WriteToLog($"[RHF] Failed to register with Rich HUD Master. Message: {message as string}");
                        }
                        else
                        {
                            ExceptionHandler.WriteToLog($"[RHF] Failed to register with Rich HUD Master.");
                        }

                        regFail = true;
                    }
                }
            }
        }
예제 #5
0
        public static BaseMessageHandler GetHandler(MsgTypes msgType)
        {
            BaseMessageHandler handler = null;

            switch (msgType)
            {
            case MsgTypes.Email:
                handler = new EmailMessageHandler();
                break;

            case MsgTypes.Txt:
                handler = new TxtMessageHandler();
                break;

            case MsgTypes.QQ:
                handler = new QQMessageHandler();
                break;

            case MsgTypes.SMS:
                handler = new SmsMessageHandler();
                break;

            case MsgTypes.WeChat:
                handler = new WeChatMessageHandler();
                break;
            }
            return(handler);
        }
예제 #6
0
        public static FieldInfo[] GetFields(Type T, ref object instance, out IRosMessage msg)
        {
            if (instance == null)
            {
                if (T.IsArray)
                {
                    instance = Array.CreateInstance(T.GetElementType(), 0);
                }
                else
                {
                    instance = Activator.CreateInstance(T);
                }
            }
            IRosMessage MSG = instance as IRosMessage;

            if (MSG == null)
            {
                msg = MSG;
                return(instance.GetType().GetFields());
            }
            MsgTypes MT = MSG.msgtype;

            if (MT != MsgTypes.Unknown)
            {
                msg = MSG;
                return(msg.GetType().GetFields().Where((fi => MSG.Fields.Keys.Contains(fi.Name) && !fi.IsStatic)).ToArray());
            }
            throw new Exception("GetFields is weaksauce");
        }
예제 #7
0
 protected virtual void addMessageSimple(MsgTypes type, string message, bool notyMessage)
 {
     if (notyMessage)
     {
         messenger.AddMessage(type, message);
     }
 }
        public async Task <ActionResult> Delete(MsgTypes type, int id, MessageSearchCondition condition)
        {
            await this.Biz.Value.Delete(type, id);

            this.SetCondition(condition);
            return(RedirectToAction("Index"));
        }
예제 #9
0
 public Subscription(string n, string md5s, string dt)
 {
     name     = n;
     md5sum   = md5s;
     datatype = dt;
     msgtype  = (MsgTypes)Enum.Parse(typeof(MsgTypes), dt.Replace("/", "__"));
 }
예제 #10
0
        public override void AddMessage(MsgTypes type, string message, Exception exception = null, bool logMessage = false, bool notyMessage = true)
        {
            if (exception == null)
            {
                if (Settings.DeploymentContext == DeploymentContext.Development)
                {
                    Debug.WriteLine($"NOTIFIER >>>> {type.GetText()} : {message}");
                }
                if (logMessage || Settings.Notifications.LogAllMessages || (type == MsgTypes.Error || type == MsgTypes.Warning))
                {
                    log(type, message);
                }

                addMessageSimple(type, message, notyMessage);
            }
            else
            {
                if (Settings.DeploymentContext == DeploymentContext.Development)
                {
                    Debug.WriteLine($"NOTIFIER >>>> EXCP : {exception.Message}");
                }

                logException(type, message, exception);

                addMessage(type, message, exception, notyMessage);
            }
        }
예제 #11
0
 public BaseMessage(MsgTypes type, bool allowHtml = false)
 {
     this.MsgType   = type;
     this.AllowHtml = allowHtml;
     this.PRI       = Priorities.Normal;
     this.Status    = MsgStatus.New;
 }
예제 #12
0
 public static IRosMessage generate(MsgTypes t)
 {
     lock (constructors)
     {
         if (constructors.ContainsKey(t))
             return constructors[t].Invoke(t);
         Type thistype = typeof (IRosMessage);
         foreach (Type othertype in thistype.Assembly.GetTypes())
         {
             if (thistype == othertype || !othertype.IsSubclassOf(thistype))
             {
                 continue;
             }
             IRosMessage msg = Activator.CreateInstance(othertype) as IRosMessage;
             if (msg != null)
             {
                 if (msg.msgtype() == MsgTypes.Unknown)
                     throw new Exception("OH NOES IRosMessage.generate is borked!");
                 if (!_typeregistry.ContainsKey(msg.msgtype()))
                     _typeregistry.Add(msg.msgtype(), msg.GetType());
                 if (!constructors.ContainsKey(msg.msgtype()))
                     constructors.Add(msg.msgtype(), T => Activator.CreateInstance(_typeregistry[T]) as IRosMessage);
             }
         }
         if (constructors.ContainsKey(t))
             return constructors[t].Invoke(t);
         else
             throw new Exception("OH NOES IRosMessage.generate is borked!");
     }
 }
예제 #13
0
 /// <summary>
 /// For Performance
 /// default of no noty for logging for import routines etc
 /// keeps in RAM, then dump all at end
 /// avoids slowing down processes which
 /// </summary>
 public void QueueMessage(MsgTypes type, string message, Exception exception = null, bool logMessage = false, bool notyMessage = false)
 {
     messagesQueue.Add(new MessageInfo()
     {
         type = type, message = message, exception = exception, logMessage = logMessage, notyMessage = notyMessage
     });
 }
예제 #14
0
        public static MsgTypes GetMessageType(string s)
        {
            //Console.WriteLine("LOOKING FOR: " + s + "'s type");
            if (GetMessageTypeMemoString.ContainsKey(s))
            {
                return(GetMessageTypeMemoString[s]);
            }
            if (s.Contains("TimeData"))
            {
                GetMessageTypeMemoString.Add(s, MsgTypes.std_msgs__Time);
                return(MsgTypes.std_msgs__Time);
            }
            if (!s.Contains("Messages"))
            {
                if (s.Contains("System."))
                {
                    Array      types = Enum.GetValues(typeof(MsgTypes));
                    MsgTypes[] mts   = (MsgTypes[])types;
                    string     test  = s.Split('.')[1];
                    MsgTypes   m     = mts.FirstOrDefault(mt => mt.ToString().ToLower().Equals(test.ToLower()));
                    GetMessageTypeMemoString.Add(s, m);
                    return(m);
                }
                return(MsgTypes.Unknown);
            }
            MsgTypes ms = (MsgTypes)Enum.Parse(typeof(MsgTypes), s.Replace("Messages.", "").Replace(".", "__").Replace("[]", ""));

            GetMessageTypeMemoString.Add(s, ms);
            return(ms);
        }
예제 #15
0
 protected virtual void addMessage(MsgTypes type, string message, Exception exception, bool notyMessage)
 {
     addMessageSimple(type, message, notyMessage);
     if (Settings.Notifications.ShowUserExceptionDetails)
     {
         messenger.AddMessage(MsgTypes.Warning, $"Exp : {exception.Message}");
     }
 }
예제 #16
0
        public async Task DeleteExpiredMsgs(long id, MsgTypes msgType)
        {
            string key         = KeyGenHelper.GenUserKey(id, "MsgIds", msgType.ToString());
            var    deletedKeys = await _redis.DeleteZsetReturnValueRangeAsync
                                     (key, 0, (DateTime.Now - TimeSpan.FromDays(30)).ToTimeStamp());

            await _redis.DeleteHashValuesAsync(KeyGenHelper.GenUserKey(id, "Msgs", msgType.ToString()), deletedKeys);
        }
예제 #17
0
 protected override void addMessage(MsgTypes type, string message, Exception exception, bool notyMessage)
 {
     base.addMessage(type, message, exception, notyMessage);
     if (!Settings.Notifications.ShowUserExceptionDetails)
     {
         messenger.AddMessage(MsgTypes.Warning, $"Exception Occurred : {Settings.Notifications.SystemWatcher} has been notified");
     }
 }
예제 #18
0
        internal ulong handleMessage(IRosMessage msg, bool ser, bool nocopy, IDictionary connection_header,
                                     PublisherLink link)
        {
            IRosMessage t            = null;
            ulong       drops        = 0;
            TimeData    receipt_time = ROS.GetTime().data;

            if (msg.Serialized != null) //will be null if self-subscribed
            {
                msg.Deserialize(msg.Serialized);
            }
            lock (callbacks_mutex)
            {
                foreach (ICallbackInfo info in callbacks)
                {
                    MsgTypes ti = info.helper.type;
                    if (nocopy || ser)
                    {
                        t = msg;
                        t.connection_header = msg.connection_header;
                        t.Serialized        = null;
                        bool was_full           = false;
                        bool nonconst_need_copy = callbacks.Count > 1;
                        info.subscription_queue.pushitgood(info.helper, t, nonconst_need_copy, ref was_full, receipt_time);
                        if (was_full)
                        {
                            ++drops;
                        }
                        else
                        {
                            info.callback.addCallback(info.subscription_queue, info.Get());
                        }
                    }
                }
            }

            if (t != null && link.Latched)
            {
                LatchInfo li = new LatchInfo
                {
                    message           = t,
                    link              = link,
                    connection_header = connection_header,
                    receipt_time      = receipt_time
                };
                if (latched_messages.ContainsKey(link))
                {
                    latched_messages[link] = li;
                }
                else
                {
                    latched_messages.Add(link, li);
                }
            }

            return(drops);
        }
예제 #19
0
 public IRosMessage(MsgTypes t, string def, bool hasheader, bool meta, Dictionary <string, MsgFieldInfo> fields, string ms5, bool isservicemessage)
 {
     msgtype            = t;
     MessageDefinition  = def;
     HasHeader          = hasheader;
     IsMetaType         = meta;
     Fields             = fields;
     MD5Sum             = ms5;
     IsServiceComponent = isservicemessage;
 }
예제 #20
0
파일: MD5.cs 프로젝트: rvlietstra/ROS.NET
 public static string Sum(MsgTypes m)
 {
     if (!md5memo.ContainsKey(m))
     {
         IRosMessage irm = IRosMessage.generate(m);
         string hashme = PrepareToHash(irm);
         md5memo.Add(m, Sum(hashme));
     }
     return md5memo[m];
 }
예제 #21
0
        public async Task ReadedMsg(long id, MsgTypes msgType, string msgId)
        {
            var msginfo = await GetMsgInfo(id, msgType, msgId);

            if (msginfo != null && msginfo.MsgState == MsgStates.Unread)
            {
                msginfo.MsgState = MsgStates.Readed;
                await SetMsgInfo(id, msgType, msginfo);
            }
        }
예제 #22
0
 public MessageDeserializer <T> MakeDeserializer <T>(MsgTypes type, SubscriptionCallbackHelper <T> helper, T m,
                                                     IDictionary connection_header) where T : IRosMessage, new()
 {
     if (type == MsgTypes.Unknown)
     {
         return(null);
     }
     //return ROS.MakeDeserializer(ROS.MakeMessage(type));
     return(new MessageDeserializer <T>(helper, m, connection_header));
 }
예제 #23
0
파일: MD5.cs 프로젝트: cephdon/ROS.NET
 public static string Sum(MsgTypes m)
 {
     if (!md5memo.ContainsKey(m))
     {
         IRosMessage irm    = IRosMessage.generate(m);
         string      hashme = PrepareToHash(irm);
         md5memo.Add(m, Sum(hashme));
     }
     return(md5memo[m]);
 }
예제 #24
0
        public void initialize <MSrv>()
            where MSrv : IRosService, new()
        {
            MSrv srv = new MSrv();

            RequestMd5Sum  = srv.RequestMessage.MD5Sum();
            ResponseMd5Sum = srv.ResponseMessage.MD5Sum();
            RequestType    = srv.RequestMessage.msgtype();
            ResponseType   = srv.ResponseMessage.msgtype();
        }
예제 #25
0
        public void initialize <MReq, MRes>() where MReq : IRosMessage, new() where MRes : IRosMessage, new()
        {
            MReq req = new MReq();
            MRes res = new MRes();

            RequestMd5Sum  = req.MD5Sum();
            ResponseMd5Sum = res.MD5Sum();
            RequestType    = req.msgtype();
            ResponseType   = res.msgtype();
        }
예제 #26
0
        internal bool addCallback <M>(SubscriptionCallbackHelper <M> helper, string md5sum, CallbackQueueInterface queue,
                                      uint queue_size, bool allow_concurrent_callbacks, string topiclol) where M : IRosMessage, new()
        {
            lock (md5sum_mutex)
            {
                if (this.md5sum == "*" && md5sum != "*")
                {
                    this.md5sum = md5sum;
                }
            }

            if (md5sum != "*" && md5sum != this.md5sum)
            {
                return(false);
            }

            lock (callbacks_mutex)
            {
                CallbackInfo <M> info = new CallbackInfo <M> {
                    helper = helper, callback = queue, subscription_queue = new Callback <M>(helper.callback().func, topiclol, queue_size, allow_concurrent_callbacks)
                };
                //if (!helper.isConst())
                //{
                ++nonconst_callbacks;
                //}

                callbacks.Add(info);

                if (latched_messages.Count > 0)
                {
                    MsgTypes ti = info.helper.type;
                    lock (publisher_links_mutex)
                    {
                        foreach (PublisherLink link in publisher_links)
                        {
                            if (link.Latched)
                            {
                                if (latched_messages.ContainsKey(link))
                                {
                                    LatchInfo latch_info         = latched_messages[link];
                                    bool      was_full           = false;
                                    bool      nonconst_need_copy = false; //callbacks.Count > 1;
                                    info.subscription_queue.pushitgood(info.helper, latched_messages[link].message, nonconst_need_copy, ref was_full, ROS.GetTime().data);
                                    if (!was_full)
                                    {
                                        info.callback.addCallback(info.subscription_queue, info.Get());
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(true);
        }
예제 #27
0
        public string GetMessage(MsgTypes type)
        {
            switch (type)
            {
            case (MsgTypes.GenericError):
                return("We just encountered an error while processing your request. We've notified the support team about this. Please try again later.");

            default:
                return(type.ToString());
            }
        }
예제 #28
0
파일: Msg.cs 프로젝트: hjhong/ColorWanted
        public static void Send(MsgTypes command, string message = "")
        {
            // 从配置文件读取端口
            int port     = Settings.Msg.Port;
            var client   = new UdpClient();
            var endpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), port);

            byte[] data = Encoding.UTF8.GetBytes($"{command}#{message}");
            client.Send(data, data.Length, endpoint);
            client.Close();
        }
예제 #29
0
        public async Task<IEnumerable<Template>> GetTemplates(string code, string appCode, MsgTypes? msgType = null, Langs? lang = null) {
            var cond = new TemplateSearchCondition() {
                AllowPage = false,
                AppCode = appCode,
                Code = code,
                Lang = lang,
                MsgType = msgType
            };

            return await this.TemplateBiz.Value.Search(cond);
        }
예제 #30
0
        public void AddMessage(MsgTypes type, string text)
        {
            Dictionary <MsgTypes, List <string> > messages = _messagesAccess.Get();

            if (!messages.ContainsKey(type))
            {
                messages.Add(type, new List <string>());
            }
            messages[type].Add(text);
            _messagesAccess.Store(messages);
        }
예제 #31
0
 public UserMsgInfo(MsgTypes msgType, string msgId, string title,
                    string content, MsgStates msgState, long msgTime, List <RewardInfo> rewardInfo)
 {
     MsgType    = msgType;
     MsgId      = msgId;
     Title      = title;
     Content    = content;
     MsgState   = msgState;
     MsgTime    = msgTime;
     RewardInfo = rewardInfo;
 }
예제 #32
0
 public override void getPublishTypes(ref bool ser, ref bool nocopy, ref MsgTypes mt)
 {
     lock (drop_mutex)
     {
         if (dropped)
         {
             ser    = false;
             nocopy = false;
             return;
         }
     }
     subscriber.getPublishTypes(ref ser, ref nocopy, ref mt);
 }
예제 #33
0
        public void Show(String msg, MsgTypes msgType)
        {
            switch (msgType)
            {
            case MsgTypes.Error:
                MessageBox.Show(msg, Captions.ErrorCaption, MessageBoxButton.OK, MessageBoxImage.Error);
                break;

            case MsgTypes.Informational:
                MessageBox.Show(msg, Captions.InfoCaption, MessageBoxButton.OK, MessageBoxImage.Information);
                break;
            }
        }
예제 #34
0
 public override void getPublishTypes(ref bool ser, ref bool nocopy, MsgTypes mt)
 {
     lock (drop_mutex)
     {
         if (dropped)
         {
             ser = false;
             nocopy = false;
             return;
         }
     }
     subscriber.getPublishTypes(ref ser, ref nocopy, mt);
 }
예제 #35
0
        public static DialogResult Show(String Caption, String Text, String Buttons, MsgTypes MsgType)
        {
            MessageBoxButtons btns = MessageBoxButtons.OK;
            MessageBoxIcon icon = MessageBoxIcon.None;

            if (Buttons.ToLower().Contains("yesno"))
            {
                if (Buttons.ToLower().Contains("cancel"))
                {
                    btns = MessageBoxButtons.YesNoCancel;
                }
                else
                {
                    btns = MessageBoxButtons.YesNo;
                }
            }

            if (Buttons.ToLower().Contains("ok"))
            {
                btns = MessageBoxButtons.OK;
            }

            switch (MsgType)
            {
                case MsgTypes.ERROR:
                    icon = MessageBoxIcon.Error;
                    if (LOGGER_LEVEL >= 0)
                        LogError(Text);
                    break;
                case MsgTypes.WARNING:
                    icon = MessageBoxIcon.Warning;
                    if (LOGGER_LEVEL >= 1)
                        LogWarning(Text);
                    break;
                case MsgTypes.INFO:
                    icon = MessageBoxIcon.Information;
                    if (LOGGER_LEVEL >= 2)
                        LogInfo(Text);
                    break;
            }

            if (Application.OpenForms.Count > 0)
            {
                return MetroFramework.MetroMessageBox.Show(Application.OpenForms[0], Text, Caption, btns, icon);
            }
            else
            {
                return DialogResult.None;
            }
        }
예제 #36
0
        public async Task<Template> GetByCode(string code, string appCode, MsgTypes msgType, Langs? lang) {
            code = code.ToUpper().Trim();
            appCode = appCode.ToUpper();

            using (var db = new Entities()) {
                var query = db.Templates.Where(t =>
                    !t.IsDeleted
                    && t.Code.ToUpper() == code
                    && t.AppCode.ToUpper() == appCode
                    && t.MsgType == msgType
                    && ((lang != null && t.Lang == lang.Value) || (lang == null && t.IsDefault))
                    );

                return await query.FirstOrDefaultAsync();
            }
        }
        public int Save(MsgTypes Data)
        {
            TopContractsV01Entities context = new TopContractsV01Entities(Utilities.getTestEnvName());
            TopContractsEntities.MsgType efMsgType = null;
            foreach (TopContractsDAL10.SystemTables.MsgType MsgType in Data.Entries)
            {
                if (MsgType.New)
                {
                    efMsgType = new TopContractsEntities.MsgType();
                }
                else
                {
                    efMsgType = context.MsgTypes.Where(c => c.MsgTypeID == MsgType.ID).SingleOrDefault();
                }

                if (MsgType.Deleted == false)
                {
                    efMsgType.InitCommonFields(efMsgType, MsgType, efMsgType.MsgTypesLNGs, this.organizationIdentifier);
                    efMsgType.ContractTypesVisibility = MsgType.ContractTypesVisibility;
                    efMsgType.IncludeID1Body = MsgType.IncludeID1Body;
                    efMsgType.IncludeID1Subject = MsgType.IncludeID1Subject;
                    efMsgType.IncludeID2Body = MsgType.IncludeID2Body;
                    efMsgType.IncludeID2Subject = MsgType.IncludeID2Subject;
                    efMsgType.IncludeNameBody = MsgType.IncludeNameBody;
                    efMsgType.IncludeNameSubject = MsgType.IncludeNameSubject;
                    efMsgType.IncludeSysCodeBody = MsgType.IncludeSysCodeBody;
                    efMsgType.IncludeSysCodeSubject = MsgType.IncludeSysCodeSubject;
                    efMsgType.LinkInBody = MsgType.LinkInBody;
                    efMsgType.LinkInSubject = MsgType.LinkInSubject;
                    efMsgType.MsgBodyPrefix = MsgType.MsgBodyPrefix;
                    efMsgType.MsgSubjectPrefix = MsgType.MsgSubjectPrefix;
                }
                if (MsgType.New)
                    context.MsgTypes.Add(efMsgType);
                else
                {
                    if (MsgType.Deleted && efMsgType != null)
                    {
                        efMsgType.DeleteLanguageEntries(efMsgType, context.MsgTypesLNGs, efMsgType.MsgTypesLNGs);
                        //for (int indx = efMsgType.MsgTypesLNGs.Count() - 1; indx >= 0; indx--)
                        //{
                        //    TopContractsEntities.MsgTypesLNG lng = efMsgType.MsgTypesLNGs.ElementAt(indx);
                        //    context.MsgTypesLNGs.Remove(lng);
                        //}
                        context.MsgTypes.Remove(efMsgType);
                    }
                }
            }
            return context.SaveChanges();
        }
예제 #38
0
 public IRosMessage(MsgTypes t, string def, bool hasheader, bool meta, Dictionary<string, MsgFieldInfo> fields, string ms5) : this(t,def,hasheader,meta,fields,ms5,false)
 {
 }
예제 #39
0
 public IRosMessage(MsgTypes t, string def, bool hasheader, bool meta, Dictionary<string, MsgFieldInfo> fields, string ms5, bool isservicemessage)
 {
     msgtype = t;
     MessageDefinition = def;
     HasHeader = hasheader;
     IsMetaType = meta;
     Fields = fields;
     MD5Sum = ms5;
     IsServiceComponent = isservicemessage;
 }
예제 #40
0
 public ProcessedArgs(MsgTypes msgType, int id, Exception ex = null)
 {
     this.MsgType = msgType;
     this.ID = id;
     this.Exception = ex;
 }
예제 #41
0
파일: MsgBox.cs 프로젝트: x893/BTool
 public MsgBox.MsgResult UserMsgBox(MsgTypes msgType, MsgButtons msgButtons, MsgResult defaultMsgResult, string msg)
 {
     return UserMsgBox(SharedObjects.MainWin, msgType, msgButtons, defaultMsgResult, msg);
 }
예제 #42
0
 public async Task<bool> Delete(MsgTypes type, int id) {
     var handler = MessageHandlerFactory.GetHandler(type);
     return await handler.Delete(id);
 }
예제 #43
0
 public async Task<Template> GetByCode(string code, string appCode, MsgTypes msgType, Langs? lang = null) {
     var template = await this.TemplateBiz.Value.GetByCode(code, appCode, msgType, lang);
     return template;
 }
예제 #44
0
 /// <summary>
 /// TCLightMsg constructor
 /// </summary>
 /// <param name="Msg">A TCANMsg structure defined in the PCAN_DNP Class</param>
 public TCLightMsg(PCAN_DNP.TPCANMsg Msg)
 {
    ID = Msg.ID;
    MsgType = (MsgTypes)Msg.MSGTYPE;
    Len = Msg.LEN;
    Data = Msg.DATA;
 }
예제 #45
0
      /// <summary>
      /// PCANLigth MsgFilter function
      /// This function set the receive message filter of the CAN Controller.
      /// REMARK:
      ///		- A quick register of all messages is possible using the parameters From and To as 0
      ///		- Every call of this function maybe cause an extention of the receive filter of the 
      ///		  CAN controller, which one can go briefly to RESET
      ///		- New in Ver 2.x:
      ///			* Standard frames will be put it down in the acc_mask/code as Bits 28..13
      ///			* Hardware driver for 82C200 must to be moved to Bits 10..0 again!
      ///	WARNING: 
      ///		It is not guaranteed to receive ONLY the registered messages.
      /// </summary>
      /// <param name="HWType">Hardware which applay the filter to</param>
      /// <param name="From">First/Start Message ID - It muss be smaller than the "To" parameter</param>
      /// <param name="To">Last/Finish Message ID - It muss be bigger than the "From" parameter</param>
      /// <param name="MsgType">Kind of Frame - Standard or Extended</param>
      /// <returns>A CANResult value - Error/status of the hardware after execute the function</returns>
      public static CANResult MsgFilter(HardwareType HWType, uint From, uint To, MsgTypes MsgType)
      {
         try
         {
            switch (HWType)
            {
               case HardwareType.ISA_1CH:
                  return (CANResult)PCAN_ISA.MsgFilter(From, To, (int)MsgType);

               case HardwareType.ISA_2CH:
                  return (CANResult)PCAN_2ISA.MsgFilter(From, To, (int)MsgType);

               case HardwareType.PCI_1CH:
                  return (CANResult)PCAN_PCI.MsgFilter(From, To, (int)MsgType);

               case HardwareType.PCI_2CH:
                  return (CANResult)PCAN_2PCI.MsgFilter(From, To, (int)MsgType);

               case HardwareType.PCC_1CH:
                  return (CANResult)PCAN_PCC.MsgFilter(From, To, (int)MsgType);

               case HardwareType.PCC_2CH:
                  return (CANResult)PCAN_2PCC.MsgFilter(From, To, (int)MsgType);

               case HardwareType.USB_1CH:
                  return (CANResult)PCAN_USB.MsgFilter(From, To, (int)MsgType);

               case HardwareType.USB_2CH:
                  return (CANResult)PCAN_2USB.MsgFilter(From, To, (int)MsgType);

               case HardwareType.DNP:
                  return (CANResult)PCAN_DNP.MsgFilter(From, To, (int)MsgType);

               case HardwareType.DNG:
                  return (CANResult)PCAN_DNG.MsgFilter(From, To, (int)MsgType);

               // Hardware is not valid for this function
               //
               default:
                  return CANResult.ERR_ILLHW;
            }
         }
         catch (Exception Ex)
         {
            // Error: Dll does not exists or the function is not available
            //
            Tracer.WriteError(TraceGroup.CANBUS, null, "MsgFilter {0}", Ex.Message + "\"");
            return CANResult.ERR_NO_DLL;
         }
      }
예제 #46
0
파일: PCANLight.cs 프로젝트: sbtree/MST
        /// <summary>
        /// PCANLigth MsgFilter function
        /// This function set the receive message filter of the CAN Controller.
        /// REMARK:
        ///		- A quick register of all messages is possible using the parameters From and To as 0
        ///		- Every call of this function maybe cause an extention of the receive filter of the 
        ///		  CAN controller, which one can go briefly to RESET
        ///		- New in Ver 2.x:
        ///			* Standard frames will be put it down in the acc_mask/code as Bits 28..13
        ///			* Hardware driver for 82C200 must to be moved to Bits 10..0 again!
        ///	WARNING: 
        ///		It is not guaranteed to receive ONLY the registered messages.
        /// </summary>
        /// <param name="HWType">Hardware which applay the filter to</param>
        /// <param name="From">First/Start Message ID - It muss be smaller than the "To" parameter</param>
        /// <param name="To">Last/Finish Message ID - It muss be bigger than the "From" parameter</param>
        /// <param name="MsgType">Kind of Frame - Standard or Extended</param>
        /// <returns>A CANResult value - Error/status of the hardware after execute the function</returns>
        public static CANResult MsgFilter(HardwareType HWType, uint From, uint To, MsgTypes MsgType)
        {
            try
            {
                switch (HWType)
                {
                    case HardwareType.ISA_1CH:
                        return (CANResult)PCAN_ISA.MsgFilter(From, To, (int)MsgType);

                    case HardwareType.ISA_2CH:
                        return (CANResult)PCAN_2ISA.MsgFilter(From, To, (int)MsgType);

                    case HardwareType.PCI_1CH:
                        return (CANResult)PCAN_PCI.MsgFilter(From, To, (int)MsgType);

                    case HardwareType.PCI_2CH:
                        return (CANResult)PCAN_2PCI.MsgFilter(From, To, (int)MsgType);

                    case HardwareType.PCC_1CH:
                        return (CANResult)PCAN_PCC.MsgFilter(From, To, (int)MsgType);

                    case HardwareType.PCC_2CH:
                        return (CANResult)PCAN_2PCC.MsgFilter(From, To, (int)MsgType);

                    case HardwareType.USB_1CH:
                        return (CANResult)PCAN_USB.MsgFilter(From, To, (int)MsgType);

                    case HardwareType.USB_2CH:
                        return (CANResult)PCAN_2USB.MsgFilter(From, To, (int)MsgType);

                    case HardwareType.DNP:
                        return (CANResult)PCAN_DNP.MsgFilter(From, To, (int)MsgType);

                    case HardwareType.DNG:
                        return (CANResult)PCAN_DNG.MsgFilter(From, To, (int)MsgType);

                    // Hardware is not valid for this function
                    //
                    default:
                        return CANResult.ERR_ILLHW;
                }
            }
            catch (Exception Ex)
            {
                // Error: Dll does not exists or the function is not available
                //
                System.Windows.Forms.MessageBox.Show("Error: \"" + Ex.Message + "\"");
                return CANResult.ERR_NO_DLL;
            }
        }
예제 #47
0
파일: MsgBox.cs 프로젝트: x893/BTool
 public void UserMsgBox(Form owner, MsgTypes msgType, string msg)
 {
     UserMsgBox(owner, msgType, MsgButtons.Ok, MsgResult.OK, msg);
 }
예제 #48
0
 public virtual void getPublishTypes(ref bool ser, ref bool nocopy, ref MsgTypes type_info)
 {
     ser = true;
     nocopy = false;
 }
        /// <summary>
        /// Adds the message.
        /// </summary>
        /// <param name="message">The message.</param>
        public void AddMessage(Message message)
        {
            if (this.InvokeRequired)
            {
                AddMessageCallback d = new AddMessageCallback(AddMessage);
                this.Invoke(d, new object[] { message });
            }
            else
            {
                checked
                {
                    Font labelFont = new Font(new FontFamily("Courier New"), 15);
                    string unformattedMessage;
                    if (string.IsNullOrEmpty(message.SenderName))
                        unformattedMessage = message.MsgText;
                    else
                        unformattedMessage = message.SenderName + ": " + message.MsgText;
                    /*Tuple<int, string> formattedMessage = BreakString47(unformatted_message);*/
                    Tuple<Size, string> formattedMessage = CalculateLabelSize(unformattedMessage, labelFont, 600);
                    Label label = new Label();
                    //label.Text = formattedMessage.Item2;
                    label.Text = formattedMessage.Item2;
                    label.Size = formattedMessage.Item1;
                    int heightDelta = label.Height+8;// = lineHeight * formattedMessage.Item1;
                    label.Click += Label_Click;
                    label.DoubleClick += Label_DoubleClick;
                    label.BackColor = Color.Azure;
                    label.ForeColor = Color.Black;

                    label.Font = labelFont;

                    switch (message.MsgType)
                    {
                        case MsgTypes.Dialog:
                            dialogs.AutoScrollPosition = new Point(0,0);
                            label.Location = new Point(0, dialogYPos);
                            dialogYPos += heightDelta;
                            dialogs.Controls.Add(label);
                            break;
                        case MsgTypes.Group:
                            groups.AutoScrollPosition = new Point(0, 0);
                            label.Location = new Point(0, groupsYPos);
                            groupsYPos += heightDelta;
                            groups.Controls.Add(label);
                            break;
                        case MsgTypes.Personal:
                            personal.AutoScrollPosition = new Point(0, 0);
                            label.Location = new Point(0, personalYPos);
                            personalYPos += heightDelta;
                            personal.Controls.Add(label);
                            break;
                    }
                    tempTable.Add(label, message);
                    lastMessageType = message.MsgType;
                    this.Refresh();
                }
            }
        }
예제 #50
0
 public async Task<BaseMessage> Get(MsgTypes type, int id) {
     var handler = MessageHandlerFactory.GetHandler(type);
     return await handler.Get(id);
 }
예제 #51
0
 public MsgFieldInfo(string name, bool isliteral, Type type, bool isconst, string constval, bool isarray,
     string lengths, bool meta, MsgTypes mt)
 {
     Name = name;
     IsArray = isarray;
     Type = type;
     IsLiteral = isliteral;
     IsMetaType = meta;
     IsConst = isconst;
     ConstVal = constval;
     if (lengths == null) return;
     if (lengths.Length > 0)
     {
         Length = int.Parse(lengths);
     }
     message_type = mt;
 }
예제 #52
0
 /// <summary>
 ///     This is self-explanatory
 /// </summary>
 /// <param name="type"> The type of message to make </param>
 /// <returns> A message of that type </returns>
 internal static IRosMessage MakeMessage(MsgTypes type)
 {
     return IRosMessage.generate(type);
 }
예제 #53
0
 internal void getPublishTypes(ref bool serialize, ref bool nocopy, MsgTypes typeEnum)
 {
     lock (subscriber_links_mutex)
     {
         foreach (SubscriberLink sub in subscriber_links)
         {
             bool s = false, n = false;
             sub.getPublishTypes(ref s, ref n, typeEnum);
             serialize = serialize || s;
             nocopy = nocopy || n;
             if (serialize && nocopy)
                 break;
         }
     }
 }