private IOperationResultComparer newRandomOperationResultComparer (Random rand2, Counter c, ObjectIdGenerator idGenerator) { return(operationComparerCreators[ rand2.Next(operationComparerCreators.Count)]( rand2, idGenerator, c)); }
private void AddObjectId() { var g = new ObjectIdGenerator(); var oid = (ObjectId)g.GenerateId(_coll, Doc); AddID(oid); }
private TestIterationParameters newIterationParameters(int listSize, int operationSequencesNumber, int operationNumberPerSequence, Random rand) { var counter = new Counter(listSize); var idGenerator = new ObjectIdGenerator(); return(new TestIterationParameters() { InitialListLength = listSize, OperationSequences = LinqHelper.Repeat( operationSequencesNumber, () => new ExecutionSequenceParameters { StartIndex = rand.Next(listSize + 2), // with head and tail node Operations = LinqHelper.Repeat( operationNumberPerSequence, () => newRandomOperationResultComparer( rand, counter, idGenerator)).ToList(), } ) .ToList(), InitializationSeed = rand.Next(), ExecutionSeed = rand.Next(), }); }
/// <summary> /// Generates a new unique oid for use with MongoDB Objects. /// </summary> /// <returns> /// </returns> public static ObjectId NewObjectId() { // TODO: generate random-ish bits. return(new ObjectId { Value = ObjectIdGenerator.Generate() }); }
private void CheckVideo(string path) { //看看目录下有哪些是数据库里没有的影片,也都加进来 DirectoryInfo dirInfo = new DirectoryInfo(path); Video v = null; foreach (DirectoryInfo d in dirInfo.GetDirectories()) { v = GetVideo(d.Name); //if (File.Exists(d.FullName + "\\" + d.Name + ".json")) //{ //} if (v == null) { v = new Video(new ObjectId(ObjectIdGenerator.Generate()), d.Name); AddVideo(v); } if (v.Path != path) { Logger.Error(string.Format("发现相同番号;{0}", v.Code)); } v.Path = path; } }
public Actress AddActress(string name, string alias, DateTime birthday, int height, int bust, int waist, int hip, string cup, string code) { Actress a = new Actress(new ObjectId(ObjectIdGenerator.Generate()), name, alias, birthday, height, bust, waist, hip, cup, code); actressList.Add(a); return(a); }
public InsertAfterIf( ObjectIdGenerator idGenerator, ListItemData value, int prevalentValue) : base(idGenerator, value) { this.prevalentValue = prevalentValue; }
/// <summary> /// Starts all members. /// </summary> public void Start() { databaseManager.Start(); scheduler.Start(); packetProcessor.Start(); MySqlHandle mySqlHandle = databaseManager.GetMySqlHandle(); try { mySqlHandle.Open(); List <long> takenObjectIds = new List <long>(); mySqlHandle.CharactersGetCharacterIds(takenObjectIds); objectIdGenerator = new ObjectIdGenerator(takenObjectIds); mySqlHandle.Close(); } catch (Exception exc) { objectIdGenerator = new ObjectIdGenerator(); LogDatabaseError(exc); } mySqlHandle.Free(); eventManager.Publish(new ServerStartEvent()); }
public ClassType AddTypeClass(string name) { ClassType classType = new ClassType(new ObjectId(ObjectIdGenerator.Generate()), name); this.classTypeList.Add(classType); classType.NeedInsert = true; return(classType); }
public void ObjectIdTest() { var idGenerator = new ObjectIdGenerator(); var id = idGenerator.NewId(); Assert.NotEqual(id, idGenerator.NewId()); Assert.True(string.CompareOrdinal(id, idGenerator.NewId()) < 0); }
public IOperationResultComparer CreateOperationResultComparer( Random rand, ObjectIdGenerator idGenerator, Counter counter) { int seed = rand.Next(); return(new VoidOperationComparer( operationCreator(idGenerator, seed))); }
public bool GetDocumentId(object document, out object id, out Type idNominalType, out IIdGenerator idGenerator) { MongoDynamic x = (MongoDynamic)document; id = x._id; idNominalType = typeof(ObjectId); idGenerator = new ObjectIdGenerator(); return(true); }
// Methods public FrmEditColor(IDataSource ds, string groupId, HashSet <string> colorNames = null) { this.InitializeComponent(); this._ds = ds; this._groupId = groupId; this._isEdit = false; this.Text = "添加颜色"; this.txtColorName.Enabled = true; this._color = new ColorClass(); this._color.Group = groupId; this._color.ObjectId = BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant(); }
private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtStyleName.Text.Trim())) { XtraMessageBox.Show("请输入风格名称!", "提示"); this.txtStyleName.Focus(); return; } if (this._edit) { this._style.Name = this.txtStyleName.Text.Trim(); this._style.IsBlendPipe = this.chkBlendPipe.Checked; this._style.IsFollowDia = this.chkFollowDia.Checked; this._style.IsFollowDir = this.chkFollowDir.Checked; this._style.IsFollowSurfH = this.chkFollowSurfH.Checked; this._style.IsRotateZ = this.chkRotateZ.Checked; this._style.IsStretchZ = this.chkStretchZ.Checked; this._style.ModelId = this.txtModelId.EditValue.ToString(); this._style.Thumbnail = this.picThumbnail.Image; if (UpdateFacStyleClass(this._style)) { this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { XtraMessageBox.Show("更新管点风格失败!", "提示"); } } else { this._style.Name = this.txtStyleName.Text.Trim(); this._style.ObjectId = BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant(); this._style.IsBlendPipe = this.chkBlendPipe.Checked; this._style.IsFollowDia = this.chkFollowDia.Checked; this._style.IsFollowDir = this.chkFollowDir.Checked; this._style.IsFollowSurfH = this.chkFollowSurfH.Checked; this._style.IsRotateZ = this.chkRotateZ.Checked; this._style.IsStretchZ = this.chkStretchZ.Checked; this._style.ModelId = this.txtModelId.EditValue.ToString(); this._style.Thumbnail = this.picThumbnail.Image; if (InsertFacStyleClass(this._style)) { this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { XtraMessageBox.Show("创建管点风格失败!", "提示"); } } }
private void btnSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtStyleName.Text.Trim())) { XtraMessageBox.Show("请输入风格名称!", "提示"); this.txtStyleName.Focus(); return; } if (this._edit) { this._style.Name = this.txtStyleName.Text.Trim(); this._style.RenderType = (RenderType)this.rgRenderType.SelectedIndex; this._style.PipeThick = Convert.ToDouble(this.txtThick.Value); this._style.HeightMode = (HeightMode)this.cbxHeightMode.SelectedIndex; this._style.HeightParam = (HeightParam)this.cbxHeightParam.SelectedIndex; this._style.TextureOutside = this._dt.Rows[0]["ObjectId"].ToString(); this._style.TextureInside = this._dt.Rows[1]["ObjectId"].ToString(); this._style.Thumbnail = this.picThumbnail.Image; if (UpdateFacStyleClass(this._style)) { this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { XtraMessageBox.Show("更新管线风格失败!", "提示"); } } else { this._style.Name = this.txtStyleName.Text.Trim(); this._style.ObjectId = BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant(); this._style.RenderType = (RenderType)this.rgRenderType.SelectedIndex; this._style.PipeThick = Convert.ToDouble(this.txtThick.Value); this._style.HeightMode = (HeightMode)this.cbxHeightMode.SelectedIndex; this._style.HeightParam = (HeightParam)this.cbxHeightParam.SelectedIndex; this._style.TextureOutside = this._dt.Rows[0]["ObjectId"].ToString(); this._style.TextureInside = this._dt.Rows[1]["ObjectId"].ToString(); this._style.Thumbnail = this.picThumbnail.Image; if (InsertFacStyleClass(this._style)) { this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { XtraMessageBox.Show("创建管线风格失败!", "提示"); } } }
public VoidOperation(ObjectIdGenerator idGenerator) : base(idGenerator) { }
public BoolReturningOperation(ObjectIdGenerator idGenerator) : base(idGenerator) { }
private bool OpenOsgModel(string osgPath, out IModel fmodel, out IModel smodel, out IPropertySet images, out IMatrix mat) { fmodel = null; smodel = null; images = null; mat = null; IResourceFactory resFactory = new ResourceFactoryClass(); if ((resFactory == null) || !File.Exists(osgPath)) { return(false); } Dictionary <string, string> dictionary = null; IDrawGroup group = null; IDrawPrimitive primitive = null; IPropertySet set = null; string str = ""; IImage property = null; try { resFactory.CreateModelAndImageFromFileEx(osgPath, out images, out smodel, out fmodel, out mat); if ((images != null) && (images.Count > 0)) { set = new PropertySetClass(); dictionary = new Dictionary <string, string>(); foreach (string str2 in images.GetAllKeys()) { property = images.GetProperty(str2) as IImage; IImage temp = null; string filePath = string.Format(string.Format(@"{0}\..\temp\{1}.png", Application.StartupPath, Guid.NewGuid().ToString()), new object[0]); if (property.WriteFile(filePath)) { temp = resFactory.CreateImageFromFile(filePath); } str = BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant(); dictionary.Add(str2, str); set.SetProperty(str, temp); if (File.Exists(filePath)) { File.Delete(filePath); } } images = set; } if ((fmodel != null) && (fmodel.GroupCount > 0)) { for (int i = 0; i < fmodel.GroupCount; i++) { group = fmodel.GetGroup(i); if (group != null) { if (!string.IsNullOrEmpty(group.CompleteMapTextureName) && dictionary.ContainsKey(group.CompleteMapTextureName)) { group.CompleteMapTextureName = dictionary[group.CompleteMapTextureName]; } if (!string.IsNullOrEmpty(group.LightMapTextureName) && dictionary.ContainsKey(group.LightMapTextureName)) { group.LightMapTextureName = dictionary[group.LightMapTextureName]; } if (group.PrimitiveCount > 0) { for (int j = 0; j < group.PrimitiveCount; j++) { primitive = group.GetPrimitive(j); if (((primitive != null) && (primitive.Material != null)) && (!string.IsNullOrEmpty(primitive.Material.TextureName) && dictionary.ContainsKey(primitive.Material.TextureName))) { primitive.Material.TextureName = dictionary[primitive.Material.TextureName]; } } } } } } if ((smodel != null) && (smodel.GroupCount > 0)) { for (int k = 0; k < smodel.GroupCount; k++) { group = smodel.GetGroup(k); if (group != null) { if (!string.IsNullOrEmpty(group.CompleteMapTextureName) && dictionary.ContainsKey(group.CompleteMapTextureName)) { group.CompleteMapTextureName = dictionary[group.CompleteMapTextureName]; } if (!string.IsNullOrEmpty(group.LightMapTextureName) && dictionary.ContainsKey(group.LightMapTextureName)) { group.LightMapTextureName = dictionary[group.LightMapTextureName]; } if (group.PrimitiveCount > 0) { for (int m = 0; m < group.PrimitiveCount; m++) { primitive = group.GetPrimitive(m); if (((primitive != null) && (primitive.Material != null)) && (!string.IsNullOrEmpty(primitive.Material.TextureName) && dictionary.ContainsKey(primitive.Material.TextureName))) { primitive.Material.TextureName = dictionary[primitive.Material.TextureName]; } } } } } } return(true); } catch (Exception exception) { return(false); } }
public PushRight(ObjectIdGenerator idGenerator, ListItemData value) : base(idGenerator, value) { }
public SelectRandomKnownNode( ObjectIdGenerator idGenerator, int seed) : base(idGenerator) { this.seed = seed; }
private void AddGeometry() { try { this.beforeRowBufferMap.Clear(); SelectCollection.Instance().Clear(); DF3DFeatureClass featureClassInfo = CommonUtils.Instance().CurEditLayer; if (featureClassInfo == null) { return; } IFeatureClass fc = featureClassInfo.GetFeatureClass(); if (fc == null) { return; } IFieldInfoCollection fields = fc.GetFields(); int indexGeo = fields.IndexOf(this._strGeometryFieldName); if (indexGeo == -1) { return; } IGeometry geo = this._drawTool.GetGeo(); IGeometry geoOut = null; switch (geo.GeometryType) { case gviGeometryType.gviGeometryModelPoint: geoOut = geo; break; case gviGeometryType.gviGeometryPoint: IPoint pt = geo as IPoint; IPoint pt1 = pt.Clone2(gviVertexAttribute.gviVertexAttributeZM) as IPoint; pt1.SetCoords(pt.X, pt.Y, pt.Z, 0, 0); geoOut = pt1; break; case gviGeometryType.gviGeometryPolyline: IPolyline line = geo as IPolyline; IPolyline line1 = this._geoFact.CreateGeometry(gviGeometryType.gviGeometryPolyline, gviVertexAttribute.gviVertexAttributeZM) as IPolyline; for (int i = 0; i < line.PointCount; i++) { IPoint ptGet = line.GetPoint(i); IPoint pttemp = ptGet.Clone2(gviVertexAttribute.gviVertexAttributeZM) as IPoint; pttemp.SetCoords(ptGet.X, ptGet.Y, ptGet.Z, 0, 0); line1.AppendPoint(pttemp); } geoOut = line1; break; case gviGeometryType.gviGeometryPolygon: IPolygon polygon = geo as IPolygon; IPolygon polygon1 = this._geoFact.CreateGeometry(gviGeometryType.gviGeometryPolygon, gviVertexAttribute.gviVertexAttributeZM) as IPolygon; for (int i = 0; i < polygon.ExteriorRing.PointCount; i++) { IPoint ptGet = polygon.ExteriorRing.GetPoint(i); IPoint pttemp = ptGet.Clone2(gviVertexAttribute.gviVertexAttributeZM) as IPoint; pttemp.SetCoords(ptGet.X, ptGet.Y, ptGet.Z, 0, 0); polygon1.ExteriorRing.AppendPoint(pttemp); } geoOut = polygon1; break; } if (geoOut == null) { return; } if (geo.GeometryType == gviGeometryType.gviGeometryModelPoint) { //导入模型到数据库中 string mn = BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant(); IModelPoint mp = geoOut as IModelPoint; bool bRes = this.ImportOsg(mn, mp.ModelName); if (!bRes) { return; } mp.ModelName = mn; geoOut = mp; } IRowBufferCollection rowCol = new RowBufferCollection(); IRowBufferFactory fac = new RowBufferFactory(); IRowBuffer row = fac.CreateRowBuffer(fields); row.SetValue(indexGeo, geoOut); rowCol.Add(row); beforeRowBufferMap[featureClassInfo] = rowCol; } catch (Exception ex) { } }
public GetValue(ObjectIdGenerator idGenerator) : base(idGenerator) { }
private void AddRecord() { try { this.beforeRowBufferMap.Clear(); SelectCollection.Instance().Clear(); if (reg == null || tc == null) { return; } FacStyleClass style = this.cmbStyle.EditValue as FacStyleClass; if (style == null) { return; } SubClass sc = this.cmbClassify.EditValue as SubClass; DF3DFeatureClass featureClassInfo = CommonUtils.Instance().CurEditLayer; if (featureClassInfo == null) { return; } IFeatureClass fc = featureClassInfo.GetFeatureClass(); if (fc == null) { return; } IResourceManager manager = fc.FeatureDataSet as IResourceManager; if (manager == null) { return; } IFeatureLayer fl = featureClassInfo.GetFeatureLayer(); if (fl == null) { return; } IFieldInfoCollection fields = fc.GetFields(); int indexOid = fields.IndexOf(fc.FidFieldName); if (indexOid == -1) { return; } int mpindex = fields.IndexOf(fl.GeometryFieldName); if (mpindex == -1) { return; } int indexShape = fields.IndexOf("Shape"); if (indexShape == -1) { return; } int indexFootPrint = fields.IndexOf("FootPrint"); if (indexFootPrint == -1) { return; } int indexStyleId = fields.IndexOf("StyleId"); if (indexStyleId == -1) { return; } int indexFacilityId = fields.IndexOf("FacilityId"); if (indexFacilityId == -1) { return; } IFieldInfo fiShape = fields.Get(indexShape); if (fiShape == null || fiShape.GeometryDef == null) { return; } IGeometry geo = this._drawTool.GetGeo(); if (geo.GeometryType != gviGeometryType.gviGeometryPoint) { return; } IPoint pt = geo as IPoint; IPoint geoOut = pt.Clone2(fiShape.GeometryDef.VertexAttribute) as IPoint; if (fiShape.GeometryDef.HasZ) { geoOut.SetCoords(pt.X, pt.Y, pt.Z, 0, 0); } else { geoOut.SetCoords(pt.X, pt.Y, 0, 0, 0); } IQueryFilter filter = new QueryFilter(); filter.WhereClause = "1=1"; filter.ResultBeginIndex = 0; filter.ResultLimit = 1; filter.PostfixClause = "ORDER BY " + fc.FidFieldName + " desc"; IFdeCursor cursor = null; cursor = fc.Search(filter, false); IRowBuffer rowtemp = cursor.NextRow(); int oid = 0; if (rowtemp != null) { oid = int.Parse(rowtemp.GetValue(indexOid).ToString()); } if (cursor != null) { System.Runtime.InteropServices.Marshal.ReleaseComObject(cursor); cursor = null; } IRowBufferFactory fac = new RowBufferFactory(); IRowBuffer row = fac.CreateRowBuffer(fields); row.SetValue(indexOid, oid + 1); row.SetValue(indexShape, geoOut); row.SetValue(indexFootPrint, geoOut.Clone2(gviVertexAttribute.gviVertexAttributeNone)); row.SetValue(indexStyleId, style.ObjectId); row.SetValue(indexFacilityId, BitConverter.ToString(ObjectIdGenerator.Generate()).Replace("-", string.Empty).ToLowerInvariant()); if (sc != null) { int indexClassify = fields.IndexOf(this._classifyName); int indexGroupId = fields.IndexOf("GroupId"); if (indexClassify != -1 && indexGroupId != -1) { row.SetValue(indexClassify, sc.Name); row.SetValue(indexGroupId, sc.GroupId); } } foreach (DataRow dr in this._dt.Rows) { IFieldInfo fi = dr["F"] as IFieldInfo; if (fi == null) { continue; } string fn = fi.Name; int index = fields.IndexOf(fn); if (index != -1) { if (dr["FV"] == null) { row.SetNull(index); } else { string strobj = dr["FV"].ToString(); bool bRes = false; switch (fi.FieldType) { case gviFieldType.gviFieldBlob: case gviFieldType.gviFieldGeometry: case gviFieldType.gviFieldUnknown: break; case gviFieldType.gviFieldFloat: float f; bRes = float.TryParse(strobj, out f); if (bRes) { row.SetValue(index, f); } else { row.SetNull(index); } break; case gviFieldType.gviFieldDouble: double d; bRes = double.TryParse(strobj, out d); if (bRes) { row.SetValue(index, d); } else { row.SetNull(index); } break; case gviFieldType.gviFieldFID: case gviFieldType.gviFieldUUID: case gviFieldType.gviFieldInt16: Int16 i16; bRes = Int16.TryParse(strobj, out i16); if (bRes) { row.SetValue(index, i16); } else { row.SetNull(index); } break; case gviFieldType.gviFieldInt32: Int32 i32; bRes = Int32.TryParse(strobj, out i32); if (bRes) { row.SetValue(index, i32); } else { row.SetNull(index); } break; case gviFieldType.gviFieldInt64: Int64 i64; bRes = Int64.TryParse(strobj, out i64); if (bRes) { row.SetValue(index, i64); } else { row.SetNull(index); } break;; case gviFieldType.gviFieldString: row.SetValue(index, strobj); break; case gviFieldType.gviFieldDate: DateTime dt; bRes = DateTime.TryParse(strobj, out dt); if (bRes) { row.SetValue(index, dt); } else { row.SetNull(index); } break; default: break; } } } } Fac plf = new PipeNodeFac(reg, style, row, tc); IModelPoint mp = null; IModel finemodel = null; IModel simplemodel = null; string name = ""; if (UCAuto3DCreate.RebuildModel(plf, style, out mp, out finemodel, out simplemodel, out name)) { if (finemodel == null || mp == null) { return; } mp.ModelEnvelope = finemodel.Envelope; row.SetValue(mpindex, mp); //if (mc != null) //{ // if (indexClassify != -1 && indexGroupid != -1) // { // } //} bool bRes = false; if (!string.IsNullOrEmpty(mp.ModelName)) { if (!manager.ModelExist(mp.ModelName)) { if (manager.AddModel(mp.ModelName, finemodel, simplemodel)) { bRes = true; } } else { if (manager.UpdateModel(mp.ModelName, finemodel) && manager.UpdateSimplifiedModel(mp.ModelName, simplemodel)) { bRes = true; } } } if (!bRes) { return; } IRowBufferCollection rowCol = new RowBufferCollection(); rowCol.Add(row); beforeRowBufferMap[featureClassInfo] = rowCol; UpdateDatabase(); app.Current3DMapControl.FeatureManager.RefreshFeatureClass(fc); } } catch (Exception ex) { } }
public Remove(ObjectIdGenerator idGenerator) : base(idGenerator) { }
public Previous(ObjectIdGenerator idGenerator) : base(idGenerator) { }
public ItemDataReturningOperation(ObjectIdGenerator idGenerator) : base(idGenerator) { }
public static Id NewId() { return(new Id(ObjectIdGenerator.GenerateNewId())); }
public ReferenceEncounters(IRootReferences references, IEntities entities, ObjectIdGenerator generator) { _references = references; _entities = entities; _generator = generator; }
public InsertAfter(ObjectIdGenerator idGenerator, ListItemData value) : base(idGenerator, value) { }
public CompareExchangeValue(ObjectIdGenerator idGenerator, int oldValue, int newValue) : base(idGenerator) { this.oldValue = oldValue; this.newValue = newValue; }