public IActionResult Add(CategoryEntity entity) { int errorCode = 0; try { if (CacheHelper.GetCategoryList(entity.PartitionKey).Count(cat => cat.NameHash.Equals(entity.NameHash)) > 0) { errorCode = Constants.ERROR_CODE_ENTITY_ALREADY_EXISTS; } else { string nextSortNumber = SequenceHelper.GetNextSequence(Constants.SORT, Constants.TABLE_CATEGORY + "_" + entity.PartitionKey, Constants.PADDING_SORT); string nextID = SequenceHelper.GetNextSequence(Constants.ID, Constants.TABLE_CATEGORY, Constants.PADDING_CATEGORYID); entity.RowKey = nextSortNumber + "_" + nextID; TableStorageHelper.InsertOrMergeAsync(Constants.TABLE_CATEGORY, entity).Wait(); CacheHelper.ClearCategoryListCache(); } } catch (Exception ex) { if (!TableStorageHelper.IsStorageException(ex, out errorCode)) { errorCode = Constants.ERROR_CODE_COMMON; } } return(RedirectToAction("Index", new { category = entity.PartitionKey, errorCode = errorCode })); }
private TranslatedQuery PrepareSubqueryParameters(SubQueryExpression subQueryExpression, out Parameter <Tuple> parameterOfTuple, out Type elementType, out ProjectionExpression projection) { // 1. Rewrite recordset and ItemProjector to parameter<tuple> var subqueryTupleParameter = context.GetTupleParameter(subQueryExpression.OuterParameter); var newDataSource = ApplyParameterToTupleParameterRewriter.Rewrite( subQueryExpression.ProjectionExpression.ItemProjector.DataSource, subqueryTupleParameter, subQueryExpression.ApplyParameter); var newItemProjectorBody = ApplyParameterToTupleParameterRewriter.Rewrite( subQueryExpression.ProjectionExpression.ItemProjector.Item, subqueryTupleParameter, subQueryExpression.ApplyParameter); var itemProjector = new ItemProjectorExpression(newItemProjectorBody, newDataSource, subQueryExpression.ProjectionExpression.ItemProjector.Context); parameterOfTuple = context.GetTupleParameter(subQueryExpression.OuterParameter); // 2. Add only parameter<tuple>. Tuple value will be assigned // at the moment of materialization in SubQuery constructor projection = new ProjectionExpression( subQueryExpression.ProjectionExpression.Type, itemProjector, subQueryExpression.ProjectionExpression.TupleParameterBindings, subQueryExpression.ProjectionExpression.ResultType); // 3. Make translation elementType = subQueryExpression.ProjectionExpression.ItemProjector.Item.Type; var resultType = SequenceHelper.GetSequenceType(elementType); var translateMethod = Translator.TranslateMethod.MakeGenericMethod(new[] { resultType }); return((TranslatedQuery)translateMethod.Invoke(context.Translator, new object[] { projection, tupleParameters.AddOne(parameterOfTuple) })); }
public int Cadastrar(StatusPedido entity) { try { const string query = @"INSERT INTO StatusPedido (Nome, Ordem) VALUES (:Nome, :Ordem)"; var parametros = new { entity.Nome, entity.Ordem }; string sequenceName = null; if (DataBaseType == DataBaseType.Oracle) { sequenceName = SequenceHelper.GetSequenceName <StatusPedido>(entity); } return(Convert.ToInt32(IDbConn.CommandInsert(query, DataBaseType, parametros, sequenceName: sequenceName))); } catch (Exception ex) { throw ex; } }
public void Test_GetIndexFromPath() { string path = SequenceHelper.AppendListEntryToSequence("gameObject.transform.children.", 2) + ".Name"; int index = SequenceHelper.GetArrayIndex(path); Assert.AreEqual(2, index); }
private string InsertTag(string newTag, string currentTag) { currentTag = currentTag?.Trim() ?? ""; bool newTagAdded = false; int nextID = -1; bool nextIDUsed = true; if (!string.IsNullOrEmpty(newTag?.Trim()) && newTag.Trim() != "|") { string[] nt = newTag.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); foreach (string text in nt) { if (!string.IsNullOrEmpty(text?.Trim())) { TagEntity tag = CacheHelper.GetTagList().FirstOrDefault(te => te.RowKey.Trim().ToLower() == text.Trim().ToLower()); if (tag == null) { if (nextIDUsed) { nextID = int.Parse(SequenceHelper.GetNextSequence("ID", Constants.TABLE_TAG, null)); } tag = new POCO.TagEntity("Tag", text.Trim()) { ID = nextID }; try { TableStorageHelper.InsertAsync(Constants.TABLE_TAG, tag).Wait(); nextIDUsed = true; newTagAdded = true; } catch (Exception ex) { nextIDUsed = false; CacheHelper.ClearTagListCache(); tag = CacheHelper.GetTagList().FirstOrDefault(te => te.RowKey.Trim().ToLower() == text.Trim().ToLower()); } } if (tag != null) { currentTag = currentTag + (currentTag.Trim().Length == 0 ? "|" : "") + tag.ID + "|"; } } } if (newTagAdded) { CacheHelper.ClearTagListCache(); } } return(currentTag); }
public static void GetSequencetwo() { Thread.Sleep(100); int i = SequenceHelper.GetSequenceValueByName("S_T_UM_EVT_REPLY"); Console.WriteLine("线程Id:" + Task.CurrentId + "序列值:" + i); }
private static ExitCodes ProgramExecution() { using (var writer = GZipUtilities.GetStreamWriter(_outputFileName)) { string cachePath = CacheConstants.TranscriptPath(_inputPrefix); var sequenceData = SequenceHelper.GetDictionaries(_referencePath); // load the cache Console.Write("- reading {0}... ", Path.GetFileName(cachePath)); var cache = TranscriptCacheHelper.GetCache(cachePath, sequenceData.refIndexToChromosome); Console.WriteLine("found {0:N0} reference sequences. ", cache.RegulatoryRegionIntervalArrays.Length); Console.Write("- writing GFF entries... "); foreach (var intervalArray in cache.RegulatoryRegionIntervalArrays) { if (intervalArray == null) { continue; } foreach (var interval in intervalArray.Array) { WriteRegulatoryFeature(writer, interval.Value); } } Console.WriteLine("finished."); } return(ExitCodes.Success); }
/// <summary> /// Creates a new instance of a Member Aspect /// </summary> /// <param name="reflectedObject"></param> /// <param name="aspectPath"></param> public MemberAspect(ReflectedObject reflectedObject, FieldInfo field) { reflectedObject.AddAspect(this); m_reflectedObject = reflectedObject; m_FieldInfo = field; m_MemberName = SequenceHelper.GetDisplayNameFromPath(field.Name); }
public IActionResult Add(TechnologyEntity technology, string StatusRemarks, bool isSubcategoryInQuery) { int errorCode = 0; string nextID = ""; try { nextID = SequenceHelper.GetNextSequence(Constants.ID, Constants.TABLE_TECHNOLOGY, Constants.PADDING_TECHNOLOGYID); technology.RowKey = technology.RowKey + "_" + nextID; technology.Description = technology.Description ?? ""; technology.Tag = InsertTag(technology.NewTag, technology.Tag); DuplicateCheckEntity duplicateCheck = new DuplicateCheckEntity(technology.PartitionKey, technology.SubcategoryID + "_" + technology.NameHash); TechnologyStatusEntity technologyStatus = GetTechnologyStatusEntity(technology.PartitionKey, nextID, technology.Status, StatusRemarks); TableStorageHelper.InsertBatchAsync(Constants.TABLE_TECHNOLOGY, duplicateCheck, technology, technologyStatus).Wait(); } catch (Exception ex) { nextID = ""; if (!TableStorageHelper.IsStorageException(ex, out errorCode)) { errorCode = Constants.ERROR_CODE_COMMON; } } return(RedirectToAction("Index", new { errorCode = errorCode, category = technology.PartitionKey, subcategory = ((isSubcategoryInQuery) ? technology.SubcategoryID : ""), technology = nextID })); }
public int Cadastrar(Produto entity) { try { const string query = @"INSERT INTO Produtos (Nome, PrecoVenda) VALUES (:Nome, :PrecoVenda)"; var parametros = new { entity.Nome, entity.PrecoVenda }; string sequenceName = null; if (DataBaseType == DataBaseType.Oracle) { sequenceName = SequenceHelper.GetSequenceName <Produto>(entity); } return(Convert.ToInt32(IDbConn.CommandInsert(query, DataBaseType, parametros, sequenceName: sequenceName))); } catch (Exception ex) { throw ex; } }
public void SequenceTest5() { int[] data = { 5 }; bool result = SequenceHelper.VerifySquenceOfBST(data, data.Length); Assert.AreEqual(result, true); }
public int Cadastrar(Candidato entity) { try { const string query = @"INSERT INTO Candidato (Nome, Curriculo, Status) VALUES (:Nome, :Curriculo, :Status)"; var parametros = new { entity.Nome, entity.Curriculo, entity.Status }; string sequenceName = null; if (DataBaseType == DataBaseType.Oracle) { sequenceName = SequenceHelper.GetSequenceName <Candidato>(entity); } return(Convert.ToInt32(IDbConn.CommandInsert(query, DataBaseType, parametros, sequenceName: sequenceName))); } catch (Exception ex) { throw ex; } }
public int Cadastrar(CandidatoVaga entity) { try { const string query = @"INSERT INTO CandidatoVaga (IdCandidato, IdVaga) VALUES (:IdCandidato, :IdVaga)"; var parametros = new { entity.IdCandidato, entity.IdVaga }; string sequenceName = null; if (DataBaseType == DataBaseType.Oracle) { sequenceName = SequenceHelper.GetSequenceName <CandidatoVaga>(entity); } return(Convert.ToInt32(IDbConn.CommandInsert(query, DataBaseType, parametros, sequenceName: sequenceName))); } catch (Exception ex) { throw ex; } }
/// <inheritdoc/> protected override Expression VisitNewArray(NewArrayExpression na) { Write("new "); Write(GetTypeName(SequenceHelper.GetElementType(na.Type))); WriteArguments("[] {", na.Expressions, "}"); return(na); }
public void SequenceTest6() { int[] data = { 7, 4, 6, 5 }; bool result = SequenceHelper.VerifySquenceOfBST(data, data.Length); Assert.AreEqual(result, false); }
public int Cadastrar(HistoricoStatus entity) { try { const string query = @"INSERT INTO HistoricoStatus (IdPedido, IdStatus, DataStatus) VALUES (:IdPedido, :IdStatus, :DataStatus)"; var parametros = new { entity.IdPedido, entity.IdStatus, entity.DataStatus }; string sequenceName = null; if (DataBaseType == DataBaseType.Oracle) { sequenceName = SequenceHelper.GetSequenceName <HistoricoStatus>(entity); } return(Convert.ToInt32(IDbConn.CommandInsert(query, DataBaseType, parametros, sequenceName: sequenceName))); } catch (Exception ex) { throw ex; } }
public void SequenceTest7() { int[] data = { 4, 6, 12, 8, 16, 14, 10 }; bool result = SequenceHelper.VerifySquenceOfBST(data, data.Length); Assert.AreEqual(result, false); }
public virtual void RemoveExc() { Statement exc = stats[2]; SequenceHelper.DestroyStatementContent(exc, true); stats.RemoveWithKey(exc.id); }
public int Cadastrar(Usuario entity) { try { const string query = @"INSERT INTO Usuarios (Nome, CPF, Email, Telefone, Sexo, DataNascimento) VALUES (:Nome, :CPF, :Email, :Telefone, :Sexo, :DataNascimento)"; var parametros = new { entity.Nome, entity.CPF, entity.Email, entity.Telefone, entity.Sexo, entity.DataNascimento }; string sequenceName = null; if (DataBaseType == DataBaseType.Oracle) { sequenceName = SequenceHelper.GetSequenceName <Usuario>(entity); } return(Convert.ToInt32(IDbConn.CommandInsert(query, DataBaseType, parametros, sequenceName: sequenceName))); } catch (Exception ex) { throw ex; } }
public int Cadastrar(VagaTecnologia entity) { try { const string query = @"INSERT INTO VagaTecnologia (IdVaga, IdTecnologia, IdEmpresa, Peso) VALUES (:IdVaga, :IdTecnologia, :IdEmpresa, :Peso)"; var parametros = new { entity.IdVaga, entity.IdTecnologia, entity.IdEmpresa, entity.Peso }; string sequenceName = null; if (DataBaseType == DataBaseType.Oracle) { sequenceName = SequenceHelper.GetSequenceName <VagaTecnologia>(entity); } return(Convert.ToInt32(IDbConn.CommandInsert(query, DataBaseType, parametros, sequenceName: sequenceName))); } catch (Exception ex) { throw ex; } }
public int Cadastrar(Pedido entity) { try { const string query = @"INSERT INTO Pedido (IdStatus, ValorPedido, ValorPedido) VALUES (:PrecoVenda, :ValorPedido, :ValorPedido)"; var parametros = new { entity.IdStatus, entity.ValorPedido, entity.DataPrevisaoEntrega }; string sequenceName = null; if (DataBaseType == DataBaseType.Oracle) { sequenceName = SequenceHelper.GetSequenceName <Pedido>(entity); } return(Convert.ToInt32(IDbConn.CommandInsert(query, DataBaseType, parametros, sequenceName: sequenceName))); } catch (Exception ex) { throw ex; } }
public static (Dictionary <string, string> EntrezGeneIdToSymbol, Dictionary <string, string> EnsemblIdToSymbol) ParseUniversalGeneArchive(string inputReferencePath, string universalGeneArchivePath) { IDictionary <string, IChromosome> refNameToChromosome; if (inputReferencePath == null) { refNameToChromosome = null; } else { (_, refNameToChromosome, _) = SequenceHelper.GetDictionaries(inputReferencePath); } UgaGene[] genes; using (var reader = new UgaGeneReader(GZipUtilities.GetAppropriateReadStream(universalGeneArchivePath), refNameToChromosome)) { genes = reader.GetGenes(); } var entrezGeneIdToSymbol = genes.GetGeneIdToSymbol(x => x.EntrezGeneId); var ensemblIdToSymbol = genes.GetGeneIdToSymbol(x => x.EnsemblId); return(entrezGeneIdToSymbol, ensemblIdToSymbol); }
private static ExitCodes ProgramExecution() { var sequenceData = SequenceHelper.GetDictionaries(_refSequencePath); var logger = new ConsoleLogger(); var caches = LoadTranscriptCaches(logger, CacheConstants.TranscriptPath(_inputPrefix), CacheConstants.TranscriptPath(_inputPrefix2), sequenceData.refIndexToChromosome); if (caches.Cache.TranscriptIntervalArrays.Length != caches.Cache2.TranscriptIntervalArrays.Length) { throw new InvalidDataException($"Expected the number of reference sequences in cache 1 ({caches.Cache.TranscriptIntervalArrays.Length}) and cache 2 ({caches.Cache2.TranscriptIntervalArrays.Length}) to be the same."); } int numRefSeqs = caches.Cache.TranscriptIntervalArrays.Length; var combinedIntervalArrays = new IntervalArray <ITranscript> [numRefSeqs]; var siftPredictionsPerRef = new Prediction[numRefSeqs][]; var polyphenPredictionsPerRef = new Prediction[numRefSeqs][]; PredictionHeader siftHeader; PredictionHeader polyphenHeader; using (var siftReader = new PredictionCacheReader(FileUtilities.GetReadStream(CacheConstants.SiftPath(_inputPrefix)), PredictionCacheReader.SiftDescriptions)) using (var siftReader2 = new PredictionCacheReader(FileUtilities.GetReadStream(CacheConstants.SiftPath(_inputPrefix2)), PredictionCacheReader.SiftDescriptions)) using (var polyphenReader = new PredictionCacheReader(FileUtilities.GetReadStream(CacheConstants.PolyPhenPath(_inputPrefix)), PredictionCacheReader.PolyphenDescriptions)) using (var polyphenReader2 = new PredictionCacheReader(FileUtilities.GetReadStream(CacheConstants.PolyPhenPath(_inputPrefix2)), PredictionCacheReader.PolyphenDescriptions)) { siftHeader = siftReader.Header; polyphenHeader = polyphenReader.Header; for (ushort refIndex = 0; refIndex < numRefSeqs; refIndex++) { var chromosome = sequenceData.refIndexToChromosome[refIndex]; Console.ForegroundColor = ConsoleColor.Yellow; logger.WriteLine($"\n{chromosome.UcscName}:"); Console.ResetColor(); var sift = CombinePredictions(logger, chromosome, "SIFT", siftReader, siftReader2); siftPredictionsPerRef[refIndex] = sift.Predictions; var polyphen = CombinePredictions(logger, chromosome, "PolyPhen", polyphenReader, polyphenReader2); polyphenPredictionsPerRef[refIndex] = polyphen.Predictions; var transcriptIntervalArray = caches.Cache.TranscriptIntervalArrays[refIndex]; var transcriptIntervalArray2 = caches.Cache2.TranscriptIntervalArrays[refIndex]; combinedIntervalArrays[refIndex] = CombineTranscripts(logger, transcriptIntervalArray, transcriptIntervalArray2, sift.Offset, polyphen.Offset); } } logger.WriteLine(); WritePredictions(logger, "SIFT", CacheConstants.SiftPath(_outputPrefix), siftHeader, siftPredictionsPerRef); WritePredictions(logger, "PolyPhen", CacheConstants.PolyPhenPath(_outputPrefix), polyphenHeader, polyphenPredictionsPerRef); WriteTranscripts(logger, CloneHeader(caches.Cache.Header), combinedIntervalArrays, caches.Cache.RegulatoryRegionIntervalArrays); return(ExitCodes.Success); }
public void InitializeModel(int totalValues) { _normalizedUniformDistributedSequence = SequenceHelper.Normalize( _aperiodicGenerator.GenerateSequence(totalValues), _aperiodicGenerator.Divider) .ToArray(); }
private static ExitCodes ProgramExecution() { var logger = new ConsoleLogger(); string transcriptPath = _inputPrefix + ".transcripts.gz"; string siftPath = _inputPrefix + ".sift.gz"; string polyphenPath = _inputPrefix + ".polyphen.gz"; string regulatoryPath = _inputPrefix + ".regulatory.gz"; (var refIndexToChromosome, var refNameToChromosome, int numRefSeqs) = SequenceHelper.GetDictionaries(_inputReferencePath); using (var transcriptReader = new MutableTranscriptReader(GZipUtilities.GetAppropriateReadStream(transcriptPath), refIndexToChromosome)) using (var regulatoryReader = new RegulatoryRegionReader(GZipUtilities.GetAppropriateReadStream(regulatoryPath), refIndexToChromosome)) using (var siftReader = new PredictionReader(GZipUtilities.GetAppropriateReadStream(siftPath), refIndexToChromosome, IntermediateIoCommon.FileType.Sift)) using (var polyphenReader = new PredictionReader(GZipUtilities.GetAppropriateReadStream(polyphenPath), refIndexToChromosome, IntermediateIoCommon.FileType.Polyphen)) using (var geneReader = new UgaGeneReader(GZipUtilities.GetAppropriateReadStream(ExternalFiles.UniversalGeneFilePath), refNameToChromosome)) { var genomeAssembly = transcriptReader.Header.Assembly; var source = transcriptReader.Header.Source; long vepReleaseTicks = transcriptReader.Header.VepReleaseTicks; ushort vepVersion = transcriptReader.Header.VepVersion; logger.Write("- loading universal gene archive file... "); var genes = geneReader.GetGenes(); var geneForest = CreateGeneForest(genes, numRefSeqs, genomeAssembly); logger.WriteLine($"{genes.Length:N0} loaded."); logger.Write("- loading regulatory region file... "); var regulatoryRegions = regulatoryReader.GetRegulatoryRegions(); logger.WriteLine($"{regulatoryRegions.Length:N0} loaded."); logger.Write("- loading transcript file... "); var transcripts = transcriptReader.GetTranscripts(); var transcriptsByRefIndex = transcripts.GetMultiValueDict(x => x.Chromosome.Index); logger.WriteLine($"{transcripts.Length:N0} loaded."); MarkCanonicalTranscripts(logger, transcripts); var predictionBuilder = new PredictionCacheBuilder(logger, genomeAssembly); var predictionCaches = predictionBuilder.CreatePredictionCaches(transcriptsByRefIndex, siftReader, polyphenReader, numRefSeqs); logger.Write("- writing SIFT prediction cache... "); predictionCaches.Sift.Write(FileUtilities.GetCreateStream(CacheConstants.SiftPath(_outputCacheFilePrefix))); logger.WriteLine("finished."); logger.Write("- writing PolyPhen prediction cache... "); predictionCaches.PolyPhen.Write(FileUtilities.GetCreateStream(CacheConstants.PolyPhenPath(_outputCacheFilePrefix))); logger.WriteLine("finished."); var transcriptBuilder = new TranscriptCacheBuilder(logger, genomeAssembly, source, vepReleaseTicks, vepVersion); var transcriptStaging = transcriptBuilder.CreateTranscriptCache(transcripts, regulatoryRegions, geneForest, numRefSeqs); logger.Write("- writing transcript cache... "); transcriptStaging.Write(FileUtilities.GetCreateStream(CacheConstants.TranscriptPath(_outputCacheFilePrefix))); logger.WriteLine("finished."); } return(ExitCodes.Success); }
public void Test_GettingArrayElement() { Classroom classroom = new Classroom(); string path = SequenceHelper.AppendListEntryToSequence("Teachers", 0) + ".Name"; string name = ReflectionHelper.GetFieldValue <string>(path, classroom); Assert.AreEqual("Mrs Henry", name); }
public void Given_Zero_As_Input_CEZSequence_Returns_List_Only_Having_Zero() { List <string> actual = SequenceHelper.CEZSequence(0); List <string> expected = new List <string> { "0" }; CollectionAssert.AreEqual(expected, actual); }
Accession37, IDictionary <string, IChromosome> Accession38) GetSequenceDictionaries(string referencePath, string assemblyInfo37Path, string assemblyInfo38Path) { var(_, refNameToChromosome, _) = SequenceHelper.GetDictionaries(referencePath); var accession37Dict = AssemblyReader.GetAccessionToChromosome(GZipUtilities.GetAppropriateStreamReader(assemblyInfo37Path), refNameToChromosome); var accession38Dict = AssemblyReader.GetAccessionToChromosome(GZipUtilities.GetAppropriateStreamReader(assemblyInfo38Path), refNameToChromosome); return(refNameToChromosome, accession37Dict, accession38Dict); }
public void Given_Zero_As_Input_FibonacciNumbers_Returns_List_Only_Having_Zero() { List <int> actual = SequenceHelper.FibonacciNumbers(0); List <int> expected = new List <int> { 0 }; CollectionAssert.AreEqual(expected, actual); }
public void Given_Positve_Whole_Number_FibonacciNumbers_Returns_Fibonacci_Numbers_UpTo_And_including_passed_value() { var value = this.TestContext.GetRuntimeDataSourceObject <dynamic>(); string actual = String.Join(",", SequenceHelper.FibonacciNumbers((int)value.number)); string expected = (string)value.sequence; Assert.AreEqual(expected, actual, "Failed for number={0} and sequence: \"{{{1}}}\" ).", value.number, value.sequence); }