示例#1
0
 public AlteryxResultMap()
 {
     Map(a => a.AccessionNumber).Name("ACCESSION_NUMBER");
     Map(a => a.ActivistInvestorCIK).Name("ACTIVIST_INVESTOR_CIK");
     Map(a => a.ActivistInvestorCity).Name("ACTIVIST_INVESTOR_CITY");
     Map(a => a.ActivistInvestorFiscalYearEnd).Name("ACTIVIST_INVESTOR_FISCAL_YEAR_END");
     Map(a => a.ActivistInvestorIRSNumber).Name("ACTIVIST_INVESTOR_IRS_NUMBER");
     Map(a => a.ActivistInvestorName).Name("ACTIVIST_INVESTOR_COMPANY_CONFORMED_NAME");
     Map(a => a.ActivistInvestorSIC).Name("ACTIVIST_INVESTOR_SIC");
     Map(a => a.ActivistInvestorStateOfIncorporation).Name("ACTIVIST_INVESTOR_STATE_OF_INCORPORATION");
     Map(a => a.ClassOfSecurities).Name("CLASS_OF_SECURITIES");
     Map(a => a.CUSIP).Name("CUSIP");
     Map(a => a.EventDate).Name("EVENT_DATE");
     Map(a => a.FilingDate).Name("FILING_DATE");
     Map(a => a.PublicDocumentCount).Name("PUBLIC_DOCUMENT_COUNT");
     Map(a => a.Source).Name("SOURCE");
     Map(a => a.SubjectCompanyCIK).Name("SUBJECT_COMPANY_CIK");
     Map(a => a.SubjectCompanyCity).Name("SUBJECT_COMPANY_CITY");
     Map(a => a.SubjectCompanyCUSIP).Name("SUBJECT_COMPANY_CUSIP");
     Map(a => a.SubjectCompanyFiscalYearEnd).Name("SUBJECT_COMPANY_FISCAL_YEAR_END");
     Map(a => a.SubjectCompanyIRSNumber).Name("SUBJECT_COMPANY_IRS_NUMBER");
     Map(a => a.SubjectCompanyName).Name("SUBJECT_COMPANY_COMPANY_CONFORMED_NAME");
     Map(a => a.SubjectCompanySIC).Name("SUBJECT_COMPANY_SIC");
     Map(a => a.SubjectCompanyStateOfIncorporation).Name("SUBJECT_COMPANY_STATE_OF_INCORPORATION");
     Map(a => a.SubmissionType).Convert(row => DataTransformers.TransformSubmissionType(row.GetField("SUBMISSION_TYPE")));
     Map(a => a.TypeOfReportingPerson).Convert(row => DataTransformers.TransformTypeOfReportingPerson(row.GetField("TYPE_OF_REPORTING_PERSON")));
 }
        public ActionResult Index(long matterId, string[] file)
        {
            return(CreateTask(() =>
            {
                var myFile = Request.Files[0];

                if (myFile == null || myFile.ContentLength == 0)
                {
                    throw new ArgumentNullException(nameof(file), "Sequence file not found or empty.");
                }

                int fileLen = myFile.ContentLength;
                var input = new byte[fileLen];

                // Initialize the stream.
                var fileStream = myFile.InputStream;

                // Read the file into the byte array.
                fileStream.Read(input, 0, fileLen);

                // Copy the byte array into a string.
                string stringSequence = Encoding.ASCII.GetString(input);
                string[] tempString = stringSequence.Split('\n', '\r');

                var sequenceStringBuilder = new StringBuilder();

                for (int j = 1; j < tempString.Length; j++)
                {
                    sequenceStringBuilder.Append(tempString[j]);
                }

                string resultStringSequence = DataTransformers.CleanFastaFile(sequenceStringBuilder.ToString());

                var chain = new BaseChain(resultStringSequence);
                string message;
                string status;
                BaseChain dbChain;
                using (var db = new LibiadaWebEntities())
                {
                    long sequenceId = db.CommonSequence.Single(c => c.MatterId == matterId).Id;
                    var commonSequenceRepository = new CommonSequenceRepository(db);
                    dbChain = commonSequenceRepository.GetLibiadaBaseChain(sequenceId);
                }

                if (dbChain.Equals(chain))
                {
                    message = "Sequence in db and in file are equal";
                    status = "Success";
                }
                else
                {
                    status = "Error";
                    if (chain.Alphabet.Cardinality != dbChain.Alphabet.Cardinality)
                    {
                        message = $"Alphabet sizes are not equal. In db - {dbChain.Alphabet.Cardinality}. In file - {chain.Alphabet.Cardinality}";
                        return new Dictionary <string, string> {
                            { "data", JsonConvert.SerializeObject(new { message }) }
                        };
                    }

                    for (int i = 0; i < chain.Alphabet.Cardinality; i++)
                    {
                        if (!chain.Alphabet[i].ToString().Equals(dbChain.Alphabet[i].ToString()))
                        {
                            message = $"{i} elements in alphabet are not equal. In db - {dbChain.Alphabet[i]}. In file - {chain.Alphabet[i]}";
                            return new Dictionary <string, string> {
                                { "data", JsonConvert.SerializeObject(new { message }) }
                            };
                        }
                    }

                    if (chain.Length != dbChain.Length)
                    {
                        message = $"Sequence length in db {dbChain.Length}, and sequence length from file{chain.Length}";
                        return new Dictionary <string, string> {
                            { "data", JsonConvert.SerializeObject(new { message, status }) }
                        };
                    }

                    int[] libiadaBuilding = chain.Building;
                    int[] dataBaseBuilding = dbChain.Building;

                    for (int j = 0; j < chain.Length; j++)
                    {
                        if (libiadaBuilding[j] != dataBaseBuilding[j])
                        {
                            message = $"{j} sequences elements are not equal. In db {dataBaseBuilding[j]}. In file {libiadaBuilding[j]}";
                            return new Dictionary <string, string> {
                                { "data", JsonConvert.SerializeObject(new { message, status }) }
                            };
                        }
                    }

                    message = "Sequences are equal and not equal at the same time.";
                }

                return new Dictionary <string, string> {
                    { "data", JsonConvert.SerializeObject(new { message, status }) }
                };
            }));
        }