コード例 #1
0
        /// <summary>
        /// 生日提醒任务
        /// </summary>
        /// <param name="state"></param>
        private void BirthdayRemind(object state)
        {
            if ((DateTime.Now - lastRemindTime).TotalSeconds >= 60) //1分钟提醒一次
            {
                var dtUser = Tmo_FakeEntityManager.Instance.GetData("tmo_userinfo",
                                                                    new[] { "user_id", "name", "plan_birthday", "doc_id" },
                                                                    string.Format(
                                                                        "(birthday_remid_year is null or birthday_remid_year<{0}) and plan_birthday is not null and doc_id is not null",
                                                                        DateTime.Now.Year));
                if (TmoShare.DataTableIsNotEmpty(dtUser))
                {
                    foreach (DataRow dr in dtUser.Rows)
                    {
                        DateTime birthday = dr.GetDataRowDateTimeValue("plan_birthday");
                        if (birthday.Month == DateTime.Now.Month && birthday.Day == DateTime.Now.Day) //过生日
                        {
                            string userid = dr.GetDataRowStringValue("user_id");
                            string name   = dr.GetDataRowStringValue("name");
                            string docid  = dr.GetDataRowStringValue("doc_id");
                            PushInvoke.SendDocInvoke(docid, 102, userid + ";" + name);
                        }
                    }
                }

                lastRemindTime = DateTime.Now;
            }

            ((ManualResetEvent)((object[])state)[0]).Set();
        }
コード例 #2
0
 /// <summary>
 /// 刷新子医生
 /// </summary>
 public void RefreshDocChildrenID()
 {
     if (TmoComm.login_docInfo != null)
     {
         string childrenDpt = TmoComm.login_docInfo.children_department;
         if (string.IsNullOrWhiteSpace(childrenDpt))
         {
             childrenDpt += "-1";
         }
         else
         {
             childrenDpt += ",-1";
         }
         DataTable     dtDocId = Tmo_FakeEntityClient.Instance.GetData("tmo_docinfo", new[] { "doc_id" }, "doc_department in (" + childrenDpt + ")");
         List <string> list    = new List <string>();
         list.Add(TmoComm.login_docInfo.doc_id.ToString());
         if (TmoShare.DataTableIsNotEmpty(dtDocId))
         {
             foreach (DataRow dr in dtDocId.Rows)
             {
                 string val = dr.GetDataRowStringValue("doc_id");
                 if (string.IsNullOrWhiteSpace(val))
                 {
                     continue;
                 }
                 list.Add(val);
             }
         }
         TmoComm.login_docInfo.children_docid = StringPlus.GetArrayStr(list, ",");
     }
 }
