//integrated methods for moving error files private static void MoveErrorFiles(string fileName) { //this region part is for moving the error files method #region ResolutionFileLocation rf = new ResolutionFileLocation(); MoveFailedFile mv = new MoveFailedFile(fileName, fileName.Remove(0, rf.outboundPath.Length)); mv.Move(); #endregion }
//method public void VerifyNumberOfRecordsMethod() { //verify the number of records reader.MoveToContent(); while (reader.Read()) { //find the specific tag (ervmt:numberOfRecords) of the resolution XML file if (reader.NodeType == XmlNodeType.Element && reader.Name == "ervmt:numberOfRecords") { //assign the specific element value and convert it to an integer string messageType = reader.ReadString(); numberOfRecords = Convert.ToInt32(messageType); //display the number of records Console.WriteLine("The number of records: " + numberOfRecords); } //find the specific tag (ervmt:repairID) of the resolution XML file string repairID = null; if (reader.NodeType == XmlNodeType.Element && reader.Name == "ervmt:repairID") { //assign the specific element value repairID = reader.ReadString(); //display the number of records Console.WriteLine("The repairID: " + repairID); //count the total of repair IDs repairIDCount++; } } reader.Close(); //reader.Dispose(); Console.WriteLine("The total of the repairIDs: " + repairIDCount); //compare between the numberOfRecords and total of repairIDs if (numberOfRecords == repairIDCount) //if match { Console.WriteLine("This number of records Passed!"); VerifyResolutionList vfRlist = new VerifyResolutionList(); vfRlist.VerifyrepairResolutionList(fileName); } else //if not match { //throw new Exception("The number of records did not match the total of repairID\n"); Console.WriteLine("The number of records did not match the total of repairID. Failed!!!\n"); msgSubject = "Errors in resolution XML file: repairID not match"; msgBody = "\n The number of records: " + numberOfRecords + ", The total of repairIDs: " + repairIDCount + ".\n The number of records did not match the total of repairID. Failed!!!\n File Name: " + fileName; try { //send the error message to email //es.SendEmailMethod(msgSubject, msgBody); //this region part is for moving the error files method #region ResolutionFileLocation rf = new ResolutionFileLocation(); MoveFailedFile mv = new MoveFailedFile(fileName, fileName.Remove(0, rf.outboundPath.Length)); mv.Move(); #endregion } catch (Exception) { throw; } } }
//verify repairResolutionList field public void VerifyrepairResolutionList(string fileName) { XmlReader reader = XmlReader.Create(fileName); XmlDocument doc = new XmlDocument(); doc.Load(fileName); reader.Close(); //reader.Dispose(); //verify the tag foreach (XmlElement e in doc.SelectNodes("//*[local-name() = 'repairOrderResolution']")) { try { string ascWarrantyCd = e.SelectSingleNode("*[local-name() = 'repairResolutionList']").InnerText; } catch (Exception) { Console.WriteLine("Missing the repairResolutionList tag. Failed!!!"); msgSubject = "Errors in resolution XML file: repairResolutionList tag"; msgBody = "\n Missing the repairResolutionList tag. Failed!!!\n File Name: " + fileName; try { //es.SendEmailMethod(msgSubject, msgBody); //this region part is for moving the error files method #region ResolutionFileLocation rf = new ResolutionFileLocation(); MoveFailedFile mv = new MoveFailedFile(fileName, fileName.Remove(0, rf.outboundPath.Length)); mv.Move(); #endregion } catch (Exception) { throw; } } } //verify the content while (reader.Read()) { string clientDamageCdCon; if (reader.NodeType == XmlNodeType.Element && reader.Name == "ervmt:repairResolutionCode") { clientDamageCdCon = reader.ReadString(); if (clientDamageCdCon == "") { Console.WriteLine("The content of repairResolutionCode tag is empty. Failed!!!\n"); msgSubject = "Errors in resolution XML file: repairResolutionCode content"; msgBody = "\n The content of repairResolutionCode tag is empty. Failed!!!\n File Name: " + fileName; try { //es.SendEmailMethod(msgSubject, msgBody); //this region part is for moving the error files method #region ResolutionFileLocation rf = new ResolutionFileLocation(); MoveFailedFile mv = new MoveFailedFile(fileName, fileName.Remove(0, rf.outboundPath.Length)); mv.Move(); #endregion } catch (Exception) { throw; } } } } reader.Close(); //reader.Dispose(); }