private void async_status(string b)
        {
            SetStatus s = new SetStatus(appendTextbox);

            //Thread.Sleep(1000);
            this.BeginInvoke(s, new Object[] { b });
        }
Beispiel #2
0
        public async Task SetStatus(SetStatus status)
        {
            await Client.SetStatusAsync((UserStatus)Enum.ToObject(
                                            typeof(UserStatus), (int)status));

            await ReplyAsync("Alright!");
        }
        public void CreatesCorrectPolicy(HttpStatusCode statusCode, string reason)
        {
            var code       = ((int)statusCode).ToString();
            var basePolicy = new SetStatus(code, reason);
            var xml        = basePolicy.GetXml().ToString();

            xml.Should().Be($"<set-status code=\"{code}\" reason=\"{reason}\" />");
        }
Beispiel #4
0
 /// <summary>
 /// Статус банківського термінала (Очікуєм карточки, Очікуєм підтвердження і ТД)
 /// </summary>
 /// <param name="ww"></param>
 void PosStatus(StatusEquipment ww)
 {
     if (ww is PosStatus status)
     {
         SetStatus?.Invoke(new StatusEquipment(Terminal.ModelEquipment, (int)status.Status, $"{status.TextState} {status.Status}"));
         Debug.WriteLine($"{DateTime.Now} {Terminal.ModelEquipment} {status.TextState} {status.Status}");
     }
 }
Beispiel #5
0
        private void btn_Status_Click(object sender, EventArgs e)
        {
            var statusSetter = new SetStatus {
                NewStatus = txb_StatusSetter.Text
            };

            client.Send(3, statusSetter);
        }
Beispiel #6
0
        private void SetStatusInfo()
        {
            int    columnNumber    = GetColumn(CurrentPosition);
            string nameTextBox     = AccessibleDescription;
            string rowNumberString = $"Row: {CurrentLine + 1} Column: {columnNumber + 1}";

            SetStatus?.Invoke(nameTextBox, rowNumberString);
            RefreshUndoRedoButton();
        }
Beispiel #7
0
        public void WriteFlash(Fel fel, byte[] fes, byte[] uboot, UInt32 address, byte[] data, bool verify = true, string what = "NAND")
        {
            var size = data.LongLength;

            size = (size + Fel.sector_size - 1) / Fel.sector_size;
            size = size * Fel.sector_size;
            if (data.LongLength != size)
            {
                var newData = new byte[size];
                Array.Copy(data, newData, data.Length);
                data = newData;
            }


            long maxProgress = (size / 65536) * (verify ? 2 : 1), progress = 0;

            // upload kernel through fel
            fel.WriteFlash(address, data,
                           delegate(Fel.CurrentAction action, string command)
            {
                switch (action)
                {
                case Fel.CurrentAction.WritingMemory:
                    SetStatus?.Invoke("Writing " + what);
                    break;
                }
                progress++;
                SetProgress?.Invoke(Math.Min(progress, maxProgress), maxProgress);
            }
                           );

            if (verify)
            {
                var r = fel.ReadFlash((UInt32)Fel.kernel_base_f, (UInt32)data.LongLength,
                                      delegate(Fel.CurrentAction action, string command)
                {
                    switch (action)
                    {
                    case Fel.CurrentAction.ReadingMemory:
                        SetStatus("Reading " + what);
                        break;
                    }
                    progress++;
                    SetProgress?.Invoke(Math.Min(progress, maxProgress), maxProgress);
                }
                                      );

                if (!data.SequenceEqual(r))
                {
                    throw new Exception("Verify failed for " + what);
                }
            }
        }
Beispiel #8
0
 public void setText(string t)
 {
     if (status.InvokeRequired)
     {
         SetStatus s = new SetStatus(setText);
         this.Invoke(s, new object[] { t });
     }
     else
     {
         status.Text = t;
     }
 }
Beispiel #9
0
    // Use this for initialization
    void Start()
    {
        SetStatus st = new SetStatus(); //啟用 設定狀態

        st.Set("1");                    //對第一項
        st.Set("2");
        st.Set("3");
        st.Set("4");
        st.Set("5");
        st.Set("6");
        st.Set("7");
        st.Set("8");
    }