コード例 #3
0
        private void ComboBoxBind()
        {
            try
            {
                DataTable wzds = TmoServiceClient.InvokeServerMethodT <DataSet>(funCode.GetPublicList, "tmo_product_type", "is_del='1' ").Tables[0];

                if (TmoShare.DataTableIsNotEmpty(wzds))
                {
                    this.BindDataTable(productType, wzds, "type_name", "type_id");
                }
                DataTable ztdt = TmoServiceClient.InvokeServerMethodT <DataSet>(funCode.GetPublicList, "tmo_product_list", " is_del='1' ").Tables[0];

                if (TmoShare.DataTableIsNotEmpty(ztdt))
                {
                    this.BindDataTable(productId, ztdt, "product_name", "product_id");
                }
                DataTable ysdt = Tmo_FakeEntityClient.Instance.GetData("tmo_sell_list", new[] { "distinct(doc_code) as doc_code" }, "is_del='1'");
                if (TmoShare.DataTableIsNotEmpty(ysdt))
                {
                    this.BindDataTable(docCode, ysdt, "doc_code", "doc_code");
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #4
0
        /// <summary>
        /// 消息推送任务
        /// </summary>
        /// <param name="state"></param>
        private void PushMessage(object state)
        {
            if ((DateTime.Now - lastPushMsgTime).TotalSeconds >= 30) //30秒检查一次
            {
                var dtMsg = Tmo_FakeEntityManager.Instance.GetData("tmo_pushmsg", new[] { "id", "doc_code", "doc_department", "doc_group", "read_user" },
                                                                   "isRead='1' and input_time>=date_sub(NOW(),INTERVAL 1 MONTH);");
                if (TmoShare.DataTableIsNotEmpty(dtMsg))
                {
                    foreach (TCPServerClient client in TCPServer.Instance.Clients.ToArray())
                    {
                        if (client.DocInfo != null)
                        {
                            DataRow[] rows = dtMsg.Select(
                                string.Format(
                                    "doc_code='{0}' or (doc_department LIKE '%,{1},%' and (read_user not like '%,{0},%' or read_user is null)) or (doc_group='{2}' and (read_user not like '%,{0},%' or read_user is null))",
                                    client.DocInfo.doc_loginid, client.DocInfo.doc_department, client.DocInfo.doc_group));
                            if (rows.Length > 0)
                            {
                                //有消息推送
                                PushInvoke.SendDocInvoke(client.DocInfo.doc_id.ToString(), 103, rows.Length.ToString());
                            }
                        }
                    }
                }

                lastPushMsgTime = DateTime.Now;
            }

            ((ManualResetEvent)((object[])state)[0]).Set();
        }
コード例 #5
0
 /// <summary>
 /// 加载数据
 /// </summary>
 public void GetData()
 {
     this.ShowWaitingPanel(() =>
     {
         try
         {
             string strmlx = TmoServiceClient.InvokeServerMethodT <string>(funCode.GetMedicalInUser, new object[] { _user_id, _dc });
             DataTable dt  = TmoShare.getDataTableFromXML(strmlx);
             if (TmoShare.DataTableIsNotEmpty(dt))
             {
                 return(dt);
             }
             return(null);
         }
         catch
         { }
         return(null);
     }, x =>
     {
         try
         {
             DataTable dt = x as DataTable;
             SetPiont(dt);
         }
         catch (Exception ex)
         {
             LogHelper.Log.Error("实体加载数据出错", ex);
             DXMessageBox.ShowWarning2("数据加载失败!请重试!");
         }
     });
 }
コード例 #6
0
        private void SendDataTh()
        {
            while (true)
            {
                try
                {
                    DataTable sendData = Tmo_FakeEntityManager.Instance.GetData("tmo_push_list", null, null, null, null, null, false, 64); //得到需要发送的数据

                    if (TmoShare.DataTableIsNotEmpty(sendData))                                                                            //判断是否有数据
                    {                                                                                                                      //有数据
                        SendMessage("开始推送...");
                        DataRowCollection drs        = sendData.Rows;
                        WaitHandle[]      doneEvents = new WaitHandle[drs.Count];

                        for (int i = 0; i < drs.Count; i++)              //遍历每行数据
                        {
                            doneEvents[i] = new ManualResetEvent(false); //非终止事件状态
                            WaitCallback threadPoolCallBack = new WaitCallback(SendItemData);
                            ThreadPool.QueueUserWorkItem(threadPoolCallBack, new object[] { doneEvents[i], drs[i] });
                        }
                        WaitHandle.WaitAll(doneEvents); //等待线程池中线程执行完毕
                        SendMessage("结束本次推送!");
                    }
                }
                catch { }
                Thread.Sleep(scanInerval);
            }
        }
コード例 #7
0
        /// <summary>
        /// 获得群组层级
        /// </summary>
        /// <param name="groupId"></param>
        /// <returns></returns>
        public int GetGroupLevel(int groupId)
        {
            DataTable dt = Tmo_FakeEntityClient.Instance.GetData("tmo_docgroup", null, null, "group_id", groupId.ToString());

            if (TmoShare.DataTableIsNotEmpty(dt))
            {
                DataRow dr = dt.Rows[0];
                return(dr.GetDataRowIntValue("group_level"));
            }
            return(-1);
        }
コード例 #8
0
        private void ComboBoxBind()
        {
            try
            {
                DataTable wzds = TmoServiceClient.InvokeServerMethodT <DataSet>(funCode.GetPublicList, "tmo_product_type", "is_del='1' ").Tables[0];

                if (TmoShare.DataTableIsNotEmpty(wzds))
                {
                    this.BindDataTable(productType, wzds, "type_name", "type_id");
                }

                DataTable ztdt = TmoServiceClient.InvokeServerMethodT <DataSet>(funCode.GetPublicList, "tmo_product_list", " is_del='1' ").Tables[0];

                if (TmoShare.DataTableIsNotEmpty(ztdt))
                {
                    this.BindDataTable(productName, ztdt, "product_name", "product_id");
                }

                DataTable ysdt = Tmo_FakeEntityClient.Instance.GetData("tmo_sell_list", new[] { "distinct(doc_code) as doc_code" }, "is_del='1'");
                if (TmoShare.DataTableIsNotEmpty(ysdt))
                {
                    this.BindDataTable(docName, ysdt, "doc_code", "doc_code");
                }

                var param = new FE_GetDataParam()
                {
                    Columns        = { "distinct(tmo_sell_list.identity)", "name" },
                    Sources        = "tmo_sell_list",
                    JoinConditions = { new JoinCondition()
                                       {
                                           JoinType = EmJoinType.LeftJoin, Table = "tmo_userinfo", OnCol = "identity"
                                       } }
                };
                param.AddWhere("tmo_sell_list.is_del='1'");

                DataSet ds = Tmo_FakeEntityClient.Instance.GetData(param);
                if (TmoShare.DataSetIsNotEmpty(ds))
                {
                    if (ds.Tables.Contains("tmo_data"))
                    {
                        DataTable yhdt = ds.Tables["tmo_data"];
                        if (TmoShare.DataTableIsNotEmpty(yhdt))
                        {
                            this.BindDataTable(receiveCode, yhdt, "name", "identity");
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #9
0
        public static string GetDataUser(string userid, string suertime)
        {
            DataTable dt = tmo_tuijianManager.Instance.GetDataUser(userid, suertime);

            if (TmoShare.DataTableIsNotEmpty(dt))
            {
                return(TmoShare.getXMLFromDataTable(dt));
            }
            else
            {
                return("");
            }
        }
コード例 #10
0
        public static string getTuiData()
        {
            DataTable dt = tmo_tuijianManager.Instance.GetData();

            if (TmoShare.DataTableIsNotEmpty(dt))
            {
                return(TmoShare.getXMLFromDataTable(dt));
            }
            else
            {
                return("");
            }
        }
コード例 #11
0
        public void loadData(DataRow dr)
        {
            string user_name = dr.GetDataRowStringValue("name");

            this.lblName.Text = user_name;
            this.ShowWaitingPanel(() =>
            {
                userid         = dr["user_id"].ToString();
                userTime       = dr["user_times"].ToString();
                string xmlData = TmoServiceClient.InvokeServerMethodT <string>(funCode.GetAttach, new object[] { userid, userTime, "new" });
                return(xmlData);
            }, xml =>
            {
                string xmlData = xml?.ToString();
                if (!string.IsNullOrWhiteSpace(xmlData))
                {
                    DataTable dt = TmoShare.getDataTableFromXML(xmlData);
                    if (TmoShare.DataTableIsNotEmpty(dt))
                    {
                        DataRow drData = dt.Rows[0];
                        atId           = drData.GetDataRowStringValue("att_id");
                        if (!string.IsNullOrWhiteSpace(atId))
                        {
                            Up(); //判断是否是更新
                        }
                        var fileName = drData.GetDataRowStringValue("filename");
                        downBytes    = drData["content_bt"] as byte[];
                        if (string.IsNullOrEmpty(fileName) || downBytes == null || downBytes.Length == 0)
                        {
                            lblTips.Text = "当前文件已经失效,请重新上传!";
                        }
                        else
                        {
                            downExName    = fileName.Substring(fileName.IndexOf('.'));
                            Stream stream = new MemoryStream(downBytes);
                            LoadPdfOrWord(stream, downExName);
                            lblTips.Text = String.Empty;
                        }
                    }
                    else
                    {
                        lblTips.Text = "当前文件已经失效,请重新上传!";
                    }
                }
                else
                {
                    lblTips.Text = "还未上传检查报告单";
                }
            }, "文件下载中");
        }
コード例 #12
0
        public static string GetMedicalIn(string xml)
        {
            DataTable dt = tmo_medical_inManager.Instance.GetDataUser(xml);

            if (TmoShare.DataTableIsNotEmpty(dt))
            {
                dt.TableName = "cc";
                return(TmoShare.getXMLFromDataTable(dt));
            }
            else
            {
                return("");
            }
        }
コード例 #13
0
        private void ComboBoxBind()
        {
            try
            {
                DataTable wzds = TmoServiceClient.InvokeServerMethodT <DataSet>(funCode.GetPublicList, "tmo_product_type", "is_del='1' ").Tables[0];

                if (TmoShare.DataTableIsNotEmpty(wzds))
                {
                    this.BindDataTable(type_id, wzds, "type_name", "type_id");
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #14
0
        /// <summary>
        /// 获得医生信息
        /// </summary>
        /// <returns></returns>
        public DocInfo GetDocInfo(string uidordocid, string pwd = "-1")
        {
            if (string.IsNullOrWhiteSpace(uidordocid))
            {
                return(null);
            }
            // DocInfo doc = TmoReomotingClient.InvokeServerMethodT<DocInfo>(funCode.CheckDocAuth, uidordocid, pwd);
            DocInfo doc = TCPClient.Instance.Login(uidordocid, pwd);

            if (doc == null)
            {
                return(null);
            }

            if (doc.err_Code == 0)
            {
                string childrenDpt = Instance.GetChildrenNodeFromTable("tmo_department", "dpt_id", "dpt_parent", doc.doc_department.ToString(), false);
                if (string.IsNullOrWhiteSpace(childrenDpt))
                {
                    doc.children_department = doc.doc_department.ToString();
                    childrenDpt            += "-1";
                }
                else
                {
                    doc.children_department = childrenDpt;
                    childrenDpt            += ",-1";
                }
                DataTable     dtDocId = Tmo_FakeEntityClient.Instance.GetData("tmo_docinfo", new[] { "doc_id" }, "doc_department in (" + childrenDpt + ")");
                List <string> list    = new List <string>();
                list.Add(doc.doc_id.ToString());
                if (TmoShare.DataTableIsNotEmpty(dtDocId))
                {
                    foreach (DataRow dr in dtDocId.Rows)
                    {
                        string val = dr.GetDataRowStringValue("doc_id");
                        if (string.IsNullOrWhiteSpace(val))
                        {
                            continue;
                        }
                        list.Add(val);
                    }
                }
                doc.children_docid = StringPlus.GetArrayStr(list, ",");
                //doc.children_department += "," + doc.doc_department;
                doc.doc_group_level = Instance.GetGroupLevel(doc.doc_group);
            }
            return(doc);
        }
コード例 #15
0
        void produtType_SelectedIndexChanged(object sender, EventArgs e)
        {
            //绑定产品
            if (this.produtType.EditValue == null || this.produtType.EditValue.ToString() == "0")
            {
                return;
            }
            string typeID = this.produtType.EditValue.ToString();
            //所在市
            DataTable dtProduct = TmoServiceClient.InvokeServerMethodT <DataSet>(funCode.GetPublicList, "tmo_product_list", "type_id=" + typeID).Tables[0];

            if (TmoShare.DataTableIsNotEmpty(dtProduct))
            {
                this.BindDataTable(productId, dtProduct, "product_name", "product_id");
            }
        }
コード例 #16
0
        /// <summary>
        /// 定时更新年龄信息
        /// </summary>
        /// <param name="state"></param>
        private void CalAge(object state)
        {
            if (DateTime.Now.TimeOfDay.TotalMinutes < 30) //12点到12点半之间更新
            {
                int      timestmp = ConfigHelper.GetConfigInt("AgeUpTime", 0, true);
                DateTime lasTime  = DateTimeHelper.StampToTime(timestmp);
                if (DateTime.Today != lasTime.Date)
                {
                    var dtUser = Tmo_FakeEntityManager.Instance.GetData("tmo_userinfo", new[] { "user_id", "birthday" });
                    if (TmoShare.DataTableIsNotEmpty(dtUser))
                    {
                        List <string> sqlList = new List <string>();
                        foreach (DataRow row in dtUser.Rows)
                        {
                            string   userid    = row.GetDataRowStringValue("user_id");
                            DateTime birthTime = row.GetDataRowDateTimeValue("birthday");
                            if (birthTime == DateTime.MinValue || birthTime == DateTime.MaxValue)
                            {
                                string birthStr;
                                if (TmoShare.isIdCardNo(userid, out birthStr))
                                {
                                    birthTime = Convert.ToDateTime(birthStr);
                                }
                                else
                                {
                                    continue;
                                }
                            }

                            int age = TmoShare.CalAge(birthTime);
                            sqlList.Add(string.Format("update tmo_userinfo set age='{0}' where user_id='{1}'", age, userid));
                        }

                        int count = MySQLHelper.ExecuteSqlList(sqlList);
                        if (count > 0)
                        {
                            ConfigHelper.UpdateConfig("AgeUpTime", DateTimeHelper.TimeToStamp(DateTime.Now).ToString(), true);
                        }
                    }
                }
            }

            ((ManualResetEvent)((object[])state)[0]).Set();
        }
コード例 #17
0
        protected override void GetDataAfterSync(DataTable source)
        {
            base.GetDataAfterSync(source);
            if (TmoShare.DataTableIsNotEmpty(source))
            {
                foreach (DataRow row in source.Rows)
                {
                    string apid   = row.GetDataRowStringValue("apid");
                    int    status = row.GetDataRowIntValue("questionnare_status");
                    if (string.IsNullOrWhiteSpace(apid))
                    {
                        row["actionplan"] = "创建";
                        row["acstate"]    = "待创建";
                    }
                    else
                    {
                        if (status <= 3)
                        {
                            row["actionplan"] = "暂存";
                            row["acstate"]    = "暂存中";
                        }
                        else
                        {
                            row["actionplan"] = "浏览";

                            DateTime apsDate = row.GetDataRowDateTimeValue("apstartdate");
                            DateTime apeDate = row.GetDataRowDateTimeValue("apenddate");
                            if (apsDate == DateTime.MaxValue || apsDate == DateTime.MaxValue)
                            {
                                row["acstate"] = "未知";
                            }
                            else if (apsDate <= DateTime.Now && apeDate >= DateTime.Now)
                            {
                                row["acstate"] = "执行中";
                            }
                            else if (apeDate < DateTime.Now)
                            {
                                row["acstate"] = "已过期";
                            }
                        }
                    }
                }
            }
        }
コード例 #18
0
        private void ComboBoxBind()
        {
            try
            {
                DataTable wzds = TmoServiceClient.InvokeServerMethodT <DataSet>(funCode.GetPublicList, "tmo_web_aticle_type", " big_class='2' ").Tables[0];

                if (TmoShare.DataTableIsNotEmpty(wzds))
                {
                    this.BindDataTable(optType, wzds, "type_name", "type_id");
                }
                DataTable ztdt = TmoServiceClient.InvokeServerMethodT <DataSet>(funCode.GetPublicList, "tmo_web_aticle_type", " big_class='4' ").Tables[0];

                if (TmoShare.DataTableIsNotEmpty(ztdt))
                {
                    this.BindDataTable(sectionType, ztdt, "type_name", "type_id");
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #19
0
        void btnAllToSelected_Click(object sender, EventArgs e)
        {
            DataTable source = gridControlUnSelected.DataSource as DataTable;

            if (TmoShare.DataTableIsNotEmpty(source))
            {
                var users = ModelConvertHelper <Userinfo> .ConvertToModel(source);

                if (users != null)
                {
                    foreach (Userinfo user in users)
                    {
                        AddUserToSelected(user);
                    }
                }
            }
            else
            {
                DXMessageBox.ShowInfo("查询结果为空", this);
            }
        }
コード例 #20
0
ファイル: UCDocInfo.cs プロジェクト: Arainsd/HealthManagement
 protected override void OnRowCellClick(DataRow dr, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
 {
     if (e.Column.Name == "gc_doc_function")   //设置权限
     {
         UCFunctionEditor edit = new UCFunctionEditor();
         edit.Title = string.Format("设置健康师【{0}】权限", dr["doc_name"]);
         string doc_function = dr["doc_function"].ToString();
         if (string.IsNullOrWhiteSpace(doc_function))
         {
             DataTable dt = Tmo_FakeEntityClient.Instance.GetData("tmo_docgroup", new[] { "group_function" }, null, "group_id", dr["doc_group"].ToString());
             if (TmoShare.DataTableIsNotEmpty(dt))
             {
                 doc_function = dt.Rows[0][0].ToString();
             }
         }
         edit.EditValue = doc_function;
         if (edit.ShowDialog() == DialogResult.OK)
         {//设置权限
             if (doc_function != edit.EditValue)
             {
                 Dictionary <string, object> dic = new Dictionary <string, object>();
                 dic.Add("doc_function", edit.EditValue);
                 bool suc = Tmo_FakeEntityClient.Instance.SubmitData(DBOperateType.Update, TableName, PrimaryKey, dr[PrimaryKey].ToString(), dic);
                 if (!suc)
                 {
                     DXMessageBox.ShowError("权限设置失败,请重试!");
                 }
                 else
                 {
                     GetData();
                 }
             }
         }
         edit.Dispose();
     }
     base.OnRowCellClick(dr, e);
 }
コード例 #21
0
ファイル: UCDocInfo.cs プロジェクト: Arainsd/HealthManagement
        protected override void OnDelClick(DataRow selectedRow)
        {
            string doc_name = selectedRow["doc_name"].ToString();
            string pkVal    = selectedRow[PrimaryKey].ToString();

            if (TmoComm.login_docInfo.doc_id.ToString() == pkVal)
            {
                DXMessageBox.ShowInfo("不能删除自身!");
                return;
            }
            DXMessageBox.btnOKClick += (object sender, EventArgs e) =>
            {
                DataTable dtcount = Tmo_FakeEntityClient.Instance.GetData("tmo_userinfo", new[] { "count(*) as count" }, "doc_id='" + pkVal + "'");
                if (TmoShare.DataTableIsNotEmpty(dtcount))
                {
                    int count = dtcount.Rows[0].GetDataRowIntValue("count");
                    if (count > 0)
                    {
                        DXMessageBox.ShowWarning("该健康师下分配有用户不能删除!");
                        return;
                    }
                }
                bool suc = Tmo_FakeEntityClient.Instance.DeleteData(TableName, PrimaryKey, pkVal);
                if (suc)
                {
                    DXMessageBox.Show("健康师删除成功!", true);
                    Tmo_CommonClient.Instance.RefreshDocChildrenID();
                    GetData();
                }
                else
                {
                    DXMessageBox.ShowWarning("删除失败!");
                }
            };
            DXMessageBox.ShowQuestion("确定要删除健康师【" + doc_name + "】吗?");
            base.OnDelClick(selectedRow);
        }
コード例 #22
0
        public bool inputUserDic(DataTable table)
        {
            List <string> sqls = new List <string>();

            if (TmoShare.DataTableIsNotEmpty(table))
            {
                foreach (DataRow row in table.Rows)
                {
                    string id  = Guid.NewGuid().ToString().Replace("-", "");
                    string sql = "INSERT into tmo_tuijian_user (dicvalue,dic_id,dicname,user_id,user_times,id,input_time) VALUES('" + row["dicvalue"].ToString() + "','" + row["dic_id"].ToString() + "','" + row["dicname"].ToString() + "','" + row["user_id"].ToString() + "','" + row["user_times"].ToString() + "','" + id + "','" + TmoShare.DateNow + "') ";
                    sqls.Add(sql);
                }
            }
            int num = MySQLHelper.ExecuteSqlList(sqls);

            if (num > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #23
0
        public bool UpdateDicUser(DataTable table)
        {
            List <string> sqls = new List <string>();

            if (TmoShare.DataTableIsNotEmpty(table))
            {
                foreach (DataRow row in table.Rows)
                {
                    string id  = Guid.NewGuid().ToString().Replace("-", "");
                    string sql = "update tmo_tuijian_user set  dicvalue='" + row["dicvalue"].ToString() + "',dic_id='" + row["dic_id"].ToString() + "',dicname='" + row["dicname"].ToString() + "',user_id='" + row["user_id"].ToString() + "',user_times='" + row["user_times"].ToString() + "',input_time='" + TmoShare.DateNow + "' where id='" + row["id"].ToString() + "' ";
                    sqls.Add(sql);
                }
            }
            int num = MySQLHelper.ExecuteSqlList(sqls);

            if (num > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #24
0
        protected override void GetDataAfterSync(DataTable source)
        {
            if (TmoShare.DataTableIsNotEmpty(source))
            {
                DataTable docTable = null;
                if (isDepartment) //按单位统计
                {
                    docTable = source.Copy();
                    source.Clear();
                }

                DataRow totalRow = source.NewRow();
                totalRow["doc_id"]   = 0;
                totalRow["doc_name"] = "总计";
                source.Rows.InsertAt(totalRow, 0);

                if (dt_tmo_userinfo == null)
                {
                    dt_tmo_userinfo = Tmo_FakeEntityClient.Instance.GetData("tmo_userinfo", new[] { "user_id", "doc_id", "vip_type", "input_time" }, string.Format("is_del!=1 and doc_id in ({0})", TmoComm.login_docInfo.children_docid));
                }

                if (dt_tmo_userinfo != null && dt_tmo_userstatus == null)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (DataRow row in dt_tmo_userinfo.Rows)
                    {
                        sb.AppendFormat("'{0}',", row.GetDataRowStringValue("user_id"));
                    }
                    sb.Append("'0'");
                    dt_tmo_userstatus = Tmo_FakeEntityClient.Instance.GetData("tmo_userstatus", new[] { "id", "user_id", "questionnare_status", "questionnaire_time", "assessment_time", "pay_time", "actionplan_time" }, "questionnare_status>=0 and user_id in (" + sb + ")");
                }

                if (dt_tmo_intervene == null)
                {
                    dt_tmo_intervene = Tmo_FakeEntityClient.Instance.GetData("tmo_intervene", new[] { "inte_id", "doc_id", "inte_way", "input_time" }, "doc_id in (" + TmoComm.login_docInfo.children_docid + ")");
                }

                foreach (DataRow row in source.Rows)
                {
                    string    doc_id = row.GetDataRowStringValue("doc_id");
                    DataRow[] drcount;
                    if (dt_tmo_userinfo != null)
                    {
                        if (doc_id == "0")
                        {
                            if (!isDate)
                            {
                                row["user_count"] = dt_tmo_userinfo.Rows.Count;
                                drcount           = dt_tmo_userinfo.Select("vip_type=1");
                                row["vip1"]       = drcount.Length;
                                drcount           = dt_tmo_userinfo.Select("vip_type=2");
                                row["vip2"]       = drcount.Length;
                                drcount           = dt_tmo_userinfo.Select("vip_type=3");
                                row["vip3"]       = drcount.Length;

                                if (dt_tmo_userstatus != null)
                                {
                                    row["question_count"] = dt_tmo_userstatus.Rows.Count;
                                    drcount                 = dt_tmo_userstatus.Select("questionnare_status>=2");
                                    row["report_count"]     = drcount.Length;
                                    drcount                 = dt_tmo_userstatus.Select("questionnare_status>=3");
                                    row["pay_count"]        = drcount.Length;
                                    drcount                 = dt_tmo_userstatus.Select("questionnare_status=4");
                                    row["actionplan_count"] = drcount.Length;
                                }
                            }
                            else
                            {
                                drcount           = dt_tmo_userinfo.Select(string.Format("input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd));
                                row["user_count"] = drcount.Length;
                                drcount           = dt_tmo_userinfo.Select(string.Format("vip_type=1 and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd));
                                row["vip1"]       = drcount.Length;
                                drcount           = dt_tmo_userinfo.Select(string.Format("vip_type=2 and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd));
                                row["vip2"]       = drcount.Length;
                                drcount           = dt_tmo_userinfo.Select(string.Format("vip_type=3 and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd));
                                row["vip3"]       = drcount.Length;

                                if (dt_tmo_userstatus != null)
                                {
                                    drcount = dt_tmo_userstatus.Select(string.Format("questionnaire_time >= '{0}' and questionnaire_time <= '{1}'", dateBegin, dateEnd));
                                    row["question_count"] = drcount.Length;
                                    drcount                 = dt_tmo_userstatus.Select(string.Format("questionnare_status>=2 and assessment_time >= '{0}' and assessment_time <= '{1}'", dateBegin, dateEnd));
                                    row["report_count"]     = drcount.Length;
                                    drcount                 = dt_tmo_userstatus.Select(string.Format("questionnare_status>=3 and pay_time >= '{0}' and pay_time <= '{1}'", dateBegin, dateEnd));
                                    row["pay_count"]        = drcount.Length;
                                    drcount                 = dt_tmo_userstatus.Select(string.Format("questionnare_status=4 and actionplan_time >= '{0}' and actionplan_time <= '{1}'", dateBegin, dateEnd));
                                    row["actionplan_count"] = drcount.Length;
                                }
                            }
                        }
                        else
                        {
                            if (!isDate)
                            {
                                drcount           = dt_tmo_userinfo.Select("doc_id = " + doc_id);
                                row["user_count"] = drcount.Length;
                                drcount           = dt_tmo_userinfo.Select("vip_type=1 and doc_id=" + doc_id);
                                row["vip1"]       = drcount.Length;
                                drcount           = dt_tmo_userinfo.Select("vip_type=2 and doc_id=" + doc_id);
                                row["vip2"]       = drcount.Length;
                                drcount           = dt_tmo_userinfo.Select("vip_type=3 and doc_id=" + doc_id);
                                row["vip3"]       = drcount.Length;

                                if (dt_tmo_userstatus != null)
                                {
                                    StringBuilder sb = new StringBuilder();
                                    drcount = dt_tmo_userinfo.Select("doc_id = " + doc_id);
                                    foreach (DataRow r in drcount)
                                    {
                                        sb.AppendFormat("'{0}',", r.GetDataRowStringValue("user_id"));
                                    }
                                    sb.Append("'0'");
                                    drcount = dt_tmo_userstatus.Select("user_id in(" + sb + ")");
                                    row["question_count"] = drcount.Length;
                                    drcount                 = dt_tmo_userstatus.Select("questionnare_status>=2 and user_id in(" + sb + ")");
                                    row["report_count"]     = drcount.Length;
                                    drcount                 = dt_tmo_userstatus.Select("questionnare_status>=3 and user_id in(" + sb + ")");
                                    row["pay_count"]        = drcount.Length;
                                    drcount                 = dt_tmo_userstatus.Select("questionnare_status=4 and user_id in(" + sb + ")");
                                    row["actionplan_count"] = drcount.Length;
                                }
                            }
                            else
                            {
                                drcount           = dt_tmo_userinfo.Select(string.Format("doc_id = {0} and input_time >= '{1}' and input_time <= '{2}'", doc_id, dateBegin, dateEnd));
                                row["user_count"] = drcount.Length;
                                drcount           = dt_tmo_userinfo.Select(string.Format("vip_type=1 and doc_id={2} and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd, doc_id));
                                row["vip1"]       = drcount.Length;
                                drcount           = dt_tmo_userinfo.Select(string.Format("vip_type=2 and doc_id={2} and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd, doc_id));
                                row["vip2"]       = drcount.Length;
                                drcount           = dt_tmo_userinfo.Select(string.Format("vip_type=3 and doc_id={2} and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd, doc_id));
                                row["vip3"]       = drcount.Length;

                                if (dt_tmo_userstatus != null)
                                {
                                    StringBuilder sb = new StringBuilder();
                                    drcount = dt_tmo_userinfo.Select("doc_id = " + doc_id);
                                    foreach (DataRow r in drcount)
                                    {
                                        sb.AppendFormat("'{0}',", r.GetDataRowStringValue("user_id"));
                                    }
                                    sb.Append("'0'");
                                    drcount = dt_tmo_userstatus.Select(string.Format("user_id in({2}) and questionnaire_time >= '{0}' and questionnaire_time <= '{1}'", dateBegin, dateEnd, sb));
                                    row["question_count"] = drcount.Length;
                                    drcount                 = dt_tmo_userstatus.Select(string.Format("questionnare_status>=2 and user_id in({2}) and assessment_time >= '{0}' and assessment_time <= '{1}'", dateBegin, dateEnd, sb));
                                    row["report_count"]     = drcount.Length;
                                    drcount                 = dt_tmo_userstatus.Select(string.Format("questionnare_status>=3 and user_id in({2}) and pay_time >= '{0}' and pay_time <= '{1}'", dateBegin, dateEnd, sb));
                                    row["pay_count"]        = drcount.Length;
                                    drcount                 = dt_tmo_userstatus.Select(string.Format("questionnare_status=4 and user_id in({2}) and actionplan_time >= '{0}' and actionplan_time <= '{1}'", dateBegin, dateEnd, sb));
                                    row["actionplan_count"] = drcount.Length;
                                }
                            }
                        }
                    }

                    if (dt_tmo_intervene != null)
                    {
                        if (doc_id == "0")
                        {
                            if (!isDate)
                            {
                                row["intervene_count"] = dt_tmo_intervene.Rows.Count;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way=2"));
                                row["smsintervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way=1"));
                                row["emailintervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way=3"));
                                row["phoneintervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way=4"));
                                row["mfintervene_count"] = drcount.Length;
                            }
                            else
                            {
                                drcount = dt_tmo_intervene.Select(string.Format("input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd));
                                row["intervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way=2 and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd));
                                row["smsintervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way=1 and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd));
                                row["emailintervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way=3 and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd));
                                row["phoneintervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way=4 and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd));
                                row["mfintervene_count"] = drcount.Length;
                            }
                        }
                        else
                        {
                            if (!isDate)
                            {
                                drcount = dt_tmo_intervene.Select(string.Format("doc_id='{0}'", doc_id));
                                row["intervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way='2' and doc_id='{0}'", doc_id));
                                row["smsintervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way='1' and doc_id='{0}'", doc_id));
                                row["emailintervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way='3' and doc_id='{0}'", doc_id));
                                row["phoneintervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way='4' and doc_id='{0}'", doc_id));
                                row["mfintervene_count"] = drcount.Length;
                            }
                            else
                            {
                                drcount = dt_tmo_intervene.Select(string.Format("doc_id='{2}' and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd, doc_id));
                                row["intervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way='2' and doc_id='{2}' and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd, doc_id));
                                row["smsintervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way='1' and doc_id='{2}' and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd, doc_id));
                                row["emailintervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way='3' and doc_id='{2}' and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd, doc_id));
                                row["phoneintervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way='4' and doc_id='{2}' and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd, doc_id));
                                row["mfintervene_count"] = drcount.Length;
                            }
                        }
                    }
                }

                if (isDepartment && TmoComm.login_docInfo.children_department != null)
                {
                    string[] deps = (TmoComm.login_docInfo.doc_department + "," + TmoComm.login_docInfo.children_department).Split(',');
                    foreach (string dep in deps)
                    {
                        if (string.IsNullOrEmpty(dep))
                        {
                            continue;
                        }

                        DataRow row = source.NewRow();
                        row["doc_id"]   = dep;
                        row["doc_name"] = Tmo_CommonClient.Instance.GetDepartmentNamesFromIDs(dep);

                        DataRow[]     docrs = docTable.Select("doc_department=" + dep);
                        StringBuilder sb0   = new StringBuilder();
                        foreach (DataRow docr in docrs)
                        {
                            sb0.AppendFormat("'{0}',", docr.GetDataRowStringValue("doc_id"));
                        }
                        sb0.Append("'-1'");
                        DataRow[] drcount;
                        if (dt_tmo_userinfo != null)
                        {
                            if (!isDate)
                            {
                                drcount           = dt_tmo_userinfo.Select("vip_type=1 and doc_id in (" + sb0 + ")");
                                row["vip1"]       = drcount.Length;
                                drcount           = dt_tmo_userinfo.Select("vip_type=2 and doc_id in (" + sb0 + ")");
                                row["vip2"]       = drcount.Length;
                                drcount           = dt_tmo_userinfo.Select("vip_type=3 and doc_id in (" + sb0 + ")");
                                row["vip3"]       = drcount.Length;
                                drcount           = dt_tmo_userinfo.Select("doc_id in (" + sb0 + ")");
                                row["user_count"] = drcount.Length;

                                if (dt_tmo_userstatus != null)
                                {
                                    StringBuilder sb = new StringBuilder();
                                    foreach (DataRow r in drcount)
                                    {
                                        sb.AppendFormat("'{0}',", r.GetDataRowStringValue("user_id"));
                                    }
                                    sb.Append("'0'");
                                    drcount = dt_tmo_userstatus.Select("user_id in(" + sb + ")");
                                    row["question_count"] = drcount.Length;
                                    drcount                 = dt_tmo_userstatus.Select("questionnare_status>=2 and user_id in(" + sb + ")");
                                    row["report_count"]     = drcount.Length;
                                    drcount                 = dt_tmo_userstatus.Select("questionnare_status>=3 and user_id in(" + sb + ")");
                                    row["pay_count"]        = drcount.Length;
                                    drcount                 = dt_tmo_userstatus.Select("questionnare_status=4 and user_id in(" + sb + ")");
                                    row["actionplan_count"] = drcount.Length;
                                }
                            }
                            else
                            {
                                drcount           = dt_tmo_userinfo.Select(string.Format("vip_type=1 and doc_id in ({2}) and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd, sb0));
                                row["vip1"]       = drcount.Length;
                                drcount           = dt_tmo_userinfo.Select(string.Format("vip_type=2 and doc_id in ({2}) and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd, sb0));
                                row["vip2"]       = drcount.Length;
                                drcount           = dt_tmo_userinfo.Select(string.Format("vip_type=3 and doc_id in ({2}) and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd, sb0));
                                row["vip3"]       = drcount.Length;
                                drcount           = dt_tmo_userinfo.Select(string.Format("doc_id in ({2}) and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd, sb0));
                                row["user_count"] = drcount.Length;

                                if (dt_tmo_userstatus != null)
                                {
                                    StringBuilder sb = new StringBuilder();
                                    drcount = dt_tmo_userinfo.Select("doc_id in (" + sb0 + ")");
                                    foreach (DataRow r in drcount)
                                    {
                                        sb.AppendFormat("'{0}',", r.GetDataRowStringValue("user_id"));
                                    }
                                    sb.Append("'0'");
                                    drcount = dt_tmo_userstatus.Select(string.Format("user_id in({2}) and questionnaire_time >= '{0}' and questionnaire_time <= '{1}'", dateBegin, dateEnd, sb));
                                    row["question_count"] = drcount.Length;
                                    drcount                 = dt_tmo_userstatus.Select(string.Format("questionnare_status>=2 and user_id in({2}) and assessment_time >= '{0}' and assessment_time <= '{1}'", dateBegin, dateEnd, sb));
                                    row["report_count"]     = drcount.Length;
                                    drcount                 = dt_tmo_userstatus.Select(string.Format("questionnare_status>=3 and user_id in({2}) and pay_time >= '{0}' and pay_time <= '{1}'", dateBegin, dateEnd, sb));
                                    row["pay_count"]        = drcount.Length;
                                    drcount                 = dt_tmo_userstatus.Select(String.Format("questionnare_status=4 and user_id in({2}) and actionplan_time >= '{0}' and actionplan_time <= '{1}'", dateBegin, dateEnd, sb));
                                    row["actionplan_count"] = drcount.Length;
                                }
                            }
                        }

                        if (dt_tmo_intervene != null)
                        {
                            if (!isDate)
                            {
                                drcount = dt_tmo_intervene.Select(string.Format("doc_id in (" + sb0 + ")"));
                                row["intervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way='2' and doc_id in (" + sb0 + ")"));
                                row["smsintervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way='1' and doc_id in (" + sb0 + ")"));
                                row["emailintervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way='3' and doc_id in (" + sb0 + ")"));
                                row["phoneintervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way='4' and doc_id in (" + sb0 + ")"));
                                row["mfintervene_count"] = drcount.Length;
                            }
                            else
                            {
                                drcount = dt_tmo_intervene.Select(string.Format("doc_id in ({2}) and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd, sb0));
                                row["intervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way='2' and doc_id in ({2}) and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd, sb0));
                                row["smsintervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way='1' and doc_id in ({2}) and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd, sb0));
                                row["emailintervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way='3' and doc_id in ({2}) and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd, sb0));
                                row["phoneintervene_count"] = drcount.Length;
                                drcount = dt_tmo_intervene.Select(string.Format("inte_way='4' and doc_id in ({2}) and input_time >= '{0}' and input_time <= '{1}'", dateBegin, dateEnd, sb0));
                                row["mfintervene_count"] = drcount.Length;
                            }
                        }
                        source.Rows.Add(row);
                    }
                }
            }
        }
コード例 #25
0
        public bool AddMonitorData(DataTable submitTable)
        {
            try
            {
                if (TmoShare.DataTableIsNotEmpty(submitTable))
                {
                    List <string> sqlList = new List <string>();

                    DataTable dtstruct = MemoryCacheHelper.GetCacheItem <DataTable>("ts_tmo_monitor",
                                                                                    () => MySQLHelper.QueryTableStruct("tmo_monitor").Tables[0], DateTime.Now.AddHours(24));
                    DataTable dtstruct1 = MemoryCacheHelper.GetCacheItem <DataTable>("ts_tmo_monitor_received",
                                                                                     () => MySQLHelper.QueryTableStruct("tmo_monitor_received").Tables[0],
                                                                                     DateTime.Now.AddHours(24));
                    DataTable dtdic = MemoryCacheHelper.GetCacheItem <DataTable>("tmo_dicmonitor",
                                                                                 () => MySQLHelper.QueryTable("select * from tmo_dicmonitor where is_del=0"),
                                                                                 DateTime.Now.AddHours(12));

                    foreach (DataRow dr in submitTable.Rows)
                    {
                        int mt_code = TmoDataComm.GetMtCode(dr["mt_name"].ToString());
                        if (mt_code == 0)
                        {
                            continue;
                        }
                        if (dr["mt_value"] == null)
                        {
                            continue;                         //跳过空值
                        }
                        string    mt_valuetype = "mt_valuetext";
                        DataRow[] drsdic       = dtdic.Select("mt_code=" + mt_code);
                        if (drsdic.Length > 0)
                        {
                            switch (drsdic[0]["mt_valuetype"].ToString())
                            {
                            case "0":
                                mt_valuetype = "mt_valueint";
                                break;

                            case "1":
                                mt_valuetype = "mt_valuefloat";
                                break;

                            case "2":
                            default:
                                mt_valuetype = "mt_valuetext";
                                break;
                            }
                        }

                        if (mt_valuetype != "mt_valuetext" && string.IsNullOrWhiteSpace(dr["mt_value"].ToString()))
                        {
                            continue;                                                                                         //跳过无效值
                        }
                        string user_id = dr["user_id"].ToString();
                        string errmsg;
                        bool   isUserId = TmoShare.isIdCardNo(user_id, out errmsg);
                        if (!isUserId)
                        {
                            //查找设备绑定关系
                            object tmp_userid = MySQLHelper.QuerySingle(
                                $"select a.dev_userid from tmo_monitor_devicebind a left join tmo_userinfo b on a.dev_userid=b.user_id where b.is_del!=1 and a.dev_sn='{user_id}'");
                            if (tmp_userid != null)
                            {
                                user_id  = tmp_userid.ToString(); //找到绑定关系
                                isUserId = true;
                            }
                        }

                        Dictionary <string, string> colVals = new Dictionary <string, string>();
                        colVals.Add("mt_code", mt_code.ToString());
                        colVals.Add("user_id", user_id);
                        DateTime mt_time      = dr.GetDataRowDateTimeValue("mt_time");
                        int      mt_timestamp = dr.GetDataRowIntValue("mt_timestamp");
                        if (mt_timestamp == -1 || mt_timestamp == -2) //错误timestamp
                        {
                            if (mt_time == DateTime.MinValue || mt_time == DateTime.MaxValue ||
                                mt_time > DateTime.Now) //无效值
                            {
                                mt_time = DateTime.Now;
                            }
                            mt_timestamp = DateTimeHelper.TimeToStamp(mt_time);
                        }
                        else
                        {
                            mt_time = DateTimeHelper.StampToTime(mt_timestamp);
                            if (mt_time == DateTime.MinValue || mt_time == DateTime.MaxValue ||
                                mt_time > DateTime.Now) //无效值
                            {
                                mt_time = DateTime.Now;
                            }
                            mt_timestamp = DateTimeHelper.TimeToStamp(mt_time);
                        }

                        dr["mt_time"] = mt_time;

                        colVals.Add("mt_timestamp", mt_timestamp.ToString());

                        int       sameType        = 0; //相同类型
                        DataTable saveTableStruct = null;
                        if (isUserId)
                        {
                            saveTableStruct = dtstruct;
                            if (MySQLHelper.Exists("tmo_monitor", colVals))
                            {
                                sameType = 1;                                             //有相同时间数据
                            }
                            colVals.Add(mt_valuetype, dr["mt_value"].ToString());
                            if (MySQLHelper.Exists("tmo_monitor", colVals))
                            {
                                continue;                                             //判断是否存在相同值
                            }
                        }
                        else
                        {
                            saveTableStruct = dtstruct1;
                            sameType        = 2; //存储到临时接收表
                            colVals.Add(mt_valuetype, dr["mt_value"].ToString());
                            if (MySQLHelper.Exists("tmo_monitor_received", colVals))
                            {
                                continue;                                                      //判断是否存在相同值
                            }
                            colVals.Add("remark", dr.GetDataRowStringValue("dev_type"));
                        }

                        foreach (DataColumn dc in submitTable.Columns)
                        {
                            string colname = dc.ColumnName;
                            if (!saveTableStruct.Columns.Contains(colname))
                            {
                                continue;                                             //非monitor表中字段跳过
                            }
                            if (colVals.ContainsKey(colname))
                            {
                                continue;                               //已添加字段跳过
                            }
                            colVals.Add(colname, dr[dc].ToString());
                        }

                        if (sameType == 0) //插入
                        {
                            StringBuilder sbsql    = new StringBuilder("insert into tmo_monitor(");
                            StringBuilder sbsqlval = new StringBuilder(" values(");
                            foreach (var item in colVals)
                            {
                                sbsql.Append(item.Key + ",");
                                sbsqlval.AppendFormat("{0},", item.Value == String.Empty ? "null" : $"'{item.Value}'");
                            }

                            sbsql.Append("input_time)");
                            sbsqlval.Append("SYSDATE())");
                            sqlList.Add(sbsql.ToString() + sbsqlval.ToString());
                        }
                        else if (sameType == 1) //修改
                        {
                            StringBuilder sbsql = new StringBuilder("update tmo_monitor set ");
                            sbsql.AppendFormat(" {0}='{1}' ", mt_valuetype, colVals[mt_valuetype]);
                            sbsql.AppendFormat(", {0}='{1}' ", "mt_isnormal", colVals["mt_isnormal"]);
                            sbsql.AppendFormat(", {0}={1} ", "input_time", "SYSDATE()");
                            sbsql.AppendFormat("where {0}='{1}' and {2}='{3}' and {4}='{5}'", "mt_code",
                                               colVals["mt_code"], "user_id", colVals["user_id"], "mt_timestamp",
                                               colVals["mt_timestamp"]);
                            sqlList.Add(sbsql.ToString());
                        }
                        else if (sameType == 2) //存储到临时接收表
                        {
                            StringBuilder sbsql    = new StringBuilder("insert into tmo_monitor_received(");
                            StringBuilder sbsqlval = new StringBuilder(" values(");
                            foreach (var item in colVals)
                            {
                                sbsql.Append(item.Key + ",");
                                sbsqlval.AppendFormat("'{0}',", item.Value);
                            }

                            sbsql.Append("input_time)");
                            sbsqlval.Append("SYSDATE())");
                            sqlList.Add(sbsql.ToString() + sbsqlval.ToString());
                        }
                    }

                    int count = MySQLHelper.ExecuteSqlTran(sqlList);
                    return(count >= 0);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Log.Error("添加监测数据失败", ex);
                return(false);
            }
        }
コード例 #26
0
ファイル: Zong.cs プロジェクト: Arainsd/HealthManagement
        public void RefData(string userId, string user_times, string quesIDs)
        {
            string uptimes = "0";

            if (user_times != "1")
            {
                uptimes = (int.Parse(user_times) - 1).ToString();
            }
            string    strmlx = TmoServiceClient.InvokeServerMethodT <string>(funCode.getScreenData, new object[] { userId, user_times, quesIDs });
            DataTable dt     = TmoShare.getDataTableFromXML(strmlx);
            string    upxml  = TmoServiceClient.InvokeServerMethodT <string>(funCode.getScreenData, new object[] { userId, uptimes, quesIDs });
            DataTable updtdd = TmoShare.getDataTableFromXML(upxml);

            if (TmoShare.DataTableIsNotEmpty(dt))
            {
                foreach (DataRow row in dt.Rows)
                {
                    string p_id = row["q_id"].ToString();
                    if (p_id == "D9115BD44B1344B88A45EF121EADCBA5")
                    {
                    }

                    #region 指标结果

                    if (p_id == "EBE1C353B35842189EF8F4041BE95CB6")
                    {
                        if (TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()) == 0)
                        {
                            continue;
                        }
                        tizhong.Text = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()).ToString();
                    }
                    if (p_id == "D9115BD44B1344B88A45EF121EADCBA5")
                    {
                        float val = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString());
                        if (val == 0)
                        {
                            continue;
                        }
                        if (val > 24)
                        {
                            fpd.Text = "肥胖";
                        }
                        bmiValue.Text = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()).ToString();
                    }
                    if (p_id == "CE8C9F888AD2447487EAA996BBA5A6BF")
                    {
                        if (TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()) == 0)
                        {
                            continue;
                        }
                        yaowei.Text = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()).ToString();
                    }
                    if (p_id == "ADF9331BADAB48BF9147611A9BBD1C79")
                    {
                        float vald = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString());
                        if (vald > 5.6 || vald < 3.9)
                        {
                            kong.ForeColor = Color.Red;
                        }
                        kong.Text = vald.ToString();
                    }

                    if (p_id == "0C1553EA1A274B56A211CCFC5F4A429E")
                    {
                        if (TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()) == 0)
                        {
                            continue;
                        }
                        float vald = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString());
                        if (vald > 7.8 || vald < 4.4)
                        {
                            can.ForeColor = Color.Red;
                        }
                        can.Text = vald.ToString();
                    }

                    if (p_id == "C41F469521E849D8B6314833C6FA92B0")
                    {
                        string[] valds = TmoShare.GetValueFromJson <string[]>(row["qr_result"].ToString());
                        if (valds != null && valds.Length > 0)
                        {
                            if (!string.IsNullOrEmpty(valds[0]) && !string.IsNullOrEmpty(valds[1]))
                            {
                                float v1 = float.Parse(valds[0]);
                                float v2 = float.Parse(valds[1]);
                                if (v1 > 140 || v1 < 90 || v2 < 60 || v2 > 90)
                                {
                                    xueya.ForeColor = Color.Red;
                                }
                                xueya.Text = v1 + "/" + v2;
                            }
                        }
                    }
                    if (p_id == "6E3658E76CE141CEB0264BA1ADEF9664")
                    {
                        float vald = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString());
                        if (vald == 0)
                        {
                            continue;
                        }
                        if (vald > 5.2 || vald < 3)
                        {
                            zongdangu.ForeColor = Color.Red;
                        }
                        zongdangu.Text = vald.ToString();
                    }
                    if (p_id == "225368D504EB431CA2E597FAD50D2949")
                    {
                        float vald = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString());
                        if (vald == 0)
                        {
                            continue;
                        }
                        if (vald > 1.7 || vald < 0)
                        {
                            ganyou.ForeColor = Color.Red;
                        }
                        ganyou.Text = vald.ToString();
                    }

                    if (p_id == "6A67F0E229964527AB541B5DD318E2C3")
                    {
                        float vald = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString());
                        if (vald == 0)
                        {
                            continue;
                        }
                        if (vald > 3.12 || vald < 0)
                        {
                            dimi.ForeColor = Color.Red;
                        }
                        dimi.Text = vald.ToString();
                    }
                    if (p_id == "D2198A7F78CF4DEFA821C4F41893E415")
                    {
                        float vald = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString());
                        if (vald == 0)
                        {
                            continue;
                        }
                        if (vald > 0.2 || vald < 0.7)
                        {
                            xrTableCell72.ForeColor = Color.Red;
                        }
                        xrTableCell72.Text = vald.ToString();
                    }//805E2FAC0F3B442DBBBFAFB4BF61F427
                    if (p_id == "805E2FAC0F3B442DBBBFAFB4BF61F427")
                    {
                        if (TmoShare.GetValueFromJson <float>(row["qr_result"].ToString(), false) == 0)
                        {
                            continue;
                        }
                        niaodan.Text = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()).ToString();
                    }
                    if (p_id == "4CD308E584744A36BC499CECCADAEB18")
                    {
                        if (TmoShare.GetValueFromJson <float>(row["qr_result"].ToString(), false) == 0)
                        {
                            continue;
                        }
                        niaobai.Text = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()).ToString();
                    }
                    if (p_id == "6501E7A0165648A6BD9409430028ADEB")
                    {
                        if (TmoShare.GetValueFromJson <float>(row["qr_result"].ToString(), false) == 0)
                        {
                            continue;
                        }
                        tongxing.Text = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()).ToString();
                    }
                    if (p_id == "C1443DA657174BC696008614A6659A99")
                    {
                        if (TmoShare.GetValueFromJson <float>(row["qr_result"].ToString(), false) == 0)
                        {
                            continue;
                        }
                        xuehong.Text = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()).ToString();
                    }
                    #endregion
                    #region 个人疾病史
                    if (p_id == "02390D277242464192B05F08D03D298B")
                    {
                        bool val = TmoShare.GetValueFromJson <bool>(row["qr_result"].ToString());
                        if (val)
                        {
                            xrTableCell138.Text      = "有";//高血压
                            xrTableCell138.ForeColor = Color.Red;
                            gxy.Text = "已患";
                        }
                    }
                    if (p_id == "0F58D8725EB5467E91231F0742FF4271")
                    {
                        bool val = TmoShare.GetValueFromJson <bool>(row["qr_result"].ToString());
                        if (val)
                        {
                            shenjing.Text = "已患";//糖尿病神经病变
                        }
                    }
                    if (p_id == "9407E0C29A914D9795B203968A8050EB")
                    {
                        bool val = TmoShare.GetValueFromJson <bool>(row["qr_result"].ToString());
                        if (val)
                        {
                            tnb.Text                 = "已患";//糖尿时间
                            xrTableCell126.Text      = "有";
                            xrTableCell126.ForeColor = Color.Red;
                        }
                    }
                    if (p_id == "16D3E509B9C0400F97F7D88EB91C8247")
                    {
                        DateTime val        = TmoShare.GetValueFromJson <DateTime>(row["qr_result"].ToString());
                        var      dtimeValue = val.ToString("yyyy-MM-dd");
                        if (dtimeValue != "0001-01-01" && dtimeValue != "9999-12-31")
                        {
                            tnb.Text                 = "已患";//糖尿时间
                            xrTableCell126.Text      = "有";
                            xrTableCell126.ForeColor = Color.Red;
                        }
                    }
                    if (p_id == "1E39A6F3231E47C7994FCD380F5A6FC6")
                    {
                        bool val = TmoShare.GetValueFromJson <bool>(row["qr_result"].ToString());
                        if (val)
                        {
                            zb.Text = "已患";//糖尿病足病
                        }
                    }
                    if (p_id == "3289721340EE4EA4BC3EB82366703B75")
                    {
                        bool val = TmoShare.GetValueFromJson <bool>(row["qr_result"].ToString());
                        if (val)
                        {
                            xrTableCell136.Text      = "有";
                            xrTableCell136.ForeColor = Color.Red;
                            xz.Text = "已患";//血脂异常
                        }
                    }
                    if (p_id == "4E89929897B3449384BAB2DC1B886BE1")
                    {
                        bool val = TmoShare.GetValueFromJson <bool>(row["qr_result"].ToString());
                        if (val)
                        {
                            yb.Text = "已患";//和病眼病
                        }
                    }
                    if (p_id == "C9541C75D3EE43D9A94124605E4FE70B")
                    {
                        bool val = TmoShare.GetValueFromJson <bool>(row["qr_result"].ToString());
                        if (val)
                        {
                            shenbing.Text = "已患";//肾病
                        }
                    }
                    if (p_id == "A44EF95BEF084F919FB78FC614E2C58E")
                    {
                        int[] vals = TmoShare.GetValueFromJson <int[]>(row["qr_result"].ToString());
                        if (vals != null && vals.Length > 0)
                        {
                            if (iscontext(vals, 226))
                            {
                                xrTableCell132.Text      = "有";
                                xrTableCell132.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 227))
                            {
                                xrTableCell134.Text      = "有";
                                xrTableCell134.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 228))
                            {
                                xrTableCell144.Text      = "有";
                                xrTableCell144.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 229))
                            {
                                xrTableCell30.Text      = "有";
                                xrTableCell30.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 225))
                            {
                                xrTableCell146.Text      = "有";
                                xrTableCell146.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 214))
                            {
                                xrTableCell148.Text      = "有";
                                xrTableCell148.ForeColor = Color.Red;
                            }
                        }
                    }
                    if (p_id == "08EAA9700B0440C2BB8957D3722F9E87")//父亲
                    {
                        int[] vals = TmoShare.GetValueFromJson <int[]>(row["qr_result"].ToString());
                        if (vals != null && vals.Length > 0)
                        {
                            if (iscontext(vals, 212))
                            {
                                fugao.Text      = "有";
                                fugao.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 208))
                            {
                                futang.Text      = "有";
                                futang.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 207))
                            {
                                fuxuezhi.Text      = "有";
                                fuxuezhi.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 225))
                            {
                                fujia.Text      = "有";
                                fujia.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 214))
                            {
                                guanxin.Text      = "有";
                                guanxin.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 226))
                            {
                                naoguanxin.Text      = "有";
                                naoguanxin.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 227))
                            {
                                fuzhongliu.Text      = "有";
                                fuzhongliu.ForeColor = Color.Red;
                            }
                        }
                    }
                    if (p_id == "65D243DFF6654CD3BC65900E8467DDA9")//母亲
                    {
                        int[] vals = TmoShare.GetValueFromJson <int[]>(row["qr_result"].ToString());
                        if (vals != null && vals.Length > 0)
                        {
                            if (iscontext(vals, 212))
                            {
                                mugao.Text      = "有";
                                mugao.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 208))
                            {
                                mutang.Text      = "有";
                                mutang.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 207))
                            {
                                muxuezhi.Text      = "有";
                                muxuezhi.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 225))
                            {
                                mujia.Text      = "有";
                                mujia.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 214))
                            {
                                muguanxin.Text      = "有";
                                muguanxin.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 226))
                            {
                                muxinnao.Text      = "有";
                                muxinnao.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 227))
                            {
                                muzhongliu.Text      = "有";
                                muzhongliu.ForeColor = Color.Red;
                            }
                        }
                    }
                    if (p_id == "F88D1C04B0F64D6B8D59CDB821AEBB4B")//兄弟姐妹
                    {
                        int[] vals = TmoShare.GetValueFromJson <int[]>(row["qr_result"].ToString());
                        if (vals != null && vals.Length > 0)
                        {
                            if (iscontext(vals, 212))
                            {
                                xmgao.Text      = "有";
                                xmgao.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 208))
                            {
                                xmtang.Text      = "有";
                                xmtang.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 207))
                            {
                                xmxuezhi.Text      = "有";
                                xmxuezhi.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 225))
                            {
                                xmjia.Text      = "有";
                                xmjia.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 214))
                            {
                                xmgaunxin.Text      = "有";
                                xmgaunxin.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 226))
                            {
                                xmxinao.Text      = "有";
                                xmxinao.ForeColor = Color.Red;
                            }
                            if (iscontext(vals, 227))
                            {
                                xmzhongliu.Text      = "有";
                                xmzhongliu.ForeColor = Color.Red;
                            }
                        }
                    }
                    #endregion
                }
            }



            if (TmoShare.DataTableIsNotEmpty(updtdd))
            {
                #region 判断上次指标结果
                foreach (DataRow row in updtdd.Rows)
                {
                    string p_id = row["q_id"].ToString();



                    if (p_id == "EBE1C353B35842189EF8F4041BE95CB6")
                    {
                        if (TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()) == 0)
                        {
                            continue;
                        }
                        tizhongUp.Text = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()).ToString();
                    }
                    if (p_id == "D9115BD44B1344B88A45EF121EADCBA5")
                    {
                        if (TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()) == 0)
                        {
                            continue;
                        }
                        bmiValueUp.Text = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()).ToString();
                    }
                    if (p_id == "CE8C9F888AD2447487EAA996BBA5A6BF")
                    {
                        if (TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()) == 0)
                        {
                            continue;
                        }
                        yaoweiUp.Text = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()).ToString();
                    }
                    if (p_id == "ADF9331BADAB48BF9147611A9BBD1C79")
                    {
                        float vald = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString());
                        if (vald == 0)
                        {
                            continue;
                        }
                        if (vald == 0)
                        {
                            continue;
                        }
                        if (vald > 5.6 || vald < 3.9)
                        {
                            kongup.ForeColor = Color.Red;
                        }
                        kongup.Text = vald.ToString();
                    }
                    if (p_id == "0C1553EA1A274B56A211CCFC5F4A429E")
                    {
                        float vald = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString());
                        if (vald == 0)
                        {
                            continue;
                        }
                        if (vald == 0)
                        {
                            continue;
                        }
                        if (vald > 7.8 || vald < 4.4)
                        {
                            canUP.ForeColor = Color.Red;
                        }
                        canUP.Text = vald.ToString();
                    }

                    if (p_id == "C41F469521E849D8B6314833C6FA92B0")
                    {
                        string[] valds = TmoShare.GetValueFromJson <string[]>(row["qr_result"].ToString());

                        if (valds != null && valds.Length > 0)
                        {
                            if (!string.IsNullOrEmpty(valds[0]) && !string.IsNullOrEmpty(valds[1]))
                            {
                                float v1 = float.Parse(valds[0]);
                                float v2 = float.Parse(valds[1]);
                                if (v1 > 140 || v1 < 90 || v2 < 60 || v2 > 90)
                                {
                                    xueyaUp.ForeColor = Color.Red;
                                }
                                xueyaUp.Text = v1 + "/" + v2;
                            }
                        }
                    }
                    if (p_id == "6E3658E76CE141CEB0264BA1ADEF9664")
                    {
                        float vald = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString());
                        if (vald == 0)
                        {
                            continue;
                        }
                        if (vald == 0)
                        {
                            continue;
                        }
                        if (vald > 5.2 || vald < 3)
                        {
                            zongdanguUp.ForeColor = Color.Red;
                        }
                        zongdanguUp.Text = vald.ToString();
                    }
                    if (p_id == "225368D504EB431CA2E597FAD50D2949")
                    {
                        float vald = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString());
                        if (vald == 0)
                        {
                            continue;
                        }
                        if (vald == 0)
                        {
                            continue;
                        }
                        if (vald > 1.7 || vald < 0)
                        {
                            ganyouUP.ForeColor = Color.Red;
                        }
                        ganyouUP.Text = vald.ToString();
                    }

                    if (p_id == "6A67F0E229964527AB541B5DD318E2C3")
                    {
                        float vald = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString());
                        if (vald == 0)
                        {
                            continue;
                        }
                        if (vald == 0)
                        {
                            continue;
                        }
                        if (vald > 3.12 || vald < 0)
                        {
                            dimiUP.ForeColor = Color.Red;
                        }
                        dimiUP.Text = vald.ToString();
                    }
                    if (p_id == "D2198A7F78CF4DEFA821C4F41893E415")
                    {
                        float vald = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString());
                        if (vald == 0)
                        {
                            continue;
                        }
                        if (vald == 0)
                        {
                            continue;
                        }
                        if (vald > 0.2 || vald < 0.7)
                        {
                            gaomiUp.ForeColor = Color.Red;
                        }
                        gaomiUp.Text = vald.ToString();
                    }
                    if (p_id == "805E2FAC0F3B442DBBBFAFB4BF61F427")
                    {
                        if (TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()) == 0)
                        {
                            continue;
                        }
                        nianodanUP.Text = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()).ToString();
                    }
                    if (p_id == "4CD308E584744A36BC499CECCADAEB18")
                    {
                        if (TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()) == 0)
                        {
                            continue;
                        }
                        niaobaiUP.Text = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()).ToString();
                    }
                    if (p_id == "6501E7A0165648A6BD9409430028ADEB")
                    {
                        if (TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()) == 0)
                        {
                            continue;
                        }
                        tongxingUP.Text = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()).ToString();
                    }
                    if (p_id == "C1443DA657174BC696008614A6659A99")
                    {
                        if (TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()) == 0)
                        {
                            continue;
                        }
                        xuehongUP.Text = TmoShare.GetValueFromJson <float>(row["qr_result"].ToString()).ToString();
                    }
                }
                #endregion
            }
        }
