Exemplo n.º 1
0
        public qAbiturient GetAbitByBarcode(int fileNum)
        {
            try
            {
                string abitQueryInet = @"SELECT qAbiturient.Barcode, EntryId, qAbiturient.HostelEduc, 
                            (Case when qAbiturient.Enabled = 1 then 0 else 1 end) AS BackDoc, 
                            qAbiturient.DateOfDisable AS BackDocDate, qAbiturient.DateOfStart AS DocDate,                           
                            qAbiturient.Priority, qAbiturient.LicenseProgramId, qAbiturient.ObrazProgramId, 
                            qAbiturient.ProfileId, qAbiturient.FacultyId, qAbiturient.StudyFormId, 
                            qAbiturient.StudyBasisId, qAbiturient.IsSecond,
                            qAbiturient.IsGosLine, qAbiturient.CommitId, qAbiturient.CommitNumber 
                            FROM qAbiturient WHERE 0=0";

                DataSet ds = _bdcInet.GetDataSet(abitQueryInet + " AND qAbiturient.Barcode = " + fileNum);
                if (ds.Tables[0].Rows.Count == 0)
                {
                    throw new Exception("Записей не найдено");
                }

                DataRow     row  = ds.Tables[0].Rows[0];
                qAbiturient abit = new qAbiturient();

                abit.IsSecond = (bool)row["IsSecond"];
                abit.EntryId  = (Guid)row["EntryId"];

                abit.CommitId     = (Guid)row["CommitId"];
                abit.CommitNumber = (int?)row["CommitNumber"];

                abit.FacultyId        = (int)row["FacultyId"];
                abit.LicenseProgramId = (int)row["LicenseProgramId"];
                abit.ObrazProgramId   = (int)row["ObrazProgramId"];
                abit.ProfileId        = (Guid?)(Util.ToNullObject(row["ProfileId"]));
                abit.StudyFormId      = (int)row["StudyFormId"];
                abit.StudyBasisId     = (int)row["StudyBasisId"];
                abit.IsGosLine        = QueryServ.ToBoolValue(row["IsGosLine"]);

                abit.BackDoc     = QueryServ.ToBoolValue(row["BackDoc"]);
                abit.BackDocDate = row.Field <DateTime?>("BackDocDate");
                abit.DocDate     = (DateTime)row["DocDate"];

                int prior;
                if (!int.TryParse(row["Priority"].ToString(), out prior))
                {
                    abit.Priority = null;
                }
                else
                {
                    abit.Priority = prior;
                }

                abit.Barcode = int.Parse(row["Barcode"].ToString());

                return(abit);
            }
            catch
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        public static void ImportMagAbits()
        {
            List <string> lstPersons = new List <string>();
            List <string> lstAbits   = new List <string>();

            LoadFromInet loadClass = new LoadFromInet();
            DBPriem      _bdcInet  = loadClass.BDCInet;

            using (PriemEntities context = new PriemEntities())
            {
                string  _sQuery = @"SELECT DISTINCT qAbiturient.Id, qAbiturient.PersonId, qAbiturient.Barcode AS AbitBarcode, extPerson.Barcode AS PersonBarcode
                              FROM qAbiturient INNER JOIN extPerson ON qAbiturient.PersonId = extPerson.Id WHERE StudyLevelId = 17 AND Enabled = 1 AND IsApprovedByComission = 1 AND IsImported = 0";
                DataSet ds      = _bdcInet.GetDataSet(_sQuery);

                Guid?personId;
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    int?abitBarcode = (int?)dr["AbitBarcode"];
                    if (!MainClass.CheckAbitBarcode(abitBarcode))
                    {
                        continue;
                    }


                    int?persBarcode = (int?)dr["PersonBarcode"];
                    if (!MainClass.CheckPersonBarcode(persBarcode))
                    {
                        personId = (from pers in context.extForeignPerson
                                    where pers.Barcode == persBarcode
                                    select pers.Id).FirstOrDefault();
                    }
                    else
                    {
                        extPersonAll person = loadClass.GetPersonByBarcode(persBarcode.Value);

                        if (!CheckIdent(person))
                        {
                            lstPersons.Add(persBarcode.ToString());
                            continue;
                        }

                        ObjectParameter entId = new ObjectParameter("id", typeof(Guid));
                        context.Person_Foreign_insert(person.Barcode, person.Name, person.SecondName, person.Surname, person.BirthDate, person.BirthPlace, person.PassportTypeId,
                                                      person.PassportSeries, person.PassportNumber, person.PassportAuthor, person.PassportDate, person.Sex, person.CountryId, person.NationalityId,
                                                      person.RegionId, person.Phone, person.Mobiles, person.Email,
                                                      person.Code, person.City, person.Street, person.House, person.Korpus, person.Flat,
                                                      person.CodeReal, person.CityReal, person.StreetReal, person.HouseReal, person.KorpusReal, person.FlatReal,
                                                      person.HostelAbit, false, null, false, null, person.IsExcellent,
                                                      person.LanguageId, person.SchoolCity, person.SchoolTypeId, person.SchoolName, person.SchoolNum, person.SchoolExitYear, person.SchoolAVG,
                                                      person.ForeignCountryEducId, person.RegionEducId, person.IsEqual, person.EqualDocumentNumber, person.HasTRKI, person.TRKICertificateNumber,
                                                      person.AttestatRegion, person.AttestatSeries, person.AttestatNum, person.DiplomSeries, person.DiplomNum,
                                                      person.HighEducation, person.HEProfession, person.HEQualification, person.HEEntryYear, person.HEExitYear, person.HEStudyFormId,
                                                      person.HEWork, person.Stag, person.WorkPlace, person.Privileges, person.PassportCode,
                                                      person.PersonalCode, person.PersonInfo, person.ExtraInfo, person.ScienceWork, person.StartEnglish, person.EnglishMark, entId);

                        //_bdcInet.ExecuteQuery("UPDATE Person SET IsImported = 1 WHERE Person.Barcode = " + persBarcode);

                        personId = (Guid)entId.Value;
                    }

                    qAbiturient abit = loadClass.GetAbitByBarcode(abitBarcode.Value);

                    int cnt = (from en in context.qEntry
                               where en.Id == abit.EntryId && !en.IsClosed
                               select en).Count();

                    if (cnt == 0)
                    {
                        lstAbits.Add(abitBarcode.ToString());
                        continue;
                    }

                    ObjectParameter abEntId = new ObjectParameter("id", typeof(Guid));

                    int competitionId;
                    if (abit.StudyBasisId == 1)
                    {
                        competitionId = 4;
                    }
                    else
                    {
                        competitionId = 3;
                    }

                    context.Abiturient_Insert(personId, abit.EntryId, competitionId, false, false, false, false, null, abit.DocDate, DateTime.Now,
                                              false, false, null, null, null, null, abit.LanguageId, false,
                                              abit.Priority, abit.Barcode, abit.CommitId, abit.CommitNumber, abit.IsGosLine, abEntId);

                    // _bdcInet.ExecuteQuery("UPDATE Application SET IsImported = 1 WHERE Application.Barcode = " + abitBarcode);
                }
            }
        }