Example #1
0
        private void SetColumnValueGrid()
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                var column = projectContext.Column.First(x => x.ID == ColumnID);
                dtgColumnValues.DataSource = column.ColumnValue.ToList();

                var col = dtgColumnValue_Columns.Columns[0] as GridViewComboBoxColumn;
                col.DataSource    = column.Table.Column.ToList();
                col.DisplayMember = "Name";
                col.ValueMember   = "ID";

                var rel = dtgColumnValue_Relationships.Columns[0] as GridViewComboBoxColumn;

                List <Relationship> listRelationships = new List <Relationship>();
                foreach (var item in column.Table.TableDrivedEntity)
                {
                    foreach (var relationship in item.Relationship)
                    {
                        listRelationships.Add(relationship);
                    }
                    foreach (var relationship in item.Relationship1)
                    {
                        listRelationships.Add(relationship);
                    }
                }
                rel.DataSource    = listRelationships;
                rel.DisplayMember = "Name";
                rel.ValueMember   = "ID";
            }
        }
Example #2
0
 public void UpdateSuperUnionToSubUnionRelationships(List <UnionToSubUnionRelationshipDTO> relationships)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         foreach (var relationship in relationships)
         {
             var dbRelationship = projectContext.UnionToSubUnionRelationshipType.First(x => x.ID == relationship.ID);
             dbRelationship.RelationshipType.IsOtherSideCreatable         = relationship.IsOtherSideCreatable;
             dbRelationship.RelationshipType.IsOtherSideDirectlyCreatable = relationship.IsOtherSideDirectlyCreatable;
             //dbRelationship.RelationshipType.IsOtherSideTransferable = relationship.IsOtherSideTransferable;
             dbRelationship.RelationshipType.Relationship.Name  = relationship.Name;
             dbRelationship.RelationshipType.Relationship.Alias = relationship.Alias;
             dbRelationship.DeterminerColumnValue = relationship.DeterminerColumnValue;
             if (relationship.DeterminerColumnID != 0)
             {
                 dbRelationship.DeterminerColumnID = relationship.DeterminerColumnID;
             }
             else
             {
                 dbRelationship.DeterminerColumnID = null;
             }
         }
         projectContext.SaveChanges();
     }
 }
 public bool EntityHasUIComposition(TableDrivedEntityDTO entity)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         return(projectContext.TableDrivedEntity.First(x => x.ID == entity.ID).EntityUIComposition.Any());
     }
 }
Example #4
0
 public bool LinkedServerExists(int firstSideServerID, int secondSideServerId)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         return(projectContext.LinkedServer.Any(x => x.SourceDBServerID == firstSideServerID && x.TargetDBServerID == secondSideServerId));
     }
 }
Example #5
0
 public void UpdateDateTimeColumnType(List <DateTimeColumnTypeDTO> columnTypes)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         foreach (var column in columnTypes)
         {
             var dbColumn = projectContext.DateTimeColumnType.First(x => x.ColumnID == column.ColumnID);
             dbColumn.ShowMiladiDateInUI = column.ShowMiladiDateInUI;
             dbColumn.ShowAMPMFormat     = column.ShowAMPMFormat;
             dbColumn.HideTimePicker     = column.HideTimePicker;
             if ((Enum_ColumnType)dbColumn.Column.OriginalTypeEnum == Enum_ColumnType.String)
             {
                 dbColumn.StringDateIsMiladi     = column.StringDateIsMiladi;
                 dbColumn.StringTimeISAMPMFormat = column.StringTimeISAMPMFormat;
                 dbColumn.StringTimeIsMiladi     = column.StringTimeIsMiladi;
             }
             else
             {
                 dbColumn.StringDateIsMiladi     = null;
                 dbColumn.StringTimeISAMPMFormat = null;
                 dbColumn.StringTimeIsMiladi     = null;
             }
         }
         projectContext.SaveChanges();
     }
 }
