private void sendToAzure(string sended) { CallClass cc = new CallClass(); cc.value = sended; cc.guid = Guid.NewGuid().ToString(); ctdHelper = new ConnectTheDotsHelper(serviceBusNamespace: "elevatorIoT", eventHubName: "elevatorEH", keyName: "elevatorSEND", key: "POoyLPA/J8Qad82M2eaUL097T7FooJePJ4va1n4irAY=", call: sended); ctdHelper.SendData(cc); }
public ObservableCollection <ProductClass> GetProducts(int InvestigationID) { ObservableCollection <ProductClass> ReturnList = new ObservableCollection <ProductClass>(); string connectionString = ConfigurationManager.ConnectionStrings["LEABrowser.Properties.Settings.LEADBConnectionString"].ConnectionString; using (SqlConnection con = new SqlConnection((connectionString))) { con.Open(); SqlCommand cmd = new SqlCommand(); try { if (InvestigationID == 0) { cmd = new SqlCommand("SELECT ID, Type, CreationDate, Source, Destination, InvestigationID, Text, Path, CallLengthInMS FROM ProductTable tblProduct FULL JOIN SMSMessageTable tblSMS ON tblProduct.ID = tblSMS.ProductID FULL JOIN VoiceCallTable tblCall ON tblProduct.ID = tblCall.ProductID ORDER BY CreationDate", con); } else { cmd = new SqlCommand("SELECT ID, Type, CreationDate, Source, Destination, InvestigationID, Text, Path, CallLengthInMS FROM ProductTable tblProduct FULL JOIN SMSMessageTable tblSMS ON tblProduct.ID = tblSMS.ProductID FULL JOIN VoiceCallTable tblCall ON tblProduct.ID = tblCall.ProductID WHERE InvestigationID = @InvestigationIDVal ORDER BY CreationDate", con); cmd.Parameters.AddWithValue("@InvestigationIDVal", InvestigationID); } using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { var itemToAdd = new ProductClass(); switch (int.Parse(reader["Type"].ToString())) { case ((int)ProductType.Call): itemToAdd = new CallClass(); itemToAdd.TypeIcon = new Bitmap(Properties.Resources.Call, new Size(20, 20)); (itemToAdd as CallClass).Path = reader["Path"].ToString(); (itemToAdd as CallClass).CallLengthInMS = long.Parse(reader["CallLengthInMS"].ToString()); itemToAdd.Type = ProductType.Call; break; case ((int)ProductType.SMS): itemToAdd = new SMSClass(); itemToAdd.TypeIcon = new Bitmap(Properties.Resources.SMS, new Size(20, 20)); (itemToAdd as SMSClass).Text = reader["Text"].ToString(); itemToAdd.Type = ProductType.SMS; break; } itemToAdd.ID = int.Parse(reader["ID"].ToString()); itemToAdd.CreationDate = DateTime.Parse(reader["CreationDate"].ToString()); itemToAdd.Source = reader["Source"].ToString(); itemToAdd.Destination = reader["Destination"].ToString(); itemToAdd.InvestigationID = int.Parse(reader["InvestigationID"].ToString()); ReturnList.Add(itemToAdd); } reader.Close(); } } catch (Exception ex) { MessageBox.Show("ERROR: " + ex.Message); } finally { if ((con != null) && (con.State == ConnectionState.Open)) { con.Close(); } if (cmd != null) { cmd.Dispose(); } } } return(ReturnList); }