コード例 #1
0
        private static ModelViews.ExceptionLog.Extend Create(ModelViews.ExceptionLog.Extend view)
        {
            var data = new DAL.exceptionLog();

            try
            {
                using (var ctx = new TraditionEntities())
                {
                    if (view.Id == 0)
                    {

                        data.exceptionStack = view.ExceptionStack;
                        data.errorState = view.ErrorState;
                        data.customInfo = view.CustomInfo;
                        data.created = DateTime.Now;
                        data.exceptionMessage = view.ExceptionMessage;
                        data.exceptionSource = view.ExceptionSource;
                        data.exceptionTargetsite = view.ExceptionTargetsite;
                        data.exceptionData = view.ExceptionData;
                        ctx.exceptionLogs.AddObject(data);
                        ctx.SaveChanges();

                    }
                }
            }
            catch (Exception ex)
            {
                //data = new DAL.exceptionLog();
                //ExceptionLog.CreateExceptionLog(ex, ExceptionLog.ErrorState.Significant, "ExceptionLogController.Create");
            }

            return Mappers.ExceptionLog.Basic(data);
        }
コード例 #2
0
 public void UpdateModelViews(ModelViewSerializable mvs)
 {
     if (ModelViews == null)
     {
         ModelViews = new ObservableCollection <ModelViewSerializable>();
     }
     if ((mvs != null) && (SelectedEntity != null) && (CurrentDbContext != null))
     {
         if (mvs.RootEntityFullClassName == SelectedEntity.CodeElementFullName)
         {
             if (CurrentDbContext.ModelViews != null)
             {
                 ModelViewSerializable result =
                     CurrentDbContext.ModelViews.FirstOrDefault(m => m.ViewName == mvs.ViewName);
                 if (result != null)
                 {
                     if (!ModelViews.Any(m => m.ViewName == mvs.ViewName))
                     {
                         ModelViews.Add(mvs);
                     }
                 }
             }
         }
     }
     OnPropertyChanged("SelectedEntity");
 }
コード例 #3
0
        private static ModelViews.TrackingLog.Extend Create(ModelViews.TrackingLog.Extend view)
        {
            var data = new DAL.trackingLog();
            try
            {
                using (var ctx = new TraditionEntities())
                {
                    if (view.Id == 0)
                    {

                        data.clientId = view.ClientId;
                        data.authUserId = view.AuthUserId;
                        data.recordId = view.RecordId;
                        data.recordTable = view.RecordTable;
                        data.memo = view.Memo;
                        data.trackingState = view.TrackingState;

                        data.created = DateTime.Now;
                        data.ipAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

                        ctx.AddTotrackingLogs(data);
                        ctx.SaveChanges();

                    }
                }
            }
            catch (Exception ex)
            {
                data = new DAL.trackingLog();
            }
            return Mappers.TrackingLog.Basic(data);
        }
コード例 #4
0
ファイル: PostServices.cs プロジェクト: Maniac8288/Blog
 /// <summary>
 /// Конвертирует модель в PostViews
 /// </summary>
 /// <param name="View">Модель ModelViews</param>
 /// <returns></returns>
 private static PostViews ConvertViewsModel(ModelViews View)
 {
     return(new PostViews
     {
         id = View.id,
         PostID = View.PostID,
     });
 }
