Click here to Skip to main content
       

.NET Framework

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
GeneralRe: Customer Hacking System TimememberKlockness18 Dec '12 - 10:25 
I'm just using
 
DateTime.Now.ToUniversalTime()

AnswerRe: Customer Hacking System TimememberRichard Deeming18 Dec '12 - 7:32 
Have a look at: http://www.nirsoft.net/utils/run_as_date.html[^]
 
It hooks the API calls to read the system clock and returns a specified date/time to a particular program.



"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer


GeneralRe: Customer Hacking System TimememberKlockness18 Dec '12 - 10:26 
This is blocked at work but I'll take a look at it when I'm at home. Thanks,
QuestionCan only book for yourself and not other users?memberxnaLearner17 Dec '12 - 1:26 
At the min, any user can book a holiday for ay employee,
 
I have added [Authorization] to the controllers, and @if (User.Identity.IsAuthenticated)
 
in the layout so only logged in users can view the pages. But how can I go about only allowing users to book a holiday for them selves
 
something like if loggedInUserID(is this assigned automatically when a user is created?) =currentPersoID, although this is only a guess and I would prob have to assign the same loggedInUserID to personID.
 

 
any suggestions?
 
Thanks
AnswerRe: Can only book for yourself and not other users?mvpRichard MacCutchan17 Dec '12 - 3:27 
This is still not the ASP.NET forum.
One of these days I'm going to think of a really clever signature.

Questionusing [Authorize] mvc3memberxnaLearner17 Dec '12 - 1:02 
So at the top of my controllers i've added in [Authorize], So far so good only logged in users can access these pages (Person and Holiday)
 
However the tabs in the homeController which navigate the users to these pages are still displayed...coming from the layout.cs
 
      <li>@Html.ActionLink("Home", "Index", "Home")</li>
            <li>@Html.ActionLink("About", "About", "Home")</li>
            <li>@Html.ActionLink("Person", "Index", "Person")</li>
            <li>@Html.ActionLink("Holidays", "Index", "Holidays")</li>
How can I only get these tabs to display if a user is logged in.
 
I have tried the approach of adding in a bool in the AccountController.cs
else
                    {
                        loggedIn = true;
                        return RedirectToAction("Index", "Home");
                    }
                }
                else
                {
                    loggedIn = false;
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
but then how do I access this from the layout.cs?
 
Is this the correct approach. Please advise. thanks
QuestionRe: using [Authorize] mvc3memberEddy Vluggen17 Dec '12 - 1:08 
Don't you think this would be more appropriate in the ASP.NET forum?
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]
They hate us for our freedom![^]

AnswerRe: using [Authorize] mvc3memberxnaLearner17 Dec '12 - 1:25 
ok thanks
QuestionAdding a flash webcam photo capturememberlhsunshine16 Dec '12 - 19:33 
My website is using asp.net with c#. Recently i am adding a new function by adding a flash webcam photo capture. In local it can function well, it can capture photo, save into database, and display the photo. However, after deploy it cannot funtion well on my server. The webcam still can function. But it cannot convert and save that photo into database. I suspect the actionscript cannot fire... Do i need to install any flash player into my server? Anybody can help me? Pls help... Urgent. TQ
 
THIS IS MY REFERENCE LINK...
http://www.dotnetspider.com/resources/38150-Capture-save-images-from-Web-camera.aspx[^]
AnswerRe: Adding a flash webcam photo capturememberEddy Vluggen17 Dec '12 - 0:42 
Does your database allow remote connections? Most hosted solutions have a firewall, preventing it.
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]
They hate us for our freedom![^]

GeneralRe: Adding a flash webcam photo capturememberlhsunshine17 Dec '12 - 1:55 
Yes, i have opened all the access... Any other idea? TQ
AnswerRe: Adding a flash webcam photo capturememberEddy Vluggen17 Dec '12 - 2:01 
lhsunshine wrote:
Yes, i have opened all the access...

I'd doubt that. Create a small test-page from where you open a connection to the database, and try with that.
 
Are you using a hosted solution, or is this your "own" server?
 
What does the page do? Does it show at all? Does it show an error? What error?
 
As a side-remark; Every members' question is equally urgent.
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]
They hate us for our freedom![^]

