public async Task <ActionResult> Create(RecordTimeView view)
        {
            if (ModelState.IsValid)
            {
                var employee = await db.Employees.Where(e => e.Email.Equals(User.Identity.Name)).FirstOrDefaultAsync();

                if (employee != null)
                {
                    var dateTimeStart = view.DateStart.AddHours(view.TimeStart.Hour).AddMinutes(view.TimeStart.Minute);
                    var dateTimeEnd   = view.DateEnd.AddHours(view.TimeEnd.Hour).AddMinutes(view.TimeEnd.Minute);

                    if (dateTimeStart <= dateTimeEnd)
                    {
                        var recordTime = new RecordTime
                        {
                            EmployeeId = employee.EmployeeId,
                            DateStart  = dateTimeStart,
                            DateEnd    = dateTimeEnd,
                        };

                        db.RecordTimes.Add(recordTime);
                        await db.SaveChangesAsync();

                        return(RedirectToAction("Index"));
                    }

                    ModelState.AddModelError(string.Empty, "La fecha/hora de finalización no puede ser menor que la fecha/hora de inicio.");
                }

                ModelState.AddModelError(string.Empty, "No se ecuentra empleado.");
            }

            return(View(view));
        }
예제 #2
0
 public Task UpdateAsync(RecordTime time)
 {
     if (time.Type != RecordType.TrackAge)
     {
         time.FromAge = int.MinValue;
         time.ToAge   = int.MaxValue;
     }
     return(context.SaveChangesAsync());
 }
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            RecordTime recordTime = await db.RecordTimes.FindAsync(id);

            db.RecordTimes.Remove(recordTime);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
예제 #4
0
        void TimeRecord()
        {
            rt = new RecordTime();

            timer           = new System.Timers.Timer(10 * 60 * 1000); //10分钟
            timer.AutoReset = true;                                    //AutoReset 属性为 true 时,每隔指定时间循环一次;如果为 false,则只执行一次。
            timer.Enabled   = true;
            timer.Elapsed  += new System.Timers.ElapsedEventHandler(rt.TimerTask);
            timer.Start();
        }
        public async Task <ActionResult> Edit([Bind(Include = "RecordTimeId,EmployeeId,DateStart,DateEnd")] RecordTime recordTime)
        {
            if (ModelState.IsValid)
            {
                db.Entry(recordTime).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "Document", recordTime.EmployeeId);
            return(View(recordTime));
        }
        // GET: RecordTimes/Delete/5
        public async Task <ActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RecordTime recordTime = await db.RecordTimes.FindAsync(id);

            if (recordTime == null)
            {
                return(HttpNotFound());
            }
            return(View(recordTime));
        }
