コード例 #1
0
        public Rs Share(object paramses)
        {
            //格式化参数
            Dictionary <string, string> p = JsonConvert.DeserializeObject <Dictionary <string, string> >(paramses.ToString());

            Rs rs = Rs.Ok();

            if (p.TryGetValue("__id", out string _id) && Guid.TryParse(_id, out Guid id))
            {
                using (Muse db = new Muse())
                {
                    var record = db.Get <ReportDataSetModel>(x => x.ShareId == id && id != Guid.Empty, new[] { "ReportDataSourceModel" });

                    string cs  = record.ReportDataSourceModel.ConnectionString;
                    string sql = record.Sql;

                    MySqlHelper msHelper = new MySqlHelper(cs);
                    DataTable   dt       = msHelper.Select(sql, out int recordsAffected);
                    var         dic      = TableConvert.Table2Dictionary(dt);
                    rs.Add("table", dic);
                    rs.Add("recordsAffected", recordsAffected);
                    return(rs);
                }
            }
            else
            {
                rs = Rs.Error();
            }
            return(rs);
        }
コード例 #2
0
        public JsonResult SetShare(Guid id)
        {
            Rs rs = Rs.Ok("共享成功");

            using (Muse db = new Muse())
            {
                var record = db.Get <ReportDataSetModel>(x => x.Id == id && id != Guid.Empty, null);
                record.ShareId = Guid.NewGuid();
                if (db.Update(record, true) > 0)
                {
                    rs.Add("record", record);
                }
                else
                {
                    rs = Rs.Error("共享失败");
                    rs.Add("record", record);
                }
                return(Json(rs, JsonRequestBehavior.AllowGet));
            }
        }