Ejemplo n.º 1
0
        public static void SaveRecord(RecordView recordToSave)
        {
            RecordDAL   recordHandler = new RecordDAL();
            Random      _random       = new Random();
            VaccineView recordVaccine = recordToSave.Vaccines.FirstOrDefault();

            if (recordVaccine != null)
            {
                VaccineView vaccine = VaccineManager.GetVaccine(recordVaccine.Name);
                if (vaccine != null)
                {
                    Record record = new Record
                    {
                        isVaccine    = true,
                        recordNumber = "RCRD" + _random.Next(20, 300),
                        notes        = "",
                        petId        = new Guid(recordToSave.PetId),
                        status       = "open",
                        tags         = GetAnualTags(recordToSave.Tags, recordToSave.Vaccines),
                        type         = "vaccine",
                        vaccineId    = new Guid(vaccine.Id),
                        createdDate  = DateTime.Now,
                        createdBy    = Constant.ADMIN_EMAIL,
                    };
                    recordHandler.Post(record);
                }
            }
        }
Ejemplo n.º 2
0
    // Used for checking exixtance of the Record in the Database
    public int checkExistance_BAL(int employeeid)
    {
        RecordDAL rDal = new RecordDAL();
            try
            {
                return rDal.checkExistance(employeeid);
            }
            catch (Exception ex)
            {
                throw;
            }

            finally
            {
                rDal = null;
            }
    }
Ejemplo n.º 3
0
    //Used for Inserting Record in the Database
    public int InsertRecord_BAL( string firstname, string lastname, DateTime dateofbirth,DateTime hiredate , string email, string phonenumber)
    {
        RecordDAL rDal = new RecordDAL();
         try
         {
             return rDal.InsertRecord( firstname,lastname, dateofbirth, hiredate, email, phonenumber);
         }

         catch
         {
             throw;
         }

         finally
         {
             rDal = null;
         }
    }
Ejemplo n.º 4
0
    public void DeleteEmployee(int employeeid)
    {
        RecordDAL rDal = new RecordDAL();
         try
         {
            rDal.DeleteEmployee(employeeid);
         }

         catch
         {
             throw;
         }

         finally
         {
             rDal = null;
         }
    }
Ejemplo n.º 5
0
    public DataTable RetrieveRecords()
    {
        //Creating the object of DAL file.

        RecordDAL rdAL = new  RecordDAL();
        try
          {

            //Calling the method of DAl using DAL object

            //and return the result to the caller of the method.

            return rdAL.RetrieveRecords();
        }
        catch
        {
            throw;
        }

        finally
        {
            //rdAL = null;
        }
    }
Ejemplo n.º 6
0
        //JSON数据格式
        //{
        //    Username: string
        //    Description:string
        //    Time:DateTime
        //    LocationStr string(四川_成都_郫县)
        //    Answers:string("010100")
        //    PicNames:string的JArray
        //}
        public void ProcessRequest(HttpContext context)
        {
            StreamReader reader     = new StreamReader(context.Request.InputStream, Encoding.UTF8);
            string       requestStr = reader.ReadToEnd();

            JObject  jObj        = JObject.Parse(requestStr);
            string   username    = jObj["Username"].ToString();
            string   description = jObj["Description"].ToString();
            DateTime time        = DateTime.Parse(jObj["Time"].ToString());
            string   locationStr = jObj["LocationStr"].ToString();
            string   answers     = jObj["Answers"].ToString();
            JArray   picNames    = JArray.Parse(jObj["PicNames"].ToString());

            //添加到自检记录
            RecordModel record = new RecordModel();

            record.Answers     = answers;
            record.Description = description;

            //如果locationStr为null,则返回"000000"(中国),否则解析并保存
            if (string.IsNullOrEmpty(locationStr))
            {
                record.Citycode = "000000";
            }
            else
            {
                record.Citycode = LocationDAL.GetLocalId(locationStr);
            }

            record.Time    = time;
            record.User_id = UserDAL.GetByUsername(username).User_id;
            long record_id = RecordDAL.Insert(record);

            //添加自检图片
            foreach (string picName in picNames)
            {
                PhotoModel photo = new PhotoModel();
                photo.Path      = picName;
                photo.Record_id = record_id;
                PhotoDAL.Insert(photo);
            }

            //返回Record_id给移动端
            JObject jObjSend = new JObject();

            jObjSend.Add("Record_id", record_id);

            byte[] buf = Encoding.UTF8.GetBytes(jObjSend.ToString());
            context.Response.OutputStream.Write(buf, 0, buf.Length);

            Thread thread = new Thread(() =>
            {
                List <CVResultModel> results = new List <CVResultModel>();

                //检查图片是否分析完成(是否Insert到CVResult中)
                const int WAIT_TIME = 240;   //等待时间(如果240秒某张图片都没有传输成功且分析完成,则放弃)
                foreach (string picName in picNames)
                {
                    //轮询
                    for (int i = 0; i < WAIT_TIME; i++)
                    {
                        if (null != CVResultDAL.GetById(picName))
                        {
                            results.Add(CVResultDAL.GetById(picName));
                            break;
                        }
                        Thread.Sleep(1000);
                    }
                }

                //计算分数并保存
                float score = ScoreUtil.GetScore(results);
                RecordDAL.UpdateScore(score, record_id);
            });

            thread.Start();
        }
