public ActionResult AddUpdateSave(ModUApiManager mod, FormCollection form)
        {
            ModUApiManager model                = new ModUApiManager();
            string         status_name          = CUtil.CStr(form["status_name"]);
            MongoCollection <ModUApiManager> mg = mongoh.GetCollection <ModUApiManager>();
            var eq = Query.EQ("_id", new BsonString(mod._id));

            if (status_name == "1")
            {
                model = mg.Find(eq).FirstOrDefault();
                if (model != null)
                {
                    return(Content(Util.JsUrlTo(Url.Action("Index"), "新增失败,香信号已存在")));
                }
                model                 = new ModUApiManager();
                model._id             = mod._id.ToUpper();
                model.is_disabled     = mod.is_disabled;
                model.user_name       = mod.user_name;
                model.last_login_time = DateTime.Now;
                mg.Insert(model);
                return(Content(Util.JsUrlTo(Url.Action("Index"), "新增成功")));
            }
            model = mg.Find(eq).FirstOrDefault();
            if (model == null)
            {
                return(Content(Util.JsUrlTo(Url.Action("Index"), "修改失败,数据不存在")));
            }
            model.is_disabled = mod.is_disabled;
            model.user_name   = mod.user_name;
            BsonDocument bd = BsonExtensionMethods.ToBsonDocument(model);

            mg.Update(Query.EQ("_id", new BsonString(mod._id)), new UpdateDocument(bd));
            return(Content(Util.JsUrlTo(Url.Action("Index"), "修改成功")));
        }
Esempio n. 2
0
        protected override void OnAuthorization(AuthorizationContext filterContext)
        {
            ViewBag.MyCivetNo = CUtil.CStr(UserInfo.BaseInfo.civetno).ToLower();  //当前用户的香信号
            string controller = this.RouteData.Values["controller"].ToString().ToLower();
            string action     = this.RouteData.Values["action"].ToString().ToLower();

            if (controller != "Home".ToLower())  //需要验证的页面
            {
                if (ViewBag.MyCivetNo == "")
                {
                    OAuth oauth = new OAuth(CivetHelper.AppID);

                    string id = CUtil.CStr(this.RouteData.Values["ID"]);

                    string QueryString  = HtmlUtil.DealQuery(Request.QueryString.ToString(), "code");
                    string redirect_url = "http://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/')
                                          + "/Login-" + controller + "/" + action + (id != "" ? "/" + id : "")
                                          + (QueryString != "" ? "?" + QueryString : "");

                    string msg = "";
                    if (ViewBag.MyCivetNo != "")
                    {
                        msg = "无权操作";
                    }
                    filterContext.Result = Content(Util.JsUrlTo(oauth.GenerateOAuthUrl(redirect_url), msg));
                    return;
                }
            }

            base.OnAuthorization(filterContext);
        }
        public ActionResult UpdateInfoSave(ModUApiPowerAplictionFind mod, FormCollection form)
        {
            string id = CUtil.CStr(form["id"]);
            MongoCollection <ModUApiPowerAplictionFind> modUApiPowerAplictionFind = mongoh.GetCollection <ModUApiPowerAplictionFind>();
            ModUApiPowerAplictionFind Model = modUApiPowerAplictionFind.Find(Query.EQ("_id", new ObjectId(id))).FirstOrDefault();

            if (Model == null)
            {
                return(Content(Util.JsUrlTo(Url.Action("Index_Already"), "数据读取异常")));
            }
            var strLocation = Query.EQ("_id", new ObjectId(id));

            modUApiPowerAplictionFind.Update((strLocation), Update.Set("serviceno_uid", mod.serviceno_uid == null ? "" : mod.serviceno_uid).Set("civetno", mod.civetno == null ? "" : mod.civetno).Set("user_name", mod.user_name == null ? "" : mod.user_name).Set("mobile", mod.mobile == null ? "" : mod.mobile).Set("ext_phone", mod.ext_phone == null ? "" : mod.ext_phone).Set("bg_name", mod.bg_name == null ? "" : mod.bg_name).Set("bu_name", mod.bu_name == null ? "" : mod.bu_name).Set("dept_name", mod.dept_name == null ? "" : mod.dept_name).Set("cost_code", mod.cost_code == null ? "" : mod.cost_code).Set("apply_reason", mod.apply_reason == null ? "" : mod.apply_reason));
            return(Content(Util.JsCustom("alert('修改成功');window.parent._close_dialog(); window.parent.refresh();")));
        }