Error in displaying the List of programs from database - c#

Here i am trying to show the list of programs from database in my list.cshtml. I am not able to get the list of programs.
Suggest me if there is any wrong in code. I am facing issue in cacheUtilities as ArgumentNullException. someone help me with the code issue to get the list of programs from database.
Controller Code
[HttpGet]
[Authorize(Roles = "Affiliate")]
public ActionResult GetTrainingPrograms(int? affiliateId, string searchStr, bool? active, string sort, int? start, int? limit)
{
int affId = UserData.AffiliateID;
if (affiliateId != null && affiliateId.Value > 0)
{
affId = affiliateId.Value;
}
string searchStrLower = string.Empty;
string queryStr = String.Concat(affId);
// The start point in the list of Training Programs
if (start != null)
{
queryStr = String.Concat(queryStr, "-", start.Value);
}
// To find Active or Inactive at the Current Time
if (active != null)
{
queryStr = String.Concat(queryStr, "-", active);
}
// Sort the List of Data
if (sort == null)
{
sort = "trainingProgramName";
}
queryStr = String.Concat(queryStr, "-", sort);
// limit on the page to Display
if (limit != null)
{
queryStr = String.Concat(queryStr, "-", limit.Value);
}
//The keywords used to find a Training Program
if (!string.IsNullOrEmpty(searchStr))
{
searchStrLower = searchStr.ToLower();
queryStr = String.Concat(queryStr, "-", searchStrLower);
}
logger.Debug("trainingProgramListKey: " + queryStr);
TrainingProgramList reloadData = CacheUtilities.Instance.GetTrainingProgramList(affiliateId);
logger.Debug("reloadData: " + reloadData + ", affId: " + affId + ", queryStr: " + queryStr);
string trainingProgramCacheKey = CbConstants.TrainingProgramCacheKey + queryStr;
TrainingProgramList trainingProgramList = null;
int totalCount = 0;
// Checks the List is null or not to Display
if (trainingProgramList != null)
{
logger.Debug("Cache miss for TrainingProgram list: " + trainingProgramCacheKey);
trainingProgramList = new TrainingProgramList();
trainingProgramList.AffiliateID = affId;
totalCount = TrainingProgramRepository.Instance.GetTrainingProgramsCount(affId, searchStrLower, active);
trainingProgramList.Entries = TrainingProgramRepository.Instance.GetTrainingPrograms(affId, searchStrLower, active, sort, start, limit);
HttpRuntime.Cache.Insert(trainingProgramCacheKey, trainingProgramList, null, Cache.NoAbsoluteExpiration, CbConstants.CacheSlidingExpirationOneDay);
}
CbJsonResponse response = new CbJsonResponse();
response.Data.Add(trainingProgramList);
response.Status = "success";
response.Meta.Add("total", Convert.ToString(totalCount));
return Json(response, "application/json", System.Text.Encoding.UTF8, JsonRequestBehavior.AllowGet);
}
}
}
Repository Code:
public List<TrainingProgramListEntry> GetTrainingPrograms(int affiliateId, string searchStr, bool? active, string sort, int? start, int? limit)
{
using (var ctx = new CrossfitPortalEntities())
{
ctx.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);
// Don't need proxies when explicitly loading.
ctx.Configuration.ProxyCreationEnabled = false;
var query = ctx.TrainingPrograms.Where(m => m.AffiliateID == affiliateId);
//The keywords used to find a Training Program
if (!string.IsNullOrEmpty(searchStr))
{
query = query.Where(m => m.Name.ToLower().Contains(searchStr));
}
if (active != null)
{
}
// The property on which to sort this list.
if (sort != null)
{
switch (sort)
{
case "TrainingProgram Name":
query = query.OrderBy(m => m.Name);
break;
}
}
//The number of Training Programs to display on this page.
if (limit != null)
{
logger.Debug("TrainingProgram query limit: " + limit.Value);
}
var entries = query.Select(m => new TrainingProgramListEntry
{
Name = m.Name,
ColorCode = m.ColorCode,
// The start point in the list of Training Programs
}).Skip((start != null) ? start.Value : 0).Take((limit != null) ? limit.Value : 10).ToList();
return entries;
}
}
CacheUtilites Code:
public TrainingProgramList GetTrainingProgramList(int? affiliateID)
{
string trainingProgramCacheKey = CbConstants.TrainingProgramCacheKey + affiliateID;
TrainingProgramList trainingprogram = (TrainingProgramList)HttpRuntime.Cache[trainingProgramCacheKey];
if (trainingprogram != null)
{
logger.Debug("Cache hit for AffProfile Entity: " + trainingProgramCacheKey);
}
else
{
logger.Debug("Cache miss for AffProfile Entity: " + trainingProgramCacheKey);
trainingprogram = TrainingProgramRepository.Instance.GetTrainingPrograms(AffiliateID);
HttpRuntime.Cache.Insert(trainingProgramCacheKey, trainingprogram, null, Cache.NoAbsoluteExpiration, CbConstants.CacheSlidingExpirationTwoHours);
}
return trainingprogram;
}

