Example #1
0
        public static void UpdatePrescsForLpu(Lpu lpu, AutoResetEvent markerEvent, DateTime datetime_on, int lpuNum, int lpuListCount)
        {
            var timeBegin = DateTime.Now;

            try
            {
                Logger.Trace("UpdatePrescsForLpu - Begin.");

                var prescList = DataRepository.GetPrescListToUpdate(lpu, datetime_on);

                foreach (var presc in prescList)
                {
                    /*if (doctor.OidTheir > 0)
                     * {
                     *  RerReference.doctor doctor_new = Rer2Interaction.UpdateDoctor(doctor);
                     *  if (doctor_new != null)
                     *  {
                     *      DataRepository.UpdateBuffer(lpu, datetime_on, actions, doctor.BufferOids);
                     *  }
                     *  else
                     *  {
                     *      Logger.Trace("Rer2Interaction.UpdateDoctor - error update doctor, doctor_new is null, doctor: {0}", doctor);
                     *  }
                     * }
                     * else
                     * {
                     *  RerReference.doctor doctor_new = Rer2Interaction.CreateDoctor(doctor);
                     *  if (doctor_new != null)
                     *  {
                     *      if (DataRepository.CreateDoctor(doctor, doctor_new))
                     *      {
                     *          DataRepository.UpdateBuffer(lpu, datetime_on, actions, doctor.BufferOids);
                     *      }
                     *      else
                     *      {
                     *          Logger.Trace("CreateDoctor - error create match for doctor: {0}", String.Format("{0} {1} {2}", doctor_new.surname, doctor_new.name, doctor_new.patronymic));
                     *      }
                     *  }
                     *  else
                     *  {
                     *      Logger.Trace("Rer2Interaction.CreateDoctor - error create doctor, doctor_new id null, doctor: {0}", doctor);
                     *  }
                     * }*/
                }
            }
            catch (Exception e)
            {
                Logger.Error(e);
            }
            finally
            {
                Logger.Trace("UpdatePrescsForLpu - ok. Duration: {0} minutes", (DateTime.Now - timeBegin).TotalMinutes);

                if (Interlocked.Decrement(ref _lpuToUpdateScheduleCount) == 0)
                {
                    markerEvent.Set();
                }
            }
        }
Example #2
0
        public static List <Presc> GetPrescListToUpdate(Lpu lpu, DateTime datetime_on)
        {
            Logger.Trace("GetPrescListToUpdate: lpu=[{0}], datetime_on=[{1}]", lpu, datetime_on.ToString());

            DataSet ds = SQL.GetPrescListToUpdate(lpu, datetime_on);

            return((from DataRow row in ds.Tables[0].Rows
                    select new Presc
            {
                Oid = row["oid"].ToString(),
                OidTheir = !string.IsNullOrEmpty(row["oid_their"].ToString()) ? Convert.ToInt64(row["oid_their"]) : 0,
                Lpu = lpu,
                Surname = row["lastname"].ToString(),
                Name = row["firstname"].ToString(),
                Patronymic = row["middlename"].ToString(),
                Snils = row["snils"].ToString(),
                PostTheirList = row["post_their_list"].ToString().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => Int64.Parse(x)).ToList(),
                SpecTheirList = row["spec_their_list"].ToString().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(x => Int64.Parse(x)).ToList(),
                BufferOids = !string.IsNullOrEmpty(row["buff_oids"].ToString()) ?
                             row["buff_oids"].ToString().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList()
                            : new List <string>()
            }).ToList());
        }
Example #3
0
        public static void UpdatePrescs(int threadCount, DateTime datetime_on)
        {
            Logger.Trace("UpdatePrescs - Begin. ThreadCount={0}", threadCount);
            var timeBegin = DateTime.Now;

            var lpuList = DataRepository.GetLpuList();

            _lpuToUpdateScheduleCount = lpuList.Count;
            var markerEvent = _lpuToUpdateScheduleCount > 0 ? new AutoResetEvent(false) : new AutoResetEvent(true);

            SetMaxThreadCount(threadCount);

            for (int i = 0; i < lpuList.Count; i++)
            {
                var lpuNum  = i + 1;
                Lpu lpuCopy = lpuList[i];

                //ThreadPool.QueueUserWorkItem(callback => UpdateDoctorsForLpu(lpuCopy, markerEvent, lpuNum, lpuList.Count));
                UpdatePrescsForLpu(lpuCopy, markerEvent, datetime_on, lpuNum, lpuList.Count);
            }

            markerEvent.WaitOne();
            Logger.Trace("UpdatePrescs - ok. Duration: {0} minutes", (DateTime.Now - timeBegin).TotalMinutes);
        }
