コード例 #1
0
        //public DP_SearchRepository ToSearchRepository(SearchRepository entityPreDefinedSearch, bool withDetails)
        //{
        //    //فانکشن به یه کلاس مستقل دیگر منتقل شود
        //    DP_SearchRepository result = new DP_SearchRepository();
        //    result.TargetEntityID = entityPreDefinedSearch.TableDrivedEntityID??0;
        //    result.Title = entityPreDefinedSearch.Title;
        //    result.EntitySearchID = entityPreDefinedSearch.EntitySearchID ?? 0;
        //    //result.IsSimpleSearch = entityPreDefinedSearch.IsSimpleSearch;
        //    result.ID = entityPreDefinedSearch.ID;
        //    if (withDetails)
        //    {
        //        if (entityPreDefinedSearch.SearchRepository != null)
        //            result.SearchRepository = ToSearchRepositoryDTO(entityPreDefinedSearch.SearchRepository, entityPreDefinedSearch.TableDrivedEntityID, entityPreDefinedSearch.TableDrivedEntity.Name);
        //        //foreach (var item in entityPreDefinedSearch.PreDefinedSearchSimpleSearchColumns)
        //        //{
        //        //    PreDefinedSearchColumns newCol = new PreDefinedSearchColumns();
        //        //    newCol.ColumnID = item.ColumnID ?? 0;
        //        //    newCol.EntitySearchColumnsID = item.EntitySearchColumnsID ?? 0;
        //        //    newCol.Value = item.Value;
        //        //    newCol.Operator = (CommonOperator)Enum.Parse(typeof(CommonOperator), item.Operator);
        //        //    result.SimpleColumns.Add(newCol);
        //        //}
        //    }
        //    return result;
        //}

        private ProxyLibrary.LogicPhraseDTO ToLogicPhraseDTO(DataAccess.LogicPhrase logicPhrase)
        {
            ProxyLibrary.LogicPhraseDTO result = null;
            if (logicPhrase.SearchRepository != null)
            {
                result = ToSearchRepositoryDTO(logicPhrase.SearchRepository);
            }
            else
            {
                result = new ProxyLibrary.LogicPhraseDTO();
                SetLogicPhraseDTO(logicPhrase, result);
            }

            return(result);
        }
コード例 #2
0
        private void SetLogicPhraseDTO(DataAccess.LogicPhrase logicPhrase, ProxyLibrary.LogicPhraseDTO logicPhraseDTO)
        {
            logicPhraseDTO.AndOrType = (AndOREqualType)logicPhrase.AndOrType;

            foreach (var dbPhrase in logicPhrase.Phrase1)
            {
                if (dbPhrase.ColumnPhrase != null)
                {
                    logicPhraseDTO.Phrases.Add(ToColumnPhraseDTO(dbPhrase.ColumnPhrase));
                }
                //else if (dbPhrase.SearchRepository != null)
                //    logicPhraseDTO.Phrases.Add(ToSearchRepositoryDTO(dbPhrase.SearchRepository));
                else if (dbPhrase.LogicPhrase != null)
                {
                    logicPhraseDTO.Phrases.Add(ToLogicPhraseDTO(dbPhrase.LogicPhrase));
                }
            }
        }
コード例 #3
0
        //private DataAccess.Phrase ToSearchRepositoryAsPhrase(DP_SearchRepository dP_SearchRepository)
        //{
        //    DataAccess.Phrase dbphrase = new DataAccess.Phrase();
        //    dbphrase.SearchRepository = ToSearchRepository(dP_SearchRepository);
        //    return dbphrase;
        //}
        //private DataAccess.LogicPhrase ToLogicPhrase(ProxyLibrary.LogicPhrase logicPhrase)
        //{
        //    DataAccess.LogicPhrase dbphrase = new DataAccess.LogicPhrase();
        //    dbphrase.Phrase.Add(new DataAccess.Phrase());
        //    dbphrase.LogicPhrase = ToLogicPhrase(logicPhrase);
        //    return dbphrase;
        //}
        private Tuple <DataAccess.LogicPhrase, DataAccess.Phrase> ToLogicPhrase(MyProjectEntities projectContext, ProxyLibrary.LogicPhraseDTO logicPhrase)
        {
            //if (logicPhrase.Phrases.Any())
            //{
            DataAccess.Phrase phrase = new DataAccess.Phrase();
            phrase.Type = 2;
            projectContext.Phrase.Add(phrase);
            phrase.LogicPhrase = new DataAccess.LogicPhrase();
            var dbLogicPhrase = phrase.LogicPhrase;

            SetLogicPhrase(projectContext, dbLogicPhrase, logicPhrase);
            return(new Tuple <DataAccess.LogicPhrase, DataAccess.Phrase>(dbLogicPhrase, phrase));
            //}
            //else
            //    return null;
        }
コード例 #4
0
 private void SetLogicPhrase(MyProjectEntities projectContext, DataAccess.LogicPhrase dbLogicPhrase, ProxyLibrary.LogicPhraseDTO logicPhrase)
 {
     dbLogicPhrase.AndOrType = (short)logicPhrase.AndOrType;
     foreach (var phrase in logicPhrase.Phrases)
     {
         DataAccess.Phrase dbPhrase = null;
         if (phrase is SearchProperty)
         {
             dbPhrase = ToColumnPhrase(projectContext, phrase as SearchProperty).Item2;
         }
         else if (phrase is DP_SearchRepository)
         {
             dbPhrase = CreateSearchRepository(projectContext, phrase as DP_SearchRepository);
         }
         else if (phrase is ProxyLibrary.LogicPhraseDTO)
         {
             dbPhrase = ToLogicPhrase(projectContext, phrase as ProxyLibrary.LogicPhraseDTO).Item2;
         }
         dbPhrase.LogicPhrase1 = dbLogicPhrase;
     }
 }