Beispiel #10
0
        public void Memboot(byte[] fes, byte[] uboot, byte[] bootImage, Fel.WriteLineHandler writeLineHandler = null)
        {
            var fel = new Fel();

            fel.WriteLine += WriteLine;
            fel.Fes1Bin    = fes;
            fel.UBootBin   = uboot;
            if (!fel.Open())
            {
                throw new Exception("USB Device Not Found");
            }

            var size = CalcKernelSize(bootImage);

            if (size > bootImage.Length || size > Fel.transfer_max_size)
            {
                throw new Exception($"Invalid boot image size: {size}");
            }
            size = (size + Fel.sector_size - 1) / Fel.sector_size;
            size = size * Fel.sector_size;
            if (bootImage.Length != size)
            {
                var newK = new byte[size];
                Array.Copy(bootImage, newK, bootImage.Length);
                bootImage = newK;
            }

            long maxProgress = size / 65536, progress = 0;

            // upload kernel through fel
            fel.WriteMemory(Fel.transfer_base_m, bootImage,
                            delegate(Fel.CurrentAction action, string command)
            {
                switch (action)
                {
                case Fel.CurrentAction.WritingMemory:
                    SetStatus?.Invoke("Uploading boot image");
                    break;
                }
                progress++;
                SetProgress?.Invoke(Math.Min(progress, maxProgress), maxProgress);
            }
                            );

            var bootCommand = string.Format("boota {0:x}", Fel.transfer_base_m);

            RunCommand(fel, bootCommand, true);
        }
Beispiel #11
0
        public ResonseCategoryList Search()
        {
            ResonseCategoryList rs = new ResonseCategoryList();

            try
            {
                rs.Categories            = _context._Category.ToList();
                rs.requestStatus.success = true;
                return(rs);
            }
            catch (Exception ex)
            {
                var set = new SetStatus();
                set.Set(rs.requestStatus, ex);
                return(rs);
            }
        }
Beispiel #12
0
 private void SynchProgressBar()
 {
     if (progressBar1.InvokeRequired)
     {
         SetStatus s = SynchProgressBar;
         Invoke(s);
     }
     else
     {
         progressBar1.Maximum = totalSize;
         progressBar1.Value   = position;
         label2.Text          = "正在复制到" + topath;
     }
     if (topathnum >= topaths.Length)
     {
         label2.Text = "复制完成";
     }
 }
Beispiel #13
0
    public void upgrade()
    {
        myLevel ml = new myLevel(num); //搜尋目前等級

        ml.Load();
        myCashJS mc = new myCashJS();

        mc.Load();
        Assets.C_.Character.Convert con = new Assets.C_.Character.Convert();
        mc.load.cash -= con.cash(ml.load.Level);
        mc.Save(mc.load.cash);
        int level = ml.load.Level;

        level++;
        ml.Save(level);
        SetStatus s1 = new SetStatus();

        s1.Set(num);

        //  UpDecide up = new UpDecide();//調整點擊變數
        //  up.upgrade();
    }
