public int Host_Save(Model.Host host) { int hostId = 0; using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString())) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = con; cmd.CommandText = "usp_Host_Save"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@HostId", host.HostId).Direction = ParameterDirection.InputOutput;; cmd.Parameters.AddWithValue("@HostName", host.HostName); cmd.Parameters.AddWithValue("@Description", host.Description); cmd.Parameters.AddWithValue("@Location", host.Location); cmd.Parameters.AddWithValue("@ContactNos", host.ContactNos); cmd.Parameters.AddWithValue("@MapLocation", host.Maplocation); if (con.State == ConnectionState.Closed) { con.Open(); } cmd.ExecuteNonQuery(); hostId = Convert.ToInt32(cmd.Parameters["@HostId"].Value); con.Close(); } } return(hostId); }
private void MarkFeedRead(RoutedEventArgs e) { if (_selectedNode == null) { return; } SimpleTreeNodeViewModel tvm = (SimpleTreeNodeViewModel)_selectedNode; if (tvm.Node is Model.Feed) { Model.Feed selectedFeed = (Model.Feed)tvm.Node; Data.Feed df = new Data.Feed(selectedFeed); df.MarkAllRead(); } else if (tvm.Node is Model.Host) { Model.Host selectedHost = (Model.Host)tvm.Node; Data.Host dh = new Data.Host(selectedHost); dh.MarkAllRead(); } else { return; } foreach (Article a in Articles) { a.Unread = false; } }
protected void btnSave_Click(object sender, EventArgs e) { int response = 0; Model.Host host = new Model.Host() { HostId = this.HostId, ContactNos = txtContactNo.Text.Trim(), Description = txtDescription.Text.Trim(), HostName = txtHostName.Text.Trim(), Location = txtLocation.Text.Trim(), Maplocation = txtMapLocation.Text.Trim() }; using (var scope = Startup.Container.BeginLifetimeScope()) { var Host = scope.Resolve <IHost>(); response = Host.Host_Save(host); } if (response > 0) { ClearControls(); LoadHostList(); Message.IsSuccess = true; Message.Text = "Saved Successfully"; } else { Message.IsSuccess = false; Message.Text = "Host Name Exists"; } }
public DataTable Host_GetAll(Model.Host host) { using (DataTable dt = new DataTable()) { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ToString())) { using (SqlCommand cmd = new SqlCommand()) { cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = "usp_Host_GetAll"; if (host.HostId == 0) { cmd.Parameters.AddWithValue("@HostId", DBNull.Value); } else { cmd.Parameters.AddWithValue("@HostId", host.HostId); } if (string.IsNullOrEmpty(host.HostName)) { cmd.Parameters.AddWithValue("@HostName", DBNull.Value); } else { cmd.Parameters.AddWithValue("@HostName", host.HostName); } if (string.IsNullOrEmpty(host.ContactNos)) { cmd.Parameters.AddWithValue("@ContactNo", DBNull.Value); } else { cmd.Parameters.AddWithValue("@ContactNo", host.ContactNos); } if (con.State == ConnectionState.Closed) { con.Open(); } using (SqlDataAdapter da = new SqlDataAdapter(cmd)) { da.Fill(dt); } con.Close(); } } return(dt); } }
private DataTable LoadHostData() { DataTable dtHost; Model.Host host = new Model.Host() { ContactNos = txtContactNo.Text.Trim(), HostName = txtHostName.Text.Trim() }; using (var scope = Startup.Container.BeginLifetimeScope()) { var Host = scope.Resolve <IHost>(); dtHost = Host.Host_GetAll(host); } return(dtHost); }
public void DSA_Sil2Cil() { Model.Host host = new Model.Host(); Model.ILoader provider = new CecilProvider.Loader(host); string buildDir = Path.GetDirectoryName(System.Reflection.Assembly.GetAssembly(typeof(CecilProvider.Loader)) .Location); // create temporary directory where we place generated dlls string tempDir = Utils.GetTemporaryDirectory(); // sanity check for needed libraries // resourceDSALibrary is the library that is going to be processed // resourceDSANUnit has test cases for the DSA library string resourceDSALibrary = Path.Combine(buildDir, "Resources/DSA/Library/DSA.dll"); string resourceDSANUnit = Path.Combine(buildDir, "Resources/DSA/NUnit/DSANUnitTests.dll"); if (!File.Exists(resourceDSALibrary) || !File.Exists((resourceDSANUnit))) { throw new FileNotFoundException(); } // read the DSA library and re compile it using our framework provider.LoadAssembly(resourceDSALibrary); CodeGenerator.CecilCodeGenerator.CecilCodeGenerator exporter = new CodeGenerator.CecilCodeGenerator.CecilCodeGenerator(host); exporter.WriteAssemblies(tempDir); // copy nunit test library to temp dir string dsaNUnit = Path.Combine(tempDir, "DSANUnitTests.dll"); File.Copy(resourceDSANUnit, dsaNUnit); // execute nunit test suite NUnitLite.AutoRun autoRun = new NUnitLite.AutoRun(System.Reflection.Assembly.LoadFrom(dsaNUnit)); string outputTxt = Path.Combine(tempDir, "output.txt"); string outputCmd = "--out=" + outputTxt; autoRun.Execute(new string[1] { outputCmd }); // check results string output = File.ReadAllText(outputTxt); Assert.IsTrue(output.Contains("Test Count: 618, Passed: 618")); }
private void LoadHostList() { DataTable dtHost; Model.Host host = new Model.Host() { }; using (var scope = Startup.Container.BeginLifetimeScope()) { var Host = scope.Resolve <IHost>(); dtHost = Host.Host_GetAll(host); } if (dtHost != null) { dgvHost.DataSource = dtHost; dgvHost.DataBind(); } }
private void LoadHostList() { DataTable dtHost; Model.Host host = new Model.Host() { }; using (var scope = Startup.Container.BeginLifetimeScope()) { var Host = scope.Resolve <IHost>(); dtHost = Host.Host_GetAll(host); } if (dtHost != null) { ddlHost.DataSource = dtHost; ddlHost.DataValueField = "HostId"; ddlHost.DataTextField = "HostName"; ddlHost.DataBind(); } ddlHost.InsertSelect(); }
private void Host_GetById() { DataTable dtHost; Model.Host host = new Model.Host() { HostId = this.HostId }; using (var scope = Startup.Container.BeginLifetimeScope()) { var Host = scope.Resolve <IHost>(); dtHost = Host.Host_GetAll(host); } if (dtHost != null && dtHost.Rows.Count > 0) { txtContactNo.Text = dtHost.Rows[0]["ContactNos"].ToString(); txtDescription.Text = dtHost.Rows[0]["Description"].ToString(); txtHostName.Text = dtHost.Rows[0]["HostName"].ToString(); txtLocation.Text = dtHost.Rows[0]["Location"].ToString(); txtMapLocation.Text = dtHost.Rows[0]["MapLocation"].ToString(); } }
public Context(Cecil.ModuleDefinition current, ModelMapping modelMapping, Model.Host host) { CurrentModule = current; ModelMapping = modelMapping; Host = host; }
public CecilCodeGenerator(Model.Host h) { host = h; }
public DataTable Host_GetAll(Model.Host host) { return(_Host.Host_GetAll(host)); }
public int Host_Save(Model.Host host) { return(_Host.Host_Save(host)); }
public Host(Model.Host h) : base(h) { }
private void InitializeData(Boolean refreshTreeView) { SetStatusMessage("Loading"); // // Read from Database // _allData = Data.Host.LoadAll(); SetStatusMessage("Loaded"); // // Update the treeview // if (refreshTreeView) { //Set selected item TreeModel.Items[0].IsSelected = true; RaisePropertyChanged("TreeModel"); SelectedItemChanged(new RoutedPropertyChangedEventArgs <object>(null, TreeModel.Items[0])); } // // Update articles // if (_selectedNode != null) { SimpleTreeNodeViewModel tvm = (SimpleTreeNodeViewModel)_selectedNode; if (tvm.Node is Model.Feed) { SetStatusMessage("Updating Articles (feed)... "); Model.Feed selectedFeed = (Model.Feed)tvm.Node; // Find the feed and add the Articles foreach (Host h in _allData) { Feed f = h.Feeds.FirstOrDefault(el => el.Location.Equals(selectedFeed.Location)); if (f != null) { Articles.AddMissing(f.Articles, new ArticleEqualityComparer(), _uiContext); } } } else if (tvm.Node is Model.Host) { SetStatusMessage("Updating Articles (host)... "); Model.Host selectedHost = (Model.Host)tvm.Node; // Find the host and add the Articels Model.Host h = _allData.FirstOrDefault(el => el.Location.Equals(selectedHost.Location)); foreach (Model.Feed feed in h.Feeds) { Articles.AddMissing(feed.Articles, new ArticleEqualityComparer(), _uiContext); } } else { SetStatusMessage("Updating Articles (article)... "); foreach (Model.Host h in _allData) { foreach (Model.Feed feed in h.Feeds) { Articles.AddMissing(feed.Articles, new ArticleEqualityComparer(), _uiContext); } } } } if (refreshTreeView) { SetStatusMessage("Refreshing Article list"); SetSortOrder(); } SetStatusMessage("Ready"); }
private async void EditFeed(RoutedEventArgs e) { if (_selectedNode == null) { return; } SimpleTreeNodeViewModel tvm = (SimpleTreeNodeViewModel)_selectedNode; Model.Feed selectedFeed = null; if (tvm.Node is Model.Feed) { selectedFeed = (Model.Feed)tvm.Node; } else { if (tvm.Node is Model.Host) { try { Model.Host selectedHost = (Model.Host)tvm.Node; IsBrowserVisible = false; RaisePropertyChanged("IsBrowserVisible"); MetroDialogSettings diagSettings = new MetroDialogSettings(); diagSettings.DefaultText = selectedHost.Zoom.ToString(); var ZoomLevel = await _dialogCoordinator.ShowInputAsync(this, "Set Zoom Level", "Enter the desired zoom level for this host: ", diagSettings); int prevZoom = selectedHost.Zoom; selectedHost.Zoom = Int32.Parse(ZoomLevel.ToString()); Data.Host dh = new Data.Host(selectedHost); dh.Save(); if (prevZoom != selectedHost.Zoom) { var msg = new SendSetZoomMessage(selectedHost.Zoom); msg.SetImmediately = true; Messenger.Default.Send <SendSetZoomMessage>(msg); } } catch (Exception ex) { await _dialogCoordinator.ShowMessageAsync(this, "Set Zoom Level", "Unable to set zoom: " + ex.Message); } finally { IsBrowserVisible = true; RaisePropertyChanged("IsBrowserVisible"); } } return; } // Hides browser otherwise dialog gets behind it IsBrowserVisible = false; RaisePropertyChanged("IsBrowserVisible"); MetroDialogSettings dialogSettings = new MetroDialogSettings(); dialogSettings.DefaultText = selectedFeed.Location.ToString(); var FeedText = await _dialogCoordinator.ShowInputAsync(this, "Edit feed", "Enter the URL of the feed:", dialogSettings); if (FeedText != null) { string errMsg = null; try { Uri feedUri = new Uri(FeedText); Data.Feed f = new Data.Feed(selectedFeed); f.Location = feedUri; f.UpdateFromUri(true, RetentionDays); f.Save(true); InitializeData(true); } catch (Exception ex) { errMsg = ex.Message; } if (errMsg != null) { await _dialogCoordinator.ShowMessageAsync(this, "Edit Feed", "Unable to edit feed with the supplied URL: " + errMsg); } } IsBrowserVisible = true; RaisePropertyChanged("IsBrowserVisible"); }