Esempio n. 1
0
        public bool AddIntervene(DBModel.tmo_intervene model)
        {
            if (model == null)
            {
                return(false);
            }
            model.input_time = DateTime.Now;
            List <tmo_intervene> list    = new List <tmo_intervene>();
            List <string>        users   = StringPlus.GetStrArray(model.user_id, ",");
            List <string>        address = StringPlus.GetStrArray(model.inte_addr, ",");

            if (users.Count > 1)
            {
                for (var i = 0; i < users.Count; i++)
                {
                    tmo_intervene newmodel = TmoShare.DeepCopy <tmo_intervene>(model);
                    newmodel.inte_id   = TmoShare.GetGuidString();
                    newmodel.user_id   = users[i];
                    newmodel.inte_addr = address[i];
                    list.Add(newmodel);
                }
            }
            else
            {
                list.Add(model);
            }

            var dics = ModelConvertHelper <tmo_intervene> .ConvertModelToDictionaries(list);

            return(MySQLHelper.AddDatas("tmo_intervene", dics));
        }
Esempio n. 2
0
        public bool AddOpinion(string userID, string title, string content)
        {
            StringBuilder sbSql = new StringBuilder();

            sbSql.Append("insert into tmo_advising_clients(");
            sbSql.Append("advise_id,user_id,advise_title,advise_content,answer_state,ask_time,is_del,input_time)");
            sbSql.Append(" values ( '");
            sbSql.Append(TmoShare.GetGuidString() + "','" + userID + "','" + title + "','" + content + "','2','" + DateTime.Now + "','1','" + DateTime.Now + "')");
            int num = MySQLHelper.ExecuteSql(sbSql.ToString());

            return(num > 0 ? true : false);
        }
Esempio n. 3
0
        protected override bool BeforeSubmitData(Dictionary <string, object> dicData)
        {
            DateTime inte_plantime = DateTime.Now;

            if (!chkNow.Checked)
            {
                inte_plantime = dteIntePlantime.DateTime.Date.Add(teIntePlantime.Time.TimeOfDay);
            }
            if (inte_plantime < DateTime.Now)
            {
                inte_plantime = DateTime.Now;
            }

            dicData.Add("inte_plantime", inte_plantime);
            dicData.Add("inte_status", 1);
            dicData.Add("doc_id", TmoComm.login_docInfo.doc_id);

            if (DbOperaType == DBOperateType.Add)
            {
                int rgval = int.Parse(rgSaveLib.EditValue.ToString());
                if (rgval != 0 && _inte_type != 1)  //需要保存到库
                {
                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic.Add("intelb_id", Tmo_FakeEntityClient.Instance.GetNextID("tmo_intervenelib", "intelb_id"));
                    dic.Add("intelb_title", inte_title.Text);
                    dic.Add("intelb_content", inte_content.Text);
                    dic.Add("intelb_type", lbType.EditValue);
                    dic.Add("doc_id", TmoComm.login_docInfo.doc_id);
                    dic.Add("is_public", rgval - 1);
                    Tmo_FakeEntityClient.Instance.SubmitData(DBOperateType.Add, "tmo_intervenelib", "intelb_id", null, dic);
                }

                var model = ModelConvertHelper <tmo_intervene> .ConvertToOneModel(dicData);

                model.inte_id   = TmoShare.GetGuidString();
                model.user_id   = user_id.Tag.ToString();
                model.inte_type = _inte_type;
                bool suc = TmoServiceClient.InvokeServerMethodT <bool>(funCode.AddIntervene, model);
                if (suc)
                {
                    this.ParentForm.DialogResult = DialogResult.OK;
                }
                else
                {
                    DXMessageBox.ShowError("新建干预失败,请稍后再试!", this);
                }
                return(false);
            }

            return(true);
        }
