Exemplo n.º 1
0
 public bool UploadFileData(PlacedCandidateModel candidate, int userid)
 {
     using (var connection = new SqlConnection(connectionString))
     {
         try
         {
             SqlParameter[] parameters = new SqlParameter[] {
                 new SqlParameter("@SumofCandidateContactNo", candidate.SumofCandidateContactNo),
                 new SqlParameter("@AverageofNoOfMonthsofPlacement", candidate.AverageofNoOfMonthsofPlacement),
                 new SqlParameter("@AvgofNoofdaysbetweennDOCDOP", candidate.AvgofNoofdaysbetweennDOCDOP),
                 new SqlParameter("@CandidateEmail", candidate.CandidateEmail),
                 new SqlParameter("@CandidateID", candidate.CandidateID),
                 new SqlParameter("@CandidateName", candidate.CandidateName),
                 new SqlParameter("@Castecategory", candidate.Castecategory),
                 new SqlParameter("@CertificateDate", candidate.CertificateDate),
                 new SqlParameter("@Certified", candidate.Certified),
                 new SqlParameter("@CountofPartnerID", candidate.CountofPartnerID),
                 new SqlParameter("@CountofSCTrainingCentreID", candidate.CountofSCTrainingCentreID),
                 new SqlParameter("@EducationAttained", candidate.EducationAttained),
                 new SqlParameter("@EmployerspocEmail", candidate.EmployerspocEmail),
                 new SqlParameter("@EmployerspocMobile", candidate.EmployerspocMobile),
                 new SqlParameter("@EmployerSpocName", candidate.EmployerSpocName),
                 new SqlParameter("@EmployerType", candidate.EmployerType),
                 new SqlParameter("@FirstEmploymentCreatedDate", candidate.FirstEmploymentCreatedDate),
                 new SqlParameter("@FYWise", candidate.FYWise),
                 new SqlParameter("@FromDate", candidate.FromDate),
                 new SqlParameter("@Gender", candidate.Gender),
                 new SqlParameter("@Jobrole", candidate.Jobrole),
                 new SqlParameter("@OrganisationDistrict", candidate.OrganisationDistrict),
                 new SqlParameter("@OrganisationState", candidate.OrganisationState),
                 new SqlParameter("@OrganizationAddress", candidate.OrganizationAddress),
                 new SqlParameter("@OrganizationName", candidate.OrganizationName),
                 new SqlParameter("@PartnerName", candidate.PartnerName),
                 new SqlParameter("@PartnerSPOCEmail", candidate.PartnerSPOCEmail),
                 new SqlParameter("@PartnerSPOCMobile", candidate.PartnerSPOCMobile),
                 new SqlParameter("@PartnerSPOCName", candidate.PartnerSPOCName),
                 new SqlParameter("@SectorName", candidate.SectorName),
                 new SqlParameter("@SelfEmployedDistrict", candidate.SelfEmployedDistrict),
                 new SqlParameter("@SelfEmployedState", candidate.SelfEmployedState),
                 new SqlParameter("@SumofSalleryPerMonth", candidate.SumofSalleryPerMonth),
                 new SqlParameter("@SumofTCSPOCMobile", candidate.SumofTCSPOCMobile),
                 new SqlParameter("@TCDistrict", candidate.TCDistrict),
                 new SqlParameter("@TCSPOCEmail", candidate.TCSPOCEmail),
                 new SqlParameter("@TCSPOCName", candidate.TCSPOCName),
                 new SqlParameter("@TCState", candidate.TCState),
                 new SqlParameter("@ToDate", candidate.ToDate),
                 new SqlParameter("@TrainingCentreName", candidate.TrainingCentreName),
                 new SqlParameter("@TrainingType", candidate.TrainingType),
                 new SqlParameter("@CreatedBy", userid),
             };
             var result =
                 SqlHelper.ExecuteNonQuery
                 (
                     connection,
                     CommandType.StoredProcedure,
                     "usp_InsertPlacedCandidate",
                     parameters
                 );
             if (result > 0)
             {
                 return(true);
             }
         }
         finally
         {
             SqlHelper.CloseConnection(connection);
         }
     }
     throw new RecordNotAddedException("Unable to Add Records");
 }
        public bool UploadFile(UserViewModel user, List <IFormFile> files)
        {
            string roleName = user.RoleName;
            //var status = true;
            string mappingFilePath =
                Path.Combine(environment.WebRootPath, "DataMappings", "PlacedCandidate", "PlacedCandidateMapping.xml");
            DataTable dt = XmlProcessor.XmlToTable(mappingFilePath);

            if (null != dt)
            {
                foreach (var file in files)
                {
                    DataTable dTable = null;
                    NPOIManager.ReadFile(file, dt, out dTable, true, roleName);
                    if (null != dTable && dTable.Rows.Count > 1)
                    {
                        //string[] additionalColumns = new string[] { "CreatedDate", "CreatedBy" };
                        //ExtendTable(additionalColumns, ref dTable, user.UserId, true);
                        //PlacedCandidateModel placeduser = null;
                        int header = -1;
                        foreach (DataRow row in dTable.Rows)
                        {
                            header++;
                            if (header == 0)
                            {
                                continue;
                            }
                            PlacedCandidateModel placeduser = new PlacedCandidateModel()
                            {
                                AverageofNoOfMonthsofPlacement = row["AverageofNoOfMonthsofPlacement"] as string ?? "",
                                AvgofNoofdaysbetweennDOCDOP    = row["AvgofNoofdaysbetweennDOCDOP"] as string ?? "",
                                CandidateEmail             = row["CandidateEmail"] as string ?? "",
                                CandidateID                = row["CandidateID"] as string ?? "",
                                CandidateName              = row["CandidateName"] as string ?? "",
                                Castecategory              = row["Castecategory"] as string ?? "",
                                CertificateDate            = row["CertificateDate"] as string ?? "",
                                Certified                  = row["Certified"] as string ?? "",
                                CountofPartnerID           = row["CountofPartnerID"] as string ?? "",
                                CountofSCTrainingCentreID  = row["CountofSCTrainingCentreID"] as string ?? "",
                                EducationAttained          = row["EducationAttained"] as string ?? "",
                                EmployerspocEmail          = row["EmployerspocEmail"] as string ?? "",
                                EmployerspocMobile         = row["EmployerspocMobile"] as string ?? "",
                                EmployerSpocName           = row["EmployerSpocName"] as string ?? "",
                                EmployerType               = row["EmployerType"] as string ?? "",
                                FirstEmploymentCreatedDate = row["FirstEmploymentCreatedDate"] as string ?? "",
                                FromDate                = row["FromDate"] as string ?? "",
                                FYWise                  = row["FYWise"] as string ?? "",
                                Gender                  = row["Gender"] as string ?? "",
                                Jobrole                 = row["Jobrole"] as string ?? "",
                                OrganisationDistrict    = row["OrganisationDistrict"] as string ?? "",
                                OrganisationState       = row["OrganisationState"] as string ?? "",
                                OrganizationAddress     = row["OrganizationAddress"] as string ?? "",
                                OrganizationName        = row["OrganizationName"] as string ?? "",
                                PartnerName             = row["PartnerName"] as string ?? "",
                                PartnerSPOCEmail        = row["PartnerSPOCEmail"] as string ?? "",
                                PartnerSPOCMobile       = row["PartnerSPOCMobile"] as string ?? "",
                                PartnerSPOCName         = row["PartnerSPOCName"] as string ?? "",
                                SectorName              = row["SectorName"] as string ?? "",
                                SelfEmployedDistrict    = row["SelfEmployedDistrict"] as string ?? "",
                                SelfEmployedState       = row["SelfEmployedState"] as string ?? "",
                                SumofCandidateContactNo = row["AverageofNoOfMonthsofPlacement"] as string ?? "",
                                SumofSalleryPerMonth    = row["SumofSalleryPerMonth"] as string ?? "",
                                SumofTCSPOCMobile       = row["SumofTCSPOCMobile"] as string ?? "",
                                TCDistrict              = row["TCDistrict"] as string ?? "",
                                TCSPOCEmail             = row["TCSPOCEmail"] as string ?? "",
                                TCSPOCName              = row["TCSPOCName"] as string ?? "",
                                TCState                 = row["TCState"] as string ?? "",
                                ToDate                  = row["ToDate"] as string ?? "",
                                TrainingCentreName      = row["TrainingCentreName"] as string ?? "",
                                TrainingType            = row["TrainingType"] as string ?? "",
                            };
                            try
                            {
                                _placedCandidateRepository.UploadFileData(placeduser, user.UserId);
                            }
                            catch (Exception ex)
                            {
                                continue;
                            }
                        }
                    }
                }
            }
            return(true);
        }