Exemplo n.º 1
0
 /// <summary>
 /// 初始化线程模型
 /// </summary>
 /// <param name="name">线程名称</param>
 /// <param name="count">线程数量</param>
 public SzThread(String name, ThreadType threadtype = ThreadType.User, Int32 count = 1)
 {
     this.threadType = threadtype;
     this.Name       = name;
     this.ID         = ids.GetId();
     if (count == 1)
     {
         System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(Run));
         thread.IsBackground = true;
         //仅次于最高级
         thread.Priority = ThreadPriority.AboveNormal;
         thread.Name     = "<" + name + "线程>";
         thread.Start();
         if (log.IsInfoEnabled())
         {
             log.Info("初始化 " + thread.Name);
         }
     }
     else
     {
         for (int i = 0; i < count; i++)
         {
             System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ThreadStart(Run));
             thread.IsBackground = true;
             //仅次于最高级
             thread.Priority = ThreadPriority.AboveNormal;
             thread.Name     = "<" + name + "线程" + "_" + (i + 1) + ">";
             thread.Start();
             if (log.IsInfoEnabled())
             {
                 log.Info("初始化 " + thread.Name);
             }
         }
     }
 }
        /// <summary>
        ///     Creates a thread within this <see cref="ITextChannel"/>.
        /// </summary>
        /// <remarks>
        ///     When <paramref name="message"/> is <see langword="null"/> the thread type will be based off of the
        ///     channel its created in. When called on a <see cref="ITextChannel"/>, it creates a <see cref="ThreadType.PublicThread"/>.
        ///     When called on a <see cref="INewsChannel"/>, it creates a <see cref="ThreadType.NewsThread"/>. The id of the created
        ///     thread will be the same as the id of the message, and as such a message can only have a
        ///     single thread created from it.
        /// </remarks>
        /// <param name="name">The name of the thread.</param>
        /// <param name="type">
        ///     The type of the thread.
        ///     <para>
        ///         <b>Note: </b>This parameter is not used if the <paramref name="message"/> parameter is not specified.
        ///     </para>
        /// </param>
        /// <param name="autoArchiveDuration">
        ///     The duration on which this thread archives after.
        ///     <para>
        ///         <b>Note: </b> Options <see cref="ThreadArchiveDuration.OneWeek"/> and <see cref="ThreadArchiveDuration.ThreeDays"/>
        ///         are only available for guilds that are boosted. You can check in the <see cref="IGuild.Features"/> to see if the
        ///         guild has the <b>THREE_DAY_THREAD_ARCHIVE</b> and <b>SEVEN_DAY_THREAD_ARCHIVE</b>.
        ///     </para>
        /// </param>
        /// <param name="message">The message which to start the thread from.</param>
        /// <param name="options">The options to be used when sending the request.</param>
        /// <returns>
        ///     A task that represents the asynchronous create operation. The task result contains a <see cref="IThreadChannel"/>
        /// </returns>
        public virtual async Task <RestThreadChannel> CreateThreadAsync(string name, ThreadType type = ThreadType.PublicThread,
                                                                        ThreadArchiveDuration autoArchiveDuration = ThreadArchiveDuration.OneDay, IMessage message = null, bool?invitable = null, int?slowmode = null, RequestOptions options = null)
        {
            var model = await ThreadHelper.CreateThreadAsync(Discord, this, name, type, autoArchiveDuration, message, invitable, slowmode, options);

            return(RestThreadChannel.Create(Discord, Guild, model));
        }
Exemplo n.º 3
0
 public static void Disconnect(ThreadType type, string username)
 {
     try
     {
         if (type == ThreadType.AnonymousThread)
         {
             Thread value;
             AnonymousThreads.TryRemove(username, out value);
             value.Join();
         }
         if (type == ThreadType.ClientThread)
         {
             Thread value;
             ClientThreads.TryRemove(username, out value);
             IMessagingClient client;
             Clients.TryRemove(username, out client);
             foreach (IMessagingClient sclient in Clients.Values)
             {
                 sclient.Alert(String.Format("{0} has diconnected", username), 3);
             }
             value.Join();
         }
     }
     catch (Exception e)
     {
         Guid guid = Guid.NewGuid();
         ConsoleUtilities.PrintCritical("A major server error has occured. Report to developer immediately. Writing to file {0}.error", guid);
         StreamWriter writer = new StreamWriter(String.Format("{0}.error", guid));
         writer.WriteLine(e.Message);
         foreach (var i in e.Data)
         {
             writer.WriteLine("{0}", i);
         }
     }
 }
Exemplo n.º 4
0
 private ThreadUpdateAuditLogData(IThreadChannel thread, ThreadType type, ThreadInfo before, ThreadInfo after)
 {
     Thread     = thread;
     ThreadType = type;
     Before     = before;
     After      = After;
 }
Exemplo n.º 5
0
        public async Task SearchOrCreateThreadAsyncTest_WhenThreadTypeIsTeamAndParticipantGuidExist_ThrowsInvalidRequestException()
        {
            var threadMockRepository  = new Mock <IThreadRepository>();
            var userMockRepository    = new Mock <IUserRepository>();
            var messageMockRepository = new Mock <IMessageRepository>();
            var groupMockRepository   = new Mock <IGroupRepository>();
            var partnerMockRepository = new Mock <IPartnerRepository>();
            var contactMockRepository = new Mock <IContactRepository>();
            var logMockRepository     = new Mock <ILogRepository>();
            var teamMockRepository    = new Mock <ITeamRepository>();

            var mapper = GetMapperForThreadProfile();

            var userId            = _rnd.Next(111, 1000);
            var participantGuid   = Guid.NewGuid();
            const ThreadType type = ThreadType.Team;

            var threadManager = new ThreadManager(partnerMockRepository.Object, threadMockRepository.Object, messageMockRepository.Object, groupMockRepository.Object, mapper, contactMockRepository.Object, teamMockRepository.Object, logMockRepository.Object);
            var exception     = await Assert.ThrowsAsync <InvalidRequestException>(() => threadManager.SearchOrCreateThreadAsync(userId, participantGuid.ToString(), type));

            Assert.IsType <InvalidRequestException>(exception);

            threadMockRepository.VerifyAll();
            userMockRepository.VerifyAll();
            messageMockRepository.VerifyAll();
            groupMockRepository.VerifyAll();
        }