コード例 #27
0
        /// <summary>
        /// 加载数据
        /// </summary>
        public void GetData()
        {
            this.ShowWaitingPanel(() =>
            {
                try
                {
                    string strmlx = TmoServiceClient.InvokeServerMethodT <string>(funCode.GetMedicalIn, new object[] { _user_id });
                    DataTable dt  = TmoShare.getDataTableFromXML(strmlx);
                    if (TmoShare.DataTableIsNotEmpty(dt))
                    {
                        return(dt);
                    }

                    return(null);
                }
                catch
                {
                }

                return(null);
            }, x =>
            {
                try
                {
                    DataTable dt = x as DataTable;
                    DataRow dr   = dt.Rows[0];
                    _id          = dr["id"].ToString();

                    DataTable dtNew = new DataTable();
                    dtNew.Columns.Add("luru_name", typeof(string));
                    dtNew.Columns.Add("luru_val", typeof(string));
                    dtNew.Columns.Add("id", typeof(string));
                    dtNew.Columns.Add("lookqu", typeof(string));
                    dtNew.Columns.Add("dc", typeof(string));

                    foreach (DataColumn dc in dt.Columns)
                    {
                        DataRow newRow = dtNew.NewRow();
                        if (dc.ColumnName == "user_id" || dc.ColumnName == "id" || dc.ColumnName == "input_time")
                        {
                            continue;
                        }

                        if (dc.ColumnName == "fbg")
                        {
                            newRow["luru_name"] = "空腹血糖";
                            newRow["dc"]        = "fbg";
                        }

                        if (dc.ColumnName == "pbg")
                        {
                            newRow["luru_name"] = "餐后血糖";
                            newRow["dc"]        = "pbg";
                        }

                        if (dc.ColumnName == "chol")
                        {
                            newRow["luru_name"] = "总胆固醇";
                            newRow["dc"]        = "chol";
                        }

                        if (dc.ColumnName == "trig")
                        {
                            newRow["luru_name"] = "甘油三酯";
                            newRow["dc"]        = "trig";
                        }

                        if (dc.ColumnName == "hdl")
                        {
                            newRow["luru_name"] = "高密度胆固醇";
                            newRow["dc"]        = "hdl";
                        }

                        if (dc.ColumnName == "ldl")
                        {
                            newRow["luru_name"] = "低密度胆固醇";
                            newRow["dc"]        = "ldl";
                        }

                        if (dc.ColumnName == "dbp")
                        {
                            newRow["luru_name"] = "舒张压";
                            newRow["dc"]        = "dbp";
                        }

                        if (dc.ColumnName == "sbp")
                        {
                            newRow["luru_name"] = "收缩压";
                            newRow["dc"]        = "sbp";
                        }

                        newRow["id"]       = id;
                        newRow["luru_val"] = dr[dc];
                        newRow["lookqu"]   = "查看趋势图";
                        dtNew.Rows.Add(newRow);
                    }

                    dgcTree.DataSource = dtNew;
                    if (gridView1.GroupCount > 0)
                    {
                        gridView1.ExpandAllGroups();
                    }

                    gridView1.MoveFirst();
                    if (dt == null)
                    {
                        return;
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.Log.Error("实体加载数据出错", ex);
                    DXMessageBox.ShowWarning2("没有数据");
                }
            });
        }
コード例 #28
0
        private DateTime lastScanTime = DateTime.MinValue; //上次扫描日期

        /// <summary>
        /// 处理无线设备临时接收表里的数据
        /// </summary>
        /// <param name="state"></param>
        private void MoveMonitorReceived(object state)
        {
            try
            {
                if ((DateTime.Now - lastScanTime).TotalMinutes > 5) //每5分钟处理一次
                {
                    List <string> sqlList = new List <string>();
                    DataTable     tmo_monitor_devicebind = MemoryCacheHelper.GetCacheItem <DataTable>("tmo_monitor_devicebind",
                                                                                                      () => MySQLHelper.QueryTable(
                                                                                                          "select a.*,b.is_del from tmo_monitor_devicebind a left join tmo_userinfo b on a.dev_userid=b.user_id where b.is_del!=1"),
                                                                                                      DateTime.Now.AddMinutes(30));
                    if (TmoShare.DataTableIsEmpty(tmo_monitor_devicebind))
                    {
                        return;
                    }
                    DataTable dtstruct = MemoryCacheHelper.GetCacheItem <DataTable>("ts_tmo_monitor", () => MySQLHelper.QueryTableStruct("tmo_monitor").Tables[0],
                                                                                    DateTime.Now.AddHours(24));
                    DataTable tmo_monitor_received =
                        Tmo_FakeEntityManager.Instance.GetData("tmo_monitor_received", null, $"input_time>='{DateTime.Now.AddDays(-30)}'");
                    if (TmoShare.DataTableIsNotEmpty(tmo_monitor_received))
                    {
                        foreach (DataRow row in tmo_monitor_received.Rows)
                        {
                            string user_id = row.GetDataRowStringValue("user_id");

                            //int dev_type = row.GetDataRowIntValue("remark");
                            DataRow[] drs = tmo_monitor_devicebind.Select($"dev_sn = '{user_id}'");
                            if (drs.Length == 0)
                            {
                                if (Regex.IsMatch(user_id, @"^[\s|\S]"))
                                {
                                    user_id = user_id.Substring(user_id.Length - 2, 2) + user_id.Remove(user_id.Length - 2);
                                    drs     = tmo_monitor_devicebind.Select($"dev_sn = '{user_id}'");
                                }
                            }

                            if (drs.Length > 0)
                            {
                                user_id = drs[0].GetDataRowStringValue("dev_userid"); //找到绑定关系
                                Dictionary <string, string> colVals = new Dictionary <string, string>();
                                colVals.Add("user_id", user_id);

                                foreach (DataColumn dc in tmo_monitor_received.Columns)
                                {
                                    string colname = dc.ColumnName;
                                    if (colname.ToLower() == "id" || colname.ToLower() == "input_time")
                                    {
                                        continue;                                                                 //跳过主键
                                    }
                                    if (colVals.ContainsKey(colname))
                                    {
                                        continue;                               //已添加字段跳过
                                    }
                                    if (!dtstruct.Columns.Contains(colname))
                                    {
                                        continue;                                      //非monitor表中字段跳过
                                    }
                                    colVals.Add(colname, row[dc].ToString());
                                }

                                StringBuilder sbsql    = new StringBuilder("insert into tmo_monitor(");
                                StringBuilder sbsqlval = new StringBuilder(" values(");
                                foreach (var item in colVals)
                                {
                                    if (item.Key == "mt_time")
                                    {
                                        try
                                        {
                                            DateTime dt = DateTimeHelper.ToDateTime(item.Value);
                                            sbsql.Append(item.Key + ",");
                                            sbsqlval.AppendFormat("'{0}',", dt.ToFormatDateTimeStr());
                                        }
                                        catch
                                        {
                                            continue;
                                        }
                                    }
                                    else
                                    {
                                        sbsql.Append(item.Key + ",");
                                        sbsqlval.AppendFormat("{0},", item.Value == String.Empty ? "null" : $"'{item.Value}'");
                                    }
                                }

                                sbsql.Append("input_time)");
                                sbsqlval.Append("SYSDATE())");
                                sqlList.Add(sbsql.ToString() + sbsqlval.ToString());

                                sqlList.Add("delete from tmo_monitor_received where id=" + row["id"]);
                            }
                        }
                    }

                    if (sqlList.Count != 0)
                    {
                        MySQLHelper.ExecuteSqlTran(sqlList);
                    }
                    lastScanTime = DateTime.Now;
                }
            }
            catch (Exception ex)
            {
                LogHelper.Log.Error("临时表保存数据到监测表错误", ex);
            }
            finally
            {
                ((ManualResetEvent)((object[])state)[0]).Set();
            }
        }
コード例 #29
0
        /// <summary>
        /// 监测数据推送微信
        /// </summary>
        /// <param name="state"></param>
        private void MonitorSendWe(object state)
        {
            string data     = @"<data>
                                <first>
                                    <value></value>
                                    <color></color>
                                </first>
                                <keyword1>
                                    <value></value>
                                    <color></color>
                                </keyword1>
                                <keyword2>
                                    <value></value>
                                    <color></color>
                                </keyword2>
                                <keyword3>
                                    <value></value>
                                    <color></color>
                                </keyword3>
                                <remark>
                                    <value></value>
                                    <color></color>
                                </remark>        
                            </data>";
            string result   = "";
            string testName = "";

            if ((DateTime.Now - lastMonitorSendWeTime).TotalSeconds >= 30) //30秒查询一次
            {
                var dtUser = Tmo_FakeEntityManager.Instance.GetData("tmo_monitor",
                                                                    new[] { "user_id", "mt_code", "mt_valueint", "mt_time", "mt_valuefloat", "mt_isnormal", "id", "mt_timestamp" },
                                                                    "mt_code in (100,101,102,103) and we_send ='2' and mt_time>=date_add(NOW(), interval -7 day)", null, null, null, false, 1000);
                if (TmoShare.DataTableIsNotEmpty(dtUser))
                {
                    List <string> skipIds = new List <string>();
                    foreach (DataRow dr in dtUser.Rows)
                    {
                        string id = dr.GetDataRowStringValue("id");
                        if (skipIds.Contains(id))
                        {
                            continue;                       //跳过处理过的血压数据
                        }
                        string userid = dr.GetDataRowStringValue("user_id");
                        if (string.IsNullOrWhiteSpace(userid))
                        {
                            continue;
                        }
                        //查询微信绑定
                        string myweixin = tmo_userinfo_tokenManager.Instance.GetBindId(userid);
                        //查询亲友是否绑定微信
                        DataSet familyds = tmo_userinfoManager.Instance.IsBindFamily(userid);
                        if (string.IsNullOrWhiteSpace(myweixin) && TmoShare.DataSetIsEmpty(familyds))
                        {
                            continue; //没有绑定微信 跳过
                        }
                        List <string> ids = new List <string>();
                        ids.Add(id);

                        string timestamp = dr.GetDataRowStringValue("mt_timestamp");

                        #region 组织发送内容

                        switch (dr["mt_code"].ToString())
                        {
                        case "100":     //舒张压
                            DataRow[] rows = dtUser.Select(string.Format("mt_code=101 and user_id='{0}' and mt_timestamp='{1}'", userid, timestamp));
                            string    ssy  = null;
                            if (rows.Length > 0)
                            {
                                ssy = rows[0].GetDataRowStringValue("mt_valueint");
                                string ssyid = rows[0].GetDataRowStringValue("id");
                                skipIds.Add(ssyid);
                                ids.Add(ssyid);
                            }

                            if (ssy == null)
                            {
                                result = "【舒张压】" + dr["mt_valueint"].ToString() + "mmHg";
                            }
                            else
                            {
                                result = ssy + "/" + dr.GetDataRowStringValue("mt_valueint") + " mmHg";
                            }
                            testName = "血压";
                            break;

                        case "101":     //收缩压
                            DataRow[] row1s = dtUser.Select(string.Format("mt_code=100 and user_id='{0}' and mt_timestamp='{1}'", userid, timestamp));
                            string    szy   = null;
                            if (row1s.Length > 0)
                            {
                                szy = row1s[0].GetDataRowStringValue("mt_valueint");
                                string szyid = row1s[0].GetDataRowStringValue("id");
                                skipIds.Add(szyid);
                                ids.Add(szyid);
                            }

                            if (szy == null)
                            {
                                result = "【收缩压】" + dr["mt_valueint"].ToString() + "mmHg";
                            }
                            else
                            {
                                result = dr.GetDataRowStringValue("mt_valueint") + "/" + szy + " mmHg";
                            }
                            testName = "血压";
                            break;

                        case "102":     //心率
                            result   = dr["mt_valueint"].ToString() + "次/分钟";
                            testName = "心率";
                            break;

                        case "103":     //血糖
                            result   = dr["mt_valuefloat"].ToString() + "mmol/L";
                            testName = "血糖";
                            break;

                        default:
                            break;
                        }

                        #endregion

                        #region 发送给自己

                        //查询自己是否绑定微信
                        if (!string.IsNullOrEmpty(myweixin))
                        {
                            DataSet ds = TmoShare.getDataSetFromXML(data);

                            ds.Tables["first"].Rows[0]["value"] = "尊敬的用户,您刚刚完成的测量:";
                            ds.Tables["first"].Rows[0]["color"] = TmoShare.RGBToWebColor(Color.Gray);

                            ds.Tables["keyword1"].Rows[0]["value"] = string.Format("[{0}]", testName);
                            ds.Tables["keyword1"].Rows[0]["color"] = "#507ED3";
                            ds.Tables["keyword2"].Rows[0]["value"] = dr.GetDataRowDateTimeValue("mt_time").ToString("yyyy年MM月dd日 HH:mm:ss");
                            ds.Tables["keyword2"].Rows[0]["color"] = TmoShare.RGBToWebColor(Color.Gray);
                            ds.Tables["keyword3"].Rows[0]["value"] = result;
                            ds.Tables["keyword3"].Rows[0]["color"] = TmoShare.RGBToWebColor(Color.Green);
                            ds.Tables["remark"].Rows[0]["value"]   = "建议您养成定期测量" + testName + "的习惯,感谢您的使用!";
                            ds.Tables["remark"].Rows[0]["color"]   = TmoShare.RGBToWebColor(Color.Gray);
                            string content = TmoCommon.TmoShare.GetXml_NO_TITLE(ds);

                            string idstr = string.Join(",", ids);
                            Dictionary <string, object> dicVals = new Dictionary <string, object>();
                            dicVals.Add("push_id", idstr);
                            dicVals.Add("user_code", userid);
                            dicVals.Add("push_type", 6);
                            dicVals.Add("push_address", myweixin);
                            dicVals.Add("content_type", "1");
                            dicVals.Add("content_title", "健康监测消息推送");
                            dicVals.Add("content_value", content);
                            dicVals.Add("push_status", 1);
                            dicVals.Add("doc_code", "admin");
                            dicVals.Add("remark", "weMonitor");

                            bool suc = tmo_push_listManager.Instance.AddToPushList(dicVals);
                            if (suc)
                            {
                                tmo_monitorManager.Instance.UpdateWXState(idstr, 3); //推送中
                            }
                        }

                        #endregion

                        #region 发送给绑定的家人

                        if (TmoShare.DataSetIsNotEmpty(familyds))
                        {
                            #region 用户信息

                            string   username = userid;
                            Userinfo user     = tmo_userinfoManager.Instance.GetUserInfoByID(userid);
                            if (user != null)
                            {
                                username = user.name;
                            }

                            #endregion

                            for (int i = 0; i < familyds.Tables[0].Columns.Count; i++)
                            {
                                DataColumn cloum    = familyds.Tables[0].Columns[i];
                                string     key      = cloum.ColumnName;
                                string     familyId = familyds.Tables[0].Rows[0][key].ToString();
                                if (string.IsNullOrEmpty(familyId))
                                {
                                    continue;
                                }

                                string familyweixin = tmo_userinfo_tokenManager.Instance.GetBindId(familyId);
                                if (!string.IsNullOrWhiteSpace(familyweixin))
                                {
                                    DataSet ds = TmoShare.getDataSetFromXML(data);

                                    ds.Tables["first"].Rows[0]["value"]    = "尊敬的用户,您的亲人" + username + "刚刚完成的测量:";
                                    ds.Tables["first"].Rows[0]["color"]    = TmoShare.RGBToWebColor(Color.Gray);
                                    ds.Tables["keyword1"].Rows[0]["value"] = string.Format("[{0}]", testName);
                                    ds.Tables["keyword1"].Rows[0]["color"] = "#507ED3";
                                    ds.Tables["keyword2"].Rows[0]["value"] = dr.GetDataRowDateTimeValue("mt_time").ToString("yyyy年MM月dd日 HH:mm:ss");
                                    ds.Tables["keyword2"].Rows[0]["color"] = TmoShare.RGBToWebColor(Color.Gray);
                                    ds.Tables["keyword3"].Rows[0]["value"] = result;
                                    ds.Tables["keyword3"].Rows[0]["color"] = TmoShare.RGBToWebColor(Color.Green);
                                    ds.Tables["remark"].Rows[0]["value"]   = "感谢您的使用!";
                                    ds.Tables["remark"].Rows[0]["color"]   = TmoShare.RGBToWebColor(Color.Gray);
                                    string content = TmoCommon.TmoShare.GetXml_NO_TITLE(ds);

                                    string idstr = string.Join(",", ids);
                                    Dictionary <string, object> dicVals = new Dictionary <string, object>();
                                    dicVals.Add("push_id", idstr + "," + -1 * (i + 1));
                                    dicVals.Add("user_code", userid);
                                    dicVals.Add("push_type", 6);
                                    dicVals.Add("push_address", familyweixin);
                                    dicVals.Add("content_type", "1");
                                    dicVals.Add("content_title", "健康监测消息推送");
                                    dicVals.Add("content_value", content);
                                    dicVals.Add("push_status", 1);
                                    dicVals.Add("doc_code", "admin");
                                    dicVals.Add("remark", "weMonitor");

                                    bool suc = tmo_push_listManager.Instance.AddToPushList(dicVals);
                                    if (suc)
                                    {
                                        tmo_monitorManager.Instance.UpdateWXState(idstr, 3); //推送中
                                    }
                                }
                            }
                        }

                        #endregion
                    }
                }

                lastMonitorSendWeTime = DateTime.Now;
            }

            ((ManualResetEvent)((object[])state)[0]).Set();
        }
コード例 #30
0
        public void GetItemData(DataRow dr)
        {
            assessment_time.Visible = false;
            int    user_times = 0;
            string timesStr   = dr["user_times"] == null ? "" : dr["user_times"].ToString();

            int.TryParse(timesStr, out user_times);
            DataTable dt    = dr.Table.Clone();
            string    times = "";
            string    clum  = "";

            try
            {
                times = dr["assessment_time"].ToString();
                clum  = "assessment_time";
            }
            catch
            {
                try
                {
                    times = dr["input_time"].ToString();
                    clum  = "input_time";
                }
                catch (Exception)
                {
                    times = dr["questionnaire_time"].ToString();
                    clum  = "questionnaire_time";
                }
            }

            Dictionary <string, string> dics = new Dictionary <string, string>();
            string    userId  = dr["user_id"].ToString();
            string    strmlx  = TmoServiceClient.InvokeServerMethodT <string>(funCode.GetIds, new object[] { userId, "" });
            DataTable dtTable = TmoShare.getDataTableFromXML(strmlx);

            if (TmoShare.DataTableIsNotEmpty(dtTable))
            {
                foreach (DataRow row in dtTable.Rows)
                {
                    if (row["usertimes"] != null && !string.IsNullOrEmpty(row["usertimes"].ToString()))
                    {
                        dics.Add(row["usertimes"].ToString(), row["qc_ids"].ToString());
                    }
                }
            }

            for (int i = 1; i <= user_times; i++)
            {
                DataRow newDr = dt.NewRow();
                newDr["user_id"]    = userId;
                newDr["user_times"] = i.ToString();
                newDr["name"]       = dr["name"];
                newDr["gender"]     = dr["gender"];
                newDr["age"]        = dr["age"];
                newDr["address"]    = dr["address"];
                string key = i.ToString();
                newDr["qc_ids"]     = dics[key];
                newDr[clum]         = times;
                newDr["birth_date"] = dr["birth_date"];
                if (i == user_times)
                {
                    newDr["del"] = dr["del"];
                }
                else
                {
                    newDr["del"] = "---";
                }
                newDr["look_report"] = dr["look_report"];
                newDr["lookImg"]     = "浏览";
                newDr["lookold"]     = "浏览(旧)";
                //dt.Columns.Add("lookold", typeof(string));
                //dt.Columns.Add("lookImg", typeof(string));
                //foreach (DataRow row in dt.Rows)
                //{
                //    row["lookImg"] = "浏览病历";
                //    //  row["look_report"]
                //    row["lookold"] = "浏览之前上传病历";
                //}
                dt.Rows.Add(newDr);
            }


            dgcTree.DataSource = dt;
            if (gridView1.GroupCount > 0)
            {
                gridView1.ExpandAllGroups();
            }

            gridView1.MoveFirst();
            if (dt == null)
            {
                return;
            }
        }