Пример #1
0
 /** Populate the Combo Box for user globe project selection */
 private void setupCombo() {
     var dataSource = new List<Obj_Project>();
     foreach (string s in brokerM.brokerRequest.listitem) {
         dataSource.Add(new Obj_Project() { Name = s, Value = s });    
     }
     this.cmboProjects.DataSource = dataSource;
     this.cmboProjects.DisplayMember = "Name";
     this.cmboProjects.ValueMember = "Value";
     this.cmboProjects.DropDownStyle = ComboBoxStyle.DropDownList;
 }
Пример #2
0
 private void setupGUIForSet() {
     var dataSource = new List<Obj_Project>();
     foreach(string s in brokerM.brokerRequest.listitem){
         dataSource.Add(new Obj_Project() {Name = s, Value = s});
     }
     
     this.BeginInvoke(new MethodInvoker(delegate {
         this.comboBox1.DataSource = dataSource;
         this.comboBox1.DisplayMember = "Name";
         this.comboBox1.ValueMember = "Value";
         this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
         this.Visible = true;
     }));
     MessageBox.Show("Generating Combo");
 }
Пример #3
0
 /** 
  * Process Buffer
  * Takes byte list as input and appends the byte stream to the response string
  * if the footer of the message is not read, continue to read
  */
 private void ProcessBuffer(List<byte> bBuffer) {
     lastSerialResponse += System.Text.Encoding.ASCII.GetString(bBuffer.ToArray());
     if (lastSerialResponse.Length > 10) {
         if (lastSerialResponse.Contains("Complete") || lastSerialResponse.Contains("COMPLETE")) {
             //Console.Beep();
             System.Diagnostics.Debug.WriteLine(String.Format("Received Complete: {0}", lastSerialResponse));
             STATUS = DEVICE_STATE_READ_COMPLETE;
             STATUSMESSAGE = lastSerialResponse;
             Console.Beep();
         } else {
             //Not yet complete, allow to buffer
             //Console.Beep();
             System.Diagnostics.Debug.WriteLine(String.Format("Received Not Complete: {0}", lastSerialResponse));
         }
     } else {
         //Not yet complete, allow to buffer
         //Console.Beep();
         System.Diagnostics.Debug.WriteLine(String.Format("Received Short: {0}", lastSerialResponse));
     }
 }
Пример #4
0
 //Received Tag Read event from device
 private void receivedTag(object sender, SerialDataReceivedEventArgs e) {
     STATUS = DEVICE_STATE_READING;
     bBuffer = new List<byte>();
     while (arduino.BytesToRead > 0) bBuffer.Add((byte)arduino.ReadByte());
     ProcessBuffer(bBuffer);
 }
Пример #5
0
 // Clear containers to prevent contamination
 private void clearcontainers() {
     lastSerialResponse = "";
     STATUS = 0;
     STATUSMESSAGE = "";
     bBuffer = new List<byte>();
 }
Пример #6
0
        private HttpWebResponse UploadFiles(Dictionary<string, string> files, Dictionary<string, string> otherValues) {
            var req = (HttpWebRequest)WebRequest.Create(this.Url);

            req.Timeout = 10000 * 1000;
            req.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
            req.AllowAutoRedirect = false;

            var mimeParts = new List<MimePart>();
            try {
                if (otherValues != null) {
                    foreach (var fieldName in otherValues.Keys) {
                        var part = new MimePart();

                        part.Headers["Content-Disposition"] = "form-data; name=\"" + fieldName + "\"";
                        part.Data = new MemoryStream(Encoding.UTF8.GetBytes(otherValues[fieldName]));

                        mimeParts.Add(part);
                    }
                }

                if (files != null) {
                    foreach (var fieldName in files.Keys) {
                        var part = new MimePart();

                        part.Headers["Content-Disposition"] = "form-data; name=\"" + fieldName + "\"; filename=\"" + files[fieldName] + "\"";
                        part.Headers["Content-Type"] = "application/octet-stream";
                        part.Data = File.OpenRead(files[fieldName]);

                        mimeParts.Add(part);
                    }
                }

                string boundary = "----------" + DateTime.Now.Ticks.ToString("x");

                req.ContentType = "multipart/form-data; boundary=" + boundary;
                req.Method = this.Method;

                long contentLength = 0;

                byte[] _footer = Encoding.UTF8.GetBytes("--" + boundary + "--\r\n");

                foreach (MimePart part in mimeParts) {
                    contentLength += part.GenerateHeaderFooterData(boundary);
                }

                req.ContentLength = contentLength + _footer.Length;

                byte[] buffer = new byte[8192];
                byte[] afterFile = Encoding.UTF8.GetBytes("\r\n");
                int read;

                using (Stream s = req.GetRequestStream()) {
                    foreach (MimePart part in mimeParts) {
                        s.Write(part.Header, 0, part.Header.Length);

                        while ((read = part.Data.Read(buffer, 0, buffer.Length)) > 0)
                            s.Write(buffer, 0, read);

                        part.Data.Dispose();

                        s.Write(afterFile, 0, afterFile.Length);
                    }

                    s.Write(_footer, 0, _footer.Length);
                }

                var res = (HttpWebResponse)req.GetResponse();

                return res;
            } catch (Exception ex) {
                Console.WriteLine(ex.Message);
                foreach (MimePart part in mimeParts)
                    if (part.Data != null)
                        part.Data.Dispose();

                return (HttpWebResponse)req.GetResponse();
            }
        }
Пример #7
0
 public string[] listAllUsers() {
     List<String> userList = new List<String>();
     DataTable temp = queryTable("UserTable", new string[]{"username"}, "1");
     foreach (DataRow row in temp.Rows) {
         userList.Add(row["username"].ToString());
     }
     return userList.ToArray();
 }