Exemplo n.º 6
0
        public ThreadPoolSettings(int numThreads,
                                  ThreadType threadType,
                                  string name = null,
                                  ApartmentState apartmentState       = ApartmentState.Unknown,
                                  Action <Exception> exceptionHandler = null,
                                  int threadMaxStackSize        = 0,
                                  ThreadPriority threadPriority = ThreadPriority.Normal)
        {
            Name             = name ?? ("DedicatedThreadPool-" + Guid.NewGuid());
            ThreadType       = threadType;
            ThreadPriority   = threadPriority;
            NumThreads       = numThreads;
            ApartmentState   = apartmentState;
            ExceptionHandler = exceptionHandler ?? (ex =>
            {
                ThrowHelper.FailFast("Unhandled exception in dedicated thread pool: " + ex);
            });
            ThreadMaxStackSize = threadMaxStackSize;

#if !HAS_TPWORKITEM
            if (numThreads <= 0)
            {
                throw new ArgumentOutOfRangeException("numThreads", string.Format("numThreads must be at least 1. Was {0}", numThreads));
            }
#endif
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DedicatedThreadPoolSettings"/> class.
        /// </summary>
        /// <param name="numThreads">TBD</param>
        /// <param name="threadType">TBD</param>
        /// <param name="name">TBD</param>
        /// <param name="deadlockTimeout">TBD</param>
        /// <param name="apartmentState">TBD</param>
        /// <param name="exceptionHandler">TBD</param>
        /// <param name="threadMaxStackSize">TBD</param>
        /// <exception cref="ArgumentOutOfRangeException">
        /// This exception is thrown if the given <paramref name="deadlockTimeout"/> is set to less than 1ms.
        /// It can also be thrown if the given <paramref name="numThreads"/> is set to less than one.
        /// </exception>
        public DedicatedThreadPoolSettings(int numThreads,
                                           ThreadType threadType,
                                           string name = null,
                                           TimeSpan?deadlockTimeout            = null,
                                           ApartmentState apartmentState       = ApartmentState.Unknown,
                                           Action <Exception> exceptionHandler = null,
                                           int threadMaxStackSize = 0)
        {
            Name               = name ?? ("DedicatedThreadPool-" + Guid.NewGuid());
            ThreadType         = threadType;
            NumThreads         = numThreads;
            DeadlockTimeout    = deadlockTimeout;
            ApartmentState     = apartmentState;
            ExceptionHandler   = exceptionHandler ?? (ex => { });
            ThreadMaxStackSize = threadMaxStackSize;

            if (deadlockTimeout.HasValue && deadlockTimeout.Value.TotalMilliseconds <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(deadlockTimeout), $"deadlockTimeout must be null or at least 1ms. Was {deadlockTimeout}.");
            }
            if (numThreads <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(numThreads), $"numThreads must be at least 1. Was {numThreads}");
            }
        }
Exemplo n.º 8
0
        public void Deserialize(GenericReader reader)
        {
            int version = reader.ReadInt();

            switch (version)
            {
            case 0:
            {
                m_ThreadCreator      = reader.ReadMobile();
                m_LastPostTime       = reader.ReadDateTime();
                m_CreationTime       = reader.ReadDateTime();
                m_ThreadType         = ( ThreadType )reader.ReadInt();
                m_Posts              = ReadPostList(reader);
                m_Viewers            = reader.ReadMobileList();
                m_ViewersSinceUpdate = reader.ReadMobileList();
                m_Posters            = reader.ReadMobileList();
                m_PostersSinceUpdate = reader.ReadMobileList();
                m_FileInUse          = reader.ReadBool();
                m_StaffMessage       = reader.ReadBool();
                m_Deleted            = reader.ReadBool();
                m_Locked             = reader.ReadBool();
                m_Subject            = reader.ReadString();
                m_ThreadID           = reader.ReadInt();
                break;
            }
            }
        }
Exemplo n.º 9
0
 public HttpTask(ThreadType threadType, TaskResponse respType = TaskResponse.Default_Response)
 {
     this.type       = TaskType.HttpTask;
     this.threadType = threadType;
     this.respType   = respType;
     this.OutFilter  = new HttpOutFilter();
 }
Exemplo n.º 10
0
        /// <summary>
        /// Constructs <see cref="CPUResults"/> with
        /// a <see cref="RipperSettings"/> instance.
        /// </summary>
        /// <param name="rs">Takes in an initial <see cref="RipperSettings"/>
        /// but is marked <see langword="readonly"/> internally.</param>
        /// <param name="userData">The <see cref="UserData"/> to get the
        /// UserType from.</param>
        /// <param name="threadType">The thread type for the test.</param>

        public CPUResults(RipperSettings rs, ref UserData userData, ThreadType threadType)
        {
            this.TestCollection = new List <TimeSpan>();
            this.rs             = rs;
            this.userData       = userData;
            this.totalDuration  = new TimeSpan();
            this.GetThreadType  = threadType;
        }
Exemplo n.º 11
0
 public Action <T> GetExecutionAction(ThreadType threadType, int threadIndex)
 {
     if (OnGetExecutionAction != null)
     {
         return(OnGetExecutionAction(threadType, threadIndex));
     }
     return(_ => { });
 }
Exemplo n.º 12
0
 internal ManagedThread(ThreadType type, ContextCallback callback, object state, ExecutionContext ctx)
 {
     m_type        = type;
     m_status      = (type == ThreadType.QueuedThread ? ThreadStatus.Queued : ThreadStatus.Unstarted);
     m_ctxCallback = callback;
     m_state       = state;
     m_ctx         = ctx;
 }
Exemplo n.º 13
0
        public ThreadedExecuter(MethodDelegate method, CallBackDelegate callback, Boolean IsSynchronous = false)
        {
            this.methodDelegate   = method;
            this.callBackDelegate = callback;
            this.threadType       = ThreadType.Resource;
            t = new Thread(new ParameterizedThreadStart(this.Process));

            this.IsSynchronous = IsSynchronous;
        }
Exemplo n.º 14
0
 /// <summary>
 /// Represents a Facebook thread
 /// </summary>
 /// <param name="type"></param>
 /// <param name="uid"></param>
 /// <param name="photo"></param>
 /// <param name="name"></param>
 /// <param name="last_message_timestamp"></param>
 /// <param name="message_count"></param>
 public FB_Thread(ThreadType type, string uid, string photo = null, string name = null, string last_message_timestamp = null, int message_count = 0)
 {
     this.uid   = uid.ToString();
     this.type  = type;
     this.photo = photo;
     this.name  = name;
     this.last_message_timestamp = last_message_timestamp;
     this.message_count          = message_count;
 }
Exemplo n.º 15
0
 public TimerTask(long start, long end, int frequency, ThreadType type = ThreadType.BackGround)
 {
     startTime      = start;
     endTime        = end;
     this.frequency = frequency;
     leftTime       = 0;
     curFre         = frequency;
     threadTp       = type;
 }
Exemplo n.º 16
0
 public DedicatedThreadPoolSettings(int numThreads, ThreadType threadType)
 {
     ThreadType = threadType;
     NumThreads = numThreads;
     if (numThreads <= 0)
     {
         throw new ArgumentOutOfRangeException("numThreads", string.Format("numThreads must be at least 1. Was {0}", numThreads));
     }
 }
Exemplo n.º 17
0
 /// <summary>
 /// Represents a Facebook thread
 /// </summary>
 /// <param name="type"></param>
 /// <param name="uid"></param>
 /// <param name="photo"></param>
 /// <param name="name"></param>
 /// <param name="last_message_timestamp"></param>
 /// <param name="message_count"></param>
 /// <param name="plan"></param>
 public FB_Thread(ThreadType type, string uid, string photo = null, string name = null, string last_message_timestamp = null, int message_count = 0, FB_Plan plan = null)
 {
     this.uid   = uid;
     this.type  = type;
     this.photo = photo;
     this.name  = name;
     this.last_message_timestamp = last_message_timestamp;
     this.message_count          = message_count;
     this.plan = plan;
 }