Beispiel #14
0
        private void button1_Click(object sender, EventArgs e)
        {
            vk start = new vk();
            if (checkBox1.Checked) // если флажон для статуса
            {
                SetStatus setStatus = new SetStatus(start.setStatus);
                IAsyncResult res1 = setStatus.BeginInvoke(richTextBox1.Text, null, null);
                res1.AsyncWaitHandle.WaitOne(2000);
                if (setStatus.EndInvoke(res1).IndexOf("error") != -1)
                {
                    NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
                    this.Invoke(ShowNotify, "Ошибка!", "При публикации\nвозникли проблемы!", (uint)0);
                }
                //start.setStatus(richTextBox1.Text);
            }
            else // если для записи на стене
            {
                string name = "";

                if (checkBox2.Checked) // если нужно изображение, загружаем
                {
                    OpenFileDialog open = new OpenFileDialog();
                    open.FileName = "";
                    open.Filter = "Изображения|*.jpg;*.gif;*.png";

                    if (open.ShowDialog() == DialogResult.OK)
                    {
                        UploadFile upload = new UploadFile(start.UploadFile);
                        IAsyncResult res11 = upload.BeginInvoke(ID, open.FileName, null, null);

                        int iter = 0;

                        while (!res11.IsCompleted)
                        {
                            iter++;
                            if (iter == 500)
                            {
                                iter = 0;
                                Application.DoEvents();
                            }
                        }

                        res11.AsyncWaitHandle.WaitOne();

                        name = upload.EndInvoke(res11);
                    }

                    if (name == "")
                    {
                        NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
                        this.Invoke(ShowNotify, "Ошибка!", "При публикации\nвозникли проблемы!", (uint)0);
                    }
                }

                if (ID != 0) // не себе
                {
                    if (name != "")
                    {
                        SetWallStatus setWallStatus = new SetWallStatus(start.SetWallStatus);
                        IAsyncResult res1 = setWallStatus.BeginInvoke(richTextBox1.Text, name, ID, null, null);
                        res1.AsyncWaitHandle.WaitOne(2000);
                        if (setWallStatus.EndInvoke(res1).IndexOf("error") != -1)
                        {
                            NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
                            this.Invoke(ShowNotify, "Ошибка!", "При публикации\nвозникли проблемы!", (uint)0);
                        }
                        //start.SetWallStatus(richTextBox1.Text, name, ID);
                    }
                    else
                    {
                        SetWallStatus setWallStatus = new SetWallStatus(start.SetWallStatus);
                        IAsyncResult res1 = setWallStatus.BeginInvoke(richTextBox1.Text, "", ID, null, null);
                        res1.AsyncWaitHandle.WaitOne(2000);
                        if (setWallStatus.EndInvoke(res1).IndexOf("error") != -1)
                        {
                            NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
                            this.Invoke(ShowNotify, "Ошибка!", "При публикации\nвозникли проблемы!", (uint)0);
                        }
                        //start.SetWallStatus(richTextBox1.Text, "", ID);
                    }
                }
                else // себе
                {
                    if (name != "")
                    {
                        SetWallStatus setWallStatus = new SetWallStatus(start.SetWallStatus);
                        IAsyncResult res1 = setWallStatus.BeginInvoke(richTextBox1.Text, name, ID, null, null);
                        res1.AsyncWaitHandle.WaitOne(2000);
                        if (setWallStatus.EndInvoke(res1).IndexOf("error") != -1)
                        {
                            NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
                            this.Invoke(ShowNotify, "Ошибка!", "При публикации\nвозникли проблемы!", (uint)0);
                        }
                        //start.SetWallStatus(richTextBox1.Text, name, ID);
                    }
                    else
                    {
                        SetStatus setWallStatus = new SetStatus(start.SetWallStatus);
                        IAsyncResult res1 = setWallStatus.BeginInvoke(richTextBox1.Text, null, null);
                        res1.AsyncWaitHandle.WaitOne(2000);
                        if (setWallStatus.EndInvoke(res1).IndexOf("error") != -1)
                        {
                            NotifyEvent ShowNotify = new NotifyEvent(ShowNotifyWindow);
                            this.Invoke(ShowNotify, "Ошибка!", "При публикации\nвозникли проблемы!", (uint)0);
                        }
                        //start.SetWallStatus(richTextBox1.Text);
                    }
                }
            }
            this.Close();
        }
Beispiel #15
0
 public Game1(Form1 form, Control control)
     : base(control)
 {
     this.form      = form;
     this.setStatus = form.SetStatusText;
 }
Beispiel #16
0
 public static void HandleSetStatus(Client client, SetStatus packet)
 {
     AnaForm.Instance.KurbanDurumuAyarla(client, packet.Message);
 }
Beispiel #17
0
 public fmIFY()
 {
     InitializeComponent();
     updateStatus = new SetStatus(setStatusMethod);
 }
Beispiel #18
0
 public static void HandleSetStatus(Client client, SetStatus packet)
 {
     FrmMain.Instance.SetStatusByClient(client, packet.Message);
 }
