示例#1
0
        public void ShowMessage(AppMessage message, MessageType messageType)
        {
            switch (messageType)
            {
                case MessageType.Success:
                    Messages.Success = message;
                    break;

                case MessageType.Error:
                    Messages.Errors.Add(message);
                    break;
            }
        }
示例#2
0
        private void MainLoopTimer_Tick(object sender, EventArgs e)
        {
            if (loggedIn && TimeSinceLoginStarted != null && TimeSinceLoginStarted.Elapsed.TotalSeconds > 13)
            {
                if ((TimeSinceWatchDogBark?.Elapsed.TotalSeconds ?? int.MaxValue) > 5)
                {
                    TimeSinceWatchDogBark = Stopwatch.StartNew();
                    AppMessage resp = Client.Send(AppMessage.New($"Warehouse for {Core.CharacterFilter.AccountName}", 90, true));
                    if (!WatchDogRegistered && resp != null)
                    {
                        WatchDogRegistered = true;
                        Log($"Registered with watchdog, pool occupancy: {resp.PoolSize + 1}");
                    }
                }
                if (FirstInner)
                {
                    Log($"CAUTION: Warehouse {VersionString} is running");
                    Log($"Anyone near you can take all your non-attuned items.");
                    Log($"Commands: whallowretrieve, whplayerdetectionjump, whallowjumpcmd");
                    FirstInner = false;
                }
                if (PendingRetrieveCommand != null && CharToLogin != null && Core.CharacterFilter.Id == CharToLogin.Value && PendingTradeGiveItems.Count > 0)
                {
                    TradeGiveItem(PendingRetrieveCommand.ChatterId, PendingRetrieveCommand.ChatterName, PendingTradeGiveItems.ToArray());
                    PendingTradeGiveItems.Clear();
                    PendingRetrieveCommand = null;
                    CharToLogin            = null;
                }
                else if (CharToLogin != null)
                {
                    CharToLogin = null;
                }

                if (PlayerDetectionJump)
                {
                    #region nearby player check
                    try
                    {
                        WorldObjectCollection woc = Core.WorldFilter.GetByObjectClass(ObjectClass.Player);
                        int playerCount           = woc.Quantity;
                        if (prevPlayerCount != playerCount)
                        {
                            prevPlayerCount = playerCount;
                            WantToJump      = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        errorLogging.LogError(ErrorLogFile, ex);
                    }
                    #endregion
                }

                if (!ItemScanInProgress && (TimeSinceScanFinished == null || TimeSinceScanFinished.Elapsed > TimeSpan.FromMinutes(5)))
                {
                    WantToSyncItems = true;
                }

                if (!CramTimer.Enabled && !StackTimer.Enabled)
                {
                    Cram();
                }
                if (!StackTimer.Enabled)
                {
                    Stack();
                }
                if (WantToJump)
                {
                    Core.Foreground();
                    SendKey("o", true, true);
                    WantToJump = false;
                }
                SyncItems();
            }
            else if (!loggedIn)
            {
                DoLoginStuff();
                return;
            }
        }
示例#3
0
 static IAppMessage DirectoryDoesNotExist(C spec)
 => AppMessage.Error($"Destination directory @DstDir does not exist and {nameof(spec.CreateDirectory)} is false",
                     new
 {
     DstDir = Path.GetDirectoryName(spec.DstPath)
 });
示例#4
0
 public IActionResult Index(AppMessage appMessage)
 {
     ViewBag.Message = "Message Changed !";
     return(View(appMessage));
 }
示例#5
0
        internal async void OnEnded()
        {
            ended = true;
            timer1000.Stop();
            timer200.Stop();

            if (ownerClosing)
            {
                return;
            }

            TaskbarHelper.Remove(ProgressBarTotal);

            if (closing)
            {
                return;
            }

            if (client.IsChild)
            {
                await client.DisconnectAsync(false, false);
            }

            if (client.TransferEvent.Items.Length == 0)
            {
                if (client.TransferEvent.IsUpload)
                {
                    AppMessage.Add("Nothing to upload.", MessageType.Warning);
                }
                else
                {
                    AppMessage.Add("Nothing to download.", MessageType.Warning);
                }
                this.Close();
                return;
            }

            ButtonCancel.IsEnabled  = false;
            ButtonCancel.Visibility = Visibility.Collapsed;
            ButtonSkip.Visibility   = Visibility.Hidden;
            ButtonPause.Visibility  = Visibility.Hidden;

            if (client.TransferEvent.HasErrors)
            {
                MiniProgressBar.SetStateColor(ProgressBarExtension.ProgressState.Error);
            }
            else
            {
                MiniProgressBar.SetStateColor(ProgressBarExtension.ProgressState.Indeterminate);
            }

            switch (fishedAction)
            {
            case FishedAction.CloseWindow:
                if (!this.IsActive && !ClientHelper.Owner.IsActive)
                {
                    ClientHelper.Owner.FlashWindow(3);
                }
                this.Close();
                return;

            case FishedAction.CloseApp:
                AutoShutdownWindow.Initialize(this, false);
                this.Close();
                return;

            case FishedAction.Shutdown:
                AutoShutdownWindow.Initialize(this, true);
                this.Close();
                return;
            }

            updateCurrentItem();
            UpdateProgress();
            updateTotalFF();

            LabelCurrentRemainsX.Visibility = Visibility.Collapsed;
            LabelTotalRemainsX.Visibility   = Visibility.Collapsed;
            LabelETA.Visibility             = Visibility.Collapsed;

            if (client.TransferEvent.IsUpload)
            {
                this.Title = client.TransferEvent.HasErrors ? AppLanguage.Get("LangTitleUploadFinishedErrors") : AppLanguage.Get("LangTitleUploadDone");
            }
            else
            {
                this.Title = client.TransferEvent.HasErrors ? AppLanguage.Get("LangTitleDownloadFinishedErrors") : AppLanguage.Get("LangTitleDownloadDone");
                ButtonOpenTarget.Visibility = Visibility.Visible;
            }

            ButtonClose.Visibility = Visibility.Visible;
            ButtonClose.IsDefault  = true;
            ButtonClose.IsCancel   = true;
            ButtonClose.Focus();
        }
示例#6
0
        /// <summary>
        /// 获得状态的信息
        /// </summary>
        /// <param name="statusCode">程序运行状态</param>
        /// <returns>返回信息</returns>
        public string GetStateMessage(StatusCode statusCode)
        {
            string returnValue = string.Empty;

            switch (statusCode)
            {
            case StatusCode.DbError:
                returnValue = AppMessage.MSG0002;
                break;

            case StatusCode.Error:
                returnValue = AppMessage.MSG0001;
                break;

            case StatusCode.OK:
                returnValue = AppMessage.MSG9965;
                break;

            case StatusCode.UserNotFound:
                returnValue = AppMessage.MSG9966;
                break;

            case StatusCode.PasswordError:
                returnValue = AppMessage.MSG9967;
                break;

            case StatusCode.LogOnDeny:
                returnValue = AppMessage.MSG9968;
                break;

            case StatusCode.ErrorOnLine:
                returnValue = AppMessage.MSG0048;
                break;

            case StatusCode.ErrorMacAddress:
                returnValue = AppMessage.MSG0049;
                break;

            case StatusCode.ErrorIPAddress:
                returnValue = AppMessage.MSG0050;
                break;

            case StatusCode.ErrorOnLineLimit:
                returnValue = AppMessage.MSG0051;
                break;

            case StatusCode.PasswordCanNotBeNull:
                returnValue = AppMessage.Format(AppMessage.MSG0007, AppMessage.MSG9961);
                break;

            case StatusCode.PasswordCanNotBeRepeat:
                returnValue = AppMessage.Format(AppMessage.MSG0102);
                break;

            case StatusCode.ErrorDeleted:
                returnValue = AppMessage.MSG0005;
                break;

            case StatusCode.SetPasswordOK:
                returnValue = AppMessage.Format(AppMessage.MSG9963, AppMessage.MSG9964);
                break;

            case StatusCode.OldPasswordError:
                returnValue = AppMessage.Format(AppMessage.MSG0040, AppMessage.MSG9961);
                break;

            case StatusCode.ChangePasswordOK:
                returnValue = AppMessage.Format(AppMessage.MSG9962, AppMessage.MSG9964);
                break;

            case StatusCode.OKAdd:
                returnValue = AppMessage.MSG0009;
                break;

            case StatusCode.CanNotLock:
                returnValue = AppMessage.MSG0043;
                break;

            case StatusCode.LockOK:
                returnValue = AppMessage.MSG0044;
                break;

            case StatusCode.OKUpdate:
                returnValue = AppMessage.MSG0010;
                break;

            case StatusCode.OKDelete:
                returnValue = AppMessage.MSG0013;
                break;

            case StatusCode.Exist:
                // "编号已存在,不可以重复."
                returnValue = AppMessage.Format(AppMessage.MSG0008, AppMessage.MSG9955);
                break;

            case StatusCode.ErrorCodeExist:
                // "编号已存在,不可以重复."
                returnValue = AppMessage.Format(AppMessage.MSG0008, AppMessage.MSG9977);
                break;

            case StatusCode.ErrorNameExist:
                // "名称已存在,不可以重复."
                returnValue = AppMessage.Format(AppMessage.MSG0008, AppMessage.MSG9978);
                break;

            case StatusCode.ErrorValueExist:
                // "值已存在,不可以重复."
                returnValue = AppMessage.Format(AppMessage.MSG0008, AppMessage.MSG9800);
                break;

            case StatusCode.ErrorUserExist:
                // "用户名已存在,不可以重复."
                returnValue = AppMessage.Format(AppMessage.MSG0008, AppMessage.MSG9957);
                break;

            case StatusCode.ErrorDataRelated:
                returnValue = AppMessage.MSG0033;
                break;

            case StatusCode.ErrorChanged:
                returnValue = AppMessage.MSG0006;
                break;

            case StatusCode.UserNotEmail:
                returnValue = AppMessage.MSG9910;
                break;

            case StatusCode.UserLocked:
                returnValue = AppMessage.MSG9911;
                break;

            case StatusCode.WaitForAudit:
            case StatusCode.UserNotActive:
                returnValue = AppMessage.MSG9912;
                break;

            case StatusCode.UserIsActivate:
                returnValue = AppMessage.MSG9913;
                break;

            case StatusCode.NotFound:
                returnValue = AppMessage.MSG9956;
                break;

            case StatusCode.ErrorLogOn:
                returnValue = AppMessage.MSG9000;
                break;

            case StatusCode.UserDuplicate:
                returnValue = AppMessage.Format(AppMessage.MSG0008, AppMessage.MSG9957);
                break;

                //// 开始审核
                //case AuditStatus.StartAudit:
                //    returnValue = AppMessage.MSG0009;
                //    break;
                //// 审核通过
                //case AuditStatus.AuditPass:
                //    returnValue = AppMessage.MSG0009;
                //    break;
                //// 待审核
                //case AuditStatus.WaitForAudit:
                //    returnValue = AppMessage.MSG0010;
                //    break;
                //// 审核退回
                //case AuditStatus.AuditReject:
                //    returnValue = AppMessage.MSG0009;
                //    break;
                //// 审核结束
                //case AuditStatus.AuditComplete:
                //    returnValue = AppMessage.MSG0010;
                //    break;
                //// 提交成功。
                //case AuditStatus.SubmitOK:
                //    returnValue = AppMessage.MSG0009;
                //    break;
            }
            return(returnValue);
        }
        public virtual void Control_Load(object sender, EventArgs e)
        {
            if (!this.DesignMode)
            {
                if (this.Parent == null && this.Parent == null)
                {
                    LoadingUtil.ShowWaitLoading();
                }

                // 设置鼠标繁忙状态,并保留原先的状态
                System.Windows.Forms.Cursor holdCursor = this.Cursor;
                this.Cursor        = Cursors.WaitCursor;
                this.ControlLoaded = false;
                try
                {
                    // 是否记录访问日志
                    if (BaseSystemInfo.RecordLog)
                    {
                        // 已经登录了系统了,才记录日志
                        if (BaseSystemInfo.UserIsLogOn)
                        {
                            // 调用服务事件
                            if (this.RecordControlLog)
                            {
                                // 调用服务事件
                                // this.LogId = dotNetService.LogService.WriteLog(UserInfo, this.ItemName, this.Text, "FormLoad");
                                DotNetService dotNetService = new DotNetService();
                                dotNetService.LogService.WriteLog(UserInfo, this.Name, AppMessage.GetMessage(this.Name), "FormLoad", AppMessage.LoadWindow);
                                if (dotNetService.LogService is ICommunicationObject)
                                {
                                    ((ICommunicationObject)dotNetService.LogService).Close();
                                }
                            }
                        }
                    }

                    // 获得页面的权限
                    this.GetPermissions();
                    // 加载窗体
                    this.ControlOnLoad();
                    // 设置按钮状态
                    this.SetControlState();
                    if (BaseSystemInfo.MultiLanguage)
                    {
                        // 多语言国际化加载

                        /*
                         * if (ResourceManagerWrapper.Instance.GetLanguages() != null)
                         * {
                         *  this.Localization(this);
                         * }
                         */
                    }
                    if (this.LoadUserParameters)
                    {
                        // 客户端页面配置加载
                        this.LoadUserParameter(this);
                    }
                    // 设置帮助
                    this.SetHelp();
                }
                catch (Exception catchException)
                {
                    catchException.ProcessException();
                }
                finally
                {
                    this.ControlLoaded = true;
                    // 设置鼠标默认状态,原来的光标状态
                    this.Cursor = holdCursor;
                }

                if (this.Parent == null)
                {
                    //LoadingUtil.StopLoading();
                }
                this.Visible = true;
            }
        }
示例#8
0
 protected static IAppMessage Describe <C>(string template, C content,
                                           [CallerFilePath] string callerFile = null, [CallerMemberName] string callerName = null)
 => AppMessage.Inform(template, content, callerFile, callerName);
示例#9
0
        private AppMessage MessageReceiver(AppMessage message)
        {
            _log.Information($"AppMessage received: {message.ToString()}");
            AppMessage retMessage = new AppMessage(AppMessage.CommandType.Error, $"Unsupported command type {message.Command.ToString()}");

            switch (message.Command)
            {
            case AppMessage.CommandType.Play:
                if (Player.IsValid)
                {
                    Player.Play();
                    retMessage.Copy(message);
                }
                else
                {
                    retMessage.Param = "";
                }
                break;

            case AppMessage.CommandType.Stop:
                if (Player.IsValid)
                {
                    Player.Pause();
                    retMessage.Copy(message);
                }
                else
                {
                    retMessage.Param = "";
                }
                break;

            case AppMessage.CommandType.Media:
                retMessage.Command = AppMessage.CommandType.Media;
                retMessage.Param   = Player.MediaUri.ToString();
                break;

            case AppMessage.CommandType.State:

                switch (Player.State)
                {
                case Windows.Media.Playback.MediaPlaybackState.Opening:
                    retMessage.Command = AppMessage.CommandType.Unknown;
                    retMessage.Param   = "Video is currently opening";
                    break;

                case Windows.Media.Playback.MediaPlaybackState.Buffering:
                    retMessage.Command = AppMessage.CommandType.Unknown;
                    retMessage.Param   = "Video is buffering";
                    break;

                case Windows.Media.Playback.MediaPlaybackState.Playing:
                    retMessage.Command = AppMessage.CommandType.Play;
                    break;

                case Windows.Media.Playback.MediaPlaybackState.Paused:
                    retMessage.Command = AppMessage.CommandType.Stop;
                    break;

                default:
                    retMessage.Command = AppMessage.CommandType.Unknown;
                    break;
                }

                break;

            default:
                break;
            }
            return(retMessage);
        }
示例#10
0
 public AppMessageDto(AppMessage message)
 {
     Code = message.Code;
     Text = message.Description;
 }
示例#11
0
 public AppMessageDto(AppMessage message, string details)
 {
     Code = message.Code;
     Text = message.Description + System.Environment.NewLine + details;
 }
#pragma warning disable CS1998 // 此异步方法缺少 "await" 运算符,将以同步方式运行。请考虑使用 "await" 运算符等待非阻止的 API 调用,或者使用 "await Task.Run(...)" 在后台线程上执行占用大量 CPU 的工作。
        public async Task HandleMessageAsync(IMiraiHttpSession client, IGroupMessageEventArgs e)
#pragma warning restore CS1998 // 此异步方法缺少 "await" 运算符,将以同步方式运行。请考虑使用 "await" 运算符等待非阻止的 API 调用,或者使用 "await Task.Run(...)" 在后台线程上执行占用大量 CPU 的工作。
        {
            try
            {
                var session = MainHolder.session;

                WatchDog.FeedDog("grpmsg");
                pThreadPool pool = MainHolder.pool;
                //MainHolder.Logger.Debug("CQPLUGIN", "Event_GroupMessageFired");
                MainHolder.MsgCount++;
                SecondlyTask.lastrecv = DateTime.Now;
                if (true)
                {
                    IGroupInfo       gpinfo = e.Sender.Group;
                    IGroupMemberInfo gminfo = e.Sender;
                    string           gpname = DataBase.me.getGroupName(gpinfo.Id);
                    if (!DataBase.me.connected)
                    {
                        MainHolder.Logger.Error("数据库", "数据库未连接");
                    }

                    foreach (IChatMessage msg in e.Chain)
                    {
                        if (msg is not UnknownChatMessage)//不处理UnknownChatMessage
                        {
                            switch (msg.Type)
                            {
                            case "Plain":
                            {
                                PlainMessage message = (PlainMessage)msg;
                                if (!DataBase.me.recQQmsg(e.Sender.Id, e.Sender.Group.Id, message.Message))
                                {
                                    MainHolder.Logger.Error("数据库", "未能将消息存入数据库");
                                }
                                //message.Message
                                {
                                    string abvn = AVFinder.abvFromString(message.Message);
                                    if (abvn != null && abvn != "")
                                    {
                                        processVideoBilibili(e, abvn);
                                    }
                                }
                                Commands.Proc(session, e, message.Message);
                            }
                            break;

                            case "Xml":
                            {
                                XmlMessage message = (XmlMessage)msg;
                                if (!DataBase.me.recQQmsg(e.Sender.Id, e.Sender.Group.Id, message.Xml))
                                {
                                    MainHolder.Logger.Error("数据库", "未能将消息存入数据库");
                                }

                                if (Commands.cocogroup == e.Sender.Group.Id)
                                {
                                    MainHolder.broadcaster.SendToGroup(e.Sender.Group.Id, "[Xml解析]\n" + message.Xml);
                                }

                                XmlDocument doc = new XmlDocument();
                                doc.LoadXml(message.Xml);
                                {
                                    if (doc["msg"] == null)
                                    {
                                        MainHolder.broadcaster.SendToAnEgg(e.Sender.Group.Id + "无msg标签的Xml消息\n" + message.Xml);
                                    }
                                    if (doc["msg"].HasAttribute("action") && doc["msg"].GetAttribute("action") == "viewMultiMsg" && DataBase.me.isAdminGroup(e.Sender.Group.Id))
                                    {
                                        string fname      = doc["msg"].GetAttribute("m_fileName");
                                        string fresid     = doc["msg"].GetAttribute("m_resid");
                                        int    tsum       = int.Parse(doc["msg"].GetAttribute("tSum"));
                                        int    flag       = int.Parse(doc["msg"].GetAttribute("flag"));
                                        int    serviceID  = int.Parse(doc["msg"].GetAttribute("serviceID"));
                                        int    m_fileSize = int.Parse(doc["msg"].GetAttribute("m_fileSize"));
                                        DataBase.me.saveMessageGroup(fname, fresid, tsum, flag, serviceID, m_fileSize);
                                        MainHolder.broadcaster.SendToGroup(e.Sender.Group.Id, "[消息存证]\n该条消息记录已提交至腾讯服务器\n存根ID:" + fname);
                                        return;
                                        //不再处理该条消息
                                    }
                                    if (doc["msg"]["source"] != null && doc["msg"]["source"].HasAttribute("name"))
                                    {
                                        switch (doc["msg"]["source"].GetAttribute("name"))
                                        {
                                        case "哔哩哔哩":                                                               //B站分享
                                            if (doc["msg"].GetAttribute("url").IndexOf("/live.bilibili.com/") > 0) //直播分享
                                            {
                                            }
                                            if (doc["msg"].GetAttribute("url").IndexOf("/b23.tv/") > 0)            //可能是视频分享
                                            {
                                                try
                                                {
                                                    string bvn = BiliApi.AVFinder.bvFromB23url(doc["msg"].GetAttribute("url"));
                                                    if (bvn != null)            //真的是视频分享
                                                    {
                                                        processVideoBilibili(e, bvn);
                                                        return;
                                                    }
                                                }
                                                catch (Exception)
                                                {
                                                }
                                            }
                                            break;

                                        case "网页分享":
                                            if (doc["msg"].GetAttribute("url").IndexOf("/live.bilibili.com/") > 0)            //直播分享
                                            {
                                            }
                                            if (doc["msg"].GetAttribute("url").IndexOf("/www.bilibili.com/video/") > 0)            //视频分享
                                            {
                                                string bvn = BiliApi.AVFinder.bvFromPlayURL(doc["msg"].GetAttribute("url"));
                                                if (bvn != null)            //真的是视频分享
                                                {
                                                    processVideoBilibili(e, bvn);
                                                    return;
                                                }
                                            }
                                            break;

                                        default:
                                            break;
                                        }
                                    }
                                }
                            }
                            break;

                            case "Json":
                            {
                                JsonMessage message = (JsonMessage)msg;
                                if (Commands.cocogroup == e.Sender.Group.Id)
                                {
                                    MainHolder.broadcaster.SendToGroup(e.Sender.Group.Id, "[Json解析]\n" + message.Json);
                                }
                                if (!DataBase.me.recQQmsg(e.Sender.Id, e.Sender.Group.Id, message.Json))
                                {
                                    MainHolder.Logger.Error("数据库", "未能将消息存入数据库");
                                }
                            }
                            break;

                            case "App":
                            {
                                AppMessage message = (AppMessage)msg;
                                if (Commands.cocogroup == e.Sender.Group.Id)
                                {
                                    MainHolder.broadcaster.SendToGroup(e.Sender.Group.Id, "[AppContent解析]\n" + message.Content);
                                }
                                if (!DataBase.me.recQQmsg(e.Sender.Id, e.Sender.Group.Id, message.Content))
                                {
                                    MainHolder.Logger.Error("数据库", "未能将消息存入数据库");
                                }
                                {
                                    string abvn = null;
                                    try
                                    {
                                        JObject jb = JObject.Parse(message.Content);
                                        abvn = AVFinder.bvFromB23url(jb["meta"]["detail_1"]["qqdocurl"].ToString());
                                    }
                                    catch
                                    {
                                    }
                                    if (abvn != null && abvn != "")
                                    {
                                        processVideoBilibili(e, abvn);
                                    }
                                }
                            }
                            break;

                            case "Source":
                                break;

                            case "Image":
                            {
                                /*try
                                 * {
                                 *  ImageMessage message = (ImageMessage)msg;
                                 *  Ticket t = TicketCoder.Decode(new Bitmap(PicLoader.loadPictureFromURL(message.Url)));
                                 *  string l = "未知";
                                 *  switch (t.Data.Level)
                                 *  {
                                 *      case Ticket.CrewLevel.舰长:
                                 *          l = "舰长";
                                 *          break;
                                 *      case Ticket.CrewLevel.总督:
                                 *          l = "总督";
                                 *          break;
                                 *      case Ticket.CrewLevel.提督:
                                 *          l = "提督";
                                 *          break;
                                 *  }
                                 *  BiliUser bu = new BiliUser(t.Data.Uid, MainHolder.biliapi);
                                 *  MainHolder.broadcaster.SendToGroup(e.Sender.Group.Id, "[船票]\n" +
                                 *      "版本=" + t.Data.SpecType + "\n" +
                                 *      "绑定账号=" + bu.name + "#" + t.Data.Uid + "\n" +
                                 *      "签发时间=" + t.Data.GenerateTime.ToString("yyyy MM dd HH:mm:ss") + "\n" +
                                 *      "等级=" + l + "\n" +
                                 *      "签名有效");
                                 * }
                                 * catch (SignatureInvalidException err)
                                 * {
                                 *  MainHolder.broadcaster.SendToGroup(e.Sender.Group.Id, "该船票签名无效");
                                 * }
                                 * catch { }
                                 */
                            }
                            break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
            catch (Exception err)
            {
                MainHolder.broadcaster.BroadcastToAdminGroup("[Exception]\n这条消息可能意味着机器人发生了错误。它仍在继续运行,但可能不是很稳定。下面的信息用来帮助鸡蛋定位错误,管理不必在意。\n[群消息接收处理]" + err.Message + "\n\n堆栈跟踪:\n" + err.StackTrace);
            }
            return;
        }
示例#13
0
        public static int Main(string[] args)
        {
            #region 返回值错误码
            // -1 path路径不存在
            // -2 port超出范围[应该为1~65535]
            // -3 port已结被使用
            #endregion

            #region 注册右键
            RegisterHelper.RegisterRightClick();
            #endregion

            #region 参数初始化
            int    port  = new Random().Next(3000, 65535);
            string path  = AppDomain.CurrentDomain.BaseDirectory;
            string vpath = "/";
            if (args.Length != 0)
            {
                path = args[0];
            }
            #endregion

            #region path 处理
            if (!Directory.Exists(path))
            {
                AppMessage.Show("The directory '" + path + "' does not exist.");
                return(-1);
            }
            if (path.EndsWith("\\", StringComparison.Ordinal) == false)
            {
                path += "\\";
            }
            #endregion

            #region port 处理
            //从配置中读取端口
            if (File.Exists(path + Config.PortIniPath))
            {
                try
                {
                    StreamReader streamReader = new StreamReader(path + Config.PortIniPath, Encoding.UTF8);
                    string       value        = streamReader.ReadToEnd();
                    streamReader.Close();
                    port = Convert.ToInt32(value);
                }
                catch (Exception ex)
                {
                }
            }
            if (port < 1 || port > 65535)
            {
                AppMessage.Show("Port is between 1 and 65535.");
                return(-2);
            }
            #endregion

            #region 创建服务 并 启动
            try
            {
                Server.Server server = new Server.Server(port, vpath, path, false);
                server.Start();

                Application.SetCompatibleTextRenderingDefault(false);
                Application.EnableVisualStyles();
                Application.Run(new AppForm(server));
            }
            catch (Exception ex)
            {
                AppMessage.Show("端口[" + port + "]已被占用,或已成功建立服务器!");
                Process.Start("http://localhost:" + port);
                return(-3);
            }
            #endregion

            return(1);
        }
示例#14
0
        /// <summary>
        /// 检查输入的有效性
        /// </summary>
        /// <returns>有效</returns>
        public override bool CheckInput()
        {
            bool returnValue = true;

            this.txtFullName.Text = this.txtFullName.Text.TrimEnd();
            if (this.txtFullName.Text.Trim().Length == 0)
            {
                MessageBox.Show(AppMessage.Format(AppMessage.MSG0007, AppMessage.MSG9978), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtFullName.Focus();
                return(false);
            }
            long sequence = 0;

            if (this.txtSequence.Text.Trim().Length == 0)
            {
                MessageBox.Show(AppMessage.Format(AppMessage.MSG0007, AppMessage.MSG0215), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtSequence.Focus();
                return(false);
            }
            else
            {
                if (!long.TryParse(this.txtSequence.Text, out sequence))
                {
                    MessageBox.Show(AppMessage.Format(AppMessage.MSG0030, AppMessage.MSG0215), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.txtSequence.Focus();
                    return(false);
                }
            }
            long reduction = 0;

            if (this.txtReduction.Text.Trim().Length == 0)
            {
                MessageBox.Show(AppMessage.Format(AppMessage.MSG0007, AppMessage.MSG0216), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtReduction.Focus();
                return(false);
            }
            else
            {
                if (!long.TryParse(this.txtReduction.Text, out reduction))
                {
                    MessageBox.Show(AppMessage.Format(AppMessage.MSG0030, AppMessage.MSG0216), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.txtReduction.Focus();
                    return(false);
                }
            }
            if (sequence <= reduction)
            {
                MessageBox.Show(AppMessage.Format(AppMessage.MSG0025, AppMessage.MSG0216, AppMessage.MSG0215), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtSequence.Focus();
                return(false);
            }
            int step = 0;

            if (this.txtStep.Text.Trim().Length == 0)
            {
                MessageBox.Show(AppMessage.Format(AppMessage.MSG0007, AppMessage.MSG0217), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtStep.Focus();
                return(false);
            }
            else
            {
                if (!int.TryParse(this.txtStep.Text, out step))
                {
                    MessageBox.Show(AppMessage.Format(AppMessage.MSG0030, AppMessage.MSG0217), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.txtSequence.Focus();
                    return(false);
                }
            }
            return(returnValue);
        }
        /// <summary>
        /// Creates an incoming message.
        /// </summary>
        /// <param name="endpoint">The endpoint.</param>
        /// <param name="payload">The payload.</param>
        /// <returns>A specific message type</returns>
        public static P3bbleMessage CreateMessage(Endpoint endpoint, List <byte> payload)
        {
            P3bbleMessage frame = null;

            switch (endpoint)
            {
            case Endpoint.Ping:
                frame = new PingMessage();
                break;

            case Endpoint.Version:
                frame = new VersionMessage();
                break;

            case Endpoint.Time:
                frame = new TimeMessage();
                break;

            case Endpoint.Logs:
                frame = new LogsMessage();
                break;

            case Endpoint.AppManager:
                frame = new AppManagerMessage();
                break;

            case Endpoint.AppManagerV3:
                frame = new AppManagerMessageV3();
                break;

            case Endpoint.MusicControl:
                frame = new MusicMessage();
                break;

            case Endpoint.ApplicationMessage:
                frame = new AppMessage(endpoint);
                break;

            case Endpoint.PhoneVersion:
                frame = new PhoneVersionMessage(false);
                break;

            case Endpoint.PutBytes:
                frame = new PutBytesMessage();
                break;

            case Endpoint.WatchFaceSelect:
                frame = new WatchFaceMessage();
                break;

            case Endpoint.StandardV3:
                frame = new StandardV3Message();
                break;
            }

            if (frame != null)
            {
                frame.GetContentFromMessage(payload);
            }

            return(frame);
        }
示例#16
0
 public static IAppMessage TaskGroupExecutionCancelled(string GroupName)
 => AppMessage.Inform("The @GroupName task group was cancelled", new
 {
     GroupName
 });
 public IActionResult Index(AppMessage obj)
 {
     ViewBag.Message = "Message changed";
     return(View(obj));
 }
示例#18
0
 public static IAppMessage WaitingForTasks(int Count, int Timeout)
 => AppMessage.Inform("Waiting a maximum of @Timeout ms for @Count currently executing tasks to finish", new
 {
     Count,
     Timeout
 });
示例#19
0
        /// <summary>
        /// 检查批量删除的输入的有效性
        /// </summary>
        /// <returns>允许批量删除</returns>
        private bool CheckInputBatchDelete()
        {
            bool            returnValue   = false;
            int             selectedCount = 0;
            BaseItemsEntity itemsEntity   = new BaseItemsEntity();

            foreach (DataGridViewRow dgvRow in grdItems_.Rows)
            {
                DataRow dataRow = (dgvRow.DataBoundItem as DataRowView).Row;
                if (dataRow.RowState != DataRowState.Deleted)
                {
                    if ((System.Boolean)(dgvRow.Cells["colSelected"].Value ?? false))
                    {
                        // 是否允许删除
                        itemsEntity.GetFrom(dataRow);
                        if (itemsEntity.AllowDelete == 0)
                        {
                            returnValue = false;
                            MessageBox.Show(AppMessage.Format(AppMessage.MSG0018, itemsEntity.FullName), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            // 这里需要直接返回了,不再进行输入交验了。
                            return(returnValue);
                        }
                        else
                        {
                            selectedCount++;
                        }
                    }
                }
            }

            //foreach (DataRowView dataRowView in this.DTItems.DefaultView)
            //{
            //    DataRow dataRow = dataRowView.Row;
            //    if (dataRow.RowState != DataRowState.Deleted)
            //    {
            //        if (dataRow["colSelected"].ToString() == true.ToString())
            //        {
            //            // 是否允许删除
            //            itemsEntity.GetFrom(dataRow);
            //            if (itemsEntity.AllowDelete == 0)
            //            {
            //                returnValue = false;
            //                MessageBox.Show(AppMessage.Format(AppMessage.MSG0018, itemsEntity.FullName), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
            //                // 这里需要直接返回了,不再进行输入交验了。
            //                return returnValue;
            //            }
            //            else
            //            {
            //                selectedCount++;
            //            }
            //        }
            //    }
            //}
            // 有记录被选中了
            returnValue = selectedCount > 0;
            if (!returnValue)
            {
                MessageBox.Show(AppMessage.MSG0024, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(returnValue);
        }
示例#20
0
 public static IAppMessage TasksUnfinished(int Count, int Timeout)
 => AppMessage.Warn("There were @Count currentingly executing tasks when a wait timeout of @Timeout ms expired", new
 {
     Count,
     Timeout
 });
 public AppException(AppMessage appMessage, string description = null)
     : base(appMessage.ToString())
 {
     AppMessage  = appMessage;
     Description = description;
 }
示例#22
0
 public static IAppMessage ExecutionIndexUpdateFailed(int TaskId)
 => AppMessage.Error("Could not add task @TaskId to the execution index", new
 {
     TaskId
 });
示例#23
0
 public string pushMessageToApp(AppMessage message)
 {
     return(pushMessageToApp(message, null));
 }
示例#24
0
 public static IAppMessage SpinnerCompleted(Task spinner)
 => AppMessage.Babble("Spinner @TaskId completed", new
 {
     TaskId = spinner.Id
 });
示例#25
0
        /// <summary>
        /// 检查批量删除的输入的有效性
        /// </summary>
        /// <returns>允许批量删除</returns>
        private bool CheckInputBatchDelete()
        {
            bool returnValue = false;

            // 检查至少要选择一个?
            if (!BaseInterfaceLogic.CheckInputSelectAnyOne(this.grdSequence, "colSelected"))
            {
                return(returnValue);
            }
            int selectedCount = 0;
            BaseSequenceEntity sequenceEntity = new BaseSequenceEntity();

            foreach (DataGridViewRow dgvRow in grdSequence.Rows)
            {
                DataRow dataRow = (dgvRow.DataBoundItem as DataRowView).Row;
                if (dataRow.RowState != DataRowState.Deleted)
                {
                    if ((System.Boolean)(dgvRow.Cells["colSelected"].Value ?? false))
                    {
                        sequenceEntity = new BaseSequenceEntity(dataRow);
                        // 有权限删除
                        if (!sequenceEntity.FullName.Equals("BaseSequence"))
                        {
                            selectedCount++;
                        }
                        else
                        {
                            MessageBox.Show(AppMessage.Format(AppMessage.MSG0018, "BaseSequence"), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return(returnValue);
                        }
                    }
                }
            }

            //foreach (DataRowView dataRowView in this.DTSequence.DefaultView)
            //{
            //    DataRow dataRow = dataRowView.Row;
            //    if (dataRow.RowState != DataRowState.Deleted)
            //    {
            //        if (dataRow["colSelected"].ToString() == true.ToString())
            //        {
            //            sequenceEntity = new BaseSequenceEntity(dataRow);
            //            // 有权限删除
            //            if (!sequenceEntity.FullName.Equals("BaseSequence"))
            //            {
            //                selectedCount++;
            //            }
            //            else
            //            {
            //                MessageBox.Show(AppMessage.Format(AppMessage.MSG0018, "BaseSequence"), AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
            //                return returnValue;
            //            }
            //        }
            //    }
            //}
            // 有记录被选中了
            returnValue = selectedCount > 0;
            if (!returnValue)
            {
                MessageBox.Show(AppMessage.MSG0024, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(returnValue);
        }
示例#26
0
 public static IAppMessage Stopping()
 => AppMessage.Inform("Stopping agent");
示例#27
0
 static IAppMessage DestinationExists(C spec)
 => AppMessage.Error($"Destination path @DstPath exists and {nameof(spec.Overwrite)} is false",
                     new
 {
     spec.DstPath
 });
示例#28
0
 public static IAppMessage Stopped()
 => AppMessage.Inform("Agent execution stopped");
示例#29
0
 static IAppMessage SourceDoesNotExist(C spec)
 => AppMessage.Error("The source path @SrcPath does not exist",
                     new
 {
     spec.SrcPath
 });
示例#30
0
 public static IAppMessage AlreadyRunning()
 => AppMessage.Warn("The agent is already running");
示例#31
0
        private static void BroadcastAppMessageAndCleanUp(AppMessage msg)
        {
            try
            {
                // NativeMethods.PostMessage((IntPtr)NativeMethods.HWND_BROADCAST,
                //	m_nAppMessage, (IntPtr)msg, IntPtr.Zero);
                IpcBroadcast.Send(msg, 0, false);
            }
            catch(Exception) { Debug.Assert(false); }

            MainCleanUp();
        }
示例#32
0
文件: Parsers.cs 项目: 0xCM/Meta.Core
 static ParseResult <char> _match(TextBlock input, char value)
 => from c in character.parse(input).Value
 select c.Parsed == value?success(c.Parsed, c.Remainder)
     : error <char>(input, AppMessage.Error($"The character '{value}' was not matched"));