public static void UpdateProgress(ProgressBarX progress, int val, int max) { IAsyncResult res; res = progress.BeginInvoke(new InvokeProgress(UpdateProgressX), new object[] { progress, val, max }); progress.EndInvoke(res); }
static void UpdateProgressX(ProgressBarX progress, int value, int maximum) { progress.Minimum = 0; progress.Maximum = maximum; progress.Value = value; progress.Text = value.ToString(); }
public static void UpdateProgram(ProgressBarX progress, Label lb) { try { GUI.UpdateLabel(lb, "Initialzing..."); GUI.UpdateProgress(progress, 5, 100); string updateserver = "http://arsslensoft.tk/update/"; string vdbinfo = "PROG.version"; // Initializing WebClient wbc = new WebClient(); wbc.Headers[HttpRequestHeader.AcceptEncoding] = "gzip"; wbc.Headers[HttpRequestHeader.Accept] = "text/plain"; wbc.Headers[HttpRequestHeader.Cookie] = "$Version=1; Skin=new;"; wbc.Headers[HttpRequestHeader.AcceptCharset] = "utf-8"; Thread.Sleep(1000); // search for update from server GUI.UpdateLabel(lb, "Downloading PROGRAM update file..."); GUI.UpdateProgress(progress, 10, 100); string vdbucontent = wbc.DownloadString(updateserver + vdbinfo); int versf = Int32.Parse(Assembly.GetExecutingAssembly().GetName().Version.ToString().Replace(".", "")); if (Convert.ToInt32(vdbucontent) > versf) { GUI.UpdateLabel(lb, "Downloading Updates " + vdbucontent + ".pgup"); GUI.UpdateProgress(progress, 50, 100); WebClient wb = new WebClient(); wb.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(wb_DownloadFileCompleted); wb.DownloadFileAsync(new Uri(updateserver + "PROG/WIN32_KPAV_" + vdbucontent + ".pgup"), AVEngine.TempDir + @"PGUP\KPAVNEW.zip"); remv = versf.ToString(); remcv = vdbucontent; } else { GUI.UpdateLabel(lb, "Kavprot smart security is up to date"); GUI.UpdateProgress(progress, 0, 100); } } catch (Exception ex) { GUI.UpdateProgress(progress, 0, 100); GUI.UpdateLabel(lb, " "); if (ex.TargetSite.ReflectedType.ToString() != "System.Net.WebClient") { AntiCrash.LogException(ex); } } finally { } }
public static void SetProgressBarValue(this ProgressBarX progressBar, int value, string msg = "") { progressBar.Invoke(new Action(() => { progressBar.Value = value; if (string.IsNullOrEmpty(msg)) { progressBar.Text = msg; progressBar.TextVisible = true; } })); }
public void UpdateProgressBar(ProgressBarX progressBarX, int healtPercentage) { if (progressBarX.InvokeRequired) { progressBarX.BeginInvoke( new MethodInvoker( delegate { UpdateProgressBar(progressBarX, healtPercentage); })); } else { progressBarX.Value = healtPercentage; } }
internal static void AddIDP(string[] files, ProgressBarX progress) { using (SQLiteTransaction trans = SDB.BeginTransaction()) { int c = 0; using (SQLiteCommand addKeysCmd = new SQLiteCommand(SDB)) { foreach (string file in files) { string sqlIns = "INSERT INTO IDP (file, hash) VALUES('" + file + "', '" + Security.GetMD5HashFromFile(file) + "')"; addKeysCmd.CommandText = sqlIns; addKeysCmd.ExecuteNonQuery(); c++; GUI.UpdateProgress(progress, c, files.Length); } } trans.Commit(); } }
public static void MakeRescue(string Directory, string Destination, ProgressBarX progress) { int i = 0; CDBuilder builder = new CDBuilder(); builder.VolumeIdentifier = "SYS_RESCUE_DISK"; builder.UseJoliet = true; List <string> files = FileHelper.GetFilesRecursive(Directory); GUI.UpdateProgress(progress, 0, files.Count); using (StreamWriter str = new StreamWriter(Directory + @"\SYSRESCUEINFO.KPAVRSCI", true)) { str.WriteLine("BEGIN SYS_RESC_DISK|" + DateTime.Now.ToString() + "|KAVPROT_ISO_RESCUE|" + Environment.MachineName + "|" + Environment.OSVersion.ToString() + "|" + Environment.UserName); foreach (string file in files) { i++; try { GUI.UpdateProgress(progress, i, files.Count); builder.AddFile(Path.GetFileName(file), file); str.WriteLine(file); builder.Build(Destination); } catch (Exception ex) { AntiCrash.LogException(ex, 2); } finally { } } str.WriteLine("END SYS_RESC_DISK " + files.Count); } builder.AddFile("SYSRESCUEINFO.KPAVRSCI", Directory + @"\SYSRESCUEINFO.KPAVRSCI"); builder.Build(Destination); }
public MainProgress(ProgressBarX progress, LabelX message) { _progress = progress; _message = message; _canceled = false; }
public static void UpdateVDB(ProgressBarX progress, Label lb) { try { int curv = VDB.version; GUI.UpdateLabel(lb, "Initialzing..."); GUI.UpdateProgress(progress, 5, 100); Dictionary <string, string> SCRIPT = new Dictionary <string, string>(); Dictionary <string, string> MD5 = new Dictionary <string, string>(); Dictionary <string, string> PEMD5 = new Dictionary <string, string>(); Dictionary <string, string> URL = new Dictionary <string, string>(); Dictionary <string, string> HEUR = new Dictionary <string, string>(); string updateserver = "http://arsslensoft.tk/update/"; string vdbinfo = "VDB.version"; // Initializing WebClient wbc = new WebClient(); wbc.Headers[HttpRequestHeader.AcceptEncoding] = "gzip"; wbc.Headers[HttpRequestHeader.Accept] = "text/plain"; wbc.Headers[HttpRequestHeader.Cookie] = "$Version=1; Skin=new;"; wbc.Headers[HttpRequestHeader.AcceptCharset] = "utf-8"; Thread.Sleep(1000); // search for update from server GUI.UpdateLabel(lb, "Downloading VDB update file..."); GUI.UpdateProgress(progress, 10, 100); string vdbucontent = wbc.DownloadString(updateserver + vdbinfo); if (Convert.ToInt32(vdbucontent) > VDB.version) { GUI.UpdateLabel(lb, "Downloading Updates..."); GUI.UpdateProgress(progress, 30, 100); for (int i = VDB.version + 1; i < Convert.ToInt32(vdbucontent) + 1; i++) { GUI.UpdateLabel(lb, "Downloading Updates (" + i.ToString() + ".vdu)..."); GUI.UpdateProgress(progress, 40, 100); string vdupath = AVEngine.TempDir + "UPDATE.vdu"; string vdurl = "http://update.arsslensoft.tk/VDB/VD/" + i.ToString() + ".vdu"; Download(vdurl, vdupath, lb); XmlDocument doc = new XmlDocument(); doc.Load(vdupath); GUI.UpdateLabel(lb, "Downloaded " + i.ToString() + ".vdu"); foreach (XmlElement el in doc.DocumentElement.ChildNodes) { if (el.GetAttribute("type") == "md5") { MD5.Add(el.GetAttribute("content"), el.InnerText); } else if (el.GetAttribute("type") == "url") { URL.Add(el.GetAttribute("content"), el.InnerText); } else if (el.GetAttribute("type") == "pemd5") { PEMD5.Add(el.GetAttribute("content"), el.InnerText); } else if (el.GetAttribute("type") == "heuristic") { HEUR.Add(el.GetAttribute("content"), el.InnerText); } else { SCRIPT.Add(el.GetAttribute("content"), el.InnerText); } } GUI.UpdateLabel(lb, "Installing Updates..."); GUI.UpdateProgress(progress, 70, 100); if (MD5.Count > 0) { VDB.AddKeys(MD5, DBT.HDB); } else { } if (PEMD5.Count > 0) { VDB.AddKeys(PEMD5, DBT.PEMD5); } else { } if (URL.Count > 0) { VDB.AddKeys(URL, DBT.WDB); } else { } if (SCRIPT.Count > 0) { VDB.AddKeys(SCRIPT, DBT.SDB); } else { } if (HEUR.Count > 0) { VDB.AddKeys(HEUR, DBT.HEUR); } else { } GUI.UpdateLabel(lb, "Updating VDBV..."); GUI.UpdateProgress(progress, 90, 100); VDB.Setversion(i.ToString()); HEUR.Clear(); SCRIPT.Clear(); URL.Clear(); PEMD5.Clear(); MD5.Clear(); File.Delete(vdupath); } GUI.UpdateLabel(lb, "Virus Database has been updated. Last version : " + curv.ToString() + " Current Version : " + VDB.version.ToString()); GUI.UpdateProgress(progress, 100, 100); Alert.Attack("Virus Database Update", "Kavprot smart security virus database has been updated.", ToolTipIcon.Info, false); GUI.UpdateProgress(progress, 0, 100); } else { GUI.UpdateLabel(lb, "Virus Database is up to date"); GUI.UpdateProgress(progress, 100, 100); Alert.Attack("Virus Database Update", "Kavprot smart security virus database is up to date", ToolTipIcon.Info, false); GUI.UpdateProgress(progress, 0, 100); } } catch (Exception ex) { GUI.UpdateProgress(progress, 0, 100); GUI.UpdateLabel(lb, " "); AVEngine.EventsManager.CallVDBUpdateCanceled(); if (ex.TargetSite.ReflectedType.ToString() != "System.Net.WebClient") { AntiCrash.LogException(ex); } } finally { } }
internal virtual void vmethod_7(ProgressBarX progressBarX_1) { progressBarX_0 = progressBarX_1; }
public static void FullScan(Label CurFile, ProgressBarX progress, ItemPanel lst) { Stopwatch st = Stopwatch.StartNew(); int total = 0; int scanned = 0; if (AVEngine.ScanSensitivity == ScanSense.High) { try { GUI.UpdateLabel(CurFile, "Initializing..."); #region GetCount foreach (string drv in Environment.GetLogicalDrives()) { Stack <string> stack = new Stack <string>(); // 3. // Add initial directory. stack.Push(drv); // 4. // Continue while there are directories to process while (stack.Count > 0) { // A. // Get top directory string dir = stack.Pop(); try { // scan all files in directory foreach (string file in Directory.GetFiles(dir, "*.*")) { total++; } // C // Add all directories at this directory. foreach (string dn in Directory.GetDirectories(dir)) { stack.Push(dn); } } catch { } } } #endregion object vir = null; foreach (string drv in Environment.GetLogicalDrives()) { Stack <string> stack = new Stack <string>(); // 3. // Add initial directory. stack.Push(drv); // 4. // Continue while there are directories to process while (stack.Count > 0) { // A. // Get top directory string dir = stack.Pop(); try { // scan all files in directory foreach (string file in Directory.GetFiles(dir, "*.*")) { scanned++; GUI.UpdateProgress(progress, scanned, total); GUI.UpdateLabel(CurFile, file); vir = FileFormat.GetFileFormat(file).ScanHS(file, CurFile); if (vir != null) { if (FileFormat.GetFileFormat(file) == AVEngine.ArchiveTypeScanner) { string[] s = vir.ToString().Split('&'); GUI.UpdatePanel(new Virus(s[0], file, s[1], FileFormat.GetFileFormat(file)), lst); } else { GUI.UpdatePanel(new Virus(vir.ToString(), file, FileFormat.GetFileFormat(file)), lst); } } } // C // Add all directories at this directory. foreach (string dn in Directory.GetDirectories(dir)) { stack.Push(dn); } } catch { } } } } catch { // alert needed GUI.UpdateLabel(CurFile, "Scan Completed"); } finally { } } else if (AVEngine.ScanSensitivity == ScanSense.Medium) { try { GUI.UpdateLabel(CurFile, "Initializing..."); #region GetCount foreach (string drv in Environment.GetLogicalDrives()) { Stack <string> stack = new Stack <string>(); // 3. // Add initial directory. stack.Push(drv); // 4. // Continue while there are directories to process while (stack.Count > 0) { // A. // Get top directory string dir = stack.Pop(); try { // scan all files in directory foreach (string file in Directory.GetFiles(dir, "*.*")) { total++; } // C // Add all directories at this directory. foreach (string dn in Directory.GetDirectories(dir)) { stack.Push(dn); } } catch { } } } #endregion object vir = null; foreach (string drv in Environment.GetLogicalDrives()) { Stack <string> stack = new Stack <string>(); // 3. // Add initial directory. stack.Push(drv); // 4. // Continue while there are directories to process while (stack.Count > 0) { // A. // Get top directory string dir = stack.Pop(); try { // scan all files in directory foreach (string file in Directory.GetFiles(dir, "*.*")) { scanned++; GUI.UpdateProgress(progress, scanned, total); GUI.UpdateLabel(CurFile, file); vir = FileFormat.GetFileFormat(file).ScanM(file, CurFile); if (vir != null) { if (FileFormat.GetFileFormat(file) == AVEngine.ArchiveTypeScanner) { string[] s = vir.ToString().Split('&'); GUI.UpdatePanel(new Virus(s[0], file, s[1], FileFormat.GetFileFormat(file)), lst); } else { GUI.UpdatePanel(new Virus(vir.ToString(), file, FileFormat.GetFileFormat(file)), lst); } } } // C // Add all directories at this directory. foreach (string dn in Directory.GetDirectories(dir)) { stack.Push(dn); } } catch { } } } } catch { // alert needed GUI.UpdateLabel(CurFile, "Scan Completed"); } finally { } } else { try { GUI.UpdateLabel(CurFile, "Initializing..."); #region GetCount foreach (string drv in Environment.GetLogicalDrives()) { Stack <string> stack = new Stack <string>(); // 3. // Add initial directory. stack.Push(drv); // 4. // Continue while there are directories to process while (stack.Count > 0) { // A. // Get top directory string dir = stack.Pop(); try { // scan all files in directory foreach (string file in Directory.GetFiles(dir, "*.*")) { total++; } // C // Add all directories at this directory. foreach (string dn in Directory.GetDirectories(dir)) { stack.Push(dn); } } catch { } } } #endregion object vir = null; foreach (string drv in Environment.GetLogicalDrives()) { Stack <string> stack = new Stack <string>(); // 3. // Add initial directory. stack.Push(drv); // 4. // Continue while there are directories to process while (stack.Count > 0) { // A. // Get top directory string dir = stack.Pop(); try { // scan all files in directory foreach (string file in Directory.GetFiles(dir, "*.*")) { scanned++; GUI.UpdateProgress(progress, scanned, total); GUI.UpdateLabel(CurFile, file); vir = FileFormat.GetFileFormat(file).Scan(file, CurFile); if (vir != null) { if (FileFormat.GetFileFormat(file) == AVEngine.ArchiveTypeScanner) { string[] s = vir.ToString().Split('&'); GUI.UpdatePanel(new Virus(s[0], file, s[1], FileFormat.GetFileFormat(file)), lst); } else { GUI.UpdatePanel(new Virus(vir.ToString(), file, FileFormat.GetFileFormat(file)), lst); } } } // C // Add all directories at this directory. foreach (string dn in Directory.GetDirectories(dir)) { stack.Push(dn); } } catch { } } } } catch { } finally { st.Stop(); // alert needed GUI.UpdateLabel(CurFile, "Scan Performed in " + st.Elapsed.ToString()); Alert.ScanCompleted(); } } }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(GeneraterForm)); this.groupPanel_DataBase = new DevComponents.DotNetBar.Controls.GroupPanel(); this.txbConnString = new DevComponents.DotNetBar.Controls.TextBoxX(); this.butDeleteConnection = new DevComponents.DotNetBar.ButtonX(); this.lblConnectionStr = new DevComponents.DotNetBar.LabelX(); this.butAddConnection = new DevComponents.DotNetBar.ButtonX(); this.cboxConnectionNameColl = new System.Windows.Forms.ComboBox(); this.lblConnectionName = new DevComponents.DotNetBar.LabelX(); this.butTest = new DevComponents.DotNetBar.ButtonX(); this.groupPanel_Config = new DevComponents.DotNetBar.Controls.GroupPanel(); this.txbURL = new DevComponents.DotNetBar.Controls.TextBoxX(); this.butSeleteSavePath = new DevComponents.DotNetBar.ButtonX(); this.labelX4 = new DevComponents.DotNetBar.LabelX(); this.groupPanel_Template = new DevComponents.DotNetBar.Controls.GroupPanel(); this.TemplateTreeView = new System.Windows.Forms.TreeView(); this.lboxTable2 = new System.Windows.Forms.ListBox(); this.butDeleteAllTable = new DevComponents.DotNetBar.ButtonX(); this.butSelectedAllTable = new DevComponents.DotNetBar.ButtonX(); this.butSelectedItemTable = new DevComponents.DotNetBar.ButtonX(); this.butDeleteItemTable = new DevComponents.DotNetBar.ButtonX(); this.lboxTable = new System.Windows.Forms.ListBox(); this.labelX3 = new DevComponents.DotNetBar.LabelX(); this.butSelectTable = new DevComponents.DotNetBar.ButtonX(); this.groupPanel_Tables = new DevComponents.DotNetBar.Controls.GroupPanel(); this.txbSelectedTable = new CodeGeneration.UserControls.TextBoxSEO(); this.cboxSaveConfig = new System.Windows.Forms.CheckBox(); this.butCreateCode = new DevComponents.DotNetBar.ButtonX(); this.butCode = new DevComponents.DotNetBar.ButtonX(); this.prog = new DevComponents.DotNetBar.Controls.ProgressBarX(); this.groupPanel_DataBase.SuspendLayout(); this.groupPanel_Config.SuspendLayout(); this.groupPanel_Template.SuspendLayout(); this.groupPanel_Tables.SuspendLayout(); this.SuspendLayout(); // // groupPanel_DataBase // this.groupPanel_DataBase.CanvasColor = System.Drawing.SystemColors.Control; this.groupPanel_DataBase.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel_DataBase.Controls.Add(this.txbConnString); this.groupPanel_DataBase.Controls.Add(this.butDeleteConnection); this.groupPanel_DataBase.Controls.Add(this.lblConnectionStr); this.groupPanel_DataBase.Controls.Add(this.butAddConnection); this.groupPanel_DataBase.Controls.Add(this.cboxConnectionNameColl); this.groupPanel_DataBase.Controls.Add(this.lblConnectionName); this.groupPanel_DataBase.Controls.Add(this.butTest); this.groupPanel_DataBase.Location = new System.Drawing.Point(12, 12); this.groupPanel_DataBase.Name = "groupPanel_DataBase"; this.groupPanel_DataBase.Size = new System.Drawing.Size(396, 111); // // // this.groupPanel_DataBase.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2; this.groupPanel_DataBase.Style.BackColorGradientAngle = 90; this.groupPanel_DataBase.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; this.groupPanel_DataBase.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid; this.groupPanel_DataBase.Style.BorderBottomWidth = 1; this.groupPanel_DataBase.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder; this.groupPanel_DataBase.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid; this.groupPanel_DataBase.Style.BorderLeftWidth = 1; this.groupPanel_DataBase.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid; this.groupPanel_DataBase.Style.BorderRightWidth = 1; this.groupPanel_DataBase.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid; this.groupPanel_DataBase.Style.BorderTopWidth = 1; this.groupPanel_DataBase.Style.CornerDiameter = 4; this.groupPanel_DataBase.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded; this.groupPanel_DataBase.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText; this.groupPanel_DataBase.TabIndex = 27; this.groupPanel_DataBase.Text = "连接数据库"; // // txbConnString // // // // this.txbConnString.Border.Class = "TextBoxBorder"; this.txbConnString.Location = new System.Drawing.Point(73, 34); this.txbConnString.Multiline = true; this.txbConnString.Name = "txbConnString"; this.txbConnString.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.txbConnString.Size = new System.Drawing.Size(224, 43); this.txbConnString.TabIndex = 42; // // butDeleteConnection // this.butDeleteConnection.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.butDeleteConnection.ForeColor = System.Drawing.SystemColors.InfoText; this.butDeleteConnection.Location = new System.Drawing.Point(303, 9); this.butDeleteConnection.Name = "butDeleteConnection"; this.butDeleteConnection.Size = new System.Drawing.Size(78, 23); this.butDeleteConnection.TabIndex = 44; this.butDeleteConnection.Text = "删 除"; this.butDeleteConnection.Click += new System.EventHandler(this.butDeleteConnection_Click); // // lblConnectionStr // this.lblConnectionStr.BackColor = System.Drawing.Color.Transparent; this.lblConnectionStr.Location = new System.Drawing.Point(8, 34); this.lblConnectionStr.Name = "lblConnectionStr"; this.lblConnectionStr.Size = new System.Drawing.Size(75, 23); this.lblConnectionStr.TabIndex = 41; this.lblConnectionStr.Text = "链接字符:"; // // butAddConnection // this.butAddConnection.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.butAddConnection.ForeColor = System.Drawing.SystemColors.InfoText; this.butAddConnection.Location = new System.Drawing.Point(208, 9); this.butAddConnection.Name = "butAddConnection"; this.butAddConnection.Size = new System.Drawing.Size(72, 23); this.butAddConnection.TabIndex = 40; this.butAddConnection.Text = "添 加"; this.butAddConnection.Click += new System.EventHandler(this.butAddConnection_Click); // // cboxConnectionNameColl // this.cboxConnectionNameColl.FormattingEnabled = true; this.cboxConnectionNameColl.Location = new System.Drawing.Point(73, 8); this.cboxConnectionNameColl.Name = "cboxConnectionNameColl"; this.cboxConnectionNameColl.Size = new System.Drawing.Size(115, 20); this.cboxConnectionNameColl.TabIndex = 39; this.cboxConnectionNameColl.SelectedIndexChanged += new System.EventHandler(this.cboxConnectionNameColl_SelectedIndexChanged_1); // // lblConnectionName // this.lblConnectionName.BackColor = System.Drawing.Color.Transparent; this.lblConnectionName.Location = new System.Drawing.Point(9, 9); this.lblConnectionName.Name = "lblConnectionName"; this.lblConnectionName.Size = new System.Drawing.Size(86, 23); this.lblConnectionName.TabIndex = 38; this.lblConnectionName.Text = "链接命令:"; // // butTest // this.butTest.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.butTest.ForeColor = System.Drawing.SystemColors.InfoText; this.butTest.Location = new System.Drawing.Point(303, 34); this.butTest.Name = "butTest"; this.butTest.Size = new System.Drawing.Size(78, 43); this.butTest.TabIndex = 3; this.butTest.Text = "连接\\测试"; this.butTest.Click += new System.EventHandler(this.butTest_Click); // // groupPanel_Config // this.groupPanel_Config.CanvasColor = System.Drawing.SystemColors.Control; this.groupPanel_Config.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel_Config.Controls.Add(this.txbURL); this.groupPanel_Config.Controls.Add(this.butSeleteSavePath); this.groupPanel_Config.Controls.Add(this.labelX4); this.groupPanel_Config.Location = new System.Drawing.Point(12, 129); this.groupPanel_Config.Name = "groupPanel_Config"; this.groupPanel_Config.Size = new System.Drawing.Size(396, 57); // // // this.groupPanel_Config.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2; this.groupPanel_Config.Style.BackColorGradientAngle = 90; this.groupPanel_Config.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; this.groupPanel_Config.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid; this.groupPanel_Config.Style.BorderBottomWidth = 1; this.groupPanel_Config.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder; this.groupPanel_Config.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid; this.groupPanel_Config.Style.BorderLeftWidth = 1; this.groupPanel_Config.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid; this.groupPanel_Config.Style.BorderRightWidth = 1; this.groupPanel_Config.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid; this.groupPanel_Config.Style.BorderTopWidth = 1; this.groupPanel_Config.Style.CornerDiameter = 4; this.groupPanel_Config.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded; this.groupPanel_Config.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText; this.groupPanel_Config.TabIndex = 29; this.groupPanel_Config.Text = "保存位置"; // // txbURL // this.txbURL.BackColor = System.Drawing.SystemColors.Window; // // // this.txbURL.Border.Class = "TextBoxBorder"; this.txbURL.Font = new System.Drawing.Font("宋体", 10F); this.txbURL.ForeColor = System.Drawing.Color.Black; this.txbURL.Location = new System.Drawing.Point(74, 0); this.txbURL.Name = "txbURL"; this.txbURL.Size = new System.Drawing.Size(258, 24); this.txbURL.TabIndex = 20; this.txbURL.Text = "C:\\Users\\fine\\Desktop\\CreateCode"; this.txbURL.TextAlign = System.Windows.Forms.HorizontalAlignment.Right; // // butSeleteSavePath // this.butSeleteSavePath.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.butSeleteSavePath.ForeColor = System.Drawing.SystemColors.InfoText; this.butSeleteSavePath.Location = new System.Drawing.Point(336, 0); this.butSeleteSavePath.Name = "butSeleteSavePath"; this.butSeleteSavePath.Size = new System.Drawing.Size(42, 23); this.butSeleteSavePath.TabIndex = 9; this.butSeleteSavePath.Text = "浏览"; this.butSeleteSavePath.Click += new System.EventHandler(this.butSelectFileSavePath_Click); // // labelX4 // this.labelX4.BackColor = System.Drawing.Color.Transparent; this.labelX4.Location = new System.Drawing.Point(6, 3); this.labelX4.Name = "labelX4"; this.labelX4.Size = new System.Drawing.Size(75, 23); this.labelX4.TabIndex = 8; this.labelX4.Text = "保存到(S):"; // // groupPanel_Template // this.groupPanel_Template.CanvasColor = System.Drawing.SystemColors.Control; this.groupPanel_Template.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel_Template.Controls.Add(this.TemplateTreeView); this.groupPanel_Template.Location = new System.Drawing.Point(12, 202); this.groupPanel_Template.Name = "groupPanel_Template"; this.groupPanel_Template.Size = new System.Drawing.Size(396, 275); // // // this.groupPanel_Template.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2; this.groupPanel_Template.Style.BackColorGradientAngle = 90; this.groupPanel_Template.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; this.groupPanel_Template.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid; this.groupPanel_Template.Style.BorderBottomWidth = 1; this.groupPanel_Template.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder; this.groupPanel_Template.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid; this.groupPanel_Template.Style.BorderLeftWidth = 1; this.groupPanel_Template.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid; this.groupPanel_Template.Style.BorderRightWidth = 1; this.groupPanel_Template.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid; this.groupPanel_Template.Style.BorderTopWidth = 1; this.groupPanel_Template.Style.CornerDiameter = 4; this.groupPanel_Template.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded; this.groupPanel_Template.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText; this.groupPanel_Template.TabIndex = 30; this.groupPanel_Template.Text = "选择模板"; // // TemplateTreeView // this.TemplateTreeView.CheckBoxes = true; this.TemplateTreeView.Dock = System.Windows.Forms.DockStyle.Fill; this.TemplateTreeView.Location = new System.Drawing.Point(0, 0); this.TemplateTreeView.Name = "TemplateTreeView"; this.TemplateTreeView.Size = new System.Drawing.Size(390, 251); this.TemplateTreeView.TabIndex = 1; this.TemplateTreeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.TemplateTreeView_NodeMouseClick); // // lboxTable2 // this.lboxTable2.BackColor = System.Drawing.SystemColors.HighlightText; this.lboxTable2.FormattingEnabled = true; this.lboxTable2.ItemHeight = 12; this.lboxTable2.Location = new System.Drawing.Point(214, 45); this.lboxTable2.Name = "lboxTable2"; this.lboxTable2.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; this.lboxTable2.Size = new System.Drawing.Size(172, 340); this.lboxTable2.TabIndex = 1; this.lboxTable2.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lboxTable2_DoubleClick); // // butDeleteAllTable // this.butDeleteAllTable.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.butDeleteAllTable.ForeColor = System.Drawing.SystemColors.InfoText; this.butDeleteAllTable.Location = new System.Drawing.Point(162, 223); this.butDeleteAllTable.Name = "butDeleteAllTable"; this.butDeleteAllTable.Size = new System.Drawing.Size(46, 23); this.butDeleteAllTable.TabIndex = 10; this.butDeleteAllTable.Text = "<<"; this.butDeleteAllTable.Click += new System.EventHandler(this.butDeleteAllTable_Click); // // butSelectedAllTable // this.butSelectedAllTable.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.butSelectedAllTable.ForeColor = System.Drawing.SystemColors.InfoText; this.butSelectedAllTable.Location = new System.Drawing.Point(162, 152); this.butSelectedAllTable.Name = "butSelectedAllTable"; this.butSelectedAllTable.Size = new System.Drawing.Size(46, 23); this.butSelectedAllTable.TabIndex = 11; this.butSelectedAllTable.Text = ">>"; this.butSelectedAllTable.Click += new System.EventHandler(this.butSelectedAllTable_Click); // // butSelectedItemTable // this.butSelectedItemTable.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.butSelectedItemTable.ForeColor = System.Drawing.SystemColors.InfoText; this.butSelectedItemTable.Location = new System.Drawing.Point(162, 107); this.butSelectedItemTable.Name = "butSelectedItemTable"; this.butSelectedItemTable.Size = new System.Drawing.Size(46, 23); this.butSelectedItemTable.TabIndex = 12; this.butSelectedItemTable.Text = ">"; this.butSelectedItemTable.Click += new System.EventHandler(this.butSelectedItemTable_Click); // // butDeleteItemTable // this.butDeleteItemTable.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.butDeleteItemTable.ForeColor = System.Drawing.SystemColors.InfoText; this.butDeleteItemTable.Location = new System.Drawing.Point(162, 190); this.butDeleteItemTable.Name = "butDeleteItemTable"; this.butDeleteItemTable.Size = new System.Drawing.Size(46, 23); this.butDeleteItemTable.TabIndex = 13; this.butDeleteItemTable.Text = "<"; this.butDeleteItemTable.Click += new System.EventHandler(this.butDeleteItemTable_Click); // // lboxTable // this.lboxTable.FormattingEnabled = true; this.lboxTable.ItemHeight = 12; this.lboxTable.Location = new System.Drawing.Point(1, 45); this.lboxTable.Name = "lboxTable"; this.lboxTable.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended; this.lboxTable.Size = new System.Drawing.Size(155, 340); this.lboxTable.TabIndex = 20; this.lboxTable.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.lboxTable_DoubleClick); // // labelX3 // this.labelX3.BackColor = System.Drawing.Color.Transparent; this.labelX3.Location = new System.Drawing.Point(8, 10); this.labelX3.Name = "labelX3"; this.labelX3.SingleLineColor = System.Drawing.SystemColors.GradientInactiveCaption; this.labelX3.Size = new System.Drawing.Size(73, 23); this.labelX3.TabIndex = 45; this.labelX3.Text = "智能筛选:"; // // butSelectTable // this.butSelectTable.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.butSelectTable.ForeColor = System.Drawing.SystemColors.InfoText; this.butSelectTable.Location = new System.Drawing.Point(295, 8); this.butSelectTable.Name = "butSelectTable"; this.butSelectTable.Size = new System.Drawing.Size(72, 23); this.butSelectTable.TabIndex = 41; this.butSelectTable.Text = "筛 选"; this.butSelectTable.Click += new System.EventHandler(this.butSelectTable_Click); // // groupPanel_Tables // this.groupPanel_Tables.CanvasColor = System.Drawing.SystemColors.Control; this.groupPanel_Tables.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel_Tables.Controls.Add(this.txbSelectedTable); this.groupPanel_Tables.Controls.Add(this.butSelectTable); this.groupPanel_Tables.Controls.Add(this.lboxTable2); this.groupPanel_Tables.Controls.Add(this.butSelectedAllTable); this.groupPanel_Tables.Controls.Add(this.butSelectedItemTable); this.groupPanel_Tables.Controls.Add(this.butDeleteAllTable); this.groupPanel_Tables.Controls.Add(this.butDeleteItemTable); this.groupPanel_Tables.Controls.Add(this.cboxSaveConfig); this.groupPanel_Tables.Controls.Add(this.butCreateCode); this.groupPanel_Tables.Controls.Add(this.labelX3); this.groupPanel_Tables.Controls.Add(this.lboxTable); this.groupPanel_Tables.Controls.Add(this.butCode); this.groupPanel_Tables.Controls.Add(this.prog); this.groupPanel_Tables.Location = new System.Drawing.Point(414, 12); this.groupPanel_Tables.Name = "groupPanel_Tables"; this.groupPanel_Tables.Size = new System.Drawing.Size(392, 465); // // // this.groupPanel_Tables.Style.BackColor2SchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground2; this.groupPanel_Tables.Style.BackColorGradientAngle = 90; this.groupPanel_Tables.Style.BackColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBackground; this.groupPanel_Tables.Style.BorderBottom = DevComponents.DotNetBar.eStyleBorderType.Solid; this.groupPanel_Tables.Style.BorderBottomWidth = 1; this.groupPanel_Tables.Style.BorderColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelBorder; this.groupPanel_Tables.Style.BorderLeft = DevComponents.DotNetBar.eStyleBorderType.Solid; this.groupPanel_Tables.Style.BorderLeftWidth = 1; this.groupPanel_Tables.Style.BorderRight = DevComponents.DotNetBar.eStyleBorderType.Solid; this.groupPanel_Tables.Style.BorderRightWidth = 1; this.groupPanel_Tables.Style.BorderTop = DevComponents.DotNetBar.eStyleBorderType.Solid; this.groupPanel_Tables.Style.BorderTopWidth = 1; this.groupPanel_Tables.Style.CornerDiameter = 4; this.groupPanel_Tables.Style.CornerType = DevComponents.DotNetBar.eCornerType.Rounded; this.groupPanel_Tables.Style.TextColorSchemePart = DevComponents.DotNetBar.eColorSchemePart.PanelText; this.groupPanel_Tables.TabIndex = 32; this.groupPanel_Tables.Text = "选择表"; // // txbSelectedTable // this.txbSelectedTable.AllowSpace = false; this.txbSelectedTable.ChoiceArray = ((System.Collections.ArrayList)(resources.GetObject("txbSelectedTable.ChoiceArray"))); this.txbSelectedTable.ChoicOnly = false; this.txbSelectedTable.Location = new System.Drawing.Point(77, 10); this.txbSelectedTable.Name = "txbSelectedTable"; this.txbSelectedTable.PromptBackColor = System.Drawing.SystemColors.InfoText; this.txbSelectedTable.PromptForeColor = System.Drawing.SystemColors.InfoText; this.txbSelectedTable.Size = new System.Drawing.Size(208, 21); this.txbSelectedTable.TabIndex = 59; // // cboxSaveConfig // this.cboxSaveConfig.AutoSize = true; this.cboxSaveConfig.BackColor = System.Drawing.SystemColors.GradientActiveCaption; this.cboxSaveConfig.Location = new System.Drawing.Point(22, 419); this.cboxSaveConfig.Name = "cboxSaveConfig"; this.cboxSaveConfig.Size = new System.Drawing.Size(96, 16); this.cboxSaveConfig.TabIndex = 46; this.cboxSaveConfig.Text = "保存本次配置"; this.cboxSaveConfig.UseVisualStyleBackColor = false; // // butCreateCode // this.butCreateCode.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.butCreateCode.ForeColor = System.Drawing.SystemColors.InfoText; this.butCreateCode.Location = new System.Drawing.Point(129, 415); this.butCreateCode.Name = "butCreateCode"; this.butCreateCode.Size = new System.Drawing.Size(75, 23); this.butCreateCode.TabIndex = 47; this.butCreateCode.Text = "生 成"; this.butCreateCode.Click += new System.EventHandler(this.butCreateCode_Click); // // butCode // this.butCode.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.butCode.ForeColor = System.Drawing.SystemColors.InfoText; this.butCode.Location = new System.Drawing.Point(248, 415); this.butCode.Name = "butCode"; this.butCode.Size = new System.Drawing.Size(75, 23); this.butCode.TabIndex = 49; this.butCode.Text = "查看代码"; this.butCode.Click += new System.EventHandler(this.butCode_Click_1); // // prog // this.prog.Location = new System.Drawing.Point(11, 391); this.prog.Name = "prog"; this.prog.Size = new System.Drawing.Size(367, 18); this.prog.Step = 100; this.prog.TabIndex = 48; this.prog.Text = "progressBarX1"; // // GeneraterForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.ClientSize = new System.Drawing.Size(812, 483); this.Controls.Add(this.groupPanel_Tables); this.Controls.Add(this.groupPanel_DataBase); this.Controls.Add(this.groupPanel_Config); this.Controls.Add(this.groupPanel_Template); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.Name = "GeneraterForm"; this.Text = "生成代码"; this.groupPanel_DataBase.ResumeLayout(false); this.groupPanel_Config.ResumeLayout(false); this.groupPanel_Template.ResumeLayout(false); this.groupPanel_Tables.ResumeLayout(false); this.groupPanel_Tables.PerformLayout(); this.ResumeLayout(false); }
public static long OutPutFeat(ref IFeatureClass pDesFeatCls, ref IFeatureClass pOriFeatCls, string sSql, IGeometry pDomainGeometry, bool bIsCut, ref ISpatialReference pSpatialReference, Dictionary <string, string> pDicField, ref ProgressBarX vProgressBar, ref LabelX lblInfo, string sInfo) { long functionReturnValue = 0; //DevComponents.DotNetBar.LabelItem IFeatureCursor pWithINFeatCursor = null; IFeatureCursor pFeatCursor = default(IFeatureCursor); IFeatureLayer pFeatLayer = default(IFeatureLayer); IFeatureSelection pFeatSelection = default(IFeatureSelection); int lFeatCount = 0; bool bInsertRight = true; if (pDesFeatCls == null | pOriFeatCls == null) { return(functionReturnValue); } if (pDesFeatCls.ShapeType == esriGeometryType.esriGeometryPoint) { bIsCut = false; } if (pDomainGeometry == null) { bIsCut = false; } //如果需要剪切,则对面要素类和线要素类分成范围内的要素和与范围相交的要素,提高提取效率 //否则,使用featurecursor进行提取,不进行选择,相对要快 if (lblInfo != null) { lblInfo.Text = sInfo + "正在获得满足条件的要素,请稍候....."; lblInfo.Refresh(); Application.DoEvents(); } if (bIsCut) { pFeatLayer = new FeatureLayer(); pFeatLayer.FeatureClass = pOriFeatCls; pFeatLayer.Name = pOriFeatCls.AliasName; //获得选择集 pFeatSelection = ClsSelectAndQuery.GetFeatSelection(ref pFeatLayer, sSql, esriSelectionResultEnum.esriSelectionResultNew, esriSpatialRelEnum.esriSpatialRelIntersects, ref pDomainGeometry); lFeatCount = pFeatSelection.SelectionSet.Count; if (vProgressBar != null) { vProgressBar.Value = 0; vProgressBar.Maximum = lFeatCount; } //获得位范围内的以及与范围相交的要素集 ClsSelectAndQuery.ClassifyFeatCursorByGeometry(ref pFeatSelection, pDomainGeometry, ref pWithINFeatCursor, pDesFeatCls.ShapeType); // 陈昉 2009-3-12 修改 修改原因 原来的方法不能搜索到包含一此Geometry的要素 //ClassifyFeatCursorByGeometry(pFeatSelection, pDomainGeometry, pWithINFeatCursor, pCrossFeatCursor, pDesFeatCls.ShapeType) if (lblInfo != null) { lblInfo.Text = sInfo + "正在输出要素,请稍候....."; lblInfo.Refresh(); Application.DoEvents(); } InsertFeatIntoFeatClsByCursor(ref pDesFeatCls, ref pWithINFeatCursor, true, pDomainGeometry, ref pSpatialReference, pDicField, ref vProgressBar); //首先把位于图幅内的要素插入 //InsertFeatIntoFeatClsByCursor(pDesFeatCls, pWithINFeatCursor, True, pDomainGeometry, pSpatialReference, _ // pDicField, vProgressBar) //'再把与范围相交的要素插入,(插入时需要进行剪切) //InsertFeatIntoFeatClsByCursor(pDesFeatCls, pCrossFeatCursor, True, pDomainGeometry, pSpatialReference, _ // pDicField, vProgressBar) } else { //获得需要提取的要素 long lFeatCount2 = (long)lFeatCount; pFeatCursor = ClsSelectAndQuery.GetFeatCursor(pOriFeatCls, sSql, esriSpatialRelEnum.esriSpatialRelIntersects, ref pDomainGeometry, true, ref lFeatCount2); lFeatCount = (int)lFeatCount2; if (vProgressBar != null) { vProgressBar.Maximum = lFeatCount; vProgressBar.Value = 0; } if (lblInfo != null) { lblInfo.Text = sInfo + "正在输出要素,请稍候....."; lblInfo.Refresh(); Application.DoEvents(); } bInsertRight = InsertFeatIntoFeatClsByCursor(ref pDesFeatCls, ref pFeatCursor, false, pDomainGeometry, ref pSpatialReference, pDicField, ref vProgressBar); //印骅 20081202 Insert失败,退出函数 if (bInsertRight == false) { functionReturnValue = -1; return(functionReturnValue); } } //杨旭斌于20080825添加,返回提取的要素个数 functionReturnValue = lFeatCount; if ((vProgressBar != null)) { //vProgressBar.Visible = False vProgressBar.Value = 0; } pWithINFeatCursor = null; return(functionReturnValue); }
//** 功能描述: 通过FeatureCursor向目标要素类中插入要素 //** 参数列表: pDesFeatCls (IFeatureClass) // pFeatCursor (IFeatureCursor) public static bool InsertFeatIntoFeatClsByCursor(ref IFeatureClass pDesFeatCls, ref IFeatureCursor pFeatCursor, bool bIsCut, IGeometry pDomainGeometry, ref ISpatialReference pSpatialReference, Dictionary <string, string> pDicField, ref ProgressBarX vProgressBar) { bool functionReturnValue = false; //要素类,用于循环 IFeature pFeat = default(IFeature); //用新建要素类的游标,使用该游标向新要素类中插入要素,并写入数据库 IFeatureCursor pDesFeatCursor = default(IFeatureCursor); //新建要素类创建的要素缓冲区 IFeatureBuffer pDesFeatBuffer = default(IFeatureBuffer); int iFeatCount = 0; IGeometry pGeometry = default(IGeometry); esriGeometryDimension EnumGeometryDimension = default(esriGeometryDimension); IGeometry pDesGeometry = default(IGeometry); bool bTransferRight = true; //记录InsertOneFeatIntoCursor的返回值 //On Error Resume Next if (pDomainGeometry == null) { bIsCut = false; } if (pDesFeatCls.ShapeType == esriGeometryType.esriGeometryPolyline) { EnumGeometryDimension = esriGeometryDimension.esriGeometry1Dimension; } else if (pDesFeatCls.ShapeType == esriGeometryType.esriGeometryPolygon) { EnumGeometryDimension = esriGeometryDimension.esriGeometry2Dimension; } else { bIsCut = false; } try { pFeat = pFeatCursor.NextFeature(); if (pFeat != null) { //从新建要素类中获得新游标,用于插入新的要素 pDesFeatCursor = pDesFeatCls.Insert(true); //创建要素缓冲区,和insert cursor 配合,创建新要素 pDesFeatBuffer = pDesFeatCls.CreateFeatureBuffer(); while (pFeat != null) { pGeometry = pFeat.ShapeCopy; if (pGeometry != null) { if (pGeometry.IsEmpty == false) { iFeatCount = iFeatCount + 1; //进行剪切或不剪切 if (bIsCut) { pDesGeometry = ClsGeometryOperator.CutFeatByGeometry(ref pGeometry, ref pDomainGeometry, ref EnumGeometryDimension); } else { pDesGeometry = pGeometry; } bTransferRight = InsertOneFeatIntoCursor(ref pFeat, pDesGeometry, ref pDesFeatCursor, ref pDesFeatBuffer, pSpatialReference, ref pDicField); //印骅 20081202 如果投影失败 则跳出函数 if (bTransferRight == false) { return(functionReturnValue); } //每一千个要素就把缓冲区内的要素类写入数据库 if (iFeatCount >= 1000) { pDesFeatCursor.Flush(); iFeatCount = 0; System.Windows.Forms.Application.DoEvents(); } if ((vProgressBar != null)) { vProgressBar.Value = vProgressBar.Value + 1; } } } pFeat = pFeatCursor.NextFeature(); } if (iFeatCount % 1000 != 0) { pDesFeatCursor.Flush(); } pDesFeatCursor = null; pDesFeatBuffer = null; } } catch (System.Runtime.InteropServices.COMException ex) { if (ex.ErrorCode == -2147216556) { functionReturnValue = false; //g_clsErrorHandle.DisplayInformation(string.Format("目标数据{0}正被其他程序使用,请检查", ((IDataset)pDesFeatCls).Name), false); MessageBoxEx.Show(string.Format("目标数据{0}正被其他程序使用,请检查", ((IDataset)pDesFeatCls).Name), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } functionReturnValue = true; return(functionReturnValue); //正常退出,返回true }
public static void ScanFiles(List <string> list, Label CurFile, ProgressBarX progress, ItemPanel lst, bool block) { Stopwatch st = Stopwatch.StartNew(); int total = 0; int scanned = 0; object vir = null; try { if (AVEngine.ScanSensitivity == ScanSense.High) { total = list.Count; foreach (string file in list) { scanned++; GUI.UpdateProgress(progress, scanned, total); GUI.UpdateLabel(CurFile, file); vir = FileFormat.GetFileFormat(file).ScanHS(file, CurFile); if (vir != null) { if (FileFormat.GetFileFormat(file) == AVEngine.ArchiveTypeScanner) { string[] s = vir.ToString().Split('&'); GUI.UpdatePanel(new Virus(s[0], file, s[1], FileFormat.GetFileFormat(file)), lst); } else { GUI.UpdatePanel(new Virus(vir.ToString(), file, FileFormat.GetFileFormat(file)), lst); } } } } else if (AVEngine.ScanSensitivity == ScanSense.Medium) { total = list.Count; foreach (string file in list) { scanned++; GUI.UpdateProgress(progress, scanned, total); GUI.UpdateLabel(CurFile, file); vir = FileFormat.GetFileFormat(file).ScanM(file, CurFile); if (vir != null) { if (FileFormat.GetFileFormat(file) == AVEngine.ArchiveTypeScanner) { string[] s = vir.ToString().Split('&'); GUI.UpdatePanel(new Virus(s[0], file, s[1], FileFormat.GetFileFormat(file)), lst); } else { GUI.UpdatePanel(new Virus(vir.ToString(), file, FileFormat.GetFileFormat(file)), lst); } } } } else { total = list.Count; foreach (string file in list) { scanned++; GUI.UpdateProgress(progress, scanned, total); GUI.UpdateLabel(CurFile, file); vir = FileFormat.GetFileFormat(file).Scan(file, CurFile); if (vir != null) { if (FileFormat.GetFileFormat(file) == AVEngine.ArchiveTypeScanner) { string[] s = vir.ToString().Split('&'); GUI.UpdatePanel(new Virus(s[0], file, s[1], FileFormat.GetFileFormat(file)), lst); } else { GUI.UpdatePanel(new Virus(vir.ToString(), file, FileFormat.GetFileFormat(file)), lst); } } } } } catch { } finally { st.Stop(); // alert needed GUI.UpdateLabel(CurFile, "Scan Performed in " + st.Elapsed.ToString()); Alert.ScanCompleted(); } }
public static void IDPScan(Label CurFile, ProgressBarX progress, ItemPanel lst) { Stopwatch st = Stopwatch.StartNew(); int total = 0; int scanned = 0; if (VDB.GetIDPCount() > 2) { #region GetCount foreach (string drv in Environment.GetLogicalDrives()) { Stack <string> stack = new Stack <string>(); // 3. // Add initial directory. stack.Push(drv); // 4. // Continue while there are directories to process while (stack.Count > 0) { // A. // Get top directory string dir = stack.Pop(); try { // scan all files in directory foreach (string file in Directory.GetFiles(dir, "*.*")) { total++; } // C // Add all directories at this directory. foreach (string dn in Directory.GetDirectories(dir)) { stack.Push(dn); } } catch { } } } #endregion Stack <string> sstack = new Stack <string>(); // 3. // Add initial directory. foreach (string drive in Environment.GetLogicalDrives()) { sstack.Push(drive); } // 4. // Continue while there are directories to process while (sstack.Count > 0) { // A. // Get top directory string dir = sstack.Pop(); try { foreach (string file in Directory.GetFiles(dir, "*.exe")) { try { if (File.Exists(file)) { GUI.UpdateLabel(CurFile, file); scanned++; GUI.UpdateProgress(progress, scanned, total); if (!VDB.GetIDP(file, Security.GetMD5HashFromFile(file))) { Virus item = new Virus("KavProtSense.IdentityChanged", file, AVEngine.PETypeScanner); GUI.UpdatePanel(item, lst); } } } catch { } finally { } } foreach (string file in Directory.GetFiles(dir, "*.msi")) { try { if (File.Exists(file)) { GUI.UpdateLabel(CurFile, file); scanned++; GUI.UpdateProgress(progress, scanned, total); if (!VDB.GetIDP(file, Security.GetMD5HashFromFile(file))) { Virus item = new Virus("KavProtSense.IdentityChanged", file, AVEngine.PETypeScanner); GUI.UpdatePanel(item, lst); } } } catch { } finally { } } foreach (string file in Directory.GetFiles(dir, "*.dll")) { try { if (File.Exists(file)) { GUI.UpdateLabel(CurFile, file); scanned++; GUI.UpdateProgress(progress, scanned, total); if (!VDB.GetIDP(file, Security.GetMD5HashFromFile(file))) { Virus item = new Virus("KavProtSense.IdentityChanged", file, AVEngine.PETypeScanner); GUI.UpdatePanel(item, lst); } } } catch { } finally { } } // C // Add all directories at this directory. foreach (string dn in Directory.GetDirectories(dir)) { sstack.Push(dn); } } catch { // D // Could not open the directory } } } else { Stack <string> sstack = new Stack <string>(); // 3. // Add initial directory. foreach (string drive in Environment.GetLogicalDrives()) { sstack.Push(drive); } // 4. // Continue while there are directories to process while (sstack.Count > 0) { // A. // Get top directory string dir = sstack.Pop(); try { VDB.AddIDP(Directory.GetFiles(dir, "*.exe"), progress); VDB.AddIDP(Directory.GetFiles(dir, "*.msi"), progress); VDB.AddIDP(Directory.GetFiles(dir, "*.dll"), progress); // C // Add all directories at this directory. foreach (string dn in Directory.GetDirectories(dir)) { sstack.Push(dn); } } catch { // D // Could not open the directory } } } st.Stop(); // alert needed GUI.UpdateLabel(CurFile, "Scan Performed in " + st.Elapsed.ToString()); Alert.ScanCompleted(); }
//private static IFeatureWorkspace m_FeatureWorkspace; /// <summary> /// 数据编码(自动赋值编码) /// </summary> /// <param name="source">源要素类</param> /// <param name="target">目标要素类</param> /// <param name="relation">匹配结果表</param> /// <param name="updateRela">欲更新的属性表字段</param> /// <param name="pProgressBarX"></param> /// <param name="targetFeatureWorkspace">待匹配图层路径</param> /// <returns></returns> //public static bool UpdateData(IFeatureClass sourceFcls, IFeatureClass targetFcls, ITable resultTable, Dictionary<string, string> updateRela // , ProgressBarX pProgressBarX, IFeatureWorkspace targetFeatureWorkspace) public static bool UpdateData(IFeatureClass sourceFcls, IFeatureClass targetFcls, ITable resultTable, ProgressBarX pProgressBarX, IFeatureWorkspace targetFeatureWorkspace) { ClsBarSync progressBar = new ClsBarSync(pProgressBarX); progressBar.SetStep(1); progressBar.SetMax(resultTable.RowCount(null)); //检查参数 if (sourceFcls == null || targetFcls == null || resultTable == null) { return(false); } #region 原注释 //当欲更新字段在目标要素类中不存在时,新建字段 //foreach (string item in fields) //{ // if (target.FindField(item) == -1) // { // IField addedField = source.Fields.get_Field(source.FindField(item)); // target.AddField(addedField); // } //} #endregion //20170914 注释掉 ////当欲更新字段在目标要素类中不存在时,新建字段 //foreach (KeyValuePair<string, string> item in updateRela) //{ // if (targetFcls.FindField(item.Value) == -1) // { // IField addedField = new FieldClass(); // IFieldEdit pFieldEdit = addedField as IFieldEdit; // pFieldEdit.Name_2 = item.Value; // pFieldEdit.AliasName_2 = item.Value; // pFieldEdit.Editable_2 = true; // pFieldEdit.Required_2 = false; // pFieldEdit.IsNullable_2 = true; // targetFcls.AddField(addedField); // } //} IWorkspaceEdit2 pWorkspaceEdit = targetFeatureWorkspace as IWorkspaceEdit2; pWorkspaceEdit.StartEditing(false); pWorkspaceEdit.StartEditOperation(); #region 20170515注释掉 //ClsUpdateCommon.EnableAchive(target.AliasName, targetFeatureWorkspace); //IHistoricalWorkspace pHistoricalWorkspace = targetFeatureWorkspace as IHistoricalWorkspace; //DateTime dTime=DateTime.Now; //pHistoricalWorkspace.AddHistoricalMarker(dTime.ToString(), dTime);//严格应该为数据库时间 #endregion #region 原来注释 //foreach (KeyValuePair<string, string> item in updateRela) //{ // if (target.FindField(item.Value) == -1) // { // IField addedField = new FieldClass(); // IFieldEdit pFieldEdit = addedField as IFieldEdit; // pFieldEdit.Name_2 = item.Value; // pFieldEdit.AliasName_2 = item.Value; // pFieldEdit.Editable_2 = true; // pFieldEdit.Required_2 = false; // pFieldEdit.IsNullable_2 = true; // target.AddField(addedField); // } //} #endregion //源图层要素的oid——1 int pSrcOIDIndex = resultTable.FindField("源OID"); //待匹配图层要素的oid——2 int pTarOIDIndex = resultTable.FindField("待匹配OID"); //变化标记的oid——3 int pChangeTagIndex = resultTable.FindField("变化标记"); ICursor rowCursor = resultTable.Search(null, false); IRow tempRow = null; tempRow = rowCursor.NextRow(); while (tempRow != null) { //当没有匹配的项时或者未发生变化时不做任何更改 if (tempRow.get_Value(pTarOIDIndex) == null || tempRow.get_Value(pChangeTagIndex).ToString() == "0") { progressBar.PerformOneStep(); continue; } //获取源图层要素 IFeature sourceFeature = sourceFcls.GetFeature(Convert.ToInt32(tempRow.get_Value(pSrcOIDIndex))); //变化标记字段值 string pChangeContent = tempRow.get_Value(pChangeTagIndex).ToString(); //获取源图层要素 string[] fromids = tempRow.get_Value(pTarOIDIndex).ToString().Split(';'); if (!(fromids.Length == 1 && fromids[0].Trim().Length == 0)) { //查找匹配与待匹配的要素 IFeature targetFeature = null; //点和线匹配名称 string pSourceName = sourceFeature.get_Value(sourceFeature.Fields.FindField(ClsConfig.LayerConfigs[(sourceFcls as IDataset).Name].NameField)).ToString(); string pTargetName = string.Empty; //面匹配分类码 //string pSourceFCODE = sourceFeature.get_Value(sourceFeature.Fields.FindField("FCODE")).ToString().Trim(); string pTargetFCODE = string.Empty; //不同形状的数据 if (sourceFcls.ShapeType != targetFcls.ShapeType) { if (sourceFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint) { //根据不同的匹配类型进行相关操作 switch (pChangeContent) { case "图形变化": //图形变化 //case "一对一": case ClsConstant.One2One: //targetFeature.Shape = sourceFeature.Shape; //plistString.Add(sourceFeature.get_Value(sourceFeature.Fields.FindField("ENTIID")).ToString()); //test targetFeature = targetFcls.GetFeature(Convert.ToInt32(tempRow.get_Value(pTarOIDIndex))); string test3 = ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].NameField; pTargetName = targetFeature.get_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].NameField)).ToString(); //test string test1 = targetFeature.get_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].EntityID)).ToString(); string test2 = sourceFeature.get_Value(sourceFeature.Fields.FindField(ClsConfig.LayerConfigs[(sourceFcls as IDataset).Name].EntityID)).ToString(); if (ClsStatic.StringSameOrNot(pSourceName, pTargetName) > 1) { targetFeature.set_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].EntityID), sourceFeature.get_Value(sourceFeature.Fields.FindField(ClsConfig.LayerConfigs[(sourceFcls as IDataset).Name].EntityID))); targetFeature.Store(); } //sourceFeature.set_Value(sourceFeature.Fields.FindField("ENTIID"), targetFeature.get_Value(targetFeature.Fields.FindField("ENTIID"))); break; //case "新增要素"://新添加要素 case ClsConstant.One2Zero: //新添加要素 //targetFeature = target.CreateFeature(); //targetFeature.Shape = sourceFeature.ShapeCopy; //UpdateAttribute(sourceFeature, targetFeature, updateRela); break; //case "一对多": case ClsConstant.One2More: //for (int i = 0; i < fromids.Length; i++) //{ // string test = fromids[i]; // int test3 = Convert.ToInt32(fromids[i]); // targetFeature = target.GetFeature(Convert.ToInt32(fromids[i])); // pTargetName = targetFeature.get_Value(targetFeature.Fields.FindFieldByAliasName("名称")).ToString(); // //targetFeature.Shape = sourceFeature.Shape; // if (ClsStatic.StringSameOrNot(pSourceName, pTargetName) > 1) // { // if (targetFeature.get_Value(targetFeature.Fields.FindField("ENTIID")).ToString().Trim().Length == 0) // { // targetFeature.set_Value(targetFeature.Fields.FindField("ENTIID"), sourceFeature.get_Value(sourceFeature.Fields.FindField("ENTIID"))); // targetFeature.Store(); // } // } //} //MessageBox.Show("出现一对多情况,请校对匹配结果表后执行匹配", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //return false; break; case "属性变化": //属性变化 //UpdateAttribute(sourceFeature, targetFeature, updateRela); break; case "属性图形变化": //都变化 //targetFeature.Shape = sourceFeature.Shape; //UpdateAttribute(sourceFeature, targetFeature, updateRela); break; //case "多对一"://多尺度更新 case ClsConstant.More2One: //多尺度更新 //targetFeature.Shape = finalGeometry; break; default: break; } } else if (sourceFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { //根据不同的匹配类型进行相关操作 switch (pChangeContent) { case "图形变化": //图形变化 //case "一对一": case ClsConstant.One2One: targetFeature = targetFcls.GetFeature(Convert.ToInt32(tempRow.get_Value(pTarOIDIndex))); pTargetName = targetFeature.get_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].NameField)).ToString(); //targetFeature.Shape = sourceFeature.Shape; if (pSourceName == pTargetName) { targetFeature.set_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].EntityID), sourceFeature.get_Value(sourceFeature.Fields.FindField(ClsConfig.LayerConfigs[(sourceFcls as IDataset).Name].EntityID))); targetFeature.Store(); } //sourceFeature.set_Value(sourceFeature.Fields.FindField("ENTIID"), targetFeature.get_Value(targetFeature.Fields.FindField("ENTIID"))); break; //case "新增要素"://新添加要素 case ClsConstant.One2Zero: //新添加要素 //targetFeature = target.CreateFeature(); //targetFeature.Shape = sourceFeature.ShapeCopy; //UpdateAttribute(sourceFeature, targetFeature, updateRela); break; //case "一对多": case ClsConstant.One2More: //MessageBox.Show("出现一对多情况,请校对匹配结果表后执行匹配", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //return false; for (int i = 0; i < fromids.Length; i++) { string test = fromids[i]; int test2 = Convert.ToInt32(fromids[i]); targetFeature = targetFcls.GetFeature(Convert.ToInt32(fromids[i])); pTargetName = targetFeature.get_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].NameField)).ToString(); //targetFeature.Shape = sourceFeature.Shape; if (pSourceName == pTargetName) { if (targetFeature.get_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].EntityID)).ToString().Trim().Length == 0) { targetFeature.set_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].EntityID), sourceFeature.get_Value(sourceFeature.Fields.FindField(ClsConfig.LayerConfigs[(sourceFcls as IDataset).Name].EntityID))); targetFeature.Store(); } } } break; case "属性变化": //属性变化 //UpdateAttribute(sourceFeature, targetFeature, updateRela); break; case "属性图形变化": //都变化 //targetFeature.Shape = sourceFeature.Shape; //UpdateAttribute(sourceFeature, targetFeature, updateRela); break; //case "多对一"://多尺度更新 case ClsConstant.More2One: //多尺度更新 //targetFeature.Shape = finalGeometry; break; default: break; } } else if (sourceFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon) { //根据不同的匹配类型进行相关操作 switch (pChangeContent) { case "图形变化": //图形变化 //case "一对一": case ClsConstant.One2One: targetFeature = targetFcls.GetFeature(Convert.ToInt32(tempRow.get_Value(pTarOIDIndex))); pTargetFCODE = targetFeature.get_Value(targetFeature.Fields.FindField("FCODE")).ToString().Trim(); //targetFeature.Shape = sourceFeature.Shape; //if (pSourceFCODE == pTargetFCODE) //{ targetFeature.set_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].EntityID), sourceFeature.get_Value(sourceFeature.Fields.FindField(ClsConfig.LayerConfigs[(sourceFcls as IDataset).Name].EntityID))); targetFeature.Store(); //} //sourceFeature.set_Value(sourceFeature.Fields.FindField("ENTIID"), targetFeature.get_Value(targetFeature.Fields.FindField("ENTIID"))); break; //case "新增要素"://新添加要素 case ClsConstant.One2Zero: //新添加要素 //targetFeature = target.CreateFeature(); //targetFeature.Shape = sourceFeature.ShapeCopy; //UpdateAttribute(sourceFeature, targetFeature, updateRela); break; //case "一对多": case ClsConstant.One2More: //MessageBox.Show("出现一对多情况,请校对匹配结果表后执行匹配", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //return false; //for (int i = 0; i < fromids.Length; i++) //{ // string test = fromids[i]; // int test2 = Convert.ToInt32(fromids[i]); // targetFeature = targetFcls.GetFeature(Convert.ToInt32(fromids[i])); // pTargetName = targetFeature.get_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].NameField)).ToString(); // //targetFeature.Shape = sourceFeature.Shape; // if (pSourceName == pTargetName) // { // if (targetFeature.get_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].EntityID)).ToString().Trim().Length == 0) // { // targetFeature.set_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].EntityID), sourceFeature.get_Value(sourceFeature.Fields.FindField(ClsConfig.LayerConfigs[(sourceFcls as IDataset).Name].EntityID))); // targetFeature.Store(); // } // } //} break; case "属性变化": //属性变化 //UpdateAttribute(sourceFeature, targetFeature, updateRela); break; case "属性图形变化": //都变化 //targetFeature.Shape = sourceFeature.Shape; //UpdateAttribute(sourceFeature, targetFeature, updateRela); break; //case "多对一"://多尺度更新 case ClsConstant.More2More: //多尺度更新 //targetFeature.Shape = finalGeometry; break; default: break; } } } //相同形状的数据 else { if (sourceFeature.Shape.GeometryType == esriGeometryType.esriGeometryPoint) { //根据不同的匹配类型进行相关操作 switch (pChangeContent) { case "图形变化": //图形变化 //case "一对一": case ClsConstant.One2One: //targetFeature.Shape = sourceFeature.Shape; //plistString.Add(sourceFeature.get_Value(sourceFeature.Fields.FindField("ENTIID")).ToString()); //test targetFeature = targetFcls.GetFeature(Convert.ToInt32(tempRow.get_Value(pTarOIDIndex))); //string test3 = ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].NameField; string test3 = ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].NameField; pTargetName = targetFeature.get_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].NameField)).ToString(); //test string test1 = targetFeature.get_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].EntityID)).ToString(); string test2 = sourceFeature.get_Value(sourceFeature.Fields.FindField(ClsConfig.LayerConfigs[(sourceFcls as IDataset).Name].EntityID)).ToString(); //if (ClsStatic.StringSameOrNot(pSourceName, pTargetName) > 1) //{ targetFeature.set_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].EntityID), sourceFeature.get_Value(sourceFeature.Fields.FindField(ClsConfig.LayerConfigs[(sourceFcls as IDataset).Name].EntityID))); targetFeature.Store(); //} //sourceFeature.set_Value(sourceFeature.Fields.FindField("ENTIID"), targetFeature.get_Value(targetFeature.Fields.FindField("ENTIID"))); break; //case "新增要素"://新添加要素 case ClsConstant.One2Zero: //新添加要素 //targetFeature = target.CreateFeature(); //targetFeature.Shape = sourceFeature.ShapeCopy; //UpdateAttribute(sourceFeature, targetFeature, updateRela); break; //case "一对多": case ClsConstant.One2More: //for (int i = 0; i < fromids.Length; i++) //{ // string test = fromids[i]; // int test3 = Convert.ToInt32(fromids[i]); // targetFeature = target.GetFeature(Convert.ToInt32(fromids[i])); // pTargetName = targetFeature.get_Value(targetFeature.Fields.FindFieldByAliasName("名称")).ToString(); // //targetFeature.Shape = sourceFeature.Shape; // if (ClsStatic.StringSameOrNot(pSourceName, pTargetName) > 1) // { // if (targetFeature.get_Value(targetFeature.Fields.FindField("ENTIID")).ToString().Trim().Length == 0) // { // targetFeature.set_Value(targetFeature.Fields.FindField("ENTIID"), sourceFeature.get_Value(sourceFeature.Fields.FindField("ENTIID"))); // targetFeature.Store(); // } // } //} //MessageBox.Show("出现一对多情况,请校对匹配结果表后执行匹配", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //return false; break; case "属性变化": //属性变化 //UpdateAttribute(sourceFeature, targetFeature, updateRela); break; case "属性图形变化": //都变化 //targetFeature.Shape = sourceFeature.Shape; //UpdateAttribute(sourceFeature, targetFeature, updateRela); break; //case "多对一"://多尺度更新 case ClsConstant.More2One: //多尺度更新 //targetFeature.Shape = finalGeometry; break; default: break; } } else if (sourceFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { //根据不同的匹配类型进行相关操作 switch (pChangeContent) { case "图形变化": //图形变化 //case "一对一": case ClsConstant.One2One: targetFeature = targetFcls.GetFeature(Convert.ToInt32(tempRow.get_Value(pTarOIDIndex))); pTargetName = targetFeature.get_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].NameField)).ToString(); //targetFeature.Shape = sourceFeature.Shape; //if (pSourceName == pTargetName) //{ targetFeature.set_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].EntityID), sourceFeature.get_Value(sourceFeature.Fields.FindField(ClsConfig.LayerConfigs[(sourceFcls as IDataset).Name].EntityID))); targetFeature.Store(); //} //sourceFeature.set_Value(sourceFeature.Fields.FindField("ENTIID"), targetFeature.get_Value(targetFeature.Fields.FindField("ENTIID"))); break; //case "新增要素"://新添加要素 case ClsConstant.One2Zero: //新添加要素 //targetFeature = target.CreateFeature(); //targetFeature.Shape = sourceFeature.ShapeCopy; //UpdateAttribute(sourceFeature, targetFeature, updateRela); break; //case "一对多": case ClsConstant.One2More: //MessageBox.Show("出现一对多情况,请校对匹配结果表后执行匹配", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //return false; for (int i = 0; i < fromids.Length; i++) { string test = fromids[i]; int test2 = Convert.ToInt32(fromids[i]); targetFeature = targetFcls.GetFeature(Convert.ToInt32(fromids[i])); pTargetName = targetFeature.get_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].NameField)).ToString(); //targetFeature.Shape = sourceFeature.Shape; if (pSourceName == pTargetName) { if (targetFeature.get_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].EntityID)).ToString().Trim().Length == 0) { targetFeature.set_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].EntityID), sourceFeature.get_Value(sourceFeature.Fields.FindField(ClsConfig.LayerConfigs[(sourceFcls as IDataset).Name].EntityID))); targetFeature.Store(); } } } break; case "属性变化": //属性变化 //UpdateAttribute(sourceFeature, targetFeature, updateRela); break; case "属性图形变化": //都变化 //targetFeature.Shape = sourceFeature.Shape; //UpdateAttribute(sourceFeature, targetFeature, updateRela); break; //case "多对一"://多尺度更新 case ClsConstant.More2One: //多尺度更新 //targetFeature.Shape = finalGeometry; break; default: break; } } else if (sourceFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon) { //根据不同的匹配类型进行相关操作 switch (pChangeContent) { case "图形变化": //图形变化 //case "一对一": case ClsConstant.One2One: targetFeature = targetFcls.GetFeature(Convert.ToInt32(tempRow.get_Value(pTarOIDIndex))); pTargetFCODE = targetFeature.get_Value(targetFeature.Fields.FindField("FCODE")).ToString().Trim(); //targetFeature.Shape = sourceFeature.Shape; //if (pSourceFCODE == pTargetFCODE) //{ targetFeature.set_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].EntityID), sourceFeature.get_Value(sourceFeature.Fields.FindField(ClsConfig.LayerConfigs[(sourceFcls as IDataset).Name].EntityID))); targetFeature.Store(); //} //sourceFeature.set_Value(sourceFeature.Fields.FindField("ENTIID"), targetFeature.get_Value(targetFeature.Fields.FindField("ENTIID"))); break; //case "新增要素"://新添加要素 case ClsConstant.One2Zero: //新添加要素 //targetFeature = target.CreateFeature(); //targetFeature.Shape = sourceFeature.ShapeCopy; //UpdateAttribute(sourceFeature, targetFeature, updateRela); break; //case "一对多": case ClsConstant.One2More: //MessageBox.Show("出现一对多情况,请校对匹配结果表后执行匹配", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //return false; //for (int i = 0; i < fromids.Length; i++) //{ // string test = fromids[i]; // int test2 = Convert.ToInt32(fromids[i]); // targetFeature = targetFcls.GetFeature(Convert.ToInt32(fromids[i])); // pTargetName = targetFeature.get_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].NameField)).ToString(); // //targetFeature.Shape = sourceFeature.Shape; // if (pSourceName == pTargetName) // { // if (targetFeature.get_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].EntityID)).ToString().Trim().Length == 0) // { // targetFeature.set_Value(targetFeature.Fields.FindField(ClsConfig.LayerConfigs[(targetFcls as IDataset).Name].EntityID), sourceFeature.get_Value(sourceFeature.Fields.FindField(ClsConfig.LayerConfigs[(sourceFcls as IDataset).Name].EntityID))); // targetFeature.Store(); // } // } //} break; case "属性变化": //属性变化 //UpdateAttribute(sourceFeature, targetFeature, updateRela); break; case "属性图形变化": //都变化 //targetFeature.Shape = sourceFeature.Shape; //UpdateAttribute(sourceFeature, targetFeature, updateRela); break; //case "多对一"://多尺度更新 case ClsConstant.More2More: //多尺度更新 //targetFeature.Shape = finalGeometry; break; default: break; } } } //targetFeature.Store(); } progressBar.PerformOneStep(); tempRow = rowCursor.NextRow(); } //对待匹配图层中剩余的点()进行编码 //CreatePOICodeRest(target, "ENTIID", plistString); pWorkspaceEdit.StopEditOperation(); pWorkspaceEdit.StopEditing(true); return(true); }
public ClsBarSync(ProgressBarX progress) { barProgress = progress; }