|
//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();
}
}
}
}
|
|
|
|
|
I used firebug. It shows "500 Internal Server Error".
|
|
|
|
|
Good morning
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.
|
|
|
|
|
HAHA... Overhere now is night time...
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.
|
|
|
|
|
|
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('/');
|
|
|
|
|
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
|
|
|
|
|
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?
|
|
|
|
|
Maybe you are over thinking the problem.
xnaLearner wrote: @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>
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
|
|
|
|
|
Yeah that worked thanks for the help frazzle
|
|
|
|
|
|
Im using microsoft sql server management studio to create my tables.
I previously had the relationships working but I have to go back an re-do them and it is throwing me an error:
im trying to do primary key 'person id' in person table with foreign key in holiday table 'person id'556
But when I try to save it I am getting the error:
- Unable to create relationship 'FK_Holidays_Person'.
The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_Holidays_Person". The conflict occurred in database "holidays", table "dbo.Person", column 'Id'.
any idea as to why it won't allow me to update this?
|
|
|
|
|
You have at least one record in the holidays table with a person ID which doesn't exist in the person table.
SELECT DISTINCT PersonID
FROM Holidays As H
WHERE Not Exists
(
SELECT 1
FROM Person As P
WHERE P.ID = H.PersonID
)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
thank you for the reply, i had to delete all the data in both tables to get it to work
|
|
|
|
|
Hi,
in my application (running in Windows CE) I use a XML file to store some configuration data that, at runtime, I load in a DataSet.
To read and to store these data I use the following code:
Private Shared Function SetCfgData() As Boolean
Try
Dim fs As New FileStream(CGlobali.CfgDataFileComplName, FileMode.Open)
Dim xr As XmlReader = System.Xml.XmlReader.Create(fs)
CGlobali.CfgData.Clear()
CGlobali.CfgData.ReadXml(xr)
xr.Close()
fs.Close()
Catch ex As System.IO.FileNotFoundException
MessageBox.Show("File " & CGlobali.CfgDataFileComplName & " not found.")
Return False
Catch ex As XmlException
MessageBox.Show("XmlException occured: " & ex.ToString)
Return False
End Try
Return True
When the user modifies these data, they are automatically updated in the DataSet and saved in the file, at least that's what I would do...
To save the data from the DataSet to the file I do this:
Private Shared Function UpdateCgfFile() As Boolean
Try
Dim StreamEncoding As Encoding
StreamEncoding = Encoding.Unicode
Dim cfgfile As New System.IO.StreamWriter(CGlobali.CfgDataFileComplName, True, StreamEncoding)
CGlobali.CfgData.WriteXml(cfgfile)
cfgfile.Close()
Return True
Catch ex As Exception
Return False
End Try
End Function
What I would get with the above code is to update existing fields in the xml file with the new values, but what I get is that the same fields are added to the existing ones.
This is the "original" file:
="1.0"="UTF-16"
<Sezioni>
<PLC>
<IP>10.0.0.85</IP>
<Port>502</Port>
<Description></Description>
<PauComm>15000</PauComm>
<ConTOut>5000</ConTOut>
<RxTOut>5000</RxTOut>
</PLC>
</Sezioni>
and this is the file after a save:
="1.0"="UTF-16"
<Sezioni>
<PLC>
<IP>10.0.0.85</IP>
<Port>502</Port>
<Description></Description>
<PauComm>15000</PauComm>
<ConTOut>5000</ConTOut>
<RxTOut>5000</RxTOut>
</PLC>
</Sezioni>
<Sezioni>
<PLC>
<IP>192.168.1.10</IP>
<Port>502</Port>
<Description />
<PauComm>15000</PauComm>
<ConTOut>5000</ConTOut>
<RxTOut>5000</RxTOut>
</PLC>
</Sezioni>
Obviously this is not the result I want to achieve, I do not want to duplicate fields, I want to update the existing ones.
Can someone tell me what I'm doing wrong?
Thanks in advance.
|
|
|
|
|
steve_9496613 wrote: Can someone tell me what I'm doing wrong?
Dim cfgfile As New System.IO.StreamWriter(CGlobali.CfgDataFileComplName, True, StreamEncoding)
What does the second parameter in the StreamWriter do?
true to append data to the file; false to overwrite the file. If the specified file does not exist, this parameter has no effect, and the constructor creates a new file.
|
|
|
|
|
...ops...
...next time I'll be more careful...
Thanks Eddy
|
|
|
|
|
You're welcome
|
|
|
|
|
I have a assembly A that must use .NET framework 3.5. This assembly has a referense to a 3rd party assembly that has been developed with .net framework 4.0. The problem is that I can't build because the 3rd party uses FW 4.0. Is it possible to solve this?
|
|
|
|
|
Create a (console) "server" app in 4.0 that references the 3rd party assembly.
Create a connection using "Named Pipes" from your 3.5 app (as "client") to the "server".
Start the server and the client, and acccess the 4.0 assembly by the client thru the server.
(Or: use message queues; a web service (on the same machine); etc.)
|
|
|
|
|
Hey guys so atm when the user goes to the holiday page, they can do 1 of 2 things
1)use a drop down box to select 'person name' and click 'view' this will display all the current holidays for this person
2)click 'create new' which will bring the user to a create page which allows them to add a new holiday(from here they select person name from drop and and select what date from calender)
This all works, however if the user originally follows the first path of selecting a person name and clicking view(it will display their holidays) if they then take the path of 2 and click 'create' it will jump to the create page. however the drop down box will be back at 'select' i would like the existing person selected from the previous drop down to display in this drop down.
A cookie or url/parameter?
anyway Im stuck please help
I've tried a cookie.
[code]
[HttpGet]
public ViewResult Index(string sortOrder, int? currentPersonID)
{
var holidays = db.Holidays.Include("Person");
HolidayList model = new HolidayList();
if (currentPersonID.HasValue)
{
model.currentPersonID = currentPersonID.Value;
}
else
{
model.currentPersonID = 0;
}
model.PList4DD = db.People.ToList();
ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "date" : "";
var dates = from d in db.Holidays
where d.PersonId == currentPersonID.Value
select d;
switch (sortOrder)
{
case "date":
dates = dates.OrderBy(p => p.HolidayDate);
break;
}
model.HList4DD = dates.ToList();
var cookie = new HttpCookie("cookie_name", "currentPersonID");
Response.AppendCookie(cookie);
return View(model);
}
public ActionResult Create()
{
var cookie = Request.Cookies["cookie_name"];
if (cookie != null)
{
string value = cookie.Value;
}
ViewBag.cookie = cookie.Value;
ViewBag.Id = new SelectList(db.People, "Id", "Name");
return View();
//tried to use the currentPersonID in index as an int but it woudlnt allow me.
[/code]
My View
[code]
@model HolidayBookingApp.Models.startANDend
@{
ViewBag.Title = "Create";
}
<p>
<span>@ViewBag.cookie</span>
<h2>Create</h2>
<form action ="ListHolidays" id="listHolidays" method="post">
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Holiday</legend>
<div>
@Html.LabelFor(model => model.PersonId, "Person")
</div>
<div>
@Html.DropDownListFor(model => model.PersonId,
new SelectList(ViewBag.Id, "Value", "Text"),
"---Select---"
)
@Html.ValidationMessageFor(model => model.PersonId)
</div>
<div>
@Html.LabelFor(model => model.HolidayDate)
</div>
<div>
@Html.TextBoxFor(model => model.HolidayDate)
@Html.TextBoxFor(model => model.endDate)
<script>
$("#HolidayDate").addClass('date-pick');
$("#endDate").addClass('date-pick');
$(function () {
$('.date-pick').datePicker(
{
createButton: false,
renderCallback: function ($td, thisDate, month, year) {
if (thisDate.isWeekend()) {
$td.addClass('weekend');
$td.addClass('disabled');
}
}
}
)
.bind('click',
function () {
$(this).dpDisplay();
this.blur();
return false;
}
)
.bind('dateSelected',
function (e, selectedDate, $td) {
console.log('You selected ' + selectedDate);
}
);
$('#HolidayDate').bind('dpClosed',
function (e, selectedDates) {
var d = selectedDates[0];
if (d) {
d = new Date(d);
$('#endDate').dpSetStartDate(d.addDays(0).asString());
}
}
);
$('#endDate').bind('dpClosed',
function (e, selectedDates) {
var d = selectedDates[0];
if (d) {
d = new Date(d);
$('#HolidayDate').dpSetEndDate(d.addDays(0).asString());
}
}
);
});
</script>
@Html.ValidationMessageFor(model => model.HolidayDate)
</div>
<p>
<input type="submit" value="Create"/>
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@*
<p>Current Person Selected is:
@TempData["currentPersonID"]
</p>*@
[code]
Once I get this going how can i get my drop down to store the value? Any help?
Thanks
|
|
|
|
|
So the user selects holidays (start and end dates) from two calendars, the dates from start to end are then stored in the DB in separate records per date.
(thanks to help from a previous question this all works fine)
Now, I want some sort of error message which doesnt allow the button to be clicked if the dates the user are selecting already exist in the DB.
Im unsure if this is done from the view, or controller?
View:
<form action ="ListHolidays" id="listHolidays" method="post">
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>Holiday</legend>
<div>
@Html.LabelFor(model => model.PersonId, "Person")
</div>
<div>
@Html.DropDownListFor(model => model.PersonId,
new SelectList(ViewBag.Id, "Value", "Text"),
"---Select---"
)
@Html.ValidationMessageFor(model => model.PersonId)
</div>
<div>
@Html.LabelFor(model => model.HolidayDate)
</div>
<div>
@Html.TextBoxFor(model => model.HolidayDate)
@Html.TextBoxFor(model => model.endDate)
<script>
$("#HolidayDate").addClass('date-pick');
$("#endDate").addClass('date-pick');
$(function () {
$('.date-pick').datePicker(
{
createButton: false,
renderCallback: function ($td, thisDate, month, year)
{
if (thisDate.isWeekend())
{
$td.addClass('weekend');
$td.addClass('disabled');
}
}
}
)
.bind('click',
function ()
{
$(this).dpDisplay();
this.blur();
return false;
}
)
.bind('dateSelected',
function (e, selectedDate, $td)
{
console.log('You selected ' + selectedDate);
}
);
$('#HolidayDate').bind('dpClosed',
function (e, selectedDates)
{
var d = selectedDates[0];
if (d)
{
d = new Date(d);
$('#endDate').dpSetStartDate(d.addDays(1).asString());
}
}
);
$('#endDate').bind('dpClosed',
function (e, selectedDates)
{
var d = selectedDates[0];
if (d)
{
d = new Date(d);
$('#HolidayDate').dpSetEndDate(d.addDays(-1).asString());
}
}
);
});
</script>
@Html.ValidationMessageFor(model => model.HolidayDate)
</div>
<p>
<input type="submit" value="Create"/>
</p>
controller:
HttpPost] public ActionResult listHolidays(Holiday holiday, int? PersonId, string HolidayDate, string endDate) {
DateTime startDates = Convert.ToDateTime(HolidayDate),
endDates = Convert.ToDateTime(endDate);
while (startDates <= endDates)
{
if (startDates.DayOfWeek != DayOfWeek.Saturday && startDates.DayOfWeek != DayOfWeek.Sunday)
{
Holiday holiday1 = new Holiday();
holiday1.PersonId = PersonId.Value;
holiday1.HolidayDate = startDates;
db.Holidays.AddObject(holiday1);
db.SaveChanges();
}
startDates = startDates.AddDays(1);
}
return RedirectToAction("Index");
so...? if holidayDate = db.exisitng date?
Unsure how to go about this.
Please advise.
thanks
|
|
|
|
|
I'd be tempted to use this logic:
$(function () {
$('.date-pick').datePicker(
{
createButton: false,
renderCallback: function ($td, thisDate, month, year)
{
if (thisDate.isWeekend())
{
$td.addClass('weekend');
$td.addClass('disabled');
}
if (thisDate.isHoliday())
{
$td.addClass('holiday');
$td.addClass('disabled');
}
}
}
)
Where you do the check for thisDate.isWeekend, add in a check to see if the date has previously been selected as well. That way you give the user a good UI experience because you can show that a date has previously been selected. Now, you will also need to add a check in to the controller to prevent the user from adding a date that's previously been selected because you are working in a multi-user system here.
|
|
|
|
|
Ahh yes i see...the holiday method was a ice feature as well...I get what your saying Pete, but unfortunately I don't know how to hard code a check for the UI that will show what dates are already chosen, how can i pull the dates across?
Also regarding putting a check in the controller could you give any advice on this? I know what I am meant to do but don't know the syntax
datetime startDate
if statedate = db.holidayDate
MessageBox("error")
disable 'select'btn
|
|
|
|
|
Hi Pete,
Im trying to give the UI experience of date if it has been previously accepted.
In My JS file:
/**
* An Array of day names starting with Sunday.
*/
Date.dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
/**
* An Array of abbreviated day names starting with Sun.
*/
Date.abbrDayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
/**
* An Array of month names starting with Janurary.
*/
Date.monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
/**
* An Array of abbreviated month names starting with Jan.
*/
Date.abbrMonthNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
/**
* The first day of the week for this locale.
*/
Date.firstDayOfWeek = 1;
/**
* The format that string dates should be represented as (e.g. 'dd/mm/yyyy' for UK, 'mm/dd/yyyy' for US, 'yyyy-mm-dd' for Unicode etc).
*/
Date.format = 'dd/mm/yyyy';
/**
* The first two numbers in the century to be used when decoding a two digit year. Since a two digit year is ambiguous (and date.setYear
* only works with numbers < 99 and so doesn't allow you to set years after 2000) we need to use this to disambiguate the two digit year codes.
*/
Date.fullYearStart = '20';
(function () {
function add(name, method) {
if (!Date.prototype[name]) {
Date.prototype[name] = method;
}
};
/**
* Checks if the year is a leap year.
*/
add("isLeapYear", function () {
var y = this.getFullYear();
return (y % 4 == 0 && y % 100 != 0) || y % 400 == 0;
});
/**
* Checks if the day is a weekend day (Sat or Sun).
*/
add("isWeekend", function () {
return this.getDay() == 0 || this.getDay() == 6;
});
I'm tryihg to add a check into 'isWeekend' to include dates that already exist but don't know how.
Can you Advise?
Thanks
|
|
|
|
|