Exemplo n.º 18
0
        public void UpdateThread(int threadID, string title, ThreadType threadType, string image)
        {
            var thread = _threadRepository.Get(threadID);

            thread.Title = title;
            thread.Type  = (int)threadType;
            thread.Image = image;
            _threadRepository.Update(thread);
            _unitOfWork.Commit();
        }
 public DedicatedThreadPoolSettings(int numThreads, ThreadType threadType, TimeSpan? deadlockTimeout = null)
 {
     ThreadType = threadType;
     NumThreads = numThreads;
     DeadlockTimeout = deadlockTimeout;
     if (deadlockTimeout.HasValue && deadlockTimeout.Value.TotalMilliseconds <= 0)
         throw new ArgumentOutOfRangeException("deadlockTimeout", string.Format("deadlockTimeout must be null or at least 1ms. Was {0}.", deadlockTimeout));
     if (numThreads <= 0)
         throw new ArgumentOutOfRangeException("numThreads", string.Format("numThreads must be at least 1. Was {0}", numThreads));
 }
 public AbstractRequestWorker(RequestHandler handler, ThreadType threadType)
 {
     mHandler    = handler ?? throw new ArgumentNullException("handler == nunll");
     mThreadType = threadType;
     if (threadType == ThreadType.Work)
     {
         mRequestQueue = new Queue <Request>();
     }
     mThreadUtil = GetThreadUtil();
 }
 protected ThreadControl GetControl(ThreadType threadType)
 {
     if (dictThreadType2Control.ContainsKey(threadType))
     {
         return(dictThreadType2Control[threadType]);
     }
     else
     {
         throw new Exception($"there is no thread which is of type '{threadType}'");
     }
 }
Exemplo n.º 22
0
 private ThreadDeleteAuditLogData(ulong id, string name, ThreadType type, bool archived,
                                  ThreadArchiveDuration autoArchiveDuration, bool locked, int?rateLimit)
 {
     ThreadId            = id;
     ThreadName          = name;
     ThreadType          = type;
     IsArchived          = archived;
     AutoArchiveDuration = autoArchiveDuration;
     IsLocked            = locked;
     SlowModeInterval    = rateLimit;
 }
 public DedicatedThreadPoolSettings(int numThreads, ThreadType threadType, string name = null, TimeSpan? deadlockTimeout = null, ApartmentState apartmentState = ApartmentState.Unknown)
 {
     Name = name ?? ("DedicatedThreadPool-" + Guid.NewGuid());
     ThreadType = threadType;
     NumThreads = numThreads;
     DeadlockTimeout = deadlockTimeout;
     ApartmentState = apartmentState;
     if (deadlockTimeout.HasValue && deadlockTimeout.Value.TotalMilliseconds <= 0)
         throw new ArgumentOutOfRangeException("deadlockTimeout", string.Format("deadlockTimeout must be null or at least 1ms. Was {0}.", deadlockTimeout));
     if (numThreads <= 0)
         throw new ArgumentOutOfRangeException("numThreads", string.Format("numThreads must be at least 1. Was {0}", numThreads));
 }
Exemplo n.º 24
0
        public async Task SearchOrCreateThreadAsyncTest_WhenThreadTypeIsUserAndParticipantGuidExist_ReturnsThreadWithMessagesResponseModel()
        {
            var threadMockRepository  = new Mock <IThreadRepository>();
            var userMockRepository    = new Mock <IUserRepository>();
            var messageMockRepository = new Mock <IMessageRepository>();
            var groupMockRepository   = new Mock <IGroupRepository>();
            var partnerMockRepository = new Mock <IPartnerRepository>();
            var contactMockRepository = new Mock <IContactRepository>();
            var logMockRepository     = new Mock <ILogRepository>();
            var teamMockRepository    = new Mock <ITeamRepository>();

            var userId            = _rnd.Next(111, 1000);
            var participantGuid   = _rnd.Next(111, 1000);
            const ThreadType type = ThreadType.User;

            var mapper             = GetMapperForThreadProfile();
            var threadEntity       = EntityModellers.CreateThreadEntity();
            var chatUserEntity     = EntityModellers.CreateChatUserEntity();
            var messageEntity      = EntityModellers.CreateMessageEntity();
            var chatUserEntityList = new List <ChatUser> {
                chatUserEntity
            };

            contactMockRepository.Setup(x => x.GetChatUserDetailAsync(participantGuid)).ReturnsAsync(chatUserEntity);
            contactMockRepository.Setup(x => x.GetChatUserDetailsAsync(threadEntity.Participants)).ReturnsAsync(chatUserEntityList);

            threadEntity.Participants.Add(participantGuid);
            threadMockRepository.Setup(x => x.SearchByParticipantIdsAsync(userId, participantGuid)).ReturnsAsync(threadEntity);
            messageMockRepository.Setup(x => x.GetByThreadIdAsync(threadEntity.Id)).ReturnsAsync(new List <MessageEntity> {
                messageEntity
            });

            var participantResponse = mapper.Map <IEnumerable <ChatUser>, IEnumerable <UserContactResponseModel> >(new List <ChatUser> {
                chatUserEntity
            });
            var messagesResponse = mapper.Map <IEnumerable <MessageEntity>, IEnumerable <MessageResponseModel> >(new List <MessageEntity> {
                messageEntity
            });
            var threadResponse     = mapper.Map <ThreadEntity, ThreadWithMessagesResponseModel>(threadEntity);
            var threadWithMessages = mapper.Map(messagesResponse, threadResponse);
            var expected           = mapper.Map(participantResponse, threadWithMessages);

            var threadManager = new ThreadManager(partnerMockRepository.Object, threadMockRepository.Object, messageMockRepository.Object, groupMockRepository.Object, mapper, contactMockRepository.Object, teamMockRepository.Object, logMockRepository.Object);
            var actual        = await threadManager.SearchOrCreateThreadAsync(userId, participantGuid.ToString(), type);

            Assert.Equal(expected, actual, new LogicEqualityComparer <ThreadWithMessagesResponseModel>());
            threadMockRepository.VerifyAll();
            userMockRepository.VerifyAll();
            messageMockRepository.VerifyAll();
            groupMockRepository.VerifyAll();
            teamMockRepository.VerifyAll();
            partnerMockRepository.VerifyAll();
        }
Exemplo n.º 25
0
        public static string GetStringValue(this ThreadType enumValue)
        {
            switch (enumValue)
            {
            case ThreadType.Cpu: return("cpu");

            case ThreadType.Wait: return("wait");

            case ThreadType.Block: return("block");
            }
            throw new ArgumentException($"'{enumValue.ToString()}' is not a valid value for enum 'ThreadType'");
        }