Example #6
0
        public void UpdateEntityOrganizationSecurityDirect(EntityOrganizationSecurityDirectDTO message)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                var dbItem = projectContext.EntityOrganizationSecurityDirect.FirstOrDefault(x => x.ID == message.ID);
                if (dbItem == null)
                {
                    dbItem = new DataAccess.EntityOrganizationSecurityDirect();
                    projectContext.EntityOrganizationSecurityDirect.Add(dbItem);
                }
                dbItem.TableDrivedEntityID = message.TableDrivedEntityID;

                dbItem.ColumnID = message.ColumnID;
                if (message.DBFunctionID != 0)
                {
                    dbItem.DatabaseFunctionID = message.DBFunctionID;
                    dbItem.Operator           = (short)message.Operator;
                }
                else
                {
                    dbItem.DatabaseFunctionID = null;
                    dbItem.Operator           = null;
                }
                projectContext.SaveChanges();
            }
        }
        //public List<CodeFunctionDTO> GetCodeFunctionsByEntityID(DR_Requester requester, int entityID)
        //{
        //    List<CodeFunctionDTO> result = new List<CodeFunctionDTO>();
        //    using (var projectContext = new DataAccess.MyProjectEntities())
        //    {
        //        IQueryable<CodeFunction> listCodeFunction;
        //        listCodeFunction = projectContext.CodeFunction.Where(x => x.CodeFunction_TableDrivedEntity.Any(y => y.TableDrivedEntityID == entityID));
        //        foreach (var item in listCodeFunction)
        //            result.Add(ToCodeFunctionDTO(item, false));

        //    }
        //    return result;
        //}

        public List <CodeFunctionDTO> GetAllCodeFunctions(DR_Requester requester, string generalFilter, List <Enum_CodeFunctionParamType> paramTypes)
        {
            List <CodeFunctionDTO> result = new List <CodeFunctionDTO>();

            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                IQueryable <CodeFunction> listCodeFunction;
                listCodeFunction = projectContext.CodeFunction;
                if (!string.IsNullOrEmpty(generalFilter))
                {
                    listCodeFunction = listCodeFunction.Where(x => x.Name.Contains(generalFilter) ||
                                                              x.ClassName.Contains(generalFilter) || x.FunctionName.Contains(generalFilter));
                }
                if (paramTypes != null && paramTypes.Any())
                {
                    List <short> list = new List <short>();
                    paramTypes.ForEach(x => list.Add((short)x));
                    listCodeFunction = listCodeFunction.Where(x => list.Contains(x.Type));
                }
                foreach (var item in listCodeFunction)
                {
                    result.Add(ToCodeFunctionDTO(item, false));
                }
            }
            return(result);
        }
Example #8
0
 private void dtgRuleOnValues_SelectionChanged(object sender, EventArgs e)
 {
     if (dtgArcGroup.SelectedRows.Count > 0)
     {
         var arcGroup = dtgArcGroup.SelectedRows.First().DataBoundItem as ArcRelationshipGroup;
         if (arcGroup.ID == 0)
         {
             btnUpdateArcRelationships.Enabled = false;
             dtgArcRelationships.Enabled       = false;
         }
         else
         {
             btnUpdateArcRelationships.Enabled = true;
             dtgArcRelationships.Enabled       = true;
         }
         using (var projectContext = new DataAccess.MyProjectEntities())
         {
             var listRel = projectContext.ArcRelationshipGroup_Relationship.Where(x => x.ArcRelationshipGroupID == arcGroup.ID);
             dtgArcRelationships.DataSource = listRel.ToList();
         }
     }
     else
     {
         btnUpdateArcRelationships.Enabled = false;
         dtgArcRelationships.Enabled       = false;
     }
 }
 public bool EntityHasAnyProcess(int targetEntityID)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         return projectContext.Process.Any(x => x.TableDrivedEntityID == targetEntityID);
     }
 }
        public bool UpdateColumnValueRange(ColumnValueRangeDTO message)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                var dbColumn = projectContext.Column.First(x => x.ID == message.ID);

                if (dbColumn.ColumnValueRange == null)
                {
                    dbColumn.ColumnValueRange = new ColumnValueRange();
                    //  projectContext.ColumnValueRange.Add(dbColumnValueRange);
                }
                //else
                //    dbColumnValueRange = projectContext.ColumnValueRange.First(x => x.ID == message.ID);
                //     dbColumnValueRange.ID = message.ID;
                //dbColumn.ColumnValueRange.ValueFromTitleOrValue = message.ValueFromTitleOrValue;
                while (dbColumn.ColumnValueRange.ColumnValueRangeDetails.Any())
                {
                    projectContext.ColumnValueRangeDetails.Remove(dbColumn.ColumnValueRange.ColumnValueRangeDetails.First());
                }
                foreach (var keyValueRange in message.Details)
                {
                    dbColumn.ColumnValueRange.ColumnValueRangeDetails.Add(new ColumnValueRangeDetails()
                    {
                        Value = keyValueRange.Value, KeyTitle = keyValueRange.KeyTitle, Tag1 = keyValueRange.Tag1, Tag2 = keyValueRange.Tag2
                    });
                }
                //dbColumnValueRange.Name = message.Name;
                projectContext.SaveChanges();
                return(true);
            }
        }