Beispiel #19
0
        public void Init(Action <string, string> pSetBarCode, Action <double, bool> pSetWeight, Action <double, bool> pSetControlWeight, Action <StatusEquipment> pActionStatus = null)
        {
            var config = Config("appsettings.json");

            State = eStateEquipment.Init;
            try
            {
                //Scaner
                var ElEquipment = ListEquipment.Where(e => e.Type == eTypeEquipment.Scaner).First();
                switch (ElEquipment.Model)
                {
                case eModelEquipment.MagellanScaner:
                    ElEquipment.Equipment = new MagellanScaner(config, null, pSetBarCode);
                    break;

                case eModelEquipment.VirtualScaner:
                    ElEquipment.Equipment = new VirtualScaner(config, null, pSetBarCode);
                    break;

                default:
                    ElEquipment.Equipment = new Scaner(config);
                    break;
                }
                Scaner = (Scaner)ElEquipment.Equipment;

                //Scale
                ElEquipment = ListEquipment.Where(e => e.Type == eTypeEquipment.Scale).First();
                switch (ElEquipment.Model)
                {
                case eModelEquipment.MagellanScale:
                    ElEquipment.Equipment = new MagellanScale(((MagellanScaner)Scaner).Magellan9300, pSetWeight);
                    break;

                case eModelEquipment.VirtualScale:
                    ElEquipment.Equipment = new VirtualScale(config, null, pSetWeight);
                    break;

                default:
                    ElEquipment.Equipment = new Scale(config);
                    break;
                }
                Scale = (Scale)ElEquipment.Equipment;

                //ControlScale
                ElEquipment = ListEquipment.Where(e => e.Type == eTypeEquipment.ControlScale).First();
                if (ElEquipment.Model == eModelEquipment.ScaleModern)
                {
                    ElEquipment.Equipment = new ScaleModern(config, null, pSetControlWeight);
                }
                else
                {
                    ElEquipment.Equipment = new Scale(config);
                };
                ControlScale = (Scale)ElEquipment.Equipment;

                //Flag
                ElEquipment = ListEquipment.Where(e => e.Type == eTypeEquipment.Signal).First();
                if (ElEquipment.Model == eModelEquipment.SignalFlagModern)
                {
                    ElEquipment.Equipment = new SignalFlagModern(config);
                }
                else
                {
                    ElEquipment.Equipment = new SignalFlag(config);
                }
                Signal = (SignalFlag)ElEquipment.Equipment;

                //Bank Pos Terminal
                foreach (var el in GetBankTerminal)
                {
                    ElEquipment = el;

                    switch (ElEquipment.Model)
                    {
                    case eModelEquipment.Ingenico:
                        ElEquipment.Equipment = new IngenicoH(config, null, PosStatus);
                        break;

                    case eModelEquipment.VirtualBankPOS:
                        ElEquipment.Equipment = new VirtualBankPOS(config, null, PosStatus);
                        break;

                    default:
                        ElEquipment.Equipment = new BankTerminal(config);
                        break;
                    }
                    Terminal = (BankTerminal)ElEquipment.Equipment;
                }

                //RRO
                ElEquipment = ListEquipment.Where(e => e.Type == eTypeEquipment.RRO).First();
                switch (ElEquipment.Model)
                {
                case eModelEquipment.ExellioFP:
                    ElEquipment.Equipment = new Equipments.ExellioFP(config, null);
                    break;

                case eModelEquipment.pRRO_SG:
                    ElEquipment.Equipment = new pRRO_SG(config, null, pActionStatus);
                    break;

                case eModelEquipment.pRRo_WebCheck:
                    ElEquipment.Equipment = new pRRO_WebCheck(config, null, pActionStatus);
                    break;

                case eModelEquipment.Maria:
                    ElEquipment.Equipment = new RRO_Maria(config, null, pActionStatus);
                    break;

                case eModelEquipment.VirtualRRO:
                    ElEquipment.Equipment = new VirtualRRO(config, null, pActionStatus);
                    break;

                default:
                    ElEquipment.Equipment = new Rro(config);
                    break;
                }
                RRO = (Rro)ElEquipment.Equipment;

                State = eStateEquipment.Ok;

                foreach (var el in  ListEquipment)
                {
                    el.Equipment.SetState += (pStateEquipment, pModelEquipment) => { SetStatus?.Invoke(new StatusEquipment()
                        {
                            ModelEquipment = pModelEquipment, State = (int)pStateEquipment, TextState = $""
                        }); };
                }
            }
            catch (Exception e)
            {
                FileLogger.WriteLogMessage($"EquipmentFront Exception => Message=>{e.Message}{Environment.NewLine}StackTrace=>{e.StackTrace}", eTypeLog.Error);
                State = eStateEquipment.Error;
            }
        }