Exemplo n.º 26
0
        protected virtual void GetThread()
        {
            ThreadType realThreadType = ThreadType.Normal;

            if (IsOnlyLookOneUser)
            {
                int totalCount;
                PostBOV5.Instance.GetUserPosts(ThreadID, LookUserID, ThreadType.Normal, PageNumber, PageSize, true, false, out m_Thread, out m_PostList, out realThreadType, out totalCount);

                m_TotalPosts = totalCount;
            }
            else
            {
                if (string.IsNullOrEmpty(Type))
                {
                    PostBOV5.Instance.GetThreadWithReplies(ThreadID, PageNumber, PageSize, true, UpdateView, true, out m_Thread, out m_PostList, out realThreadType);
                }
                else if (GetPosts(ThreadType.Normal, out m_TotalPosts, out m_Thread, out m_PostList))
                {
                }
                else if (IsUnapprovePosts || IsMyUnapprovePosts)
                {
                    m_MustRemovePostListFirstOne = false;
                    int total;
                    PostBOV5.Instance.GetUnapprovedPostThread(ThreadID, null, PageNumber, PageSize, out m_Thread, out m_PostList, out total);
                    m_TotalPosts = total;
                }
                else
                {
                    ShowError(new InvalidParamError("type"));
                }
            }
            //如果不是 投票 问题  辩论  则跳到相应的页面
            if (realThreadType != ThreadType.Normal)
            {
                Response.Redirect(BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, PostBOV5.Instance.GetThreadTypeString(realThreadType)));
            }

            PostBOV5.Instance.ProcessKeyword(m_PostList, ProcessKeywordMode.TryUpdateKeyword);

            //if (_Request.IsSpider == false)
            //{
            //List<int> userIDs = new List<int>();
            //foreach(PostV5 post in m_PostList)
            //{
            //    userIDs.Add(post.UserID);
            //}
            //UserBO.Instance.GetUsers(userIDs, GetUserOption.WithAll);
            UserBO.Instance.GetUsers(m_PostList.GetUserIds(), GetUserOption.WithAll);
            //}
        }
Exemplo n.º 27
0
        public void SubscribeToComponentStateRequest <T>(Action <ComponentStateRequest <T> > componentStateRequestHandler,
                                                         ComponentId componentId = ComponentId.UNDEFINED,
                                                         ThreadType threadType   = ThreadType.PublisherThread) where T : RequestedComponentState
        {
            Predicate <ComponentStateRequest <T> > filter = null;

            if (componentId != ComponentId.UNDEFINED)
            {
                filter = chg => chg.Id == componentId;
            }
            _eventAggregator.GetEvent <ComponentStateRequestEvent <ComponentStateRequest <T> > >().Unsubscribe(componentStateRequestHandler);
            _eventAggregator.GetEvent <ComponentStateRequestEvent <ComponentStateRequest <T> > >().Subscribe(componentStateRequestHandler,
                                                                                                             threadType.ToThreadOption(), true, filter);
        }
Exemplo n.º 28
0
 public DedicatedThreadPoolSettings(int numThreads, ThreadType threadType, TimeSpan?deadlockTimeout = null)
 {
     ThreadType      = threadType;
     NumThreads      = numThreads;
     DeadlockTimeout = deadlockTimeout;
     if (deadlockTimeout.HasValue && deadlockTimeout.Value.TotalMilliseconds <= 0)
     {
         throw new ArgumentOutOfRangeException("deadlockTimeout", string.Format("deadlockTimeout must be null or at least 1ms. Was {0}.", deadlockTimeout));
     }
     if (numThreads <= 0)
     {
         throw new ArgumentOutOfRangeException("numThreads", string.Format("numThreads must be at least 1. Was {0}", numThreads));
     }
 }
Exemplo n.º 29
0
 public bool CanCreateThreadType(int forumID, int userID, ThreadType type)
 {
     int posting = GetPermissionValue(forumID, userID, Permission.Posting);
     switch (type)
     {
         case ThreadType.Regular:
         case ThreadType.Sticky:
         case ThreadType.Announcement:
         case ThreadType.GlobalAnnouncement:
             return posting >= (int)type;
         default:
             return false;
     }
 }
Exemplo n.º 30
0
        /// <summary>
        /// Runs the benchmarking test on the CPU
        /// with a particular <see cref="ThreadType"/>.
        /// </summary>
        /// <param name="threadType">The type of threading
        /// for the test.</param>
        /// <param name="userData">The <see cref="UserData"/> thats passed
        /// into the instance for user information but is marked
        /// <see langword="readonly"/> internally.</param>
        /// <param name="ui">The <see cref="MainWindow"/> instance thats passed
        /// into for UI related tasks for updating components in it.</param>
        /// <returns>A new <see cref="CPUResults"/> instance
        /// containing the result.</returns>
        /// <exception cref="RipperThreadException"></exception>

        public void RunCPUBenchmark(ThreadType threadType, ref UserData userData, MainWindow ui)
        {
            var results = new CPUResults(this.rs, ref userData, threadType);

            switch (threadType)
            {
            case ThreadType.Single:
            {
                // runs task on main thread.
                RunTestsSingle(ref results);

                InteractWithUI(ref results, ui);

                break;
            }

            case ThreadType.SingleUI:
            {
                // runs task, and waits for results.

                // local function instead of action, very similar to
                // Action a = delegate () { RunTestsSingle(ref results); };
                void a()
                {
                    RunTestsSingleUI(ref results, ui);
                }

                Task task = new Task(a);

                task.Start();
                // the placement of this wait will have to be outside of here.
                // likely in MainWindow.

                break;
            }

            case ThreadType.Multithreaded:
            {
                break;
            }

            default:
            {
                throw new RipperThreadException("Unknown thread type to call. " +
                                                "public CPUResults RunCPUBenchmark(ThreadType threadType) " +
                                                "in function.CPUFunctions ");
            }
            }
        }
Exemplo n.º 31
0
        /// <summary>
        /// Returns a string representation of the <see cref="ThreadType"/> type.
        /// </summary>
        /// <param name="threadType">The <see cref="ThreadType"/> </param>
        /// <returns></returns>

        protected virtual string GetThreadAsString(ThreadType threadType)
        {
            switch (threadType)
            {
            case ThreadType.Single: { return("Single threaded"); }

            case ThreadType.SingleUI: { return("Dual threaded"); }

            case ThreadType.Multithreaded: { return("Multithreaded"); }

            default: {
                return("");
            }
            }
        }
Exemplo n.º 32
0
        public void Execute(EventOutput eventOutput, IEventCompleted completed)
        {
            mEventOutput    = eventOutput;
            mEventCompleted = completed;
            ThreadType threadType = Handler.ThreadType;

            if (threadType == ThreadType.ThreadPool)
            {
                System.Threading.ThreadPool.QueueUserWorkItem(async(d) => await Execute());
            }
            else
            {
                NextQueue.Enqueue(this);
            }
        }
        // If we ever want to make an implementation of IThread that we want in core,
        /// <summary>
        /// Creates an IThread instance of the specified thread type.
        /// </summary>
        /// <param name="threadType">Type of the file.</param>
        /// <returns></returns>
        public static IThread Create(ThreadType threadType)
        {
            IThread thread = new BasicThread();

            switch (threadType)
            {
                case ThreadType.MockThread:
                    thread = new MockThread();
                    break;
                default:
                    // returns the default - BasicFile implementation
                    break;
            }

            return thread;
        }