Related

How to limit the amount of parameters for concatenatenation?

The idea of the program is to concatenate different parameters and put it all inside another parameter. How to let the end user decide if he wants to concatenate 2 or 3 parameters. Right now it is like if you don't put in 3 parameters it won't work. Nothing I came up with works.
namespace CombineParametersWinForm
{
public partial class Form1 : System.Windows.Forms.Form
{
//Class variable
Document revitDoc { get; set; }
public Form1(Document doc)
{
InitializeComponent();
this.revitDoc = doc;
//Create a list of the parameters you want your user to choose from
List<string> stringParameters = new List<string>
{
"Weight",
"Angle",
"Manufacturer"
};
//Add list to comboboxes on form
foreach (string parameterName in stringParameters)
{
comboBox1.Items.Insert(0, parameterName);
comboBox2.Items.Insert(0, parameterName);
comboBox3.Items.Insert(0, parameterName);
}
}
private void button1_Click(object sender, EventArgs e)
{
FilteredElementCollector collector = new FilteredElementCollector(revitDoc);
ElementCategoryFilter filter = new ElementCategoryFilter(BuiltInCategory.OST_PipeFitting);
//Applying Filter
IList<Element> ducts = collector.WherePasses(filter).WhereElementIsNotElementType().ToElements();
foreach (Element duct in ducts)
{
//Get Parameter values
string parameterValue1 = duct.LookupParameter(comboBox1.Text).AsValueString();
string parameterValue2 = duct.LookupParameter(comboBox2.Text).AsValueString();
string parameterValue3 = duct.LookupParameter(comboBox3.Text).AsValueString();
string newValue = parameterValue1 + "-" + parameterValue2 + "-" + parameterValue3;
//do not need .ToString() when setting parameter
using (Transaction t = new Transaction(revitDoc, "Set Parameter name"))
{
t.Start();
duct.LookupParameter("New").Set(newValue);
t.Commit();
}
Ideas. First is pretty long one.
string parameterValue1 = duct.LookupParameter(comboBox1.Text).AsValueString();
string parameterValue2 = duct.LookupParameter(comboBox2.Text).AsValueString();
string parameterValue3 = duct.LookupParameter(comboBox3.Text).AsValueString();
if (parameterValue1 != "" || parameterValue1 != null)
{
parameterValue1 = parameterValue11;
}
if (parameterValue2 != "" || parameterValue2 != null)
{
parameterValue1 = parameterValue22;
}
if (parameterValue3 != "" || parameterValue3 != null)
{
parameterValue3 = parameterValue33;
}
if (parameterValue1 == "" || parameterValue1 == null)
{
parameterValue11 = "";
}
if (parameterValue2 == "" || parameterValue2 == null)
{
parameterValue22 = "";
}
if (parameterValue3 == "" || parameterValue3 == null)
{
parameterValue33 = "";
}
string newValue = parameterValue1 + "-" + parameterValue2 + "-" + parameterValue3;
using (Transaction t = new Transaction(revitDoc, "Set Parameter name"))
{
t.Start();
duct.LookupParameter("New").Set(newValue);
t.Commit();
}
}
}
}
}
Second is a short one but still doesn't work
string parameterValue1 = duct.LookupParameter(comboBox1.Text).AsValueString();
string parameterValue2 = duct.LookupParameter(comboBox2.Text).AsValueString();
string parameterValue3 = duct.LookupParameter(comboBox3.Text).AsValueString();
List<string> listParam = new List<string> { parameterValue1, parameterValue2, parameterValue3 };
foreach (string s in listParam)
{
if (s != "" /*&& s != null*/)
{
List<string> listParamNotNull = new List<string> { s };
string newValue = String.Join(" ,", listParamNotNull);
using (Transaction t = new Transaction(revitDoc, "Set Parameter name"))
{
t.Start();
duct.LookupParameter("New").Set(newValue);
t.Commit();
}
You are creating three separate Lists and wanting to do something against all of them combined, but actually doing against each of them individually, overwriting as you go.
Please take a closer look at your nested logic.
Something like this is likely more appropriate:
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
string parameterValue1 = "Value1";
string parameterValue2 = ""; // purposefully providing an empty value
string parameterValue3 = "Value3";
var listParamIn = new List<string> { parameterValue1, parameterValue2, parameterValue3 };
var listParamOut = new List<string>();
foreach (string s in listParamIn){
if (string.IsNullOrEmpty(s))
continue;
listParamOut.Add(s);
}
string newValue = String.Join(", ", listParamOut);
Console.WriteLine(newValue);
/* continue with your transaction
using (Transaction t = new Transaction(revitDoc, "Set Parameter name")){
t.Start();
duct.LookupParameter("New").Set(newValue);
t.Commit();
}
*/
}
}
Output:
Value1, Value3
See:
https://dotnetfiddle.net/mXdL5F