Beispiel #20
0
        public void WriteAudioFiles(string dir, CUEStyle style, SetStatus statusDel)
        {
            const int buffLen = 16384;
            int       iTrack, iIndex, iSource, iDest, i, j, samplesRemIndex, samplesRemSource, copyCount;

            string[]     destPaths;
            int[]        destLengths;
            byte[]       buff = new byte[buffLen * 2 * 2];
            TrackInfo    track;
            IAudioSource audioSource = null;
            IAudioDest   audioDest   = null;
            bool         htoaToFile  = ((style == CUEStyle.GapsAppended) && _preserveHTOA &&
                                        (_tracks[0].IndexLengths[0] != 0));
            bool discardOutput;

            if (_usePregapForFirstTrackInSingleFile)
            {
                throw new Exception("UsePregapForFirstTrackInSingleFile is not supported for writing audio files.");
            }

            if (style == CUEStyle.SingleFile)
            {
                destPaths    = new string[1];
                destPaths[0] = Path.Combine(dir, _singleFilename);
            }
            else
            {
                destPaths = new string[TrackCount + (htoaToFile ? 1 : 0)];
                if (htoaToFile)
                {
                    destPaths[0] = Path.Combine(dir, _htoaFilename);
                }
                for (i = 0; i < TrackCount; i++)
                {
                    destPaths[i + (htoaToFile ? 1 : 0)] = Path.Combine(dir, _trackFilenames[i]);
                }
            }
            for (i = 0; i < destPaths.Length; i++)
            {
                for (j = 0; j < _sourcePaths.Count; j++)
                {
                    if (destPaths[i].ToLower() == _sourcePaths[j].ToLower())
                    {
                        throw new Exception("Source and destination audio file paths cannot be the same.");
                    }
                }
            }

            if (_writeOffset != 0)
            {
                int        absOffset = Math.Abs(_writeOffset);
                SourceInfo sourceInfo;

                sourceInfo.Path   = null;
                sourceInfo.Offset = 0;
                sourceInfo.Length = absOffset;

                if (_writeOffset < 0)
                {
                    _sources.Insert(0, sourceInfo);

                    int last = _sources.Count - 1;
                    while (absOffset >= _sources[last].Length)
                    {
                        absOffset -= _sources[last].Length;
                        _sources.RemoveAt(last--);
                    }
                    sourceInfo         = _sources[last];
                    sourceInfo.Length -= absOffset;
                    _sources[last]     = sourceInfo;
                }
                else
                {
                    _sources.Add(sourceInfo);

                    while (absOffset >= _sources[0].Length)
                    {
                        absOffset -= _sources[0].Length;
                        _sources.RemoveAt(0);
                    }
                    sourceInfo         = _sources[0];
                    sourceInfo.Offset += absOffset;
                    sourceInfo.Length -= absOffset;
                    _sources[0]        = sourceInfo;
                }

                _appliedWriteOffset = true;
            }

            destLengths = CalculateAudioFileLengths(style);

            iSource          = -1;
            iDest            = -1;
            samplesRemSource = 0;

            if (style == CUEStyle.SingleFile)
            {
                iDest++;
                audioDest = GetAudioDest(destPaths[iDest], destLengths[iDest]);
            }

            for (iTrack = 0; iTrack < TrackCount; iTrack++)
            {
                statusDel(String.Format("Writing track {0:00}...", iTrack + 1));

                track = _tracks[iTrack];

                if ((style == CUEStyle.GapsPrepended) || (style == CUEStyle.GapsLeftOut))
                {
                    if (audioDest != null)
                    {
                        audioDest.Close();
                    }
                    iDest++;
                    audioDest = GetAudioDest(destPaths[iDest], destLengths[iDest]);
                }

                for (iIndex = 0; iIndex <= track.LastIndex; iIndex++)
                {
                    if ((style == CUEStyle.GapsAppended) && (iIndex == 1))
                    {
                        if (audioDest != null)
                        {
                            audioDest.Close();
                        }
                        iDest++;
                        audioDest = GetAudioDest(destPaths[iDest], destLengths[iDest]);
                    }

                    samplesRemIndex = track.IndexLengths[iIndex] * 588;

                    if ((style == CUEStyle.GapsAppended) && (iIndex == 0) && (iTrack == 0))
                    {
                        discardOutput = !htoaToFile;
                        if (htoaToFile)
                        {
                            iDest++;
                            audioDest = GetAudioDest(destPaths[iDest], destLengths[iDest]);
                        }
                    }
                    else if ((style == CUEStyle.GapsLeftOut) && (iIndex == 0))
                    {
                        discardOutput = true;
                    }
                    else
                    {
                        discardOutput = false;
                    }

                    while (samplesRemIndex != 0)
                    {
                        if (samplesRemSource == 0)
                        {
                            if (audioSource != null)
                            {
                                audioSource.Close();
                            }
                            audioSource      = GetAudioSource(++iSource);
                            samplesRemSource = _sources[iSource].Length;
                        }

                        copyCount = Math.Min(Math.Min(samplesRemIndex, samplesRemSource), buffLen);

                        audioSource.Read(buff, copyCount);
                        if (!discardOutput)
                        {
                            audioDest.Write(buff, copyCount);
                        }

                        samplesRemIndex  -= copyCount;
                        samplesRemSource -= copyCount;

                        lock (this) {
                            if (_stop)
                            {
                                audioSource.Close();
                                try { audioDest.Close(); } catch {}
                                throw new StopException();
                            }
                        }
                    }
                }
            }

            if (audioSource != null)
            {
                audioSource.Close();
            }
            audioDest.Close();
        }
 private void Execute(Client client, SetStatus message)
 {
     OnStatusUpdated(client, message.Message);
 }