コード例 #5
0
        public void OnSelectedItemViewNameChanged()
        {
            if (SelectedItem == null)
            {
                return;
            }
            ModelViewForeignKey foreignKey = SelectedItem as ModelViewForeignKey;

            if (foreignKey == null)
            {
                return;
            }
            //foreignKey.IsAssinging = true;
            foreignKey.ViewName = SelectedItemViewName;
            //foreignKey.IsAssinging = false;
            if (foreignKey.ScalarProperties == null)
            {
                foreignKey.ScalarProperties = new ObservableCollection <ModelViewProperty>();
            }
            if (string.IsNullOrEmpty(foreignKey.ViewName))
            {
                return;
            }
            if (foreignKey.ScalarProperties.Count > 0)
            {
                return;
            }
            ModelViewSerializable modelViewSerializable = ModelViews.FirstOrDefault(mv => mv.ViewName == foreignKey.ViewName);

            if (modelViewSerializable.ScalarProperties == null)
            {
                return;
            }
            modelViewSerializable.ScalarProperties.ForEach(mv => foreignKey.ScalarProperties.Add(mv.ModelViewPropertySerializableAssingTo(new ModelViewProperty())));
            bool isRequired = foreignKey.ModelViewForeignKeyIsRequired();

            foreach (ModelViewProperty prop in foreignKey.ScalarProperties)
            {
                prop.IsRequiredInView = prop.IsRequiredInView && isRequired;
            }
            foreignKey.IsAssinging      = true;
            foreignKey.ForeignKeyPrefix = foreignKey.NavigationName + modelViewSerializable.ViewName;
            foreignKey.IsAssinging      = false;
            foreignKey.OnModelViewForeignKeyPrefixChanged();
            foreignKey.ModelViewForeignKeyUpdateForeignKeyNameChain();
        }