GeneralRe: Adding a flash webcam photo capturememberlhsunshine17 Dec '12 - 2:07 
It does not show any error. When i click the "capture" button photo, the photo is captured. But does not save into the database...
QuestionRe: Adding a flash webcam photo capturememberEddy Vluggen17 Dec '12 - 2:09 
Paste your database-save-code here, and we'll have a look. I assume you added an exception-handler to the example from the tutorial?
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]
They hate us for our freedom![^]

AnswerRe: Adding a flash webcam photo capturememberlhsunshine17 Dec '12 - 13:49 
Sorry for late reply. This is my code. TQ
 

Sorry for late reply. This is my code. TQ

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Collections.Generic;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Data.SqlClient;
using Pic.User;
using Pic.Action;
using Pic.Common;
 
namespace Pic
{
public partial class ImageConversions : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
clsAction action = new clsAction();
 
DateTime thisDay = DateTime.Now;
string time = thisDay.ToString("yyyyMMMd HHmmss");
string imgMember = time + ".jpg";
string imgPath = "MemberPicture/" + imgMember;
 

txtAcc.Text = Session["Cust"].ToString();
lblGeoID.Text = Session["geoID"].ToString();
//lblMNo.Text = Session["memberNo"].ToString();
//lblMName.Text = Session["memberName"].ToString();
lblMember.Text = Session["Member"].ToString();
//string memberID = Convert.ToInt32(txtAcc.Text);
int memberGeoID = Convert.ToInt32(lblGeoID.Text);
 
CreatePhoto();
 
action.ExecuteInsert(imgMember, imgPath, txtAcc.Text, memberGeoID,lblMember.Text);
 

}
 
void CreatePhoto()
{
try
{
string strPhoto = Request.Form["imageData"]; //Get the image from flash file
byte[] photo = Convert.FromBase64String(strPhoto);
 
DateTime thisDay = DateTime.Now;
string time = thisDay.ToString("yyyyMMMd HHmmss");
 
//get the file name of the posted image
string imgMember = time + ".jpg";
 
//sets the image path
string imgPath = "MemberPicture/" + imgMember;
 
//then save it to the Folder
FileStream fs = new FileStream(imgPath, FileMode.OpenOrCreate, FileAccess.Write);
 
BinaryWriter br = new BinaryWriter(fs);
br.Write(photo);
br.Flush();
br.Close();
fs.Close();
 
}
catch (Exception Ex)
{
throw;
}
}
}
}
//=======================================================================================================
public void ExecuteInsert(string member, string path, string acNo, int memberGeoID, string memberNo)
{
try
{
clsDB db = new clsDB();
 
clsUser user = new clsUser();
 

SqlParameter[] sqlParams = {
new SqlParameter("@ImageMember", member),
new SqlParameter("@ImgPath", path),
new SqlParameter("@MID", acNo),
new SqlParameter("@M_GeoID", memberGeoID),
//new SqlParameter("@MNo", MNo),
//new SqlParameter("@MName", MName),
new SqlParameter("@memberNo", memberNo)
};
 
db.ExecuteStoredProcedure("spAddMemberPic", sqlParams);
 
}
catch (Exception)
{
throw;
}
}
AnswerRe: Adding a flash webcam photo capturememberEddy Vluggen18 Dec '12 - 2:01 
You'll have to debug the CreatePhoto method, and verify the contents of the variables. Also verify that the user has the correct access-rights to that folder.
 
A few remarks on the code;
  • It'd be advisable to dispose objects that support it. Ideally, you'd wrap it with a using-argument, so that it gets disposed as soon as we're out of scope. E.g.;
    using (var fs = new FileStream(args here))
    {
      //place where you can access the stream
    }
  • Catching an exception just to rethrow it, is technically the same as not catching the exception in the first place. If there's an exception, write it to the screen, a logfile, anything.
  • Concatenating paths would best be done using Path.Combine.
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]
They hate us for our freedom![^]

GeneralRe: Adding a flash webcam photo capturememberlhsunshine18 Dec '12 - 18:03 
//I have modified my code to become like this.
//Logfile does not show any error message.
//Still cannot function well in server but can function well in local only.
 