Exemplo n.º 34
0
 public bool ChangeFileInfo(ThreadType thread, string fileName)
 {
     bool ret = false;
     int count = 0;
     foreach (ThreadType threadType in ThreadArray)
     {
         if (threadType.FileName == fileName)
         {
             ThreadArray[count] = thread;
             ret = true;
             break;
         }
         count++;
     }
     return ret;
 }
        /// <summary>
        /// 向队列尾部增加一个阻塞状态的线程
        /// </summary>
        /// <param name="type">线程类型(READER/WRITER)</param>
        /// <returns>创建的读者线程</returns>
        private ThreadWorker EnqueueBlockingThread(ThreadType type)
        {
            ThreadWorker new_ThreadWorker = null; //新建线程

            if (type == ThreadType.WRITER)        //创建写者线程
            {
                new_ThreadWorker = new ThreadWorker(ThreadType.WRITER, Thread.CurrentThread);
            }
            else //创建读者线程
            {
                new_ThreadWorker = new ThreadWorker(ThreadType.READER, Thread.CurrentThread);
            }
            new_ThreadWorker.Status = ThreadStatus.BLOCKING; //状态置为阻塞
            queue.Enqueue(new_ThreadWorker);                 //将线程放入队尾
            return(new_ThreadWorker);                        //将新建的线程返回以便后续状态判断
        }
Exemplo n.º 36
0
 public ThreadEntry( string subject, PostEntry post, Mobile pm, DateTime creationTime, int id, ThreadType type )
 {
     m_Subject = subject;
     m_ThreadCreator = pm;
     m_CreationTime = creationTime;
     m_ThreadType = type;
     m_ThreadID = id;
     m_Locked = false;
     m_Viewers = new ArrayList();
     m_Posters = new ArrayList();
     m_ViewersSinceUpdate = new ArrayList();
     m_PostersSinceUpdate = new ArrayList();
     m_Posts = new ArrayList();
     m_Viewers.Add( pm );
     m_Posters.Add( pm );
     m_ViewersSinceUpdate.Add( pm );
     m_PostersSinceUpdate.Add( pm );
     m_Posts.Add( post );
     m_LastPostTime = DateTime.Now;
 }
Exemplo n.º 37
0
 public ThreadTypeAttribute(ThreadType threadType) {
     ThreadType = threadType;
 }
Exemplo n.º 38
0
 public ThreadTypes(string name, ThreadType type)
 {
     Name = name;
     Value = (int)type;
     Type = type;
 }
Exemplo n.º 39
0
 public void AddFileInfo(ThreadType threadType)
 {
     ThreadArray.Add(threadType);
 }
Exemplo n.º 40
0
 public OperationEventArgs(ThreadType type, ushort ir)
 {
     CurrentThreadType = type;
     CurrentIR = ir;
 }
Exemplo n.º 41
0
        private TimeSpan GetExpiresDate(ThreadType threadType)
        {
            int times = 0;
            string timeUnit = string.Empty;
            if (threadType == ThreadType.Question)
            {
                getTime(ForumSetting.QuestionValidDays[My], out times, out timeUnit);
            }
            else if (threadType == ThreadType.Polemize)
            {
                getTime(ForumSetting.PolemizeValidDays[My], out times, out timeUnit);
            }
            else if (threadType == ThreadType.Poll)
            {
                getTime(ForumSetting.PollValidDays[My], out times, out timeUnit);
            }
            if (times > 0)
            {
                int value = _Request.Get<int>("expiresDays", Method.Post, 0);
                //if (value > times)
                //    ShowError("有效天数不能超过" + Convert.ToInt32(times) + timeUnit);
                if (value <= 0)
                    value = Convert.ToInt32(Time);

                //DateTime expiresDate = DateTimeUtil.Now;
                TimeSpan expiresTime = new TimeSpan();
                switch (timeUnit)
                {
                    case "天":
                        expiresTime = new TimeSpan(value, 0, 0, 0);
                        break;
                    case "小时":
                        expiresTime = new TimeSpan(0, value, 0, 0);
                        break;
                    case "分钟":
                        expiresTime = new TimeSpan(0, 0, value, 0);
                        break;
                    case "秒":
                        expiresTime = new TimeSpan(0, 0, 0, value);
                        break;
                    default: break;
                }
                return expiresTime;
            }
            return TimeSpan.MaxValue;
        }
Exemplo n.º 42
0
 public TestAttribute(ThreadType threadType = ThreadType.Default)
 {
     ThreadType = threadType;
 }
Exemplo n.º 43
0
 public bool IsType(ThreadType threadType)
 {
     return this.Type == (int)threadType;
 }
Exemplo n.º 44
0
 public override void Deserialize(IXunitSerializationInfo data) {
     ThreadType = (ThreadType)Enum.Parse(typeof(ThreadType), data.GetValue<string>(nameof(ThreadType)));
     base.Deserialize(data);
 }
Exemplo n.º 45
0
 public static void AddType(FlatBufferBuilder builder, ThreadType type)
 {
     builder.AddSbyte(1, (sbyte)(type), 0);
 }
Exemplo n.º 46
0
        public override ThreadCollectionV5 GetThreads(int forumID, ThreadType threadType, int pageNumber, int pageSize, ThreadSortField? sortType, DateTime? beginDate, DateTime? endDate, bool isDesc, bool returnTotalThreads, int offset, out int totalThreads)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.Pager.IsDesc = isDesc;
                query.Pager.ResultFields = ThreadFields;
                ProcessSortField(query, sortType);

                query.Pager.PageNumber = pageNumber;
                query.Pager.PageSize = pageSize;
                //query.Pager.TotalRecords = totalThreads;
                query.Pager.SelectCount = returnTotalThreads;
                query.Pager.TableName = "[bx_Threads]";
                query.Pager.Offset = offset;

                StringBuilder condition = new StringBuilder();

                condition.Append(" [ThreadType]=@ThreadType ");
                query.CreateParameter<int>("@ThreadType", (int)threadType, SqlDbType.TinyInt);

                condition.Append(" AND [ForumID]=@ForumID ");
                query.CreateParameter<int>("@ForumID", forumID, SqlDbType.Int);

                //置顶在缓存中取
                //condition.Append(" AND [ThreadStatus] < 4 ");
                condition.Append(" AND [ThreadStatus] = 1 ");


                ProcessThreadDateScope(beginDate, endDate, query, condition);

                //if (beginDate != null)
                //{
                //    condition.Append(" AND [CreateDate] >= @BeginDate ");
                //    query.CreateParameter<DateTime>("@BeginDate", beginDate.Value, SqlDbType.DateTime);
                //}

                //if (endDate != null)
                //{
                //    condition.Append(" AND [CreateDate] <= @EndDate ");
                //    query.CreateParameter<DateTime>("@EndDate", endDate.Value, SqlDbType.DateTime);
                //}

                query.Pager.Condition = condition.ToString();

                totalThreads = 0;
                ThreadCollectionV5 threads = new ThreadCollectionV5();
                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        threads.Add(GetThread(reader, null));
                    }
                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            totalThreads = reader.Get<int>(0);
                        }
                    }
                }

                return threads;
            }
        }
