/// <summary> /// Gets a list f pets by status /// </summary> /// <param name="status"></param> /// <returns></returns> public List <Pet> GetPetByStatus(statusEnum status) { List <Pet> pets = new List <Pet>(); string apiUriPath = $"{_apiUri}findByStatus?status={status}"; try { var request = (HttpWebRequest)WebRequest.Create(apiUriPath); request.Method = "GET"; var response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { string content = string.Empty; using (var stream = response.GetResponseStream()) { using (var sr = new StreamReader(stream)) { content = sr.ReadToEnd(); } } pets = JsonConvert.DeserializeObject <List <Pet> >(content); } } catch (Exception ex) { pets = null; } return(pets); }
private bool pulseWebcamGTK() { if (webcamStartThreadBeforeTestStatus == statusEnum.NOT_STARTED) { label_video_feedback_text(WebcamManage.GuiContactsEncoder.CONTACTS, "Initializing camera."); pulsebar_webcam.Visible = true; webcamStartThreadBeforeTestStatus = statusEnum.STARTING; } if (!webcamStartThread.IsAlive) { pulsebar_webcam.Visible = false; if (webcamStartThreadBeforeTestStatus == statusEnum.FAILURE) { label_video_feedback_text(WebcamManage.GuiContactsEncoder.CONTACTS, "Problems starting camera."); } else if (webcamStartThreadBeforeTestStatus == statusEnum.SUCCESS) { webcamManage.ReallyStarted = true; label_video_feedback_text(WebcamManage.GuiContactsEncoder.CONTACTS, "Recording ..."); } on_button_execute_test_accepted(); LogB.ThreadEnded(); return(false); } pulsebar_webcam.Fraction = Util.DivideSafeFraction(swWebcamStart.Elapsed.TotalSeconds, 10); Thread.Sleep(50); //LogB.Debug(webcamStartThread.ThreadState.ToString()); return(true); }
//Attention: no GTK here private void webcamStartThreadBeforeTest() { bool problems = false; swWebcamStart = new Stopwatch(); swWebcamStart.Start(); do { System.Threading.Thread.Sleep(100); if (swWebcamStart.Elapsed.TotalSeconds >= 10) { problems = true; } } while(!WebcamManage.RecordingFileStarted() && !problems); swWebcamStart.Stop(); if (problems) { LogB.Information("Problems starting camera."); webcamStartThreadBeforeTestStatus = statusEnum.FAILURE; } else { webcamStartThreadBeforeTestStatus = statusEnum.SUCCESS; } }
private JObject GetResponseStatus(statusEnum stat) { JObject response = new JObject(); status statusObj = GatewayContext.statuses.Find(s => s.status_id == (int)stat); response.Add("id", statusObj.status_id); response.Add("mesasage", statusObj.mesasage); return(response); }
public void connectatabase(int myselect) { statusEnum newstatus = new statusEnum(); newstatus = (statusEnum)myselect; string sqll = "Select * From ApplyData where Status = '" + newstatus + "'"; SqlDataAdapter sqldata = new SqlDataAdapter(sqll, TempConn.GetConn()); DataSet ds = new DataSet(); sqldata.Fill(ds); Application.ItemsSource = ds.Tables[0].DefaultView; }
public static int run(Main.RabbitmqMessageCallback doWork) { try { var factory = new ConnectionFactory() { HostName = ConfigurationManager.AppSettings["HostName"].Trim(), //"192.168.31.157", UserName = ConfigurationManager.AppSettings["UserName"].Trim(), //"admin",//用户名 Password = ConfigurationManager.AppSettings["Password"].Trim(), //"admin",//密码 VirtualHost = ConfigurationManager.AppSettings["VirtualHost"].Trim(), //"my_vhost" }; factory.AutomaticRecoveryEnabled = true; var connection = factory.CreateConnection(); var channel = connection.CreateModel(); channel.BasicQos(prefetchSize: 0, prefetchCount: 1, global: true); #region EventingBasicConsumer //定义消费者 var consumer = new EventingBasicConsumer(channel); //接收到消息时执行的任务 consumer.Received += (model, ea) => { string message = Encoding.UTF8.GetString(ea.Body); if (ea.DeliveryTag != deliveryTag) { deliveryTag = ea.DeliveryTag; doWork(message); } else { deliveryTag = ea.DeliveryTag; status = statusEnum.REPULSE; channel.BasicNack(ea.DeliveryTag, false, true); } }; //处理消息 channel.BasicConsume(queue: "work", false, consumer: consumer); return(1); #endregion } catch (Exception er) { return(0); } }
private void OpenFile(BinaryReader reader) { string startFileSig = ""; for (int i = 0; i < 8; i++)//8 bytes { startFileSig += reader.ReadChar(); } if (!startFileSig.StartsWith("#PES"))//this is not a file that we can read { _readyStatus = statusEnum.ParseError; lastError = "Missing #PES at beginning of file"; reader.Close(); return; } parser.LoadPec(reader, true, reader.ReadInt32()); }
private void OpenFile(string filename) { #if !DEBUG try { #endif _filename = filename; fileIn = new System.IO.BinaryReader(System.IO.File.Open(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read)); string startFileSig = ""; for (int i = 0; i < 4; i++) // 4 bytes { startFileSig += fileIn.ReadChar(); } if (startFileSig != "#PES") { // This is not a file that we can read readyStatus = statusEnum.ParseError; lastError = "Missing #PES at beginning of file"; fileIn.Close(); return; } // PES version string versionString = ""; for (int i = 0; i < 4; i++) // 4 bytes { versionString += fileIn.ReadChar(); } pesVersion = Convert.ToUInt16(versionString); int pecstart = fileIn.ReadInt32(); fileIn.BaseStream.Position = pecstart + 48; int numColors = fileIn.ReadByte() +1; List<byte> colorList = new List<byte>(); for (int x = 0; x < numColors; x++) { colorList.Add(fileIn.ReadByte()); } fileIn.BaseStream.Position = pecstart + 532; bool thisPartIsDone = false; stitchBlock curBlock; int prevX = 0; int prevY = 0; int maxX = 0; int minX = 0; int maxY = 0; int minY = 0; int colorNum = -1; int colorIndex = 0; List<Point> tempStitches = new List<Point>(); while (!thisPartIsDone) { byte val1; byte val2; val1 = fileIn.ReadByte(); val2 = fileIn.ReadByte(); if (val1 == 255 && val2 == 0) { //end of stitches thisPartIsDone = true; //add the last block curBlock = new stitchBlock(); curBlock.stitches = new Point[tempStitches.Count]; tempStitches.CopyTo(curBlock.stitches); curBlock.stitchesTotal = tempStitches.Count; colorNum++; colorIndex = colorList[colorNum]; curBlock.colorIndex = colorIndex; curBlock.color = getColorFromIndex(colorIndex); blocks.Add(curBlock); } else if (val1 == 254 && val2 == 176) { //color switch, start a new block curBlock = new stitchBlock(); curBlock.stitches = new Point[tempStitches.Count]; tempStitches.CopyTo(curBlock.stitches); curBlock.stitchesTotal = tempStitches.Count; colorNum++; colorIndex = colorList[colorNum]; curBlock.colorIndex = colorIndex; curBlock.color = getColorFromIndex(colorIndex); blocks.Add(curBlock); tempStitches = new List<Point>(); //read useless(?) byte fileIn.ReadByte(); } else { int deltaX = 0; int deltaY = 0; if ((val1 & 0x80) == 0x80) { //this is a jump stitch deltaX = ((val1 & 0x0f) << 8) + val2; /* dead code? bit we're checking is masked out in previous line if ((deltaX & 0x0800) == 0x0800) { deltaX = deltaX - 4096; } */ //read next byte for Y value val2 = fileIn.ReadByte(); } else { //normal stitch deltaX = val1; if (deltaX > 63) { deltaX = deltaX - 128; } } if ((val2 & 0x08) == 0x80) { //this is a jump stitch int val3 = fileIn.ReadByte(); deltaY = ((val2 & 0x0f) << 8) + val3; /* dead code? bit we're checking is masked out in previous line if ((deltaY & 0x0800) == 0x0800) { deltaY = deltaY - 4096; }*/ } else { //normal stitch deltaY = val2; if (deltaY > 63) { deltaY = deltaY - 128; } } tempStitches.Add(new Point(prevX + deltaX, prevY + deltaY)); prevX = prevX + deltaX; prevY = prevY + deltaY; if (prevX > maxX) { maxX = prevX; } else if (prevX < minX) { minX = prevX; } if (prevY > maxY) { maxY = prevY; } else if (prevY < minY) { minY = prevY; } } } imageWidth = maxX - minX; imageHeight = maxY - minY; translateStart.X = -minX; translateStart.Y = -minY; readyStatus = statusEnum.Ready; // Close the file fileIn.Close(); #if !DEBUG } catch (System.IO.IOException ioex) { readyStatus = statusEnum.IOError; lastError = ioex.Message; if (fileIn != null) { fileIn.Close(); } } catch (Exception ex) { readyStatus = statusEnum.ParseError; lastError = ex.Message; if (fileIn != null) { fileIn.Close(); } } #endif }
private void OpenFile(string filename) { #if !DEBUG try { #endif _filename = filename; fileIn = new System.IO.BinaryReader(System.IO.File.Open(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read)); string startFileSig = ""; for (int i = 0; i < 4; i++) // 4 bytes { startFileSig += fileIn.ReadChar(); } if (startFileSig != "#PES") { // This is not a file that we can read readyStatus = statusEnum.ParseError; lastError = "Missing #PES at beginning of file"; fileIn.Close(); return; } // PES version string versionString = ""; for (int i = 0; i < 4; i++) // 4 bytes { versionString += fileIn.ReadChar(); } pesVersion = Convert.ToUInt16(versionString); int pecstart = fileIn.ReadInt32(); // Read number of colors in this design fileIn.BaseStream.Position = pecstart + 48; int numColors = fileIn.ReadByte() + 1; List <byte> colorList = new List <byte>(); for (int x = 0; x < numColors; x++) { colorList.Add(fileIn.ReadByte()); } // Read stitch data fileIn.BaseStream.Position = pecstart + 532; bool thisPartIsDone = false; StitchBlock curBlock; int prevX = 0; int prevY = 0; int maxX = 0; int minX = 0; int maxY = 0; int minY = 0; int colorNum = -1; int colorIndex = 0; List <Stitch> tempStitches = new List <Stitch>(); while (!thisPartIsDone) { byte val1; byte val2; val1 = fileIn.ReadByte(); val2 = fileIn.ReadByte(); if (val1 == 0xff && val2 == 0x00) { //end of stitches thisPartIsDone = true; //add the last block curBlock = new StitchBlock(); curBlock.stitches = new Stitch[tempStitches.Count]; tempStitches.CopyTo(curBlock.stitches); curBlock.stitchesTotal = tempStitches.Count; colorNum++; colorIndex = colorList[colorNum]; curBlock.colorIndex = colorIndex; curBlock.color = getColorFromIndex(colorIndex); blocks.Add(curBlock); } else if (val1 == 0xfe && val2 == 0xb0) { //color switch, start a new block curBlock = new StitchBlock(); curBlock.stitches = new Stitch[tempStitches.Count]; tempStitches.CopyTo(curBlock.stitches); curBlock.stitchesTotal = tempStitches.Count; colorNum++; colorIndex = colorList[colorNum]; curBlock.colorIndex = colorIndex; curBlock.color = getColorFromIndex(colorIndex); //read useless(?) byte // The value of this 'useless' byte seems to alternate // between 2 and 1 for every other block. The only // exception I've noted is the last block which appears // to always be 0. curBlock.unknownStartByte = fileIn.ReadByte(); blocks.Add(curBlock); tempStitches = new List <Stitch>(); } else { int deltaX = 0; int deltaY = 0; if ((val1 & 0x80) == 0x80) { // This is a 12-bit int. Allows for needle movement // of up to +2047 or -2048. deltaX = get12Bit2sComplement(val1, val2); // The X value used both bytes, so read next byte // for Y value. val1 = fileIn.ReadByte(); } else { // This is a 7-bit int. Allows for needle movement // of up to +63 or -64. deltaX = get7Bit2sComplement(val1); // The X value only used 1 byte, so copy the second // to to the first for Y value. val1 = val2; } if ((val1 & 0x80) == 0x80) { // This is a 12-bit int. Allows for needle movement // of up to +2047 or -2048. // Read in the next byte to get the full value val2 = fileIn.ReadByte(); deltaY = get12Bit2sComplement(val1, val2); } else { // This is a 7-bit int. Allows for needle movement // of up to +63 or -64. deltaY = get7Bit2sComplement(val1); // Finished reading data for this stitch, no more // bytes needed. } tempStitches.Add( new Stitch( new Point(prevX, prevY), new Point(prevX + deltaX, prevY + deltaY) ) ); prevX = prevX + deltaX; prevY = prevY + deltaY; if (prevX > maxX) { maxX = prevX; } else if (prevX < minX) { minX = prevX; } if (prevY > maxY) { maxY = prevY; } else if (prevY < minY) { minY = prevY; } } } imageWidth = maxX - minX; imageHeight = maxY - minY; translateStart.X = -minX; translateStart.Y = -minY; readyStatus = statusEnum.Ready; // Close the file fileIn.Close(); #if !DEBUG } catch (System.IO.IOException ioex) { readyStatus = statusEnum.IOError; lastError = ioex.Message; if (fileIn != null) { fileIn.Close(); } } catch (Exception ex) { readyStatus = statusEnum.ParseError; lastError = ex.Message; if (fileIn != null) { fileIn.Close(); } } #endif }
private void OpenFile(string filename) { #if !DEBUG try { #endif _filename = filename; fileIn = new System.IO.BinaryReader(System.IO.File.Open(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read)); string startFileSig = ""; for (int i = 0; i < 4; i++) // 4 bytes { startFileSig += fileIn.ReadChar(); } if (startFileSig != "#PES") { // This is not a file that we can read readyStatus = statusEnum.ParseError; lastError = "Missing #PES at beginning of file"; fileIn.Close(); return; } // PES version string versionString = ""; for (int i = 0; i < 4; i++) // 4 bytes { versionString += fileIn.ReadChar(); } pesVersion = Convert.ToUInt16(versionString); int pecstart = fileIn.ReadInt32(); // Read number of colors in this design fileIn.BaseStream.Position = pecstart + 48; int numColors = fileIn.ReadByte() +1; List<byte> colorList = new List<byte>(); for (int x = 0; x < numColors; x++) { colorList.Add(fileIn.ReadByte()); } // Read stitch data fileIn.BaseStream.Position = pecstart + 532; bool thisPartIsDone = false; StitchBlock curBlock; int prevX = 0; int prevY = 0; int maxX = 0; int minX = 0; int maxY = 0; int minY = 0; int colorNum = -1; int colorIndex = 0; List<Stitch> tempStitches = new List<Stitch>(); while (!thisPartIsDone) { byte val1; byte val2; val1 = fileIn.ReadByte(); val2 = fileIn.ReadByte(); if (val1 == 0xff && val2 == 0x00) { //end of stitches thisPartIsDone = true; //add the last block curBlock = new StitchBlock(); curBlock.stitches = new Stitch[tempStitches.Count]; tempStitches.CopyTo(curBlock.stitches); curBlock.stitchesTotal = tempStitches.Count; colorNum++; colorIndex = colorList[colorNum]; curBlock.colorIndex = colorIndex; curBlock.color = getColorFromIndex(colorIndex); blocks.Add(curBlock); } else if (val1 == 0xfe && val2 == 0xb0) { //color switch, start a new block curBlock = new StitchBlock(); curBlock.stitches = new Stitch[tempStitches.Count]; tempStitches.CopyTo(curBlock.stitches); curBlock.stitchesTotal = tempStitches.Count; colorNum++; colorIndex = colorList[colorNum]; curBlock.colorIndex = colorIndex; curBlock.color = getColorFromIndex(colorIndex); //read useless(?) byte // The value of this 'useless' byte seems to alternate // between 2 and 1 for every other block. The only // exception I've noted is the last block which appears // to always be 0. curBlock.unknownStartByte = fileIn.ReadByte(); blocks.Add(curBlock); tempStitches = new List<Stitch>(); } else { int deltaX = 0; int deltaY = 0; if ((val1 & 0x80) == 0x80) { // This is a 12-bit int. Allows for needle movement // of up to +2047 or -2048. deltaX = get12Bit2sComplement(val1, val2); // The X value used both bytes, so read next byte // for Y value. val1 = fileIn.ReadByte(); } else { // This is a 7-bit int. Allows for needle movement // of up to +63 or -64. deltaX = get7Bit2sComplement(val1); // The X value only used 1 byte, so copy the second // to to the first for Y value. val1 = val2; } if ((val1 & 0x80) == 0x80) { // This is a 12-bit int. Allows for needle movement // of up to +2047 or -2048. // Read in the next byte to get the full value val2 = fileIn.ReadByte(); deltaY = get12Bit2sComplement(val1, val2); } else { // This is a 7-bit int. Allows for needle movement // of up to +63 or -64. deltaY = get7Bit2sComplement(val1); // Finished reading data for this stitch, no more // bytes needed. } tempStitches.Add( new Stitch( new Point(prevX, prevY), new Point(prevX + deltaX, prevY + deltaY) ) ); prevX = prevX + deltaX; prevY = prevY + deltaY; if (prevX > maxX) { maxX = prevX; } else if (prevX < minX) { minX = prevX; } if (prevY > maxY) { maxY = prevY; } else if (prevY < minY) { minY = prevY; } } } imageWidth = maxX - minX; imageHeight = maxY - minY; translateStart.X = -minX; translateStart.Y = -minY; readyStatus = statusEnum.Ready; // Close the file fileIn.Close(); #if !DEBUG } catch (System.IO.IOException ioex) { readyStatus = statusEnum.IOError; lastError = ioex.Message; if (fileIn != null) { fileIn.Close(); } } catch (Exception ex) { readyStatus = statusEnum.ParseError; lastError = ex.Message; if (fileIn != null) { fileIn.Close(); } } #endif }
public DeviceExecuteResponseCommand(statusEnum Status) { status = Status.ToString(); }