Example #1
0
        public int GetIloscMiejscWolnychVip()
        {
            if (Pojazd != null)
            {
                if (ListaRezerwacji.Count() != 0)
                {
                    int liczba = 0;
                    foreach (RezerwcjaBilet Objekt in ListaRezerwacji)
                    {
                        if (Objekt.CzyVIP() == true)
                        {
                            liczba++;
                        }
                    }

                    return(Pojazd.GetIloscMiejscVip() - liczba);
                }
                else
                {
                    return(Pojazd.GetIloscMiejscVip());
                }
            }
            else
            {
                throw new Wyjatek("Nie został dodany samolot obsłudujący ten lot, lub został on usunięty!!");
            }
        }
Example #2
0
        public async Task <ActionResult <Objekt> > PostObjekt(Objekt objekt)
        {
            _context.Objekts.Add(objekt);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetObjekt", new { id = objekt.HouseId }, objekt));
        }
Example #3
0
        public int GetIloscMiejscWolnychZwyklych()
        {
            if (Pojazd != null)
            {
                if (ListaRezerwacji.Count() != 0)
                {
                    int liczba = 0;
                    foreach (RezerwcjaBilet Objekt in ListaRezerwacji)
                    {
                        if (Objekt.CzyVIP() == false)
                        {
                            liczba++;
                        }
                    }

                    return(Pojazd.GetIloscMiejsc() - liczba);
                }
                else
                {
                    return(Pojazd.GetIloscMiejsc());
                }
            }
            else
            {
                throw new Wyjatek("Nie został dodany samolot obsłudujący ten lot, lub został!!");// niech uzytkownik wypełni pole samolotu!! niech w ekstrymalnych przypadkach program usuwa                                                                           // dany lot żebby problemy się nie robiły
            }
        }
Example #4
0
        public async Task <IActionResult> PutObjekt(int id, Objekt objekt)
        {
            if (id != objekt.HouseId)
            {
                return(BadRequest());
            }

            _context.Entry(objekt).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ObjektExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        private ISpelvärld SkapaSpelvärldMedKaraktärenVid(Position position)
        {
            var spelvärld      = new Spelvärld();
            var spelarkaraktär = new Objekt {
                Position = position
            };

            spelvärld.LäggTill(spelarkaraktär, Objekttyp.Spelarkaraktären);
            return(spelvärld);
        }
        /// <summary>
        /// 设置实体对象
        /// </summary>
        /// <param name="objekt">实体对象</param>
        public static void SetObjekt(Objekt objekt)
        {
            string key = GenerateKey(objekt.Id);

            if (CurrentInstance._objektBuffer.ContainsKey(key))
            {
                CurrentInstance._objektBuffer.Remove(key);
            }
            CurrentInstance._objektBuffer.Add(key, objekt);
            Cache.Current.Set(key, objekt, new TimeSpan(0, 1, 0, 0));
        }
Example #7
0
        /// <summary>
        /// 设置指定对象的seo关键字。
        /// </summary>
        /// <param name="keys"></param>
        /// <param name="relationshipName"></param>
        /// <param name="sourceId"></param>
        public static void SetObjektSeo(List <string> keys, string relationshipName, string sourceId)
        {
            List <FeSeoKey> entityKeys = new List <FeSeoKey>();

            foreach (string key in keys)
            {
                FeSeoKey entity = new ObjektCollection <FeSeoKey>(Klass.ForId("FeSeoKey@Klass"), new WhereClause("\"key\" = '" + key + "'")).TryGetSingleResult();
                if (entity == null)
                {
                    entity     = new FeSeoKey();
                    entity.Key = key;
                    entity.Save();
                }
                IEnumerable <FeSeoKey> query = from t in entityKeys
                                               where t.Key == entity.Key
                                               select t;
                if (query.Count() == 0)
                {
                    entityKeys.Add(entity);
                }
            }
            Objekt objekt = ObjektFactory.Find(sourceId);
            List <RelationshipObjekt> relationshipList = objekt.ROCC.GetROC(relationshipName).ToList();
            List <RelationshipObjekt> deleteList       = new List <RelationshipObjekt>();

            foreach (RelationshipObjekt item3 in relationshipList)
            {
                IEnumerable <FeSeoKey> existQuery2 = from t in entityKeys
                                                     where t.Id == item3.Related.Id
                                                     select t;
                if (existQuery2.Count() == 0)
                {
                    deleteList.Add(item3);
                }
            }
            foreach (RelationshipObjekt item4 in deleteList)
            {
                item4.Delete();
                item4.Save();
            }
            foreach (FeSeoKey item5 in entityKeys)
            {
                IEnumerable <RelationshipObjekt> existQuery = from t in relationshipList
                                                              where t.Related.Id == item5.Id
                                                              select t;
                if (existQuery.Count() == 0)
                {
                    RelationshipObjekt relationship = ObjektFactory.New <RelationshipObjekt>(Klass.ForName(relationshipName));
                    relationship.Source  = objekt;
                    relationship.Related = item5;
                    relationship.Save();
                }
            }
        }
Example #8
0
        public async Task <ActionResult <Objekt> > PostObjekt(Objekt item)
        {
            if (item.besitzer != null)
            {
                item.besitzer = _context.Person.Find(item.besitzer.PersonId);
            }
            _context.Objekt.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetObjekt), new { id = item.ObjektId }, item));
        }