namespace Pic
{
public partial class ImageConversions : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
clsAction action = new clsAction();
 
DateTime thisDay = DateTime.Now;
string time = thisDay.ToString("yyyyMMMd HHmmss");
string imgMember = time + ".jpg";
string fName="MemberPicture/";
string imgPath = Path.Combine(fName,imgMember);
 
try
{
txtAcc.Text = Session["Cust"].ToString();
lblGeoID.Text = Session["geoID"].ToString();
lblMember.Text = Session["Member"].ToString();
int memberGeoID = Convert.ToInt32(lblGeoID.Text);
 
CreatePhoto();
 
action.ExecuteInsert(imgMember, imgPath, txtAcc.Text, memberGeoID, lblMember.Text);
lblMsg.Text = "Success";
}
catch (Exception ex)
{
FileInfo txt = new FileInfo("Log.txt");
StreamWriter sw = txt.AppendText();
sw.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss tt") + " " + "Line No:" + ex.Source + " Message " + ex.Message);
sw.WriteLine(" ");
sw.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss tt") + " " + ex.StackTrace);
sw.WriteLine(" ");
sw.WriteLine(" ");
sw.Close();
}
 

}
 
void CreatePhoto()
{
try
{
string strPhoto = Request.Form["imageData"]; //Get the image from flash file
byte[] photo = Convert.FromBase64String(strPhoto);
 
DateTime thisDay = DateTime.Now;
string time = thisDay.ToString("yyyyMMMd HHmmss");
 
//get the file name of the posted image
string imgMember = time + ".jpg";
string fName = "MemberPicture/";
string imgPath = Path.Combine(fName, imgMember);
 
string fileName = Path.Combine(fName,imgPath);
using (var fs = new FileStream(imgPath, FileMode.OpenOrCreate, FileAccess.Write))
{
// read the file
BinaryWriter br = new BinaryWriter(fs);
br.Write(photo);
br.Flush();
br.Close();
fs.Close();
}
}
catch (Exception ex)
{
FileInfo txt = new FileInfo("Log.txt");
StreamWriter sw = txt.AppendText();
sw.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss tt") + " " + "Line No:" + ex.Source + " Message " + ex.Message);
sw.WriteLine(" ");
sw.WriteLine(DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss tt") + " " + ex.StackTrace);
sw.WriteLine(" ");
sw.WriteLine(" ");
sw.Close();
}
}
}
}
GeneralRe: Adding a flash webcam photo capturememberlhsunshine18 Dec '12 - 19:18 
I used firebug. It shows "500 Internal Server Error".
GeneralRe: Adding a flash webcam photo capturememberEddy Vluggen18 Dec '12 - 20:40 
Good morning Smile | :)
 
lhsunshine wrote:
500 Internal Server Error

That's a generic message, saying something went wrong during execution of the code on the server. There'll be an exception probably, but that should have shown in your text-file now. Unless, the user isn't allowed to write there. Perhaps it's easier to display the message using Response.Write. I'm not an ASP-programmer, but the code "looks" like it should run.
 
I'm guessing that something goes wrong either by decoding the picture from Base64 (try and save the raw data, might be a nice clue for debugging) or the users' rights. Easy way to check the latter is by creating a small test-page that writes a line of text to that location.
Bastard Programmer from Hell Suspicious | :suss:
If you can't read my code, try converting it here[^]
They hate us for our freedom![^]

GeneralRe: Adding a flash webcam photo capturememberlhsunshine19 Dec '12 - 2:28 
HAHA... Overhere now is night time... Smile | :)
 
My Log.txt file is worked. I have try to input other error. Log.txt has an error message. But now is no error shown. I think it never go to this page. This page is fire from the button "Capture" in flash. I suspect the action script in flash do not fire.
QuestionSplitting a urlmemberEl daniel14 Dec '12 - 22:02 
I have this link: iPad/Tablet/eBook Accessories on my page then when requesting it I am getting a server error application but I have found the issue but I am stack on how to correct it.Then my kestion is How to split this link : iPad/Tablet/eBook Accessories into something like this iPad-Tablet-eBook.aspx when requesting it,in other word I want it to be like this iPad-Tablet-eBook.aspx in url because I am splitting like this
else if (HttpContext.Current.Request.Url.ToString().ToLower().Contains("/product/"))
               {
                   string[] url = HttpContext.Current.Request.Url.ToString().Split(new string[] { "/Product/" }, StringSplitOptions.None);
 
                   url = url[url.Length - 1].Split('/');

Questionpulling across value from list to display in viewmemberxnaLearner14 Dec '12 - 5:58 
Hey Guys...so trying to get my head around MVC
 
My Index for holiday page is linked to the model
 
@model HolidayBookingApp.Models.HolidayList
Im trying to pull the value of Holidays remaining from the HList4DD (HolidayListForDropDown) which is coming from the HolidayList.cs page.
 
I can get it through...
 
@foreach (var item in Model.HList4DD)
{
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.PersonId)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.HolidayDate)
        </td>
        <td>
        @Html.DisplayFor(modelItem => item.Person.HolidaysRemaining)
        </td>