Updating values in gridview is not working

There is a row in gridview in which there is a column name as POA_NO whose value is 899.
But I am deleting that value and updating it as blank. But still it is getting updated as 899 only.
Here is my code
protected void GrdDetail_UpdateCommand(object sender, GridRecordEventArgs e)
{
if (Session["ViewInfo"] != null)
{
dtViewInfo = (DataTable)Session["ViewInfo"];
}
else
{
return;
}
DataRow[] drViewInfo = dtViewInfo.Select("SR_NO = " + e.Record["SR_NO"]);
if (e.Record["TYPE"] != "")
{
drViewInfo[0]["TYPE"] = e.Record["TYPE"];
}
else
{
drViewInfo[0]["TYPE"] = "NULL";
}
if (e.Record["REF_NO"] != "")
{
drViewInfo[0]["REF_NO"] = e.Record["REF_NO"];
}
if (e.Record["REF_DATE"] != "")
{
drViewInfo[0]["REF_DATE"] = e.Record["REF_DATE"];
}
if (e.Record["POA_NO"] != "")
{
drViewInfo[0]["POA_NO"] = e.Record["POA_NO"];
}
if (e.Record["POA_DATE"] != "")
{
drViewInfo[0]["POA_DATE"] = e.Record["POA_DATE"];
}
if (e.Record["POA_NAME"] != "")
{
drViewInfo[0]["POA_NAME"] = e.Record["POA_NAME"];
}
if (e.Record["ATTACHMENT"] != "")
{
drViewInfo[0]["ATTACHMENT"] = e.Record["ATTACHMENT"];
}
GrdDetail.DataSource = dtViewInfo;
GrdDetail.DataBind();
AddToViewState("GridViewInfo");
}
EDIT
Page load code
dtViewInfo = CF.ExecuteDT("select sr_no, type, ref_no, to_char (ref_date,'dd/MM/yyyy') ref_date, POA_NO , to_char (POA_DATE, 'dd/MM/yyyy') POA_DATE, POA_NAME, attachment from xxcus.XXACL_PN_VIEW_DATA_INFO " +
"where mkey = '" + StrMkey + "' order by sr_no");
GrdDetail.DataSource = dtViewInfo;
GrdDetail.DataBind();
AddToViewState("GridViewInfo");

Check each List item if Null