Example #11
0
 internal EntityRelationshipTailDTO ToEntityRelationshipTailDTO(int entityID, string relationshipIDTail)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         return(ToEntityRelationshipTailDTO(projectContext, relationshipIDTail, entityID, "", 0, "", null, false).Item1);
     }
 }
Example #12
0
        public int UpdateEntityRelationshipTailDataMenu(EntityRelationshipTailDataMenuDTO message)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                EntityRelationshipTailDataMenu dbItem = null;
                if (message.ID == 0)
                {
                    dbItem = new EntityRelationshipTailDataMenu();
                    projectContext.EntityRelationshipTailDataMenu.Add(dbItem);
                }
                else
                {
                    dbItem = projectContext.EntityRelationshipTailDataMenu.First(x => x.ID == message.ID);
                }

                dbItem.Name = message.Name;
                dbItem.EntityRelationshipTailID = message.EntityRelationshipTailID;
                while (dbItem.EntityRelationshipTailDataMenuItems.Any())
                {
                    projectContext.EntityRelationshipTailDataMenuItems.Remove(dbItem.EntityRelationshipTailDataMenuItems.First());
                }
                foreach (var fitem in message.Items.Where(x => x.DataMenuSettingID != 0))
                {
                    dbItem.EntityRelationshipTailDataMenuItems.Add(new EntityRelationshipTailDataMenuItems()
                    {
                        DataMenuSettingID = fitem.DataMenuSettingID,
                        Path = fitem.Path,
                        TableDrivedEntityID = fitem.TableDrivedEntityID
                    });
                }
                projectContext.SaveChanges();
                return(dbItem.ID);
            }
        }
Example #13
0
        public List <EntityCommandDTO> GetEntityCommands(DR_Requester requester, int entityID, bool withDetails)
        {
            //var cachedItem = CacheManager.GetCacheManager().GetCachedItem(CacheItemType.Command, entityID.ToString());
            //if (cachedItem != null)
            //    return (cachedItem as List<EntityCommandDTO>);

            List <EntityCommandDTO> result = new List <EntityCommandDTO>();

            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                IQueryable <EntityCommand> listEntityCommand;
                if (entityID != 0)
                {
                    listEntityCommand = projectContext.EntityCommand.Where(x => x.TableDrivedEntity_EntityCommand.Any(y => y.TableDrivedEntityID == entityID));
                }
                else
                {
                    listEntityCommand = projectContext.EntityCommand;
                }
                foreach (var item in listEntityCommand)
                {
                    if (DataIsAccessable(requester, item))
                    {
                        result.Add(ToEntityCommandDTO(requester, item, withDetails));
                    }
                }
            }
            //CacheManager.GetCacheManager().AddCacheItem(result, CacheItemType.Command, entityID.ToString());
            return(result);
        }
Example #14
0
        private void dtgColumnValues_SelectionChanged(object sender, EventArgs e)
        {
            if (dtgColumnValues.SelectedRows.Count > 0)
            {
                var ColumnValue = dtgColumnValues.SelectedRows.First().DataBoundItem as ColumnValue;
                if (ColumnValue.ID == 0)
                {
                    pageRuleOnColumns.Enabled       = false;
                    pageRuleOnRelationships.Enabled = false;
                }
                else
                {
                    pageRuleOnColumns.Enabled       = true;
                    pageRuleOnRelationships.Enabled = true;
                }
                using (var projectContext = new DataAccess.MyProjectEntities())
                {
                    var listCol = projectContext.ColumnValue_Column.Where(x => x.ColumnValueID == ColumnValue.ID);
                    dtgColumnValue_Columns.DataSource = listCol.ToList();

                    var listRel = projectContext.ColumnValue_Relationship.Where(x => x.ColumnValueID == ColumnValue.ID);
                    dtgColumnValue_Relationships.DataSource = listRel.ToList();
                }
            }
            else
            {
                pageRuleOnColumns.Enabled       = false;
                pageRuleOnRelationships.Enabled = false;
            }
        }
