/// <summary> /// Runs every 100 msecs /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer_Tick(object sender, System.EventArgs e) { if (waitHandle.WaitOne(0, false)) // gets signal { this.DialogResult = DialogResult.OK; Close(); return; } if (this.timeout != TimeSpan.Zero) { this.timeCounter--; if (this.timeCounter <= 0) { waitHandle.Set(); // signal done (timeout) this.operationTimeout = true; this.DialogResult = DialogResult.Abort; Close(); return; } } // update progress bar info if (progressBar.Value + progressBar.Step >= progressBar.Maximum) { progressBar.Value = 0; } else { progressBar.Increment(progressBar.Step); } }
public static void UpdatePbar(System.Windows.Forms.ProgressBar name, int step) { if (name.InvokeRequired) { object[] params_list = new object[] { name, step }; name.Invoke(new UpdateProgressBar(UpdatePbar), params_list); } else { name.Increment(step); } }
/// <summary> /// Increments the progress bar by one. Updates the percent complete in the title. /// </summary> /// <remarks><pre> ///Revision History ///MM/DD/YY who Version Issue# Description ///-------- --- ------- ------ --------------------------------------------- ///08/26/04 REM 7.00.15 N/A Initial Release ///</pre></remarks> public virtual void IncrementProgress() { try { m_pbrProgress.Increment(1); SetTitle(m_strTitle); Refresh(); } catch (Exception e) { MessageBox.Show(e.Message); } }
private void IncreaseProgressBar(object sender, EventArgs e) { // Increment the value of the ProgressBar a value of one each time. progressBar1.Increment(1); // Display the textual value of the ProgressBar in the StatusBar control's first panel. statusBarPanel1.Text = progressBar1.Value.ToString() + "% Completed"; // Determine if we have completed by comparing the value of the Value property to the Maximum value. if (progressBar1.Value == progressBar1.Maximum) { // Stop the timer. time.Stop(); } }
void UpdateProgressBar() { if (_ProgressBar.InvokeRequired) { MethodInvoker updateProgressBar = UpdateProgressBar; _ProgressBar.BeginInvoke(updateProgressBar); } else { _ProgressBar.Increment(1); } }
private void cmdMake_Click(object sender, System.EventArgs e) { if (chkSameOutputFolder.Checked == false && txtWorkingFolder.Text.Equals(txtOutputFolder.Text)) { MessageBox.Show("Output folder can not be same as input folder", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { this.Cursor = Cursors.WaitCursor; statusBarPanel1.Text = "Busy"; Application.DoEvents(); WaterMark wm; string srcPic, dstPic; for (int i = 0; i < lstFileList.CheckedItems.Count; i++) { //srcPic = txtWorkingFolder.Text + lstFileList.Items[i].ToString().Substring(1); srcPic = txtWorkingFolder.Text + lstFileList.Items[i].ToString().Substring(lstFileList.Items[i].ToString().LastIndexOf("\\")); if (chkSameOutputFolder.Checked == true) { dstPic = srcPic.Insert(srcPic.LastIndexOf("."), txtSuffix.Text); } else { dstPic = txtOutputFolder.Text + "\\" + srcPic.Substring(srcPic.LastIndexOf("\\") + 1); } new WaterMark(srcPic).SaveImage(_buttons.getWotermarks(), dstPic); //wm.MarkImage(srcPic, dstPic); progressBar1.Increment(1); statusBarPanel2.Text = "Proecessing Image " + srcPic.Substring(lstFileList.Items[i].ToString().LastIndexOf("\\") + 1); Application.DoEvents(); } progressBar1.Value = 0; statusBarPanel1.Text = "Ready"; statusBarPanel2.Text = ""; this.Cursor = Cursors.Default; Application.DoEvents(); } catch (Exception ex) { progressBar1.Value = 0; statusBarPanel1.Text = "Ready"; statusBarPanel2.Text = ex.Message; this.Cursor = Cursors.Default; Application.DoEvents(); } }
// bardzo wolny filtr kolorow (nasycenie poszczegolnych składowych) //!: znowu unsafe i iteracje po wskaznikach by się chyba przydały public static Bitmap GetFiltered(Bitmap bmp,Color c, ProgressBar pb = null) { float r,g,b; for(int x = 0; x < bmp.Width; x++) { for (int y = 0; y < bmp.Height; y++) { Color get = bmp.GetPixel(x, y); r = (c.R > 0) ? (float)get.R * ((float)c.R / 255) : 0; g = (c.G > 0) ? (float)get.G * ((float)c.G / 255) : 0; b = (c.B > 0) ? (float)get.B * ((float)c.B / 255) : 0; Color set = Color.FromArgb((int)r,(int)g,(int)b); bmp.SetPixel(x, y, set); if (pb != null) pb.Increment(1); } } return bmp; }
private void generateObjByType(List<string> typeList, string ownerName, string rootPath, List<string> pathList, ProgressBar fileBar) { int i = 0; foreach (var type in typeList) { i++; GenerateTemplate template = TemplateFactory.getInstance(type); List<string> objNameList = template.getObjNameList(type); string scriptStr = template.generateObjList(objNameList, type); string path = template.writeStringToDisk(rootPath, type, scriptStr, ownerName); pathList.Add(path); for (int j = 1; j < objNameList.Count()+1; j++) { int incre = 100 / i / j; fileBar.Increment(incre); } } }
private void Update_Tick(object sender, EventArgs e) { pbProgress.Increment(1); if (pbProgress.Value == 25) { if (!Directory.Exists(Application.ExecutablePath + "\\Files")) { //Directory.CreateDirectory(Application.ExecutablePath + "\\Files"); } } if (pbProgress.Value == 100) { if (_globalBooleanSettingsManager.GetIsInBetaMode()) { New.MainWindow mainWindow = new New.MainWindow(); //_fadeEffects.FadeOutWindow(this, mainWindow); Hide(); mainWindow.Show(); _tmrUpdate.Stop(); } else { MainWindow mainWindow = new MainWindow(); //_fadeEffects.FadeOutWindow(this, mainWindow); Hide(); mainWindow.Show(); _tmrUpdate.Stop(); } } }
/// <summary> // SOURCE: did up where this cam efrom /// xDirectory.Copy() - Copy a Source Directory /// and it's SubDirectories/Files /// </summary> /// <param name="diSource">The Source Directory</param> /// <param name="diDestination">The Destination Directory</param> /// <param name="FileFilter">The File Filter /// (Standard Windows Filter Parameter, Wildcards: "*" and "?")</param> /// <param name="DirectoryFilter">The Directory Filter /// (Standard Windows Filter Parameter, Wildcards: "*" and "?")</param> /// <param name="Overwrite">Whether or not to Overwrite /// a Destination File if it Exists.</param> /// <param name="FolderLimit">Iteration Limit - Total Number /// of Folders/SubFolders to Copy</param> public static void Copy(DirectoryInfo diSource, DirectoryInfo diDestination, string FileFilter, string DirectoryFilter, bool Overwrite, int FolderLimit, ProgressBar bar) { int iterator = 0; List<DirectoryInfo> diSourceList = new List<DirectoryInfo>(); List<FileInfo> fiSourceList = new List<FileInfo>(); try { ///// Error Checking ///// if (diSource == null) throw new ArgumentException("Source Directory: NULL"); if (diDestination == null) throw new ArgumentException("Destination Directory: NULL"); if (!diSource.Exists) throw new IOException("Source Directory: Does Not Exist"); if (!(FolderLimit > 0)) throw new ArgumentException("Folder Limit: Less Than 1"); if (DirectoryFilter == null || DirectoryFilter == string.Empty) DirectoryFilter = "*"; if (FileFilter == null || FileFilter == string.Empty) FileFilter = "*"; if (bar == null) throw new ArgumentException("Copy - Progress Bar: NULL"); ///// Add Source Directory to List ///// diSourceList.Add(diSource); ///// First Section: Get Folder/File Listing ///// while (iterator < diSourceList.Count && iterator < FolderLimit) { foreach (DirectoryInfo di in diSourceList[iterator].GetDirectories(DirectoryFilter)) diSourceList.Add(di); foreach (FileInfo fi in diSourceList[iterator].GetFiles(FileFilter)) fiSourceList.Add(fi); iterator++; } if (bar != null) { bar.Maximum = fiSourceList.Count; bar.Minimum = 0; bar.Step = 1; bar.Value = 0; } ///// Second Section: Create Folders from Listing ///// foreach (DirectoryInfo di in diSourceList) { if (di.Exists) { string sFolderPath = diDestination.FullName + @"\" + di.FullName.Remove(0, diSource.FullName.Length); ///// Prevent Silly IOException ///// if (!Directory.Exists(sFolderPath)) Directory.CreateDirectory(sFolderPath); } } ///// Third Section: Copy Files from Listing ///// foreach (FileInfo fi in fiSourceList) { if (fi.Exists) { string sFilePath = diDestination.FullName + @"\" + fi.FullName.Remove(0, diSource.FullName.Length); //// Better Overwrite Test W/O IOException from CopyTo() //// if (Overwrite) fi.CopyTo(sFilePath, true); else { ///// Prevent Silly IOException ///// if (!File.Exists(sFilePath)) fi.CopyTo(sFilePath, true); } if (bar != null) { bar.Increment(1); } } } } catch { throw; } }
private void btnClickMe_Click(object sender, System.EventArgs e) { progressBar.Increment(5); lbResults.Items.Add("I've been clicked!"); }
private void UpdateProgressInvoker(int delta, ProgressBar p) { p.Increment(delta); }
private void IncrementProgress( ProgressBar pb, int val ) { pb.Increment ( val ); }
public void Increment(int value) { ProgressBar.Increment(value); }
/*Precondition: Postcondition: Loops through list of stock passed in, and inserts them into SQLite DB*/ public void insertOrders(List<Order> allOrders, ProgressBar progBar) { //Check to see if orders table exists if (checkForTable("Orders")) { //Open DB and start transcation - transaction hugely increases speed of insert dbConnection.Open(); SQLiteTransaction transaction = dbConnection.BeginTransaction(); //Loop through all stock foreach (Order o in allOrders) { string orderInsert = ""; string firstName = SyntaxHelper.escapeSingleQuotes(o.firstName); string lastName = SyntaxHelper.escapeSingleQuotes(o.lastName); string institution = SyntaxHelper.escapeSingleQuotes(o.institution); string postcode = SyntaxHelper.escapeSingleQuotes(o.postcode); string orderReference = SyntaxHelper.escapeSingleQuotes(o.orderReference); string progress = SyntaxHelper.escapeSingleQuotes(o.progress); double freightCost = o.freightCost; int invoiceNo = o.invoiceNo; DateTime invoiceDate = o.invoiceDate; string comments = SyntaxHelper.escapeSingleQuotes(o.comments); int customerID = o.customerID; int orderID = o.orderID; //Build insert command. If order has an ID insert it with that ID if not (new order) and insert with a new ID using autoincrement from SQLite if (o.orderID == -1) { orderInsert = "INSERT INTO Orders VALUES(null, '" + firstName + "', '" + lastName + "', '" + institution + "', '" + postcode + "', '" + orderReference + "', '" + progress + "', '" + freightCost + "', '" + invoiceNo + "', '" + invoiceDate.ToString("yyyy-MM-dd HH:mm:ss") + "', '" + comments + "', '" + customerID + "')"; } else { orderInsert = "INSERT INTO Orders VALUES(" + orderID + ", '" + firstName + "', '" + lastName + "', '" + institution + "', '" + postcode + "', '" + orderReference + "', '" + progress + "', '" + freightCost + "', '" + invoiceNo + "', '" + invoiceDate.ToString("yyyy-MM-dd HH:mm:ss") + "', '" + comments + "', '" + customerID + "')"; } SQLiteCommand insertCommand = new SQLiteCommand(orderInsert, dbConnection); insertCommand.ExecuteNonQuery(); //Update UI for user to see progress progBar.Increment(1); } //Commit transaction and close connection transaction.Commit(); dbConnection.Close(); } }
public void exportarExcelDiametricClass(ProgressBar bar, DataGridView data, string Type, int numCLass) { try { SaveFileDialog fichero = new SaveFileDialog(); bar.Visible = true; ProjectBL pyBl = new ProjectBL(Program.ContextData); PROYECTO project = (PROYECTO)Program.Cache.Get("project"); if (project != null) { fichero.Filter = "Excel (*.xls)|*.xls"; fichero.FileName = "Reporte "+ Type+" clases diametricas "+ project.LUGAR + " "+ DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year; if (fichero.ShowDialog() == DialogResult.OK) { //hacer visible la barra de progreso y fijar el valor maximo con el numero de registros a exportar bar.Visible = true; aplicacion = new excel.Application(); libros_trabajo = aplicacion.Workbooks.Add(); excel.Worksheet hoja_reporte; hoja_reporte = (excel.Worksheet)libros_trabajo.Worksheets.get_Item(1); hoja_reporte.Name = "Reporte Clases Diametricas"; hoja_reporte.Cells[1, 1] = "Informacion del proyecto"; hoja_reporte.Cells[1, 1].Font.Bold = true; hoja_reporte.Range[hoja_reporte.Cells[1, 1], hoja_reporte.Cells[1, data.Columns.Count]].Merge(); hoja_reporte.Cells[2, 1] = "Lugar"; hoja_reporte.Cells[2, 1].Font.Bold = true; hoja_reporte.Cells[2, 2] = project.LUGAR.ToString(); hoja_reporte.Cells[2, 2].HorizontalAlignment =Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter; hoja_reporte.Cells[2, 2].WrapText = true; hoja_reporte.Cells[3, 1] = "Descripcion"; hoja_reporte.Cells[3, 1].Font.Bold = true; hoja_reporte.Cells[3, 2] = project.DESCRIPCION.ToString(); hoja_reporte.Cells[3, 2].HorizontalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter; hoja_reporte.Cells[3, 2].WrapText = true; hoja_reporte.Cells[4, 1] = "Responsable"; hoja_reporte.Cells[4, 1].Font.Bold = true; hoja_reporte.Cells[4, 2] = project.USUARIO.NOMBRES.ToString() + " " + project.USUARIO.APELLIDOS.ToString(); hoja_reporte.Cells[4, 2].HorizontalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter; hoja_reporte.Cells[4, 2].WrapText = true; hoja_reporte.Cells[5, 1] = "Reporte " + Type; hoja_reporte.Cells[5, 1].Font.Bold = true; hoja_reporte.Range[hoja_reporte.Cells[5, 1], hoja_reporte.Cells[5, data.Columns.Count]].Merge(); hoja_reporte.get_Range("A1", "O" + data.Columns.Count).HorizontalAlignment = excel.XlVAlign.xlVAlignCenter; hoja_reporte.get_Range("A" + data.Rows.Count + 6, "O" + data.Columns.Count).HorizontalAlignment = excel.XlVAlign.xlVAlignCenter; int col = 1; foreach (DataGridViewColumn column in data.Columns) { hoja_reporte.Cells[6, col].NumberFormat = "@"; hoja_reporte.Cells[6, col] = column.HeaderText.ToString(); hoja_reporte.Cells[6, col].WrapText = true; hoja_reporte.Cells[6, col].Font.Bold = true; col++; } int i = 7; bar.Minimum = 0; bar.Maximum = data.Rows.Count; foreach (DataGridViewRow row in data.Rows) { //de formulario extraer coord x y Y el estrato la linea numero de parcela y el usuario se puede hay que revisar muy bien esta parte int j = 1; foreach (DataGridViewTextBoxCell cell in row.Cells) { hoja_reporte.Cells[i, j].WrapText = true; hoja_reporte.Cells[i, j] = cell.Value.ToString(); if (j <= (data.Columns.Count - (numCLass + 3))) { hoja_reporte.Cells[i, j].Font.Bold = true; } j++; } bar.Increment(1); i++; } libros_trabajo.Worksheets.Add(hoja_reporte); MessageBox.Show("Los datos se exportaron correctamente.", "Operacion exitosa", MessageBoxButtons.OK, MessageBoxIcon.Information); bar.Visible = false; libros_trabajo.SaveAs(fichero.FileName, excel.XlFileFormat.xlWorkbookNormal); libros_trabajo.Close(true); aplicacion.Quit(); System.Diagnostics.Process.Start(fichero.FileName); } } else MessageBox.Show("No existe un proyecto abierto dentro del sistema.", "Operacion invalida", MessageBoxButtons.OK, MessageBoxIcon.Error); bar.Visible = false; } catch (Exception ex) { bar.Visible = false; Error_Form errorForm = new Error_Form(ex.Message); errorForm.Show(); } }
public void IncrementProgressBar(int val) { progressBar.Increment(val); }
public void Styles () { ProgressBar c = new ProgressBar (); //-- Assert.AreEqual(ProgressBarStyle.Blocks, c.Style, "orig=blocks"); //-- c.Style = ProgressBarStyle.Continuous; //-- c.Style = ProgressBarStyle.Marquee; // Increment and PerformStep are documented to fail in Marquee style. try { c.Increment (5); Assert.Fail ("should have thrown -- Increment"); } catch (InvalidOperationException) { } try { c.PerformStep (); Assert.Fail ("should have thrown -- PerformStep "); } catch (InvalidOperationException) { } // What about the other value-related properties? No fail apparently! c.Value = 20; c.Minimum = 5; c.Maximum = 95; //-- // Now undefined style values... try { c.Style = (ProgressBarStyle)4; Assert.Fail("should have thrown -- bad style4"); } catch (global::System.ComponentModel.InvalidEnumArgumentException ex) { //Console.WriteLine(ex.Message); Assert.AreEqual(typeof(global::System.ComponentModel.InvalidEnumArgumentException), ex.GetType (), "Typeof bad style4"); Assert.AreEqual("value", ex.ParamName, "ParamName bad style 4"); } try { c.Style = (ProgressBarStyle)99; Assert.Fail("should have thrown -- bad style99"); } catch (global::System.ComponentModel.InvalidEnumArgumentException ex) { Assert.AreEqual (typeof(global::System.ComponentModel.InvalidEnumArgumentException), ex.GetType (), "Typeof bad style99"); Assert.AreEqual ("value", ex.ParamName, "ParamName bad style 99"); } }
/*Precondition: Postcondition: Loops through list of customers passed in, and inserts them into SQLite DB*/ public void insertCustomers(List<Customer> customers, ProgressBar progBar) { //Check to see if customer table exists if (checkForTable("Customer")) { //Open DB and start transcation - transaction hugely increases speed of insert dbConnection.Open(); SQLiteTransaction transaction = dbConnection.BeginTransaction(); //Loop through all customers foreach (Customer c in customers) { int custID = c.custID; string firstName = SyntaxHelper.escapeSingleQuotes(c.firstName); string lastName = SyntaxHelper.escapeSingleQuotes(c.lastName); string institution = SyntaxHelper.escapeSingleQuotes(c.institution); string address1 = SyntaxHelper.escapeSingleQuotes(c.address1); string address2 = SyntaxHelper.escapeSingleQuotes(c.address2); string address3 = SyntaxHelper.escapeSingleQuotes(c.address3); string country = SyntaxHelper.escapeSingleQuotes(c.country); string postcode = SyntaxHelper.escapeSingleQuotes(c.postCode); string email = SyntaxHelper.escapeSingleQuotes(c.email); string comments = SyntaxHelper.escapeSingleQuotes(c.comments); string sales = SyntaxHelper.escapeSingleQuotes(c.sales); string payment = SyntaxHelper.escapeSingleQuotes(c.payment); string customerInsert = ""; //Build insert command. If customer has an ID insert it with that ID if not (new customer) and insert with a new ID using autoincrement from SQLite if (c.custID == -1) { customerInsert = "INSERT INTO Customer VALUES(null, '" + firstName + "', '" + lastName + "', '" + institution + "', '" + address1 + "', '" + address2 + "', '" + address3 + "', '" + country + "', '" + postcode + "', '" + email + "', '" + comments + "', '" + sales + "', '" + payment + "')"; } else { customerInsert = "INSERT INTO Customer VALUES(" + custID + ", '" + firstName + "', '" + lastName + "', '" + institution + "', '" + address1 + "', '" + address2 + "', '" + address3 + "', '" + country + "', '" + postcode + "', '" + email + "', '" + comments + "', '" + sales + "', '" + payment + "')"; } SQLiteCommand insertCommand = new SQLiteCommand(customerInsert, dbConnection); insertCommand.ExecuteNonQuery(); //Update UI for user to see progress progBar.Increment(1); } //Commit transaction and close connection transaction.Commit(); dbConnection.Close(); } }
public void PerformStepAndIncrement () { ProgressBar c = new ProgressBar (); // c.Value = 10; c.Step = 30; Assert.AreEqual (10, c.Value, "StepAt30_Init"); c.PerformStep (); Assert.AreEqual (40, c.Value, "StepAt30_1"); c.PerformStep (); Assert.AreEqual (70, c.Value, "StepAt30_2"); // c.Value = 0; c.Step = 20; Assert.AreEqual (0, c.Value, "StepAt20_Init"); // c.PerformStep (); Assert.AreEqual (20, c.Value, "StepAt20_1"); c.PerformStep (); Assert.AreEqual (40, c.Value, "StepAt20_2"); c.PerformStep (); Assert.AreEqual (60, c.Value, "StepAt20_3"); c.PerformStep (); Assert.AreEqual (80, c.Value, "StepAt20_4"); c.PerformStep (); Assert.AreEqual (100, c.Value, "StepAt20_5"); c.PerformStep (); Assert.AreEqual (100, c.Value, "StepAt20_6x"); c.PerformStep (); Assert.AreEqual (100, c.Value, "StepAt20_7x"); // c.Step = -20; Assert.AreEqual (100, c.Value, "StepAt2Neg0_Init"); c.PerformStep (); Assert.AreEqual (80, c.Value, "StepAtNeg20_1"); c.PerformStep (); Assert.AreEqual (60, c.Value, "StepAtNeg20_2"); // c.Step = -40; Assert.AreEqual (60, c.Value, "StepAt2Neg40_Init"); c.PerformStep (); Assert.AreEqual (20, c.Value, "StepAtNeg40_1"); c.PerformStep (); Assert.AreEqual (0, c.Value, "StepAtNeg40_2"); c.PerformStep (); Assert.AreEqual (0, c.Value, "StepAtNeg40_2"); // c.Increment (30); Assert.AreEqual (30, c.Value, "Increment30_1"); c.Increment (30); Assert.AreEqual (60, c.Value, "Increment30_2"); c.Increment (30); Assert.AreEqual (90, c.Value, "Increment30_3"); c.Increment (30); Assert.AreEqual (100, c.Value, "Increment30_4x"); }
internal static int runTransform(MigrationData theMigr, FeatureMappingData theMap, ProgressBar thePB) { IFields outFields; IQueryFilter QF; IFeature outF; IRow outR = null; String FldName, PKPre; String defValue = ""; String recPriKey = ""; AttributeMappingData theAttMap; ITopologicalOperator theTopo; DataLossEntries theDL; IMAware MM; IZAware ZZ; IGeometry GG; Boolean hasConversion = false; IZ ZF; IPoint PP; IPolygon AA; IPolyline LL; IMCollection MColl; IMSegmentation2 MSeg; int inType, outType, L1, L2; Double inVal; Int32 M, T; Int32 PKNum; int inPos, sNum; ITable outTB = null; esriFieldType TIn; esriFieldType TOut; IFeatureClass srcFC = GeoDbProcs.GetFeatureClass(theMigr.srcWS, theMap.srcFC); IFeatureClass destFC = GeoDbProcs.GetFeatureClass(theMigr.destWS, theMap.destFC); int MoveQty = GeoDbProcs.GetFeatureCount(theMap.srcFC, theMigr.srcWS); int FeatCnt = GeoDbProcs.GetFeatureCount(theMap.destFC, theMigr.destWS); IEnumIndex theSPIndexes = destFC.Indexes.FindIndexesByFieldName(destFC.ShapeFieldName); theSPIndexes.Reset(); IIndex theSP = theSPIndexes.Next(); if (theSP != null) { destFC.DeleteIndex(theSP); } IWorkspaceEdit outWE = (IWorkspaceEdit)theMigr.destWS; outWE.StartEditing(false); outWE.StartEditOperation(); thePB.Visible = true; thePB.Maximum = MoveQty; thePB.Value = 0; Boolean FirstRecord = true; IFeatureCursor allFeats = srcFC.Search(null, false); if (theMigr.splitNon) { outTB = GeoDbProcs.GetTable(theMigr.destWS, theMigr.preSplit + theMap.destFC); } IFeature srcF = allFeats.NextFeature(); int PKCounter = FeatCnt + 1; while (srcF != null) { try { if (theMigr.splitNon) { outR = outTB.CreateRow(); } outF = destFC.CreateFeature(); outFields = outF.Fields; // populate the indicated default values for (int m = 1; m < outFields.FieldCount; m++) if (outFields.get_Field(m).Type != esriFieldType.esriFieldTypeGeometry) if (outFields.get_Field(m).Editable) if (outFields.get_Field(m).DefaultValue != null) { outF.set_Value(m, outFields.get_Field(m).DefaultValue); } // translate and reproject the geometry for (int m = 1; m < outFields.FieldCount; m++) { if (outFields.get_Field(m).Type == esriFieldType.esriFieldTypeGeometry) { # region geometryTransformation switch (theMap.zmTransform) { case 0: // No M or Z Value Changes switch (srcF.Shape.GeometryType) { case esriGeometryType.esriGeometryPoint: // geometry is Point GG = srcF.ShapeCopy; PP = (IPoint)GG; if (theMap.geomTransform == 4 && theMigr.ptToPolygon) { theTopo = (ITopologicalOperator)PP; IPolygon newP = (IPolygon)theTopo.Buffer(1.0); ZZ = (IZAware)newP; if (ZZ.ZAware != true) { ZZ.ZAware = true; IPolygon thePoly = (IPolygon)ZZ; IZ thePZ = (IZ)thePoly; thePZ.SetConstantZ(PP.Z); newP = (IPolygon)thePZ; } outF.Shape = newP; } else if (theMap.geomTransform == 4) { GeoDbProcs.DeleteFeature(destFC, outF.OID); } else { outF.Shape = PP; } break; case esriGeometryType.esriGeometryPolyline: // geometry is line GG = srcF.Shape; LL = (IPolyline)GG; if (theMap.geomTransform == 3 && theMigr.PolylineToPt) { } outF.Shape = LL; break; case esriGeometryType.esriGeometryPolygon: GG = srcF.Shape; AA = (IPolygon)GG; if (theMap.geomTransform == 1) { IArea theA = (IArea)AA; IPoint theP = null; if (theMigr.PolygonToPtI) { theP = theA.LabelPoint; } if (theMigr.PolygonToPtA) { theP = theA.Centroid; } outF.Shape = theP; } else if (theMap.geomTransform == 2) { theTopo = (ITopologicalOperator)AA; IGeometry theL = theTopo.Boundary; outF.Shape = theL; } else { outF.Shape = AA; } break; default: outF.Shape = srcF.ShapeCopy; break; } break; case 1: // remove Z values on source geometries switch (srcF.Shape.GeometryType) { case esriGeometryType.esriGeometryPoint: GG = srcF.Shape; PP = (IPoint)GG; ZZ = (IZAware)PP; if (ZZ.ZAware) { ZZ.DropZs(); ZZ.ZAware = false; } PP = (IPoint)ZZ; if (theMap.geomTransform == 4 && theMigr.ptToPolygon) { theTopo = (ITopologicalOperator)PP; IGeometry theP = theTopo.Buffer(1.0); outF.Shape = theP; } else { outF.Shape = PP; } break; case esriGeometryType.esriGeometryPolyline: GG = srcF.Shape; LL = (IPolyline)GG; ZZ = (IZAware)LL; if (ZZ.ZAware) { ZZ.DropZs(); ZZ.ZAware = false; } LL = (IPolyline)ZZ; outF.Shape = LL; break; case esriGeometryType.esriGeometryPolygon: GG = srcF.Shape; AA = (IPolygon)GG; ZZ = (IZAware)AA; if (ZZ.ZAware) { ZZ.DropZs(); ZZ.ZAware = false; } AA = (IPolygon)ZZ; if (theMap.geomTransform == 1) { IArea theA = (IArea)AA; IPoint theP = null; if (theMigr.PolygonToPtI) { theP = theA.LabelPoint; } if (theMigr.PolygonToPtA) { theP = theA.Centroid; } outF.Shape = theP; } else if (theMap.geomTransform == 2) { theTopo = (ITopologicalOperator)AA; IGeometry theL = theTopo.Boundary; outF.Shape = theL; } else { outF.Shape = AA; } break; } break; case 2: // add default Z Values switch (srcF.Shape.GeometryType) { case esriGeometryType.esriGeometryPoint: GG = srcF.Shape; PP = (IPoint)GG; ZZ = (IZAware)PP; if (ZZ.ZAware != true) { ZZ.ZAware = true; } PP = (IPoint)ZZ; PP.Z = theMigr.DefZ; if (theMap.geomTransform == 4 && theMigr.ptToPolygon) { theTopo = (ITopologicalOperator)GG; IGeometry theP = theTopo.Buffer(1.0); ZZ = (IZAware)theP; if (ZZ.ZAware != true) { ZZ.ZAware = true; IPolygon thePoly = (IPolygon)ZZ; IZ thePZ = (IZ)thePoly; thePZ.SetConstantZ(theMigr.DefZ); theP = (IPolygon)thePZ; } outF.Shape = theP; } else if (theMap.geomTransform == 4) { GeoDbProcs.DeleteFeature(destFC, outF.OID); } else { outF.Shape = PP; } break; case esriGeometryType.esriGeometryPolyline: GG = srcF.Shape; LL = (IPolyline)GG; ZZ = (IZAware)LL; if (ZZ.ZAware != true) { ZZ.ZAware = true; } LL = (IPolyline)ZZ; ZF = (IZ)LL; ZF.SetConstantZ(theMigr.DefZ); LL = (IPolyline)ZF; outF.Shape = LL; break; case esriGeometryType.esriGeometryPolygon: GG = srcF.Shape; AA = (IPolygon)GG; if (theMap.geomTransform == 1) { IArea theA = (IArea)AA; IPoint theP = null; if (theMigr.PolygonToPtI) { theP = theA.LabelPoint; } if (theMigr.PolygonToPtA) { theP = theA.Centroid; } ZZ = (IZAware)theP; if (ZZ.ZAware != true) { ZZ.ZAware = true; } theP.Z = theMigr.DefZ; outF.Shape = theP; } else if (theMap.geomTransform == 2) { theTopo = (ITopologicalOperator)AA; IGeometry theL = theTopo.Boundary; ZZ = (IZAware)theL; if (ZZ.ZAware != true) { ZZ.ZAware = true; } theL = (IGeometry)ZZ; ZF = (IZ)theL; ZF.SetConstantZ(theMigr.DefZ); theL = (IGeometry)ZF; outF.Shape = theL; } else { ZZ = (IZAware)AA; if (ZZ.ZAware != true) { ZZ.ZAware = true; } AA = (IPolygon)ZZ; ZF = (IZ)AA; ZF.SetConstantZ(theMigr.DefZ); AA = (IPolygon)ZF; outF.Shape = AA; } break; } break; case 3: // remove M values switch (srcF.Shape.GeometryType) { case esriGeometryType.esriGeometryPoint: GG = srcF.Shape; PP = (IPoint)GG; MM = (IMAware)PP; if (MM.MAware == true) { MM.DropMs(); MM.MAware = false; } PP = (IPoint)MM; if (theMap.geomTransform == 4 && theMigr.ptToPolygon) { theTopo = (ITopologicalOperator)PP; IGeometry theP = theTopo.Buffer(1.0); ZZ = (IZAware)theP; if (ZZ.ZAware != true) { ZZ.ZAware = true; } theP = (IPolygon)ZZ; ZF = (IZ)theP; ZF.SetConstantZ(PP.Z); theP = (IPolygon)ZF; outF.Shape = theP; } else { outF.Shape = PP; } break; case esriGeometryType.esriGeometryPolyline: GG = srcF.Shape; LL = (IPolyline)GG; MM = (IMAware)LL; if (MM.MAware == true) { MM.DropMs(); MM.MAware = false; } LL = (IPolyline)MM; outF.Shape = LL; break; case esriGeometryType.esriGeometryPolygon: GG = srcF.Shape; AA = (IPolygon)GG; MM = (IMAware)AA; if (MM.MAware == true) { MM.DropMs(); MM.MAware = false; } AA = (IPolygon)MM; if (theMap.geomTransform == 1) { IArea theA = (IArea)AA; IPoint theP = null; if (theMigr.PolygonToPtI) { theP = theA.LabelPoint; } if (theMigr.PolygonToPtA) { theP = theA.Centroid; } outF.Shape = theP; } else if (theMap.geomTransform == 2) { theTopo = (ITopologicalOperator)AA; IGeometry theL = theTopo.Boundary; outF.Shape = theL; } else { outF.Shape = AA; } break; } break; case 4: // Add M's to geometry switch (srcF.Shape.GeometryType) { case esriGeometryType.esriGeometryPoint: GG = srcF.Shape; PP = (IPoint)GG; MM = (IMAware)PP; if (MM.MAware != true) { MM.MAware = true; } PP = (IPoint)MM; if (theMap.geomTransform == 4 && theMigr.ptToPolygon) { theTopo = (ITopologicalOperator)PP; IGeometry theP = theTopo.Buffer(1.0); outF.Shape = theP; } else { outF.Shape = PP; } outF.Shape = PP; break; case esriGeometryType.esriGeometryPolyline: GG = srcF.Shape; LL = (IPolyline)GG; MM = (IMAware)LL; if (MM.MAware != true) { MM.MAware = true; } LL = (IPolyline)MM; MColl = (IMCollection)LL; MSeg = (IMSegmentation2)MColl; MSeg.SetMsAsDistance(true); LL = (IPolyline)MSeg; outF.Shape = LL; break; case esriGeometryType.esriGeometryPolygon: GG = srcF.Shape; AA = (IPolygon)GG; MM = (IMAware)AA; if (MM.MAware != true) { MM.MAware = true; } AA = (IPolygon)MM; MColl = (IMCollection)AA; MSeg = (IMSegmentation2)MColl; MSeg.SetMsAsDistance(true); AA = (IPolygon)MSeg; if (theMap.geomTransform == 1) { IArea theA = (IArea)AA; IPoint theP = null; if (theMigr.PolygonToPtI) { theP = theA.LabelPoint; } if (theMigr.PolygonToPtA) { theP = theA.Centroid; } outF.Shape = theP; } else if (theMap.geomTransform == 2) { theTopo = (ITopologicalOperator)AA; IGeometry theL = theTopo.Boundary; outF.Shape = theL; } else { outF.Shape = AA; } break; } break; case 5: // remove both M and Z Values switch (srcF.Shape.GeometryType) { case esriGeometryType.esriGeometryPoint: GG = srcF.Shape; PP = (IPoint)GG; MM = (IMAware)PP; if (MM.MAware == true) { MM.DropMs(); MM.MAware = false; } PP = (IPoint)MM; ZZ = (IZAware)PP; ZZ.DropZs(); ZZ.ZAware = false; PP = (IPoint)ZZ; if (theMap.geomTransform == 4 && theMigr.ptToPolygon) { theTopo = (ITopologicalOperator)PP; IGeometry theP = theTopo.Buffer(1.0); outF.Shape = theP; } else { outF.Shape = PP; } outF.Shape = PP; break; case esriGeometryType.esriGeometryPolyline: GG = srcF.Shape; LL = (IPolyline)GG; MM = (IMAware)LL; if (MM.MAware == true) { MM.DropMs(); MM.MAware = false; } LL = (IPolyline)MM; ZZ = (IZAware)LL; ZZ.DropZs(); ZZ.ZAware = false; LL = (IPolyline)ZZ; outF.Shape = LL; break; case esriGeometryType.esriGeometryPolygon: GG = srcF.Shape; AA = (IPolygon)GG; MM = (IMAware)AA; if (MM.MAware == true) { MM.DropMs(); MM.MAware = false; } AA = (IPolygon)MM; ZZ = (IZAware)AA; ZZ.DropZs(); ZZ.ZAware = false; AA = (IPolygon)ZZ; if (theMap.geomTransform == 1) { IArea theA = (IArea)AA; IPoint theP = null; if (theMigr.PolygonToPtI) { theP = theA.LabelPoint; } if (theMigr.PolygonToPtA) { theP = theA.Centroid; } outF.Shape = theP; } else if (theMap.geomTransform == 2) { theTopo = (ITopologicalOperator)AA; IGeometry theL = theTopo.Boundary; outF.Shape = theL; } else { outF.Shape = AA; } break; } break; case 6: // Add M and Z Values switch (srcF.Shape.GeometryType) { case esriGeometryType.esriGeometryPoint: GG = srcF.Shape; PP = (IPoint)GG; ZZ = (IZAware)PP; if (ZZ.ZAware != true) { ZZ.ZAware = true; } PP = (IPoint)ZZ; PP.Z = theMigr.DefZ; MM = (IMAware)PP; if (MM.MAware != true) { MM.MAware = true; } PP = (IPoint)MM; if (theMap.geomTransform == 4 && theMigr.ptToPolygon) { theTopo = (ITopologicalOperator)PP; IGeometry theP = theTopo.Buffer(1.0); outF.Shape = theP; } else { outF.Shape = PP; } outF.Shape = PP; break; case esriGeometryType.esriGeometryPolyline: GG = srcF.Shape; LL = (IPolyline)GG; ZZ = (IZAware)LL; if (ZZ.ZAware != true) { ZZ.ZAware = true; } LL = (IPolyline)ZZ; ZF = (IZ)LL; ZF.SetConstantZ(theMigr.DefZ); LL = (IPolyline)ZF; MM = (IMAware)LL; if (MM.MAware == true) { MM.DropMs(); MM.MAware = false; } LL = (IPolyline)MM; outF.Shape = LL; break; case esriGeometryType.esriGeometryPolygon: GG = srcF.Shape; AA = (IPolygon)GG; if (theMap.geomTransform == 1) { IArea theA = (IArea)AA; IPoint theP = null; if (theMigr.PolygonToPtI) { theP = theA.LabelPoint; } if (theMigr.PolygonToPtA) { theP = theA.Centroid; } outF.Shape = theP; } else if (theMap.geomTransform == 2) { theTopo = (ITopologicalOperator)AA; IGeometry theL = theTopo.Boundary; outF.Shape = theL; } else { outF.Shape = AA; } ZZ = (IZAware)AA; if (ZZ.ZAware != true) { ZZ.ZAware = true; } AA = (IPolygon)ZZ; ZF = (IZ)AA; ZF.SetConstantZ(theMigr.DefZ); AA = (IPolygon)ZF; MM = (IMAware)AA; if (MM.MAware == true) { MM.DropMs(); MM.MAware = false; } AA = (IPolygon)MM; break; } break; } #endregion } else { # region fieldTransformation FldName = outFields.get_Field(m).Name; theAttMap = getAttributeMapping(theMap, FldName); if (theAttMap != null) { switch (theAttMap.transform) { case -1: //the field is not mapped break; case 0: // the field is translatable As Is inPos = GeoDbProcs.getFieldPosition(theMigr.srcWS, theAttMap.srcFC, theAttMap.srcAtt); if (srcF.get_Value(inPos) != null) if (srcF.get_Value(inPos).ToString() != "") { outF.set_Value(m, srcF.get_Value(inPos)); } if (FirstRecord) { theAttMap.AddResults(srcF.Fields.get_Field(inPos).Name + " into " + FldName + " As Is"); } break; case 18: // insertion of constant values for nulls inPos = GeoDbProcs.getFieldPosition(theMigr.srcWS, theAttMap.srcFC, theAttMap.srcAtt); if (srcF.get_Value(inPos) != null) if (srcF.get_Value(inPos).ToString() != "") { outF.set_Value(m, srcF.get_Value(inPos)); } if (FirstRecord) { theAttMap.AddResults(srcF.Fields.get_Field(inPos).Name + " into " + FldName + " inserting " + defValue + " for NULLS"); } break; case 23: // overwrite with a constant or place a constant in all records switch (outF.Fields.get_Field(m).Type) { case esriFieldType.esriFieldTypeString: outF.set_Value(m, theAttMap.constant.ToString()); break; case esriFieldType.esriFieldTypeDouble: outF.set_Value(m, Convert.ToDouble(theAttMap.constant)); break; case esriFieldType.esriFieldTypeSingle: outF.set_Value(m, Convert.ToSingle(theAttMap.constant)); break; case esriFieldType.esriFieldTypeInteger: outF.set_Value(m, Convert.ToInt32(theAttMap.constant)); break; case esriFieldType.esriFieldTypeSmallInteger: outF.set_Value(m, Convert.ToInt16(theAttMap.constant)); break; case esriFieldType.esriFieldTypeDate: outF.set_Value(m, Convert.ToDateTime(theAttMap.constant)); break; } if (FirstRecord) { theAttMap.AddResults("Placed Constant " + theAttMap.constant.ToString() + " into " + FldName + " Overwriting Existing Data"); } break; case 4: // shorten a character/string field inPos = GeoDbProcs.getFieldPosition(theMigr.srcWS, theAttMap.srcFC, theAttMap.srcAtt); if (srcF.get_Value(inPos) != null) if (srcF.get_Value(inPos).ToString() != "") { if (srcF.get_Value(inPos).ToString().Length <= outF.Fields.get_Field(m).Length) { outF.set_Value(m, srcF.get_Value(inPos)); } else { theAttMap.AddDataLoss(new DataLossEntries(theAttMap.serialNumber, theAttMap.srcFC, theAttMap.destFC, theAttMap.srcAtt, srcF.OID, "Data Loss in shortening a String Field")); outF.set_Value(m, srcF.get_Value(inPos).ToString().Substring(0, outF.Fields.get_Field(m).Length)); } } if (theAttMap.dataLoss == 1) { theAttMap.AddResults("Data Loss in Moving " + srcF.get_Value(inPos) + " to " + FldName); } break; case 10: // converting numeric to string case 11: case 12: case 13: inPos = GeoDbProcs.getFieldPosition(theMigr.srcWS, theAttMap.srcFC, theAttMap.srcAtt); if (srcF.get_Value(inPos) != null) if (srcF.get_Value(inPos).ToString().Length <= outF.Fields.get_Field(m).Length) { outF.set_Value(m, srcF.get_Value(inPos)); } else { theAttMap.AddDataLoss(new DataLossEntries(theAttMap.serialNumber, theAttMap.srcFC, theAttMap.destFC, theAttMap.srcAtt, srcF.OID, "Data Loss in converting Numeric Data Type to String")); outF.set_Value(m, srcF.get_Value(inPos).ToString().Substring(0, outF.Fields.get_Field(m).Length)); } if (theAttMap.dataLoss == 1) { theAttMap.AddResults("Data Loss in Moving " + srcF.get_Value(inPos) + " to " + FldName); } if (theAttMap.dataLoss == 0) { theAttMap.AddResults(srcF.Fields.get_Field(inPos).Name + " into " + FldName + " converting numeric Data Type"); } break; case 5: // converting string to integer inPos = GeoDbProcs.getFieldPosition(theMigr.srcWS, theAttMap.srcFC, theAttMap.srcAtt); if (srcF.get_Value(inPos) != null) { Int32 i = 0; Boolean result = Int32.TryParse(srcF.get_Value(inPos).ToString(), out i); if (result != true) { theAttMap.AddDataLoss(new DataLossEntries(theAttMap.serialNumber, theAttMap.srcFC, theAttMap.destFC, theAttMap.srcAtt, srcF.OID, "Data Loss in converting String to Long Integer")); } if (theAttMap.dataLoss == 1) { theAttMap.AddResults("Data Loss in Moving " + srcF.get_Value(inPos) + " to " + FldName); } if (theAttMap.dataLoss == 0) { theAttMap.AddResults(srcF.Fields.get_Field(inPos).Name + " into " + FldName + " converting Data Type"); } } break; case 6: inPos = GeoDbProcs.getFieldPosition(theMigr.srcWS, theAttMap.srcFC, theAttMap.srcAtt); if (srcF.get_Value(inPos) != null) { Double i = 0; Boolean result = Double.TryParse(srcF.get_Value(inPos).ToString(), out i); if (result != true) { theAttMap.AddDataLoss(new DataLossEntries(theAttMap.serialNumber, theAttMap.srcFC, theAttMap.destFC, theAttMap.srcAtt, srcF.OID, "Data Loss in converting String to Double")); } if (theAttMap.dataLoss == 1) { theAttMap.AddResults("Data Loss in Moving " + srcF.get_Value(inPos) + " to " + FldName); } if (theAttMap.dataLoss == 0) { theAttMap.AddResults(srcF.Fields.get_Field(inPos).Name + " into " + FldName + " converting Data Type"); } } break; case 14: inPos = GeoDbProcs.getFieldPosition(theMigr.srcWS, theAttMap.srcFC, theAttMap.srcAtt); if (srcF.get_Value(inPos) != null) { int i = 0; Boolean result = int.TryParse(srcF.get_Value(inPos).ToString(), out i); if (result != true) { theAttMap.AddDataLoss(new DataLossEntries(theAttMap.serialNumber, theAttMap.srcFC, theAttMap.destFC, theAttMap.srcAtt, srcF.OID, "Data Loss in converting String to Short Integer")); } if (theAttMap.dataLoss == 1) { theAttMap.AddResults("Data Loss in Moving " + srcF.get_Value(inPos) + " to " + FldName); } if (theAttMap.dataLoss == 0) { theAttMap.AddResults(srcF.Fields.get_Field(inPos).Name + " into " + FldName + " converting Data Type"); } } break; case 3: // double/single to int/shortInt case 16: inPos = GeoDbProcs.getFieldPosition(theMigr.srcWS, theAttMap.srcFC, theAttMap.srcAtt); if (srcF.get_Value(inPos) != null) { inVal = (Double)srcF.get_Value(inPos); if (inVal == Convert.ToInt32(inVal)) { outF.set_Value(m, Convert.ToInt32(inVal)); } else { outF.set_Value(m, Convert.ToInt32(inVal)); theAttMap.AddDataLoss(new DataLossEntries(theAttMap.serialNumber, theAttMap.srcFC, theAttMap.destFC, theAttMap.srcAtt, srcF.OID, "Data Loss in converting Decimal to Integer")); } if (theAttMap.dataLoss == 1) { theAttMap.AddResults("Data Loss in Moving " + srcF.get_Value(inPos) + " to " + FldName); } if (theAttMap.dataLoss == 0) { theAttMap.AddResults(srcF.Fields.get_Field(inPos).Name + " into " + FldName + " converting Data Type"); } } break; case 8: // long integer to datetime inPos = GeoDbProcs.getFieldPosition(theMigr.srcWS, theAttMap.srcFC, theAttMap.srcAtt); if (srcF.get_Value(inPos) != null) { String yearEquiv = srcF.get_Value(inPos).ToString(); if (yearEquiv.Length != 8) { theAttMap.AddDataLoss(new DataLossEntries(theAttMap.serialNumber, theAttMap.srcFC, theAttMap.destFC, theAttMap.srcAtt, srcF.OID, "Data Loss in converting Integer to DateTime")); } else { DateTime theD = new DateTime(Convert.ToInt16(yearEquiv.Substring(0, 4)), Convert.ToInt16(yearEquiv.Substring(5, 2)), Convert.ToInt16(yearEquiv.Substring(7, 2))); outF.set_Value(m, theD); } if (theAttMap.dataLoss == 1) { theAttMap.AddResults("Data Loss in Moving " + srcF.get_Value(inPos) + " to " + FldName); } if (theAttMap.dataLoss == 0) { theAttMap.AddResults(srcF.Fields.get_Field(inPos).Name + " into " + FldName + " converting Data Type"); } } break; case 17: // populating the Primary Keys PKPre = theMigr.preK; recPriKey = PKPre + PKCounter.ToString("0000000#"); outF.set_Value(m, recPriKey); if (FirstRecord) { theAttMap.AddResults("Primary Key Values Auto-populated beginning with " + PKPre + PKCounter.ToString("0000000#")); } PKCounter += 1; break; case 21: // Autopopulate the SubTypeID Int32 theST = Convert.ToInt32(theAttMap.constant); outF.set_Value(m, theST); if (FirstRecord) { theAttMap.AddResults("SubtypeID populated with " + theAttMap.constant.ToString()); } break; case 20: // domain Value Conversion (reserved for future use inPos = GeoDbProcs.getFieldPosition(theMigr.srcWS, theAttMap.srcFC, theAttMap.srcAtt); if (srcF.get_Value(inPos) != null) if (srcF.get_Value(inPos).ToString() != "") { hasConversion = false; if (theAttMap.theConversions != null) { foreach (ValueMappingData theConversion in theAttMap.theConversions) if (theConversion.srcV.ToString().ToLower() == srcF.get_Value(inPos).ToString().ToLower()) { hasConversion = true; outF.set_Value(m, theConversion.destV.ToString()); } if (hasConversion == false) { theAttMap.AddDataLoss(new DataLossEntries(theAttMap.serialNumber, theAttMap.srcFC, theAttMap.destFC, theAttMap.srcAtt, srcF.OID, "No Conversion Specified for " + srcF.get_Value(inPos))); } } } if (FirstRecord) { theAttMap.AddResults(srcF.Fields.get_Field(inPos).Name + " into " + FldName + " As Is"); } break; } } #endregion } } if (theMigr.splitNon) { for (int n = 0; n < outTB.Fields.FieldCount; n++) { if (outTB.Fields.get_Field(n).Editable == true) { FldName = outTB.Fields.get_Field(n).Name; int b = srcFC.Fields.FindField(FldName); TIn = srcFC.Fields.get_Field(b).Type; TOut = outTB.Fields.get_Field(n).Type; L1 = srcFC.Fields.get_Field(b).Length; L2 = outTB.Fields.get_Field(n).Length; String thePK = theMap.destPK.ToString().ToUpper(); if (FldName.ToUpper() == theMap.destPK.ToString().ToUpper()) { outR.set_Value(n, recPriKey); } else { inPos = GeoDbProcs.getFieldPosition(theMigr.srcWS, theMap.srcFC, FldName); if (inPos >= 0) { outR.set_Value(n, srcF.get_Value(inPos)); } } } } outR.Store(); } outF.Store(); thePB.Increment(1); if (MoveQty >= 10) { int Moved = Convert.ToInt32(MoveQty / 10); if (thePB.Value % Moved == 0) { outWE.StopEditOperation(); outWE.StopEditing(true); outWE.StartEditing(false); outWE.StartEditOperation(); } } Application.DoEvents(); }
/*Precondition: Postcondition: Loops through list of stock passed in, and inserts them into SQLite DB*/ public void insertStock(List<Stock> allStock, ProgressBar progBar) { //Check to see if stock table exists if (checkForTable("Stock")) { //Open DB and start transcation - transaction hugely increases speed of insert dbConnection.Open(); SQLiteTransaction transaction = dbConnection.BeginTransaction(); //Loop through all stock foreach (Stock s in allStock) { string stockInsert = ""; int quantity = s.quantity; string note = SyntaxHelper.escapeSingleQuotes(s.note); string author = SyntaxHelper.escapeSingleQuotes(s.author); string title = SyntaxHelper.escapeSingleQuotes(s.title); string subtitle = SyntaxHelper.escapeSingleQuotes(s.subtitle); string publisher = SyntaxHelper.escapeSingleQuotes(s.publisher); string description = SyntaxHelper.escapeSingleQuotes(s.description); string comments = SyntaxHelper.escapeSingleQuotes(s.comments); double price = s.price; string subject = SyntaxHelper.escapeSingleQuotes(s.subject); string catalogue = SyntaxHelper.escapeSingleQuotes(s.catalogue); string initials = SyntaxHelper.escapeSingleQuotes(s.initials); string sales = SyntaxHelper.escapeSingleQuotes(s.sales); string bookID = SyntaxHelper.escapeSingleQuotes(s.bookID); string dateEntered = SyntaxHelper.escapeSingleQuotes(s.dateEntered); int stockID = s.stockID; //Build insert command. If stock has an ID insert it with that ID if not (new stock) and insert with a new ID using autoincrement from SQLite if (s.stockID == -1) { stockInsert = "INSERT INTO Stock VALUES(null, '" + quantity + "', '" + note + "', '" + author + "', '" + title + "', '" + subtitle + "', '" + publisher + "', '" + description + "', '" + comments + "', '" + price + "', '" + subject + "', '" + catalogue + "', '" + initials + "', '" + sales + "', '" + bookID + "', '" + dateEntered + "')"; } else { stockInsert = "INSERT INTO Stock VALUES(" + stockID + ", '" + quantity + "', '" + note + "', '" + author + "', '" + title + "', '" + subtitle + "', '" + publisher + "', '" + description + "', '" + comments + "', '" + price + "', '" + subject + "', '" + catalogue + "', '" + initials + "', '" + sales + "', '" + bookID + "', '" + dateEntered + "')"; } SQLiteCommand insertCommand = new SQLiteCommand(stockInsert, dbConnection); insertCommand.ExecuteNonQuery(); //Update UI for user to see progress progBar.Increment(1); } //Commit transaction and close connection transaction.Commit(); dbConnection.Close(); } }
private void DoIncrement(int val) { progressBar.Increment(val); UpdateStatusText(); }
public void loadTestStudent(ProgressBar bar) { try { bar.Visible = true; OpenFileDialog fichero = new OpenFileDialog(); fichero.Filter = "Excel (*.xls)|*.xls;*.xlsx"; bar.Visible = true; ProjectBL pyBl = new ProjectBL(Program.ContextData); FormBL formBl = new FormBL(Program.ContextData); InventoryLineBL lineInvBl = new InventoryLineBL(Program.ContextData); listStratumsAdded = new ArrayList(); if (fichero.ShowDialog() == System.Windows.Forms.DialogResult.OK) { try { excel.Application aplicacion; excel.Workbook libros_trabajo; excel.Worksheet hojas_trabajo; excel.Range exlRange; aplicacion = new excel.Application(); //Asignamos el libro que sera abierot libros_trabajo = aplicacion.Workbooks.Open(fichero.FileName, 0, true, 5, "", "", true, excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); hojas_trabajo = (excel.Worksheet)libros_trabajo.Worksheets.get_Item(1); exlRange = hojas_trabajo.UsedRange; //Recorremos el archivo excel como si fuera una matriz //leemos las especies que se encuentran en la hoja TStudentBL tStudentBL = new TStudentBL(Program.ContextData); bar.Maximum = exlRange.Rows.Count; bar.Value = 0; string n = "", alpha = "", valor = ""; for (int i = 2; i <= exlRange.Rows.Count; i++) { TSTUDENT tableTstudent = new TSTUDENT(); n = (exlRange.Cells[i, 1] as excel.Range).Value + ""; alpha = (exlRange.Cells[i, 2] as excel.Range).Value + ""; valor = (exlRange.Cells[i, 3] as excel.Range).Value + ""; tableTstudent.N = int.Parse(n); tableTstudent.ALPHA = decimal.Parse(alpha); tableTstudent.VALOR = decimal.Parse(valor); tStudentBL.InsertTStudent(tableTstudent); string result = tStudentBL.SaveChanges(); if (result != "") { if (!result.Equals("")) { Error_Form errorForm = new Error_Form(result); errorForm.MdiParent = (Form)bar.Parent.Parent; errorForm.Show(); return; } } bar.Increment(1); } MessageBox.Show("Los datos se cargaron correctamente.", "Operacion exitosa", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { throw ex; } } bar.Visible = false; } catch (Exception ex) { Error_Form errorForm = new Error_Form(ex.Message); errorForm.MdiParent = (Form)bar.Parent.Parent; errorForm.Show(); bar.Visible = false; } }
/************************************* * get table columns and columns values *************************************/ private string prepareScriptOfTable(OracleConnection conn, string tableName, string ownerName, ProgressBar fileBar) { StringBuilder scriptCol = new StringBuilder(); StringBuilder scriptFinal = new StringBuilder(); scriptFinal.Append("SET DEFINE OFF; " + RETCHAR); scriptFinal.Append("DELETE FROM " + ownerName + "." + tableName + ";" + RETCHAR); // Step 1: get all columns name of the table string sqlText = DBSQL.QUERY_TABLE_COLUMNS; sqlText = sqlText.Replace("?", tableName); DataSet ds = OracleClient.getResultTable(conn, sqlText); List<string> colList = new List<string>(); if (ds.Tables.Count > 0) { scriptCol.Append("INSERT INTO " + ownerName + "." + tableName + "("); // prepare one row with the column type for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { colList.Add(ds.Tables[0].Rows[i][1].ToString()); if (i != ds.Tables[0].Rows.Count - 1) { scriptCol.Append(ds.Tables[0].Rows[i][0] + ","); } else { scriptCol.Append(ds.Tables[0].Rows[i][0] + ")"); } } scriptCol.Append(RETCHAR); scriptCol.Append(" VALUES( "); } // Step 2: get all values and combine to the insert script string sqlValueText = DBSQL.QUERY_COLUMNS_VALUES; sqlValueText = sqlValueText.Replace("?", tableName); DataSet valueDS = OracleClient.getResultTable(conn, sqlValueText); if (valueDS.Tables.Count > 0) { for (int i = 0; i < valueDS.Tables[0].Rows.Count; i++) { // first append the column script scriptFinal.Append(scriptCol); string columnValue = ""; for (int j = 0; j < colList.Count; j++) { columnValue = getDataTypeScript(valueDS.Tables[0].Rows[i][j].ToString(), colList[j]); if (j != colList.Count - 1) { scriptFinal.Append(columnValue + ","); } else { scriptFinal.Append(columnValue); } // update progress bar int incre = 100 / (i + 1) / (j + 1); fileBar.Increment(incre); } scriptFinal.Append(");" + RETCHAR); } } scriptFinal.Append("COMMIT;"); return scriptFinal.ToString(); }
void Button3Click(object sender, System.EventArgs e) { progressBar.Increment(1); }
private void BatchSaveForUnitTests() { var path = @"d:\Programs\Benchmarks\Fraps\Screenshots"; var pb = new ProgressBar(); pb.Maximum = 18; pb.Dock = DockStyle.Bottom; Controls.Add(pb); pb.Show(); foreach (var file in Directory.GetFiles(path, "*.png")) { var bmp = Bitmap.FromFile(file) as Bitmap; var result = Screenshot.GetTooltip(bmp, false); if (result == null) { Debugger.Break(); return; } var tt = new D3Bit.Tooltip(result); var r = new Results(tt); pbItem.Image = tt.Processed; SaveForUnitTests(r, result, bmp.Size); pb.Increment(1); Trace.TraceInformation("Saved " + r.Name); bmp.Dispose(); } pb.Hide(); MessageBox.Show("Done!"); }
public void IncreaseProgress(ProgressBar control, int increment) { if (control.InvokeRequired) { control.Invoke(new ControlProgressBar(IncreaseProgress), new object[] { control, increment }); } else { control.Increment(increment); } }
private void incrementLoading(ProgressBar bar) { if (bar.Value >= bar.Maximum) { bar.Value = bar.Minimum; } bar.Increment(5); }
/*Precondition: Postcondition: Loops through all of the OrderedStock and inserts them into SQLite DB, updates user with progress*/ public void insertOrderedStock(List<OrderedStock> allOrderedStock, ProgressBar progBar) { //Check to see if orderedstock table exists if (checkForTable("OrderedStock")) { //Open DB and start transcation - transaction hugely increases speed of insert dbConnection.Open(); SQLiteTransaction transaction = dbConnection.BeginTransaction(); //Loop through all orderedStock foreach (OrderedStock o in allOrderedStock) { string orderedStockInsert = ""; int orderID = o.orderID; int stockID = o.stockID; int quantity = o.quantity; string author = SyntaxHelper.escapeSingleQuotes(o.author); string title = SyntaxHelper.escapeSingleQuotes(o.title); double price = o.price; string bookID = SyntaxHelper.escapeSingleQuotes(o.bookID); double discount = o.discount; int orderedStockID = o.orderedStockID; //Build insert command. If OrderedStock has an ID insert it with that ID if not (new orderedSock) and insert with a new ID using autoincrement from SQLite if (o.orderedStockID == -1) { orderedStockInsert = "INSERT INTO OrderedStock VALUES(null, " + orderID + ", " + stockID + ", " + quantity + ", '" + author + "', '" + title + "', '" + price + "', '" + bookID + "', '" + discount + "')"; } else { orderedStockInsert = "INSERT INTO OrderedStock VALUES(" + orderedStockID + ", " + orderID + ", " + stockID + ", " + quantity + ", '" + author + "', '" + title + "', '" + price + "', '" + bookID + "', '" + discount + "')"; } SQLiteCommand insertCommand = new SQLiteCommand(orderedStockInsert, dbConnection); insertCommand.ExecuteNonQuery(); //Update UI for user to see progress progBar.Increment(1); } //Commit transaction and close connection transaction.Commit(); dbConnection.Close(); } }