Exemplo n.º 47
0
        public override void GetPolemizeWithReplies(int threadID, PostType? postType, int pageNumber, int pageSize, bool getExtendedInfo, bool getThread, bool getThreadContent, bool checkThreadType, ref BasicThread thread, out PostCollectionV5 posts, ref ThreadType threadType, out int totalCount)
        {
            totalCount = 0;
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_GetPolemizeWithReplies";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<int>("@ThreadID", threadID, SqlDbType.Int);
                query.CreateParameter<bool>("@GetExtendedInfo", getExtendedInfo, SqlDbType.Bit);
                query.CreateParameter<bool>("@GetThread", getThread, SqlDbType.Bit);
                query.CreateParameter<int>("@PageIndex", pageNumber - 1, SqlDbType.Int);
                query.CreateParameter<int>("@PageSize", pageSize, SqlDbType.Int);
                SetTopMarkCountParam(query);

                int? postTypeValue = null;
                if (postType != null)
                    postTypeValue = (int)postType.Value;

                query.CreateParameter<int?>("@PostType", postTypeValue, SqlDbType.TinyInt);

                if (thread != null && postType == null)
                    totalCount = thread.TotalReplies + 1;

                query.CreateParameter<int?>("@TotalCount", totalCount, SqlDbType.Int);
                query.CreateParameter<bool>("@CheckThreadType", checkThreadType, SqlDbType.Bit);

                if (thread != null && thread.ThreadContent != null)
                    getThreadContent = false;

                query.CreateParameter<bool>("@GetThreadContent", getThreadContent, SqlDbType.Bit);
                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    if (checkThreadType)
                    {
                        while (reader.Read())
                        {
                            threadType = (ThreadType)reader.Get<byte>(0);
                        }
                    }

                    bool hasReadThreadContent = false;

                    #region Read hasReadThreadContent value
                    if (checkThreadType == false)
                    {
                        while (reader.Read())
                        {
                            hasReadThreadContent = reader.Get<int>(0) == 1;
                        }
                    }
                    else
                    {
                        if (reader.NextResult())
                        {
                            while (reader.Read())
                            {
                                hasReadThreadContent = reader.Get<int>(0) == 1;
                            }
                        }
                    }
                    #endregion

                    PostCollectionV5 tempPosts = new PostCollectionV5();

                    #region 读取 主题内容 设置tempPosts
                    if (hasReadThreadContent)
                    {
                        if (getExtendedInfo)
                        {
                            tempPosts = GetPosts(reader, false);
                        }
                        else
                        {
                            if (reader.NextResult())
                            {
                                tempPosts = new PostCollectionV5(reader);
                            }
                        }
                    }
                    #endregion

                    if (getThread)
                    {
                        #region Read thread
                        if (reader.NextResult())
                        {
                            while (reader.Read())
                            {
                                thread = GetThread(reader, null);
                            }
                        }
                        #endregion
                    }

                    if (thread != null && tempPosts.Count > 0)
                    {
                        thread.ThreadContent = tempPosts[0];
                    }

                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            totalCount = reader.Get<int>(0);
                        }
                    }

                    if (getExtendedInfo)
                    {
                        posts = GetPosts(reader, false);
                    }
                    else
                    {
                        if (reader.NextResult())
                        {
                            posts = new PostCollectionV5(reader);
                        }
                        else
                            posts = new PostCollectionV5();
                    }

                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            bool resetOrder = reader.Get<bool>(0);
                            if (resetOrder)
                            {
                                PostCollectionV5 results = new PostCollectionV5();
                                for (int i = posts.Count; i > 0; i--)
                                {
                                    results.Add(posts[i - 1]);
                                }

                                posts = results;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 48
0
        public override void GetUserPosts(int threadID, int userID, int pageNumber, int pageSize, bool getExtendedInfo, bool getThread, bool checkThreadType, ref BasicThread thread, out PostCollectionV5 posts, ref ThreadType threadType, out int totalCount)
        {
            totalCount = 0;
            posts = new PostCollectionV5();
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_GetThreadUserPosts";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<int>("@ThreadID", threadID, SqlDbType.Int);
                query.CreateParameter<bool>("@GetExtendedInfo", getExtendedInfo, SqlDbType.Bit);
                query.CreateParameter<bool>("@GetThread", getThread, SqlDbType.Bit);
                query.CreateParameter<int>("@PageIndex", pageNumber - 1, SqlDbType.Int);
                query.CreateParameter<int>("@PageSize", pageSize, SqlDbType.Int);
                query.CreateParameter<int>("@UserID", userID, SqlDbType.Int);
                query.CreateParameter<int>("@ThreadType", (int)threadType, SqlDbType.TinyInt);
                query.CreateParameter<bool>("@CheckThreadType", checkThreadType, SqlDbType.Bit);

                SetTopMarkCountParam(query);

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    bool isFirstRead = true;
                    if (checkThreadType)
                    {
                        isFirstRead = false;
                        while (reader.Read())
                        {
                            threadType = (ThreadType)reader.Get<byte>(0);
                        }
                    }

                    if (getThread)
                    {
                        if (isFirstRead)
                        {
                            while (reader.Read())
                            {
                                thread = GetThread(reader,null);
                            }
                        }
                        else
                        {
                            if (reader.NextResult())
                            {
                                while (reader.Read())
                                {
                                    thread = GetThread(reader,null);
                                }
                            }
                        }

                        isFirstRead = false;
                    }

                    if (isFirstRead)
                    {
                        while (reader.Read())
                            totalCount = reader.Get<int>(0);
                    }
                    else
                    {
                        if (reader.NextResult())
                        {
                            while (reader.Read())
                                totalCount = reader.Get<int>(0);
                        }
                    }

                    if (getExtendedInfo)
                    {
                        posts = GetPosts(reader, false);
                    }
                    else
                    {
                        if (reader.NextResult())
                        {
                            posts = new PostCollectionV5(reader);
                        }
                        else
                            posts = new PostCollectionV5();
                    }

                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            bool resetOrder = reader.Get<bool>(0);
                            if (resetOrder)
                            {
                                PostCollectionV5 results = new PostCollectionV5();
                                for (int i = posts.Count; i > 0; i--)
                                {
                                    results.Add(posts[i - 1]);
                                }

                                posts = results;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 49
0
        private string GetExtendData(BasicThread thread, ThreadType threadType, XSqlDataReader reader, bool isFirstRead)
        {
            string extendData = null;
            switch (threadType)
            {
                case ThreadType.Poll:
                    PollThreadV5 poll = thread == null ? new PollThreadV5() : (PollThreadV5)thread;
                    if (isFirstRead || reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            poll.FillPoll(reader);
                        }
                    }

                    if (reader.NextResult())
                    {
                        poll.PollItems = new PollItemCollectionV5(reader);
                    }
                    if (thread == null || poll.VotedUserIDs == null)
                        poll.VotedUserIDs = new List<int>();
                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            poll.VotedUserIDs.Add(reader.Get<int>(0));
                        }
                    }
                    extendData = poll.GetExtendData();
                    break;
                case ThreadType.Question:
                    QuestionThread question = thread == null ? new QuestionThread() : (QuestionThread)thread;
                    if (isFirstRead || reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            question.FillQuestion(reader);
                        }
                    }

                    if (thread == null || question.Rewards == null)
                        question.Rewards = new Dictionary<int, int>();
                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            question.Rewards.Add(reader.Get<int>("PostID"), reader.Get<int>("Reward"));
                        }
                    }
                    extendData = question.GetExtendData();
                    break;
                case ThreadType.Polemize:
                    PolemizeThreadV5 polemize = thread == null ? new PolemizeThreadV5() : (PolemizeThreadV5)thread;
                    if (isFirstRead || reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            polemize.FillPolemize(reader);
                        }
                    }
                    if (reader.NextResult())
                    {
                        polemize.FillPolemizeUsers(reader);
                    }
                    extendData = polemize.GetExtendData();
                    break;
                default: break;
            }

            if (thread != null)
                thread.ExtendDataIsNull = false;

            return extendData;
        }
