[WebMethod]
public XmlDocument SaveDataMethod(string xml)
{
try
{
objExceptionLog.LogMessage("Confirm if method called", "SaveDataMethod");
int UserID = 0;
DateTime VisitDate = DateTime.Now;
int DealerID = 0;
string Remarks = "";
decimal Collection = 0;
string ChequeDDNo = "";
DateTime ChequeDDDate = DateTime.Now;
DataSet ds = new DataSet();
ds = Decode(xml);
foreach (DataRow dr in ds.Tables[0].Rows)
{
UserID = Convert.ToInt32(dr["UserID"]);
VisitDate = Convert.ToDateTime(dr["VisitDate"]);
DealerID = Convert.ToInt32(dr["DealerID"]);
Remarks = Convert.ToString(dr["Remarks"]);
Collection = Convert.ToDecimal(dr["Collection"]);
ChequeDDNo = Convert.ToString(dr["ChequeDDNo"]);
ChequeDDDate = Convert.ToDateTime(dr["ChequeDDDate"]);
string strresult = "";
BusinessDealerVisit objBusiness = new BusinessDealerVisit();
strresult = objBusiness.Save(new EntityDealerVisit
{
DealerVisitUserID = UserID,
Date = VisitDate,
VisitedDealerID = DealerID,
Remarks = Remarks,
Collection = Collection,
ChequeDDNo = ChequeDDNo,
ChequeDDDate = ChequeDDDate
});
//Console.WriteLine(dr["ColName"].ToString());
}
//List<string> MyCollection = new List<string>();
//XElement xmlTree = XElement.Parse(xml);
//foreach (XElement e1 in xmlTree.Elements())
//{
// string values = e1.Value;
// MyCollection.Add(values);
//}
//MyCollection.ToArray();
//UserID = Convert.ToInt32(MyCollection[0]);
//VisitDate = Convert.ToDateTime(MyCollection[1]);
//DealerID = Convert.ToInt32(MyCollection[2]);
//Remarks = Convert.ToString(MyCollection[3]);
//Collection = Convert.ToDecimal(MyCollection[4]);
//ChequeDDNo = Convert.ToString(MyCollection[5]);
//ChequeDDDate = Convert.ToDateTime(MyCollection[6]);
//string strresult = "";
//BusinessData objBusiness = new BusinessData ();
try
{
// strresult = objBusiness.Save(new EntityData
// {
// DealerVisitUserID = UserID,
// Date = VisitDate,
// VisitedDealerID = DealerID,
// Remarks = Remarks,
// Collection = Collection,
// ChequeDDNo = ChequeDDNo,
// ChequeDDDate = ChequeDDDate
// });
Document = CreateBaseStringBuilder();
Document.AppendLine("<SaveData>");
Document.AppendLine("<Message>" + "Data Saved sucessfully" + "</Message>");
Document.AppendLine("</SaveData>");
XMLDocument.LoadXml(Document.ToString());
objExceptionLog.LogMessage("Confirmation SaveData Saved sucessfully", "InsertDealerVisit");
return (XMLDocument);
//}
}
catch (Exception ex)
{
Document = CreateBaseStringBuilder();
Document.AppendLine("<SaveData>");
Document.AppendLine("<Message>" + "Error Saving Record" + "</Message>");
Document.AppendLine("</SaveData>");
XMLDocument.LoadXml(Document.ToString());
objExceptionLog.LogMessage("Error Saving Record", "SaveDataMethod");
return (XMLDocument);
}
}
catch (Exception ex)
{
objExceptionLog.LogErrorMessage(ex, "SaveDataMethod");
return null;
}
}
public DataSet Decode(string xml)
{
try
{
StringReader theReader = new StringReader(xml);
DataSet theDataSet = new DataSet();
theDataSet.ReadXml(theReader);
return theDataSet;
}
catch (Exception ex)
{
objExceptionLog.LogErrorMessage(ex, "Decode");
return null;
}
}
public XmlDocument SaveDataMethod(string xml)
{
try
{
objExceptionLog.LogMessage("Confirm if method called", "SaveDataMethod");
int UserID = 0;
DateTime VisitDate = DateTime.Now;
int DealerID = 0;
string Remarks = "";
decimal Collection = 0;
string ChequeDDNo = "";
DateTime ChequeDDDate = DateTime.Now;
DataSet ds = new DataSet();
ds = Decode(xml);
foreach (DataRow dr in ds.Tables[0].Rows)
{
UserID = Convert.ToInt32(dr["UserID"]);
VisitDate = Convert.ToDateTime(dr["VisitDate"]);
DealerID = Convert.ToInt32(dr["DealerID"]);
Remarks = Convert.ToString(dr["Remarks"]);
Collection = Convert.ToDecimal(dr["Collection"]);
ChequeDDNo = Convert.ToString(dr["ChequeDDNo"]);
ChequeDDDate = Convert.ToDateTime(dr["ChequeDDDate"]);
string strresult = "";
BusinessDealerVisit objBusiness = new BusinessDealerVisit();
strresult = objBusiness.Save(new EntityDealerVisit
{
DealerVisitUserID = UserID,
Date = VisitDate,
VisitedDealerID = DealerID,
Remarks = Remarks,
Collection = Collection,
ChequeDDNo = ChequeDDNo,
ChequeDDDate = ChequeDDDate
});
//Console.WriteLine(dr["ColName"].ToString());
}
//List<string> MyCollection = new List<string>();
//XElement xmlTree = XElement.Parse(xml);
//foreach (XElement e1 in xmlTree.Elements())
//{
// string values = e1.Value;
// MyCollection.Add(values);
//}
//MyCollection.ToArray();
//UserID = Convert.ToInt32(MyCollection[0]);
//VisitDate = Convert.ToDateTime(MyCollection[1]);
//DealerID = Convert.ToInt32(MyCollection[2]);
//Remarks = Convert.ToString(MyCollection[3]);
//Collection = Convert.ToDecimal(MyCollection[4]);
//ChequeDDNo = Convert.ToString(MyCollection[5]);
//ChequeDDDate = Convert.ToDateTime(MyCollection[6]);
//string strresult = "";
//BusinessData objBusiness = new BusinessData ();
try
{
// strresult = objBusiness.Save(new EntityData
// {
// DealerVisitUserID = UserID,
// Date = VisitDate,
// VisitedDealerID = DealerID,
// Remarks = Remarks,
// Collection = Collection,
// ChequeDDNo = ChequeDDNo,
// ChequeDDDate = ChequeDDDate
// });
Document = CreateBaseStringBuilder();
Document.AppendLine("<SaveData>");
Document.AppendLine("<Message>" + "Data Saved sucessfully" + "</Message>");
Document.AppendLine("</SaveData>");
XMLDocument.LoadXml(Document.ToString());
objExceptionLog.LogMessage("Confirmation SaveData Saved sucessfully", "InsertDealerVisit");
return (XMLDocument);
//}
}
catch (Exception ex)
{
Document = CreateBaseStringBuilder();
Document.AppendLine("<SaveData>");
Document.AppendLine("<Message>" + "Error Saving Record" + "</Message>");
Document.AppendLine("</SaveData>");
XMLDocument.LoadXml(Document.ToString());
objExceptionLog.LogMessage("Error Saving Record", "SaveDataMethod");
return (XMLDocument);
}
}
catch (Exception ex)
{
objExceptionLog.LogErrorMessage(ex, "SaveDataMethod");
return null;
}
}
public DataSet Decode(string xml)
{
try
{
StringReader theReader = new StringReader(xml);
DataSet theDataSet = new DataSet();
theDataSet.ReadXml(theReader);
return theDataSet;
}
catch (Exception ex)
{
objExceptionLog.LogErrorMessage(ex, "Decode");
return null;
}
}
No comments:
Post a Comment