Ejemplo n.º 1
0
        public static void SaveJira(Jira jira)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(@"<?xml version='1.0' encoding='gb2312' ?>");
            sb.Append("\r\n");
            sb.Append(jira.GetXml());
            Binary bi = new Binary();

            bi.WriteBytes(System.Text.Encoding.Default.GetBytes(sb.ToString()));
            byte[] sendData = bi.GetBytes();
            HttpPostService.Post(DataCenter.ServerAddr + "giraservice?func=savegira&gid=" + jira.JiraID, sendData, true);
            m_dataDic[jira.JiraID] = sb.ToString();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Ajax处理类
 /// </summary>
 public static void AjaxHandle()
 {
     while (true)
     {
         AjaxRequest request = null;
         if (m_requests != null)
         {
             lock (m_requests)
             {
                 int requestsSize = m_requests.Count;
                 if (requestsSize > 0)
                 {
                     request = m_requests[requestsSize - 1];
                     m_requests.RemoveAt(requestsSize - 1);
                 }
             }
         }
         if (request != null)
         {
             String resStr    = "";
             String lowerType = request.m_type.ToLower();
             if (lowerType == "get")
             {
                 resStr = HttpGetService.Get(request.m_url);
             }
             else if (lowerType == "post")
             {
                 resStr = HttpPostService.Post(request.m_url);
             }
             if (m_listener != null)
             {
                 m_listener.Invoke(new AjaxResponse(request.m_indicator, request.m_type, request.m_url, request.m_dataType, request.m_callBack, resStr));
             }
             else
             {
                 request.m_indicator.CallFunction(request.m_callBack + "('" + resStr + "');");
             }
         }
         Thread.Sleep(1);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 触发秒表事件
        /// </summary>
        /// <param name="sender">调用者</param>
        /// <param name="timerID">秒表ID</param>
        private void CallTimerEvent(object sender, int timerID)
        {
            if (m_isOver)
            {
                return;
            }
            if (m_sky != null)
            {
                if (m_currentQuestion != null && m_mode >= 5 && m_currentQuestion.m_type != "极限")
                {
                    TimeSpan ts = DateTime.Now - m_bulletTime;
                    int      bollSeconds = 30, totalSeconds = (int)ts.TotalSeconds;
                    m_sky.Text = "";
                    if (totalSeconds >= bollSeconds)
                    {
                        Sound.Play("sound\\attbomb.wav");
                        m_sky.CreateBullets(6);
                        m_bulletTime = DateTime.Now;
                    }
                    else if (totalSeconds == bollSeconds - 1)
                    {
                        Sound.Play("sound\\1.wav");
                        m_sky.Text = "1";
                    }
                    else if (totalSeconds == bollSeconds - 2)
                    {
                        Sound.Play("sound\\2.wav");
                        m_sky.Text = "2";
                    }
                    else if (totalSeconds == bollSeconds - 3)
                    {
                        Sound.Play("sound\\3.wav");
                        m_sky.Text = "3";
                    }
                    else if (totalSeconds == bollSeconds - 4)
                    {
                        Sound.Play("sound\\bomb.wav");
                        m_sky.Text = "准备炸弹";
                    }
                    TimeSpan ts2 = DateTime.Now - m_shadowTime;
                    int      shadownTime = 1, totalSeconds2 = (int)ts2.TotalSeconds;
                    if (totalSeconds2 >= shadownTime)
                    {
                        m_shadowTime = DateTime.Now;
                    }
                    m_sky.OnTimer(timerID);
                }
                if (m_currentQuestion != null && (m_currentQuestion.m_type == "记忆" || m_currentQuestion.m_type == "算数"))
                {
                    if (m_currentQuestion.m_answer == m_txtAnswer.Text)
                    {
                        for (int i = 0; i < 5; i++)
                        {
                            AddBarrage("回答正确", 0, 4 + i);
                        }
                        ChangeQuestion();
                    }
                }
            }
            double m_oldCurrentTick = m_currentTick;

            if (m_currentTick > 0)
            {
                TimeSpan ts            = DateTime.Now - m_lastTime;
                bool     bulletIsClick = true;
                foreach (Bullet bullet in m_sky.m_bullets)
                {
                    if (!bullet.IsClick)
                    {
                        bulletIsClick = false;
                    }
                }
                if (bulletIsClick)
                {
                    m_currentTick -= (double)ts.Milliseconds / 1000;
                }
                if (m_currentTick <= 0)
                {
                    if (m_questions != null)
                    {
                        m_answers[m_currentQuestion.m_title] = m_txtAnswer.Text;
                    }
                    if (m_currentQuestion != null && m_currentQuestion.m_type == "极限")
                    {
                        Native.ExportToImage(DataCenter.GetAppPath() + "\\成绩截图.jpg");
                    }
                    m_lblTime.Text   = "时间到了";
                    m_txtAnswer.Text = m_currentQuestion.m_type;
                    m_currentTick    = 0;
                    ChangeQuestion();
                }
                else
                {
                    if (m_currentQuestion.m_type == "记忆")
                    {
                        if (m_totalTick - m_currentTick > m_totalTick / 2)
                        {
                            m_txtQuestion.Text   = "不可见";
                            m_txtAnswer.ReadOnly = false;
                            if (m_txtAnswer.Text == "请迅速记忆上面这串数字,在此文字消失时打出刚才那串数字")
                            {
                                m_txtAnswer.Text = "";
                            }
                        }
                        if (m_currentTick <= 2)
                        {
                            m_txtQuestion.Text = m_currentQuestion.m_answer;
                        }
                    }
                    double finishTime = (double)((TimeSpan)(DateTime.Now - m_firstTime)).TotalMilliseconds / 1000;
                    m_lblTime.Text = "还剩" + m_currentTick.ToString("0.00") + "秒 已用时" + finishTime.ToString("0.00") + "秒";
                    if (finishTime > 60 * m_examMinute)
                    {
                        m_answers[m_currentQuestion.m_title] = m_txtAnswer.Text;
                        String        file  = DataCenter.GetAppPath() + "\\Result.txt";
                        StringBuilder sb    = new StringBuilder();
                        int           index = 1;
                        foreach (String question in m_answers.Keys)
                        {
                            sb.AppendLine(index.ToString() + "." + question);
                            sb.AppendLine(m_answers[question]);
                            index++;
                        }
                        CFileA.Write(file, sb.ToString());
                        String examName = "";
                        CFileA.Read(DataCenter.GetAppPath() + "\\WriteYourName.txt", ref examName);
                        String          url         = "http://" + m_ip + ":10009/sendresult?name=" + examName;
                        HttpPostService postService = new HttpPostService();
                        postService.Post(url, sb.ToString());
                        m_txtAnswer.Text = "考试时间到,请等待考试结果!";
                        Native.Invalidate();
                        m_isOver = true;
                    }
                }
            }
            if (m_mode == 5)
            {
                if (m_currentQuestion.m_type == "打字" || m_currentQuestion.m_type == "极限")
                {
                    if (m_tick % 5 == 0)
                    {
                        AddBarrage(m_rd.Next(0, 2) == 0 ? "111" : "222", 2, m_rd.Next(3, 20));
                    }
                }
            }
            m_lastTime = DateTime.Now;
            m_tick++;
            if (m_tick > 10000)
            {
                m_tick = 0;
            }
            Native.Invalidate();
        }