|
dcof wrote: Should I have the network administrator reboot the test server Why? You are just guessing here. The first thing to do is to investigate what is wrong with your program.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I think you need to learn how to debug applications. Deploy debug builds to the servers, and use remote debugging to hook up to the application you think is at fault. Actually step over the code and see what's going on, rather than expecting us to throw random guesses as to what the problem could be. Deploy and pray is not a valid testing strategy.
|
|
|
|
|
Hi Everyone,
I am trying to create a web page that would allow users to create Citirx session for their needs. I was looking for any article or help available within the forum but I ended up hitting a brick wall. could someone guide me to the right article or any help with regrds to this?
Thanks in advance,
Philip
|
|
|
|
|
Arun Philip Reynolds wrote: I am trying to create a web page that would allow users to create Citirx session for their needs.
Doesn't Citrix offer their own (secured) webpage to host the applications if you install their server?
Arun Philip Reynolds wrote: <layer> I was looking for any article or help available within the forum but I ended up hitting a brick wall.
There will not be any articles on the subject; it's not a general request. Your best bet is to hit the Citrix-forums, and see if you can get support from their staff. I have no idea how they integrate the 'ica-files' into the dashboard, and I'm pretty sure that it depends on the logged in user (and his rights) which will be shown. So the real question here would be whether this is at all possible with the current Citrix-environment, or whether they closed that part out of security.
Bastard Programmer from Hell
if you can't read my code, try converting it here[^]
|
|
|
|
|
ok, I Know about Enum.GetValues() , but what i want to know if is possible is to do a foreach through the values of a enum such as i can do the following:
foreach(var value in enum){
list.Add(new SelectListItem(){
Text = value.ToString(),
Value = ((int)value).ToString()
});
}
say that i have the following enum:
enum States{
Running,
Stoped,
Paused
}
the only way to accomplish what i described above is through the use of Enum.GetValues() and Enum.GetNames() ? or there is some syntax sugar?
I'm asking more out of curiosity than anything else
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
Nope. No syntactic sugar. Since an Enum is not enumerable, you can't just specify the enum type itself. You must get the enum values in an array or other IEnumerable implementor first.
|
|
|
|
|
and the only way to do this and maintain the type of the enum is adding the values manually to the list...
I was thinking of someway to call a method with every possibly constant of a enum, but the only thing i got so far is something like:
foreach(int value in Enum.GetValues(typeof(MyEnum))){
MyEnum e = (MyEnum)value;
...
}
or if you prefer the linq way...
((IEnumerable<int>)Enum.GetValues(typeof(MyEnum))).Select(x => (MyEnum)x);
the only thing i don't understand is why i can't call the Select method directly on the return of Enum.GetValues() , maybe because Array implements the non-generic IEnumerable interface?
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
Sentenryu wrote: the only thing i don't understand is why i can't call the Select method directly
on the return of Enum.GetValues() , maybe because Array
implements the non-generic IEnumerable interface?
LINQ works on the IQueryable interface, which array's don't support.
Arrays support the following interfaces:
ICloneable, IList, ICollection, IEnumerable, IStructuralComparable and IStructuralEquatable
The .Select extension works on any IEnumerable, including arrays, so I think your .Select example is a bit flawed. I don't know what you're doing, but...
|
|
|
|
|
First of all, i forgot to say thanks for your answer, so Thanks!
In the case i'm just getting a IEnumerable<SelectListItem> with the values of a enum to display as radiobuttons, the actual code (with the excuse of having names in portuguese) is this:
ViewBag.ApetiteOptions = ((IEnumerable<int>)Enum.GetValues(typeof(Apetite))).Select(x => new SelectListItem() {
Text = ((Apetite)x).ToString(),
Value = x.ToString()
});
Visual Studio (2012) gives me an error when I try to use the select method directly on the return type of the
Enum.GetValues() , I guess it's because this method returns a instace of Array (the base class), and not a instance of int[] .
int[] implements IEnumerable<int> , while Array implements IEnumerable , the Select method Expects IEnumerable<TSource> ...
while writting this post, i updated this bit of code to this:
ViewBag.ApetiteOptions = Enum.GetValues(typeof(Apetite)).OfType<int>().Select(x => new SelectListItem() {
Text = ((Apetite)x).ToString(),
Value = x.ToString()
});
I'm a little bit more happy now
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
|
See my answer below, all your LINQ example is missing is a call to
OfType<States>()
|
|
|
|
|
Dave Kreskowiak wrote: LINQ works on the IQueryable interface, which array's don't support.
No, LINQ to SQL / EF works on IQueryable, most of Linq2Objects works on IEnumerable<t>
|
|
|
|
|
Crap. That's what I get with 4 hours of sleep...
|
|
|
|
|
GetValues() does return an enumerable list of the actual enums, so your original code works with VERY few changes:
foreach(var value in Enum.GetValues(typeof(States))){
list.Add(new SelectListItem(){
Text = value.ToString(),
Value = ((int)value).ToString()
});
}
Live example: http://rextester.com/PWOX45762[^]
You can also use LINQ if you want, but that call to Enum.GetValues() returns an Array, so you neeed to call OfType<states>() to coerce it to a generic IEnumerable<states>
var list = Enum.GetValues(typeof(States))
.OfType<States>()
.Select(i => .... );
Live example: http://rextester.com/TRHMMB31708[^]
|
|
|
|
|
Wow, I always thought it returned a Array containing int's, this will really simplify the things! thanks a lot!
I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)
|
|
|
|
|
Hi i'm working out my registration using a three tiered architecture and i'm trying to send the random userid which i got from registering in the aspx page to my custom table which i created. Here is the error i get:
Error 1 'DataClass.ConnectionClass' does not contain a definition for 'ProviderUserKey' and no extension method 'ProviderUserKey' accepting a first argument of type 'DataClass.ConnectionClass' could be found (are you missing a using directive or an assembly reference? Does anyone know how to correct it
here is my presentation layer or the UI layer
using System;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.ApplicationServices;
using System.Data;
using System.Data.SqlClient;
using DataClass;
public partial class Account_Register : System.Web.UI.Page
{
ConnectionClass newobj = new ConnectionClass();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void CreateUserButton_Click(object sender, EventArgs e)
{
string F_Name = txtFirstName.Text;
string L_Name = txtLastName.Text;
string Address = txtAddress.Text;
string City = txtCity.Text;
string State = txtState.Text;
string Zip = txtZipCode.Text;
string DOB = txtDOB.Text;
string Phone = txtPhone.Text;
string email = txtEmail.Text;
string User_Name = txtUserName.Text;
string Password = txtPassword.Text;
string PasswordQuestion = txtPasswordQuestion.Text;
string PasswordAnswer = txtPasswordAnswer.Text;
MembershipCreateStatus createStatus;
MembershipUser newUser = Membership.CreateUser(txtUserName.Text, txtPassword.Text, txtEmail.Text, txtPasswordQuestion.Text, txtPasswordAnswer.Text, true, out createStatus);
switch (createStatus)
{
case MembershipCreateStatus.Success:
string UserId = newUser.ProviderUserKey.ToString();
lblCreateAccount.Text = "The user account was successfully created!";
break;
case MembershipCreateStatus.DuplicateUserName:
lblCreateAccount.Text = "There already exists a user with this username.";
break;
case MembershipCreateStatus.DuplicateEmail:
lblCreateAccount.Text = "There already exists a user with this email address.";
break;
case MembershipCreateStatus.InvalidEmail:
lblCreateAccount.Text = "There email address you provided in invalid.";
break;
case MembershipCreateStatus.InvalidAnswer:
lblCreateAccount.Text = "There security answer was invalid.";
break;
case MembershipCreateStatus.InvalidPassword:
lblCreateAccount.Text = "The password you provided is invalid. It must be seven characters long and have at least one non-alphanumeric character.";
break;
default:
lblCreateAccount.Text = "There was an unknown error; the user account was NOT created.";
break;
}
string userid;
if (newUser != null)
{
userid = newobj.ProviderUserKey.ToString();
newobj.Insert(userid, F_Name, L_Name, Address, City, State, Zip, DOB, Phone,
email, User_Name, Password, PasswordQuestion, PasswordAnswer);
}
}
}
Here is my Data Layer
using System;
using System.Data;
using System.Configuration;
using System.Collections.Specialized;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace DataClass
{
public class ConnectionClass
{
string connStr = ConfigurationManager.ConnectionStrings["aspnetdbConnectionString"].ToString();
public ConnectionClass()
{
}
public int Insert (string U_ID, string F_Name, string L_Name, string Address, string City, string State, string Zip, string DOB, string Phone,
string email, string User_Name, string Password, string PasswordQuestion, string PasswordAnswer)
{
SqlConnection con = new SqlConnection(connStr);
con.Open();
SqlCommand cmd = new SqlCommand("user_membership", con);
cmd.CommandType = CommandType.StoredProcedure;
try {
cmd.Parameters.Add("@UserId", SqlDbType.UniqueIdentifier).Value = new Guid(U_ID);
cmd.Parameters.AddWithValue("@F_Name", F_Name);
cmd.Parameters.AddWithValue("@L_Name", L_Name);
cmd.Parameters.AddWithValue("@Address", Address);
cmd.Parameters.AddWithValue("@City", City);
cmd.Parameters.AddWithValue("@State", State);
cmd.Parameters.AddWithValue("@Zip", Zip);
cmd.Parameters.AddWithValue("@DOB", DOB);
cmd.Parameters.AddWithValue("@Phone", Phone);
cmd.Parameters.AddWithValue("@email", email);
cmd.Parameters.AddWithValue("@User_Name", User_Name);
cmd.Parameters.AddWithValue("@Password", Password);
cmd.Parameters.AddWithValue("@PasswordQuestion", PasswordQuestion);
cmd.Parameters.AddWithValue("@PasswordAnswer", PasswordAnswer);
return cmd.ExecuteNonQuery();
}
catch { throw; }
finally
{
con.Dispose();
con.Close();
cmd.Dispose();
}
}
public DataTable Load(string F_Name, string L_Name, string Address, string City, string State, string Zip, string DOB, string Phone,
string email, string User_Name, string Password, string PasswordQuestion, string PasswordAnswer)
{
SqlConnection conn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("user_membership", conn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.SelectCommand.CommandType = CommandType.StoredProcedure;
DataSet ds = new DataSet();
try
{
cmd.Parameters.AddWithValue("@F_Name", F_Name);
cmd.Parameters.AddWithValue("@L_Name", L_Name);
cmd.Parameters.AddWithValue("@Address", Address);
cmd.Parameters.AddWithValue("@City", City);
cmd.Parameters.AddWithValue("@State", State);
cmd.Parameters.AddWithValue("@Zip", Zip);
cmd.Parameters.AddWithValue("@DOB", DOB);
cmd.Parameters.AddWithValue("@Phone", Phone);
cmd.Parameters.AddWithValue("@email", email);
cmd.Parameters.AddWithValue("@User_Name", User_Name);
cmd.Parameters.AddWithValue("@Password", Password);
cmd.Parameters.AddWithValue("@PasswordQuestion", PasswordQuestion);
cmd.Parameters.AddWithValue("@PasswordAnswer", PasswordAnswer);
da.Fill(ds);
return ds.Tables[0];
}
catch
{
throw;
}
finally
{
ds.Dispose();
da.Dispose();
conn.Close();
conn.Dispose();
}
}
}
}
|
|
|
|
|
Ahem:
ConnectionClass newobj = new ConnectionClass();
And
userid = newobj.ProviderUserKey.ToString();
Did you mean:
userid = newUser.ProviderUserKey.ToString();
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
Thanks for the response. I can compile it now.
|
|
|
|
|
Hi,
I had a database in access I want to connect through connection string where shall I write the connection string so that it is written once & can be use at different places through out the project.
Second I want to get data in a combobox using that same connection & using a select query at the time of form load in C#
Please suggest .
THanks
|
|
|
|
|
Jaleel Ahmed wrote: where shall I write the connection string so that it is written once & can be use at different places through out the project
Generally it should be in your app.config file.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Jaleel Ahmed wrote: Second I want to get data in a combobox using that same connection & using a select query at the time of form load in C#
Fire the query in the Form_Load event.
|
|
|
|
|
Hello,
You can use below code to fill Combobox on your form load even.
private void Form1_Load(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt = FillDT();
this.cmbTempControl.DataSource = dt;
this.cmbTempControl.ValueMember = "ID";
this.cmbTempControl.DisplayMember = "Name";
}
protected DataTable FillDataTable()
{
DataTable dtTemp = new DataTable();
return dtTemp;
}
Thanks
KiranKumar Roy
|
|
|
|
|
Hi guys, there is a project im working on for a client and im stuck on how to calculate progressive tax based on the income of a particular employee's salary, im not sure about my approach, i wrote a class library in c-sharp for easy portability. Here is the sample code or the library.
namespace TaxCalculator
{
public class ProgressiveTax
{
readonly double limit1 = 0,
limit2 = 10164, limit3 = 10165,
limit4 = 19740, limit5 = 19741,
limit6 = 29316, limit7 = 29317,
limit8 = 38892;
private double taxedAmount = 0;
private double ComputeTax(double grossPay)
{
if ((grossPay >= limit1) && (grossPay <= limit2))
{
taxedAmount = grossPay * 0.1;
return taxedAmount;
}
else if ((grossPay >= limit3) && (grossPay <= limit4))
{
taxedAmount = ComputeTax(limit2) + ((grossPay - limit2) * 0.15);
return taxedAmount;
}
else if ((grossPay >= limit5) && (grossPay <= limit6))
{
taxedAmount = ComputeTax(limit4) + ((grossPay - limit4) * 0.2);
return taxedAmount;
}
else if ((grossPay >= limit7) && (grossPay <= limit8))
{
taxedAmount = ComputeTax(limit6) + ((grossPay - limit6) * 0.25);
return taxedAmount;
}
else if ((grossPay > limit8))
{
taxedAmount = ComputeTax(limit8) + ((grossPay - limit8) * 0.3);
return taxedAmount;
}
return 0;
}
public double ComputeNet(double netSalary = 0)
{
netSalary = netSalary - ComputeTax(netSalary);
return netSalary;
}
public double GetTax(double salaryAmount)
{
salaryAmount = ComputeTax(salaryAmount);
return salaryAmount;
}
}
}
|
|
|
|
|
What happens if the tax rates or limits change? The data should be stored in a table somewhere, and read in at run time - you would then store it in a class or structure like this:
public class TaxRates
{
public double UpperLimit;
public double LowerLimit;
public double Deductible;
public double CalcRate;
} Populate a list of these from your table and then all you need do is iterate looking for the value where the value is between lower and upper and then use this to form the basis of your calculation. Also, you should note that your sample code has holes in it. What happens if someone earns 10164.01?
|
|
|
|
|
Pete O'Hanlon wrote: What happens if the tax rates or limits change? The data should be stored in a table somewhere, and read in at run time
I agree. Hard coded values in programs should always be kept to a minimum.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|