Ejemplo n.º 7
0
        public static List <RecordView> GetRecords(string name)
        {
            List <RecordView> recordViews   = new List <RecordView>();
            RecordDAL         recordHandler = new RecordDAL();
            PetDAL            petHandler    = new PetDAL();
            List <Record>     records       = recordHandler.GetList();
            List <Pet>        petList       = petHandler.GetList();
            Pet pet = petList.Where(p => p.name.Trim() == name).FirstOrDefault();

            if (pet != null && !string.IsNullOrEmpty(pet.name))
            {
                records = records.Where(r => r.petId == pet.id).ToList();
                foreach (Record record in records)
                {
                    RecordView recordView = new RecordView()
                    {
                        Id                         = record.id.ToString(),
                        IsVaccine                  = record.isVaccine.Value,
                        Name                       = record.recordNumber == null ? "" : record.recordNumber.Trim(),
                        Notes                      = record.notes == null ? "" : record.notes.Trim(),
                        RecordNumber               = record.recordNumber.Trim(),
                        Status                     = record.status == null ? "" : record.status.Trim(),
                        Tags                       = record.tags != null?record.tags.Split(',').ToList() : new List <string>(),
                                              Type = record.type == null ? "" : record.type.Trim(),
                    };
                    if (record.isVaccine.Value)
                    {
                        VaccineDAL     vaccineHandler = new VaccineDAL();
                        List <Vaccine> vaccines       = vaccineHandler.GetList();
                        vaccines = vaccines.Where(v => v.id == record.vaccineId).ToList();
                        List <VaccineView> vaccineViews = new List <VaccineView>();
                        foreach (var vaccine in vaccines)
                        {
                            vaccineViews.Add(new VaccineView
                            {
                                Cost        = vaccine.cost.ToString(),
                                Description = vaccine.description == null ? "" : vaccine.description.Trim(),
                                Disease     = vaccine.disease == null ? "" : vaccine.disease.Trim(),
                                Id          = vaccine.id.ToString(),
                                Living      = vaccine.living == true ? "Is living" : "Not living",
                                Name        = vaccine.name == null ? "" : vaccine.name.Trim(),
                                Preparation = vaccine.preparation == null ? "" : vaccine.preparation.Trim(),
                                Type        = vaccine.type == null ? "" : vaccine.type.Trim(),
                            });
                        }
                        recordView.Vaccines = vaccineViews;
                    }
                    recordView.Tags = recordView.Tags.Select(s => s.Trim()).ToList();

                    recordViews.Add(recordView);
                }
            }

            if (recordViews.Count >= 1)
            {
                return(recordViews);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 窗口加载时:通过GET请求的"record_id"参数到数据库取得相应的自检信息并显示
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
            long record_id;

            if (long.TryParse(Request.Params["record_id"], out record_id))
            {
                //调用数据库访问类查询该主键对应的自检记录
                RecordModel  record = RecordDAL.GetById(record_id);
                PhotoModel[] photos = PhotoDAL.GetAllByRecordId(record_id);

                //原图片
                List <string> srcUrls = new List <string>();
                List <string> dstUrls = new List <string>();
                foreach (var photo in photos)
                {
                    srcUrls.Add("~/ImageWebForm.aspx?fileType=src&picName=" + photo.Path);
                    dstUrls.Add("~/ImageWebForm.aspx?fileType=dst&picName=" + photo.Path);
                }

                //将图片绑定到控件上
                dl_srcImgs.DataSource = srcUrls;
                dl_srcImgs.DataBind();

                dl_dstImgs.DataSource = dstUrls;
                dl_dstImgs.DataBind();

                //取得该自检对应图片的所有处理结果
                List <CVResultModel> results = new List <CVResultModel>();
                foreach (var photo in photos)
                {
                    var result = CVResultDAL.GetById(photo.Path);
                    if (result != null)
                    {
                        results.Add(result);
                    }
                }

                //分析处理结果
                float score = ScoreUtil.GetScore(results);

                //结论
                StringBuilder builder = new StringBuilder();
                //builder.AppendFormat("系统分析得分:{0:f2}", score).AppendLine();
                var group = Severity.Group(score);
                switch (group)
                {
                case Severity.SeverityEnum.Normal:
                    builder.AppendLine("牙齿正常,请注意保持");
                    break;

                case Severity.SeverityEnum.Light:
                    builder.AppendLine("有少量龋齿或程度较轻");
                    break;

                case Severity.SeverityEnum.Medium:
                    builder.AppendLine("有一定龋齿或程度中等");
                    break;

                case Severity.SeverityEnum.Severe:
                    builder.AppendLine("有大量龋齿或龋坏严重");
                    break;

                default:
                    break;
                }

                if (group != Severity.SeverityEnum.Normal)
                {
                    builder.AppendLine("可能为色素沉着,牙石或牙垢,保持口腔清洁或前往正规医院洗牙可以让结果更准确");
                }
                lbl_conclusion.Text = builder.ToString().Replace(Environment.NewLine, "<br>");

                //医生意见
                DiagnosisModel[] diagnoses = DiagnosisDAL.GetAllByRecordId(record_id);
                List <string>    comments  = new List <string>();
                foreach (var diagnosis in diagnoses)
                {
                    string item = string.Format("{0} {1}", diagnosis.Time.ToString(), DoctorDAL.GetById(diagnosis.Doc_id).RealName)
                                  + Environment.NewLine + diagnosis.Result;
                    comments.Add(item);
                }
                dl_comments.DataSource = comments;
                dl_comments.DataBind();
            }
            else
            {
                //record_id出错
            }
        }
Ejemplo n.º 9
0
        public void ProcessRequest(HttpContext context)
        {
            StreamReader reader     = new StreamReader(context.Request.InputStream, Encoding.UTF8);
            string       requestStr = reader.ReadToEnd();

            //返回所有自检结果,其中本地区的置前
            if ("ListAll".Equals(requestStr))
            {
                ////获取IP地理信息
                //string hostIP = context.Request.UserHostAddress;
                //IPRecord ip = HttpHelper.GetIPRecord(hostIP);

                ////通过IP地理信息获取所在区域的编号
                //RecordModel[] recordModels = null;
                //if (string.IsNullOrEmpty(ip.Province))
                //{
                //    //返回所有的自检
                //    recordModels = RecordDAL.GetAll();
                //}
                //else if (string.IsNullOrEmpty(ip.City))
                //{
                //    //返回指定省份的自检
                //    recordModels = RecordDAL.GetAllProvinceFirst(ip.Province);
                //}
                //else if (string.IsNullOrEmpty(ip.District))
                //{
                //    //返回指定城市的自检
                //    recordModels = RecordDAL.GetAllCityFirst(ip.City);
                //}
                //else
                //{
                //    //返回指定区域的自检
                //    recordModels = RecordDAL.GetAllAreaFirst(ip.District);
                //}

                RecordModel[] recordModels = RecordDAL.GetAll();
                JObject       jObj         = new JObject();
                jObj.Add("count", recordModels.Length);
                JArray jArr = new JArray();
                foreach (RecordModel recordModel in recordModels)
                {
                    jArr.Add(JsonConvert.SerializeObject(new ExRecordModel(recordModel)));
                }
                jObj.Add("content", jArr);

                byte[] bytes = Encoding.UTF8.GetBytes(jObj.ToString());
                context.Response.OutputStream.Write(bytes, 0, bytes.Length);
            }
            else if (requestStr.StartsWith("Patient: "))
            {
                //返回指定用户的自检信息
                string        username     = requestStr.Substring("Patient: ".Length);
                RecordModel[] recordModels = RecordDAL.GetByUsername(username);

                JObject jObj = new JObject();
                jObj.Add("count", recordModels.Length);
                JArray jArr = new JArray();
                foreach (RecordModel recordModel in recordModels)
                {
                    jArr.Add(JsonConvert.SerializeObject(recordModel));
                }
                jObj.Add("content", jArr);

                byte[] bytes = Encoding.UTF8.GetBytes(jObj.ToString());
                context.Response.OutputStream.Write(bytes, 0, bytes.Length);
            }
            else if (requestStr.StartsWith("Record_id: "))
            {
                //返回指定编号的自检信息
                long record_id;
                if (long.TryParse(requestStr.Substring("Record_id: ".Length), out record_id))
                {
                    var record = RecordDAL.GetById(record_id);

                    string json = JsonConvert.SerializeObject(record);

                    byte[] bytes = Encoding.UTF8.GetBytes(json);
                    context.Response.OutputStream.Write(bytes, 0, bytes.Length);
                }
            }
            else
            {
                //返回指定id对应的自检图片
                long         id     = long.Parse(requestStr);
                PhotoModel[] photos = PhotoDAL.GetAllByRecordId(id);
                JObject      jObj   = new JObject();
                jObj.Add("count", photos.Length);
                JArray jArr = new JArray();
                foreach (PhotoModel photo in photos)
                {
                    jArr.Add(JsonConvert.SerializeObject(photo));
                }
                jObj.Add("content", jArr);

                byte[] bytes = Encoding.UTF8.GetBytes(jObj.ToString());
                context.Response.OutputStream.Write(bytes, 0, bytes.Length);
            }
        }
Ejemplo n.º 10
0
    //Updating Record
    public int UpdateRecord_BAL( int employeeid, string firstname, string lastname, string email, Int32 phonenumber)
    {
        RecordDAL rDal = new RecordDAL();
         try
          {
              return rDal.UpdateRecord( employeeid, firstname, lastname, email, phonenumber);
          }

        catch
        {
            throw;
        }

        finally
        {
            rDal = null;
        }
    }