I am quite poor at writing code, hence the question. Below I am adding items into a SharePoint List from a DB while checking if any of the fields contains DBNulls. Rather than having to perform the check for each column like I am below, can someone help me to put it in a loop if possible? I would be forever grateful
using (OdbcConnection connection = new OdbcConnection())
{
connection.ConnectionString = "dsn=abc;uid=xyz;pwd=yuo;DataSource=aaa";
connection.ConnectionTimeout = 100;
connection.Open();
OdbcCommand command_donor = new OdbcCommand("Select * From vw_SP_aaa_bbb", connection);
try
{
using (OdbcDataReader reader = command_donor.ExecuteReader())
{
while (reader.Read())
{
var obj0 = reader.GetValue(48);
var obj1 = reader.GetValue(0);
var obj2 = reader.GetValue(33);
var obj3 = reader.GetValue(47);
var obj4 = reader.GetValue(42);
var obj5 = reader.GetValue(42);
ListItem oListItem_aaa = oList_aaa .AddItem(itemCreateInfo);
if (obj0 == null || obj0.Equals(DBNull.Value))
{ oListItem_aaa["Title"] = ""; }
else
{ oListItem_aaa["Title"] = reader.GetString(48).ToString(); }
if (obj1 == null || obj1.Equals(DBNull.Value))
{ oListItem_aaa["aaa_x0020_ID"] = ""; }
else
{ oListItem_aaa["aaa_x0020_ID"] = reader.GetString(0).ToString(); }
if (obj2 == null || obj2.Equals(DBNull.Value))
{ oListItem_aaa["Excluded_x0020_By"] = ""; }
else
{ oListItem_aaa["Excluded_x0020_By"] = reader.GetString(33).ToString(); }
if (obj3 == null || obj3.Equals(DBNull.Value))
{ oListItem_aaa["Excluded_x0020_On"] = ""; }
else
{ oListItem_aaa["Excluded_x0020_On"] = reader.GetDateTime(47).ToString("MM/dd/yyyy"); }
if (obj4 == null || obj4.Equals(DBNull.Value))
{ oListItem_aaa["Reason"] = ""; }
else
{ oListItem_aaa["Reason"] = reader.GetString(42).Substring(50, reader.GetString(42).ToString().Length-50); }
if (obj5 == null || obj5.Equals(DBNull.Value))
{ oListItem_aaa["Publish"] = ""; }
else
{ oListItem_aaa["Publish"] = reader.GetString(42).Substring(50, reader.GetString(42).ToString().Length - 50); }
oListItem_aaa.Update();
context.ExecuteQuery();
}
}
}
catch (Exception exception)
{
Console.WriteLine("The Error is:" + exception);
Console.ReadLine();
}
}
Use Short IIF like
oListItem_aaa["Excluded_x0020_By"] = (obj1 == null || obj1.Equals(DBNull.Value)) ? "" : reader.GetString(0).ToString();
or
var obj0 = (reader.GetValue(48) != DBNull.Value && !String.IsNullOrEmpty(Convert.ToString(reader.GetValue(48)))) ? reader.GetValue(48) : "");
in one line. Then you dont need to use the if then else's... described also in MSDN at Operator ?: (C#-Referenz).

How to get Android device owner's user profile data using Xamarin/C#