Example #4
0
        public static void UpdateBuffer(Lpu lpu, DateTime startTime, List <string> actions, List <string> buff_oids)
        {
            var    ht          = new Hashtable();
            string oids_action = string.Empty;

            if (actions != null)
            {
                oids_action = string.Join(",", actions);
            }

            string oids = string.Empty;

            if (buff_oids != null)
            {
                oids = string.Join <string>(",", buff_oids);
            }

            const string sQuerry = @"
            update mir.web_buffer_transfer_rer btr
               set upload_date = CURRENT_TIMESTAMP
             where btr.lpu = :lpu
               and btr.action in ( select unnest( string_to_array(:actions, ',') ) )
               and btr.regist_date < :start_date
               and btr.schedule_starton < date_trunc('week', CURRENT_DATE) + interval '21 day'
               and btr.oid in ( select unnest( string_to_array(:oids, ',') ) )";

            GetDataAccess().AddParameter(ht, "lpu", lpu.Oid, DataAccessType.VarChar);
            GetDataAccess().AddParameter(ht, "actions", oids_action, DataAccessType.VarChar);
            GetDataAccess().AddParameter(ht, "start_date", startTime, DataAccessType.TimeStamp);
            GetDataAccess().AddParameter(ht, "oids", oids, DataAccessType.VarChar);

            lock (GetDataAccess())
            {
                GetDataAccess().ExecuteProc(sQuerry, ht);
            }
        }
Example #5
0
        public static DataSet GetPrescListToUpdate(Lpu lpu, DateTime datetime_on)
        {
            const string sQuerry = @"
              select distinct s.oid,
                     th.code as oid_their,
                     p.lastname,
                     p.firstname,
                     p.middlename,
                     replace(replace(p.snils, '-', ''), ' ', '') as snils,
                     string_agg( thp.code, ',' ) over ( partition by s.oid order by lpad(thp.code, 10, '0') 
                                      rows between unbounded preceding and unbounded following ) as post_their_list,
                     string_agg( thss.code, ',' ) over ( partition by s.oid order by lpad(thss.code, 10, '0') 
                                      rows between unbounded preceding and unbounded following ) as spec_their_list,
                     string_agg( buff.oid, ',' ) over ( partition by s.oid order by buff.regist_date 
                                      rows between unbounded preceding and unbounded following ) as buff_oids
                from mir.sysuser s
               inner join mir.people p
                  on p.oid = s.oid
                 and p.snils is not null
               inner join mir.sotr sot
                  on sot.sysuser = s.oid
               inner join mir.otdel o
                  on o.oid = sot.otdel
               inner join mir.sotr_sertificatespeciality sss
                  on sss.sotr = sot.oid   

                left join mir.eown ow
                  on ow.code = s.oid
                 and ow.etable_id = mir.etable_get_by_syn('MEDOTRADE', 'SYSUSER')
                left join mir.etheir th
                  on th.oid = ow.etheir_id
                 and th.etable_id = mir.etable_get_by_syn('RER2', 'DOCTOR')

               inner join mir.eown owss
                  on owss.code = sss.sertificatespeciality
                 and owss.etable_id = mir.etable_get_by_syn('MEDOTRADE', 'SERTIFICATESPECIALITY')
               inner join mir.etheir thss
                  on thss.oid = owss.etheir_id
                 and thss.etable_id = mir.etable_get_by_syn('RER2', 'SPEC')
                 
               inner join mir.eown owp
                  on owp.code = sot.post
                 and owp.etable_id = mir.etable_get_by_syn('MEDOTRADE', 'POST')
               inner join mir.etheir thp
                  on thp.oid = owp.etheir_id
                 and thp.etable_id = mir.etable_get_by_syn('RER2', 'POST') 
                 
               inner join mir.web_buffer_transfer_rer buff
                  on buff.key_field_value = sot.oid
                 and buff.upload_date is null
                 and buff.lpu = o.lpu
                 and buff.table_name = 'SOTR'
                 and buff.action = 'UPDATE'
                 and buff.regist_date < :datetime_on
                 
               where o.lpu = :lpu";

            var ht = new Hashtable();

            GetDataAccess().AddParameter(ht, "lpu", lpu.Oid, DataAccessType.VarChar);
            GetDataAccess().AddParameter(ht, "datetime_on", datetime_on, DataAccessType.TimeStamp);


            lock (GetDataAccess())
            {
                return(GetDataAccess().GetDataSet(sQuerry, ht));
            }
        }