Esempio n. 1
0
        private void ReadAttribute(IDBObject myDBObject, XmlReader myReader)
        {
            var key   = myReader.GetAttribute(GraphMLTokens.KEY);
            var value = myReader.ReadElementContentAsString();

            if (key != null)
            {
                var tupel = _AttributeDefinitions[key];

                if (tupel != null)
                {
                    var attrName = tupel.Item2;
                    var attrType = tupel.Item3;

                    if (value == null) // use default value
                    {
                        value = tupel.Item4;
                    }

                    if (attrType != null && value != null)
                    {
                        // add or update property
                        myDBObject[attrName] = CastValue(attrType, value);
                    }
                }
            }
        }
Esempio n. 2
0
        public async Task <ReplaceOneResult> HandoffSaveAsync(ISerializable obj)
        {
            IDBObject saveme = obj.GetDBObject();

            try
            {
                if (saveme.ModelType == ModelTypes.ShipModel)
                {
                    return(await _handedOffShips.ReplaceOneAsync(Builders <ShipModel> .Filter.Eq(s => s.Id, saveme.Id), (ShipModel)saveme, new UpdateOptions { IsUpsert = true }));
                }
                else if (saveme.ModelType == ModelTypes.PlayerModel)
                {
                    return(await _handedOffPlayers.ReplaceOneAsync(Builders <PlayerModel> .Filter.Eq(s => s.Id, saveme.Id), (PlayerModel)saveme, new UpdateOptions { IsUpsert = true }));
                }
                else
                {
                    throw new Exception("Error: Handoff serialization not available for objects of type " + saveme.ModelType);
                }
            }
            catch (Exception e)
            {
                ConsoleManager.WriteLine("Exception in " + this + ": " + e.Message, ConsoleMessageType.Error);
                ConsoleManager.WriteLine(e.StackTrace, ConsoleMessageType.Error);
                return(ReplaceOneResult.Unacknowledged.Instance);
            }
        }
Esempio n. 3
0
 public Mission(int id, Action action, bool isProgressType, IDBObject context)
 {
     Id             = id;
     Action         = action;
     IsProgressType = isProgressType;
     Context        = context;
 }
Esempio n. 4
0
 /// <summary>
 /// Creates the specified db.
 /// </summary>
 /// <param name="db">The db.</param>
 /// <param name="collectionName">Name of the collection.</param>
 /// <param name="options">The options.</param>
 public static void create(this IDatabase db, string collectionName, IDBObject options)
 {
     DBQuery createCmd = new DBQuery("create", collectionName);
     createCmd.PutAll(options);
     IDBObject result = db.ExecuteCommand(createCmd);
     result.ThrowIfResponseNotOK("create failed");
 }
Esempio n. 5
0
        public void ConvertFromDBObject(IDBObject obj)
        {
            if (!(obj is DB_Category))
            {
                return;
            }

            DB_Category dbCat = obj as DB_Category;

            this.ID = Guid.Parse(dbCat.ID);
            this.IsMasterCategory = dbCat.IsMasterCategory;
            this.Name             = dbCat.Name;

            DataHelper.AddItem(this);

            if (!string.IsNullOrEmpty(dbCat.ParentCategory))
            {
                DB_Category parentDBCat = new DB_Category();
                parentDBCat.Load(dbCat.ParentCategory);
                ISaveable saveable = DataHelper.LoadedObjects.FirstOrDefault(lo => lo.ID.ToString() == parentDBCat.ID);
                if (saveable != null)
                {
                    Category parentCat = DataHelper.LoadedObjects.Where(lo => lo is Category).Cast <Category>().FirstOrDefault(lo => lo.ID.ToString() == parentDBCat.ID);
                    this.ParentCategory = parentCat;
                }
                else
                {
                    Category parentCat = new Category();
                    parentCat.ConvertFromDBObject(parentDBCat);
                    this.ParentCategory = parentCat;
                }
            }
        }
Esempio n. 6
0
 // obj must be of type Table.Type, value of type Type
 public void Set(IDBObject obj, object value)
 {
     if (obj.GetType() != container.Type)
     {
         throw new ArgumentException("Attempt to set field " + this + " on object of type " + obj.GetType().FullName);
     }
     property.SetValue(obj, value, null);
 }
Esempio n. 7
0
 // obj must be of type Table.Type
 public object Get(IDBObject obj)
 {
     if (obj.GetType() != container.Type)
     {
         throw new ArgumentException("Attempt to get field " + this + " on object of type " + obj.GetType().FullName);
     }
     return(property.GetValue(obj, null));
 }
