Beispiel #1
0
 /// <summary>
 /// 调用回调函数通知客户端执行出错
 /// </summary>
 /// <param name="message">错误信息</param>
 /// <param name="type">操作的类型</param>
 public void ErrorNotify(string message, ExcuteType type)
 {
     if (m_callback != null)
     {
         m_callback.ErrorNotify("registration", message, type);
     }
 }
Beispiel #2
0
 public StateDescription(string appName, ExcuteType excuteType, ExcuteState excuteState, double statePercentage, Exception exception)
 {
     AppName = appName;
     ExcuteType = excuteType;
     ExcuteState = excuteState;
     StatePercentage = statePercentage;
     Exception = exception;
     _dateTime = DateTime.Now;
 }
 public StateDescription(string appName, ExcuteType excuteType, ExcuteState excuteState, double statePercentage, Exception exception)
 {
     AppName         = appName;
     ExcuteType      = excuteType;
     ExcuteState     = excuteState;
     StatePercentage = statePercentage;
     Exception       = exception;
     _dateTime       = DateTime.Now;
 }
Beispiel #4
0
 protected virtual void PreExcuteCommand(ExcuteType excuteType)
 {
     if (objectDAO.SessionManager != null)
     {
         Transaction = objectDAO.SessionManager.GetCurrentTransaction(Connection);
     }
     if (Connection.State == ConnectionState.Closed)
     {
         Connection.Open();
     }
     //Console.WriteLine(CommandText);//TODO: Add log here.
 }
Beispiel #5
0
 public static void UpdateState(string appName, ExcuteType excuteType, ExcuteState excuteState, double statePercentage, Exception exception = null)
 {
     //CheckConnect();
     //var stateDesc = new StateDescription
     //    (
     //    appName,
     //    excuteType,
     //    excuteState,
     //    statePercentage,
     //    exception
     //    );
     //StatePacket packet = new StatePacket("", StatePacket.Type.AddMonitor, Serializer.SerializeToBytes(stateDesc));
     //foreach (var client in _clients)
     //{
     //    client.Send<string>(packet);
     //}
 }
Beispiel #6
0
        public TaskExcuteActor()
        {
            ReceiveAsync <int>(async taskId =>
            {
                //await Context.ActorOf<UpdateVersionActor>().Ask(string.Empty);
                Log(taskId, GameAction.START_TASK, "正在准备执行任务");
                using (var db = new Db())
                    task = db.GetTaskById(taskId);
                if (task == null)
                {
                    await TaskError(taskId, GameAction.START_TASK, null, "TASK NOT EXISTS \r\n" + "ID: " + taskId);
                    return;
                }
                if (task.enable == false)
                {
                    Log(taskId, GameAction.START_TASK, "任务被禁用,请编辑任务后启动");
                    await TaskError(taskId, GameAction.START_TASK, null, "TASK NOT ENABLED \r\n" + "ID: " + taskId);
                    return;
                }
                if (task.end_time != null && task.end_time.Value < DateTime.Now)
                {
                    Log(taskId, GameAction.START_TASK, "任务已经到期");
                    await TaskError(taskId, GameAction.START_TASK, null, "TASK IS END!\r\n" + "ID: " + taskId);
                    return;
                }
                if (task.state == (int)TaskState.RUNNING && task.expires_time > DateTime.Now)
                {
                    Log(taskId, GameAction.START_TASK, "检查到任务正在进行中,等待结果");
                    await TaskError(taskId, GameAction.START_TASK, null, "TASK IS RUNNING!\r\n" + "ID: " + taskId);
                    return;
                }
                using (var db = new Db())
                    role = db.GetUserRoleById(task.user_role_id);
                if (role == null)
                {
                    Log(taskId, GameAction.START_TASK, "执行帐号不存在,任务无法执行");
                    await TaskError(taskId, GameAction.START_TASK, null, "ROLE NOT EXISTS \r\n" + "ID: " + taskId + ", ROLE_ID: " + task.user_role_id);
                    return;
                }
                using (var db = new Db())
                    device = db.GetDeviceById(role.device_id);
                if (device == null)
                {
                    Log(taskId, GameAction.START_TASK, "执行帐号设备信息不存在,任务无法执行");
                    await TaskError(taskId, GameAction.START_TASK, null, "DEVICE NOT EXISTS!\r\n" + "ID: " + taskId + ", ROLE_ID: " + task.user_role_id + ",DEVICE_ID: " + role.device_id);
                    return;
                }
                if (task.state != 0 && task.expires_time < DateTime.Now)
                {
                    excuteType = ExcuteType.Expires;
                }
                else if (task.state == (int)TaskState.NET_ERROR || task.state == (int)TaskState.GAME_ERROR)
                {
                    excuteType = ExcuteType.ErrorReStart;
                }
                if (excuteType == ExcuteType.Expires)
                {
                    Log(taskId, GameAction.START_TASK, "检测任务执行超时,恢复任务中");
                }
                else if (excuteType == ExcuteType.ErrorReStart)
                {
                    Log(taskId, GameAction.START_TASK, "检测任务执行失败,恢复任务中");
                }

                using (var db = new Db())
                {
                    roleData = db.GetRoleDataByRoleId(role.id);
                    if (roleData == null)
                    {
                        roleData = new role_data()
                        {
                            role_id    = role.id,
                            last_login = new DateTime(1990, 1, 1)
                        };
                        db.Add(roleData);
                    }

                    var taskDataList = db.GetTaskDataByTaskId(task.id);
                    var dataDic      = new Dictionary <string, string>();
                    foreach (var item in taskDataList)
                    {
                        dataDic[item.name] = item.value;
                    }
                    taskDatas = dataDic;
                    db.Database.ExecuteSqlCommand("update user_task set state=@p0 where id=@p1", (int)TaskState.RUNNING, taskId);
                }
                if (task.current_action == 1024)
                {
                    task.current_action = 0;
                }
                switch (task.action)
                {
                case "Login":
                    await ExcuteLoginTask();
                    break;

                case "Battle":
                    await ExcuteBattleTask();
                    break;

                default:
                    Log(task.id, GameAction.START_TASK, "未知的计划类型,禁用该计划");
                    using (var db = new Db())
                        db.Database.ExecuteSqlCommand("update user_task set state=0,enable=0,current_action=0 where id=@p1", taskId);
                    await TaskError(taskId, GameAction.START_TASK, null, "ID: " + taskId + " UNKNOWN ACTION!");
                    return;
                }
                Sender.Tell(true);
            });
        }
 public IAsyncResult BeginErrorNotify(string serviceName, string message, ExcuteType type, AsyncCallback callback, object asyncState)
 {
     return(null);
 }
Beispiel #8
0
 protected virtual void PostExcuteCommand(ExcuteType excuteType)
 {
 }