public IndexForm(Form parent, TableClass tableObject, DBRegistrationClass dbReg, List <TableClass> tables) { InitializeComponent(); this.MdiParent = parent; BearbeitenMode = StateClasses.EditStateClass.eBearbeiten.eInsert; _dbReg = dbReg; _localNotify.Notify.OnRaiseErrorHandler += Notify_OnRaiseErrorHandler; _localNotify.Notify.OnRaiseInfoHandler += Notify_OnRaiseInfoHandler; _orgTableObject = tableObject; _tableObject = tableObject; _orgIndexObject = new IndexClass(); _orgIndexObject.Name = $@"{tableObject.Name}_INX"; _orgIndexObject.IsActive = true; _indexObject = _orgIndexObject; _tables = tables; _indexActiveChanged = false; lvFields.Items.Clear(); txtIndexName.Text = MakeNewIndexName(); FillSortingToCombo(); _dataFilled = true; }
public ActionResult SiparisOnayla(SiparisProductModel spm) { IndexClass ic = new IndexClass(); if (spm != null) { SessionModel sm = ControlSession(); if (sm != null) { Users u = db.Users.FirstOrDefault(x => x.Kadi == sm.Kadi && x.Sifre == sm.Sifre); if (u != null) { int a = ic.SiparisOnayla(spm, u); if (a == 1) { return(new RedirectResult(@"~/Home/Index?m=1")); } else if (a == 2) { return(new RedirectResult(@"~/Home/Index?m=2")); } else if (a == 0) { return(new RedirectResult(@"~/Home/Index?m=0")); } } } else { return(RedirectToAction("Login")); } } return(RedirectToAction("Index")); }
public IndexForm(Form parent, IndexClass indexObject, DBRegistrationClass dbReg, List <TableClass> tables) { InitializeComponent(); this.MdiParent = parent; BearbeitenMode = eBearbeiten.eEdit; _dbReg = dbReg; cbFields.Items.Clear(); lvFields.Items.Clear(); _indexObject = indexObject; _orgIndexObject = indexObject; var TableName = RefreshIndicesAndGetTablename(_orgIndexObject.Name); _tableObject = tables.Find(X => X.Name == TableName); // _tableObject.Indices.TryGetValue(_orgIndexObject.Name,out _orgIndexObject); _indexActiveChanged = false; _localNotify.Notify.OnRaiseErrorHandler += Notify_OnRaiseErrorHandler; _localNotify.Notify.OnRaiseInfoHandler += Notify_OnRaiseInfoHandler; _tables = tables; // _tableObject = StaticTreeClass.Instance().GetTableObjectForIndexForm(_dbReg, TableName); _orgTableObject = _tableObject; FillSortingToCombo(); _dataFilled = true; }
public static void Execute(IFeatureClass featureClass, String indexName, String nameOfField) { // Ensure the feature class contains the specified field. int fieldIndex = featureClass.FindField(nameOfField); if (fieldIndex == -1) { throw new ArgumentException("The specified field does not exist in the feature class."); } // Get the specified field from the feature class. IFields featureClassFields = featureClass.Fields; IField field = featureClassFields.get_Field(fieldIndex); // Create a fields collection and add the specified field to it. IFields fields = new FieldsClass(); IFieldsEdit fieldsEdit = (IFieldsEdit)fields; fieldsEdit.FieldCount_2 = 1; fieldsEdit.set_Field(0, field); // Create an index and cast to the IIndexEdit interface. IIndex index = new IndexClass(); IIndexEdit indexEdit = (IIndexEdit)index; // Set the index's properties, including the associated fields. indexEdit.Fields_2 = fields; indexEdit.IsAscending_2 = false; indexEdit.IsUnique_2 = false; indexEdit.Name_2 = indexName; // Add the index to the feature class. featureClass.AddIndex(index); }
private void hotSpot2_Click(object sender, EventArgs e) { BearbeitenMode = StateClasses.EditStateClass.eBearbeiten.eInsert; ckActive.Checked = true; _indexActiveChanged = false; lvFields.Items.Clear(); _indexObject = _orgIndexObject; txtIndexName.Text = MakeNewIndexName(); MakeSQL(); }
public static void createSpatialIndex(IFeatureClass fc, double gridOneSize = 0.0, double gridTwoSize = 0.0, double gridThreeSize = 0.0) { String shapeFieldName = fc.ShapeFieldName; // Clone the shape field from the feature class. int shapeFieldIndex = fc.FindField(shapeFieldName); IFields fields = fc.Fields; IField sourceField = fields.get_Field(shapeFieldIndex); IClone sourceFieldClone = (IClone)sourceField; IClone targetFieldClone = sourceFieldClone.Clone(); IField targetField = (IField)targetFieldClone; // Open the geometry definition from the cloned field and modify it. IGeometryDef geometryDef = targetField.GeometryDef; IGeometryDefEdit geometryDefEdit = (IGeometryDefEdit)geometryDef; if (gridTwoSize > 0.0) { geometryDefEdit.GridCount_2 = 1; geometryDefEdit.set_GridSize(0, gridOneSize); } if (gridTwoSize > 0.0) { geometryDefEdit.GridCount_2 = 2; geometryDefEdit.set_GridSize(1, gridTwoSize); } if (gridThreeSize > 0.0) { geometryDefEdit.GridCount_2 = 3; geometryDefEdit.set_GridSize(2, gridThreeSize); } // Create a spatial index and set the required attributes. IIndex newIndex = new IndexClass(); IIndexEdit newIndexEdit = (IIndexEdit)newIndex; newIndexEdit.Name_2 = shapeFieldName + "_Indx"; // Create a fields collection and assign it to the new index. IFields newIndexFields = new FieldsClass(); IFieldsEdit newIndexFieldsEdit = (IFieldsEdit)newIndexFields; newIndexFieldsEdit.AddField(targetField); newIndexEdit.Fields_2 = newIndexFields; // Add the spatial index back into the feature class. fc.AddIndex(newIndex); }
static void Main() { Name[] n = new Name[3]; n[0] = new Name("零"); n[1] = new Name("壹"); n[2] = new Name("贰"); foreach (Name e in n) { Console.WriteLine(e.mname + " "); } IndexClass ind = new IndexClass(); ind[0] = "零零"; ind[1] = "壹壹"; ind[2] = "贰贰"; for (int i = 0; i < ind.Lengh; i++) { Console.WriteLine(ind[i]); } IndexInfo1 info = new IndexInfo1(); info[0] = "男"; info[1] = "女"; info[2] = "男"; info[3] = "无"; info["wewe"] = "无"; Console.WriteLine(info[0]); Console.WriteLine(info[1]); Console.WriteLine(info[2]); Console.WriteLine(info[3]); Console.WriteLine(info["wewe"]); //检索时不太好转换 int 和 string 型的键值 IndexInfo2 info2 = new IndexInfo2(); info2[0] = "张"; info2[1] = "李"; info2[2] = "王"; Console.WriteLine(info2[0] + " " + info2["张"]); Console.WriteLine(info2[1] + " " + info2["李"]); Console.WriteLine(info2[2] + " " + info2["王"]); }
private void updateSpatialIndex() { try { IFieldsEdit fieldsEdit = new FieldsClass(); IIndexEdit indexEditor = new IndexClass(); fieldsEdit.AddField(this.mySelf.Fields.get_Field(1)); indexEditor.Name_2 = "Shape"; indexEditor.Fields_2 = fieldsEdit; this.mySelf.AddIndex((IIndex)indexEditor); } catch (System.Exception ex) { #if DEBUG System.Windows.Forms.MessageBox.Show(ex.Message); #endif eLog.Debug(ex); } }
protected override void RenderAttributes(XElement element, FoRenderOptions options) { base.RenderAttributes(element, options); if (Id.HasValue()) { element.Add(new XAttribute("id", Id)); } if (IndexClass.HasValue()) { element.Add(new XAttribute("index-class", IndexClass)); } if (IndexKey.HasValue()) { element.Add(new XAttribute("index-key", IndexKey)); } if (FlowName.HasValue()) { element.Add(new XAttribute("flow-name", FlowName)); } }
public IndexForm(Form parent, string indexName, DBRegistrationClass dbReg, List <TableClass> tables, eBearbeiten mode) { InitializeComponent(); this.MdiParent = parent; BearbeitenMode = mode; _dbReg = dbReg; cbFields.Items.Clear(); lvFields.Items.Clear(); string TableName = string.Empty; if (mode == eBearbeiten.eInsert) { TableName = tables[0].Name; _orgIndexObject = new IndexClass(); _orgIndexObject.Name = "NEW_INDEX_INX1"; _orgIndexObject.IsActive = true; } else { TableName = RefreshIndicesAndGetTablename(indexName); _tableObject = tables.Find(X => X.Name == TableName); _tableObject.Indices.TryGetValue(indexName, out _orgIndexObject); } _indexObject = _orgIndexObject; _indexActiveChanged = false; _localNotify.Notify.OnRaiseErrorHandler += Notify_OnRaiseErrorHandler; _localNotify.Notify.OnRaiseInfoHandler += Notify_OnRaiseInfoHandler; _tables = tables; _tableObject = StaticTreeClass.Instance().GetTableObjectForIndexForm(_dbReg, TableName); _orgTableObject = _tableObject; FillSortingToCombo(); _dataFilled = true; }
public override Index Decode(XElement data) { List <XElement> nodes = data.Descendants().ToList(); nodes.Sort(CompareElements); Dictionary <string, IndexElement> elements = new Dictionary <string, IndexElement>(); while (nodes.Count > 0) { XElement el = nodes[0]; nodes.RemoveAt(0); switch (el.Name.LocalName.ToLower()) { case "import": XDocument doc = XDocument.Load("Resources/" + el.Attribute("file").Value); nodes.AddRange(doc.Root.Descendants()); nodes.Sort(CompareElements); break; case "class": IndexClass c = classEncoder.Decode(el); elements.Add(c.id, c); break; case "verb": IndexVerb v = verbEncoder.Decode(el); elements.Add(v.id, v); break; case "obj": IndexObject o = objEncoder.Decode(el); elements.Add(o.id, o); break; default: throw new NotImplementedException(); } } }
public ActionResult Index(int?m) { IndexClass ic = new IndexClass(); if (m != null) { string msg = ic.GetAlertMessage(Convert.ToInt32(m)); Response.Write(msg); } SessionModel sm = ControlSession(); if (sm != null) { string adsoyad = GetNameSurnameBakiye(); if (adsoyad != null) { Response.Write("<label style='color:red;'>Hoşgeldiniz; " + adsoyad + " </label>"); } List <IndexProductModel> lipm = ic.UrunListesi(); return(View(lipm)); } return(RedirectToAction("Login")); }
public static string CreateAlterIndecesDLL(IndexClass index, eCreateMode cmode) { StringBuilder sb = new StringBuilder(); // ALTER TABLE TADRESSEN ADD CONSTRAINT FK_TADRESSEN FOREIGN KEY(TPLZ_ID) REFERENCES TPLZ(ID) ON UPDATE CASCADE; // -> //ALTER TABLE #REPLACE_TABLE ADD CONSTRAINT #REPLACE_CONSTRAINTNAME FOREIGN KEY(#REPLACE_COLUMNS) REFERENCES #REPLACE_REFERENCES_TABLE (#REPLACE_REFERENCES_COLUMNS) ON UPDATE #UPDATE_TYPE;"; if (index != null) { if ((cmode == eCreateMode.drop) || (cmode == eCreateMode.recreate)) { string cmd = SQLPatterns.DropIndexPattern.Replace(SQLPatterns.IndexKey, index.Name); sb.Append(cmd); } if ((cmode == eCreateMode.create) || (cmode == eCreateMode.recreate)) { //"CREATE INDEX #REPLACE_INDEXNAME ON #REPLACE_TABLENAME(#REPLACE_COLUMNS);"; string cmd = SQLPatterns.AddIndexPattern.Replace(SQLPatterns.IndexKey, index.Name).Replace(SQLPatterns.TableKey, index.RelationName).Replace(SQLPatterns.ColumnKey, MakeConcatedStr(index.RelationFields, ",")); sb.Append(cmd); } } return(sb.ToString()); }
//--------------------------------------------------------------------- // CHANGED: CR13 (Export features performance) // Add a new attribute index to a feature class. /// <summary> /// Adds an attribute index to a field in a feature class. /// </summary> /// <param name="featureClass">The feature class.</param> /// <param name="indexName">Name of the index.</param> /// <param name="fieldName">Name of the field.</param> public void AddFieldIndex(IFeatureClass featureClass, String indexName, String fieldName) { // Ensure the feature class contains the specified field. int fieldIndex = featureClass.FindField(fieldName); if (fieldIndex == -1) return; // Get the specified field from the feature class. IFields featureClassFields = featureClass.Fields; IField field = featureClassFields.get_Field(fieldIndex); // Create a fields collection and add the specified field to it. IFields fields = new FieldsClass(); IFieldsEdit fieldsEdit = (IFieldsEdit)fields; fieldsEdit.FieldCount_2 = 1; fieldsEdit.set_Field(0, field); //Create an index and cast to the IIndexEdit interface. IIndex index = new IndexClass(); IIndexEdit indexEdit = (IIndexEdit)index; // Set the index's properties, including the associated fields. indexEdit.Fields_2 = fields; indexEdit.IsAscending_2 = false; indexEdit.IsUnique_2 = false; indexEdit.Name_2 = indexName; // Attempt to acquire an exclusive schema lock on the feature class. ISchemaLock schemaLock = (ISchemaLock)featureClass; try { schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock); featureClass.AddIndex(index); } catch (COMException comExc) { // Handle this in a way appropriate to your application. Console.WriteLine("A COM Exception was thrown: {0}", comExc.Message); } finally { schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock); } }
void AddPrimitiveElementOrReference( ref ChannelInfos channelInfos, object Value, #if DEBUG string debug_Name, Type debug_type, #endif int TypeNumber, int?ReferenceToInstanceNumber, bool ShouldWriteType) { #if DEBUG if (Value == null) { throw new ArgumentNullException(); } #endif #region Manages instances if (Value.GetType() == typeof(string) && channelInfos.ChannelNumber == ChannelNumber.InstancesChannel) { IndexClass index; if (!this.ClassInstanceIndexes.TryGetValue(Value, out index)) { index = new IndexClass(this.AddObjToKnownInstances(Value)); // serialize the object at the root of the Instances branch: this.ChannelAddPrimitiveElementToRoot( ref channelInfos, Value, #if DEBUG debug_Name, #endif TypeNumber, // For an instance, the type is always wrote. unchecked ((TypeCode)TypeNumber) #if DEBUG , this.l3typeManagerCollection.GetTypeManager(TypeNumber).l2TypeManager.L1TypeManager.type #endif ); } // Replace instance by a reference: this._ChannelAddReference( ref channelInfos, #if DEBUG debug_Name, #endif index.Value #if DEBUG , debug_type #endif ); return; } #endregion Manages instances this._ChannelAddPrimitiveElement( ref channelInfos, Value, #if DEBUG debug_Name, #endif ShouldWriteType ? TypeNumber : (int?)null, unchecked ((TypeCode)TypeNumber) #if DEBUG , debug_type #endif ); }
void AddAComplexObject(ref ChannelInfos channelInfos, object obj, #if DEBUG string NameToWrite, #endif int TypeNumber, L3TypeManager tm, bool WriteType) { #if DEBUG if (tm == null) { Debugger.Break(); } #endif { L3TypeManager tm2 = null; var obj2 = this.CreateAContainerIfNecessary(obj, tm, out tm2); if (tm2 != null) { tm = tm2; TypeNumber = tm2.TypeIndex; WriteType = true; obj = obj2; } } #region Manages instances bool typeToBeSerializedIsAClass = tm.l2TypeManager.IsClass; if (typeToBeSerializedIsAClass && channelInfos.ChannelNumber != ChannelNumber.TypeDescriptorsChannel) { IndexClass index; if (!this.ClassInstanceIndexes.TryGetValue(obj, out index)) { index = new IndexClass(this.AddObjToKnownInstances(obj)); // serialize the object at the root of the Instances branch: this.AddAComplexObject_NoInstanceTest( ref this.channelInfos[(int)ChannelNumber.InstancesChannel], obj, #if DEBUG NameToWrite, #endif tm, true, true); // For an instance, the type is always wrote. } // Replace instance by a reference: this._ChannelAddReference( ref channelInfos, #if DEBUG NameToWrite, #endif index.Value #if DEBUG , this.l3typeManagerCollection.GetTypeManager(TypeNumber).l2TypeManager.L1TypeManager.type #endif ); return; } #endregion Manages instances // We serialize the complex object: AddAComplexObject_NoInstanceTest(ref channelInfos, obj, #if DEBUG NameToWrite, #endif tm, false, WriteType); }
public void LoadBuiltinClasses() { classes["Int"] = new IntClass(); classes["Float"] = new FloatClass(); classes["Boolean"] = new BooleanClass(); classes["String"] = new StringClass(); classes["Char"] = new CharClass(); classes["Byte"] = new ByteClass(); classes["Message"] = new MessageClass(); classes["Unassigned"] = new UnassignedClass(); classes["Tuple"] = new TupleClass(); classes["NameValue"] = new NameValueClass(); classes["Lambda"] = new LambdaClass(); classes["Void"] = new VoidClass(); classes["Some"] = new SomeClass(); classes["None"] = new NoneClass(); classes["Array"] = new ArrayClass(); classes["Iterator"] = new IteratorClass(); classes["LazyIterator"] = new LazyIteratorClass(); classes["StreamIterator"] = new StreamIteratorClass(); classes["Any"] = new AnyClass(); classes["Placeholder"] = new PlaceholderClass(); classes["Range"] = new RangeClass(); classes["Dictionary"] = new DictionaryClass(); classes["Container"] = new ContainerClass(); classes["Unmatched"] = new UnmatchedClass(); classes["Complex"] = new ComplexClass(); classes["Rational"] = new RationalClass(); classes["Long"] = new LongClass(); classes["Lazy"] = new LazyClass(); classes["YieldingInvokable"] = new YieldingInvokableClass(); classes["Del"] = new DelClass(); classes["Slice"] = new SliceClass(); classes["End"] = new EndClass(); classes["List"] = new ListClass(); classes["Arguments"] = new ArgumentsClass(); classes["Symbol"] = new SymbolClass(); classes["Infinity"] = new InfinityClass(); classes["OpenRange"] = new OpenRangeClass(); classes["KeyValue"] = new KeyValueClass(); classes["Regex"] = new RegexClass(); classes["Pattern"] = new PatternClass(); classes["PackageFunction"] = new PackageFunctionClass(); classes["Sys"] = new SysClass(); classes["Math"] = new MathClass(); classes["RuntimeFunction"] = new RuntimeFunctionClass(); classes["Reference"] = new ReferenceClass(); classes["Group"] = new RegexGroupClass(); classes["Match"] = new RegexMatchClass(); classes["Date"] = new DateClass(); classes["Interval"] = new IntervalClass(); classes["TypeConstraint"] = new TypeConstraintClass(); classes["ByteArray"] = new ByteArrayClass(); classes["Selector"] = new SelectorClass(); classes["Number"] = new NumberClass(); classes["Collection"] = new CollectionClass(); classes["TextFinding"] = new TextFindingClass(); classes["SkipTake"] = new SkipTakeClass(); classes["Constructor"] = new ConstructorClass(); classes["MutString"] = new MutStringClass(); classes["Error"] = new ErrorClass(); classes["Success"] = new SuccessClass(); classes["Failure"] = new FailureClass(); classes["Optional"] = new OptionalClass(); classes["Result"] = new ResultClass(); classes["Monad"] = new MonadClass(); classes["Unit"] = new UnitClass(); classes["YieldReturn"] = new YieldReturnClass(); classes["Index"] = new IndexClass(); classes["Cycle"] = new CycleClass(); classes["Set"] = new SetClass(); }
//Реструктуризация БД по схеме public bool RestructDB(string pathDB) { if (!m_isSchema) { return(false); } File.Copy(pathDB, pathDB + ".old", true); bool isRestructed = false; ConnectionClass conn = null; try { conn = new ConnectionClass(); conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pathDB, "", "", 0); m_catalogADOX.ActiveConnection = conn; for (int i = 0; i < m_schema.tables.Length; ++i) { string tableName; try { tableName = m_catalogADOX.Tables[m_schema.tables[i].name].Name; } catch { AddTableADOX(m_schema.tables[i].name); tableName = m_schema.tables[i].name; isRestructed = true; } jcolumns[] cols = m_schema.tables[i].columns; for (int j = 0; j < cols.Length; ++j) { string columnName = cols[j].name; ADOX.DataTypeEnum columnType = cols[j].type; int columnPrecision = cols[j].precision; int columnDefSize = cols[j].definedSize; try { string temp = m_catalogADOX.Tables[tableName].Columns[columnName].Name; } catch { ColumnClass columnADOX = new ColumnClass(); columnADOX.ParentCatalog = m_catalogADOX; columnADOX.Name = columnName; columnADOX.Type = columnType; columnADOX.DefinedSize = columnDefSize; columnADOX.Precision = columnPrecision; columnADOX.Properties["Autoincrement"].Value = (object)cols[j].autoincrement; columnADOX.Properties["Nullable"].Value = (object)cols[j].nullable; columnADOX.Properties["Fixed Length"].Value = (object)cols[j].fixedLength; AddColumnADOX(tableName, columnADOX, columnType, columnDefSize); isRestructed = true; } ADOX.DataTypeEnum temp_type = m_catalogADOX.Tables[tableName].Columns[columnName].Type; int temp_precision = m_catalogADOX.Tables[tableName].Columns[columnName].Precision; int temp_definedSize = m_catalogADOX.Tables[tableName].Columns[columnName].DefinedSize; if (columnType != temp_type || columnPrecision != temp_precision || columnDefSize != temp_definedSize || cols[j].autoincrement != (bool)m_catalogADOX.Tables[tableName].Columns[columnName].Properties["Autoincrement"].Value || cols[j].nullable != (bool)m_catalogADOX.Tables[tableName].Columns[columnName].Properties["Nullable"].Value || cols[j].fixedLength != (bool)m_catalogADOX.Tables[tableName].Columns[columnName].Properties["Fixed Length"].Value ) { ALTERColumnADOX(conn, tableName, columnName, columnType, columnPrecision, columnDefSize, cols[j]); isRestructed = true; } } //index jindexs[] ind = m_schema.tables[i].indexs; if (ind != null) { for (int j = 0; j < ind.Length; j++) { try { string name = m_catalogADOX.Tables[m_schema.tables[i].name].Indexes[ind[j].name].Name; } catch { IndexClass indexADOX = new IndexClass(); indexADOX.Name = ind[j].name; indexADOX.Clustered = ind[j].clustered; indexADOX.IndexNulls = ind[j].indexNulls; indexADOX.PrimaryKey = ind[j].primaryKey; indexADOX.Unique = ind[j].unique; indexADOX.Columns.Append(ind[j].name, ADOX.DataTypeEnum.adInteger, 0); //m_catalogADOX.Tables[m_schema.tables[i].name].Indexes.Refresh(); try { m_catalogADOX.Tables[m_schema.tables[i].name].Indexes.Append(ind[j].name, ind[j].name); } catch {} //catch (System.Runtime.InteropServices.COMException e) //{ //System.Windows.Forms.MessageBox.Show(e.Message); //} isRestructed = true; } } } //keys jkeys[] key = m_schema.tables[i].keys; if (key != null) { for (int j = 0; j < key.Length; j++) { try { string name = m_catalogADOX.Tables[m_schema.tables[i].name].Keys[key[j].name].Name; } catch { KeyClass keyADOX = new KeyClass(); keyADOX.Name = key[j].name; keyADOX.Type = key[j].type; m_catalogADOX.Tables[m_schema.tables[i].name].Keys.Append( key[j].name, key[j].type, m_catalogADOX.Tables[m_schema.tables[i].name].Columns[key[j].column], "", ""); //key[j].name, key[j].type, key[j].column, "", ""); //Без этой записи на win2000 выдавала глюк!!! Первая строка в vars отказывалась записыватся m_catalogADOX.Tables[m_schema.tables[i].name].Keys.Refresh(); } } } //Data jrows[] rows = m_schema.tables[i].rows; if (rows != null && m_schema.tables[i].name == "vars") { FillDataRestruct(conn, m_schema.tables[i].name, rows); } } } finally { if (conn != null) { conn.Close(); } //System.Runtime.InteropServices.Marshal.ReleaseComObject(m_catalogADOX); //m_catalogADOX = new CatalogClass(); } return(isRestructed); }
//Создаем новую пустую БД из схемы public void CreateDB(string pathDB) { if (!m_isSchema) { return; } if (File.Exists(pathDB)) { File.Copy(pathDB, pathDB + ".old", true); File.Delete(pathDB); } string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pathDB; try { m_catalogADOX.Create(connStr); for (int i = 0; i < m_schema.tables.Length; i++) { TableClass tableADOX = new TableClass(); tableADOX.Name = m_schema.tables[i].name; tableADOX.ParentCatalog = m_catalogADOX; jcolumns[] cols = m_schema.tables[i].columns; for (int j = 0; j < cols.Length; j++) { ColumnClass columnADOX = new ColumnClass(); columnADOX.ParentCatalog = m_catalogADOX; columnADOX.Name = cols[j].name; columnADOX.Type = cols[j].type; columnADOX.DefinedSize = cols[j].definedSize; columnADOX.Precision = cols[j].precision; columnADOX.Properties["Autoincrement"].Value = (object)cols[j].autoincrement; columnADOX.Properties["Nullable"].Value = (object)cols[j].nullable; columnADOX.Properties["Fixed Length"].Value = (object)cols[j].fixedLength; tableADOX.Columns.Append(columnADOX, cols[j].type, cols[j].definedSize); } m_catalogADOX.Tables.Append(tableADOX); //index jindexs[] ind = m_schema.tables[i].indexs; if (ind != null) { for (int j = 0; j < ind.Length; j++) { IndexClass indexADOX = new IndexClass(); indexADOX.Name = ind[j].name; indexADOX.Clustered = ind[j].clustered; indexADOX.IndexNulls = ind[j].indexNulls; indexADOX.PrimaryKey = ind[j].primaryKey; indexADOX.Unique = ind[j].unique; m_catalogADOX.Tables[m_schema.tables[i].name].Indexes.Append(ind[j].name, ind[j].name); } } //key jkeys[] key = m_schema.tables[i].keys; if (key != null) { for (int j = 0; j < key.Length; j++) { KeyClass keyADOX = new KeyClass(); keyADOX.Name = key[j].name; keyADOX.Type = key[j].type; //keyADOX.Columns = key[j].column; //keyADOX.Columns.Append(key[j].column, ADOX.DataTypeEnum.adInteger, 0); //ColumnClass columnADOX = new ColumnClass(); //columnADOX.Name = key[j].column; m_catalogADOX.Tables[m_schema.tables[i].name].Keys.Append( key[j].name, key[j].type, m_catalogADOX.Tables[m_schema.tables[i].name].Columns[key[j].column], "", ""); //Без этой записи на win2000 выдавала глюк!!! Первая строка в vars отказывалась запичыватся m_catalogADOX.Tables[m_schema.tables[i].name].Keys.Refresh(); } } } } finally { //if (conn != null) // conn.Close(); //m_catalogADOX.ActiveConnection = null; } //Data и ConnectionClass conn = null; try { conn = new ConnectionClass(); conn.Open(connStr, "", "", 0); for (int i = 0; i < m_schema.tables.Length; i++) { jrows[] rows = m_schema.tables[i].rows; if (rows != null && m_schema.tables[i].name == "vars") { FillDataRestruct(conn, m_schema.tables[i].name, rows); } } } finally { if (conn != null) { conn.Close(); } } }
//Реструктуризация БД по схеме public bool RestructDB( string pathDB) { if (!m_isSchema) return false; File.Copy( pathDB, pathDB+".old", true); bool isRestructed = false; ConnectionClass conn = null; try { conn = new ConnectionClass(); conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+pathDB,"","",0); m_catalogADOX.ActiveConnection = conn; for ( int i = 0; i < m_schema.tables.Length; ++i ) { string tableName; try { tableName = m_catalogADOX.Tables[m_schema.tables[i].name].Name; } catch { AddTableADOX( m_schema.tables[i].name); tableName = m_schema.tables[i].name; isRestructed = true; } jcolumns[] cols = m_schema.tables[i].columns; for ( int j = 0; j < cols.Length; ++j ) { string columnName = cols[j].name; ADOX.DataTypeEnum columnType = cols[j].type; int columnPrecision = cols[j].precision; int columnDefSize = cols[j].definedSize; try { string temp = m_catalogADOX.Tables[tableName].Columns[columnName].Name; } catch { ColumnClass columnADOX = new ColumnClass(); columnADOX.ParentCatalog = m_catalogADOX; columnADOX.Name = columnName; columnADOX.Type = columnType; columnADOX.DefinedSize = columnDefSize; columnADOX.Precision = columnPrecision; columnADOX.Properties["Autoincrement"].Value = (object)cols[j].autoincrement; columnADOX.Properties["Nullable"].Value = (object)cols[j].nullable; columnADOX.Properties["Fixed Length"].Value = (object)cols[j].fixedLength; AddColumnADOX( tableName, columnADOX, columnType, columnDefSize); isRestructed = true; } ADOX.DataTypeEnum temp_type = m_catalogADOX.Tables[tableName].Columns[columnName].Type; int temp_precision = m_catalogADOX.Tables[tableName].Columns[columnName].Precision; int temp_definedSize = m_catalogADOX.Tables[tableName].Columns[columnName].DefinedSize; if (columnType != temp_type || columnPrecision != temp_precision || columnDefSize != temp_definedSize || cols[j].autoincrement != (bool)m_catalogADOX.Tables[tableName].Columns[columnName].Properties["Autoincrement"].Value || cols[j].nullable != (bool)m_catalogADOX.Tables[tableName].Columns[columnName].Properties["Nullable"].Value || cols[j].fixedLength != (bool)m_catalogADOX.Tables[tableName].Columns[columnName].Properties["Fixed Length"].Value ) { ALTERColumnADOX( conn, tableName, columnName, columnType, columnPrecision, columnDefSize, cols[j]); isRestructed = true; } } //index jindexs[] ind = m_schema.tables[i].indexs; if (ind != null) { for ( int j = 0; j < ind.Length; j++ ) { try { string name = m_catalogADOX.Tables[m_schema.tables[i].name].Indexes[ind[j].name].Name; } catch { IndexClass indexADOX = new IndexClass(); indexADOX.Name = ind[j].name; indexADOX.Clustered = ind[j].clustered; indexADOX.IndexNulls = ind[j].indexNulls; indexADOX.PrimaryKey = ind[j].primaryKey; indexADOX.Unique = ind[j].unique; indexADOX.Columns.Append(ind[j].name, ADOX.DataTypeEnum.adInteger, 0); //m_catalogADOX.Tables[m_schema.tables[i].name].Indexes.Refresh(); try { m_catalogADOX.Tables[m_schema.tables[i].name].Indexes.Append( ind[j].name, ind[j].name); } catch{} //catch (System.Runtime.InteropServices.COMException e) //{ //System.Windows.Forms.MessageBox.Show(e.Message); //} isRestructed = true; } } } //keys jkeys[] key = m_schema.tables[i].keys; if (key != null) { for ( int j = 0; j < key.Length; j++ ) { try { string name = m_catalogADOX.Tables[m_schema.tables[i].name].Keys[key[j].name].Name; } catch { KeyClass keyADOX = new KeyClass(); keyADOX.Name = key[j].name; keyADOX.Type = key[j].type; m_catalogADOX.Tables[m_schema.tables[i].name].Keys.Append( key[j].name, key[j].type, m_catalogADOX.Tables[m_schema.tables[i].name].Columns[key[j].column], "", ""); //key[j].name, key[j].type, key[j].column, "", ""); //Без этой записи на win2000 выдавала глюк!!! Первая строка в vars отказывалась записыватся m_catalogADOX.Tables[m_schema.tables[i].name].Keys.Refresh(); } } } //Data jrows[] rows = m_schema.tables[i].rows; if (rows != null && m_schema.tables[i].name=="vars") FillDataRestruct( conn, m_schema.tables[i].name, rows); } } finally { if (conn != null) conn.Close(); //System.Runtime.InteropServices.Marshal.ReleaseComObject(m_catalogADOX); //m_catalogADOX = new CatalogClass(); } return isRestructed; }
/// <summary> /// 初始化数据 /// </summary> public void InitData(object progress1) { ProgressBar progress = (ProgressBar)progress1; //耗时巨大的代码 // MainForm.baseData.InitData(progressBar1); ////////////////////////////////////////////////////////////////////////// //建立分区索引 IEnumIndex pEnumIndex = zoneLCA_FC.Indexes.FindIndexesByFieldName(zidField); IIndex pTemIndex = pEnumIndex.Next(); if (pTemIndex == null) { IIndex pIndex = new IndexClass(); IIndexEdit pIndexEdit = pIndex as IIndexEdit; IFields pFields = new FieldsClass(); IFieldsEdit pFieldsEdit = pFields as IFieldsEdit; int zidindex = zoneLCA_FC.Fields.FindField(zidField); IField pField = zoneLCA_FC.Fields.Field[zidindex]; pFieldsEdit.FieldCount_2 = 1; pFieldsEdit.set_Field(0, pField); pIndexEdit.Fields_2 = pFields; pIndexEdit.Name_2 = zidField; pIndexEdit.IsAscending_2 = true; zoneLCA_FC.AddIndex(pIndex); } //建立分类索引 IEnumIndex pEnumIndex1 = zoneLCA_FC.Indexes.FindIndexesByFieldName(codeField); IIndex pTemIndex1 = pEnumIndex1.Next(); if (pTemIndex == null) { IIndex pIndex = new IndexClass(); IIndexEdit pIndexEdit = pIndex as IIndexEdit; IFields pFields = new FieldsClass(); IFieldsEdit pFieldsEdit = pFields as IFieldsEdit; int codeindex = zoneLCA_FC.Fields.FindField(codeField); IField pField = zoneLCA_FC.Fields.Field[codeindex]; pFieldsEdit.FieldCount_2 = 1; pFieldsEdit.set_Field(0, pField); pIndexEdit.Fields_2 = pFields; pIndexEdit.Name_2 = codeField; pIndexEdit.IsAscending_2 = true; zoneLCA_FC.AddIndex(pIndex); } areaIndex = zoneLCA_FC.FindField("Shape_Area"); perimeterIndex = zoneLCA_FC.FindField("Shape_Length"); if (zone_FC != null) { areaIndex_zone = zone_FC.FindField("Shape_Area"); perimeterIndex_zone = zone_FC.FindField("Shape_Length"); } codeIndex = zoneLCA_FC.FindField(codeField); Utilities.Common.SetProgress(progress); IQueryDef pQueryDef; IRow pRow; ICursor pCursor; IWorkspace pWorkspace; IFeatureWorkspace pFeatureWorkspace; IDataset pDataset; pDataset = zoneLCA_FC as IDataset; pWorkspace = pDataset.Workspace; pFeatureWorkspace = pDataset.Workspace as IFeatureWorkspace; pQueryDef = pFeatureWorkspace.CreateQueryDef(); ////////////////////////////////////////////////////////////////////////// //添加分区唯一值 pQueryDef.SubFields = "DISTINCT(" + zidField + ")"; pQueryDef.Tables = pDataset.Name; pCursor = pQueryDef.Evaluate(); pRow = pCursor.NextRow(); while (pRow != null) { object obj = pRow.get_Value(0); zoneValue.Add(obj.ToString()); pRow = pCursor.NextRow(); if (progress.Value < progress.Maximum) { progress.Value++; } } ////////////////////////////////////////////////////////////////////////// //添加 分类唯一值 pQueryDef.SubFields = "DISTINCT(" + codeField + ")"; pQueryDef.Tables = pDataset.Name; pCursor = pQueryDef.Evaluate(); pRow = pCursor.NextRow(); while (pRow != null) { object obj = pRow.get_Value(0); ccValue.Add(obj.ToString()); pRow = pCursor.NextRow(); if (progress.Value < progress.Maximum) { progress.Value++; } } if (zone_FC != null) { string objectFiled = ""; objectFiled = zone_FC.Fields.Field[0].Name; pQueryDef.SubFields = (zone_FC as IDataset).Name + "." + objectFiled; //pQueryDef.SubFields = pDataset.Name + "." + zidField + "," + (zone_FC as IDataset).Name + "." + zidField + "," + (zone_FC as IDataset).Name + ".OBJECTID"; pQueryDef.Tables = (zone_FC as IDataset).Name; for (int i = 0; i < zoneValue.Count; i++) { pQueryDef.WhereClause = zidField + " = " + "'" + zoneValue[i] + "'"; pCursor = pQueryDef.Evaluate(); pRow = pCursor.NextRow(); while (pRow != null) { object obj1 = pRow.get_Value(0); // zoneValue.Add(obj.ToString()); zoneObjectID.Add((int)obj1); pRow = pCursor.NextRow(); if (progress.Value < progress.Maximum) { progress.Value++; } } } } string objectFiled1 = ""; objectFiled1 = zoneLCA_FC.Fields.Field[0].Name; ///////////////////////// //1 pQueryDef.SubFields = objectFiled1 + ",Shape_Area"; pQueryDef.Tables = pDataset.Name; for (int i = 0; i < zoneValue.Count; i++) { double area = 0.0; pQueryDef.WhereClause = zidField + "=\'" + zoneValue[i] + "\'"; pCursor = pQueryDef.Evaluate(); pRow = pCursor.NextRow(); List <int> pids = new List <int>(); while (pRow != null) { area += (double)pRow.get_Value(1); pids.Add((int)pRow.get_Value(0)); pRow = pCursor.NextRow(); // progress.Invoke((MethodInvoker)delegate() // { // if (progress.Value < progress.Maximum) // { // progress.Value++; // } // }); if (progress.Value < progress.Maximum) { progress.Value++; } } zoneArea.Add(area); patchIDs.Add(pids); } for (int i = 0; i < patchIDs.Count; i++) { patchIDArray.Add(GetZonePids(i)); // progress.Invoke((MethodInvoker)delegate() // { // if (progress.Value < progress.Maximum) // { // progress.Value++; // } // }); if (progress.Value < progress.Maximum) { progress.Value++; } } }
//Создаем новую пустую БД из схемы public void CreateDB( string pathDB) { if (!m_isSchema) return; if (File.Exists(pathDB)) { File.Copy( pathDB, pathDB+".old", true); File.Delete( pathDB); } string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+pathDB; try { m_catalogADOX.Create(connStr); for ( int i = 0; i < m_schema.tables.Length; i++ ) { TableClass tableADOX = new TableClass(); tableADOX.Name = m_schema.tables[i].name; tableADOX.ParentCatalog = m_catalogADOX; jcolumns[] cols = m_schema.tables[i].columns; for ( int j = 0; j < cols.Length; j++ ) { ColumnClass columnADOX = new ColumnClass(); columnADOX.ParentCatalog = m_catalogADOX; columnADOX.Name = cols[j].name; columnADOX.Type = cols[j].type; columnADOX.DefinedSize = cols[j].definedSize; columnADOX.Precision = cols[j].precision; columnADOX.Properties["Autoincrement"].Value = (object)cols[j].autoincrement; columnADOX.Properties["Nullable"].Value = (object)cols[j].nullable; columnADOX.Properties["Fixed Length"].Value = (object)cols[j].fixedLength; tableADOX.Columns.Append(columnADOX, cols[j].type, cols[j].definedSize); } m_catalogADOX.Tables.Append(tableADOX); //index jindexs[] ind = m_schema.tables[i].indexs; if (ind != null) { for ( int j = 0; j < ind.Length; j++ ) { IndexClass indexADOX = new IndexClass(); indexADOX.Name = ind[j].name; indexADOX.Clustered = ind[j].clustered; indexADOX.IndexNulls = ind[j].indexNulls; indexADOX.PrimaryKey = ind[j].primaryKey; indexADOX.Unique = ind[j].unique; m_catalogADOX.Tables[m_schema.tables[i].name].Indexes.Append( ind[j].name, ind[j].name); } } //key jkeys[] key = m_schema.tables[i].keys; if (key != null) { for ( int j = 0; j < key.Length; j++ ) { KeyClass keyADOX = new KeyClass(); keyADOX.Name = key[j].name; keyADOX.Type = key[j].type; //keyADOX.Columns = key[j].column; //keyADOX.Columns.Append(key[j].column, ADOX.DataTypeEnum.adInteger, 0); //ColumnClass columnADOX = new ColumnClass(); //columnADOX.Name = key[j].column; m_catalogADOX.Tables[m_schema.tables[i].name].Keys.Append( key[j].name, key[j].type, m_catalogADOX.Tables[m_schema.tables[i].name].Columns[key[j].column], "", ""); //Без этой записи на win2000 выдавала глюк!!! Первая строка в vars отказывалась запичыватся m_catalogADOX.Tables[m_schema.tables[i].name].Keys.Refresh(); } } } } finally { //if (conn != null) // conn.Close(); //m_catalogADOX.ActiveConnection = null; } //Data и ConnectionClass conn = null; try { conn = new ConnectionClass(); conn.Open(connStr,"","",0); for ( int i = 0; i < m_schema.tables.Length; i++ ) { jrows[] rows = m_schema.tables[i].rows; if (rows != null && m_schema.tables[i].name=="vars") FillDataRestruct( conn, m_schema.tables[i].name, rows); } } finally { if (conn != null) conn.Close(); } }