コード例 #6
0
        public virtual void ImportBtnCommandAction(Object param)
        {
            OpenFileDialog ofdlg = new OpenFileDialog();

            ofdlg.Filter     = "JSON-files(*.json)|*.json";
            ofdlg.DefaultExt = "json";
            ofdlg.Title      = "Select a source to import";
            if (ofdlg.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            try
            {
                string jsonString = File.ReadAllText(ofdlg.FileName);
                DbContextSerializable srcContext = JsonConvert.DeserializeObject <DbContextSerializable>(jsonString);
                if (CurrentDbContext == null)
                {
                    return;
                }
                if (CurrentDbContext.ModelViews == null)
                {
                    CurrentDbContext.ModelViews = new List <ModelViewSerializable>();
                }
                foreach (ModelViewSerializable itm in srcContext.ModelViews)
                {
                    if (itm.RootEntityClassName != SelectedEntity.CodeElementName)
                    {
                        continue;
                    }
                    if (CurrentDbContext.ModelViews.Any(m => m.ViewName == itm.ViewName))
                    {
                        continue;
                    }
                    ModelViewSerializable destItm = itm.ModelViewSerializableGetCopy(this.DestinationProject, this.DefaultProjectNameSpace, this.DestinationFolder, this.DbSetProppertyName, this.SelectedEntity);
                    CurrentDbContext.ModelViews.Add(destItm);
                    ModelViews.Add(destItm);
                }
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show("Error:" + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
コード例 #7
0
        public void OnForeignKeySelected(ModelViewForeignKey foreignKey)
        {
            if (ModelViews == null)
            {
                ModelViews = new ObservableCollection <ModelViewSerializable>();
            }
            if (foreignKey == null)
            {
                ModelViews.Clear();
                return;
            }
            if (ModelViews.Any(mv => ((mv.RootEntityFullClassName != foreignKey.NavigationEntityFullName) || (mv.RootEntityUniqueProjectName != foreignKey.NavigationEntityUniqueProjectName))))
            {
                ModelViews.Clear();
            }
            if (CurrentDbContext == null)
            {
                return;
            }
            if (CurrentDbContext.ModelViews == null)
            {
                return;
            }
            List <ModelViewSerializable> result = CurrentDbContext.ModelViews
                                                  .Where(mv => (mv.RootEntityFullClassName == foreignKey.NavigationEntityFullName) && (mv.RootEntityUniqueProjectName == foreignKey.NavigationEntityUniqueProjectName))
                                                  .ToList();

            if (result != null)
            {
                if (result.Count != ModelViews.Count)
                {
                    result.ForEach(r =>
                    {
                        if (!ModelViews.Any(mv => mv.ViewName == r.ViewName))
                        {
                            ModelViews.Add(r);
                        }
                    });
                }
            }
        }
コード例 #8
0
ファイル: PostServices.cs プロジェクト: Maniac8288/Blog
 /// <summary>
 /// Добовляет просмотр к посту
 /// </summary>
 /// <param name="PostID">Номер поста</param>
 public void GetView(int PostID)
 {
     using (var db = new DataContext())
     {
         ModelViews View = new ModelViews();
         View.PostID = PostID;
         HttpCookie CookieReq = HttpContext.Current.Request.Cookies["PostViews"];
         if (CookieReq == null)
         {
             HttpCookie ViewsCookie = new HttpCookie("PostViews");
             if (ViewsCookie == null || string.IsNullOrWhiteSpace(ViewsCookie.Value))
             {
                 View.id = Guid.NewGuid();
                 var NewView = ConvertViewsModel(View);
                 db.PostViews.Add(NewView);
                 var post = db.Posts.FirstOrDefault(x => x.PostID == PostID);
                 post.CountViews++;
                 db.SaveChanges();
                 ViewsCookie.Expires.AddDays(1);
                 ViewsCookie.Value = View.id.ToString();
                 HttpContext.Current.Response.Cookies.Add(ViewsCookie);
             }
         }
         else
         {
             Guid Value = Guid.Parse(CookieReq.Value);
             if (db.PostViews.FirstOrDefault(x => x.id == Value && x.PostID == View.PostID) == null)
             {
                 View.id = Value;
                 var NewView = ConvertViewsModel(View);
                 db.PostViews.Add(NewView);
                 var post = db.Posts.FirstOrDefault(x => x.PostID == PostID);
                 post.CountViews++;
                 db.SaveChanges();
             }
         }
     }
 }
コード例 #9
0
 public void DoAnalize()
 {
     if (ModelViews == null)
     {
         ModelViews = new ObservableCollection <ModelViewSerializable>();
     }
     if ((ModelViews.Count > 0) || (SelectedEntity == null))
     {
         CheckIsReady();
         return;
     }
     if (CurrentDbContext.ModelViews != null)
     {
         foreach (ModelViewSerializable itm in CurrentDbContext.ModelViews)
         {
             if (itm.RootEntityFullClassName == SelectedEntity.CodeElementFullName)
             {
                 ModelViews.Add(itm);
             }
         }
     }
     CheckIsReady();
 }
コード例 #10
0
        public override void Run()
        {
            using (var txn = model.BeginTransaction("Example"))
            {
                ModelViews.Add("ProductDataView");

                var lib = New <IfcProjectLibrary>(l => l.Name = "Air Terminal Library");
                var hz  = New <IfcSIUnit>(u =>
                {
                    u.Name     = Xbim.Ifc4.Interfaces.IfcSIUnitName.HERTZ;
                    u.UnitType = Xbim.Ifc4.Interfaces.IfcUnitEnum.FREQUENCYUNIT;
                });
                var watt = New <IfcSIUnit>(u =>
                {
                    u.Name     = Xbim.Ifc4.Interfaces.IfcSIUnitName.WATT;
                    u.UnitType = Xbim.Ifc4.Interfaces.IfcUnitEnum.POWERUNIT;
                });
                var db = New <IfcDerivedUnit>(u =>
                {
                    u.UnitType = Xbim.Ifc4.Interfaces.IfcDerivedUnitEnum.SOUNDPRESSURELEVELUNIT;
                    u.Elements.Add(New <IfcDerivedUnitElement>(due =>
                    {
                        due.Exponent = 1;
                        due.Unit     = watt;
                    }));
                    u.Elements.Add(New <IfcDerivedUnitElement>(due =>
                    {
                        due.Exponent = -1;
                        due.Unit     = watt;
                    }));
                });
                lib.UnitsInContext = New <IfcUnitAssignment>(ua =>
                {
                    ua.Units.Add(hz);
                    ua.Units.Add(db);
                });

                var type = New <IfcAirTerminalType>(t => t.Name = "Air Terminal");
                New <IfcRelDeclares>(rel =>
                {
                    rel.RelatingContext = lib;
                    rel.RelatedDefinitions.Add(type);
                });
                var pset = New <IfcPropertySet>(ps =>
                {
                    ps.Name = "Air Terminal Properties";
                });
                type.HasPropertySets.Add(pset);

                var prop = New <IfcPropertyTableValue>(t =>
                {
                    t.Name         = "Acustic Performance [table of values]";
                    t.DefiningUnit = hz;
                    t.DefinedUnit  = db;
                    t.DefiningValues.AddRange(new IfcValue[] {
                        new IfcFrequencyMeasure(63),
                        new IfcFrequencyMeasure(125),
                        new IfcFrequencyMeasure(250),
                        new IfcFrequencyMeasure(500),
                        new IfcFrequencyMeasure(1000),
                        new IfcFrequencyMeasure(2000),
                        new IfcFrequencyMeasure(4000),
                        new IfcFrequencyMeasure(8000)
                    });
                    t.DefinedValues.AddRange(new IfcValue[] {
                        new IfcSoundPressureLevelMeasure(102),
                        new IfcSoundPressureLevelMeasure(99),
                        new IfcSoundPressureLevelMeasure(98),
                        new IfcSoundPressureLevelMeasure(98),
                        new IfcSoundPressureLevelMeasure(97),
                        new IfcSoundPressureLevelMeasure(95),
                        new IfcSoundPressureLevelMeasure(86),
                        new IfcSoundPressureLevelMeasure(81)
                    });
                });
                pset.HasProperties.Add(prop);

                var docProp = New <IfcPropertyReferenceValue>(r =>
                {
                    r.Name = "Acustic Performance [document reference]";
                    r.PropertyReference = New <IfcDocumentReference>(doc =>
                    {
                        doc.Name     = "Acustic Performance Documentation";
                        doc.Location = "https://www.daikinac.com/content/assets/DOC/EngineeringManuals/EDUS041501.pdf";
                    });
                });
                pset.HasProperties.Add(docProp);

                var fce = New <IfcPropertySingleValue>(r =>
                {
                    r.Name         = "Acustic Performance [function]";
                    r.NominalValue = new IfcText("0.0492424242 * Math.pow(x,4) - 1.0328282828 * Math.pow(x,3) + 6.8068181818 * Math.pow(x,2) - 17.753968254 * x + 114.14285714");
                    r.Description  = "ISO/IEC 22275:2018";
                });
                pset.HasProperties.Add(fce);

                txn.Commit();
            }

            // this will save .ifc, .ifcxml and .log with all potential schema errors
            SaveAs("properties", true, typeof(IfcProjectLibrary));
        }
コード例 #11
0
 public void OnSelectedEntityChanged()
 {
     SelectedModel = null;
     ModelViews.Clear();
 }
コード例 #12
0
 public void OnCurrentDbContextChanged()
 {
     SelectedModel = null;
     ModelViews.Clear();
 }
コード例 #13
0
        public override void Run()
        {
            using (var txn = model.BeginTransaction("Example"))
            {
                ModelViews.Add("ProductDataView");

                var lib = New <IfcProjectLibrary>(l => l.Name = "Declaration of Performance");
                Comment(lib, @"Root element of this file. Because this doesn't define a specific instance in the building it is a library.
It can be used to declare elements, properties, property templates and other library objects 
which can be later used in the actual design.");
                var mm = New <IfcSIUnit>(u =>
                {
                    u.Name     = Xbim.Ifc4.Interfaces.IfcSIUnitName.METRE;
                    u.Prefix   = Xbim.Ifc4.Interfaces.IfcSIPrefix.MILLI;
                    u.UnitType = Xbim.Ifc4.Interfaces.IfcUnitEnum.LENGTHUNIT;
                    Comment(u, @"All units are machine readable in IFC. They are either SI or their definitions
are infered from SI units. Because of that, relations between all units are well defined,
reliable and it is possible to validate them.");
                });
                lib.UnitsInContext = New <IfcUnitAssignment>(ua =>
                {
                    ua.Units.Add(mm);
                    Comment(ua, @"Units are assigned to the library project to that when units are not explicitely
defined for properties thay can be found on the project level. There are exact rules to find units for
all measure types (for example 'LENGTHUNIT' for 'IfcLengthMeasue' etc.)");
                });

                var declarations = New <IfcRelDeclares>(rel =>
                {
                    rel.RelatingContext = lib;
                }).RelatedDefinitions;
                Comment(declarations.OwningEntity, @"This relation points to all definitions declared within the scope of the library.
These can be elements, element types, properties or property templates");

                var psetTemplate = New <IfcPropertySetTemplate>(ps =>
                {
                    ps.Name             = "Essential Characteristics";
                    ps.ApplicableEntity = nameof(IfcBuildingElementPart);
                    ps.TemplateType     = Xbim.Ifc4.Interfaces.IfcPropertySetTemplateTypeEnum.PSET_TYPEDRIVENOVERRIDE;
                });
                Comment(psetTemplate, @"Template of the property set is used to group properties in logical groups.
This can contain any number of properties with the name unique within the set. 'IfcBuildingElementPart' is the best IFC
entity type fit for a brick so it is used as the applicable entity definition");

                declarations.Add(psetTemplate);

                var lengthTemplate = New <IfcComplexPropertyTemplate>(t =>
                {
                    t.Name      = "dimensions";
                    t.UsageName = "dimensions";
                    t.HasPropertyTemplates.Add(
                        New <IfcSimplePropertyTemplate>(v =>
                    {
                        v.Name               = "length";
                        v.TemplateType       = Xbim.Ifc4.Interfaces.IfcSimplePropertyTemplateTypeEnum.P_SINGLEVALUE;
                        v.PrimaryUnit        = mm;
                        v.PrimaryMeasureType = nameof(IfcLengthMeasure);
                        Comment(v, "Simple name-definition-value property template defining actual value, type of measure (length) and unit (mm)");

                        New <IfcRelAssociatesConstraint>(r =>
                        {
                            r.RelatedObjects.Add(v);
                            r.RelatingConstraint = New <IfcMetric>(m =>
                            {
                                m.Name            = "Required length";
                                m.ConstraintGrade = Xbim.Ifc4.Interfaces.IfcConstraintEnum.HARD;
                                m.Benchmark       = Xbim.Ifc4.Interfaces.IfcBenchmarkEnum.EQUALTO;
                                m.DataValue       = new IfcLengthMeasure(300);
                                Comment(m, "Metric constraint used to define required value of 300 mm");
                            });
                            Comment(r, "Relation used to set a constraint on the template property");
                        });
                    })
                        );
                });
                psetTemplate.HasPropertyTemplates.Add(lengthTemplate);
                Comment(lengthTemplate, @"Complex property template is used to describe all aspects of the property. 
Both property set template and property template have globally unique GUID which can be used for 
global management of definitions and to maintain relations to data dictionaries. ");

                var docRel = New <IfcRelAssociatesDocument>(r =>
                {
                    r.RelatedObjects.Add(lengthTemplate);
                    r.RelatingDocument = New <IfcDocumentReference>(d =>
                    {
                        d.Name           = "EN 772-1";
                        d.Location       = new IfcURIReference("https://standards.cen.eu");
                        d.Identification = "3bhhlYovD1xOzSEP5n2HRY";
                        Comment(d, "Document reference pointing to relevant document. GUID is used for unique identification.");
                    });
                });
                Comment(docRel, @"Relation associates this property template with the document reference");


                Comment(lib.OwnerHistory, @"Owner history is used to define ownership of the information.");

                txn.Commit();
            }

            SaveAs("Example_7_Dimensions", true, typeof(IfcProjectLibrary));
        }