I'm building an app for Android 4.0 (Ice Cream Sandwich) and higher, and would like to get the device owner's user profile info such as:
DisplayName, Email, Phone, Job Title, Company, Office Location, Website and Url
I've tried different methods from different Stackoverflow posts that I read, including going to the phone's accounts to querying the user profile (ContactsContract.Profile.ContentUri). No dice. I've checked the permissions for ReadOwnerData and ReadProfile.
Right now I'm querying the Contacts with this code, but the managed query is returning with a count of 0.
var c = act.ManagedQuery (ContactsContract.Profile.ContentUri, null, null, null, null);
int count = c.Count;
string[] columnNames = c.GetColumnNames();
bool b = c.MoveToFirst();
int position = c.Position;
if (position == 0) {
do {
for (int j = 0; j < columnNames.Length; j++) {
string columnName = columnNames[j];
try {
string columnValue = c.GetString(c.GetColumnIndex(columnName));
} catch {}
if (c.GetString(c.GetColumnIndex("is_user_profile")) == "1") {
if (c.GetString(c.GetColumnIndex("has_email")) == "1") {
//var cEmail = ManagedQuery (ContactsContract.Data.ContentUri, null, ContactsContract.Data.InterfaceConsts.HasPhoneNumber + "!=0 AND (" + ContactsContract.Data.InterfaceConsts.Mimetype + "=? OR " + ContactsContract.Data.InterfaceConsts.Mimetype + "=?)", new String[]{ ContactsContract.CommonDataKinds.Email.ContentItemType, ContactsContract.CommonDataKinds.Phone.ContentItemType, ContactsContract.Contacts.InterfaceConsts.Id }, null);
var cEmail = act.ManagedQuery (ContactsContract.CommonDataKinds.Email.ContentUri, null, ContactsContract.CommonDataKinds.Email.InterfaceConsts.Type + " = ?", new String[]{ c.GetString(c.GetColumnIndex(BaseColumns.Id)) }, null);
string[] columnNamesEmail = cEmail.GetColumnNames();
if (cEmail.Count > 0) {
cEmail.MoveToFirst();
do {
sEmail = cEmail.GetString(cEmail.GetColumnIndex(ContactsContract.CommonDataKinds.Email.InterfaceConsts.Type));
//sEmail = cEmail.GetString(cEmail.GetColumnIndex(ContactsContract.CommonDataKinds.Email.InterfaceConsts.Data));
//sEmail = cEmail.GetString(cEmail.GetColumnIndex(ContactsContract.CommonDataKinds.Email.InterfaceConsts.ContactId));
} while (cEmail.MoveToNext());
}
cEmail.Close();
}
if (c.GetString(c.GetColumnIndex("has_phone_number")) == "1") {
var cPhone = act.ManagedQuery (ContactsContract.CommonDataKinds.Phone.ContentUri, null, ContactsContract.CommonDataKinds.Phone.InterfaceConsts.ContactId + " = ?", new String[]{ c.GetString(c.GetColumnIndex(BaseColumns.Id)) }, null);
string[] columnNamesPhone = cPhone.GetColumnNames();
if (cPhone.Count > 0) {
cPhone.MoveToFirst();
do {
sPhone = cPhone.GetString(cPhone.GetColumnIndex(ContactsContract.CommonDataKinds.Phone.InterfaceConsts.Type));
} while (cPhone.MoveToNext());
}
cPhone.Close();
}
}
}
} while (c.MoveToNext());
}
c.Close();
This part of the code returns with a count of 0:
if (cEmail.Count > 0) {
Can someone point out how I can rewrite this query?
var cEmail = act.ManagedQuery (ContactsContract.CommonDataKinds.Email.ContentUri, null, ContactsContract.CommonDataKinds.Email.InterfaceConsts.Type + " = ?", new String[]{ c.GetString(c.GetColumnIndex(BaseColumns.Id)) }, null);
Or should I go back to querying the user profile or accounts? Here's the code I was using for them:
Accounts:
Account[] accounts = AccountManager.Get (Context).GetAccounts ();
foreach (Account acc in accounts) {
--- can only get DisplayName and ID
}
User Profile:
var uri = ContactsContract.Profile.ContentUri;
string[] projection = {
ContactsContract.CommonDataKinds.StructuredName.DisplayName,
ContactsContract.CommonDataKinds.Email.Address,
ContactsContract.CommonDataKinds.Phone.Number,
ContactsContract.CommonDataKinds.Organization.Title,
ContactsContract.CommonDataKinds.Organization.Company,
ContactsContract.CommonDataKinds.Organization.OfficeLocation,
ContactsContract.CommonDataKinds.Website.Url };
var cursor = ManagedQuery (uri, projection, null, null, null);
if (cursor.MoveToFirst ()) {
do {
sDisplayName = cursor.GetString (cursor.GetColumnIndex (projection [0]));
sEmail = cursor.GetString (cursor.GetColumnIndex (projection [1]));
sPhone = cursor.GetString (cursor.GetColumnIndex (projection [2]));
sTitle = cursor.GetString (cursor.GetColumnIndex (projection [3]));
sCompany = cursor.GetString (cursor.GetColumnIndex (projection [4]));
sOfficeLocation = cursor.GetString (cursor.GetColumnIndex (projection [5]));
sWebsite = cursor.GetString (cursor.GetColumnIndex (projection [6]));
} while (cursor.MoveToNext());
}

How to continue execution of method after returning data?

I developed a Web API for performance monitoring on machines, that when calling the resource via URL, the information is printed on the browser in json format. One of the methods has a loop that gets a new data value every second.
Is it possible to "return" the value upon each iteration and display it in json on the browser, thus updating automatically with each iteration? In other words, I'm trying to create a live update mechanism, rather than waiting for the program to execute and then displaying the json once the performance data log is completed.
public List<LogInfo> LogTimedPerfData(string macName, string categoryName, string counterName,
string instanceName, string logName, long? seconds)
{
iModsDBRepository modsDB = new iModsDBRepository();
List<MachineInfo> theMac = modsDB.GetMachineByName(macName);
if (theMac.Count == 0)
return new List<LogInfo>();
else if (instanceName == null)
{
if (!PerformanceCounterCategory.Exists(categoryName, macName) ||
!PerformanceCounterCategory.CounterExists(counterName, categoryName, macName) )
{
return new List<LogInfo>();
}
}
else if (instanceName != null)
{
if (!PerformanceCounterCategory.Exists(categoryName, macName) ||
!PerformanceCounterCategory.CounterExists(counterName, categoryName, macName) ||
!PerformanceCounterCategory.InstanceExists(instanceName, categoryName, macName))
{
return new List<LogInfo>();
}
}
else if (logName == null)
{
return new List<LogInfo>();
}
// Check if entered log name is a duplicate for the authenticated user
List<LogInfo> checkDuplicateLog = this.GetSingleLog(logName);
if (checkDuplicateLog.Count > 0)
{
return new List<LogInfo>();
}
PerformanceCounterCategory category = new PerformanceCounterCategory(categoryName, theMac[0].MachineName);
if (category.CategoryName == null || category.MachineName == null)
{
return new List<LogInfo>();
}
List<LogInfo> logIt = new List<LogInfo>();
if (category.CategoryType != PerformanceCounterCategoryType.SingleInstance)
{
List<InstanceInfo> instances = modsDB.GetInstancesFromCatMacName(theMac[0].MachineName, category.CategoryName);
foreach (InstanceInfo inst in instances)
{
if (!category.InstanceExists(inst.InstanceName))
{
continue;
}
else if (inst.InstanceName.Equals(instanceName, StringComparison.OrdinalIgnoreCase))
{
PerformanceCounter perfCounter = new PerformanceCounter(categoryName, counterName,
inst.InstanceName, theMac[0].MachineName);
string data = "";
List<UserInfo> currUser = this.GetUserByName(WindowsIdentity.GetCurrent().Name);
string timeStarted = DateTime.Now.ToString("MM/dd/yyyy - h:mm:ss tt");
string[] dataValues = new string[(int)seconds];
for (int i = 0; i < seconds; i++)
{
data = "Value " + i + ": " + perfCounter.NextValue().ToString();
dataValues[i] = data;
Thread.Sleep(1000);
}
string timeFinished = DateTime.Now.ToString("MM/dd/yyyy - h:mm:ss tt");
Log log = new Log
{
LogName = logName,
CounterName = perfCounter.CounterName,
InstanceName = perfCounter.InstanceName,
CategoryName = perfCounter.CategoryName,
MachineName = perfCounter.MachineName,
TimeStarted = timeStarted,
TimeFinished = timeFinished,
PerformanceData = string.Join(",", dataValues),
UserID = currUser[0].UserID
};
this.CreateLog(log);
logIt.Add(new LogInfo
{
LogName = logName,
CounterName = perfCounter.CounterName,
InstanceName = perfCounter.InstanceName,
CategoryName = perfCounter.CategoryName,
MachineName = perfCounter.MachineName,
TimeStarted = timeStarted,
TimeFinished = timeFinished,
PerformanceData = dataValues.ToList<string>()
});
break;
}
}
}
else
{
PerformanceCounter perfCounter = new PerformanceCounter(categoryName, counterName,
"", theMac[0].MachineName);
string data = "";
List<UserInfo> currUser = this.GetUserByName(WindowsIdentity.GetCurrent().Name);
string timeStarted = DateTime.Now.ToString("MM/dd/yyyy - h:mm:ss tt");
string[] dataValues = new string[(int)seconds];
for (int i = 0; i < seconds; i++)
{
data = "Value " + i + ": " + perfCounter.NextValue().ToString();
dataValues[i] = data;
Thread.Sleep(1000);
}
string timeFinished = DateTime.Now.ToString("MM/dd/yyyy - h:mm:ss tt");
Log log = new Log
{
LogName = logName,
CounterName = perfCounter.CounterName,
InstanceName = perfCounter.InstanceName,
CategoryName = perfCounter.CategoryName,
MachineName = perfCounter.MachineName,
TimeStarted = timeStarted,
TimeFinished = timeFinished,
PerformanceData = string.Join(",", dataValues),
UserID = currUser[0].UserID
};
this.CreateLog(log);
logIt.Add(new LogInfo
{
LogName = logName,
CounterName = perfCounter.CounterName,
InstanceName = perfCounter.InstanceName,
CategoryName = perfCounter.CategoryName,
MachineName = perfCounter.MachineName,
TimeStarted = timeStarted,
TimeFinished = timeFinished,
PerformanceData = dataValues.ToList<string>()
});
}
return logIt;
}
You might want to do some research on SignalR there are a couple tutorials out there on pushing notifications to browsers with SignalR.
Handful of possibly helpful links:
https://github.com/SignalR/SignalR/wiki
http://www.codeproject.com/Articles/322154/ASP-NET-MVC-SIngalR-and-Knockout-based-Real-time-U
http://www.msguy.com/2011/11/real-time-push-notifications-with.html

Categories