Q:
I allow my user to upload an xml file to insert its contents in my database.
I ask if there's some idea to know the attributes which have been changed to update the equivalent fields in my database without uploading the updated file again(clear all the data related to this file and insert it again).
Is there some way rather than a form .
My xml snip:
My .cs snip :
List days = new List();//List of days.
IEnumerable resultDays = ReadDayNodes(targetFileName);
foreach (DayNode name in resultDays)
{
Day day = new Day();
if (!string.IsNullOrEmpty(ddl_batch.SelectedValue))
day.BatchNum = int.Parse(ddl_batch.SelectedValue);
if (!string.IsNullOrEmpty(ddl_department.SelectedValue))
day.DepCode = int.Parse(ddl_department.SelectedValue);
if (!string.IsNullOrEmpty(ddl_study.SelectedValue))
day.StudyCode = int.Parse(ddl_study.SelectedValue);
if (!string.IsNullOrEmpty(name.Day))
day.DayId = name.Day;
day.ShortName = name.Short;
day.Name = name.Name;
days.Add(day);
}
/********************************************************************************************************************/
private struct DayNode
{
public string Name { get; private set; }
public string Short { get; private set; }
public string Day { get; private set; }
public DayNode(string Name, string Short, string Day)
: this()
{
this.Name = Name;
this.Short = Short;
this.Day = Day;
}
}
/********************************************************************************************************************/
private static IEnumerable ReadDayNodes(string filePath)
{
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read))
using (XmlReader xrdr = new XmlTextReader(fs))
while (xrdr.Read())
if (xrdr.NodeType == XmlNodeType.Element && xrdr.LocalName == "day")
yield return new DayNode(xrdr.GetAttribute("name"), xrdr.GetAttribute("short"), xrdr.GetAttribute("day"));
}
/********************************************************************************************************************/
resultDay = CommonUitilities.InsertDays(days);
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)