Example #15
0
 public void MergeISARelationships(string name, List <ISARelationshipDTO> relationships, ISARelationshipDTO selectedOne)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         int isaRelationID = 0;
         foreach (var relationship in relationships)
         {
             //if (relationship == selectedOne)
             //    isaRelationID = relationship.ID;
             //else
             //{
             var dbRelationship = projectContext.ISARelationship.First(x => x.ID == relationship.ID);
             foreach (var detail in dbRelationship.SuperToSubRelationshipType)
             {
                 detail.ISARelationshipID = selectedOne.ID;
             }
             foreach (var detail in dbRelationship.SubToSuperRelationshipType)
             {
                 detail.ISARelationshipID = selectedOne.ID;
             }
             //}
         }
         projectContext.SaveChanges();
     }
 }
Example #16
0
        //private string GetSchemaObjectName(string dbName, string schemaName)
        //{
        //    return dbName + ">" + schemaName;
        //}

        public ObjectDTO GetParentObject(DatabaseObjectCategory objectCategory, int objectIdentity)
        {
            if (objectCategory == DatabaseObjectCategory.Database)
            {
                return(null);
            }
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                ObjectDTO result = null;
                if (objectCategory == DatabaseObjectCategory.Schema)
                {
                    //var dbName = objectIdentity.Split('>')[0];
                    var schema = projectContext.DBSchema.First(x => x.ID == objectIdentity);
                    result = ToObjectDTO(DatabaseObjectCategory.Database, schema.DatabaseInformationID, schema.DatabaseInformation.Name, "", 0);
                }
                else if (objectCategory == DatabaseObjectCategory.Entity)
                {
                    //int id = Convert.ToInt32(objectIdentity);
                    var entity = projectContext.TableDrivedEntity.First(x => x.ID == objectIdentity);
                    result = ToObjectDTO(DatabaseObjectCategory.Schema, entity.Table.DBSchemaID, entity.Table.DBSchema.Name, "", 0);
                }
                else if (objectCategory == DatabaseObjectCategory.Column)
                {
                    //var column = projectContext.TableDrivedEntity.First(x => x.ID == objectIdentity);
                    //result = ToObjectDTO("Schema", GetSchemaObjectName(entity.Table.Catalog, entity.Table.RelatedSchema), entity.Table.RelatedSchema);
                }
                return(result);
            }
        }
Example #17
0
        public int Save(ISARelationshipDTO item)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                ISARelationship dbItem = null;
                if (item.ID == 0)
                {
                    dbItem = new ISARelationship();
                    projectContext.ISARelationship.Add(dbItem);
                }
                else
                {
                    dbItem = projectContext.ISARelationship.First(x => x.ID == item.ID);
                }

                dbItem.Name          = item.Name;
                dbItem.IsDisjoint    = item.IsDisjoint;
                dbItem.InternalTable = item.InternalTable == true;
                //dbItem.InternalTableColumnID = item.InternalTableColumnID == 0 ? (int?)null : item.InternalTableColumnID;
                dbItem.IsGeneralization     = item.IsGeneralization;
                dbItem.IsSpecialization     = !item.IsSpecialization;
                dbItem.IsTolatParticipation = item.IsTolatParticipation;
                projectContext.SaveChanges();
                return(dbItem.ID);
            }
        }
 public bool HasEntityNotInNavigationTree(int databaseID)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         return(projectContext.TableDrivedEntity.Any(x => x.IsOrginal == true && x.IsView == false && x.IsDisabled == false && x.Table.DBSchema.DatabaseInformationID == databaseID && x.IndependentDataEntry == true && !projectContext.NavigationTree.Any(y => y.Category == "Entity" && y.ItemIdentity == x.ID)));
     }
 }