Although this displays the holidays remaining for every holiday booked. So if 20 holidays is the limit (4 booked and 16 remaining) this will produce a list of the dates of holidays booked i.e 4 records stating which date is booked, but it will show the '16' holidays remaining 4 times as well.
 
Yes, this is because it is inside the for loop but I tried to display it on its own and it didnt work
 
@Html.DisplayFor(model => model.HList4DD.//what do i add here?
Also tried to add
 
Person person = new Person();
            currentHolidaysRemaining = person.HolidaysRemaining; 
to the HolidayList. cs then in the view do
@Html.DisplayFor(model => model.currentHolidaysRemaining)
but its not pulling across the correct value, just returning 0
 
please advise....thanks
AnswerRe: pulling across value from list to display in viewmemberxnaLearner14 Dec '12 - 6:49 
Im now using
bool isFirst = true;
@int remainingHolidays = 0;
 
@foreach (var item in Model.HList4DD)
{
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.PersonId)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.HolidayDate)
        </td>
   
 
   if (isFirst)
   {
      remainingHolidays = item.Person.HolidaysRemaining;
      isFirst = false;
   }
        
        <td>
            @Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
            @Html.ActionLink("Details", "Details", new { id = item.Id }) |
            @Html.ActionLink("Delete", "Delete", new { id = item.Id })
        </td>
    </tr>}
        
    
    <tr>
      <div class="editor-label">
         @*   @Html.LabelFor(model => model.PList4DD, "Person")*@
        </div>
 
        <div class="editor-field">
       
             <form action ="/Holidays/Index" id="some" method="post"> 
 
            @* *WORKING VERSION**@ @Html.DropDownListFor(model => model.HList4DD.First().HolidayDate, new SelectList(Model.PList4DD, "Id", "Name", Model.currentPersonID), "--select--")
        
 
       <script>
           function updateFormEnabled() 
           {
               if (verifyAdSettings()) 
               {
                   $('#sbmt').removeAttr('disabled');
               }
               else 
               {
                   $('#sbmt').attr('disabled', 'disabled');
               }
           }
 
           function verifyAdSettings() 
           {
               if ($('#HolidayDate').val() != '') 
               {
                   return true;
 
               }
               else 
               {
                   return false;
               }
           }
 

           $('#HolidayDate').change(updateFormEnabled);         
           </script>
 
      <td>
      @remainingHolidays.ToString()
   </td>
               
             <input type="submit" id= "sbmt" name="ViewHolidaysDD" value="View"/>
              </form>
         
  <script>
      $('#sbmt').attr('disabled', '');
        </script>
 
</table>
 

the @remainingHolidays.ToString() 5 lines or so up from the bottom is saying it doesnt exist in the current context?
AnswerRe: pulling across value from list to display in viewmemberfrazzle-me14 Dec '12 - 17:41 
Maybe you are over thinking the problem.
 
xnaLearner wrote:
@foreach (var item in Model.HList4DD)
{
<!-- add a variable say int i = 0;-->
<tr>
<td>
@Html.DisplayFor(modelItem => item.PersonId)
</td>
<td>
@Html.DisplayFor(modelItem => item.HolidayDate)
</td>
<!-- if i == 0 -->
<td>
@Html.DisplayFor(modelItem => item.Person.HolidaysRemaining)
</td>

 
Then you just increment the value of i.
 
Hope this helps.
 
[edit] fixed formating.
Frazzle the name say's it all

Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
John F. Woods

GeneralRe: pulling across value from list to display in viewmemberxnaLearner15 Dec '12 - 8:28 
Yeah that worked thanks for the help frazzle

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web03 | 2.6.130523.1 | Last Updated 24 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid