public HttpResponseMessage getUserActivityCodes(postmethod pm) { getUserActivityCodes ga = new getUserActivityCodes(); try { string qry = "select * from MDM_DeviceMaster where DeviceID='" + pm.uuid + "'"; dr = databaseHelper.getDataReader(qry); if (dr.Read()) { if (!dr.IsClosed) { dr.Close(); } List <userCodes> uc = new List <userCodes>(); qry = "select ActivityCode,ActivityName,Type from MDM_ActivityCode"; dtable = databaseHelper.getDataTable(qry); foreach (DataRow drow in dtable.Rows) { uc.Add(new userCodes { code = drow["ActivityCode"].ToString(), name = drow["ActivityName"].ToString(), type = drow["Type"].ToString() }); } ga.userCodes = uc; ga.response = true; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, ga); /*qry = "delete from MDM_PushNotification where DeviceID='" + pm.uuid + "'"; * rcnt = databaseHelper.ExecuteQuery(qry);*/ return(response); } else { ga.response = true; ga.errorCode = "Authentication Failed"; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, ga); return(response); } } catch (Exception ex) { linfo.LogFile(enLogType.EXCEPTION, ex.Message, null); } finally { if (dr != null && !dr.IsClosed) { dr.Close(); } } return(null); }
/// <summary> ///Process The Remotely Enabled GPS. A webservice which is called after the gps of the selected ///devices are enabled /// </summary> /// <param name="Ar"></param> /// <returns></returns> public HttpResponseMessage ProcessRemotelyEnableGPS(postmethod pm) { ar = new WebApiResponse(); string qry = "select * from MDM_DeviceMaster where DeviceID='" + pm.uuid + "'"; dr = databaseHelper.getDataReader(qry); try { if (dr.Read()) { if (!dr.IsClosed) { dr.Close(); } qry = "update MDM_DeviceMaster set GPSStatus=1 where DeviceID='" + pm.uuid + "'"; rcnt = databaseHelper.ExecuteQuery(qry); qry = "delete from MDM_PushNotification where DeviceID='" + pm.uuid + "' and Command like '%Remotely Enable GPS%'"; rcnt = databaseHelper.ExecuteQuery(qry); ar.response = true; response = Request.CreateResponse(HttpStatusCode.Created, ar); return(response); } else { ar.errorCode = "Authentication Failed"; ar.response = false; response = Request.CreateResponse(HttpStatusCode.BadRequest, ar); return(response); } } catch (Exception ex) { ar.errorCode = "Remote Enable GPS Failed"; ar.response = false; response = Request.CreateResponse(HttpStatusCode.BadRequest, ar); linfo.LogFile(enLogType.EXCEPTION, ex.Message, null); } finally { if (dr != null && !dr.IsClosed) { dr.Close(); } } return(response); }
public HttpResponseMessage getAccessibleWebsites(postmethod pm) { getAccessibleWebsites gaw = new getAccessibleWebsites(); List <weblist> wl = new List <weblist>(); try { string qry = "select * from MDM_DeviceMaster where DeviceID='" + pm.uuid + "'"; dr = databaseHelper.getDataReader(qry); if (dr.Read()) { string UserId = dr["UserId"].ToString().ToUpper(); if (!dr.IsClosed) { dr.Close(); } string Designation = null; qry = "select UserType from AppUsers where UserName='******'"; dr = databaseHelper.getDataReader(qry); if (dr.Read()) { Designation = dr["UserType"].ToString().ToUpper(); } if (!dr.IsClosed) { dr.Close(); } qry = "Select WebsiteName,UserId,UserDesignation from MDM_AccessibleWebsite"; dtable = databaseHelper.getDataTable(qry); List <weblist> website = new List <weblist>(); foreach (DataRow drow in dtable.Rows) { //linfo.LogFile(enLogType.QUERY, "drow[UserId] = " + drow["UserId"] + " drow[UserDesignation] = "+drow["UserDesignation"]+" UserId = "+UserId+". UserDesignation = "+Designation+"","rizwan"); if (drow["UserId"] == DBNull.Value && drow["UserDesignation"] == DBNull.Value) // Default Application { website.Add(new weblist { WebsiteName = (drow["WebsiteName"] == DBNull.Value) ? "" : drow["WebsiteName"].ToString() }); //linfo.LogFile(enLogType.INFO, "UserID,UserDesignation are null. WebsiteName = " + drow["WebsiteName"] + "", "rizwan"); } else if (drow["UserId"] != DBNull.Value && drow["UserDesignation"] != DBNull.Value && drow["UserId"].ToString().Length > 0 && drow["UserDesignation"].ToString().Length > 0 && drow["UserID"].ToString().Split(',').Contains(UserId) && drow["UserDesignation"].ToString().Split(',').Contains(UserId))// Application Valid only to specific user. { website.Add(new weblist { WebsiteName = (drow["WebsiteName"] == DBNull.Value) ? "" : drow["WebsiteName"].ToString() }); //linfo.LogFile(enLogType.INFO, "UserId and UserDesignation are not null . drow[UserId] = " + drow["UserId"] + " drow[UserDesignation] = " + drow["UserDesignation"] + " UserId = " + UserId + ". UserDesignation = " + Designation + "", "rizwan"); } else if (drow["UserId"] != DBNull.Value && drow["UserDesignation"] == DBNull.Value && drow["UserId"].ToString().Length > 0 && drow["UserId"].ToString().Split(',').Contains(UserId)) // Accessible to specific user. { website.Add(new weblist { WebsiteName = (drow["WebsiteName"] == DBNull.Value) ? "" : drow["WebsiteName"].ToString() }); // linfo.LogFile(enLogType.INFO, "Userid is not null. drow[UserId] = "+drow["UserId"]+" and Userid="+UserId+". drow[UserDesignation] = "+drow["UserDesignation"]+" and Designation = "+Designation+" WebsiteName = " + drow["WebsiteName"] + "", "rizwan"); } else if (drow["UserDesignation"] != DBNull.Value && drow["UserId"] == DBNull.Value && drow["UserDesignation"].ToString().Length > 0 && drow["UserDesignation"].ToString().Contains(Designation))//accessible to user of specific designation { website.Add(new weblist { WebsiteName = (drow["WebsiteName"] == DBNull.Value) ? "" : drow["WebsiteName"].ToString() }); //linfo.LogFile(enLogType.INFO, "UserDesignation is not null. drow[UserId] = " + drow["UserId"] + " and Userid=" + UserId + ". drow[UserDesignation] = " + drow["UserDesignation"] + " and Designation = " + Designation + " WebsiteName = " + drow["WebsiteName"] + "", "rizwan"); } } gaw.websiteurl = website; gaw.response = true; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, gaw); qry = "delete from MDM_PushNotification where DeviceID='" + pm.uuid + "' and Command='Get Accessible Website'"; rcnt = databaseHelper.ExecuteQuery(qry); return(response); } else { ar = new WebApiResponse(); ar.errorCode = "Authentication failed"; ar.response = false; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, ar); return(response); } } catch (Exception ex) { linfo.LogFile(enLogType.EXCEPTION, "Problem in getAccessibleWebsites function." + ex.Message + "", null); } finally { if (dr != null && !dr.IsClosed) { dr.Close(); } } return(null); }
public HttpResponseMessage getAccessibleApps(postmethod pm) { getConfigurationDetails gc = new getConfigurationDetails(); getAccessibleApps gaa = new getAccessibleApps(); List <application> ga = new List <application>(); string qry = "select * from MDM_DeviceMaster where DeviceID='" + pm.uuid + "'"; dr = databaseHelper.getDataReader(qry); if (dr.Read()) { string UserId = dr["UserId"] != DBNull.Value ? dr["UserId"].ToString().ToUpper() : null; if (!dr.IsClosed) { dr.Close(); } string Designation = null; qry = "select UserType from AppUsers where UserName='******'"; dr = databaseHelper.getDataReader(qry); if (dr.Read()) { Designation = dr["UserType"].ToString().ToUpper(); } if (!dr.IsClosed) { dr.Close(); } qry = "select ApplicationName,ApplicationPackage,UserId,UserDesignation from MDM_AccessibleApplication"; dtable = databaseHelper.getDataTable(qry); if (dtable.Rows.Count > 0) { foreach (DataRow drow in dtable.Rows) { //linfo.LogFile(enLogType.QUERY, "drow[UserId] = " + drow["UserId"] + " drow[UserDesignation] = " + drow["UserDesignation"] + " UserId = " + UserId + ". UserDesignation = " + Designation + "", "rizwan"); if (drow["UserId"] == DBNull.Value && drow["UserDesignation"] == DBNull.Value) // Default Application { ga.Add(new application { applicationName = (drow["ApplicationName"] == DBNull.Value) ? "" : drow["ApplicationName"].ToString(), applicationPackage = (drow["ApplicationPackage"] == DBNull.Value) ? "" : drow["ApplicationPackage"].ToString() }); //linfo.LogFile(enLogType.INFO, "UserID,UserDesignation are null. ApplicationName = " + drow["ApplicationName"] + " ApplicationPackage = "+drow["ApplicationPackage"]+"", "rizwan"); } else if (drow["UserId"] != DBNull.Value && drow["UserDesignation"] != DBNull.Value && drow["UserId"].ToString().Length > 0 && drow["UserDesignation"].ToString().Length > 0 && drow["UserId"].ToString().Split(',').Contains(UserId) && drow["UserDesignation"].ToString().Split(',').Contains(UserId))// Application Valid only to specific user. { ga.Add(new application { applicationName = (drow["ApplicationName"] == DBNull.Value) ? "" : drow["ApplicationName"].ToString(), applicationPackage = (drow["ApplicationPackage"] == DBNull.Value) ? "" : drow["ApplicationPackage"].ToString() }); //linfo.LogFile(enLogType.INFO, "Userid and UserDesignation are not null . drow[UserId] = " + drow["UserId"] + " and Userid=" + UserId + ". drow[UserDesignation] = " + drow["UserDesignation"] + " and Designation = " + Designation + " ApplicationName = " + drow["ApplicationName"] + " ApplicationPackage = " + drow["ApplicationPackage"] + "", "rizwan"); } else if (drow["UserId"] != DBNull.Value && drow["UserDesignation"] == DBNull.Value && drow["UserID"].ToString().Length > 0 && drow["UserID"].ToString().Split(',').Contains(UserId))// Application Valid only to specific user. { ga.Add(new application { applicationName = (drow["ApplicationName"] == DBNull.Value) ? "" : drow["ApplicationName"].ToString(), applicationPackage = (drow["ApplicationPackage"] == DBNull.Value) ? "" : drow["ApplicationPackage"].ToString() }); //linfo.LogFile(enLogType.INFO, "Userid is not null. drow[UserId] = " + drow["UserId"] + " and Userid=" + UserId + ". drow[UserDesignation] = " + drow["UserDesignation"] + " and Designation = " + Designation + " ApplicationName = " + drow["ApplicationName"] + " ApplicationPackage = " + drow["ApplicationPackage"] + "", "rizwan"); } else if (drow["UserDesignation"] != DBNull.Value && drow["UserId"] == DBNull.Value && drow["UserDesignation"].ToString().Length > 0 && drow["UserDesignation"].ToString().Split(',').Contains(Designation)) //application valid only to specific designation (multiple user can come to same designation) { ga.Add(new application { applicationName = (drow["ApplicationName"] == DBNull.Value) ? "" : drow["ApplicationName"].ToString(), applicationPackage = (drow["ApplicationPackage"] == DBNull.Value) ? "" : drow["ApplicationPackage"].ToString() }); //linfo.LogFile(enLogType.INFO, "UserDesignation is not null. drow[UserId] = " + drow["UserId"] + " and Userid=" + UserId + ". drow[UserDesignation] = " + drow["UserDesignation"] + " and Designation = " + Designation + " ApplicationName = " + drow["ApplicationName"] + " ApplicationPackage = " + drow["ApplicationPackage"] + "", "rizwan"); } } } gaa.applications = ga; #region Website list qry = "Select WebsiteName from MDM_AccessibleWebsite"; dtable = databaseHelper.getDataTable(qry); List <weblist> website = new List <weblist>(); foreach (DataRow drow in dtable.Rows) { website.Add(new weblist { WebsiteName = (drow["WebsiteName"] == DBNull.Value) ? "" : drow["WebsiteName"].ToString() }); } gaa.websiteurl = website; #endregion gaa.response = true; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, gaa); qry = "delete from MDM_PushNotification where DeviceID='" + pm.uuid + "' and Command='Get Accessible Apps'"; rcnt = databaseHelper.ExecuteQuery(qry); return(response); } else { ar = new WebApiResponse(); ar.errorCode = "Authentication failed"; ar.response = false; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, ar); return(response); } }
public HttpResponseMessage getConfigurationDetails(postmethod pm) { getConfigurationDetails gc = new getConfigurationDetails(); string qry = "select * from MDM_DeviceMaster where DeviceID='" + pm.uuid + "'"; dr = databaseHelper.getDataReader(qry); if (dr.Read()) { if (!dr.IsClosed) { dr.Close(); } qry = "select ID from MDM_ActivityCode"; dtable = databaseHelper.getDataTable(qry); List <logactivity> La = new List <logactivity>(); foreach (DataRow drow in dtable.Rows) { La.Add(new logactivity { activityCode = drow["ID"].ToString(), isLogActive = true }); } qry = "select LowBatteryLogPer,DeviceTracingFrequency from MDM_ConfigurationPolicy"; dr = databaseHelper.getDataReader(qry); int logperc = 0; int deviceTF = 0; if (dr.Read()) { logperc = (dr["LowBatteryLogPer"] == null) ? 0 : Convert.ToInt32(dr["LowBatteryLogPer"]); deviceTF = (dr["DeviceTracingFrequency"] == null) ? 0 : Convert.ToInt32(dr["DeviceTracingFrequency"]); } gc.batteryLevel = logperc; gc.locationInterval = deviceTF * 60; gc.logactivity = La; gc.response = true; response = Request.CreateResponse(HttpStatusCode.Created, gc); if (!dr.IsClosed) { dr.Close(); } qry = "delete from MDM_PushNotification where DeviceID='" + pm.uuid + "' and Command='Configuration Details'"; rcnt = databaseHelper.ExecuteQuery(qry); return(response); } else { gc.response = false; gc.errorCode = "Unable to Fetch"; response = Request.CreateResponse(HttpStatusCode.Created, gc); return(response); } }
/// <summary> ///Process The Remotely Enabled GPS. A webservice which is called after the gps of the selected ///devices are enabled /// </summary> /// <param name="Ar"></param> /// <returns></returns> public HttpResponseMessage ProcessRemotelyEnableGPS(postmethod pm) { ar = new WebApiResponse(); string qry = "select * from MDM_DeviceMaster where DeviceID='" + pm.uuid + "'"; dr = databaseHelper.getDataReader(qry); try { if (dr.Read()) { if (!dr.IsClosed) dr.Close(); qry = "update MDM_DeviceMaster set GPSStatus=1 where DeviceID='" + pm.uuid + "'"; rcnt = databaseHelper.ExecuteQuery(qry); qry = "delete from MDM_PushNotification where DeviceID='" + pm.uuid + "' and Command like '%Remotely Enable GPS%'"; rcnt = databaseHelper.ExecuteQuery(qry); ar.response = true; response = Request.CreateResponse(HttpStatusCode.Created, ar); return response; } else { ar.errorCode = "Authentication Failed"; ar.response = false; response = Request.CreateResponse(HttpStatusCode.BadRequest, ar); return response; } } catch(Exception ex) { ar.errorCode = "Remote Enable GPS Failed"; ar.response = false; response = Request.CreateResponse(HttpStatusCode.BadRequest, ar); linfo.LogFile(enLogType.EXCEPTION, ex.Message, null); } finally { if (dr != null && !dr.IsClosed) dr.Close(); } return response; }
public HttpResponseMessage getUserActivityCodes(postmethod pm) { getUserActivityCodes ga = new getUserActivityCodes(); try { string qry = "select * from MDM_DeviceMaster where DeviceID='" + pm.uuid + "'"; dr = databaseHelper.getDataReader(qry); if (dr.Read()) { if (!dr.IsClosed) dr.Close(); List<userCodes> uc = new List<userCodes>(); qry = "select ActivityCode,ActivityName,Type from MDM_ActivityCode"; dtable = databaseHelper.getDataTable(qry); foreach (DataRow drow in dtable.Rows) { uc.Add(new userCodes { code = drow["ActivityCode"].ToString(), name = drow["ActivityName"].ToString(), type = drow["Type"].ToString() }); } ga.userCodes = uc; ga.response = true; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, ga); /*qry = "delete from MDM_PushNotification where DeviceID='" + pm.uuid + "'"; rcnt = databaseHelper.ExecuteQuery(qry);*/ return response; } else { ga.response = true; ga.errorCode = "Authentication Failed"; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, ga); return response; } } catch (Exception ex) { linfo.LogFile(enLogType.EXCEPTION, ex.Message, null); } finally { if (dr != null && !dr.IsClosed) dr.Close(); } return null; }
public HttpResponseMessage getAccessibleWebsites(postmethod pm) { getAccessibleWebsites gaw = new getAccessibleWebsites(); List<weblist> wl = new List<weblist>(); try { string qry = "select * from MDM_DeviceMaster where DeviceID='" + pm.uuid + "'"; dr = databaseHelper.getDataReader(qry); if (dr.Read()) { string UserId = dr["UserId"].ToString().ToUpper(); if (!dr.IsClosed) dr.Close(); string Designation = null; qry = "select UserType from AppUsers where UserName='******'"; dr = databaseHelper.getDataReader(qry); if (dr.Read()) { Designation = dr["UserType"].ToString().ToUpper(); } if (!dr.IsClosed) dr.Close(); qry = "Select WebsiteName,UserId,UserDesignation from MDM_AccessibleWebsite"; dtable = databaseHelper.getDataTable(qry); List<weblist> website = new List<weblist>(); foreach (DataRow drow in dtable.Rows) { //linfo.LogFile(enLogType.QUERY, "drow[UserId] = " + drow["UserId"] + " drow[UserDesignation] = "+drow["UserDesignation"]+" UserId = "+UserId+". UserDesignation = "+Designation+"","rizwan"); if (drow["UserId"] == DBNull.Value && drow["UserDesignation"] == DBNull.Value) // Default Application { website.Add(new weblist { WebsiteName = (drow["WebsiteName"] == DBNull.Value) ? "" : drow["WebsiteName"].ToString() }); //linfo.LogFile(enLogType.INFO, "UserID,UserDesignation are null. WebsiteName = " + drow["WebsiteName"] + "", "rizwan"); } else if (drow["UserId"] != DBNull.Value && drow["UserDesignation"] != DBNull.Value && drow["UserId"].ToString().Length > 0 && drow["UserDesignation"].ToString().Length > 0 && drow["UserID"].ToString().Split(',').Contains(UserId) && drow["UserDesignation"].ToString().Split(',').Contains(UserId))// Application Valid only to specific user. { website.Add(new weblist { WebsiteName = (drow["WebsiteName"] == DBNull.Value) ? "" : drow["WebsiteName"].ToString() }); //linfo.LogFile(enLogType.INFO, "UserId and UserDesignation are not null . drow[UserId] = " + drow["UserId"] + " drow[UserDesignation] = " + drow["UserDesignation"] + " UserId = " + UserId + ". UserDesignation = " + Designation + "", "rizwan"); } else if (drow["UserId"] != DBNull.Value && drow["UserDesignation"] == DBNull.Value && drow["UserId"].ToString().Length > 0 && drow["UserId"].ToString().Split(',').Contains(UserId)) // Accessible to specific user. { website.Add(new weblist { WebsiteName = (drow["WebsiteName"] == DBNull.Value) ? "" : drow["WebsiteName"].ToString() }); // linfo.LogFile(enLogType.INFO, "Userid is not null. drow[UserId] = "+drow["UserId"]+" and Userid="+UserId+". drow[UserDesignation] = "+drow["UserDesignation"]+" and Designation = "+Designation+" WebsiteName = " + drow["WebsiteName"] + "", "rizwan"); } else if (drow["UserDesignation"] != DBNull.Value && drow["UserId"] == DBNull.Value && drow["UserDesignation"].ToString().Length > 0 && drow["UserDesignation"].ToString().Contains(Designation))//accessible to user of specific designation { website.Add(new weblist { WebsiteName = (drow["WebsiteName"] == DBNull.Value) ? "" : drow["WebsiteName"].ToString() }); //linfo.LogFile(enLogType.INFO, "UserDesignation is not null. drow[UserId] = " + drow["UserId"] + " and Userid=" + UserId + ". drow[UserDesignation] = " + drow["UserDesignation"] + " and Designation = " + Designation + " WebsiteName = " + drow["WebsiteName"] + "", "rizwan"); } } gaw.websiteurl = website; gaw.response = true; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, gaw); qry = "delete from MDM_PushNotification where DeviceID='" + pm.uuid + "' and Command='Get Accessible Website'"; rcnt = databaseHelper.ExecuteQuery(qry); return response; } else { ar = new WebApiResponse(); ar.errorCode = "Authentication failed"; ar.response = false; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, ar); return response; } } catch(Exception ex) { linfo.LogFile(enLogType.EXCEPTION, "Problem in getAccessibleWebsites function."+ex.Message+"",null); } finally { if (dr != null && !dr.IsClosed) dr.Close(); } return null; }
public HttpResponseMessage getAccessibleApps(postmethod pm) { getConfigurationDetails gc = new getConfigurationDetails(); getAccessibleApps gaa = new getAccessibleApps(); List<application> ga = new List<application>(); string qry = "select * from MDM_DeviceMaster where DeviceID='" + pm.uuid + "'"; dr = databaseHelper.getDataReader(qry); if (dr.Read()) { string UserId = dr["UserId"] != DBNull.Value ? dr["UserId"].ToString().ToUpper() : null; if (!dr.IsClosed) dr.Close(); string Designation = null; qry = "select UserType from AppUsers where UserName='******'"; dr = databaseHelper.getDataReader(qry); if (dr.Read()) { Designation = dr["UserType"].ToString().ToUpper(); } if (!dr.IsClosed) dr.Close(); qry = "select ApplicationName,ApplicationPackage,UserId,UserDesignation from MDM_AccessibleApplication"; dtable = databaseHelper.getDataTable(qry); if (dtable.Rows.Count > 0) { foreach (DataRow drow in dtable.Rows) { //linfo.LogFile(enLogType.QUERY, "drow[UserId] = " + drow["UserId"] + " drow[UserDesignation] = " + drow["UserDesignation"] + " UserId = " + UserId + ". UserDesignation = " + Designation + "", "rizwan"); if (drow["UserId"] == DBNull.Value && drow["UserDesignation"] == DBNull.Value) // Default Application { ga.Add(new application { applicationName = (drow["ApplicationName"] == DBNull.Value) ? "" : drow["ApplicationName"].ToString(), applicationPackage = (drow["ApplicationPackage"] == DBNull.Value) ? "" : drow["ApplicationPackage"].ToString() }); //linfo.LogFile(enLogType.INFO, "UserID,UserDesignation are null. ApplicationName = " + drow["ApplicationName"] + " ApplicationPackage = "+drow["ApplicationPackage"]+"", "rizwan"); } else if (drow["UserId"] != DBNull.Value && drow["UserDesignation"] != DBNull.Value && drow["UserId"].ToString().Length > 0 && drow["UserDesignation"].ToString().Length > 0 && drow["UserId"].ToString().Split(',').Contains(UserId) && drow["UserDesignation"].ToString().Split(',').Contains(UserId))// Application Valid only to specific user. { ga.Add(new application { applicationName = (drow["ApplicationName"] == DBNull.Value) ? "" : drow["ApplicationName"].ToString(), applicationPackage = (drow["ApplicationPackage"] == DBNull.Value) ? "" : drow["ApplicationPackage"].ToString() }); //linfo.LogFile(enLogType.INFO, "Userid and UserDesignation are not null . drow[UserId] = " + drow["UserId"] + " and Userid=" + UserId + ". drow[UserDesignation] = " + drow["UserDesignation"] + " and Designation = " + Designation + " ApplicationName = " + drow["ApplicationName"] + " ApplicationPackage = " + drow["ApplicationPackage"] + "", "rizwan"); } else if (drow["UserId"] != DBNull.Value && drow["UserDesignation"] == DBNull.Value && drow["UserID"].ToString().Length > 0 && drow["UserID"].ToString().Split(',').Contains(UserId))// Application Valid only to specific user. { ga.Add(new application { applicationName = (drow["ApplicationName"] == DBNull.Value) ? "" : drow["ApplicationName"].ToString(), applicationPackage = (drow["ApplicationPackage"] == DBNull.Value) ? "" : drow["ApplicationPackage"].ToString() }); //linfo.LogFile(enLogType.INFO, "Userid is not null. drow[UserId] = " + drow["UserId"] + " and Userid=" + UserId + ". drow[UserDesignation] = " + drow["UserDesignation"] + " and Designation = " + Designation + " ApplicationName = " + drow["ApplicationName"] + " ApplicationPackage = " + drow["ApplicationPackage"] + "", "rizwan"); } else if (drow["UserDesignation"] != DBNull.Value && drow["UserId"] == DBNull.Value && drow["UserDesignation"].ToString().Length > 0 && drow["UserDesignation"].ToString().Split(',').Contains(Designation)) //application valid only to specific designation (multiple user can come to same designation) { ga.Add(new application { applicationName = (drow["ApplicationName"] == DBNull.Value) ? "" : drow["ApplicationName"].ToString(), applicationPackage = (drow["ApplicationPackage"] == DBNull.Value) ? "" : drow["ApplicationPackage"].ToString() }); //linfo.LogFile(enLogType.INFO, "UserDesignation is not null. drow[UserId] = " + drow["UserId"] + " and Userid=" + UserId + ". drow[UserDesignation] = " + drow["UserDesignation"] + " and Designation = " + Designation + " ApplicationName = " + drow["ApplicationName"] + " ApplicationPackage = " + drow["ApplicationPackage"] + "", "rizwan"); } } } gaa.applications = ga; #region Website list qry = "Select WebsiteName from MDM_AccessibleWebsite"; dtable = databaseHelper.getDataTable(qry); List<weblist> website = new List<weblist>(); foreach (DataRow drow in dtable.Rows) { website.Add(new weblist { WebsiteName = (drow["WebsiteName"] == DBNull.Value) ? "" : drow["WebsiteName"].ToString() }); } gaa.websiteurl = website; #endregion gaa.response = true; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, gaa); qry = "delete from MDM_PushNotification where DeviceID='" + pm.uuid + "' and Command='Get Accessible Apps'"; rcnt = databaseHelper.ExecuteQuery(qry); return response; } else { ar = new WebApiResponse(); ar.errorCode = "Authentication failed"; ar.response = false; HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.BadRequest, ar); return response; } }
public HttpResponseMessage getConfigurationDetails(postmethod pm) { getConfigurationDetails gc = new getConfigurationDetails(); string qry = "select * from MDM_DeviceMaster where DeviceID='" + pm.uuid + "'"; dr = databaseHelper.getDataReader(qry); if (dr.Read()) { if (!dr.IsClosed) dr.Close(); qry = "select ID from MDM_ActivityCode"; dtable = databaseHelper.getDataTable(qry); List<logactivity> La = new List<logactivity>(); foreach (DataRow drow in dtable.Rows) { La.Add(new logactivity { activityCode = drow["ID"].ToString(), isLogActive = true }); } qry = "select LowBatteryLogPer,DeviceTracingFrequency from MDM_ConfigurationPolicy"; dr = databaseHelper.getDataReader(qry); int logperc = 0; int deviceTF = 0; if (dr.Read()) { logperc = (dr["LowBatteryLogPer"] == null) ? 0 : Convert.ToInt32(dr["LowBatteryLogPer"]); deviceTF = (dr["DeviceTracingFrequency"] == null) ? 0 : Convert.ToInt32(dr["DeviceTracingFrequency"]); } gc.batteryLevel = logperc; gc.locationInterval = deviceTF * 60; gc.logactivity = La; gc.response = true; response = Request.CreateResponse(HttpStatusCode.Created, gc); if (!dr.IsClosed) dr.Close(); qry = "delete from MDM_PushNotification where DeviceID='" + pm.uuid + "' and Command='Configuration Details'"; rcnt = databaseHelper.ExecuteQuery(qry); return response; } else { gc.response = false; gc.errorCode = "Unable to Fetch"; response = Request.CreateResponse(HttpStatusCode.Created, gc); return response; } }