/// <summary> /// Save /// </summary> /// <param name="projectId">projectId</param> /// <param name="countryId">countryId</param> /// <param name="provinceId">provinceId</param> /// <param name="countyId">countyId</param> /// <param name="cityId">cityId</param> /// <param name="companyId">companyId</param> /// <param name="loginId">loginId</param> public void Save(int companyId, int loginId) { foreach (DataMigrationTDS.JlDataMigrationRow row in (DataMigrationTDS.JlDataMigrationDataTable)Table) { // Get ids & location ProjectGateway projectGateway = new ProjectGateway(); DataMigrationProjectGateway dataMigrationProjectGateway = new DataMigrationProjectGateway(null); string name = string.Format("{0} Data Migration Project", row.Client); int projectId = dataMigrationProjectGateway.GetProjectIdByName(name); if (projectId != 0) { projectGateway.LoadByProjectId(projectId); // get parameters Int64 countryId = projectGateway.GetCountryID(projectId); Int64? provinceId = null; if (projectGateway.GetProvinceID(projectId).HasValue) provinceId = projectGateway.GetProvinceID(projectId); Int64? countyId = null; if (projectGateway.GetCountyID(projectId).HasValue) countyId = projectGateway.GetCountyID(projectId); Int64? cityId = null; if (projectGateway.GetCityID(projectId).HasValue) cityId = projectGateway.GetCityID(projectId); //Save section int section_assetId = SaveSection(row, projectId, countryId, provinceId, countyId, cityId, companyId); Guid originalId = row.OriginalID; if (row.JLiner) { SaveJLWork(originalId, section_assetId, row.NumLats, row.NotLinedYet, row.AllMeasured, row.IssueWithLaterals, row.NotMeasuredYet, row.NotDeliveredYet, projectId, countryId, provinceId, countyId, cityId, companyId); } // Insert in DataMigration Table string originalSectionId = row.OriginalSectionID; AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway(); assetSewerSectionGateway.LoadByAssetId(section_assetId, companyId); string newSectionId = assetSewerSectionGateway.GetSectionId(section_assetId); DataMigrationGateway dataMigrationGateway = new DataMigrationGateway(null); dataMigrationGateway.InsertDataMigration(originalId, originalSectionId, section_assetId, newSectionId); } } }
private bool ProcessBulkUpload(string fName, out string bulkUploadResultMessage) { bool bulkUploadProccessed = true; bulkUploadResultMessage = ""; AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway(); AppSettingsReader appSettingReader = new AppSettingsReader(); string excelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties='Excel 8.0;HDR=YES;IMEX=1';Data Source=" + fName + ";"; OleDbConnection connection = new OleDbConnection(excelConnectionString); OleDbCommand command = null; OleDbDataReader dataReader = null; try { try { connection.Open(); command = new OleDbCommand("select * from [sections]", connection); dataReader = command.ExecuteReader(); dataReader.Close(); connection.Close(); } catch (Exception ex) { bulkUploadResultMessage = "You did not define the 'sections' data range. Bulk upload ABORTED. Original message: " + ex.Message; bulkUploadProccessed = false; if (connection.State == ConnectionState.Open) { connection.Close(); } } //--- Process bulk upload if (bulkUploadProccessed) { connection.Open(); command = new OleDbCommand("select * from [sections]", connection); dataReader = command.ExecuteReader(); int id = 0; while (dataReader.Read()) { if (!IsEmptyRow(dataReader)) { bool deleted = false; int companiesId = 0; string client = ""; string subArea = ""; string street = ""; string usmh = ""; string dsmh = ""; string mapSize = ""; //Size_ string mapLength = ""; //ScaledLength string actualLength = ""; // string confirmedSize = ""; bool jlWork = false; // JL work string usmhMn = ""; string dsmhMn = ""; string usmhDepth = ""; string dsmhDepth = ""; string steelTapeThruPipe = ""; string usmhAtMouth1200 = ""; string usmhAtMouth100 = ""; string usmhAtMouth200 = ""; string usmhAtMouth300 = ""; string usmhAtMouth400 = ""; string usmhAtMouth500 = ""; string dsmhAtMouth1200 = ""; string dsmhAtMouth100 = ""; string dsmhAtMouth200 = ""; string dsmhAtMouth300 = ""; string dsmhAtMouth400 = ""; string dsmhAtMouth500 = ""; string dataCell = null; string dataCellToUpper = null; //--- ... fill section row string originalSectionId = dataReader.GetValue(dataReader.GetOrdinal("ID")).ToString().Trim(); for (int i = 0; i < dataReader.FieldCount; i++) { dataCell = dataReader.GetValue(i).ToString().Trim(); dataCellToUpper = dataReader.GetValue(i).ToString().Trim().ToUpper(); switch (dataReader.GetName(i).Trim()) { case "ID": originalSectionId = dataCell; break; case "COMPANIES_ID": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { companiesId = int.Parse(dataCell); } else { bulkUploadResultMessage = "Invalid value in 'COMPANIES_ID' column (" + originalSectionId + "). Bulk upload ABORTED."; } break; case "SubArea": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { subArea = dataCell; } break; case "Street": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { street = dataCell; } break; case "USMH": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { usmh = dataCell; } break; case "DSMH": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { dsmh = dataCell; } break; case "Size_": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { if (Distance.IsValidDistance(dataCell)) { mapSize = dataCell; } else { bulkUploadResultMessage = "Invalid value in 'Size_' column (" + originalSectionId + "). Bulk upload ABORTED."; bulkUploadProccessed = false; } } break; case "ScaledLength": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { if (Distance.IsValidDistance(dataCell)) { mapLength = dataCell; } else { bulkUploadResultMessage = "Invalid value in 'ScaledLength' column (" + originalSectionId + "). Bulk upload ABORTED."; bulkUploadProccessed = false; } } break; case "ActualLength": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { if (Distance.IsValidDistance(dataCell)) { actualLength = dataCell; } else { bulkUploadResultMessage = "Invalid value in 'ActualLength' column (" + originalSectionId + " " + dataCell + "). Bulk upload ABORTED."; bulkUploadProccessed = false; } } break; case "ConfirmedSize": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { if (Distance.IsValidDistance(dataCell)) { confirmedSize = dataCell; } else { bulkUploadResultMessage = "Invalid value in 'ConfirmedSize' column (" + originalSectionId + "). Bulk upload ABORTED."; bulkUploadProccessed = false; } } break; case "JLiner": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { jlWork = (dataCellToUpper == "YES") ? true : false; } break; case "USMHMN": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { usmhMn = dataCell; } break; case "DSMHMN": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { dsmhMn = dataCell; } break; case "USMHDepth": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { usmhDepth = dataCell; } break; case "DSMHDepth": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { dsmhDepth = dataCell; } break; case "SteelTapeThruPipe": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { steelTapeThruPipe = dataCell; } break; case "USMHAtMouth1200": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { usmhAtMouth1200 = dataCell; } break; case "USMHAtMouth100": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { usmhAtMouth100 = dataCell; } break; case "USMHAtMouth200": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { usmhAtMouth200 = dataCell; } break; case "USMHAtMouth300": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { usmhAtMouth300 = dataCell; } break; case "USMHAtMouth400": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { usmhAtMouth400 = dataCell; } break; case "USMHAtMouth500": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { usmhAtMouth500 = dataCell; } break; case "DSMHAtMouth1200": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { dsmhAtMouth1200 = dataCell; } break; case "DSMHAtMouth100": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { dsmhAtMouth100 = dataCell; } break; case "DSMHAtMouth200": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { dsmhAtMouth200 = dataCell; } break; case "DSMHAtMouth300": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { dsmhAtMouth300 = dataCell; } break; case "DSMHAtMouth400": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { dsmhAtMouth400 = dataCell; } break; case "DSMHAtMouth500": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { dsmhAtMouth500 = dataCell; } break; case "Deleted": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { deleted = (dataCellToUpper == "YES") ? true : false; } break; default: bulkUploadResultMessage = "Invalid column name '" + dataReader.GetName(i) + "' in section data range."; bulkUploadProccessed = false; break; } if (!bulkUploadProccessed) { break; } } if (bulkUploadProccessed && jlWork && !deleted) { DataMigrationGateway dataMigrationGateway = new DataMigrationGateway(null); Guid originalId = dataMigrationGateway.GetOriginalIdByCompanyIdCompaniesIdRecordIdStreet(int.Parse(hdfCompanyId.Value), companiesId, originalSectionId, street); id = id + 1; if (!dataMigrationGateway.IsMigratedSection(originalId, originalSectionId)) { //--- Initialize int companyId = Int32.Parse(hdfCompanyId.Value); DataMigrationTDS dataSet = new DataMigrationTDS(); dataSet.JlDataMigration.Merge(dataMigration, true); JlDataMigration model = new JlDataMigration(dataSet); CompaniesGateway companiesGateway = new CompaniesGateway(); companiesGateway.LoadByCompaniesId(companiesId, companyId); client = companiesGateway.GetName(companiesId); model.Insert(originalId, originalSectionId, companiesId, client, subArea, street, usmh, dsmh, mapSize, mapLength, actualLength, confirmedSize, jlWork, usmhMn, dsmhMn, usmhDepth, dsmhDepth, steelTapeThruPipe, usmhAtMouth1200, usmhAtMouth100, usmhAtMouth200, usmhAtMouth300, usmhAtMouth400, usmhAtMouth500, dsmhAtMouth1200, dsmhAtMouth100, dsmhAtMouth200, dsmhAtMouth300, dsmhAtMouth400, dsmhAtMouth500, 0, 0, false, "No", 0, 0); dataMigration = dataSet.JlDataMigration; Session["dataMigration"] = dataSet.JlDataMigration; } } } } dataReader.Close(); connection.Close(); } } catch (Exception ex) { if (!dataReader.IsClosed) { dataReader.Close(); } if (connection.State == ConnectionState.Open) { connection.Close(); } throw ex; } return (bulkUploadProccessed) ? true : false; }
/// <summary> /// SaveFLLWork /// </summary> /// <param name="projectId"></param> /// <param name="section_assetId"></param> /// <param name="companyId"></param> /// <param name="comments"></param> /// <param name="loginId"></param> private void SaveFLLWork(DataMigrationTDS.DataMigrationRow row, int projectId, int section_assetId, int companyId, string comments, int loginId) { DateTime dateTime_ = DateTime.Now; string commentsToWork = ""; string clientId = ""; if (!row.IsClientIDNull()) clientId = row.ClientID; DateTime? proposedLiningDate = null; if (!row.IsProposedLiningDateNull()) proposedLiningDate = row.ProposedLiningDate; DateTime? deadLineLiningDate = null; if (!row.IsDeadlineDateNull()) deadLineLiningDate = row.DeadlineDate; DateTime? p1Date = null; if (!row.IsP1DateNull()) p1Date = row.P1Date; DateTime? m1Date = null; if (!row.IsM1DateNull()) m1Date = row.M1Date; DateTime? m2Date = null; if (!row.IsM2DateNull()) m2Date = row.M2Date; DateTime? installDate = null; if (!row.IsInstallDateNull()) installDate = row.InstallDate; DateTime? finalVideoDate = null; if (!row.IsFinalVideoNull()) finalVideoDate = row.FinalVideo; bool issueIdentified = row.IssueIdentified; bool issueLFS = row.LFSIssue; bool issueClient = row.ClientIssue; bool issueSales = row.SalesIssue; bool issueGivenToClient = row.IssueGivenToBayCity; bool issueResolved = row.IssueResolved; bool issueInvestigation = row.InvestigationIssue; int? cxisRemoved = null; if (!row.IsCXIsRemovedNull()) cxisRemoved = int.Parse(row.CXIsRemoved); string lineWidthId = ""; if (!row.IsLineWithIDNull()) lineWidthId = row.LineWithID; string measurementsTakenBy = ""; if (!row.IsMeasurementsTakenByNull()) measurementsTakenBy = row.MeasurementsTakenBy; string hydrantAddress = ""; if (!row.IsHydrantAddressNull()) hydrantAddress = row.HydrantAddress; string distanceToInversionMh = ""; if (!row.IsDistanceToInversionMHNull()) distanceToInversionMh = row.DistanceToInversionMH; string trafficControl = ""; if (!row.IsDegreeOfTrafficControlNull()) trafficControl = row.DegreeOfTrafficControl; string hydroWireDetails = ""; if (!row.IsHydroWireDetailsNull()) hydroWireDetails = row.HydroWireDetails; bool rampsRequired = row.RampsRequired; bool pipeSizeChanges = row.PipeSizeChange; bool standarBypass = row.StandarBypass; bool roboticPrepRequired = row.RoboticPrepRequired; bool schoolZone = row.SchoolZone; bool restaurantArea = row.RestaurantArea; bool carswashLaundromat = row.CarwashLaundromat; bool hydroPulley = row.HydroPulley; bool fridgeCart = row.FridgeCart; bool twoPump = row.TwoInchPump; bool sixBypass = row.SixInchBypass; bool scaffolding = row.Scaffolding; bool winchExtension = row.WinchExtension; bool extraGenerator = row.ExtraGenerator; bool greyCableExtension = row.GreyCableExtension; bool easementMats = row.EasementMats; string measurementType = ""; if (!row.IsMeasurementTypeNull()) measurementType = row.MeasurementType; string measurementFromMh = ""; if (!row.IsMeasuredFromManholeNull()) measurementFromMh = row.MeasuredFromManhole; string videoDoneFromMh = ""; if (!row.IsVideoDoneFromNull()) videoDoneFromMh = row.VideoDoneFrom; string videoDoneToMh = ""; if (!row.IsToManholeNull()) videoDoneToMh = row.ToManhole; string videoDistance = ""; if (!row.IsCutterDescriptionDuringMeasuringNull()) videoDistance = row.CutterDescriptionDuringMeasuring; bool dropPipe = row.DropPipe; string dropPipeInvertDepth = ""; if (!row.IsDropPipeInvertDepthNull()) dropPipeInvertDepth = row.DropPipeInvertDepth; int? cappedLaterals = null; if (!row.IsCappedLateralsNull()) cappedLaterals = row.CappedLaterals; string materialType = ""; if (!row.IsPipeMaterialTypeNull()) materialType = row.PipeMaterialType; string usmh = ""; if (!row.IsUSMHNull()) usmh = row.USMH; string dsmh = ""; if (!row.IsDSMHNull()) dsmh = row.DSMH; if (comments != "") { // ... Get user name LoginGateway loginGateway = new LoginGateway(); loginGateway.LoadByLoginId(loginId, companyId); string user = loginGateway.GetLastName(loginId, companyId) + " " + loginGateway.GetFirstName(loginId, companyId); // ... Form the comment string commentsToWork = commentsToWork + dateTime_ + "\n" + "(" + user.Trim() + ") \n Subject: Bulk Upload Comments \n Comment: " + comments; } if (measurementFromMh != "") { if (measurementFromMh.ToUpper() == "USMH" || usmh.Contains(measurementFromMh)) { measurementFromMh = "USMH"; } if (measurementFromMh.ToUpper() == "DSMH" || dsmh.Contains(measurementFromMh)) { measurementFromMh = "DSMH"; } if (measurementFromMh != "USMH" && measurementFromMh != "DSMH") { measurementFromMh = ""; } } if (videoDoneFromMh != "") { if (videoDoneFromMh.ToUpper() == "USMH" || usmh.Contains(videoDoneFromMh)) { videoDoneFromMh = "USMH"; } if (videoDoneFromMh.ToUpper() == "DSMH" || dsmh.Contains(videoDoneFromMh)) { videoDoneFromMh = "DSMH"; } if (videoDoneFromMh != "USMH" && videoDoneFromMh != "DSMH") { videoDoneFromMh = ""; } } if (videoDoneToMh != "") { if (videoDoneToMh.ToUpper() == "USMH" || usmh.Contains(videoDoneToMh)) { videoDoneToMh = "USMH"; } if (videoDoneToMh.ToUpper() == "DSMH" || dsmh.Contains(videoDoneToMh)) { videoDoneToMh = "DSMH"; } if (videoDoneToMh != "USMH" && videoDoneToMh != "DSMH") { videoDoneToMh = ""; } } WorkFullLengthLining workFullLengthLining = new WorkFullLengthLining(null); int workId = workFullLengthLining.InsertDirectEmptyWorks(projectId, section_assetId, null, clientId, proposedLiningDate, deadLineLiningDate, p1Date, m1Date, m2Date, installDate, finalVideoDate, issueIdentified, issueLFS, issueClient, issueSales, issueGivenToClient, issueResolved, false, companyId, issueInvestigation, commentsToWork, ""); if (comments != "") { WorkCommentsGateway workCommentsGateway = new WorkCommentsGateway(); workCommentsGateway.LoadByWorkIdWorkType(workId, companyId, "Full Length Lining"); WorkComments workComments = new WorkComments(workCommentsGateway.Data); workComments.Insert(workId, 0, "Other", "Bulk Upload Comments", loginId, dateTime_, comments, null, false, companyId, false, "Full Length Lining"); // UpdateComments workCommentsGateway.Update(); } if (materialType != "") { DataMigrationGateway dataMigrationGateway = new DataMigrationGateway(null); dataMigrationGateway.InsertMaterial(section_assetId, 1, materialType, dateTime_, false, companyId); } }
private bool ProcessBulkUpload(string fName, out string bulkUploadResultMessage) { bool bulkUploadProccessed = true; bulkUploadResultMessage = ""; AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway(); AppSettingsReader appSettingReader = new AppSettingsReader(); string excelConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties='Excel 8.0;HDR=YES;IMEX=1';Data Source=" + fName + ";"; OleDbConnection connection = new OleDbConnection(excelConnectionString); OleDbCommand command = null; OleDbDataReader dataReader = null; try { try { connection.Open(); command = new OleDbCommand("select * from [sections]", connection); dataReader = command.ExecuteReader(); dataReader.Close(); connection.Close(); } catch (Exception ex) { bulkUploadResultMessage = "You did not define the 'sections' data range. Bulk upload ABORTED. Original message: " + ex.Message; bulkUploadProccessed = false; if (connection.State == ConnectionState.Open) { connection.Close(); } } //--- Process bulk upload if (bulkUploadProccessed) { connection.Open(); command = new OleDbCommand("select * from [sections]", connection); dataReader = command.ExecuteReader(); int id = 0; while (dataReader.Read()) { if (!IsEmptyRow(dataReader)) { string clientId = ""; int companiesId = 0; string client = ""; string subArea = ""; string street = ""; string usmh = ""; string dsmh = ""; string mapSize = ""; //Size_ string mapLength = ""; //ScaledLength DateTime? p1Date = null; string actualLength = ""; // string cxisRemoved = ""; DateTime? m1Date = null; DateTime? m2Date = null; DateTime? installDate = null; DateTime? finalVideo = null; bool issueIdentified = false; bool issueResolved = false; bool fllWork = false; // FLL Work bool issueGivenToBayCity = false; string confirmedSize = ""; DateTime? deadLineDate = null; DateTime? proposedLiningDate = null; bool salesIssue = false; bool lfsIssue = false; bool clientIssue = false; bool investigationIssue = false; bool jlWork = false; // JL work bool raWork = false; // RA Work DateTime? preFlushDate = null; DateTime? preVideoDate = null; string usmhMn = ""; string dsmhMn = ""; string usmhDepth = ""; string dsmhDepth = ""; string measurementsTakenBy = ""; string steelTapeThruPipe = ""; string usmhAtMouth1200 = ""; string usmhAtMouth100 = ""; string usmhAtMouth200 = ""; string usmhAtMouth300 = ""; string usmhAtMouth400 = ""; string usmhAtMouth500 = ""; string dsmhAtMouth1200 = ""; string dsmhAtMouth100 = ""; string dsmhAtMouth200 = ""; string dsmhAtMouth300 = ""; string dsmhAtMouth400 = ""; string dsmhAtMouth500 = ""; string hydrantAdrress = ""; string distanceToInversionMh = ""; bool rampsRequired = false; string degreeOfTrafficControl = ""; bool standarBypass = false; string hydroWireDetails = ""; string pipeMaterialType = ""; int? capedLaterals = null; bool roboticPrepRequired = false; bool pipeSizeChange = false; string videoDoneFrom = ""; string ToManhole = ""; string cutterDescriptionDuringMeasuring = ""; string lineWidthId = ""; bool schoolZone = false; bool restaurantArea = false; bool carswashLaundromat = false; bool hydroPulley = false; bool fridgeCart = false; bool twoInchPump = false; bool sixInchBypass = false; bool scaffolding = false; bool winchExtension = false; bool extraGenerator = false; bool greyCableExtension = false; bool easementMats = false; string measurementType = ""; bool dropPipe = false; string dropPipeInvertDepth = ""; string measurementFromManhole = ""; string dataCell = null; string dataCellToUpper = null; //--- ... fill section row string originalSectionId = dataReader.GetValue(dataReader.GetOrdinal("ID")).ToString().Trim(); for (int i = 0; i < dataReader.FieldCount; i++) { dataCell = dataReader.GetValue(i).ToString().Trim(); dataCellToUpper = dataReader.GetValue(i).ToString().Trim().ToUpper(); switch (dataReader.GetName(i).Trim()) { case "ID": originalSectionId = dataCell; break; case "ClientID": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { clientId = dataCell; } break; case "COMPANIES_ID": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { companiesId = int.Parse(dataCell); } else { string aux = dataReader.GetFieldType(2).ToString(); string aux2 = dataReader.GetDouble(dataReader.GetOrdinal("COMPANIES_ID")).ToString(); string aux3 = dataReader.GetString(dataReader.GetOrdinal("COMPANIES_ID")).ToString(); } break; case "Client": if (dataCellToUpper != "NULL") { client = dataCell; } break; case "SubArea": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { subArea = dataCell; } break; case "Street": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { street = dataCell; } break; case "USMH": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { usmh = dataCell; } break; case "DSMH": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { dsmh = dataCell; } break; case "Size_": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { if (Distance.IsValidDistance(dataCell)) { mapSize = dataCell; } } break; case "ScaledLength": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { if (Distance.IsValidDistance(dataCell)) { mapLength = dataCell; } } break; case "P1Date": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { p1Date = Convert.ToDateTime(dataCell); } break; case "ActualLength": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { if (Distance.IsValidDistance(dataCell)) { actualLength = dataCell; } } break; case "CXIsRemoved": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { cxisRemoved = dataCell; } break; case "M1Date": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { m1Date = Convert.ToDateTime(dataCell); } break; case "M2Date": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { m2Date = Convert.ToDateTime(dataCell); } break; case "InstallDate": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { installDate = Convert.ToDateTime(dataCell); } break; case "FinalVideo": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { finalVideo = Convert.ToDateTime(dataCell); } break; case "IssueIdentified": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { issueIdentified = (dataCellToUpper == "YES") ? true : false; } break; case "IssueResolved": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { issueResolved = (dataCellToUpper == "YES") ? true : false; } break; case "FullLengthLining": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { fllWork = (dataCellToUpper == "YES") ? true : false; } break; case "IssueGivenToBayCity": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { issueGivenToBayCity = (dataCellToUpper == "YES") ? true : false; } break; case "ConfirmedSize": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { if (Distance.IsValidDistance(dataCell)) { confirmedSize = dataCell; } } break; case "DeadlineDate": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { deadLineDate = Convert.ToDateTime(dataCell); } break; case "ProposedLiningDate": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { proposedLiningDate = Convert.ToDateTime(dataCell); } break; case "SalesIssue": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { salesIssue = (dataCellToUpper == "YES") ? true : false; } break; case "LFSIssue": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { lfsIssue = (dataCellToUpper == "YES") ? true : false; } break; case "ClientIssue": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { clientIssue = (dataCellToUpper == "YES") ? true : false; } break; case "InvestigationIssue": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { investigationIssue = (dataCellToUpper == "YES") ? true : false; } break; case "JLiner": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { jlWork = (dataCellToUpper == "YES") ? true : false; } break; case "RehabAssessment": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { raWork = (dataCellToUpper == "YES") ? true : false; } break; case "PreFlushDate": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { preFlushDate = Convert.ToDateTime(dataCell); } break; case "PreVideoDate": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { preVideoDate = Convert.ToDateTime(dataCell); } break; case "USMHMN": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { usmhMn = dataCell; } break; case "DSMHMN": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { dsmhMn = dataCell; } break; case "USMHDepth": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { usmhDepth = dataCell; } break; case "DSMHDepth": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { dsmhDepth = dataCell; } break; case "MeasurementsTakenBy": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { measurementsTakenBy = dataCell; } break; case "SteelTapeThruPipe": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { steelTapeThruPipe = dataCell; } break; case "USMHAtMouth1200": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { usmhAtMouth1200 = dataCell; } break; case "USMHAtMouth100": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { usmhAtMouth100 = dataCell; } break; case "USMHAtMouth200": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { usmhAtMouth200 = dataCell; } break; case "USMHAtMouth300": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { usmhAtMouth300 = dataCell; } break; case "USMHAtMouth400": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { usmhAtMouth400 = dataCell; } break; case "USMHAtMouth500": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { usmhAtMouth500 = dataCell; } break; case "DSMHAtMouth1200": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { dsmhAtMouth1200 = dataCell; } break; case "DSMHAtMouth100": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { dsmhAtMouth100 = dataCell; } break; case "DSMHAtMouth200": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { dsmhAtMouth200 = dataCell; } break; case "DSMHAtMouth300": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { dsmhAtMouth300 = dataCell; } break; case "DSMHAtMouth400": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { dsmhAtMouth400 = dataCell; } break; case "DSMHAtMouth500": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { dsmhAtMouth500 = dataCell; } break; case "HydrantAddress": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { hydrantAdrress = dataCell; } break; case "DistanceToInversionMH": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { distanceToInversionMh = dataCell; } break; case "RampsRequired": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { rampsRequired = (dataCellToUpper == "YES") ? true : false; } break; case "DegreeOfTrafficControl": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { degreeOfTrafficControl = dataCell; } break; case "StandarBypass": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { standarBypass = (dataCellToUpper == "YES") ? true : false; } break; case "HydroWireDetails": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { hydroWireDetails = dataCell; } break; case "PipeMaterialType": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { pipeMaterialType = dataCell; } break; case "CappedLaterals": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { capedLaterals = int.Parse(dataCell); } break; case "RoboticPrepRequired": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { roboticPrepRequired = (dataCellToUpper == "YES") ? true : false; } break; case "PipeSizeChange": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { pipeSizeChange = (dataCellToUpper == "YES") ? true : false; } break; case "VideoDoneFrom": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { videoDoneFrom = dataCell; } break; case "ToManhole": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { ToManhole = dataCell; } break; case "CutterDescriptionDuringMeasuring": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { cutterDescriptionDuringMeasuring = dataCell; } break; case "LineWithID": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { lineWidthId = dataCell; } break; case "SchoolZone": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { schoolZone = (dataCellToUpper == "YES") ? true : false; } break; case "RestaurantArea": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { restaurantArea = (dataCellToUpper == "YES") ? true : false; } break; case "CarwashLaundromat": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { carswashLaundromat = (dataCellToUpper == "YES") ? true : false; } break; case "HydroPulley": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { hydroPulley = (dataCellToUpper == "YES") ? true : false; } break; case "FridgeCart": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { fridgeCart = (dataCellToUpper == "YES") ? true : false; } break; case "TwoInchPump": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { twoInchPump = (dataCellToUpper == "YES") ? true : false; } break; case "SixInchBypass": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { sixInchBypass = (dataCellToUpper == "YES") ? true : false; } break; case "Scaffolding": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { scaffolding = (dataCellToUpper == "YES") ? true : false; } break; case "WinchExtension": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { winchExtension = (dataCellToUpper == "YES") ? true : false; } break; case "ExtraGenerator": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { extraGenerator = (dataCellToUpper == "YES") ? true : false; } break; case "GreyCableExtension": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { greyCableExtension = (dataCellToUpper == "YES") ? true : false; } break; case "EasementMats": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { easementMats = (dataCellToUpper == "YES") ? true : false; } break; case "MeasurementType": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { measurementType = dataCell; } break; case "DropPipe": if ((dataCellToUpper == "YES") || (dataCellToUpper == "NO")) { dropPipe = (dataCellToUpper == "YES") ? true : false; } break; case "DropPipeInvertDepth": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { dropPipeInvertDepth = dataCell; } break; case "MeasuredFromManhole": if (dataCellToUpper != "NULL" && dataCellToUpper != "") { measurementFromManhole = dataCell; } break; default: bulkUploadResultMessage = "Invalid column name '" + dataReader.GetName(i) + "' in section data range."; bulkUploadProccessed = false; break; } if (!bulkUploadProccessed) { break; } } if (bulkUploadProccessed) { DataMigrationGateway dataMigrationGateway = new DataMigrationGateway(null); Guid originalId = dataMigrationGateway.GetOriginalIdByCompanyIdCompaniesIdRecordIdStreet(int.Parse(hdfCompanyId.Value), companiesId, originalSectionId, street); id = id + 1; if (!dataMigrationGateway.IsMigratedSection(originalId, originalSectionId)) { //--- Initialize DataMigrationTDS dataSet = new DataMigrationTDS(); dataSet.DataMigration.Merge(dataMigration, true); DataMigration model = new DataMigration(dataSet); model.Insert(originalId, originalSectionId, clientId, companiesId, client, subArea, street, usmh, dsmh, mapSize, mapLength, p1Date, actualLength, cxisRemoved, m1Date, m2Date, installDate, finalVideo, issueIdentified, issueResolved, fllWork, issueGivenToBayCity, confirmedSize, deadLineDate, proposedLiningDate, salesIssue, lfsIssue, clientIssue, investigationIssue, jlWork, raWork, preFlushDate, preVideoDate, usmhMn, dsmhMn, usmhDepth, dsmhDepth, measurementsTakenBy, steelTapeThruPipe, usmhAtMouth1200, usmhAtMouth100, usmhAtMouth200, usmhAtMouth300, usmhAtMouth400, usmhAtMouth500, dsmhAtMouth1200, dsmhAtMouth100, dsmhAtMouth200, dsmhAtMouth300, dsmhAtMouth400, dsmhAtMouth500, hydrantAdrress, distanceToInversionMh, rampsRequired, degreeOfTrafficControl, standarBypass, hydroWireDetails, pipeMaterialType, capedLaterals, roboticPrepRequired, pipeSizeChange, videoDoneFrom, ToManhole, cutterDescriptionDuringMeasuring, lineWidthId, schoolZone, restaurantArea, carswashLaundromat, hydroPulley, fridgeCart, twoInchPump, sixInchBypass, scaffolding, winchExtension, extraGenerator, greyCableExtension, easementMats, measurementType, dropPipe, dropPipeInvertDepth, measurementFromManhole); dataMigration = dataSet.DataMigration; Session["dataMigration"] = dataSet.DataMigration; } } } } dataReader.Close(); connection.Close(); } } catch (Exception ex) { if (!dataReader.IsClosed) { dataReader.Close(); } if (connection.State == ConnectionState.Open) { connection.Close(); } throw ex; } return (bulkUploadProccessed) ? true : false; }
/// <summary> /// Save /// </summary> /// <param name="projectId">projectId</param> /// <param name="countryId">countryId</param> /// <param name="provinceId">provinceId</param> /// <param name="countyId">countyId</param> /// <param name="cityId">cityId</param> /// <param name="companyId">companyId</param> /// <param name="loginId">loginId</param> public void Save(int companyId, int loginId) { foreach (DataMigrationTDS.DataMigrationRow row in (DataMigrationTDS.DataMigrationDataTable)Table) { // Get ids & location ProjectGateway projectGateway = new ProjectGateway(); DataMigrationProjectGateway dataMigrationProjectGateway = new DataMigrationProjectGateway(null); string name = string.Format("{0} Data Migration Project", row.Client); int projectId = dataMigrationProjectGateway.GetProjectIdByName(name); if (projectId != 0) { projectGateway.LoadByProjectId(projectId); // get parameters Int64 countryId = projectGateway.GetCountryID(projectId); Int64? provinceId = null; if (projectGateway.GetProvinceID(projectId).HasValue) provinceId = projectGateway.GetProvinceID(projectId); Int64? countyId = null; if (projectGateway.GetCountyID(projectId).HasValue) countyId = projectGateway.GetCountyID(projectId); Int64? cityId = null; if (projectGateway.GetCityID(projectId).HasValue) cityId = projectGateway.GetCityID(projectId); //Save section int section_assetId = SaveSection(row, projectId, countryId, provinceId, countyId, cityId, companyId); if (row.RehabAssessment) { string raComments = ""; SaveRAWork(row, projectId, section_assetId, companyId, raComments, loginId); } if (row.FullLengthLining) { string fllComments = ""; SaveFLLWork(row, projectId, section_assetId, companyId, fllComments, loginId); } if (row.JLiner) { SaveJLWork(projectId, section_assetId, companyId); } // Insert in DataMigration Table Guid originalId = row.OriginalID; string originalSectionId = row.OriginalSectionID; AssetSewerSectionGateway assetSewerSectionGateway = new AssetSewerSectionGateway(); assetSewerSectionGateway.LoadByAssetId(section_assetId, companyId); string newSectionId = assetSewerSectionGateway.GetSectionId(section_assetId); DataMigrationGateway dataMigrationGateway = new DataMigrationGateway(null); dataMigrationGateway.InsertDataMigration(originalId, originalSectionId, section_assetId, newSectionId); } } }