Example #19
0
        public void UpdateEntityExternalReports(DR_Requester requester, EntityExternalReportDTO message)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                BizEntityReport bizEntityReport = new MyModelManager.BizEntityReport();

                var dbEntitySpecifiedReport = projectContext.EntityExternalReport.FirstOrDefault(x => x.ID == message.ID);
                if (dbEntitySpecifiedReport == null)
                {
                    message.ReportType           = ReportType.SearchableReport;
                    message.SearchableReportType = SearchableReportType.ExternalReport;
                    dbEntitySpecifiedReport      = new EntityExternalReport();
                    dbEntitySpecifiedReport.EntitySearchableReport = bizEntitySearchableReport.ToNewEntitySearchableReport(message);
                }
                else
                {
                    bizEntitySearchableReport.ToUpdateEntitySearchableReport(dbEntitySpecifiedReport.EntitySearchableReport, message);
                }

                dbEntitySpecifiedReport.URL = message.URL;
                if (dbEntitySpecifiedReport.ID == 0)
                {
                    projectContext.EntityExternalReport.Add(dbEntitySpecifiedReport);
                }

                var entity = new BizTableDrivedEntity().GetSimpleEntityWithColumns(requester, message.TableDrivedEntityID);
                CreateReportTable(entity);
                //ساختن جدول معادل

                projectContext.SaveChanges();
            }
        }
 public void UpdateEntityActionActivities(int entityId, List <EntityActionActivityDTO> entityActionActivities)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         var dbEntityActionActivities = projectContext.ActionActivity_TableDrivedEntity.Where(x => x.TableDrivedEntityID == entityId);
         var sentIds    = entityActionActivities.Select(y => y.ID).ToList();
         var removeList = dbEntityActionActivities.Where(x => !sentIds.Contains(x.ID)).ToList();
         foreach (var item in removeList)
         {
             projectContext.ActionActivity_TableDrivedEntity.Remove(item);
         }
         foreach (var entityActionActivity in entityActionActivities)
         {
             var dbEntityActionActivity = projectContext.ActionActivity_TableDrivedEntity.FirstOrDefault(x => x.ID == entityActionActivity.ID);
             if (dbEntityActionActivity == null)
             {
                 dbEntityActionActivity = new DataAccess.ActionActivity_TableDrivedEntity();
             }
             dbEntityActionActivity.StepType            = (short)entityActionActivity.Step;
             dbEntityActionActivity.ActionActivityID    = entityActionActivity.ActionActivityID;
             dbEntityActionActivity.TableDrivedEntityID = entityId;
             dbEntityActionActivity.ID = entityActionActivity.ID;
             dbEntityActionActivity.ResultSensetive = entityActionActivity.ResultSensetive;
             if (dbEntityActionActivity.ID == 0)
             {
                 projectContext.ActionActivity_TableDrivedEntity.Add(dbEntityActionActivity);
             }
         }
         projectContext.SaveChanges();
     }
 }
 //public bool AddCodeFunctionToEntity(int codefuntionID, int entityID, bool showInFormula)
 //{
 //    using (var projectContext = new DataAccess.MyProjectEntities())
 //    {
 //        var dbCodeFunctionEntity = projectContext.CodeFunction_TableDrivedEntity.FirstOrDefault(x => x.TableDrivedEntityID == entityID && x.CodeFunctionID == codefuntionID);
 //        if (dbCodeFunctionEntity == null)
 //        {
 //            projectContext.CodeFunction_TableDrivedEntity.Add(new CodeFunction_TableDrivedEntity() { CodeFunctionID = codefuntionID, TableDrivedEntityID = entityID, ShowInFormula = showInFormula });
 //        }
 //        else
 //        {
 //            dbCodeFunctionEntity.ShowInFormula = showInFormula;
 //        }
 //        projectContext.SaveChanges();
 //    }
 //    return true;
 //}
 public int UpdateCodeFunctionEntity(CodeFunction_EntityDTO CodeFunctionEntity)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         var dbCodeFunctionEntity = projectContext.CodeFunction_TableDrivedEntity.FirstOrDefault(x => x.ID == CodeFunctionEntity.ID);
         if (dbCodeFunctionEntity == null)
         {
             dbCodeFunctionEntity = new CodeFunction_TableDrivedEntity();
         }
         dbCodeFunctionEntity.CodeFunctionID      = CodeFunctionEntity.CodeFunctionID;
         dbCodeFunctionEntity.TableDrivedEntityID = CodeFunctionEntity.EntityID;
         dbCodeFunctionEntity.Title = CodeFunctionEntity.Title;
         dbCodeFunctionEntity.Name  = CodeFunctionEntity.Name;
         while (dbCodeFunctionEntity.CodeFunction_TableDrivedEntity_Parameters.Any())
         {
             projectContext.CodeFunction_TableDrivedEntity_Parameters.Remove(dbCodeFunctionEntity.CodeFunction_TableDrivedEntity_Parameters.First());
         }
         //if (!CodeFunctionEntity.CodeFunctionEntityColumns.Any(x => x.ColumnID == 0))
         //{
         foreach (var column in CodeFunctionEntity.CodeFunctionEntityColumns)
         {
             CodeFunction_TableDrivedEntity_Parameters dbColumn = new DataAccess.CodeFunction_TableDrivedEntity_Parameters();
             dbColumn.ColumnID = column.ColumnID;
             dbColumn.CodeFunctionParameterID = column.CodeFunctionParameterID;
             dbCodeFunctionEntity.CodeFunction_TableDrivedEntity_Parameters.Add(dbColumn);
         }
         //}
         if (dbCodeFunctionEntity.ID == 0)
         {
             projectContext.CodeFunction_TableDrivedEntity.Add(dbCodeFunctionEntity);
         }
         projectContext.SaveChanges();
         return(dbCodeFunctionEntity.ID);
     }
 }
 public bool OrginalEntityExists(string functionName, int databaseID)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         return(projectContext.DatabaseFunction.Any(x => x.FunctionName == functionName && x.DBSchema.DatabaseInformationID == databaseID));
     }
 }