Exemplo n.º 50
0
        public Thread CreateThread(
            int forumID,
            int userID,
            string threadTitle,
            ThreadType threadType,
            string threadImage,
            string message,
            string pollText,
            string[] pollOptions,
            HttpPostedFileBase[] files)
        {
            Thread thread = new Thread
            {
                ForumID = forumID,
                Type = (int)threadType,
                Image = threadImage,
                Title = threadTitle,
                HasPoll = false
            };

            string parsedMessage = _parseServices.ParseBBCodeText(message);

            var firstPost = new Post()
            {
                UserID = userID,
                Date = DateTime.UtcNow,
                ThreadID = thread.ThreadID,
                TextOnly = _parseServices.GetTextOnly(message),
                Text = message,
                ParsedText = parsedMessage
            };

            thread.Posts.Add(firstPost);

            if (!string.IsNullOrWhiteSpace(pollText))
            {
                Poll poll = new Poll
                {
                    Question = pollText,
                    PollID = thread.ThreadID
                };

                thread.Poll = poll;

                var options = new System.Data.Objects.DataClasses.EntityCollection<PollOption>();
                foreach (string po in pollOptions)
                {
                    poll.PollOptions.Add(new PollOption
                    {
                        Text = po
                    });
                }
                thread.HasPoll = true;
            }

            if (files != null)
            {
                foreach (var file in files)
                {
                    string savedName = _fileServices.UploadFile(file);
                    firstPost.Attachments.Add(new Attachment()
                    {
                        Downloaded = 0,
                        SavedName = savedName,
                        DownloadName = file.FileName,
                        Size = file.ContentLength,
                        Type = file.ContentType
                    });
                }
            }
            _threadRepository.Add(thread);
            _unitOfWork.Commit();
            return thread;
        }
Exemplo n.º 51
0
        protected bool GetPosts(ThreadType threadType, out int? totalCount, out BasicThread thread, out PostCollectionV5 posts)
        {
            totalCount = null;
            thread = null;
            posts = null;
            ThreadType realThreadType = threadType;
            if (string.Compare(Type, SystemForum.RecycleBin.ToString(), true) == 0)
            {
                PostBOV5.Instance.GetPosts(ThreadID, false, PageNumber, PageSize, null, true, true, true, true, ref thread, out posts, ref realThreadType);
                if (realThreadType != threadType)
                {
                    BbsRouter.JumpToUrl(BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, PostBOV5.Instance.GetThreadTypeString(realThreadType)), "type=" + Type);
                }

                if (thread == null)
                {
                    ShowError("您要查看的主题不存在或者已被删除");
                }

                //totalCount = base.TotalPosts;
                return true;
            }
            else if (string.Compare(Type, SystemForum.UnapproveThreads.ToString(), true) == 0)
            {
                PostBOV5.Instance.GetPosts(ThreadID, false, PageNumber, PageSize, null, true, true, true, true, ref thread, out posts, ref realThreadType);
                //m_Thread.ThreadContent = m_PostList[0];
                totalCount = posts.TotalRecords;
                if (realThreadType != threadType)
                {
                    BbsRouter.JumpToUrl(BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, PostBOV5.Instance.GetThreadTypeString(realThreadType)), "type=" + Type);
                }

                if (thread == null)
                {
                    ShowError("您要查看的主题不存在或者已被删除");
                }

                return true;
            }
            else if (string.Compare(Type, MyThreadType.MyUnapprovedThread.ToString(), true) == 0)
            //|| string.Compare(Type, MyThreadType.MyUnapprovedPostThread.ToString(), true) == 0)
            {
                int count;
                PostBOV5.Instance.GetUnapprovedPostThread(ThreadID, MyUserID, PageNumber, PageSize, out thread, out posts, out count);


                if (thread == null)
                {
                    ShowError("您要查看的主题不存在或者已被删除");
                }
                if (posts.Count > 0)
                    thread.ThreadContent = posts[0];
                else
                    ShowError("您要查看的主题不存在或者已被删除");


                totalCount = count;
                return true;
            }
            else if (IsGetPost)
            {
                if (threadType != ThreadType.Normal)
                {
                    BbsRouter.JumpToUrl(BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, PostBOV5.Instance.GetThreadTypeString(ThreadType.Normal)), "type=getpost&postid=" + PostID);
                }

                thread = PostBOV5.Instance.GetThread(ThreadID);
                PostV5 post = PostBOV5.Instance.GetPost(PostID, true);
                if (post == null)
                {
                    ShowError("您要查看的帖子不存在或者已被删除");
                }

                posts = new PostCollectionV5();
                posts.Add(post);

                totalCount = 1;

                return true;
            }
            else
                return false;
        }
Exemplo n.º 52
0
 public OperationEventArgs(ThreadType type)
 {
     CurrentThreadType = type;
 }
Exemplo n.º 53
0
        public void AddButtonLabeled(int x, int y, int buttonID, int buttonValue, string text, string views, string replys, bool staff, ThreadType type)
        {
            AddImage(655, 368, 10411);
            AddButton(x, y, buttonValue, buttonValue, buttonID, GumpButtonType.Reply, 0);
            if (type == ThreadType.RegularThread)
                AddHtml(x + 40, y, 300, 20, Color(staff ? "Staff: " + text : text, staff ? LabelColor - 500 : LabelColor), false, false);
            if (type == ThreadType.Sticky)
                AddHtml(x + 40, y, 300, 20, Color("Fixed: " + text, LabelColor - 450), false, false);
            if (type == ThreadType.Announcement)
                AddHtml(x + 40, y, 300, 20, Color("Announcement: " + text, LabelColor - 350), false, false);

            AddLabel(x + 370, y, 38, views + "/" + replys);
        }
Exemplo n.º 54
0
 public CompositeTestAttribute(ThreadType threadType = ThreadType.Default, bool showWindow = false) {
     ThreadType = threadType;
     ShowWindow = showWindow;
 }
Exemplo n.º 55
0
        public void Deserialize( GenericReader reader )
        {
            int version = reader.ReadInt();

            switch( version )
            {
                case 0:
                    {
                        m_ThreadCreator = reader.ReadMobile();
                        m_LastPostTime = reader.ReadDateTime();
                        m_CreationTime = reader.ReadDateTime();
                        m_ThreadType = ( ThreadType )reader.ReadInt();
                        m_Posts = ReadPostList( reader );
                        m_Viewers = reader.ReadMobileList();
                        m_ViewersSinceUpdate = reader.ReadMobileList();
                        m_Posters = reader.ReadMobileList();
                        m_PostersSinceUpdate = reader.ReadMobileList();
                        m_FileInUse = reader.ReadBool();
                        m_StaffMessage = reader.ReadBool();
                        m_Deleted = reader.ReadBool();
                        m_Locked = reader.ReadBool();
                        m_Subject = reader.ReadString();
                        m_ThreadID = reader.ReadInt();
                        break;
                    }
            }
        }  
