Sunday, 15 September 2013

Run .NET 2.0 application in Windows 8 x64

Run .NET 2.0 application in Windows 8 x64

i make program in visual studio 2005 and NeFramWork 2.0 . this program run
in windows 7 64 bit ,but not in windows 8 64 bit although i run the as
administrator so please help me

Saturday, 14 September 2013

C# - How to get/set an object's property value without using Reflection

C# - How to get/set an object's property value without using Reflection

I need to be able to store a reference to an object's property in order to
read/write it later, ideally without using reflection. I'm also open to a
design pattern that works too, but performance is paramount as my
application will be making millions of calls to "run" on various "Parent"
classes. The code template below should explain what I'm trying to do.
Also, one more requirement, I'd like to keep it such that the variables I
am "requiring" are object properties of the Child class, and not data
structures stored in some list, for example.
Thank you.
class requiredAttribute : Attribute
{
}
abstract class Parent
{
abstract protected void _run();
public Parent() {
// This can do whatever set-up is necessary in order to make the
below run() call
// not need reflection.
/* What code goes here? */
}
public void run() {
// This code should reset all 'required' properties to null.
/* What goes here? */
_run();
// This code needs to ensure any required property is now not null.
// If it finds a null one, it should throw.
/* What goes here? */
}
}
class Child : Parent
{
[required]
protected object value1;
[required]
protected object value2;
// not required..
protected object value3;
protected void _run() {
// This must set all 'required' properties' values, otherwise the
Parent should throw.
value1 = "some value";
value2 = "some other value";
}
}

Parsing .csv file into 2d array

Parsing .csv file into 2d array

I'm trying to parse a csv file into a 2d array in C#. I'm having a very
strang issue, here is my code:
string filePath = @"C:\Users\Matt\Desktop\Eve Spread
Sheet\Auto-Manufacture.csv";
StreamReader sr = new StreamReader(filePath);
data = null;
int Row = 0;
while (!sr.EndOfStream)
{
string[] Line = sr.ReadLine().Split(',');
if (Row == 0)
{
data = new string[Line.Length, Line.Length];
}
for (int column = 0; column < Line.Length; column++)
{
data[Row, column] = Line[column];
}
Row++;
Console.WriteLine(Row);
}
My .csv file has 87 rows, but there is a strange issue in the execution
where it will read the first 15 rows into the data array exactly as
expected but when it gets down to the data[Row, column] = Line[column];
line for the 16th time it seems to just break out of the entire
loop(without meeting the sr.EndOfStream condition) and not read any more
data into the data array. Can anyone explain what might be happeneing?

Facebook Open Graph publish custom story only visible on "activity log"

Facebook Open Graph publish custom story only visible on "activity log"

I use Facebook Open Graph to publish custom story in my android app. I'v
created the story in the Facebook application console, with the custom
object and action, submitted it of review with "Explicit share" and got
approved. My problem is that I'm able to create the object, and create an
action using this object, but I only see the story on my activity log (and
also under "recent activities" on timeline) but no one else sees the story
and it does not look as I've created it. I use the "Explicitly Shared"
fled in the action, but nothing is shown. can someone help

Getting the value from MySQL to check radio buttons generates a notice

Getting the value from MySQL to check radio buttons generates a notice

I'm trying to set the "checked" status of a radio button based on the
value from the MySQL database. The main purpose of the code is to be a
"edit user profile data" script. I managed to get all information from the
database and everything gets edited as it should if the user choses to but
I can't seem to make the radio buttons work. I get the following message:
Notice: Use of undefined constant Male - assumed 'Male' in
C:\xampp\htdocs\Signup\user_panel.php on line 57
I checked SO for this notice but I couldn't find anything related to radio
buttons AND the notice.
This is the code:
<form action="includes/user_panel.php" method="POST">
<table>
<tr>
<td><label for="email"> E-mail </label></td>
<td><input type="email" name="email" id="email"
value="<?php echo "{$fetch['email']}"; ?>"></td>
</tr>
<tr>
<td><label for="first_name"> First name </label></td>
<td><input type="text" name="first_name"
id="first_name" value="<?php echo
"{$fetch['first_name']}"; ?>"></td>
</tr>
<tr>
<td><label for="last_name"> Last name </label></td>
<td><input type="text" name="last_name"
id="last_name" value="<?php echo
"{$fetch['last_name']}"; ?>"></td>
</tr>
<tr>
<td><label for="birthday"> Birthday </label></td>
<td><input type="date" name="birthday"
id="birthday" value="<?php echo
"{$fetch['birthday']}"; ?>"></td>
</tr>
<tr>
<td><label for="sex"> Sex </label></td>
<?php
if ($fetch['birthday'] = Male)
{
echo "<td><input type='radio' name='sex'
value='male' id='sex' checked> Male <input
type='radio' name='sex' value='female'
id='sex'> Female </td>";
}
else
{
echo "<td><input type='radio' name='sex'
value='male' id='sex'> Male <input
type='radio' name='sex' value='female'
id='sex' checked> Female </td>";
}
?>
</tr>
</table>
</br>
<input type="submit" name="edit_user" value="Edit"
class="button_1">
<input type="hidden" name="edit_user_data">
</form>
Additional information:
$initial_email = $_SESSION['email'];
$username = $_SESSION['username'];
$query_user_panel="SELECT * FROM users WHERE email = '$initial_email' OR
username= '$username'";
$result_user_panel=mysql_query($query_user_panel) or die (mysql_error());
$fetch = mysql_fetch_assoc($result_user_panel)
Line 57 is the one with the "if".
Scroll down the code and you'll see where the sex should get checked. I
tried with a "if" but that generates me the notice that I wrote.
I know that MySQL is depreciated and I should use MySQLi. If you have the
time please check this question as well: Simplest MySQL to MySQLi
transition
Thank you very much and please let me know if I need to edit my post or
provide with additional data.

What are the performance considerations if using $_SESSION in cakephp inspite of $this->Session

What are the performance considerations if using $_SESSION in cakephp
inspite of $this->Session

What are the performance considerations in CakePHP of directly accessing
$_SESSION['variableName'] instead of calling
$this->Session->read('variableName') to access session variables?

i ssue in avoiding user from entering empty string in ajax post

i ssue in avoiding user from entering empty string in ajax post

I have a jquery ajax post and when a user wirte and press enter in a
textbox this ajax triggers and show the value of text box in a <pre> html
element. http://jsfiddle.net/LQg7W/2133/ obviuosly this jsfiddledoes not
show anything because I sis not put the ajax post inside it. but when the
user writes Nothing and press enter this ajax is triggered and return
something. but how can I catch the empty strings from user?
This is located in my view:
if(e.keyCode == 13) {
var currentLine = $('#terminal').text();
var inputData = $(e.currentTarget).val();
$('#terminal').text(currentLine + "\r\n" + inputData +
"\r\n"); //show the current and previous value
$("#textInput").val(" $> ");
AjaxPost(inputData);
}
and this ajax post is in model:
AjaxPost : function(dataAttribute, view, cacheId) {
console.log(cacheId);
var that = this;
if(dataAttribute === ""){
view.showMessage( " " , true);
}
$.ajax({
type : "POST",
url : "/api/user" ,
datatype : "application/json",
contentType: " text/plain",
data : dataAttribute,
success : function(data) {
console.log(data);
},
error : function(error) {
},
my problem is that my input data has default value of "$>" so I cannot
check this condition if (inputdata === "" ) because it is always full!!
Have any idea?