Beispiel #22
0
        // 数据读取及合并
        private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (dataDir.Equals(""))
            {
                return;
            }
            if (!PubTools.GlobalVar.mysqltool.Connect())
            {
                MessageBox.Show("无法连接数据库,请检查");
                return;
            }

            SetList     setlist     = new SetList(SetListImpl);
            SetProgress setprogress = new SetProgress(SetProgressImpl);
            SetStatus   setstatus   = new SetStatus(SetStatusImpl);
            int         newDataNum  = 0;

            // 列出子目录
            DirectoryInfo info = new DirectoryInfo(dataDir);

            DirectoryInfo[] subDirList = info.GetDirectories();
            for (int i = 0; i < subDirList.Length; i++)
            {
                newDataNum = 0;
                String path      = dataDir + "\\" + subDirList[i].Name;
                int    pathLen   = path.Length + 1;
                String tableName = subDirList[i].Name;

                this.Invoke(setprogress, 0);
                // 新建TABLE
                this.Invoke(setlist, tableName + ": Read XML File Begin.");
                DataTable dt = PubTools.GlobalVar.ds.Tables.Add(tableName);
                DataTool.InitMDTable(dt);

                // 逐个文件读入本地datatable,并合并到数据库
                String[] filenames = System.IO.Directory.GetFiles(path);
                for (int j = 0; j < filenames.Length; j++)
                {
                    String filename = filenames[j].Substring(pathLen);
                    try
                    {
                        dt.ReadXml(filenames[j]);
                    }
                    catch (Exception ex)
                    {
                        this.Invoke(setlist, tableName + ": Err " + filenames[j].Substring(pathLen) + " " + ex.Message);
                        continue;
                    }

                    // 根据本地数据获取:时间段
                    String maxDay = (String)dt.Compute("max(TradingDay)", "");
                    String minDay = (String)dt.Compute("min(TradingDay)", "");

                    // 读取数据库中数据
                    DataTable dtDB = GlobalVar.ds.Tables["md_import"];
                    dtDB.Rows.Clear();
                    String cmd = "select * from md_import where InstrumentID='" + tableName + "' and TradingDay between '" + minDay + "' and '" + maxDay + "'";
                    GlobalVar.mysqltool.ReadData(cmd, "md_import");
                    this.Invoke(setstatus, tableName + ": " + filename + " mem/DB: " + dt.Rows.Count.ToString() + "/" + dtDB.Rows.Count.ToString());

                    // 合并到数据库
                    PubTools.MDDataMerge merge = new PubTools.MDDataMerge(dt, dtDB);
                    while (merge.progress >= 0)
                    {
                        Thread.Sleep(PubTools.Const.SleepTime);
                    }
                    this.Invoke(setprogress, 100 * j / filenames.Length);
                    newDataNum += merge.newDataNum;
                    dt.Rows.Clear();
                }
                this.Invoke(setlist, tableName + ": New Data rows number: " + newDataNum.ToString());

                // 清除数据
                GlobalVar.ds.Tables.Remove(dt);
                dt.Dispose();
            }
            GlobalVar.mysqltool.DisConnect();
        }