Example #23
0
 public int SaveDatabase(DatabaseDTO message)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         var dbDatabase = projectContext.DatabaseInformation.FirstOrDefault(x => x.ID == message.ID);
         if (dbDatabase == null)
         {
             dbDatabase = new DatabaseInformation();
             dbDatabase.SecurityObject      = new SecurityObject();
             dbDatabase.SecurityObject.Type = (int)DatabaseObjectCategory.Database;
         }
         dbDatabase.DBServerID       = message.DBServerID;
         dbDatabase.Name             = message.Name;
         dbDatabase.Title            = message.Title;
         dbDatabase.DBHasDate        = message.DBHasData;
         dbDatabase.ConnectionString = message.ConnectionString;
         dbDatabase.DBType           = message.DBType.ToString();
         if (dbDatabase.ID == 0)
         {
             projectContext.DatabaseInformation.Add(dbDatabase);
         }
         projectContext.SaveChanges();
         return(dbDatabase.ID);
     }
 }
 public DatabaseFunctionDTO GetOrginalDatabaseFunction(string name, int databaseID)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         return(ToDatabaseFunctionDTO(projectContext.DatabaseFunction.First(x => x.FunctionName == name && x.DBSchema.DatabaseInformationID == databaseID), true));
     }
 }
Example #25
0
 public void UpdateTimeColumnType(List <TimeColumnTypeDTO> columnTypes)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         foreach (var column in columnTypes)
         {
             var dbColumn = projectContext.TimeColumnType.First(x => x.ColumnID == column.ColumnID);
             //if (!column.StringValueIsMiladi)
             //{
             //    if ((Enum_ColumnType)dbColumn.Column.OriginalTypeEnum == Enum_ColumnType.Time)
             //    {
             //        throw new Exception("ستون از نوع زمان می باشد و گزینه مقدار شمسی به اشتباه انتخاب شده است");
             //    }
             //}
             dbColumn.ShowMiladiTime = column.ShowMiladiTime;
             dbColumn.ShowAMPMFormat = column.ShowAMPMFormat;
             if ((Enum_ColumnType)dbColumn.Column.OriginalTypeEnum == Enum_ColumnType.String)
             {
                 dbColumn.StringTimeIsMiladi     = column.StringTimeIsMiladi;
                 dbColumn.StringTimeISAMPMFormat = column.StringTimeISAMPMFormat;
             }
             else
             {
                 dbColumn.StringTimeIsMiladi     = null;
                 dbColumn.StringTimeISAMPMFormat = null;
             }
         }
         projectContext.SaveChanges();
     }
 }
        public List <DatabaseFunctionDTO> GetAllDatabaseFunctions(DR_Requester dR_Requester, string generalFilter, Enum_DatabaseFunctionType type)
        {
            List <DatabaseFunctionDTO> result = new List <DatabaseFunctionDTO>();

            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                IQueryable <DatabaseFunction> listDatabaseFunction;
                listDatabaseFunction = projectContext.DatabaseFunction;
                if (!string.IsNullOrEmpty(generalFilter))
                {
                    listDatabaseFunction = listDatabaseFunction.Where(x => x.FunctionName.Contains(generalFilter));
                }

                if (type == Enum_DatabaseFunctionType.Function)
                {
                    listDatabaseFunction = listDatabaseFunction.Where(x => x.Type == (short)Enum_DatabaseFunctionType.Function);
                }
                else if (type == Enum_DatabaseFunctionType.StoredProcedure)
                {
                    listDatabaseFunction = listDatabaseFunction.Where(x => x.Type == (short)Enum_DatabaseFunctionType.StoredProcedure);
                }
                foreach (var item in listDatabaseFunction)
                {
                    result.Add(ToDatabaseFunctionDTO(item, false));
                }
            }
            return(result);
        }