Exemplo n.º 56
0
        public override void GetPosts(int threadID, bool onlyNormal, int pageNumber, int pageSize, int? totalCount, bool getExtendedInfo, bool getThread, bool getThreadContent, bool checkThreadType, ref BasicThread thread, out PostCollectionV5 posts, ref ThreadType threadType)
        {
            using (SqlQuery query = new SqlQuery())
            {
                query.CommandText = "bx_GetPagePosts";
                query.CommandType = CommandType.StoredProcedure;

                query.CreateParameter<int>("@ThreadID", threadID, SqlDbType.Int);
                query.CreateParameter<bool>("@GetExtendedInfo", getExtendedInfo, SqlDbType.Bit);
                query.CreateParameter<bool>("@GetThread", getThread, SqlDbType.Bit);
                query.CreateParameter<int>("@PageIndex", pageNumber - 1, SqlDbType.Int);
                query.CreateParameter<int>("@PageSize", pageSize, SqlDbType.Int);
                query.CreateParameter<int?>("@TotalCount", totalCount, SqlDbType.Int);
                query.CreateParameter<int>("@ThreadType", (int)threadType, SqlDbType.TinyInt);
                query.CreateParameter<bool>("@CheckThreadType", checkThreadType, SqlDbType.Bit);
                query.CreateParameter<bool>("@OnlyNormal", onlyNormal, SqlDbType.Bit);

                SetTopMarkCountParam(query);


                if (getThreadContent)
                {
                    if (thread != null && thread.ThreadContent != null)// && thread is BasicThread)
                    {
                        getThreadContent = false;
                    }
                }

                bool getBestPost = false;

                QuestionThread question = null;
                if (getThreadContent)
                {
                    if (thread != null && thread is QuestionThread)
                    {
                        question = (QuestionThread)thread;
                        getBestPost = question.BestPost == null;
                    }
                    else if (thread == null && getThread)
                    {
                        getBestPost = true;
                    }
                }

                if (pageNumber == 1)
                    getThreadContent = false;

                query.CreateParameter<bool>("@GetBestPost", getBestPost, SqlDbType.Bit);
                query.CreateParameter<bool>("@GetThreadContent", getThreadContent, SqlDbType.Bit);


                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    if (checkThreadType)
                    {
                        while (reader.Read())
                        {
                            threadType = (ThreadType)reader.Get<byte>(0);
                        }
                    }

                    bool hasReadThreadContentOrBestPost = false;

                    #region Read hasReadThreadContentOrBestPost value
                    if (checkThreadType == false)
                    {
                        while (reader.Read())
                        {
                            hasReadThreadContentOrBestPost = reader.Get<int>(0) == 1;
                        }
                    }
                    else
                    {
                        if (reader.NextResult())
                        {
                            while (reader.Read())
                            {
                                hasReadThreadContentOrBestPost = reader.Get<int>(0) == 1;
                            }
                        }
                    }
                    #endregion

                    PostCollectionV5 tempPosts = new PostCollectionV5();

                    #region 读取 主题内容 最佳答案 设置tempPosts  仅当 getExtendedInfo = false 时有
                    if (hasReadThreadContentOrBestPost)
                    {
                        //if (getExtendedInfo)
                        //{
                        //    tempPosts = GetPosts(reader, false);
                        //}
                        //else
                        //{
                            if (reader.NextResult())
                            {
                                tempPosts = new PostCollectionV5(reader);
                            }

                            if (reader.NextResult())
                            {
                                if (reader.Read())
                                {
                                    int id = reader.Get<int>("PostID");
                                    if (id != 0)
                                    {
                                        PostV5 post = new PostV5(reader);
                                        tempPosts.Add(post);
                                    }
                                }
                            }
                        //}
                    }
                    #endregion

                    if (getThread)
                    {
                        #region Read thread
                        if (reader.NextResult())
                        {
                            while (reader.Read())
                            {
                                thread = GetThread(reader,null);
                            }
                        }
                        #endregion
                    }

                    int total = 0;
                    if (onlyNormal == false)
                    {
                        if (reader.NextResult() && reader.Read())
                        {
                            total = reader.Get<int>(0);
                        }
                    }

                    if (thread != null && tempPosts.Count > 0)
                    {
                        SetThreadContent(thread, question, tempPosts, getBestPost, pageNumber, false);
                    }

                    if (getExtendedInfo)
                    {
                        posts = GetPosts(reader, false);

                        if (thread != null && (getBestPost || getThreadContent))
                        {
                            SetThreadContent(thread, question, posts, getBestPost, pageNumber, true);
                        }
                    }
                    else
                    {
                        if (reader.NextResult())
                        {
                            posts = new PostCollectionV5(reader);
                        }
                        else
                            posts = new PostCollectionV5();
                    }

                    if (reader.NextResult())
                    {
                        while (reader.Read())
                        {
                            bool resetOrder = reader.Get<bool>(0);
                            if (resetOrder)
                            {
                                PostCollectionV5 results = new PostCollectionV5();
                                for (int i = posts.Count; i > 0; i--)
                                {
                                    results.Add(posts[i - 1]);
                                }

                                posts = results;
                            }
                        }
                    }

                    if (reader.NextResult())
                    {
                        string s = null;
                        while (reader.Read())
                        {
                            s = reader.Get<string>(0);
                        }

#if !Publish
                        if (reader.SqlQuery.TempInfo != null)
                            reader.SqlQuery.TempInfo += "-----" + s;
                        else
                            reader.SqlQuery.TempInfo = s;
#endif
                    }

                    if (pageNumber == 1 && thread != null && posts.Count > 0)
                        thread.ThreadContent = posts[0];
                        

                    posts.TotalRecords = total;
                }
            }
        }
Exemplo n.º 57
0
 public void UpdateThread(int threadID, string title, ThreadType threadType, string image)
 {
     var thread = _threadRepository.Get(threadID);
     thread.Title = title;
     thread.Type = (int)threadType;
     thread.Image = image;
     _threadRepository.Update(thread);
     _unitOfWork.Commit();
 }
Exemplo n.º 58
0
 public TestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, ITestMethod testMethod, TestParameters parameters, object[] testMethodArguments = null) 
     : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments) {
     ThreadType = parameters.ThreadType;
 }
Exemplo n.º 59
0
 internal ManagedThread(ThreadType type, ContextCallback callback, object state, ExecutionContext ctx)
 {
     m_type = type;
     m_status = (type == ThreadType.QueuedThread ? ThreadStatus.Queued : ThreadStatus.Unstarted);
     m_ctxCallback = callback;
     m_state = state;
     m_ctx = ctx;
 }
 public CompositeTestAttribute(ThreadType threadType = ThreadType.Default)
 {
     ThreadType = threadType;
 }