Beispiel #23
0
 void PrintClass_OnSetStatus(string text)
 {
     try
     {
         if (this.InvokeRequired)
         {
             SetStatus del = new SetStatus(PrintClass_OnSetStatus);
             this.Invoke(del, text);
         }
         else
         {
             label18.ForeColor = Color.Black;
             label18.Text = text;
             this.Refresh();
             System.Threading.Thread.Sleep(500);
         }
     }
     catch (ObjectDisposedException)
     { }
 }
        /// <summary>
        ///异步复制文件
        /// </summary>
        /// <param name="ar"></param>
        private void AsyncCopyFile(IAsyncResult ar)
        {
            int       readedLength;
            SetStatus s = new SetStatus(appendTextbox);

            try {
                //判断stream是否可读(是否已被关掉)
                if (stream.CanRead)
                {
                    // 锁定 FileStream
                    lock (stream)
                    {
                        readedLength = stream.EndRead(ar);     // 等到挂起的异步读取完成
                    }
                }
                else
                {
                    //this.BeginInvoke(s,new Object[]{""});
                    return;
                }
                string url = ar.AsyncState as string;
                // 写入磁盘
                var fsWriter = new FileStream(url, FileMode.Append, FileAccess.Write);
                fsWriter.Write(buffer, 0, buffer.Length);
                fsWriter.Close();

                // 当前位置
                position += readedLength;

                this.BeginInvoke(s, new Object[] { "" });
                if (position >= Size)   // 读取完毕
                {
                    stream.Close();     //关闭
                    curCopyNo++;
                    TotalPostion += Size;
                    Size          = 0;
                    position      = 0;
                    copyCircle();
                    return;
                }
                if (stream.CanRead)
                {
                    lock (stream)
                    {
                        int leftSize = Size - position;
                        if (leftSize < BUFFER_SIZE)
                        {
                            buffer = new byte[leftSize];
                        }
                        stream.BeginRead(buffer, 0, buffer.Length, new AsyncCallback(AsyncCopyFile), url);
                    }
                }
                else
                {
                    return;
                }
            } catch (Exception e) {
                TotalPostion += Size;
                MessageBox.Show(infostr + "文件出错!" + e.ToString());
                this.BeginInvoke(s, new Object[] { "ERROR:" + infostr + "文件出错" + e.ToString() });
                curCopyNo++;
                copyCircle();
            }
        }