Example #9
0
 private void DoDataChange(object sender, Objekt obj)
 {
     try
     {
         obj.Update();
     }
     catch (Exception ex)
     {
         Console.WriteLine("Fehler beim DoDataChange", ex);
         //throw;
     }
 }
Example #10
0
        public async Task <IActionResult> Create([Bind("HouseId,Images,Adress,HousingType,FormOfLease,Price,Rooms,LivingArea,BiArea,PlotArea,Descriptions,ShowingDate,BuildYear,BrookerId")] Objekt objekt)
        {
            if (ModelState.IsValid)
            {
                _context.Add(objekt);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BrookerId"] = new SelectList(_context.Brookers, "BrookerId", "Email", objekt.BrookerId);
            return(View(objekt));
        }
Example #11
0
        public async Task <IActionResult> PutObjekt(int id, Objekt item)
        {
            if (id != item.ObjektId)
            {
                return(BadRequest());
            }

            _context.Entry(item).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(NoContent());
        }
Example #12
0
 void Ujemanje(Objekt o1)
 {
     //Recursively groups all the objects and neighbour objects
     for (int i = 0; i < Objekti.Count; i++)
     {
         try
         {
             if ((Objekti[i] != o1) && (Objekti[i].Group != o1.Group) && (Objekti[i].Rect.IntersectsWith(o1.Rect)))
             {
                 Objekti[i].Group = o1.Group;
                 o1.Group.Objekti.Add(Objekti[i]);
                 Ujemanje(Objekti[i]);
             }
         }
         catch { }
     }
 }
Example #13
0
        /// <summary>
        ///     设置指定对象的属性。
        /// </summary>
        /// <param name="characters"></param>
        /// <param name="relationshipName"></param>
        /// <param name="sourceId"></param>
        public static void SetObjektCharacter(List <string> characters, string relationshipName, string sourceId)
        {
            Objekt objekt = ObjektFactory.Find(sourceId);
            List <RelationshipObjekt> relationshipList = objekt.ROCC.GetROC(relationshipName).ToList();

            foreach (RelationshipObjekt item in relationshipList)
            {
                item.Delete();
                item.Save();
            }
            foreach (string character in characters)
            {
                RelationshipObjekt relationship = ObjektFactory.New <RelationshipObjekt>(Klass.ForName(relationshipName));
                relationship.Source  = objekt;
                relationship.Related = ObjektFactory.Find(character);
                relationship.Save();
            }
        }
Example #14
0
        private static ISpelvärld SkapaSpelvärld()
        {
            var tile = new Bildstorlek(32, 32);

            var väggar = new int[][]
            {
                new int[] { 1, 1, 1, 1, 1 },
                new int[] { 1, 2, 2, 2, 1 },
                new int[] { 1, 2, 2, 2, 1 },
                new int[] { 1, 2, 2, 2, 1 },
                new int[] { 1, 1, 1, 1, 1 }
            };

            var spelvärld = new Spelvärld();

            var spelarkaraktär = new Objekt {
                Position = new Position(3 * 32, 3 * 32, 1), Bild = new Bild(new Bildmängdskoordinat(0, 0), new Bildstorlek(32, 32))
            };

            spelvärld.LäggTill(spelarkaraktär, Objekttyp.Spelarkaraktären);

            for (var y = 0; y < 5; y++)
            {
                for (var x = 0; x < 5; x++)
                {
                    if (väggar[x][y] == 1)
                    {
                        spelvärld.LäggTill(new Objekt {
                            Position = new Position(x * 32, y * 32, 0), Bild = new Bild(new Bildmängdskoordinat(1 * 32, 3 * 32), tile)
                        });
                    }
                    else if (väggar[x][y] == 2)
                    {
                        spelvärld.LäggTill(new Objekt {
                            Position = new Position(x * 32, y * 32, 0), Bild = new Bild(new Bildmängdskoordinat(0 * 32, 3 * 32), tile)
                        });
                    }
                }
            }


            return(spelvärld);
        }
Example #15
0
        /// <summary>
        /// 设置指定对象的seo关键字。
        /// </summary>
        /// <param name="tags"></param>
        /// <param name="relationshipName"></param>
        /// <param name="sourceId"></param>
        public static void SetObjektTag(List <string> tags, string relationshipName, string sourceId)
        {
            List <FeTag> entityTags = new List <FeTag>();

            foreach (string tag in tags)
            {
                FeTag entity = new ObjektCollection <FeTag>(Klass.ForId("FeTag@Klass"), new WhereClause("\"tag\" = '" + tag + "'")).TryGetSingleResult();
                if (entity == null)
                {
                    entity      = new FeTag();
                    entity.Tag  = tag;
                    entity.From = ObjektFactory.Find <Value>("75d290896b3d40ad802c9d6b04d61a9b@Value");
                    entity.Save();
                }
                IEnumerable <FeTag> query = from t in entityTags
                                            where t.Tag == entity.Tag
                                            select t;
                if (query.Count() == 0)
                {
                    entityTags.Add(entity);
                }
            }
            Objekt objekt = ObjektFactory.Find(sourceId);
            List <RelationshipObjekt> relationshipList = objekt.ROCC.GetROC(relationshipName).ToList();

            foreach (RelationshipObjekt item2 in relationshipList)
            {
                item2.Delete();
                item2.Save();
            }
            foreach (FeTag item3 in entityTags)
            {
                RelationshipObjekt relationship = ObjektFactory.New <RelationshipObjekt>(Klass.ForName(relationshipName));
                relationship.Source  = objekt;
                relationship.Related = item3;
                relationship.Save();
            }
        }
Example #16
0
        /// <summary>
        ///
        /// </summary>
        private Object3D Parse(string text)
        {
            // v float float float

            var vertex_pattern = @"v( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)";

            // vn float float float

            var normal_pattern = @"vn( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)";

            // vt float float

            var uv_pattern = @"vt( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)";

            // f vertex vertex vertex ...

            var face_pattern1 = @"f( +-?\d+)( +-?\d+)( +-?\d+)( +-?\d+)?";

            // f vertex/uv vertex/uv vertex/uv ...

            var face_pattern2 = @"f( +(-?\d+)\/(-?\d+))( +(-?\d+)\/(-?\d+))( +(-?\d+)\/(-?\d+))( +(-?\d+)\/(-?\d+))?";

            // f vertex/uv/normal vertex/uv/normal vertex/uv/normal ...

            var face_pattern3 = @"f( +(-?\d+)\/(-?\d+)\/(-?\d+))( +(-?\d+)\/(-?\d+)\/(-?\d+))( +(-?\d+)\/(-?\d+)\/(-?\d+))( +(-?\d+)\/(-?\d+)\/(-?\d+))?";

            // f vertex//normal vertex//normal vertex//normal ...

            var face_pattern4 = @"f( +(-?\d+)\/\/(-?\d+))( +(-?\d+)\/\/(-?\d+))( +(-?\d+)\/\/(-?\d+))( +(-?\d+)\/\/(-?\d+))?";


            var lines = text.Split('\n');

            for (var i = 0; i < lines.Length; i++)
            {
                var line = lines[i];
                line = line.Trim();

                if (line.Length == 0 || line[0] == '#')
                {
                    continue;
                }

                {
                    var rgx     = new Regex(vertex_pattern, RegexOptions.IgnoreCase);
                    var matches = rgx.Matches(line);

                    foreach (Match match in matches)
                    {
                        this._vertices.AddRange(new [] { floatParse(match.Groups[1].Value), floatParse(match.Groups[2].Value), floatParse(match.Groups[3].Value) });
                    }

                    if (matches.Count > 0)
                    {
                        continue;
                    }
                }

                {
                    var rgx     = new Regex(normal_pattern, RegexOptions.IgnoreCase);
                    var matches = rgx.Matches(line);

                    foreach (Match match in matches)
                    {
                        this._normals.AddRange(new[] { floatParse(match.Groups[1].Value), floatParse(match.Groups[2].Value), floatParse(match.Groups[3].Value) });
                    }

                    if (matches.Count > 0)
                    {
                        continue;
                    }
                }

                {
                    var rgx     = new Regex(uv_pattern, RegexOptions.IgnoreCase);
                    var matches = rgx.Matches(line);

                    foreach (Match match in matches)
                    {
                        this._uvs.AddRange(new[] { floatParse(match.Groups[1].Value), floatParse(match.Groups[2].Value) });
                    }

                    if (matches.Count > 0)
                    {
                        continue;
                    }
                }

                {
                    var rgx     = new Regex(face_pattern1, RegexOptions.IgnoreCase);
                    var matches = rgx.Matches(line);

                    foreach (Match match in matches)
                    {
                        addFace(
                            intParse(match.Groups[1].Value), intParse(match.Groups[2].Value), intParse(match.Groups[3].Value), intParse(match.Groups[4].Value),
                            null, null, null, null,
                            null, null, null, null);
                    }

                    if (matches.Count > 0)
                    {
                        continue;
                    }
                }

                {
                    var rgx     = new Regex(face_pattern2, RegexOptions.IgnoreCase);
                    var matches = rgx.Matches(line);

                    foreach (Match match in matches)
                    {
                        addFace(
                            intParse(match.Groups[2].Value), intParse(match.Groups[5].Value), intParse(match.Groups[8].Value), intParse(match.Groups[11].Value),
                            intParse(match.Groups[3].Value), intParse(match.Groups[6].Value), intParse(match.Groups[9].Value), intParse(match.Groups[12].Value),
                            null, null, null, null);
                    }

                    if (matches.Count > 0)
                    {
                        continue;
                    }
                }

                {
                    var rgx     = new Regex(face_pattern3, RegexOptions.IgnoreCase);
                    var matches = rgx.Matches(line);

                    foreach (Match match in matches)
                    {
                        addFace(
                            intParse(match.Groups[2].Value), intParse(match.Groups[6].Value), intParse(match.Groups[10].Value), intParse(match.Groups[14].Value),
                            intParse(match.Groups[3].Value), intParse(match.Groups[7].Value), intParse(match.Groups[11].Value), intParse(match.Groups[15].Value),
                            intParse(match.Groups[4].Value), intParse(match.Groups[8].Value), intParse(match.Groups[12].Value), intParse(match.Groups[16].Value));
                    }

                    if (matches.Count > 0)
                    {
                        continue;
                    }
                }


                {
                    var rgx     = new Regex(face_pattern4, RegexOptions.IgnoreCase);
                    var matches = rgx.Matches(line);

                    foreach (Match match in matches)
                    {
                        addFace(
                            intParse(match.Groups[2].Value), intParse(match.Groups[5].Value), intParse(match.Groups[8].Value), intParse(match.Groups[11].Value),
                            null, null, null, null,
                            intParse(match.Groups[3].Value), intParse(match.Groups[6].Value), intParse(match.Groups[9].Value), intParse(match.Groups[12].Value));
                    }

                    if (matches.Count > 0)
                    {
                        continue;
                    }
                }

                if (line.Contains("o "))
                {
                    this._geometry = new Geometry();

                    this._material = new Material();

                    this._object = new Objekt {
                        name = line.Substring(2, line.Length - 2).Trim(), Geometry = this._geometry, Material = this._material
                    };

                    this._objects.Add(this._object);

                    continue;
                }

                if (line.Contains("g "))
                {
                    // group
                    continue;
                }

                if (line.Contains("usemtl "))
                {
                    // material

                    this._material.name = line.Substring(7, line.Length - 7).Trim();

                    continue;
                }

                if (line.Contains("mtllib "))
                {
                    // mtl file
                    continue;
                }

                if (line.Contains("s "))
                {
                    // // smooth shading
                    continue;
                }

                Trace.TraceInformation("OBJLoader: Unhandled line " + line);
            }

            var container = new Object3D();

            for (var i = 0; i < this._objects.Count; i++)
            {
                var obj  = this._objects[i];
                var geom = obj.Geometry;

                var buffergeometry = new BufferGeometry();

                buffergeometry.AddAttribute("position", new BufferAttribute <float>(geom.Vertices.ToArray(), 3));

                if (geom.Normals.Count > 0)
                {
                    buffergeometry.AddAttribute("normal", new BufferAttribute <float>(geom.Normals.ToArray(), 3));
                }

                if (geom.Uvs.Count > 0)
                {
                    buffergeometry.AddAttribute("uv", new BufferAttribute <float>(geom.Uvs.ToArray(), 2));
                }

                var mat = new MeshLambertMaterial();
                mat.Name = obj.Material.name;

                var mesh = new Mesh(buffergeometry, mat);
                mesh.Name = obj.name;

                container.Add(mesh);
            }

            return(container);
        }
Example #17
0
        /// <summary>
        /// Calculates motion between two images
        /// </summary>
        /// <param name="FirstImage">Firs image</param>
        /// <param name="SecondImage">Second image</param>
        /// <param name="Sensitivity">Minimum color difference</param>
        /// <param name="Preciseness">Pixel size</param>
        /// <returns>Motion detected</returns>
        public bool DetectMotion(Bitmap FirstImage, Bitmap SecondImage, int Sensitivity, int Preciseness, bool Pixelize)
        {

            if (FirstImage.Size != SecondImage.Size)
                throw new Exception("Image sizes must be the same.");


            int l = Sensitivity;

                try
                {
                    Bitmap original = (Bitmap)((Bitmap)SecondImage).GetThumbnailImage(SecondImage.Width, SecondImage.Height, null, new IntPtr());
                    FirstImage = ImageManipulation.ToBlackAndWhite(FirstImage);
                    SecondImage = ImageManipulation.ToBlackAndWhite(SecondImage);



                    int b = Preciseness;
                    if (Pixelize)
                    {
                        ImageManipulation.Pixelate(FirstImage, b);
                        ImageManipulation.Pixelate(SecondImage, b);
                    }


                    byte[] rgb1 = ImageManipulation.GetBytes(FirstImage);
                    byte[] rgb2 = ImageManipulation.GetBytes(SecondImage);



                    Graphics grp = Graphics.FromImage(original);
                    Objekti.Clear();
                    Grupe.Clear();

                    //Copy Start

                    for (int y = 0; y < FirstImage.Height - 4; y += b)
                        for (int x = 0; x < FirstImage.Width - 4; x += b)
                        {
                            byte barva1 = GetColor(x, y, rgb1, FirstImage.Width);
                            byte barva2 = GetColor(x, y, rgb2, SecondImage.Width);
                            int raz = Math.Abs(barva1 - barva2);
                            if (raz > l)
                            {
                                Objekt obj = new Objekt();
                                obj.Rect = new Rectangle(x - b, y - b, b + b, b + b);
                                obj.Jakost = raz;
                                Objekti.Add(obj);

                            }

                        }



                    for (int i = 0; i < Objekti.Count; i++)
                    {
                        if (Objekti[i].Group == null)
                        {
                            Grupa grupa = new Grupa();

                            Objekt o1 = Objekti[i];
                            grupa.Objekti.Add(o1);
                            o1.Group = grupa;

                            Ujemanje(o1);

                            Grupe.Add(grupa);
                        }

                    }

                    Najdeno.Clear();
                    foreach (Grupa grupa in Grupe)
                    {
                        int miX = grupa.Objekti[0].Rect.X;
                        int miY = grupa.Objekti[0].Rect.Y;

                        int maX = grupa.Objekti[0].Rect.X;
                        int maY = grupa.Objekti[0].Rect.Y;

                        foreach (Objekt o in grupa.Objekti)
                        {
                            if (o.Rect.X < miX)
                                miX = o.Rect.X;
                            if (o.Rect.X + o.Rect.Width > maX)
                                maX = o.Rect.X + o.Rect.Width;

                            if (o.Rect.Y < miY)
                                miY = o.Rect.Y;
                            if (o.Rect.Y + o.Rect.Height > maY)
                                maY = o.Rect.Y + o.Rect.Height;
                        }
                        Najdeno.Add(new Rectangle(miX, miY, maX - miX, maY - miY));

                    }

                    for (int i = 0; i < Grupe.Count; i++)
                    {
                        foreach (Objekt obj in Grupe[i].Objekti)
                        {
                            if (i == 0)
                                grp.DrawRectangle(Pens.Blue, obj.Rect);
                            //grp.DrawRectangle(new Pen(Color.FromArgb(obj.Jakost, 0, 0)), obj.Rect);
                            else if (i == 1)
                                grp.DrawRectangle(Pens.Red, obj.Rect);
                            else if (i == 2)
                                grp.DrawRectangle(Pens.Green, obj.Rect);
                            else if (i == 3)
                                grp.DrawRectangle(Pens.Pink, obj.Rect);
                            else if (i == 4)
                                grp.DrawRectangle(Pens.Blue, obj.Rect);
                            else if (i == 5)
                                grp.DrawRectangle(Pens.Orange, obj.Rect);
                            else if (i == 6)
                                grp.DrawRectangle(Pens.Orchid, obj.Rect);
                            else if (i == 7)
                                grp.DrawRectangle(Pens.Snow, obj.Rect);
                            else if (i == 8)
                                grp.DrawRectangle(Pens.LightYellow, obj.Rect);
                            else if (i == 9)
                                grp.DrawRectangle(Pens.LightYellow, obj.Rect);
                            else if (i == 10)
                                grp.DrawRectangle(Pens.Gainsboro, obj.Rect);
                            else if (i == 11)
                                grp.DrawRectangle(Pens.Purple, obj.Rect);
                            else if (i == 12)
                                grp.DrawRectangle(Pens.HotPink, obj.Rect);
                            else
                                grp.DrawRectangle(Pens.White, obj.Rect);

                        }
                    }

                    //for (int i = 0; i < Najdeno.Count; i++)
                    //    grp.DrawRectangle(Pens.Yellow, Najdeno[i]);

                    //double Sens = 10;
                    for (int i = 0; i < Najdeno.Count; i++)
                    {
                        grp.DrawRectangle(Pens.Yellow, Najdeno[i]);
                    }


                    MotionRectangles.Clear();
                    MotionRectangles.AddRange(Najdeno);

                    //Copy End
                    grp.Save();

                    ProcessedImage = original;


                    if (MotionRectangles.Count > 0)
                        return true;
                    else
                        return false;

                }
                catch { throw new Exception("There was an error while trying to calculate motion detection."); }


        }
 public FlyttaSpelarobjekt(ISpelvärld spelvärld, ISpelarhandling spelarhandling)
 {
     _spelvärld      = spelvärld ?? throw new UndantagFörSaknatKrav("FlyttaSpelarobjekt måste skapas med spelvärld.");
     _spelarkaraktär = _spelvärld.HämtaSpelarKaraktären();
     _spelarhandling = spelarhandling ?? throw new UndantagFörSaknatKrav("FlyttaSpelarobjekt måste skapas med spelarhandling.");
 }
Example #19
0
        private void Error(object sender, EventArgs e)
        {
            SessionContext sessionContext = null;

            if (PersistenceContext.IsExisting)
            {
                if (PersistenceContext.SessionContext.IsDiagnosis)
                {
                    string        loginName     = User.Current.LoginName;
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.Append(loginName).Append(" ObjetkFrameworkWebAdapter ").Append("PersitentContextAutoFinish(Failure:Discard) ")
                    .Append(PersistenceContext.GetString());
                    diagnosis.Info(stringBuilder);
                }
                sessionContext = PersistenceContext.SessionContext;
                if (!PersistenceContext.IsTransaction)
                {
                    try
                    {
                        PersistenceContext.Discard();
                    }
                    catch (Exception exception)
                    {
                        log.Warn("未处理异常检查,自动结束(Discard)当前持久化上下文出错。", exception);
                    }
                }
                else
                {
                    PersistenceContext.Discard();
                }
            }
            string message    = httpApplication.Server.GetLastError().Message;
            string stackTrace = httpApplication.Server.GetLastError().StackTrace;

            log.Error(message + stackTrace);
            try
            {
                if (sessionContext == null)
                {
                    sessionContext = new SessionContext("Web未处理异常", ObjektFactory.Find <User>("e2c4e2f4ecec4d6d8dce2fe6c831352e@User"));
                }
                if (!PersistenceContext.IsExisting)
                {
                    PersistenceContext.BeginTransaction(sessionContext);
                }
                Objekt    value     = ObjektFactory.Find("3c757b8d46364133a2061a455394d640@Value");
                Objekt    value2    = ObjektFactory.Find("97dff0c8a32542bc8c28e5c10c9cc3c9@Value");
                string    value3    = $"{message}发生在{HttpContext.Current.Request.RawUrl},错误堆栈{stackTrace}";
                SystemLog systemLog = new SystemLog();
                systemLog.SetProperty("type", value);
                systemLog.SetProperty("logType", value2);
                systemLog.SetProperty("abstract", message);
                systemLog.SetProperty("detail", value3);
                systemLog.Save();
                PersistenceContext.Accept();
            }
            catch
            {
                PersistenceContext.Discard();
            }
        }
Example #20
0
 public override int GetHashCode()
 {
     return(Objekt.GetHashCode() ^ Nr.GetHashCode());
 }
Example #21
0
 private static bool BildVäljare(Objekt objekt)
 {
     return(objekt.Bild != null && objekt.Position != null);
 }