TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Robson Amaral
NA
132
17.3k
Popular one dataTable and get index of the line
May 12 2018 2:10 PM
How do I populate my dataTable in the mue method import and grab the index
from the correct line from my initated file from line 6? Here's my code:
protected
void
Page_Load (
object
sender, EventArgs, and)
{
}
protected
void
import_Click (
object
sender, EventArgs and)
{
DataTable Data =
new
DataTable ();
if
(selectFileContent! =
null
)
{
string
Excel = AppDomain.CurrentDomain.BaseDirectory + select File.FileName;
select File.SaveAs (Excel);
Data = Excel Data (Excel);
var recordsValid = ((DataTable) Data) .Rows.OfType <DataRow> (). Skip (5);
// Delete the last line
recordsValid = RecordsValid.Take (RecordsValid.Count () - 1);
// read 100 out of 100 records
int
amount_for_page = 100;
int
total_of_page;
// Count valid records
int
qtd_total_registers = recordsValids.Count ();
// Perform mathematical calculations for total pages.
total_of_pages = (
int
) Math.Ceiling ((
double
) qtd_total_records / amount_by_page);
if
(recordsValid.Count ()> 0)
{
bool
layoutValid = CheckLayout (Data);
if
(! layoutValid)
ClientScript.RegisterStartupScript (
typeof
(
string
),
"Error"
,
"<script> alert ('Non-standard file layout defined for import.') </ Script>"
);
else
{
// Basic validation required for import. PS: NumLinhas-1 because the file has the last line with total, which is useless to import.
VerificationPreliminary (valid records);
// Start the repetition routine to read all the lines, starting in cell B6
if
(!
{
this
.ValidateDuplicityInterested ();
// Creating Parallel Tasks
List <System.Threading.Tasks.Task> TasksParallel =
new
List <System.Threading.Tasks.Task> ();
for
(
int
j = 0; j <total_of_pages; j ++)
{
var page = j;
// read the 100 lines
var linesPerPage = recordsResults.Skip (page * quantity_by_page) .Take (quantity_by_page);
// Breaking into 10 threads, I will break the list with the extension created below
var data_rows_divididos = linesPerPagina.SplitList (10);
foreach
(var linesDivided
in
data_rows_divided)
{
// I ADD TO MY PARALLEL TASK LIST
TasksParalelas.Add (TableTransform (split lines, j, userLog));
}
}
// START THE PARALLEL TASKS
foreach
(var task
in
TasksParallel)
task.Start ();
// NOW I EXPECT ALL JOBS TO COMPLETE
System.Threading.Tasks.Task.WaitAll (TasksParalelas.ToArray ());
}
}
private
System.Threading.Tasks.Task Processing table (IEnumerable <DataRow> dataparam,
int
i, UserLibrary user)
{
// userLogin = appLogin.LoginPorLogin (GetUserAuthenticated ().));
Action <
object
> processing = (data) =>
{
NHibernate.Context.ThreadStaticSessionContext.Bind (NhibernateHelper.HelpThreading (). OpenSession ());
foreach
(var line
in
(IEnumerable <DataRow>) data)
{
List <Process> listProcessOpen =
new
List <Process> ();
Process process =
null
;
Interested interested =
new
Interested ();
// search for the process by the previous or current judicial number
if
(! line.ItemArray [1] .ToString ().) Equals (
""
))
process = aplProcess.consultPerNProcessOER (line.ItemArray [1] .ToString ());
if
(process ==
null
)
{
if
(! line.ItemArray [2] .ToString ().) Equals (
""
))
process = aplProcess.consultPerNProcessOER (line.ItemArray [2] .ToString ());
}
// find the person interested by cpf / cnpj
if
(line.ItemArray [7] .ToString (). Length == 14)
interested = aplInterado.ConsultaPorCPF (AuxiliarCPF_CNPJ.DesformataCPF (line.ItemArray [7] .ToString ()));
if
(line.ItemArray [7] .ToString (). Length == 18)
interested = apl
Interested.ConsultPerCPF (HelpCPF_CNPJ.DesformatCNPJ (line.ItemArray [7] .ToString ()));
if
(process! =
null
)
{
// if the process is not null I search all procinter related to it
List <ProcessInterest> listprocinter = ProcessInterested.consultProcesso(process.Code);
if
(listprocinter.Exists (o => o.interest == interested))
//
I can not
get
the index of the interested one of the correct line here, here lives the problem, therefore I thought of popular the dataTable
in
the beginning and to pass the index here direct, however I
do
not know how to
do
.
log.Append (
"The interested"
+ process.Interested.Name +
", entered in the line"
+ (i + 1) +
"was added again to the process"
+ process.NumProcesso +
""
);
else
{
// New Process - 6.3
process =
new
Process ();
process.Interested = interested;
}
}
}
}
Reply
Answers (
0
)
checkbox data pass from webgrid in mvc example
How to download huge data in dropdownist