Beispiel #25
0
        private static void HandlePacket(Packet packet)
        {
            Console.WriteLine(packet.Type);

            switch (packet.Type)
            {
            case PacketType.ServerTime:
                SecondsLeft = ((ServerTime)packet).Seconds;
                break;

            case PacketType.SetStatus:
            {
                SetStatus setStatus = (SetStatus)packet;
                Players[setStatus.Id].Thinking = setStatus.TurnOver;
                break;
            }

            case PacketType.GameOver:
                Game.PushState(new GameOverScreen());
                break;

            case PacketType.InitSelectionScreen:
            {
                InitSelectionScreen initSelectionScreen = (InitSelectionScreen)packet;
                Game.PushState(new SelectionScreen(initSelectionScreen.Options));
                InMatch = false;
                break;
            }

            case PacketType.SelectCardCzar:
            {
                SelectCardCzar selectCardCzar = (SelectCardCzar)packet;
                InGame         game           = (InGame)Game.PeekFirstState();

                foreach (Player p in game.Players)
                {
                    p.Czar = false;
                }

                if (Players.ContainsKey(selectCardCzar.Id))
                {
                    Players[selectCardCzar.Id].Czar = true;
                }
                else
                {
                    game.LocalPlayer.Czar = true;
                }

                foreach (Player p in game.Entities.OfType <Player>())
                {
                    p.Thinking = !p.Czar;
                }

                break;
            }

            case PacketType.WinnerPicked:
            {
                if (Game.PeekState().GetType() != typeof(GameOverScreen))
                {
                    InMatch = true;
                    Game.PopState();

                    WinnerPicked winnerPicked = (WinnerPicked)packet;
                    InGame       game         = (InGame)Game.PeekState();

                    if (winnerPicked.Id != 0)
                    {
                        Player player = Players.ContainsKey(winnerPicked.Id) ? Players[winnerPicked.Id] : game.LocalPlayer;
                        ++player.Score;

                        Game.PushState(new WinnerScreen(player.Name, CurrentBlackCard.Info.Value, winnerPicked.Cards));
                    }
                    else
                    {
                        Game.PushState(new WinnerScreen("No one", CurrentBlackCard.Info.Value, new List <string>()));
                    }
                }
                break;
            }

            case PacketType.WhiteCard:
            {
                WhiteCard whiteCards = (WhiteCard)packet;

                foreach (CardInfo c in whiteCards.Cards)
                {
                    Card card = new Card(c)
                    {
                        Position = new Vector2f(-1024.0f, -1024.0f),
                        Scale    = new Vector2f(0.643f * 0.8f, 0.643f * 0.8f)
                    };

                    Hand.Add(card);
                    Game.PeekFirstState().Entities.Add(card);
                }

                if (Hand.Any(c => c.Info.Value.Contains("brain")) && !gotBrainTumorOnce)
                {
                    Assets.PlaySound("BrainTumorCardStart.wav");
                    gotBrainTumorOnce = true;
                }
                else if (Random.Next(100) < 5)
                {
                    Assets.PlaySound("NoBrainTumorCardStart5.wav");
                }

                break;
            }

            case PacketType.BlackCard:
            {
                BlackCard blackCard = (BlackCard)packet;

                if (CurrentBlackCard != null)
                {
                    Game.PeekFirstState().Entities.Remove(CurrentBlackCard);
                }

                CurrentBlackCard = new Card(blackCard.Card)
                {
                    Position = new Vector2f(GameOptions.Width - 256.0f + 4.0f, 48.0f + 32.0f)
                };
                Game.PeekFirstState().Entities.Add(CurrentBlackCard);
                break;
            }

            case PacketType.LobbyBeginGame:
                Game.SetState(new InGame(((Lobby)Game.PeekFirstState()).Players));
                InMatch = true;
                break;

            case PacketType.PlayerDelete:
            {
                PlayerDelete playerDelete = (PlayerDelete)packet;
                Game.PeekFirstState().Entities.Remove(Players[playerDelete.Id]);
                Players.Remove(playerDelete.Id);

                break;
            }

            case PacketType.PlayerNew:
            {
                PlayerNew playerNew = (PlayerNew)packet;
                Player    player    = new Player(playerNew.Name);
                Players.Add(playerNew.Id, player);

                Game.PeekState().Entities.Add(player);
                break;
            }

            case PacketType.ChatMessage:
            {
                ChatMessage chatMessage = (ChatMessage)packet;

                // TODO Unify chatlogs...
                if (Game.PeekFirstState().GetType() == typeof(Lobby))
                {
                    ((Lobby)Game.PeekFirstState()).ChatBacklog.Add(chatMessage.Value);
                }
                else
                {
                    ((InGame)Game.PeekFirstState()).ChatBacklog.Add(chatMessage.Value);
                }

                GameUtility.PlayTaunt(chatMessage.Value);

                Assets.PlaySound("Bubble.wav");
                break;
            }

            default:
                Console.WriteLine("Unhandled packet!");
                break;
            }
        }