I am getting excel sheet rows and columns value and insert DB by using the below code
Now I want to get the mobile number one by one and do mobile number validation for all row column value.
If anyone knows kindly suggest me to solve this task
string folderPath = string.Format("{0}\\{1}\\{2}\\{3}\\Interaction\\", System.Configuration.ConfigurationManager.AppSettings["InteractionFileData"], DateTime.Now.ToString("yyyy"), DateTime.Now.ToString("MMM"), DateTime.Now.ToString("dd"));
if (!Directory.Exists(folderPath))
Directory.CreateDirectory(folderPath);
if (ReadSFTP(folderPath, ref message))
{
string[] Files = Directory.GetFiles(folderPath, "*.xlsx*")
.Select(path => Path.GetFileName(path))
.ToArray();
for (var i = 0; i < Files.Length; i++)
{
string fname = folderPath + Files[i];
DataTable dt = TRMFile.Models.Helper.GeneralHelper.ExcelToDataset(fname);
StringBuilder sb = new StringBuilder();
for (int row = 0; dt.Rows.Count > row; row++)
{
for (int column = 0; dt.Columns.Count > column; column++)
sb.AppendFormat("{0}#", dt.Rows[row][column]);
sb.Length--;
sb.Append("*");
}
StringBuilder sbRequest = new StringBuilder();
sbRequest.AppendFormat("<Request><Filename>{0}</Filename><TRMData>{1}</TRMData></Request>", Files[i], sb.ToString());
string responseXml = TRMFile.Models.Helper.GeneralHelper.SendService("TRMFileUpdation", TRMFile.Models.Helper.GeneralHelper.EncryptDecrypt(sbRequest.ToString(), 1));
string designationFolder = string.Format("{0}\\{1}\\{2}\\{3}\\Interaction_Backup\\", System.Configuration.ConfigurationManager.AppSettings["InteractionFileData"], DateTime.Now.ToString("yyyy"), DateTime.Now.ToString("MMM"), DateTime.Now.ToString("dd"));
MovetoBackupFolder(folderPath, designationFolder);
}
}
else
{
Models.Helper.GeneralHelper.Log_Handler(this.GetType().Name, System.Reflection.MethodBase.GetCurrentMethod().Name, "SFTP Failed", 1);
}
I want to check mobile number should be 10 digits only, if it is more than 12 digits, will take the last 10 digits only.
thats the validation i want otherwise get and insert working fine
if (mobileNo.Length == 12)
mobileNo = mobileNo.Substring(2, mobileNo.Length - 2);
else if (mobileNo.Length == 13)
mobileNo = mobileNo.Substring(3, mobileNo.Length - 3);
else if (mobileNo.Length >= 10)
mobileNo = mobileNo.Substring(mobileNo.Length - 10);