Esempio n. 4
0
        public bool Add(DBModel.tmo_push_list model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tmo_push_list(");
            strSql.Append("push_id,user_code,push_type,push_address,content_type,content_title,content_value,content_url,push_status,push_count,push_time,doc_code,remark,input_time)");
            strSql.Append(" values (");
            strSql.Append("@push_id,@user_code,@push_type,@push_address,@content_type,@content_title,@content_value,@content_url,@push_status,@push_count,@push_time,@doc_code,@remark,@input_time)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@push_id",       MySqlDbType.VarChar,    50),
                new MySqlParameter("@user_code",     MySqlDbType.VarChar,    50),
                new MySqlParameter("@push_type",     MySqlDbType.VarChar,    50),
                new MySqlParameter("@push_address",  MySqlDbType.VarChar,   200),
                new MySqlParameter("@content_type",  MySqlDbType.VarChar,    50),
                new MySqlParameter("@content_title", MySqlDbType.VarChar,   100),
                new MySqlParameter("@content_value", MySqlDbType.Text),
                new MySqlParameter("@content_url",   MySqlDbType.VarChar,   200),
                new MySqlParameter("@push_status",   MySqlDbType.Int32,       2),
                new MySqlParameter("@push_count",    MySqlDbType.Int32,      10),
                new MySqlParameter("@push_time",     MySqlDbType.DateTime),
                new MySqlParameter("@doc_code",      MySqlDbType.VarChar,    50),
                new MySqlParameter("@remark",        MySqlDbType.VarChar,   100),
                new MySqlParameter("@input_time",    MySqlDbType.DateTime)
            };
            parameters[0].Value  = TmoShare.GetGuidString();
            parameters[1].Value  = model.user_code;
            parameters[2].Value  = model.push_type;
            parameters[3].Value  = model.push_address;
            parameters[4].Value  = model.content_type;
            parameters[5].Value  = model.content_title;
            parameters[6].Value  = model.content_value;
            parameters[7].Value  = model.content_url;
            parameters[8].Value  = model.push_status;
            parameters[9].Value  = model.push_count;
            parameters[10].Value = model.push_time;
            parameters[11].Value = model.doc_code;
            parameters[12].Value = model.remark;
            parameters[13].Value = TmoShare.DateTimeNow;

            int rows = MySQLHelper.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 5
0
 public bool Delete(string pushID, int trySendTimes, bool isTrue)
 {
     try
     {
         //查询次数
         object pushCountobj = MySQLHelper.GetSingle("select push_count from tmo_push_list where push_id='" + pushID + "'");
         int    pushCount    = 1;
         if (pushCountobj != null && !string.IsNullOrWhiteSpace(pushCountobj.ToString()))
         {
             pushCount = Convert.ToInt32(pushCountobj);
         }
         pushCount++;   //每次自动加1
         List <string> sqlList = new List <string>();
         //成功删除数据,失败更新数据
         string receiveSql = "UPDATE tmo_push_list SET push_count=" + pushCount + ",push_time='" + TmoShare.DateTimeNow + "' WHERE push_id='" + pushID + "'";
         if (isTrue || pushCount >= trySendTimes)
         {
             string historySql = @"INSERT INTO tmo_push_history 
                              SELECT '" + TmoShare.GetGuidString() + "',user_code,push_type,push_address,content_type,content_title,content_value,content_url,{0},"
                                 + pushCount + ",'" + TmoShare.DateTimeNow + @"',doc_code,remark,input_time 
                              FROM tmo_push_list 
                              WHERE  push_id = '" + pushID + "'";
             historySql = isTrue ? string.Format(historySql, 1) : string.Format(historySql, 2);
             sqlList.Add(historySql);
             receiveSql = string.Format("delete from tmo_push_list where push_id='{0}'", pushID);
         }
         sqlList.Add(receiveSql);
         int rows = MySQLHelper.ExecuteSqlTran(sqlList); //将数据移动到历史表中
         if (rows > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch
     {
         return(false);
     }
 }
        public bool SaveActionPlan(string userid, int user_times, string content, byte[] pdfbytes)
        {
            if (string.IsNullOrWhiteSpace(userid) || string.IsNullOrWhiteSpace(content))
            {
                return(false);
            }

            Dictionary <string, object> dicContent = TmoShare.GetValueFromJson <Dictionary <string, object> >(content);
            DateTime apstartdate = DateTime.MinValue;
            DateTime apenddate   = DateTime.MinValue;

            if (dicContent.ContainsKey("0_3"))
            {
                apstartdate = (DateTime)dicContent["0_3"];
            }
            if (dicContent.ContainsKey("0_4"))
            {
                apenddate = (DateTime)dicContent["0_4"];
            }

            Dictionary <string, string> dicData = new Dictionary <string, string>();

            dicData.Add("userid", userid);
            dicData.Add("usertimes", user_times.ToString());

            bool update = MySQLHelper.Exists("tmo_actionplan", dicData);

            if (apstartdate != DateTime.MinValue)
            {
                dicData.Add("apstartdate", apstartdate.ToFormatDateStr());
            }
            if (apenddate != DateTime.MinValue)
            {
                dicData.Add("apenddate", apenddate.ToFormatDateStr());
            }
            if (dicContent.ContainsKey("aclb_id"))
            {
                dicData.Add("aplib", dicContent["aclb_id"].ToString());
            }

            string apid = string.Empty;

            if (!update)
            {
                apid = TmoShare.GetGuidString();
                dicData.Add("apid", apid);
            }
            else
            {
                apid =
                    MySQLHelper.GetSingle("select apid from tmo_actionplan where userid='" + userid + "' and usertimes=" +
                                          user_times).ToString();
            }

            dicData.Add("content", content);

            if (pdfbytes != null)
            {
                string acpath  = ConfigHelper.GetConfigString("acPath");
                string pdfpath = Path.Combine(Environment.CurrentDirectory, userid + "_" + user_times + ".pdf");
                if (!string.IsNullOrWhiteSpace(acpath))
                {
                    pdfpath = Path.Combine(acpath, userid + "_" + user_times + ".pdf");
                }
                try
                {
                    if (File.Exists(pdfpath))
                    {
                        File.Delete(pdfpath);
                    }
                    File.WriteAllBytes(pdfpath, pdfbytes);
                }
                catch
                {
                    if (!Debugger.IsAttached)
                    {
                        return(false);
                    }
                }

                dicData.Add("pdfpath", pdfpath.Replace('\\', '|'));
            }

            bool suc = false;

            if (update)
            {
                suc = MySQLHelper.UpdateData("tmo_actionplan", "apid", apid, dicData);
            }
            else
            {
                suc = MySQLHelper.AddData("tmo_actionplan", dicData);
            }

            if (suc && pdfbytes != null)
            {
                string updateSql = "update tmo_userstatus set questionnare_status=4,actionplan_time='{2}' where user_id='{0}' and usertimes='{1}'";
                suc = MySQLHelper.ExecuteSql(string.Format(updateSql, userid, user_times, DateTime.Now)) > 0;
            }
            return(suc);
        }
        public string PushAddWeiXinAnswer(string strxml)
        {
            if (!string.IsNullOrEmpty(strxml))
            {
                DataSet ds = TmoShare.getDataSetFromXML(strxml);
                if (ds == null || ds.Tables.Count < 0 || ds.Tables[0] == null || ds.Tables[0].Rows.Count < 0)
                {
                    return("error");
                }
                else
                {
                    DataRow row    = ds.Tables[0].Rows[0];
                    string  awm_id = row["awm_id"].ToString();
                    if (awm_id == "1")
                    {
                        #region 是否为第一次回复

                        string sqlUpdate = "update tmo_weixin_content set is_answer=1,is_look=1 where wm_id='" + row["wm_id"].ToString() + "'";
                        int    num1      = MySQLHelper.ExecuteSql(sqlUpdate);
                        if (num1 <= 0)
                        {
                            return("error");
                        }
                        string sql = "insert into tmo_weixin_answer (awm_id,wm_id,answer_code,token_open_id,input_time,content,is_del,r_mark)" +
                                     "VALUES(?awm_id,?wm_id,?answer_code,?token_open_id,?input_time,?content,?is_del,?r_mark)";

                        MySqlParameter[] parameters =
                        {
                            new MySqlParameter("?awm_id",        MySqlDbType.VarChar,     30),
                            new MySqlParameter("?wm_id",         MySqlDbType.VarChar,    100),
                            new MySqlParameter("?answer_code",   MySqlDbType.VarChar,   5000),
                            new MySqlParameter("?token_open_id", MySqlDbType.VarChar,    100),
                            new MySqlParameter("?input_time",    MySqlDbType.DateTime),
                            new MySqlParameter("?content",       MySqlDbType.VarChar,    100),
                            new MySqlParameter("?is_del",        MySqlDbType.Int32,       11),
                            new MySqlParameter("?r_mark",        MySqlDbType.VarChar, 500)
                        };


                        parameters[0].Value = TmoShare.GetGuidString();
                        parameters[1].Value = row["wm_id"].ToString();
                        parameters[2].Value = row["answer_code"].ToString();
                        parameters[3].Value = row["token_open_id"].ToString();
                        parameters[4].Value = System.DateTime.Now;
                        parameters[5].Value = row["content"].ToString();
                        parameters[6].Value = 1;
                        parameters[7].Value = row["r_mark"].ToString();

                        int num = MySQLHelper.ExecuteSql(sql, parameters);

                        if (num > 0)
                        {
                            return("success");
                        }
                        else
                        {
                            return("error");
                        }

                        #endregion
                    }
                    else
                    {
                        string sql = "insert into tmo_weixin_answer (awm_id,wm_id,answer_code,token_open_id,input_time,content,is_del,r_mark)" +
                                     "VALUES('" + TmoShare.GetGuidString() + "','" + row["wm_id"].ToString() + "','" + row["answer_code"].ToString() + "','"
                                     + row["token_open_id"].ToString() + "','" + System.DateTime.Now + "','" + row["content"].ToString() +
                                     "',1,'" + row["r_mark"].ToString() + "')";

                        int num1 = MySQLHelper.ExecuteSql(sql);
                        if (num1 > 0)
                        {
                            return("success");
                        }
                        else
                        {
                            return("error");
                        }
                    }
                }
            }
            else
            {
                return("error");
            }
        }