Example #27
0
 public void MergeUnionRelationships(string name, List <UnionRelationshipDTO> relationships, UnionRelationshipDTO selectedOne)
 {
     using (var projectContext = new DataAccess.MyProjectEntities())
     {
         //   int UnionRelationID = 0;
         foreach (var relationship in relationships)
         {
             //if (relationship == selectedOne)
             //    UnionRelationID = relationship.ID;
             //else
             //{
             var dbRelationship = projectContext.UnionRelationshipType.First(x => x.ID == relationship.ID);
             foreach (var detail in dbRelationship.UnionToSubUnionRelationshipType)
             {
                 detail.UnionRelationshipTypeID = selectedOne.ID;
             }
             foreach (var detail in dbRelationship.SubUnionToUnionRelationshipType)
             {
                 detail.UnionRelationshipTypeID = selectedOne.ID;
             }
             //}
         }
         projectContext.SaveChanges();
     }
 }
        public List <DatabaseFunctionDTO> GetDatabaseFunctions(DR_Requester requester, Enum_DatabaseFunctionType type, int databaseID = 0)
        {
            List <DatabaseFunctionDTO> result = new List <DatabaseFunctionDTO>();

            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                //projectContext.Configuration.LazyLoadingEnabled = false;
                IQueryable <DatabaseFunction> listDatabaseFunction;

                if (databaseID == 0)
                {
                    listDatabaseFunction = projectContext.DatabaseFunction;
                }
                else
                {
                    listDatabaseFunction = projectContext.DatabaseFunction.Where(x => x.DBSchema.DatabaseInformationID == databaseID);
                } if (type == Enum_DatabaseFunctionType.Function)
                {
                    listDatabaseFunction = listDatabaseFunction.Where(x => x.Type == (short)Enum_DatabaseFunctionType.Function);
                }
                else if (type == Enum_DatabaseFunctionType.StoredProcedure)
                {
                    listDatabaseFunction = listDatabaseFunction.Where(x => x.Type == (short)Enum_DatabaseFunctionType.StoredProcedure);
                }
                foreach (var item in listDatabaseFunction)
                {
                    result.Add(ToDatabaseFunctionDTO(item, false));
                }
            }
            return(result);
        }
        public void Save(int entityID, List <EntityUICompositionDTO> items)
        {
            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                SaveItem(projectContext, entityID, items);

                try
                {
                    projectContext.SaveChanges();
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException e)
                {
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                          eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                              ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    throw;
                }
            }
        }
Example #30
0
        public bool UpdateArchiveFolder(ArchiveFolderDTO message)
        {
            List <ArchiveFolderDTO> result = new List <ArchiveFolderDTO>();

            using (var projectContext = new DataAccess.MyProjectEntities())
            {
                ArchiveFolder dbitem = null;
                if (message.ID != 0)
                {
                    dbitem = projectContext.ArchiveFolder.First(x => x.ID == message.ID);
                }
                else
                {
                    dbitem = new ArchiveFolder();
                }
                dbitem.Name = message.Name;
                dbitem.TableDrivedEntityID = (message.EntityID == 0 ? (int?)null : message.EntityID);
                if (dbitem.ID == 0)
                {
                    projectContext.ArchiveFolder.Add(dbitem);
                }
                projectContext.SaveChanges();
            }
            return(true);
        }