예제 #7
0
        public int Insert()
        {
            string querySql = "select 1 from AudioDownLoadInfo where GUID={0} and ShareToStetName={1}";

            if (null != Mediator.sqliteHelper.ExecuteScalar(querySql, Guid, ShareToStetName))
            {
                return(0);
            }

            string sql   = "insert into AudioDownLoadInfo select {0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14},{15},{16}";
            int    count = Mediator.sqliteHelper.ExecuteNonQuery(sql, Guid, StetSerialNumber, StetName, PatientType, PatientID, PatientName, Posture,
                                                                 Part, RecordTime.ToString("yyyy-MM-dd HH:mm:ss"), TakeTime.ToString(), Remark, DocName, DocDiagnose, ShareStetName, ShareToStetName, ShareTime == DateTime.MinValue ? "" : ShareTime.ToString("yyyy-MM-dd HH:mm:ss"), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

            return(count);
        }
        // GET: RecordTimes/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            RecordTime recordTime = await db.RecordTimes.FindAsync(id);

            if (recordTime == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EmployeeId = new SelectList(db.Employees, "EmployeeId", "Document", recordTime.EmployeeId);
            return(View(recordTime));
        }
예제 #9
0
        public async Task AddAsync(RecordTime time)
        {
            if (time.Type != RecordType.TrackAge)
            {
                time.FromAge = int.MinValue;
                time.ToAge   = int.MaxValue;
            }

            context.RecordTimes.Add(time);
            try
            {
                await context.SaveChangesAsync();
            }
            catch (DbUpdateException e)
            {
                throw new NumberCollissionException(LogMessages.RecordTimeAlreadyExists, e);
            }
        }
예제 #10
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (recordTime_ != null)
            {
                hash ^= RecordTime.GetHashCode();
            }
            if (offset_ != null)
            {
                hash ^= Offset.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
예제 #11
0
        private void CekPesanToday()
        {
            RecordTime record = new RecordTime(totalTimeTextBox.Text, timePerUseTextBox.Text);

            record.Masukan(record.Baca1, record.Baca2);
            if (record.scan1 <= 4 && record.scan1 > 0)
            {
                if (record.scan2 <= 1 && record.scan2 > 0)
                {
                    MessageBox.Show("Berikut laporan penggunaanmu hari ini");
                    Pesan1 pesannya = new Pesan1();
                    pesannya.PesanPesan();
                }
                else if (record.scan2 > 1 && record.scan2 <= 24)
                {
                    MessageBox.Show("Berikut laporan penggunaanmu hari ini");
                    Pesan2 pesannya = new Pesan2();
                    pesannya.PesanPesan();
                }
            }
            else if (record.scan1 > 4 && record.scan1 <= 24)
            {
                if (record.scan2 <= 1 && record.scan2 > 0)
                {
                    MessageBox.Show("Berikut laporan penggunaanmu hari ini");
                    Pesan3 pesannya = new Pesan3();
                    pesannya.PesanPesan();
                }
                else if (record.scan2 > 1 && record.scan2 <= 24)
                {
                    MessageBox.Show("Berikut laporan penggunaanmu hari ini");
                    Pesan4 pesannya = new Pesan4();
                    pesannya.PesanPesan();
                }
            }
            totalTimeTextBox.Text  = String.Empty;
            timePerUseTextBox.Text = String.Empty;
        }
예제 #12
0
 public void MergeFrom(Checkpoint other)
 {
     if (other == null)
     {
         return;
     }
     if (other.recordTime_ != null)
     {
         if (recordTime_ == null)
         {
             RecordTime = new global::Google.Protobuf.WellKnownTypes.Timestamp();
         }
         RecordTime.MergeFrom(other.RecordTime);
     }
     if (other.offset_ != null)
     {
         if (offset_ == null)
         {
             Offset = new global::Com.DigitalAsset.Ledger.Api.V1.LedgerOffset();
         }
         Offset.MergeFrom(other.Offset);
     }
     _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
 }
예제 #13
0
 internal Record(byte item, RecordDate date, RecordTime time)
 {
     Item = item;
     Date = date;
     Time = time;
 }
예제 #14
0
 internal Record32(byte item, RecordDate date, RecordTime time, uint value) : base(item, date, time)
 {
     Value = value;
 }
예제 #15
0
        public static Record[] ReadRecord()
        {
            var records = new List <Record>();
            var handle  = HIDAPI.hid_open(VENDOR_ID, PRODUCT_ID, IntPtr.Zero);

            if (handle.ToInt32() <= 0)
            {
                Debug.Print("Could not open device.");

                return(null);
            }

            try
            {
                var outBuffer = new byte[]
                {
                    0x02,           // USB Read Report
                    0x02,           // Size of payload
                    READ_RECORD,    // READ_RECORD
                    READ_RECORD     // Checksum (only one byte so same as command)
                };

                var numWritten = HIDAPI.hid_write(handle, outBuffer, outBuffer.Length);

                if (numWritten < 4)
                {
                    Debug.Print("Failed to write request to device.");

                    return(null);
                }

                using (var mem = new MemoryStream(1024))
                {
                    var payload = PerformRead(handle);

                    if (payload == null)
                    {
                        Debug.Print("Could not read data from device.");

                        return(null);
                    }

                    if (payload[0] != READ_RECORD)
                    {
                        Debug.Print("Payload is not a READ_RECORD result.");

                        return(null);
                    }

                    var totalSize = payload[1];
                    var data      = new byte[payload.Length - 2];

                    Array.Copy(payload, 2, data, 0, data.Length);

                    mem.Write(data, 0, data.Length);

                    while (mem.Length < totalSize)
                    {
                        data = PerformRead(handle);

                        if (data == null)
                        {
                            Debug.Print("Could not read data from device.");

                            return(null);
                        }

                        if ((mem.Length + data.Length) >= totalSize)
                        {
                            mem.Write(data, 0, data.Length - 1); // -1 because we don't want to include the final checksum byte
                        }
                        else
                        {
                            mem.Write(data, 0, data.Length);
                        }
                    }

                    mem.Seek(0, SeekOrigin.Begin);

                    while (mem.Position < mem.Length)
                    {
                        var type    = Utils.ReadByte(mem);
                        var item    = type;
                        var hasDate = (type & ITEM_DATE) != 0;
                        var hasTime = (type & ITEM_TIME) != 0;

                        if (hasDate)
                        {
                            item = Convert.ToByte(item & ~ITEM_DATE);
                        }

                        if (hasTime)
                        {
                            item = Convert.ToByte(item & ~ITEM_TIME);
                        }

                        var valueBytes = new byte[0];

                        switch (item)
                        {
                        case ITEM_INTEMP:
                            valueBytes = Utils.ReadBytes(mem, 2);
                            break;

                        case ITEM_OUTTEMP:
                            valueBytes = Utils.ReadBytes(mem, 2);
                            break;

                        case ITEM_DEWPOINT:
                            valueBytes = Utils.ReadBytes(mem, 2);
                            break;

                        case ITEM_WINDCHILL:
                            valueBytes = Utils.ReadBytes(mem, 2);
                            break;

                        case ITEM_HEATINDEX:
                            valueBytes = Utils.ReadBytes(mem, 2);
                            break;

                        case ITEM_INHUMI:
                            valueBytes = Utils.ReadBytes(mem, 1);
                            break;

                        case ITEM_OUTHUMI:
                            valueBytes = Utils.ReadBytes(mem, 1);
                            break;

                        case ITEM_ABSBARO:
                            valueBytes = Utils.ReadBytes(mem, 2);
                            break;

                        case ITEM_RELBARO:
                            valueBytes = Utils.ReadBytes(mem, 2);
                            break;

                        case ITEM_WINDDIRECTION:
                            valueBytes = Utils.ReadBytes(mem, 2);
                            break;

                        case ITEM_WINDSPEED:
                            valueBytes = Utils.ReadBytes(mem, 2);
                            break;

                        case ITEM_GUSTSPEED:
                            valueBytes = Utils.ReadBytes(mem, 2);
                            break;

                        case ITEM_RAINEVENT:
                            valueBytes = Utils.ReadBytes(mem, 4);
                            break;

                        case ITEM_RAINRATE:
                            valueBytes = Utils.ReadBytes(mem, 4);
                            break;

                        case ITEM_RAINHOUR:
                            valueBytes = Utils.ReadBytes(mem, 4);
                            break;

                        case ITEM_RAINDAY:
                            valueBytes = Utils.ReadBytes(mem, 4);
                            break;

                        case ITEM_RAINWEEK:
                            valueBytes = Utils.ReadBytes(mem, 4);
                            break;

                        case ITEM_RAINMONTH:
                            valueBytes = Utils.ReadBytes(mem, 4);
                            break;

                        case ITEM_RAINYEAR:
                            valueBytes = Utils.ReadBytes(mem, 4);
                            break;

                        case ITEM_RAINTOTALS:
                            valueBytes = Utils.ReadBytes(mem, 4);
                            break;

                        case ITEM_LIGHT:
                            valueBytes = Utils.ReadBytes(mem, 4);
                            break;

                        case ITEM_UV:
                            valueBytes = Utils.ReadBytes(mem, 2);
                            break;

                        case ITEM_UVI:
                            valueBytes = Utils.ReadBytes(mem, 1);
                            break;

                        default:
                            return(null);
                        }

                        RecordDate date = null;
                        RecordTime time = null;

                        if (hasDate)
                        {
                            var dateBuffer = new byte[3];
                            var numRead    = mem.Read(dateBuffer, 0, dateBuffer.Length);

                            if (numRead < dateBuffer.Length)
                            {
                                Debug.Print("Could not read date from memory.");

                                return(null);
                            }

                            date = new RecordDate(dateBuffer[0], dateBuffer[1], dateBuffer[2]);
                        }

                        if (hasTime)
                        {
                            var timeBuffer = new byte[2];
                            var numRead    = mem.Read(timeBuffer, 0, timeBuffer.Length);

                            if (numRead < timeBuffer.Length)
                            {
                                Debug.Print("Could not read time from memory.");

                                return(null);
                            }

                            time = new RecordTime(timeBuffer[0], timeBuffer[1]);
                        }

                        Record record = null;

                        switch (item)
                        {
                        case ITEM_INTEMP:
                        {
                            ushort value = BitConverter.ToUInt16(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record16(item, date, time, value);

                            break;
                        }

                        case ITEM_OUTTEMP:
                        {
                            ushort value = BitConverter.ToUInt16(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record16(item, date, time, value);

                            break;
                        }

                        case ITEM_DEWPOINT:
                        {
                            ushort value = BitConverter.ToUInt16(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record16(item, date, time, value);

                            break;
                        }

                        case ITEM_WINDCHILL:
                        {
                            ushort value = BitConverter.ToUInt16(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record16(item, date, time, value);

                            break;
                        }

                        case ITEM_HEATINDEX:
                        {
                            ushort value = BitConverter.ToUInt16(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record16(item, date, time, value);

                            break;
                        }

                        case ITEM_INHUMI:
                        {
                            record = new Record8(item, date, time, valueBytes[0]);

                            break;
                        }

                        case ITEM_OUTHUMI:
                        {
                            record = new Record8(item, date, time, valueBytes[0]);

                            break;
                        }

                        case ITEM_ABSBARO:
                        {
                            ushort value = BitConverter.ToUInt16(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record16(item, date, time, value);

                            break;
                        }

                        case ITEM_RELBARO:
                        {
                            ushort value = BitConverter.ToUInt16(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record16(item, date, time, value);

                            break;
                        }

                        case ITEM_WINDDIRECTION:
                        {
                            ushort value = BitConverter.ToUInt16(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record16(item, date, time, value);

                            break;
                        }

                        case ITEM_WINDSPEED:
                        {
                            ushort value = BitConverter.ToUInt16(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record16(item, date, time, value);

                            break;
                        }

                        case ITEM_GUSTSPEED:
                        {
                            ushort value = BitConverter.ToUInt16(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record16(item, date, time, value);

                            break;
                        }

                        case ITEM_RAINEVENT:
                        {
                            uint value = BitConverter.ToUInt32(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record32(item, date, time, value);

                            break;
                        }

                        case ITEM_RAINRATE:
                        {
                            uint value = BitConverter.ToUInt32(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record32(item, date, time, value);

                            break;
                        }

                        case ITEM_RAINHOUR:
                        {
                            uint value = BitConverter.ToUInt32(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record32(item, date, time, value);

                            break;
                        }

                        case ITEM_RAINDAY:
                        {
                            uint value = BitConverter.ToUInt32(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record32(item, date, time, value);

                            break;
                        }

                        case ITEM_RAINWEEK:
                        {
                            uint value = BitConverter.ToUInt32(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record32(item, date, time, value);

                            break;
                        }

                        case ITEM_RAINMONTH:
                        {
                            uint value = BitConverter.ToUInt32(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record32(item, date, time, value);

                            break;
                        }

                        case ITEM_RAINYEAR:
                        {
                            uint value = BitConverter.ToUInt32(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record32(item, date, time, value);

                            break;
                        }

                        case ITEM_RAINTOTALS:
                        {
                            uint value = BitConverter.ToUInt32(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record32(item, date, time, value);

                            break;
                        }

                        case ITEM_LIGHT:
                        {
                            uint value = BitConverter.ToUInt32(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record32(item, date, time, value);

                            break;
                        }

                        case ITEM_UV:
                        {
                            ushort value = BitConverter.ToUInt16(Utils.ReverseBytes(valueBytes), 0);

                            record = new Record16(item, date, time, value);

                            break;
                        }

                        case ITEM_UVI:
                        {
                            record = new Record8(item, date, time, valueBytes[0]);

                            break;
                        }
                        }

                        if (record != null)
                        {
                            records.Add(record);
                        }
                    }
                }
            }
            finally
            {
                HIDAPI.hid_close(handle);
            }

            return(records.ToArray());
        }
예제 #16
0
 public Task RemoveAsync(RecordTime time)
 {
     context.RecordTimes.Remove(time);
     return(context.SaveChangesAsync());
 }
예제 #17
0
        /// <summary>
        /// 根据方案管理者ID,生成记录包括完成与未完成的(按循环条件)
        /// </summary>
        public void Procedure()
        {
            if (myRow != null)
            {
                string    quryRec = "select * from T_FOLLOW_RECORD where patient_id=" + pid + " and solution_id=" + sid + " order by id";
                DataTable recTb   = App.GetDataSet(quryRec).Tables[0];
                myRec = GetRecords(recTb);
            }

            string uid = App.UserAccount.UserInfo.User_id;
            string tempSql;

            if (sid != "")
            {
                tempSql = "select * from T_FOLLOW_INFO where id =" + sid + "";
                DataSet dsTemp = App.GetDataSet(tempSql);
                myInfo = GetInfo(dsTemp);
            }
            //全部插入,然后遍历现有Record表去除已有的记录
            ArrayList Batch = new ArrayList();

            Batch.Clear();
            Class_FollowInfo info = myInfo[0];

            //参考时间默认为出院时间
            DateTime myTime = Convert.ToDateTime(myRow.Cells["参考时间"].Value.ToString());
            string   sql    = "";

            try
            {
                //先考虑是否为手动控制启用病人

                string Manual = App.ReadSqlVal("select * from T_FOLLOW_MANUALPATIENT where patient_id=" + pid + " and solution_id=" + info.Id + " and isadd=1   ", 0, "definefollows");

                #region Manual
                if (Manual != "" && Manual != null)
                {
                    string   ExistRecord = App.ReadSqlVal("select max(requested_time) 完成时间 from T_FOLLOW_RECORD where patient_id=" + pid + " and solution_id=" + info.Id + " ", 0, "完成时间");
                    DateTime NowTime     = App.GetSystemTime().Date;
                    DateTime RefTime     = Convert.ToDateTime(myRow.Cells["参考时间"].Value.ToString());
                    DateTime RecordTime;
                    if (ExistRecord != "")
                    {
                        RecordTime = Convert.ToDateTime(ExistRecord);
                    }
                    else
                    {
                        RecordTime = RefTime;
                    }
                    TimeSpan tSpan1     = RecordTime - RefTime;
                    TimeSpan tSpan2     = NowTime - RecordTime;
                    int      MinusTime1 = (int)tSpan1.TotalDays;
                    int      MinusTime2 = (int)tSpan2.TotalDays;
                    if (Manual.IndexOf(",") != -1)
                    {
                        string[] Items = Manual.Split(',');
                        for (int i = 0; i < Items.Length; i++)
                        {
                            string Span = Items[i];
                            if (MinusTime2 < 0)
                            {
                                break;
                            }
                            if (Span.IndexOf("年") != -1)
                            {
                                if (MinusTime1 > 0)
                                {
                                    MinusTime1 -= Convert.ToInt32(Span.Substring(0, Span.IndexOf("年"))) * 365;
                                }
                                else
                                {
                                    MinusTime2 -= Convert.ToInt32(Span.Substring(0, Span.IndexOf("年"))) * 365;
                                    RecordTime  = RecordTime.AddYears(Convert.ToInt32(Span.Substring(0, Span.IndexOf("年"))));
                                    if (MinusTime2 >= 0)
                                    {
                                        sql = "insert into T_FOLLOW_RECORD(PATIENT_ID,SOLUTION_ID,CREATOR_ID,REQUESTED_TIME) VALUES(" + pid + "," + info.Id + "," + App.UserAccount.UserInfo.User_id + ",'" + RecordTime.ToShortDateString() + "')";
                                        Batch.Add(sql);
                                    }
                                }
                            }
                            if (Span.IndexOf("月") != -1)
                            {
                                if (MinusTime1 > 0)
                                {
                                    MinusTime1 -= Convert.ToInt32(Span.Substring(0, Span.IndexOf("月"))) * 30;
                                }
                                else
                                {
                                    MinusTime2 -= Convert.ToInt32(Span.Substring(0, Span.IndexOf("月"))) * 30;
                                    RecordTime  = RecordTime.AddMonths(Convert.ToInt32(Span.Substring(0, Span.IndexOf("月"))));
                                    if (MinusTime2 >= 0)
                                    {
                                        sql = "insert into T_FOLLOW_RECORD(PATIENT_ID,SOLUTION_ID,CREATOR_ID,REQUESTED_TIME) VALUES(" + pid + "," + info.Id + "," + App.UserAccount.UserInfo.User_id + ",'" + RecordTime.ToShortDateString() + "')";
                                        Batch.Add(sql);
                                    }
                                }
                            }
                            if (Span.IndexOf("天") != -1)
                            {
                                if (MinusTime1 > 0)
                                {
                                    MinusTime1 -= Convert.ToInt32(Span.Substring(0, Span.IndexOf("天")));
                                }
                                else
                                {
                                    MinusTime2 -= Convert.ToInt32(Span.Substring(0, Span.IndexOf("天")));
                                    RecordTime  = RecordTime.AddDays(Convert.ToInt32(Span.Substring(0, Span.IndexOf("天"))));
                                    if (MinusTime2 >= 0)
                                    {
                                        sql = "insert into T_FOLLOW_RECORD(PATIENT_ID,SOLUTION_ID,CREATOR_ID,REQUESTED_TIME) VALUES(" + pid + "," + info.Id + "," + App.UserAccount.UserInfo.User_id + ",'" + RecordTime.ToShortDateString() + "')";
                                        Batch.Add(sql);
                                    }
                                }
                            }
                            if (i == Items.Length - 1)
                            {
                                i--;
                            }
                        }
                    }
                    else
                    {
                        while (true)
                        {
                            if (MinusTime2 < 0)
                            {
                                break;
                            }
                            if (Manual.IndexOf("年") != -1)
                            {
                                if (MinusTime1 > 0)
                                {
                                    MinusTime1 -= Convert.ToInt32(Manual.Substring(0, Manual.IndexOf("年"))) * 365;
                                }
                                else
                                {
                                    MinusTime2 -= Convert.ToInt32(Manual.Substring(0, Manual.IndexOf("年"))) * 365;
                                    RecordTime  = RecordTime.AddYears(Convert.ToInt32(Manual.Substring(0, Manual.IndexOf("年"))));
                                    if (MinusTime2 >= 0)
                                    {
                                        sql = "insert into T_FOLLOW_RECORD(PATIENT_ID,SOLUTION_ID,CREATOR_ID,REQUESTED_TIME) VALUES(" + pid + "," + info.Id + "," + App.UserAccount.UserInfo.User_id + ",to_date('" + RecordTime.ToShortDateString() + "','yyyy-MM-dd'))";
                                        Batch.Add(sql);
                                    }
                                }
                            }
                            if (Manual.IndexOf("月") != -1)
                            {
                                if (MinusTime1 > 0)
                                {
                                    MinusTime1 -= Convert.ToInt32(Manual.Substring(0, Manual.IndexOf("月"))) * 30;
                                }
                                else
                                {
                                    MinusTime2 -= Convert.ToInt32(Manual.Substring(0, Manual.IndexOf("月"))) * 30;
                                    RecordTime  = RecordTime.AddMonths(Convert.ToInt32(Manual.Substring(0, Manual.IndexOf("月"))));
                                    if (MinusTime2 >= 0)
                                    {
                                        sql = "insert into T_FOLLOW_RECORD(PATIENT_ID,SOLUTION_ID,CREATOR_ID,REQUESTED_TIME) VALUES(" + pid + "," + info.Id + "," + App.UserAccount.UserInfo.User_id + ",to_date('" + RecordTime.ToShortDateString() + "','yyyy-MM-dd'))";
                                        Batch.Add(sql);
                                    }
                                }
                            }
                            if (Manual.IndexOf("天") != -1)
                            {
                                if (MinusTime1 > 0)
                                {
                                    MinusTime1 -= Convert.ToInt32(Manual.Substring(0, Manual.IndexOf("天")));
                                }
                                else
                                {
                                    MinusTime2 -= Convert.ToInt32(Manual.Substring(0, Manual.IndexOf("天")));
                                    RecordTime  = RecordTime.AddDays(Convert.ToInt32(Manual.Substring(0, Manual.IndexOf("天"))));
                                    if (MinusTime2 >= 0)
                                    {
                                        sql = "insert into T_FOLLOW_RECORD(PATIENT_ID,SOLUTION_ID,CREATOR_ID,REQUESTED_TIME) VALUES(" + pid + "," + info.Id + "," + App.UserAccount.UserInfo.User_id + ",to_date('" + RecordTime.ToShortDateString() + "','yyyy-MM-dd'))";
                                        Batch.Add(sql);
                                    }
                                }
                            }
                        }
                    }
                }

                #endregion
                /**************************************************************************************************************************************************************************************/
                /***************************************************************************************完成手动添加病人的记录插入***********************************************************************************************/
                #region Auto
                else
                {
                    string   ExistRecord = "";
                    int      ExistTimes  = 0; //计数用来查看是否超过方案规定次数
                    int      TimesCount  = 0; //计数当前已生成记录
                    DateTime NowTime     = DateTime.Today;
                    DateTime RefTime     = Convert.ToDateTime(myRow.Cells["参考时间"].Value.ToString());
                    DateTime RecordTime;
                    //判断是否已存在记录,若已存在则时间点以当前最大应随访时间开始计算
                    if (myRec != null)
                    {
                        ExistRecord = myRec[myRec.Length - 1].Requested_time;
                        ExistTimes  = TimesCount = myRec.Length;
                        RecordTime  = Convert.ToDateTime(ExistRecord);
                    }
                    else
                    {
                        RecordTime = RefTime;
                        if (info.Defaultdays != "0")
                        {
                            RecordTime = RecordTime.AddDays(Convert.ToInt32(info.Defaultdays));
                            sql        = "insert into T_FOLLOW_RECORD(PATIENT_ID,SOLUTION_ID,CREATOR_ID,REQUESTED_TIME) VALUES(" + pid + "," + info.Id + "," + App.UserAccount.UserInfo.User_id + ",to_date('" + RecordTime.ToShortDateString() + "','yyyy-MM-dd'))";
                            Batch.Add(sql);
                            ExistTimes++;
                        }
                    }

                    int MinusTime2 = (int)(NowTime - RecordTime).TotalDays;


                    if (info.Definefollows != "")
                    {
                        string[] Items = info.Definefollows.Split(',');
                        for (int i = 0; i < Items.Length; i++)
                        {
                            if (MinusTime2 < 0)
                            {
                                break;
                            }
                            if (TimesCount != 0)
                            {
                                //若最后一条记录设置了下次随访时间
                                if (TimesCount == 1)
                                {
                                    if (myRec[myRec.Length - 1].Next_time != "")
                                    {
                                        if (myRec[myRec.Length - 1].Is_timeset == "1")
                                        {
                                            RecordTime = Convert.ToDateTime(myRec[myRec.Length - 1].Next_time);
                                            sql        = "insert into t_follow_record(patient_id,solution_id,creator_id,requested_time) values(" + pid + "," + sid + "," + App.UserAccount.UserInfo.User_id + ",to_date('" + RecordTime.ToShortDateString() + "','yyyy-MM-dd'))";
                                            Batch.Add(sql);
                                            ExistTimes++;
                                        }
                                        if (myRec[myRec.Length - 1].Is_timeset == "0")
                                        {
                                            RecordTime = Convert.ToDateTime(myRec[myRec.Length - 1].Next_time);
                                        }
                                    }
                                    MinusTime2 = (int)(NowTime - RecordTime).TotalDays;
                                }
                                if (i >= Items.Length - 1)
                                {
                                    i--;
                                }
                                TimesCount--;
                                continue;
                            }
                            //判断是否符合方案的结束条件
                            if (info.FinishType != "")
                            {
                                if (info.FinishType.IndexOf("次") != -1)
                                {
                                    if (ExistTimes >= Convert.ToInt32(info.FinishType.Substring(0, info.FinishType.IndexOf("次"))))
                                    {
                                        break;
                                    }
                                }
                                else
                                {
                                    int      span2    = 0;
                                    TimeSpan tempSpan = RecordTime - RefTime;
                                    span2 = (int)tempSpan.TotalDays + Convert.ToInt32(info.Defaultdays);
                                    int span1 = 0;
                                    if (info.FinishType.IndexOf("年") != -1)
                                    {
                                        span1 = Convert.ToInt32(info.FinishType.Substring(0, info.FinishType.IndexOf("年"))) * 365;
                                    }
                                    if (info.FinishType.IndexOf("月") != -1)
                                    {
                                        span1 = Convert.ToInt32(info.FinishType.Substring(0, info.FinishType.IndexOf("月"))) * 30;
                                    }
                                    if (info.FinishType.IndexOf("天") != -1)
                                    {
                                        span1 = Convert.ToInt32(info.FinishType.Substring(0, info.FinishType.IndexOf("天")));
                                    }
                                    if (span1 <= span2)
                                    {
                                        break;
                                    }
                                }
                            }

                            string Span = "";
                            if (i >= Items.Length)
                            {
                                i = Items.Length - 1;
                            }
                            Span = Items[i];
                            if (Span.IndexOf("年") != -1)
                            {
                                RecordTime = RecordTime.AddYears(Convert.ToInt32(Span.Substring(0, Span.IndexOf("年"))));
                                sql        = "insert into T_FOLLOW_RECORD(PATIENT_ID,SOLUTION_ID,CREATOR_ID,REQUESTED_TIME) VALUES(" + pid + "," + info.Id + "," + App.UserAccount.UserInfo.User_id + ",to_date('" + RecordTime.ToShortDateString() + "','yyyy-MM-dd'))";
                                Batch.Add(sql);
                                ExistTimes++;
                                MinusTime2 = (int)(NowTime - RecordTime).TotalDays;
                            }
                            if (Span.IndexOf("月") != -1)
                            {
                                RecordTime = RecordTime.AddMonths(Convert.ToInt32(Span.Substring(0, Span.IndexOf("月"))));
                                sql        = "insert into T_FOLLOW_RECORD(PATIENT_ID,SOLUTION_ID,CREATOR_ID,REQUESTED_TIME) VALUES(" + pid + "," + info.Id + "," + App.UserAccount.UserInfo.User_id + ",to_date('" + RecordTime.ToShortDateString() + "','yyyy-MM-dd'))";
                                Batch.Add(sql);
                                ExistTimes++;
                                MinusTime2 = (int)(NowTime - RecordTime).TotalDays;
                            }
                            if (Span.IndexOf("天") != -1)
                            {
                                RecordTime = RecordTime.AddDays(Convert.ToInt32(Span.Substring(0, Span.IndexOf("天"))));
                                sql        = "insert into T_FOLLOW_RECORD(PATIENT_ID,SOLUTION_ID,CREATOR_ID,REQUESTED_TIME) VALUES(" + pid + "," + info.Id + "," + App.UserAccount.UserInfo.User_id + ",to_date('" + RecordTime.ToShortDateString() + "','yyyy-MM-dd'))";
                                Batch.Add(sql);
                                ExistTimes++;
                                MinusTime2 = (int)(NowTime - RecordTime).TotalDays;
                            }
                            if (i >= Items.Length - 1)
                            {
                                i--;
                            }
                        }
                    }
                    else
                    {
                        while (true)
                        {
                            string Span = info.Followtype;
                            if (MinusTime2 < 0)
                            {
                                break;
                            }
                            if (TimesCount != 0)
                            {
                                //若最后一条记录设置了下次随访时间
                                if (TimesCount == 1)
                                {
                                    if (myRec[myRec.Length - 1].Next_time != "")
                                    {
                                        RecordTime = Convert.ToDateTime(myRec[myRec.Length - 1].Next_time);
                                        sql        = "insert into t_follow_record(patient_id,solution_id,creator_id,requested_time) values(" + pid + "," + sid + "," + App.UserAccount.UserInfo.User_id + ",to_date('" + RecordTime.ToShortDateString() + "','yyyy-MM-dd'))";
                                        Batch.Add(sql);
                                        ExistTimes++;
                                    }
                                    MinusTime2 = (int)(NowTime - RecordTime).TotalDays;
                                }
                                TimesCount--;
                                continue;
                            }
                            if (info.FinishType != "")
                            {
                                if (info.FinishType.IndexOf("次") != -1)
                                {
                                    if (ExistTimes >= Convert.ToInt32(info.FinishType.Substring(0, info.FinishType.IndexOf("次"))))
                                    {
                                        break;
                                    }
                                }
                                else
                                {
                                    int      span2    = 0;
                                    TimeSpan tempSpan = RecordTime - RefTime;
                                    span2 = (int)tempSpan.TotalDays + Convert.ToInt32(info.Defaultdays);
                                    int span1 = 0;
                                    if (info.FinishType.IndexOf("年") != -1)
                                    {
                                        span1 = Convert.ToInt32(info.FinishType.Substring(0, info.FinishType.IndexOf("年"))) * 365;
                                    }
                                    if (info.FinishType.IndexOf("月") != -1)
                                    {
                                        span1 = Convert.ToInt32(info.FinishType.Substring(0, info.FinishType.IndexOf("月"))) * 30;
                                    }
                                    if (info.FinishType.IndexOf("天") != -1)
                                    {
                                        span1 = Convert.ToInt32(info.FinishType.Substring(0, info.FinishType.IndexOf("天")));
                                    }
                                    if (span1 <= span2)
                                    {
                                        break;
                                    }
                                }
                            }

                            if (info.Followtype.IndexOf("年") != -1)
                            {
                                RecordTime = RecordTime.AddYears(Convert.ToInt32(info.Followtype.Substring(0, info.Followtype.IndexOf("年"))));
                                sql        = "insert into T_FOLLOW_RECORD(PATIENT_ID,SOLUTION_ID,CREATOR_ID,REQUESTED_TIME) VALUES(" + pid + "," + info.Id + "," + App.UserAccount.UserInfo.User_id + ",to_date('" + RecordTime.ToShortDateString() + "','yyyy-MM-dd'))";
                                Batch.Add(sql);
                                ExistTimes++;
                                MinusTime2 = (int)(NowTime - RecordTime).TotalDays;
                            }
                            if (info.Followtype.IndexOf("月") != -1)
                            {
                                RecordTime = RecordTime.AddMonths(Convert.ToInt32(info.Followtype.Substring(0, info.Followtype.IndexOf("月"))));
                                sql        = "insert into T_FOLLOW_RECORD(PATIENT_ID,SOLUTION_ID,CREATOR_ID,REQUESTED_TIME) VALUES(" + pid + "," + info.Id + "," + App.UserAccount.UserInfo.User_id + ",to_date('" + RecordTime.ToShortDateString() + "','yyyy-MM-dd'))";
                                Batch.Add(sql);
                                ExistTimes++;
                                MinusTime2 = (int)(NowTime - RecordTime).TotalDays;
                            }
                            if (info.Followtype.IndexOf("天") != -1)
                            {
                                RecordTime = RecordTime.AddDays(Convert.ToInt32(info.Followtype.Substring(0, info.Followtype.IndexOf("天"))));
                                sql        = "insert into T_FOLLOW_RECORD(PATIENT_ID,SOLUTION_ID,CREATOR_ID,REQUESTED_TIME) VALUES(" + pid + "," + info.Id + "," + App.UserAccount.UserInfo.User_id + ",to_date('" + RecordTime.ToShortDateString() + "','yyyy-MM-dd'))";
                                Batch.Add(sql);
                                ExistTimes++;
                                MinusTime2 = (int)(NowTime - RecordTime).TotalDays;
                            }
                        }
                    }
                }

                #endregion
                string[] final = new string[Batch.Count];
                for (int j = 0; j < Batch.Count; j++)
                {
                    final[j] = Batch[j].ToString();
                }

                App.ExecuteBatch(final);
            }
            catch (Exception ex)
            {
                App.MsgErr(ex.Message);
            }
        }
예제 #18
0
 internal Record16(byte item, RecordDate date, RecordTime time, ushort value) : base(item, date, time)
 {
     Value = value;
 }
예제 #19
0
        private async Task <Response> ProcessFile(string file)
        {
            var path  = System.Web.HttpContext.Current.Server.MapPath(file);
            var lines = System.IO.File.ReadAllLines(path);
            var log   = string.Empty;

            using (var transaction = db.Database.BeginTransaction())
            {
                try
                {
                    int lineNumber = 0;
                    foreach (var line in lines)
                    {
                        try
                        {
                            var fields     = line.Split(',');
                            var recordTime = new RecordTime
                            {
                                EmployeeId = int.Parse(fields[0]),
                                DateStart  = DateTime.Parse(fields[1]),
                                DateEnd    = DateTime.Parse(fields[2]),
                            };

                            var oldRecord = await db.RecordTimes.
                                            Where(r => r.EmployeeId == recordTime.EmployeeId &&
                                                  r.DateStart == recordTime.DateStart &&
                                                  r.DateEnd == recordTime.DateEnd).
                                            FirstOrDefaultAsync();

                            if (oldRecord == null)
                            {
                                db.RecordTimes.Add(recordTime);
                            }
                        }
                        catch (Exception ex)
                        {
                            log += $"EROR Línea: {lineNumber}, {ex.Message}\n";
                        }

                        lineNumber++;
                    }

                    await db.SaveChangesAsync();

                    transaction.Commit();
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    ex.ToString();
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = ex.ToString(),
                    });
                }
            }

            return(new Response
            {
                IsSuccess = true,
                Message = log,
            });
        }