Esempio n. 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Update"/> class.
 /// </summary>
 /// <param name="fullNameSpace">The full name space.</param>
 /// <param name="selector">The selector.</param>
 /// <param name="document">The document.</param>
 /// <param name="flags">The flags.</param>
 public Update(string fullNameSpace, IDBObject selector, IDBObject document, UpdateOption flags)
     : base(Operation.Update)
 {
     FullNameSpace = fullNameSpace;
     Selector = selector;
     Document = document;
     Flags = flags;
 }
Esempio n. 9
0
        public static void ConsolePrint(this IDBObject obj)
        {
            var type = obj.GetType();

            foreach (var property in type.GetProperties())
            {
                Console.WriteLine("{0}: {1}", property.Name, property.GetValue(obj));
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Adds a new object
        /// </summary>
        /// <param name="newObject">The object to add</param>
        internal virtual void AddObject(IDBObject newObject)
        {
            if (this.databaseObjects.ContainsKey(string.Concat(newObject.Schema, newObject.Name)))
            {
                throw new Exception(string.Format("Duplicate object found: {0}", newObject.Name));
            }

            this.databaseObjects.Add(string.Concat(newObject.Schema, newObject.Name), newObject);
        }
Esempio n. 11
0
        private void WriteIntoIPS(List <MyStruct> objectsToWrite)
        {
            IDBObject obj = null;

            foreach (var item in objectsToWrite)
            {
                dependsFlag = DependsOnFLAG(item.Flag);
                dependsFlag?.Invoke(ref obj, item);
            }
        }
Esempio n. 12
0
 public void Set(IDBObject obj, string value, bool truncate)
 {
     if (!typeof(string).Equals(Type))
     {
         throw new ArgumentException("Attempt to set non-string field " + this + " with truncation");
     }
     if (truncate && value != null && Length != null && value.Length > Length)
     {
         value = value.Substring(0, (int)Length);
     }
     Set(obj, value);
 }
Esempio n. 13
0
 /// <summary>
 /// Removes pending object from the pending collection
 /// </summary>
 internal void RemovePendingDBObject()
 {
     string[] keys = new string[this.databaseObjects.Count];
     this.databaseObjects.Keys.CopyTo(keys, 0);
     foreach (string s in keys)
     {
         IDBObject so = this.databaseObjects[s];
         if (!so.Complete)
         {
             this.databaseObjects.Remove(s);
         }
     }
 }
Esempio n. 14
0
        public void MakeRelationsBtwnDocs(Dictionary <string, IDBObject> children, IDBObject parent)
        {
            IDBRelationCollection coll = Session.GetRelationCollection(1014);

            IDBObject objectParentChecked = parent.CheckOut(true); //  asm
            IDBObject newChildChecked;

            foreach (var child in children)
            {
                newChildChecked = child.Value.CheckOut(true);                                               //  prt
                IDBRelation relation = coll.Create(objectParentChecked.ObjectID, newChildChecked.ObjectID); // создаем связь между изделием и документом
            }
        }
Esempio n. 15
0
 public int Save(IDBObject idbObject)
 {
     lock (locker) {
         if (idbObject.ID != 0)
         {
             database.Update(idbObject);
             return(idbObject.ID);
         }
         else
         {
             return(database.Insert(idbObject));
         }
     }
 }
Esempio n. 16
0
        protected override Player _instantiateObject(IDBObject pm, LocatorService ls)
        {
            PlayerModel model = pm as PlayerModel;

            if (model.PlayerType == PlayerTypes.Human)
            {
                return(new HumanPlayer(model, ls));
            }
            else
            {
                var p = new NPCPlayer(model, ls);
                p.MessageService = new RedisOutgoingMessageService(_redisServer, p);
                return(p);
            }
        }
Esempio n. 17
0
        public void ConvertFromDBObject(IDBObject obj)
        {
            if (!(obj is DB_Payee))
            {
                return;
            }

            DB_Payee dbPay = obj as DB_Payee;

            this.ID       = Guid.Parse(dbPay.ID);
            this.IsActive = dbPay.IsActive;
            this.Name     = dbPay.Name;

            DataHelper.AddItem(this);
        }
Esempio n. 18
0
        private void WriteAdditionalAttributesContent(string myAttributeTarget, IDBObject myObject)
        {
            foreach (var id in _AdditionalAttributes.Keys)
            {
                var value = _AdditionalAttributes[id];

                if (value.AttributeTarget.Equals(myAttributeTarget))
                {
                    if (myObject.Attributes.ContainsKey(value.AttributeName))
                    {
                        //<data id="..">..</data>
                        _StreamWriter.WriteLine("           <{0} {1}=\"{2}\">{3}{4}",
                                                GraphMLTokens.DATA, GraphMLTokens.KEY, id, myObject.Attributes[value.AttributeName].ToString(), GraphMLTokens.DATA_END_TAG);
                    }
                }
            }
        }
Esempio n. 19
0
        // ReSharper disable UnusedMember.Global
        public static IList <T> LoaderImpl <T>(AbstractBufferedReader reader, IDBObject owner) where T : class
        // ReSharper restore UnusedMember.Global
        {
            var count = reader.ReadVUInt32();

            if (count == 0)
            {
                return(null);
            }
            var oids = new List <ulong>((int)count);

            while (count-- > 0)
            {
                oids.Add(reader.ReadVUInt64());
            }
            return(new ListOfDBObject <T>(owner, oids));
        }
Esempio n. 20
0
 public bool UpdateObject(IDBObject dbObject)
 {
     Npgsql.NpgsqlConnection  conn       = null;
     Npgsql.NpgsqlTransaction trans      = null;
     Npgsql.NpgsqlConnection  readerConn = null;
     try
     {
         if (dbObject != null)
         {
             conn       = (Npgsql.NpgsqlConnection)NpgsqlConnectionImpl.GetInstance().GetNewConnection();
             readerConn = (Npgsql.NpgsqlConnection)NpgsqlConnectionImpl.GetInstance().GetNewConnection();
             object result = this.GetDataReader(dbObject.GetObjectByIdQuery(), readerConn);
             if (result != null)
             {
                 string strSql = dbObject.GetUpdateStatement();
                 Npgsql.NpgsqlCommand command = new Npgsql.NpgsqlCommand(strSql);
                 command.Connection = conn;
                 trans = conn.BeginTransaction();
                 command.ExecuteNonQuery();
                 trans.Commit();
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         if (trans != null)
         {
             trans.Rollback();
         }
         throw ex;
     }
     finally
     {
         if (conn != null)
         {
             conn.Close();
         }
         if (readerConn != null)
         {
             readerConn.Close();
         }
     }
     return(false);
 }
Esempio n. 21
0
        void element_object(string name, IDBObject obj)
        {
            Condition.Requires(obj, "obj").IsNotNull();

            IDBObjectCustom custom = obj as IDBObjectCustom;
            if (custom != null)
            {
                custom.Write(this);
                return;
            }

            if (_handleSpecialObjects(name, obj))
                return;

            if (!string.IsNullOrWhiteSpace(name))
            {
                element_type(TypeByte.OBJECT);
                element_name(name);
            }

            long sizePos = BaseStream.Position;
            Write(0); //Dummy object size, will overwrite later
            //write the _id first
            if (obj.HasID())
            {
                element("_id", obj.GetID());
            }
            IList<string> transientFields = obj.GetAs<IList<string>>("_transientFields");

            foreach (string key in obj.Keys)
            {
                if (key.Equals("_id"))
                    continue;

                if (transientFields != null && transientFields.Contains(key))
                    continue;

                object val = obj[key];
                element(key, val);
            }
            Write((byte)TypeByte.EOO);
            //Go back and overwrite the dummy length
            RewindAndWriteSize(sizePos);
        }
Esempio n. 22
0
        //asmDesignition - имя сборки находящейся на одном уровне с objectsOfTheSameLevel
        private void BuildTreeView(List <MyStruct> allObjects, string asmDesignition, List <MyStruct> objectsOfTheSameLevel)
        {
            MyStruct             asm;
            Predicate <MyStruct> getAsm = delegate(MyStruct t) { return(t.Designition == asmDesignition); };
            Predicate <MyStruct> getHigherReferencedAsm = delegate(MyStruct t) { return(t.RefAsmName == asmDesignition); };

            //cписок деталей/чертежей/сборок нижнего уровня, которые ссылаються на name (имя сборки более высокого уровня)
            List <MyStruct> list = allObjects.FindAll(getHigherReferencedAsm);

            // сборки которые есть на нижнем уровне
            List <MyStruct> subList = list?.Where(x => x.IPsDocType.Equals(IPSObjectTypes.DocSldAssembly)).ToList();


            if (list.Count == 0) // в list только одна сборка, на которую не ссылаються другие обьекты, сборка нижнего уровня
            {
                asm = allObjects.Find(getAsm);
                WriteIntoIPS(new List <MyStruct> {
                    asm
                });                                       // записали сборку
                //связь со сборкой высшего уровня???
            }

            if (subList.Count == 0)//если сборок нет, заливаем в IPS
            {
                asm = objectsOfTheSameLevel.Find(getAsm);

                IDBObject obj = null;
                CreatDoc(ref obj, asm); // создали документ сборки

                list.Remove(asm);
                WriteIntoIPS(list); // а теперь обьекты, которые на нее ссылаються

                MakeRelationsBtwnDocs(createdDocs, createdDocs.Where(x => x.Key.Equals(asm.Designition)).First().Value);
            }
            else
            {
                foreach (var item in subList)
                {
                    BuildTreeView(allObjects, item.Designition, list);
                }
            }
        }
    public static IDBObject CreateObject(string type)
    {
        IDBObject ObjSelector = null;

        switch (type)
        {
        case "SP":
            ObjSelector = new SQLStoreProc();
            break;

        case "FUNC":
            ObjSelector = new SQLFucntion();
            break;

        default:
            ObjSelector = new SQLMisc();
            break;
        }
        return(ObjSelector);
    }
Esempio n. 24
0
        public void ConvertFromDBObject(IDBObject obj)
        {
            if (!(obj is DB_Account))
            {
                return;
            }

            DB_Account acc = obj as DB_Account;

            this.ID          = Guid.Parse(acc.ID);
            this.IsActive    = acc.IsActive;
            this.IsOffBudget = acc.IsOffBudget;
            this.Name        = acc.Name;
            this.Note        = acc.Note;
            Enums.AccountType type = Enums.AccountType.None;
            Enum.TryParse <Enums.AccountType>(acc.Type, out type);
            this.Type = type;

            DataHelper.AddItem(this);
        }
Esempio n. 25
0
        public void InitializationTest(int id, int start, int current, int end, bool isAe)
        {
            DBContext.Progresses.Clear();

            Progress progress1 = null;

            try
            {
                progress1 = new Progress(start, current, end);
                if (isAe && id > 0)
                {
                    Assert.Fail();
                }
                DBContext.Progresses.Add(progress1);
            }
            catch (ArgumentException) { }

            IDBObject progress2 = null;

            try
            {
                progress2 = new Progress(id, start, current, end);
                if (isAe)
                {
                    Assert.Fail();
                }
                DBContext.Progresses.Add((Progress)progress2);
            }
            catch (ArgumentException) { }

            if (!isAe)
            {
                Assert.AreEqual(id, progress2.Id);
                Assert.AreEqual(start, progress1.Start);
                Assert.AreEqual(start, ((Progress)progress2).Start);
                Assert.AreEqual(current, progress1.Current);
                Assert.AreEqual(current, ((Progress)progress2).Current);
                Assert.AreEqual(end, progress1.End);
                Assert.AreEqual(end, ((Progress)progress2).End);
            }
        }
Esempio n. 26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="DocObj">Передаем null, инициализируеться в методе</param>
        /// <param name="_object"></param>
        private void CreatDoc(ref IDBObject DocObj, MyStruct _object)
        {
            DocObj = null;
            IDBObjectCollection coll = Session.GetObjectCollection((int)_object.IPsDocType);

            DocObj = coll.Create((int)_object.IPsDocType);

            // добавление создаваемого обьекта в Документы/Конструкторские/Электронные модели
            IDBAttribute atrName        = DocObj.Attributes.FindByGUID(new Guid(SystemGUIDs.attributeName));        //наименование документа
            IDBAttribute atrDesignation = DocObj.Attributes.FindByGUID(new Guid(SystemGUIDs.attributeDesignation)); //обозначение документа

            atrName.Value        = _object.Name;
            atrDesignation.Value = _object.Designition;

            var res = createdDocs.Where(x => x.Key.Equals(_object.Designition)).ToList();

            if (res.Count == 0)
            {
                createdDocs.Add(_object.Designition, DocObj);
            }
        }
Esempio n. 27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="DocObj">При записи в БД нового обьекта, DocObj это новый обьект созданный предварительным вызовом CreateDoc(); при добавлении файла к существующей сборке, DocObj - обьект сборки"</param>
        /// <param name="filePath"></param>
        private void Blob(ref IDBObject DocObj, MyStruct _object)
        {
            if (_object.Flag == 5)// пишем Blob не в новый документ, а в сборку
            {
                DocObj = createdDocs.Where(x => x.Key.Equals(_object.RefAsmName)).Select(y => y.Value).First();
            }

            int          attrFile = MetaDataHelper.GetAttributeTypeID(new Guid(SystemGUIDs.attributeFile));// атрибут "Файл"
            IDBAttribute fileAtr  = DocObj.GetAttributeByID(attrFile);

            if (fileAtr.Values.Count() >= 1)
            {
                fileAtr.AddValue(_object.Path);
            }
            using (var ms = new MemoryStream(File.ReadAllBytes(_object.Path)))
            {
                BlobInformation blInfo = new BlobInformation(0, 0, DateTime.Now, _object.Path, ArcMethods.NotPacked, null);
                BlobProcWriter  writer = new BlobProcWriter(fileAtr, (int)AttributableElements.Object, blInfo, ms, null, null);

                writer.WriteData();
            }
        }
Esempio n. 28
0
        protected static SourcedEvent DeserializeToEventIDBObject(IDBObject dbObject)
        {
            Type eventType = Type.GetType((string)dbObject["_AssemblyQualifiedEventTypeName"]);

            var sourceId = Guid.Parse(dbObject["_SourceId"].ToString());

            var deserializedEvent = Activator.CreateInstance(eventType) as SourcedEvent;

            foreach (string key in dbObject.Keys)
            {
                var propertyOnEvent = eventType.GetProperty(key, BindingFlags.Public | BindingFlags.Instance);

                // TODO: Add warning to the log file when the prop was not found or writable.
                if (propertyOnEvent == null || !propertyOnEvent.CanWrite)
                {
                    continue;
                }

                var propertyTypesMatch = propertyOnEvent.PropertyType.Equals(dbObject[key].GetType());

                if (propertyTypesMatch)
                {
                    propertyOnEvent.SetValue(deserializedEvent, dbObject[key], new object[] { });
                }

                var propertyOnEventIsGuidAndDbObjectPropertyIsString
                    = !propertyTypesMatch &&
                      propertyOnEvent.PropertyType.Equals(typeof(Guid)) &&
                      dbObject[key].GetType().Equals(typeof(string));

                if (propertyOnEventIsGuidAndDbObjectPropertyIsString)
                {
                    var parsedGuid = new Guid(dbObject[key].ToString());
                    propertyOnEvent.SetValue(deserializedEvent, parsedGuid, new object[] { });
                }
            }

            return(deserializedEvent);
        }
Esempio n. 29
0
        /// <summary>
        /// Создает изделие
        /// </summary>
        /// <param name="productType"></param>
        /// <param name="parentID">ID документа на который создаеться изделие</param>//prt
        private void CreateProduct(ref IDBObject DocObj, MyStruct _object)
        {
            IDBObjectCollection coll   = Session.GetObjectCollection((int)_object.IPsProductType);
            IDBObject           newObj = coll.Create((int)_object.IPsProductType);

            //берем аттрибуты объекта
            IDBAttribute atrDesignation = newObj.GetAttributeByGuid(new Guid(SystemGUIDs.attributeDesignation)); //обозначение
            IDBAttribute atrName        = newObj.GetAttributeByGuid(new Guid(SystemGUIDs.attributeName));        //наименование

            atrDesignation.Value = _object.Designition;
            atrName.Value        = _object.Name;
            newObj.CommitCreation(true);

            IDBObject newObjChecked = newObj.CheckOut();

            IDBRelationCollection colRel   = Session.GetRelationCollection(1004);
            IDBRelation           relation = colRel.Create(newObjChecked.ObjectID, DocObj.ID); // создаем связь между изделием и докумиентом,

            if (relation == null)
            {
                MessageBox.Show("Failed create the relation of type " + colRel.RelationTypeID.ToString());
            }
        }
Esempio n. 30
0
 public bool DeleteObject(IDBObject dbObject)
 {
     Npgsql.NpgsqlTransaction trans = null;
     Npgsql.NpgsqlConnection  conn  = null;
     try
     {
         if (dbObject != null)
         {
             conn = (Npgsql.NpgsqlConnection)NpgsqlConnectionImpl.GetInstance().GetNewConnection();
             Npgsql.NpgsqlCommand command = new Npgsql.NpgsqlCommand(dbObject.GetDeleteStatement());
             command.Connection = conn;
             trans = conn.BeginTransaction();
             int count = command.ExecuteNonQuery();
             trans.Commit();
             if (count > 0)
             {
                 return(true);
             }
         }
     }
     catch (Exception ex)
     {
         if (trans != null)
         {
             trans.Rollback();
         }
         throw ex;
     }
     finally
     {
         if (conn != null)
         {
             conn.Close();
         }
     }
     return(false);
 }
Esempio n. 31
0
 private void OnAttributeChange(IDBObject sender)
 {
     HighLightOnce = sender;
 }
Esempio n. 32
0
 public void BringElementToFront(IDBObject element)
 {
     if (element == null)
         return;
     int graphPrior = (int)Graph.GetAlgorithmObj(_KH_PANE_GRAPH_PRIOR);
     if (new Edge(new Vertex(),new Vertex()).GetType().Equals(element.GetType()))
     {
         Edge e = (Edge)element;
         e.SetAlgorithmObj(_KH_PANE_GRAPH_PRIOR, graphPrior);
     }
     if(new Vertex().GetType().Equals(element.GetType())){
         Vertex e = (Vertex)element;
         graphPrior += 1;
         e.SetAlgorithmObj(_KH_PANE_GRAPH_PRIOR, graphPrior);
         foreach (Edge ei in e.IncomingEdges)
         {
             BringElementToFront(ei);
         }
         foreach (Edge eo in e.OutgoingEdges)
         {
             BringElementToFront(eo);
         }
     }
 }
Esempio n. 33
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (DragElement == null)
            {
                if (currentButtons == MouseButtons.Left)
                    command = CommandMode.TranslateView;
                else if (currentButtons == MouseButtons.Right)
                    command = CommandMode.ScaleView;
                else command = CommandMode.None;//
            }

            Point currentLocation;
            PointF transformed_location;
            if (abortDrag)
            {
                transformed_location = originalLocation;

                var points = new PointF[] { originalLocation };
                transformation.TransformPoints(points);
                currentLocation = new Point((int)points[0].X, (int)points[0].Y);
            }
            else
            {
                currentLocation = e.Location;

                var points = new PointF[] { currentLocation };
                inverse_transformation.TransformPoints(points);
                transformed_location = points[0];
            }

            var deltaX = (lastLocation.X - currentLocation.X) / zoom;
            var deltaY = (lastLocation.Y - currentLocation.Y) / zoom;

            bool needRedraw = false;
            switch (command)
            {
                case CommandMode.ScaleView:
                    if (!mouseMoved)
                    {
                        if ((Math.Abs(deltaY) > 1))
                            mouseMoved = true;
                    }

                    if (mouseMoved &&
                        (Math.Abs(deltaY) > 0))
                    {
                        zoom *= (float)Math.Pow(2, deltaY / 100.0f);
                        Cursor.Position = this.PointToScreen(lastLocation);
                        snappedLocation = //lastLocation =
                            currentLocation;
                        this.Refresh();
                    }
                    return;
                case CommandMode.TranslateView:
                    {
                        if (!mouseMoved)
                        {
                            if ((Math.Abs(deltaX) > 1) ||
                                (Math.Abs(deltaY) > 1))
                                mouseMoved = true;
                        }

                        if (mouseMoved &&
                            (Math.Abs(deltaX) > 0) ||
                            (Math.Abs(deltaY) > 0))
                        {
                            translation.X -= deltaX * zoom;
                            translation.Y -= deltaY * zoom;
                            snappedLocation = lastLocation = currentLocation;
                            this.Refresh();
                        }
                        return;
                    }
            }

            if (dragging)
            {
                if (!mouseMoved)
                {
                    if ((Math.Abs(deltaX) > 1) ||
                        (Math.Abs(deltaY) > 1))
                        mouseMoved = true;
                }

                if (mouseMoved &&
                    (Math.Abs(deltaX) > 0) ||
                    (Math.Abs(deltaY) > 0))
                {
                    mouseMoved = true;
                    if (DragElement != null)
                    {
                        BringElementToFront(DragElement);

                        if (new Vertex().GetType().Equals(DragElement.GetType()))
                        {
                            var vertex = DragElement as Vertex;
                            PointF location = (PointF)vertex.GetAlgorithmObj(_KH_PANE_LOCATION);
                            RectangleF bounds = (RectangleF)vertex.GetAlgorithmObj(_KH_PANE_BOUNDS);
                            vertex.SetAlgorithmObj(_KH_PANE_LOCATION
                                , new PointF((int)Math.Round(location.X - deltaX),
                                           (int)Math.Round(location.Y - deltaY))
                            );
                            vertex.SetAlgorithmObj(_KH_PANE_BOUNDS
                                , new RectangleF(
                                    (int)Math.Round(bounds.X- deltaX),
                                    (int)Math.Round(bounds.Y - deltaY),
                                    (int)Math.Round(bounds.Width),
                                    (int)Math.Round(bounds.Height)
                                    )
                            );
                            snappedLocation = lastLocation = currentLocation;
                            this.Refresh();
                            return;
                        }
                    }
                }
            }

            //NodeConnector destinationConnector = null;
            //IElement draggingOverElement = null;

            IEdge elementEdge = FindEdgeAt(transformed_location);

            if (elementEdge != null)
            {
                if (HoverElement != elementEdge)
                {
                    HoverElement = elementEdge;
                    needRedraw = true;
                }
            }
            else
            {
                IVertex elementVertex = FindVertexAt(transformed_location);

                if (HoverElement != elementVertex)
                {
                    HoverElement = elementVertex;
                    needRedraw = true;
                }
            }

            if (needRedraw)
                this.Refresh();
        }
Esempio n. 34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LastError"/> class.
 /// </summary>
 /// <param name="res">The res.</param>
 public LastError(IDBObject res)
     : base(res)
 {
 }
Esempio n. 35
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DatabaseList"/> class.
 /// </summary>
 /// <param name="response">The response.</param>
 public DatabaseList(IDBObject response)
     : base(response)
 {
 }
Esempio n. 36
0
 /// <summary>
 /// Writes the DB object.
 /// </summary>
 /// <param name="writer">The writer.</param>
 /// <param name="dbo">The dbo.</param>
 protected virtual void WriteDBObject(WireProtocolWriter writer, IDBObject dbo)
 {
     writer.Write(dbo);
 }
Esempio n. 37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Aggregate"/> class.
 /// </summary>
 /// <param name="column">The column.</param>
 /// <param name="aggregateType">Type of the aggregate.</param>
 public Aggregate(IDBObject column, AggregateFunction aggregateType)
 {
     ColumnName     = column.QualifiedName;
     _aggregateType = aggregateType;
     Alias          = String.Concat(GetFunctionType(this), "Of", column.Name);
 }
Esempio n. 38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssertInfo"/> class.
 /// </summary>
 /// <param name="obj">The obj.</param>
 public AssertInfo(IDBObject obj)
     : base(obj)
 {
 }
Esempio n. 39
0
 /// <summary>
 /// Writes the specified object.
 /// </summary>
 /// <param name="o">the object to encode</param>
 public void Write(IDBObject o)
 {
     element_object(null, o);
 }
Esempio n. 40
0
 void SetFlag(IDBObject obj, Flags.State state, bool Set)
 {
     obj.SetAlgorithmObj(state.ToString(), Set);
 }
Esempio n. 41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Aggregate"/> class.
 /// </summary>
 /// <param name="column">The column.</param>
 /// <param name="alias">The alias.</param>
 /// <param name="aggregateType">Type of the aggregate.</param>
 public Aggregate(IDBObject column, string alias, AggregateFunction aggregateType)
 {
     ColumnName = column.QualifiedName;
     Alias = alias;
     _aggregateType = aggregateType;
 }
Esempio n. 42
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Aggregate"/> class.
 /// </summary>
 /// <param name="column">The column.</param>
 /// <param name="aggregateType">Type of the aggregate.</param>
 public Aggregate(IDBObject column, AggregateFunction aggregateType)
 {
     ColumnName = column.QualifiedName;
     _aggregateType = aggregateType;
     Alias = String.Concat(GetFunctionType(this), "Of", column.Name);
 }
Esempio n. 43
0
        private bool _handleSpecialObjects(string name, IDBObject o)
        {
            if (o == null)
                return false;

            if (o is IDBCollection)
            {
                IDBCollection c = (IDBCollection)o;
                element_ref(name, c.Uri.GetCollectionName(), Oid.CollectionRefID);
                return true;
            }

            if ((o as IList) == null && o.ContainsKey(Constants.NO_REF_HACK))
            {
                o.Remove(Constants.NO_REF_HACK);
                return false;
            }

            if (!_dontRefContains(o) &&
             name != null &&
                 !(o is IList) &&
                 o.CameFromDB())
            {
                element_ref(name, o["_ns"].ToString(), o.GetOid());
                return true;
            }

            return false;
        }
Esempio n. 44
0
        private void ReadAttribute(IDBObject myDBObject, XmlReader myReader)
        {
            var key = myReader.GetAttribute(GraphMLTokens.KEY);
            var value = myReader.ReadElementContentAsString();

            if (key != null)
            {
                var tupel = _AttributeDefinitions[key];

                if (tupel != null)
                {
                    var attrName = tupel.Item2;
                    var attrType = tupel.Item3;

                    if (value == null) // use default value
                    {
                        value = tupel.Item4;
                    }

                    if (attrType != null && value != null)
                    {
                        // add or update property
                        myDBObject[attrName] = CastValue(attrType, value);
                    }
                }
            }
        }
Esempio n. 45
0
        protected static SourcedEvent DeserializeToEventIDBObject(IDBObject dbObject)
        {
            Type eventType = Type.GetType((string)dbObject["_AssemblyQualifiedEventTypeName"]);

            var sourceId = Guid.Parse(dbObject["_SourceId"].ToString());

            var deserializedEvent = Activator.CreateInstance(eventType) as SourcedEvent;

            foreach (string key in dbObject.Keys)
            {
                var propertyOnEvent = eventType.GetProperty(key, BindingFlags.Public | BindingFlags.Instance);

                // TODO: Add warning to the log file when the prop was not found or writable.
                if (propertyOnEvent == null || !propertyOnEvent.CanWrite) continue;

                var propertyTypesMatch = propertyOnEvent.PropertyType.Equals(dbObject[key].GetType());

                if (propertyTypesMatch)
                {
                    propertyOnEvent.SetValue(deserializedEvent, dbObject[key], new object[] { });
                }

                var propertyOnEventIsGuidAndDbObjectPropertyIsString
                    = !propertyTypesMatch &&
                      propertyOnEvent.PropertyType.Equals(typeof(Guid)) &&
                      dbObject[key].GetType().Equals(typeof(string));

                if (propertyOnEventIsGuidAndDbObjectPropertyIsString)
                {
                    var parsedGuid = new Guid(dbObject[key].ToString());
                    propertyOnEvent.SetValue(deserializedEvent, parsedGuid, new object[] { });
                }
            }

            return deserializedEvent;
        }
Esempio n. 46
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DBObjectWrapper"/> class.
 /// </summary>
 /// <param name="obj">The obj.</param>
 public DBObjectWrapper(IDBObject obj)
 {
     Object = obj;
 }
Esempio n. 47
0
 public DBObjectEventArgs(IDBObject dbobject)
 {
     DBObject = dbobject;
 }
Esempio n. 48
0
        private void WriteAdditionalAttributesContent(string myAttributeTarget, IDBObject myObject)
        {
            foreach (var id in _AdditionalAttributes.Keys)
            {
                var value = _AdditionalAttributes[id];

                if (value.AttributeTarget.Equals(myAttributeTarget))
                {
                    if (myObject.Attributes.ContainsKey(value.AttributeName))
                    {
                        //<data id="..">..</data>
                        _StreamWriter.WriteLine("           <{0} {1}=\"{2}\">{3}{4}",
                            GraphMLTokens.DATA, GraphMLTokens.KEY, id, myObject.Attributes[value.AttributeName].ToString(), GraphMLTokens.DATA_END_TAG);
                    }
                }
            }
        }
Esempio n. 49
0
 /// <summary>
 /// Adds a new object
 /// </summary>
 /// <param name="newObject">The object to add</param>
 internal override void AddObject(IDBObject newObject)
 {
     base.AddObject(newObject);
 }
Esempio n. 50
0
        private static void setup()
        {
            small = new DBObject();

            DBObjectArray a = new DBObjectArray();
            a["0"] = "test";
            a["1"] = "benchmark";
            medium = new DBObject() {
                {"integer", 5},
                {"number", 5.05},
                {"bool", false},
                {"array", a},
                };

            DBObjectArray harvest = new DBObjectArray();
            for (int test = 0; test < 20; test++)
            {
                harvest[test * 14 + 0] = "10gen";
                harvest[test * 14 + 1] = "web";
                harvest[test * 14 + 2] = "open";
                harvest[test * 14 + 3] = "source";
                harvest[test * 14 + 4] = "application";
                harvest[test * 14 + 5] = "paas";
                harvest[test * 14 + 6] = "platform-as-a-service";
                harvest[test * 14 + 7] = "technology";
                harvest[test * 14 + 8] = "helps";
                harvest[test * 14 + 9] = "developers";
                harvest[test * 14 + 10] = "focus";
                harvest[test * 14 + 11] = "building";
                harvest[test * 14 + 12] = "mongodb";
                harvest[test * 14 + 13] = "mongo";
            }
            large = new DBObject()
            {
                {"base_url", "http://www.example.com/test-me"},
                {"total_word_count", 6743},
                {"access_time", new DateTime()},
                {"meta_tags", new DBObject() {
                     {"description", "test am a long description string"},
                     {"author", "Holly Man"},
                     {"dynamically_created_meta_tag", "who know\n what"}}},
                {"page_structure", new DBObject() {
                     {"counted_tags", 3450},
                     {"no_of_js_attached", 10},
                     {"no_of_images", 6}}},
                {"harvested_words", harvest}
            };
        }
Esempio n. 51
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Delete"/> class.
 /// </summary>
 /// <param name="objectToDelete">The object to delete.</param>
 /// <param name="fullNameSpace">The full name space.</param>
 public Delete(IDBObject objectToDelete, string fullNameSpace)
     : base(Operation.Delete)
 {
     FullNameSpace = fullNameSpace;
     DeleteQuery = objectToDelete;
 }
Esempio n. 52
0
 //{version : dbVersion, gitVersion : gitCommitId, sysInfo : osInfo, ok : 1}
 /// <summary>
 /// Initializes a new instance of the <see cref="BuildInfo"/> class.
 /// </summary>
 /// <param name="response">The response.</param>
 public BuildInfo(IDBObject response)
     : base(response)
 {
 }
Esempio n. 53
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Aggregate"/> class.
 /// </summary>
 /// <param name="column">The column.</param>
 /// <param name="alias">The alias.</param>
 /// <param name="aggregateType">Type of the aggregate.</param>
 public Aggregate(IDBObject column, string alias, AggregateFunction aggregateType)
 {
     ColumnName     = column.QualifiedName;
     Alias          = alias;
     _aggregateType = aggregateType;
 }
Esempio n. 54
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OpTime"/> class.
 /// </summary>
 /// <param name="obj">The obj.</param>
 public OpTime(IDBObject obj)
     : base(obj)
 {
 }
Esempio n. 55
0
 //{ err : errorMessage, nPrev : countOpsBack, ok : 1 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PrevError"/> class.
 /// </summary>
 /// <param name="response">The response.</param>
 public PrevError(IDBObject response)
     : base(response)
 {
 }
Esempio n. 56
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DBError"/> class.
 /// </summary>
 /// <param name="response">The underlying response object from the database.</param>
 public DBError(IDBObject response)
 {
     Response = response;
 }