Exemplo n.º 1
0
        public ActionResult OperateSite()
        {
            //NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
            InvokeResult result = new InvokeResult();

            var siteName = PageReq.GetForm("siteName");
            var opType   = PageReq.GetForm("opType");
            var path     = PageReq.GetForm("path");

            var serverId = PageReq.GetFormInt("serverId");
            var server   = dataOp.FindOneByQuery("ServerInfo", Query.EQ("serverId", serverId.ToString()));

            MZ.BusinessLogicLayer.WebService.RemoteIISSites client = new BusinessLogicLayer.WebService.RemoteIISSites(server.String("serverAddress"));
            var isSuccess = client.OperateWebSite(siteName, opType);

            if (isSuccess)
            {
                result.Status = Status.Successful;
            }
            else
            {
                result.Status = Status.Failed;
            }
            return(Json(TypeConvert.InvokeResultToPageJson(result)));
        }
Exemplo n.º 2
0
        private string SaveDWGNewVersion(FormCollection saveForm, BsonDocument oldfileDoc, DataOperation dataOp)
        {
            string localPath   = PageReq.GetForm("uploadFileList");
            string name        = PageReq.GetForm("name");
            string subMapParam = PageReq.GetForm("subMapParam");
            string newGuid2d   = PageReq.GetForm("guid2d");

            BsonDocument fileDoc = new BsonDocument();

            fileDoc.Add("version", (oldfileDoc.Int("version") + 1).ToString());
            fileDoc.Add("localPath", localPath);
            fileDoc.Add("ext", Path.GetExtension(localPath));
            fileDoc.Add("name", string.IsNullOrEmpty(name) == true ? Path.GetFileName(localPath) : name);
            fileDoc.Add("subMapParam", subMapParam);
            fileDoc.Add("guid2d", newGuid2d);
            var query = Query.EQ("fileId", oldfileDoc.String("fileId"));

            dataOp.Update("FileLibrary", query, fileDoc);

            BsonDocument fileVerDoc = new BsonDocument();

            fileVerDoc.Add("name", fileDoc.String("name"));
            fileVerDoc.Add("ext", fileDoc.String("ext"));
            fileVerDoc.Add("localPath", localPath);
            fileVerDoc.Add("version", fileDoc.String("version"));
            fileVerDoc.Add("subMapParam", subMapParam);
            fileVerDoc.Add("guid2d", newGuid2d);
            fileVerDoc.Add("fileId", oldfileDoc.String("fileId"));
            InvokeResult result = dataOp.Insert("FileLibVersion", fileVerDoc);

            fileVerDoc = result.BsonInfo;
            int fileRelId = 0;

            if (result.Status == Status.Successful)
            {
                var relResult = dataOp.Update("FileRelation", "db.FileRelation.distinct('_id',{'fileId':'" + fileDoc.String("fileId") + "'})", "version=" + fileDoc.String("version"));
                fileRelId = result.BsonInfo.Int("fileRelId");
            }

            List <FileParam> paramList = new List <FileParam>();
            FileParam        fp        = new FileParam();

            fp.path     = localPath;
            fp.ext      = fileDoc.String("ext");
            fp.strParam = string.Format("{0}@{1}-{2}-{3}", "sysObject", fileRelId, oldfileDoc.String("fileId"), fileVerDoc.String("fileVerId"));
            paramList.Add(fp);
            JavaScriptSerializer script = new JavaScriptSerializer();
            string   strJson            = script.Serialize(paramList);
            PageJson json = new PageJson();

            json.Success = result.Status == Status.Successful ? true : false;
            string keyValue  = saveForm["keyValue"] != null ? saveForm["keyValue"] : "0";
            var    strResult = json.ToString() + "|" + strJson + "|" + keyValue;

            return(strResult);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更新推送令牌
        /// </summary>
        /// <returns></returns>
        public JsonResult UpdatePushToken()
        {
            InvokeResult result    = new InvokeResult();
            string       loginName = PageReq.GetForm("loginName");
            string       token     = PageReq.GetForm("token");
            BsonDocument user      = dataOp.FindOneByKeyVal("SysUser", "loginName", loginName);

            if (user != null && !string.IsNullOrEmpty(token))
            {
                BsonDocument doc = new BsonDocument();
                doc.Add("token", token);

                result = dataOp.Update("SysUser", Query.EQ("userId", user.Text("userId")), doc);
            }
            return(Json(result));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 侨鑫单点登陆
        /// </summary>
        /// <returns></returns>
        //[HttpPost]
        public ActionResult login_QXSSO()
        {
            string   certInfo  = PageReq.GetForm("certInfo");
            PageJson json      = new PageJson();
            string   ReturnUrl = PageReq.GetParam("ReturnUrl"); //单点登陆自动跳转页面

            if (string.IsNullOrEmpty(certInfo))
            {
                certInfo = PageReq.GetParam("certInfo");
            }
            certInfo = Server.UrlDecode(certInfo).Replace(" ", "+");
            string redirectUrl = "";

            if (!string.IsNullOrEmpty(ReturnUrl))
            {
                redirectUrl = ReturnUrl;
            }
            else
            {
                redirectUrl = SysAppConfig.IndexUrl; //自动调整页面为空,则调整到首页
            }
            if (!string.IsNullOrEmpty(certInfo))
            {
                loginService login = new loginService();
                string       user  = login.getLoginInfo(certInfo, "userID").Trim();
                if (user == "error")
                {
                    return(Redirect(string.Format("{0}{1}", SysAppConfig.HostDomain, redirectUrl)));;
                }
                else
                {
                    DataOperation dataOp  = new DataOperation();
                    BsonDocument  userObj = dataOp.FindOneByKeyVal("SysUser", "loginName", user);
                    if (userObj != null)
                    {
                        this.SetUserLoginInfo(userObj, "");    //记录用户成功登录的信息
                    }
                }
            }
            else
            {
                return(Redirect(string.Format("{0}{1}", SysAppConfig.HostDomain, redirectUrl)));
            }


            return(Redirect(string.Format("{0}{1}", SysAppConfig.HostDomain, redirectUrl)));
        }
Exemplo n.º 5
0
        public JsonResult SetPushState()
        {
            InvokeResult result    = new InvokeResult();
            string       loginName = PageReq.GetForm("loginName");
            string       isPush    = PageReq.GetForm("isPush");
            BsonDocument user      = dataOp.FindOneByKeyVal("SysUser", "loginName", loginName);

            if (user != null && !string.IsNullOrEmpty(isPush))
            {
                BsonDocument doc = new BsonDocument();
                doc.Add("isPush", isPush);

                result          = dataOp.Update("SysUser", Query.EQ("userId", user.Text("userId")), doc);
                result.BsonInfo = new BsonDocument();
            }
            return(Json(result));
        }
Exemplo n.º 6
0
        public JsonResult GetCustomerByKeyWord()
        {
            string keyWord = PageReq.GetForm("keyWord");
            List <CustomerConfig> customList = new List <CustomerConfig>();

            try
            {
                var list = GenerateCustomerList();
                if (!string.IsNullOrEmpty(keyWord))
                {
                    customList = list.Where(t => t.name.Contains(keyWord)).ToList();
                }
            }
            catch (Exception ex)
            {
            }
            return(Json(customList, JsonRequestBehavior.DenyGet));
        }
Exemplo n.º 7
0
        public string SaveTZCADDWGFile(FormCollection saveForm)
        {
            DataOperation dataOp = new DataOperation();

            Session["userId"] = PageReq.GetFormInt("userId");
            string oldGuid2d   = PageReq.GetForm("oldguid2d");
            bool   isPreDefine = saveForm["isPreDefine"] != null?bool.Parse(saveForm["isPreDefine"]) : false;

            BsonDocument oldfileDoc = dataOp.FindOneByKeyVal("FileLibrary", "guid2d", oldGuid2d);

            #region 判断是否是新建地块
            int isNewProj = PageReq.GetFormInt("isNewProj");

            if (isNewProj == 1)
            {
                InvokeResult newProjRet = new InvokeResult();

                int    nodePid   = PageReq.GetFormInt("nodePid");
                string name      = PageReq.GetForm("name");
                int    typeObjId = 9;

                if (nodePid > 0)
                {
                    newProjRet = dataOp.Insert("ProjectNode", new BsonDocument().Add("name", name).Add("nodePid", nodePid.ToString()).Add("typeObjId", typeObjId.ToString()));
                }

                saveForm["keyValue"] = newProjRet.BsonInfo.String("nodeId");
            }
            #endregion

            if (saveForm["fileObjId"].ToString() == "57")   //如果文档类型是变更单,则直接进入保存
            {
                return(this.SaveMultipleUploadFiles(saveForm));
            }

            if (oldfileDoc == null)
            {
                return(this.SaveMultipleUploadFiles(saveForm));
            }
            else
            {
                return(this.SaveDWGNewVersion(saveForm, oldfileDoc, dataOp));
            }
        }
        public ActionResult SaveCompanyInfo()
        {
            var          tableName     = PageReq.GetForm("tableName");
            var          keyField      = PageReq.GetForm("keyField");
            var          keyValue      = PageReq.GetForm("keyValue");
            var          htmlEditField = PageReq.GetForm("htmlEditField");
            var          htmlEditValue = Server.UrlDecode(PageReq.GetForm("htmlEditValue"));
            var          dataOp        = new DataOperation();
            var          curObj        = dataOp.FindOneByKeyVal(tableName, keyField, keyValue);
            var          updateBson    = new BsonDocument().Add(htmlEditField, htmlEditValue);
            InvokeResult result        = new InvokeResult();

            if (curObj != null)
            {
                result = dataOp.Update(curObj, updateBson);
            }

            return(Json(TypeConvert.InvokeResultToPageJson(result)));
        }
Exemplo n.º 9
0
        public ActionResult QuickMissionSave()
        {
            InvokeResult result = new InvokeResult();

            string missionTemplateId = PageReq.GetForm("missionTemplateId");

            string        weixin      = PageReq.GetForm("weixin");
            string        missionType = PageReq.GetForm("missionType");
            string        type        = PageReq.GetForm("type");
            string        WorkPlanManageConnectionString = System.Web.Configuration.WebConfigurationManager.AppSettings["WorkPlanManageConnectionString"];
            DataOperation dataOp = new DataOperation(WorkPlanManageConnectionString, true);

            if (string.IsNullOrEmpty(missionTemplateId))
            {
                result.Status  = Status.Failed;
                result.Message = "输入参数有误请重试";
                return(Json(TypeConvert.InvokeResultToPageJson(result)));
            }
            var curMissionTemplate = dataOp.FindOneByQuery("MissionTemplate", Query.EQ("_id", ObjectId.Parse(missionTemplateId)));

            if (curMissionTemplate == null)
            {
                result.Status  = Status.Failed;
                result.Message = "输入参数有误请重试";
                return(Json(TypeConvert.InvokeResultToPageJson(result)));
            }
            var           query          = Query.Or(Query.EQ("missionTemplateId", missionTemplateId), Query.EQ("name", curMissionTemplate.Text("name")));
            var           curUserMission = dataOp.FindOneByQuery("MissionLibrary", Query.And(Query.EQ("weixin", weixin), query));
            LifeDayHelper helper         = new LifeDayHelper(dataOp);

            if (curUserMission == null)//添加
            {
                result = helper.InitialMissionTemplate(weixin, missionTemplateId);
            }
            else //删除
            {
                result = dataOp.Delete("MissionLibrary", Query.EQ("_id", ObjectId.Parse(curUserMission.Text("_id"))));
            }

            return(Json(TypeConvert.InvokeResultToPageJson(result)));
        }
Exemplo n.º 10
0
        /// <summary>
        /// 上传多个文件
        /// </summary>
        /// <param name="saveForm"></param>
        /// <returns></returns>
        public string SaveMultipleUploadFiles(FormCollection saveForm)
        {
            DataOperation dataOp = new DataOperation();

            string tableName    = PageReq.GetForm("tableName");
            string keyName      = PageReq.GetForm("keyName");
            string keyValue     = saveForm["keyValue"].ToString();
            string localPath    = PageReq.GetForm("uploadFileList");
            string fileSaveType = saveForm["fileSaveType"] != null ? saveForm["fileSaveType"] : "multiply";
            int    fileTypeId   = PageReq.GetFormInt("fileTypeId");
            int    fileObjId    = PageReq.GetFormInt("fileObjId");
            int    uploadType   = PageReq.GetFormInt("uploadType");
            string subMapParam  = PageReq.GetForm("subMapParam");
            string guid2d       = PageReq.GetForm("guid2d");
            string oldGuid2d    = PageReq.GetForm("oldguid2d");
            bool   isPreDefine  = saveForm["isPreDefine"] != null?bool.Parse(saveForm["isPreDefine"]) : false;

            Dictionary <string, string> propDic  = new Dictionary <string, string>();
            FileOperationHelper         opHelper = new FileOperationHelper();
            List <InvokeResult <FileUploadSaveResult> > result = new List <InvokeResult <FileUploadSaveResult> >();

            localPath = localPath.Replace("\\\\", "\\");

            #region 如果保存类型为单个single 则删除旧的所有关联文件
            if (!string.IsNullOrEmpty(fileSaveType))
            {
                if (fileSaveType == "single")
                {
                    opHelper.DeleteFile(tableName, keyName, keyValue);
                }
            }
            #endregion

            #region 通过关联读取对象属性
            if (!string.IsNullOrEmpty(localPath.Trim()))
            {
                string[] fileStr = Regex.Split(localPath, @"\|H\|", RegexOptions.IgnoreCase);
                Dictionary <string, string> filePath = new Dictionary <string, string>();
                foreach (string file in fileStr)
                {
                    string[] filePaths = Regex.Split(file, @"\|Y\|", RegexOptions.IgnoreCase);

                    if (filePaths.Length > 0)
                    {
                        string[] subfile = Regex.Split(filePaths[0], @"\|Z\|", RegexOptions.IgnoreCase);
                        if (subfile.Length > 0)
                        {
                            if (!filePath.Keys.Contains(subfile[0]))
                            {
                                if (filePaths.Length >= 2)
                                {
                                    filePath.Add(subfile[0], filePaths[1]);
                                }
                                else
                                {
                                    filePath.Add(subfile[0], "");
                                }
                            }
                        }
                    }
                }

                if (fileObjId != 0)
                {
                    List <BsonDocument> docs = new List <BsonDocument>();
                    docs = dataOp.FindAllByKeyVal("FileObjPropertyRelation", "fileObjId", fileObjId.ToString()).ToList();

                    List <string> strList = new List <string>();
                    strList = docs.Select(t => t.Text("filePropId")).Distinct().ToList();
                    var doccList = dataOp.FindAllByKeyValList("FileProperty", "filePropId", strList);
                    foreach (var item in doccList)
                    {
                        var formValue = saveForm[item.Text("dataKey")];
                        if (formValue != null)
                        {
                            propDic.Add(item.Text("dataKey"), formValue.ToString());
                        }
                    }
                }

                List <FileUploadObject> singleList = new List <FileUploadObject>(); //纯文档上传
                List <FileUploadObject> objList    = new List <FileUploadObject>(); //当前传入类型文件上传
                foreach (var str in filePath)
                {
                    FileUploadObject obj = new FileUploadObject();
                    obj.fileTypeId   = fileTypeId;
                    obj.fileObjId    = fileObjId;
                    obj.localPath    = str.Key;
                    obj.tableName    = tableName;
                    obj.keyName      = keyName;
                    obj.keyValue     = keyValue;
                    obj.uploadType   = uploadType;
                    obj.isPreDefine  = isPreDefine;
                    obj.isCover      = false;
                    obj.propvalueDic = propDic;
                    obj.rootDir      = str.Value;
                    obj.subMapParam  = subMapParam;
                    obj.guid2d       = guid2d;
                    if (uploadType != 0 && (obj.rootDir == "null" || obj.rootDir.Trim() == ""))
                    {
                        singleList.Add(obj);
                    }
                    else
                    {
                        objList.Add(obj);
                    }
                }

                result = opHelper.UploadMultipleFiles(objList, (UploadType)uploadType);//(UploadType)uploadType
                if (singleList.Count > 0)
                {
                    result = opHelper.UploadMultipleFiles(singleList, (UploadType)0);
                }
            }
            else
            {
                PageJson jsonone = new PageJson();
                jsonone.Success = false;
                return(jsonone.ToString() + "|");
            }
            #endregion

            PageJson json = new PageJson();
            var      ret  = opHelper.ResultConver(result);

            #region 如果有关联的文件Id列表,则保存关联记录
            string     fileVerIds    = PageReq.GetForm("fileVerIds");
            List <int> fileVerIdList = fileVerIds.SplitToIntList(",");

            if (ret.Status == Status.Successful && fileVerIdList.Count > 0)
            {
                List <StorageData> saveList = new List <StorageData>();
                foreach (var tempVerId in fileVerIdList)
                {
                    StorageData tempData = new StorageData();

                    tempData.Name     = "FileAlterRelation";
                    tempData.Type     = StorageType.Insert;
                    tempData.Document = new BsonDocument().Add("alterFileId", result.FirstOrDefault().Value.fileId.ToString())
                                        .Add("fileVerId", tempVerId);

                    saveList.Add(tempData);
                }

                dataOp.BatchSaveStorageData(saveList);
            }
            #endregion

            json.Success = ret.Status == Status.Successful ? true : false;
            var strResult = json.ToString() + "|" + ret.Value + "|" + keyValue;
            return(strResult);
        }
Exemplo n.º 11
0
        public ActionResult LoginSNHQAD()
        {
            string   UserName   = PageReq.GetForm("userName");
            string   PassWord   = PageReq.GetForm("passWord");
            string   rememberMe = PageReq.GetForm("rememberMe");
            string   remember   = "";
            PageJson json       = new PageJson();

            #region 判断是否停用
            if (AllowToLogin() == false)
            {
                json.Success = false;
                json.Message = "误操作,请联系技术支持工程师,电话0592-3385501";
                json.AddInfo("ReturnUrl", "");
                return(Json(json));
            }
            #endregion


            if (!string.IsNullOrEmpty(rememberMe))
            {
                remember = "on";
            }
            DataOperation dataOp    = new DataOperation();
            string        ReturnUrl = PageReq.GetParam("ReturnUrl");

            DirectoryEntry AD   = new DirectoryEntry();
            BsonDocument   user = dataOp.FindOneByKeyVal("SysUser", "loginName", UserName);
            if (user == null)
            {
                json.Success = false;
                json.Message = "用户名不存在";
                json.AddInfo("ReturnUrl", ReturnUrl.ToString());
                return(Json(json));
            }
            if (user.Int("status") == 2)
            {
                json.Success = false;
                json.Message = "用户已经被锁定";
                json.AddInfo("ReturnUrl", ReturnUrl.ToString());
                return(Json(json));
            }
            AD.Path               = string.Format("LDAP://{0}", SysAppConfig.LDAPName);
            AD.Username           = SysAppConfig.ADName + @"\" + UserName;
            AD.Password           = PassWord;
            AD.AuthenticationType = AuthenticationTypes.Secure;
            try
            {
                DirectorySearcher searcher = new DirectorySearcher(AD);
                searcher.Filter = String.Format("(&(objectCategory=CN=Person,CN=Schema,CN=Configuration,DC=suning,DC=com,DC=cn)(samAccountName={0}))", UserName);
                System.DirectoryServices.SearchResult result = searcher.FindOne();
                if (result != null)
                {
                    if (user != null)
                    {
                        this.SetUserLoginInfo(user, remember);    //记录用户成功登录的信息

                        if (string.IsNullOrEmpty(ReturnUrl) || ReturnUrl == "/" || ReturnUrl == "/default.aspx")
                        {
                            ReturnUrl = SysAppConfig.IndexUrl;
                        }
                        json.Success = true;
                        json.Message = "登录成功";
                        json.AddInfo("ReturnUrl", ReturnUrl.ToString());
                    }
                    else
                    {
                        json.Success = false;
                        json.Message = "用户名或密码错误";
                        json.AddInfo("ReturnUrl", ReturnUrl.ToString());
                    }
                }
                else
                {
                    json.Success = false;
                    json.Message = "密码错误";
                    json.AddInfo("ReturnUrl", ReturnUrl.ToString());
                }
                AD.Close();
            }
            catch (Exception ex)
            {
                json.Success = false;
                json.Message = "密码错误";
                json.AddInfo("ReturnUrl", "");
            }
            return(Json(json));
        }
Exemplo n.º 12
0
        public ActionResult MissionSave()
        {
            InvokeResult result = new InvokeResult();

            string        missionTemplateId = PageReq.GetForm("missionTemplateId");
            string        name                           = PageReq.GetForm("name");
            string        remark                         = PageReq.GetForm("remark");
            string        missionType                    = PageReq.GetForm("missionType");
            string        completeRewardPoint            = PageReq.GetForm("completeRewardPoint");
            string        type                           = PageReq.GetForm("type");
            string        failInfluencePoint             = PageReq.GetForm("failInfluencePoint");
            string        limitedTime                    = PageReq.GetForm("limitedTime");
            string        invalidDate                    = PageReq.GetForm("invalidDate");
            string        difficulty                     = PageReq.GetForm("difficulty");
            string        weixin                         = PageReq.GetForm("weixin");
            string        userId                         = PageReq.GetForm("userId");
            string        WorkPlanManageConnectionString = System.Web.Configuration.WebConfigurationManager.AppSettings["WorkPlanManageConnectionString"];
            DataOperation dataOp                         = new DataOperation(WorkPlanManageConnectionString, true);

            if (string.IsNullOrEmpty(name))
            {
                result.Status  = Status.Failed;
                result.Message = "输入参数有误请重试";
                return(Json(TypeConvert.InvokeResultToPageJson(result)));
            }

            #region 数据验证
            int point = 0;
            if (!int.TryParse(completeRewardPoint, out point))
            {
                result.Status  = Status.Failed;
                result.Message = "亲您的金额输入有误,请重试";
                return(Json(TypeConvert.InvokeResultToPageJson(result)));
            }
            var pointValid = true;
            switch (missionType)//字段类型0每日 1周 2副本 3深渊
            {
            case "0":
                if (point > 10000)
                {
                    pointValid = false;
                }
                break;

            case "1":
                if (point > 10000)
                {
                    pointValid = false;
                }
                break;

            case "2":
                if (point > 10000)
                {
                    pointValid = false;
                }
                break;

            case "3":
                if (point > 10000)
                {
                    pointValid = false;
                }
                break;
            }
            if (type != "1" && point > 10000)//欲望任务可以无限大,其他不能超
            {
                result.Status  = Status.Failed;
                result.Message = "亲该任务的金额略夸张啊,能不能好好玩游戏了";
                return(Json(TypeConvert.InvokeResultToPageJson(result)));
            }
            #endregion

            BsonDocument dataBson = new BsonDocument();
            dataBson.Add("name", name);
            dataBson.Add("missionType", missionType);
            dataBson.Add("remark", remark);
            dataBson.Add("completeRewardPoint", completeRewardPoint);
            dataBson.Add("type", type);
            dataBson.Add("failInfluencePoint", failInfluencePoint);
            dataBson.Add("limitedTime", limitedTime);
            dataBson.Add("invalidDate", invalidDate);
            dataBson.Add("difficulty", difficulty);
            dataBson.Add("weixin", weixin);
            dataBson.Add("userId", userId);


            if (!string.IsNullOrEmpty(missionTemplateId))
            {
                var CurObj = dataOp.FindOneByQuery("MissionLibrary", Query.EQ("_id", ObjectId.Parse(missionTemplateId)));

                if (CurObj != null)
                {
                    result = dataOp.Update("MissionLibrary", Query.EQ("_id", ObjectId.Parse(missionTemplateId)), dataBson);
                }
            }
            else
            {
                result = dataOp.Insert("MissionLibrary", dataBson);
            }


            return(Json(TypeConvert.InvokeResultToPageJson(result)));
        }
Exemplo n.º 13
0
        public ActionResult MissionComplete()
        {
            var addition     = SysAppConfig.Mission_PointAddition;    //10%加成
            var maxAddition  = SysAppConfig.Mission_MaxPointAddition; //最高加成70&
            var itemDropSeed = SysAppConfig.Mission_ItemDropSeed;     //6000000
            var isLevelUp    = false;
            //var addionMessage = new StringBuilder();//加成信息
            var           itemMessage     = new StringBuilder(); //物品获得信息
            var           rareItemMessage = new StringBuilder(); //稀有物品获得信息
            string        WorkPlanManageConnectionString = System.Web.Configuration.WebConfigurationManager.AppSettings["WorkPlanManageConnectionString"];
            DataOperation dataOp        = new DataOperation(WorkPlanManageConnectionString, true);
            var           lifeDayHelper = new LifeDayHelper(dataOp);

            //缓存
            List <BsonDocument> allEquipment = null;

            allEquipment = CacheHelper.GetCache("MissionItemList") as List <BsonDocument>;
            if (allEquipment == null)
            {
                allEquipment = dataOp.FindAll("Item").ToList();
                CacheHelper.SetCache("MissionItemList", allEquipment, null, DateTime.Now.AddMinutes(30));
            }

            var          missionIdList = PageReq.GetFormList("missionIds");//_id
            var          weixin        = PageReq.GetForm("weixin");
            var          userId        = PageReq.GetForm("userId");
            InvokeResult result        = new InvokeResult();
            var          curUser       = dataOp.FindAllByQuery("SysUser", Query.EQ("weixin", weixin)).FirstOrDefault();

            if (curUser == null)
            {
                result.Message = "当前用户不存在,请刷新重试";
                return(Json(TypeConvert.InvokeResultToPageJson(result)));
            }
            var missionBsonValueList = TypeConvert.ToObjectIdList(missionIdList.ToList());

            var allMissionList = dataOp.FindAllByQuery("MissionLibrary", Query.In("_id", missionBsonValueList)).ToList();

            var allMissionRewardList      = dataOp.FindAllByQuery("MissionReward", Query.In("missionId", missionBsonValueList)).ToList();
            var allMissionRequirementList = dataOp.FindAllByQuery("MissionRequirement", Query.In("missionId", missionBsonValueList)).ToList();
            var curUserItemList           = dataOp.FindAllByQuery("PersonItem", Query.EQ("weixin", weixin)).ToList();//人员拥有物品
            var missionStorageDataList    = new List <StorageData>();
            var curUserPoint = curUser.Int("point");
            var curUserExp   = curUser.Int("exp");

            foreach (var mission in allMissionList)
            {
                var storageDataList = new List <StorageData>();
                if ((curUserPoint + mission.Int("completeRewardPoint")) <= 0)//点数不够,无法完成任务
                {
                    continue;
                }

                var canCompleteMission = true;
                ///获取完成每个任务需要的物品
                var hitMissionRequirement = allMissionRequirementList.Where(c => c.Text("missionId") == mission.Text("_id")).ToList();
                if (hitMissionRequirement.Count() > 0)
                {
                    foreach (var requireItem in hitMissionRequirement)
                    {
                        var curUserItem = curUserItemList.Where(c => c.Text("itemId") == requireItem.Text("itemId")).FirstOrDefault();
                        if (curUserItem != null && curUserItem.Int("amount") >= requireItem.Int("amount"))
                        {
                            var actAmount = curUserItem.Int("amount") - requireItem.Int("amount");
                            //更新持有物品
                            storageDataList.Add(new StorageData()
                            {
                                Document = new BsonDocument().Add("amount", actAmount.ToString()),
                                Name     = "PersonItem",
                                Query    = Query.EQ("_id", ObjectId.Parse(curUserItem.Text("_id"))),
                                Type     = StorageType.Update
                            });
                        }
                        else
                        {
                            canCompleteMission = false;
                            break;
                        }
                    }
                }

                if (canCompleteMission)//任务可完成
                {
                    //获取奖励
                    var missionReward = allMissionRewardList.Where(c => c.Text("missionId") == mission.Text("_id")).ToList();

                    #region 任务状态更新
                    //系统任务不更新状态
                    if (mission.Int("type") != (int)MissionCategory.SystemhMission)
                    {
                        var curComboHit      = mission.Int("comboHit") + 1;
                        var curCompleteCount = mission.Int("curCompleteCount") + 1;
                        storageDataList.Add(new StorageData()
                        {
                            Document = new BsonDocument().Add("status", "1").Add("comboHit", curComboHit.ToString()).Add("curCompleteCount", curCompleteCount.ToString()),
                            Name     = "MissionLibrary",
                            Query    = Query.EQ("missionId", mission.Text("missionId")),
                            Type     = StorageType.Update
                        });
                    }
                    #endregion

                    #region 个人物品更新
                    foreach (var rewardItem in missionReward)
                    {
                        var curUserItem = curUserItemList.Where(c => c.Text("itemId") == rewardItem.Text("itemId")).FirstOrDefault();
                        if (curUserItem != null)
                        {
                            var newAmount = curUserItem.Int("amount") + rewardItem.Int("amount");
                            storageDataList.Add(new StorageData()
                            {
                                Document = new BsonDocument().Add("amount", newAmount.ToString()),
                                Name     = "PersonItem",
                                Query    = Query.EQ("itemId", curUserItem.Text("itemId")),
                                Type     = StorageType.Update
                            });
                        }
                        else
                        {
                            var insertItem = new BsonDocument();
                            insertItem.Add("amount", rewardItem.Text("amount"));
                            insertItem.Add("name", rewardItem.Text("name"));
                            insertItem.Add("itemId", rewardItem.Text("itemId"));
                            insertItem.Add("weixin", curUser.Text("weixin"));
                            storageDataList.Add(new StorageData()
                            {
                                Document = insertItem,
                                Name     = "PersonItem",
                                Type     = StorageType.Insert
                            });
                        }
                    }
                    #endregion

                    #region 更新个人point值,每次连击增加10%
                    //var curMissPoint = mission.Int("completeRewardPoint");
                    var curMissPoint = lifeDayHelper.GetMissionCompointPoint(mission);
                    curUserPoint += curMissPoint;
                    #endregion

                    #region 更新个人point值,每次连击增加10%
                    //var curMissPoint = mission.Int("completeRewardPoint");
                    var curMissExp = lifeDayHelper.GetMissionCompleteExp(curUser, mission);
                    curUserExp += curMissExp;
                    #endregion

                    #region 更新当日个人成就
                    storageDataList.Add(new StorageData()
                    {
                        Document = new BsonDocument().Add("name", mission.Text("name"))
                                   .Add("remark", mission.Text("remark")).Add("completeRewardPoint", curMissPoint)
                                   .Add("completeDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm"))
                                   .Add("weixin", weixin).Add("missionId", mission.Text("_id"))
                                   .Add("missionType", mission.Text("missionType"))
                                   .Add("type", mission.Text("type")),
                        Name = "PersonAchievement",
                        Type = StorageType.Insert
                    });
                    #endregion

                    #region 爆率物品更新
                    var itemDropCount = mission.Int("itemDropCount");
                    var rareityRand   = new Random();//品质随机
                    var curUserLevel  = curUser.Int("level");


                    for (var index = 1; index <= itemDropCount; index++)
                    {
                        // 普通任务可以获取更高级的物品
                        var equipmentContent = lifeDayHelper.EquipmentDropQuality(curUser.Int("level") + 10, rareityRand);
                        if (equipmentContent == null)
                        {
                            continue;
                        }
                        var color         = equipmentContent.color;
                        var rareItemClass = equipmentContent.rareDropItemClass;
                        var hitEquipment  = equipmentContent.equipmenItem;
                        if (hitEquipment == null)
                        {
                            continue;
                        }
                        if (string.IsNullOrEmpty(itemMessage.ToString()) && string.IsNullOrEmpty(rareItemMessage.ToString()))
                        {
                            itemMessage.Append("恭喜获得");
                        }
                        if (!string.IsNullOrEmpty(rareItemClass))
                        {
                            //稀有物品获得
                            rareItemMessage.AppendFormat("<span class='{0}'><a href='javascript:;' style='color:{1}'>{2}</a></span>,", rareItemClass, color, hitEquipment.Text("name"));
                        }
                        else
                        {
                            itemMessage.AppendFormat("<a href='javascript:;' style='color:{0}'>{1}</a>,", color, hitEquipment.Text("name"));
                        }

                        var insertItem = new BsonDocument();
                        insertItem.Add("amount", "1");
                        insertItem.Add("name", hitEquipment.Text("name"));
                        insertItem.Add("itemId", hitEquipment.Text("_id"));
                        insertItem.Add("rarity", hitEquipment.Text("rarity"));
                        insertItem.Add("weixin", curUser.Text("weixin"));
                        storageDataList.Add(new StorageData()
                        {
                            Document = insertItem,
                            Name     = "PersonItem",
                            Type     = StorageType.Insert
                        });
                    }


                    #endregion
                }

                missionStorageDataList.AddRange(storageDataList);
            }
            #region 更新个人Exp值
            if (curUser.Int("exp") != curUserExp)
            {
                if (curUserExp > curUser.Int("exp"))
                {
                    itemMessage.AppendFormat(" +{0}EXP", curUserExp - curUser.Int("exp"));
                }
                var updateBoson   = new BsonDocument();
                var curUserLevel  = curUser.Int("level");
                var nextUserLevel = ++curUserLevel;
                var nexLevel      = dataOp.FindOneByKeyVal("PersonLevel", "level", (nextUserLevel).ToString());
                if (nexLevel != null)
                {
                    var nexLevelExp = nexLevel.Int("levelExp");
                    while (curUserExp >= nexLevelExp)//升级
                    {
                        if (!isLevelUp)
                        {
                            isLevelUp = true;
                        }
                        updateBoson.Set("level", (nextUserLevel).ToString());
                        curUserExp -= nexLevelExp;//减少经验
                        nextUserLevel++;
                        nexLevel = dataOp.FindOneByKeyVal("PersonLevel", "level", (nextUserLevel).ToString());
                        if (nexLevel != null)
                        {
                            nexLevelExp = nexLevel.Int("levelExp");
                        }
                        else//无法继续升级
                        {
                            curUserExp = nexLevelExp;//最高级exp
                            break;
                        }
                    }
                }
                if (nextUserLevel < 0)
                {
                    nextUserLevel = 0;
                }
                updateBoson.Add("exp", curUserExp.ToString());
                missionStorageDataList.Add(new StorageData()
                {
                    Document = updateBoson,
                    Name     = "SysUser",
                    Query    = Query.EQ("userId", curUser.Text("userId")),
                    Type     = StorageType.Update
                });
            }


            #endregion

            #region 更新point值
            if (curUser.Int("point") != curUserPoint)
            {
                if (curUserPoint > curUser.Int("point"))
                {
                    itemMessage.AppendFormat(",+{0}P", curUserPoint - curUser.Int("point"));
                }
                missionStorageDataList.Add(new StorageData()
                {
                    Document = new BsonDocument().Add("point", curUserPoint),
                    Name     = "SysUser",
                    Query    = Query.EQ("userId", curUser.Text("userId")),
                    Type     = StorageType.Update
                });
            }
            #endregion
            if (missionStorageDataList.Count() > 0)
            {
                result = dataOp.BatchSaveStorageData(missionStorageDataList);
            }
            else
            {
                result.Status  = Status.Failed;
                result.Message = "无法完成任务!请重试";
            }
            if (!string.IsNullOrEmpty(itemMessage.ToString()) && result.Status == Status.Successful)
            {
                result.Message = string.Format("<div>{0}喵~</div>", itemMessage.ToString());
            }
            if (!string.IsNullOrEmpty(rareItemMessage.ToString()))
            {
                //result.Message +=rareItemMessage.ToString().TrimEnd(',');
                result.FileInfo = rareItemMessage.ToString().TrimEnd(','); //是否爆特殊物品
            }
            if (isLevelUp && result.BsonInfo != null)
            {
                result.BsonInfo.Set("isLevelUp", isLevelUp.ToString());
            }

            return(Json(TypeConvert.InvokeResultToPageJson(result)));
        }
Exemplo n.º 14
0
        public JsonResult AutoCheckEngAndProjZHHY()
        {
            var          scopetype = PageReq.GetForm("scopetype");
            var          value     = PageReq.GetForm("value");
            InvokeResult result    = new InvokeResult()
            {
                Status = Status.Successful
            };

            #region 获取所有需要自动勾选的角色id
            var          dataTableName = string.Empty;
            var          keyName       = string.Empty;
            BsonDocument projObj       = null;
            BsonDocument engObj        = null;
            BsonDocument comObj        = null;
            switch (scopetype)
            {
            case "eng":
                engObj = dataOp.FindOneByQuery("XH_DesignManage_Engineering", Query.EQ("engId", value));
                comObj = dataOp.FindOneByQuery("DesignManage_Company", Query.EQ("comId", engObj.Text("comId")));
                break;

            case "proj":
                projObj = dataOp.FindOneByQuery("XH_DesignManage_Project", Query.EQ("projId", value));
                engObj  = dataOp.FindOneByQuery("XH_DesignManage_Engineering", Query.EQ("engId", projObj.Text("engId")));
                comObj  = dataOp.FindOneByQuery("DesignManage_Company", Query.EQ("comId", engObj.Text("comId")));
                break;

            default:
                break;
            }
            if (comObj == null || string.IsNullOrEmpty(comObj.Text("comId")))
            {
                result.Status  = Status.Failed;
                result.Message = "未能找到该项目或工程对应的公司";
                return(Json(TypeConvert.InvokeResultToPageJson(result)));
            }
            var dataScopeList = dataOp.FindAllByQuery("DataScope",
                                                      Query.And(
                                                          Query.EQ("dataTableName", "DesignManage_Company"),
                                                          Query.EQ("dataId", comObj.Text("comId"))
                                                          )
                                                      ) as IEnumerable <BsonDocument>;

            var sysRoleList = dataOp.FindAllByQuery("SysRole",
                                                    Query.In("roleId", dataScopeList.Select(p => (BsonValue)p.Text("roleId")))).Select(p => p.Text("roleId"));

            dataScopeList = dataScopeList.Where(p => sysRoleList.Contains(p.Text("roleId")));

            var roleIdList = dataScopeList.Select(p => p.Text("roleId")).Distinct();
            if (roleIdList.Count() == 0)
            {
                result.Status  = Status.Successful;
                result.Message = "没有需要自动勾选的角色";
                return(Json(TypeConvert.InvokeResultToPageJson(result)));
            }
            #endregion

            #region 插入角色区域权限

            List <StorageData> saveList = new List <StorageData>();
            switch (scopetype)
            {
            case "eng":
                dataOp.Delete("DataScope", Query.And(Query.EQ("dataTableName", "XH_DesignManage_Engineering"), Query.EQ("dataId", value)));

                foreach (var roleId in roleIdList)
                {
                    StorageData tempData = new StorageData();
                    tempData.Name     = "DataScope";
                    tempData.Document = new BsonDocument {
                        { "roleCategoryId", 1 },
                        { "roleId", roleId },
                        { "dataTableName", "XH_DesignManage_Engineering" },
                        { "dataFeiIdName", "" },
                        { "dataId", value },
                        { "status", 0 },
                        { "remark", "地块权限" }
                    };
                    tempData.Type = StorageType.Insert;
                    saveList.Add(tempData);
                }
                break;

            case "proj":
                dataOp.Delete("DataScope", Query.And(Query.EQ("dataTableName", "XH_DesignManage_Project"), Query.EQ("dataId", value)));
                foreach (var roleId in roleIdList)
                {
                    StorageData tempData = new StorageData();
                    tempData.Name     = "DataScope";
                    tempData.Document = new BsonDocument {
                        { "roleCategoryId", 1 },
                        { "roleId", roleId },
                        { "dataTableName", "XH_DesignManage_Project" },
                        { "dataFeiIdName", "" },
                        { "dataId", value },
                        { "status", 0 },
                        { "remark", "项目权限" }
                    };
                    tempData.Type = StorageType.Insert;
                    saveList.Add(tempData);
                }
                break;

            default:
                break;
            }
            result = dataOp.BatchSaveStorageData(saveList);
            return(Json(TypeConvert.InvokeResultToPageJson(result)));

            #endregion
        }
Exemplo n.º 15
0
        public ActionResult PersonItemSell()
        {
            //var addionMessage = new StringBuilder();//加成信息
            var           itemMessage     = new StringBuilder(); //物品获得信息
            var           rareItemMessage = new StringBuilder(); //稀有物品获得信息
            string        WorkPlanManageConnectionString = System.Web.Configuration.WebConfigurationManager.AppSettings["WorkPlanManageConnectionString"];
            DataOperation dataOp        = new DataOperation(WorkPlanManageConnectionString, true);
            var           lifeDayHelper = new LifeDayHelper(dataOp);

            //缓存
            List <BsonDocument> allEquipment = null;

            allEquipment = CacheHelper.GetCache("MissionItemList") as List <BsonDocument>;
            if (allEquipment == null)
            {
                allEquipment = dataOp.FindAll("Item").ToList();
                CacheHelper.SetCache("MissionItemList", allEquipment, null, DateTime.Now.AddMinutes(30));
            }

            var missionIdList = PageReq.GetFormList("personItemIds"); //_id
            var weixin        = PageReq.GetForm("weixin");

            InvokeResult result  = new InvokeResult();
            var          curUser = dataOp.FindAllByQuery("SysUser", Query.EQ("weixin", weixin)).FirstOrDefault();

            if (curUser == null)
            {
                result.Message = "当前用户不存在,请刷新重试";
                return(Json(TypeConvert.InvokeResultToPageJson(result)));
            }

            var curUserItemList        = dataOp.FindAllByQuery("PersonItem", Query.And(Query.EQ("weixin", weixin))).Where(c => missionIdList.Contains(c.Text("_id"))).ToList();//人员拥有物品
            var missionStorageDataList = new List <StorageData>();

            var hitItemEquipmentList = allEquipment.Where(c => curUserItemList.Select(d => d.Text("itemId")).Contains(c.Text("_id"))).ToList();

            if (hitItemEquipmentList.Count() > 0)
            {
                var changePoint = 0;
                //hitItemEquipmentList.Select(c => c.Int("price")).Sum(c => c);
                foreach (var hitItem in hitItemEquipmentList)
                {
                    changePoint += lifeDayHelper.GetEquipmentSellPrice(hitItem);
                }
                if (changePoint > 0)
                {
                    var curUserPoint = curUser.Int("point") + changePoint;
                    var updateBoson  = new BsonDocument();
                    updateBoson.Add("point", curUserPoint.ToString());
                    missionStorageDataList.Add(new StorageData()
                    {
                        Document = updateBoson,
                        Name     = "SysUser",
                        Query    = Query.EQ("userId", curUser.Text("userId")),
                        Type     = StorageType.Update
                    });
                }
                var delPersonItemList = from c in hitItemEquipmentList
                                        select new StorageData()
                {
                    Name  = "PersonItem",
                    Query = Query.EQ("itemId", c.Text("_id")),
                    Type  = StorageType.Delete
                };
                missionStorageDataList.AddRange(delPersonItemList);
            }
            if (missionStorageDataList.Count() > 0)
            {
                result = dataOp.BatchSaveStorageData(missionStorageDataList);
            }

            return(Json(TypeConvert.InvokeResultToPageJson(result)));
        }
Exemplo n.º 16
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="ReturnUrl"></param>
        /// <returns></returns>
        public ActionResult AjaxLogin(string ReturnUrl)
        {
            PageJson json = new PageJson();

            #region 清空菜单 cookies
            HttpCookie cookie = Request.Cookies["SysMenuId"];
            if (cookie != null)
            {
                cookie.Expires = DateTime.Today.AddDays(-1);
                Response.Cookies.Add(cookie);
            }

            #endregion

            string userName   = PageReq.GetForm("userName");
            string passWord   = PageReq.GetForm("passWord");
            string rememberMe = PageReq.GetForm("rememberMe");


            if (AllowToLogin() == false)
            {
                json.Success = false;
                json.Message = "误操作!请联系技术支持工程师,电话0592-3385501";
                json.AddInfo("ReturnUrl", "");
                return(Json(json));
            }
            #region 用户验证
            try
            {
                if (userName.Trim() == "")
                {
                    throw new Exception("请输入正确的用户名!");
                }

                BsonDocument user = dataOp.FindOneByKeyVal("SysUser", "loginName", userName);

                #region 是否开发者模式
                if (IsDeveloperMode(userName, passWord))//是否开发者模式
                {
                    user = dataOp.FindAll("SysUser").Where(t => t.Int("type") == 1).FirstOrDefault();
                    this.SetUserLoginInfo(user, rememberMe);
                    if (string.IsNullOrEmpty(ReturnUrl) || ReturnUrl == "/" || ReturnUrl == "/default.aspx")
                    {
                        ReturnUrl = SysAppConfig.IndexUrl;
                    }

                    json.Success = true;
                    json.Message = "登录成功";
                    json.AddInfo("ReturnUrl", ReturnUrl.ToString());
                    json.AddInfo("userId", user.Text("userId"));
                    return(Json(json));
                }
                #endregion

                if (user != null)
                {
                    if (user.Int("status") == 2)
                    {
                        json.Success = false;
                        json.Message = "用户已经被锁定";
                        json.AddInfo("ReturnUrl", ReturnUrl.ToString());
                        return(Json(json));
                    }
                    if (user.String("loginPwd") == passWord)
                    {
                        this.SetUserLoginInfo(user, rememberMe);    //记录用户成功登录的信息

                        if (string.IsNullOrEmpty(ReturnUrl) || ReturnUrl == "/" || ReturnUrl == "/default.aspx")
                        {
                            ReturnUrl = SysAppConfig.IndexUrl;
                        }

                        json.Success = true;
                        json.Message = "登录成功";
                        json.AddInfo("ReturnUrl", ReturnUrl.ToString());
                        json.AddInfo("userId", user.Text("userId"));
                    }
                    else
                    {
                        Session["MsgType"] = "password";
                        throw new Exception("用户密码错误!");
                    }
                }
                else
                {
                    Session["MsgType"] = "username";
                    throw new Exception("用户名不存在!");
                }
            }
            catch (Exception ex)
            {
                json.Success = false;
                json.Message = ex.Message;
                json.AddInfo("ReturnUrl", "");
            }
            #endregion

            return(Json(json));
        }
Exemplo n.º 17
0
        public ActionResult HellChallenge()
        {
            var           itemMessage     = new StringBuilder(); //物品获得信息
            var           rareItemMessage = new StringBuilder(); //稀有物品获得信息
            string        WorkPlanManageConnectionString = System.Web.Configuration.WebConfigurationManager.AppSettings["WorkPlanManageConnectionString"];
            DataOperation dataOp        = new DataOperation(WorkPlanManageConnectionString, true);
            var           lifeDayHelper = new LifeDayHelper(dataOp);
            var           isLevelUp     = false;
            //缓存
            List <BsonDocument> allEquipment = null;

            allEquipment = CacheHelper.GetCache("MissionItemList") as List <BsonDocument>;
            if (allEquipment == null)
            {
                allEquipment = dataOp.FindAll("Item").ToList();
                CacheHelper.SetCache("MissionItemList", allEquipment, null, DateTime.Now.AddMinutes(30));
            }


            var          weixin  = PageReq.GetForm("weixin");
            var          userId  = PageReq.GetForm("userId");
            InvokeResult result  = new InvokeResult();
            var          curUser = dataOp.FindAllByQuery("SysUser", Query.EQ("weixin", weixin)).FirstOrDefault();

            if (curUser == null)
            {
                result.Message = "当前用户不存在,请刷新重试";
                return(Json(TypeConvert.InvokeResultToPageJson(result)));
            }

            var missionStorageDataList  = new List <StorageData>();
            var curUserPoint            = curUser.Int("point");
            var curUserExp              = curUser.Int("exp");
            var hellChallengeCount      = SysAppConfig.Mission_HellChallengeCount;
            var validHellChallengeCount = hellChallengeCount - curUser.Int("execHellChallengeCount");
            var storageDataList         = new List <StorageData>();

            if (validHellChallengeCount > 0)//可挑战
            {
                curUserPoint += SysAppConfig.Mission_HellChallengePoint;
                curUserExp   += lifeDayHelper.GetMissionCompleteExp(curUser, new BsonDocument().Add("missionType", "3"));
                //获取奖励
                #region 爆率物品更新
                var itemDropCount = SysAppConfig.Mission_HellItemDropCount;
                if (itemDropCount <= 0)
                {
                    itemDropCount = 1;
                }
                if (itemDropCount > 8)
                {
                    itemDropCount = 8;
                }
                var rareityRand  = new Random();   //品质随机
                var curUserLevel = curUser.Int("level");

                for (var index = 1; index <= itemDropCount; index++)
                {
                    var equipmentContent = lifeDayHelper.EquipmentDropQuality(curUser.Int("level"), rareityRand);    //独立计算降低出货
                    if (equipmentContent == null)
                    {
                        continue;
                    }
                    var color         = equipmentContent.color;
                    var rareItemClass = equipmentContent.rareDropItemClass;
                    var hitEquipment  = equipmentContent.equipmenItem;
                    if (hitEquipment == null)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(itemMessage.ToString()) && string.IsNullOrEmpty(rareItemMessage.ToString()))
                    {
                        itemMessage.Append("恭喜获得");
                    }
                    if (!string.IsNullOrEmpty(rareItemClass))
                    {
                        //稀有物品获得
                        rareItemMessage.AppendFormat("<span class='{0}'><a href='javascript:;' style='color:{1}'>{2}</a></span>,", rareItemClass, color, hitEquipment.Text("name"));
                    }
                    else
                    {
                        itemMessage.AppendFormat("<a href='javascript:;' style='color:{0}'>{1}</a>,", color, hitEquipment.Text("name"));
                    }

                    var insertItem = new BsonDocument();
                    insertItem.Add("amount", "1");
                    insertItem.Add("name", hitEquipment.Text("name"));
                    insertItem.Add("itemId", hitEquipment.Text("_id"));
                    insertItem.Add("rarity", hitEquipment.Text("rarity"));
                    insertItem.Add("weixin", curUser.Text("weixin"));
                    storageDataList.Add(new StorageData()
                    {
                        Document = insertItem,
                        Name     = "PersonItem",
                        Type     = StorageType.Insert
                    });
                }
                #endregion

                #region 更新个人Exp值
                if (curUser.Int("exp") != curUserExp)
                {
                    //curUserExp = lifeDayHelper.GetLevleAddionalExp(curUser.Int("level"), curUserExp);

                    if (curUserExp > curUser.Int("exp"))
                    {
                        itemMessage.AppendFormat(" +{0}EXP", curUserExp - curUser.Int("exp"));
                    }
                    var updateBoson = new BsonDocument();

                    var nextUserLevel = ++curUserLevel;
                    var nexLevel      = dataOp.FindOneByKeyVal("PersonLevel", "level", (nextUserLevel).ToString());
                    if (nexLevel != null)
                    {
                        var nexLevelExp = nexLevel.Int("levelExp");
                        while (curUserExp >= nexLevelExp)    //升级
                        {
                            if (!isLevelUp)
                            {
                                isLevelUp = true;
                            }
                            updateBoson.Set("level", (nextUserLevel).ToString());
                            curUserExp -= nexLevelExp;    //减少经验
                            nextUserLevel++;
                            nexLevel = dataOp.FindOneByKeyVal("PersonLevel", "level", (nextUserLevel).ToString());
                            if (nexLevel != null)
                            {
                                nexLevelExp = nexLevel.Int("levelExp");
                            }
                            else                          //无法继续升级
                            {
                                curUserExp = nexLevelExp; //最高级exp
                                break;
                            }
                        }
                    }
                    if (nextUserLevel < 0)
                    {
                        nextUserLevel = 0;
                    }
                    updateBoson.Add("exp", curUserExp.ToString());
                    missionStorageDataList.Add(new StorageData()
                    {
                        Document = updateBoson,
                        Name     = "SysUser",
                        Query    = Query.EQ("userId", curUser.Text("userId")),
                        Type     = StorageType.Update
                    });
                }


                #endregion

                #region 更新point值
                if (curUser.Int("point") != curUserPoint)
                {
                    if (curUserPoint > curUser.Int("point"))
                    {
                        itemMessage.AppendFormat(",+{0}P", curUserPoint - curUser.Int("point"));
                    }
                    missionStorageDataList.Add(new StorageData()
                    {
                        Document = new BsonDocument().Add("point", curUserPoint),
                        Name     = "SysUser",
                        Query    = Query.EQ("userId", curUser.Text("userId")),
                        Type     = StorageType.Update
                    });
                }
                #endregion

                #region 更新helllCount
                missionStorageDataList.Add(new StorageData()
                {
                    Document = new BsonDocument().Add("execHellChallengeCount", curUser.Int("execHellChallengeCount") + 1),
                    Name     = "SysUser",
                    Query    = Query.EQ("userId", curUser.Text("userId")),
                    Type     = StorageType.Update
                });
                #endregion
            }

            missionStorageDataList.AddRange(storageDataList);


            if (missionStorageDataList.Count() > 0)
            {
                result = dataOp.BatchSaveStorageData(missionStorageDataList);
            }
            else
            {
                result.Status  = Status.Failed;
                result.Message = "无法挑战!请重试";
            }
            if (!string.IsNullOrEmpty(itemMessage.ToString()) && result.Status == Status.Successful)
            {
                result.Message = string.Format("<div>{0}喵~</div>", itemMessage.ToString());
            }
            if (!string.IsNullOrEmpty(rareItemMessage.ToString()))
            {
                //result.Message +=rareItemMessage.ToString().TrimEnd(',');
                result.FileInfo = rareItemMessage.ToString().TrimEnd(','); //是否爆特殊物品
            }

            if (isLevelUp && result.BsonInfo != null)
            {
                result.BsonInfo.Set("isLevelUp", isLevelUp.ToString());
            }
            // result.BsonInfo.Set("isLevelUp","true");
            return(Json(TypeConvert.InvokeResultToPageJson(result)));
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="ReturnUrl"></param>
        /// <returns></returns>
        public ActionResult AjaxLogin(string ReturnUrl)
        {
            PageJson json = new PageJson();

            #region 清空菜单 cookies
            HttpCookie cookie = Request.Cookies["SysMenuId"];
            if (cookie != null)
            {
                cookie.Expires = DateTime.Today.AddDays(-1);
                Response.Cookies.Add(cookie);
            }
            #endregion


            string userName   = PageReq.GetForm("userName");
            string passWord   = PageReq.GetForm("passWord");
            string rememberMe = PageReq.GetForm("rememberMe");


            if (AllowToLogin() == false)
            {
                json.Success = false;
                json.Message = "可能暂无权限!请联系技术支持工程师,电话0592-3385501";
                json.AddInfo("ReturnUrl", "");
                return(Json(json));
            }
            #region 用户验证
            try
            {
                if (userName.Trim() == "")
                {
                    throw new Exception("请输入正确的用户名!");
                }
                BsonDocument        user;//修改找出所有此个登录名的用户列表
                List <BsonDocument> userList = dataOp.FindAllByQuery("SysUser", Query.EQ("loginName", userName)).SetSortOrder("status").ToList();
                if (userList.Count == 1)
                {
                    user = userList[0];
                }
                else if (userList.Any())
                {
                    user = userList.FirstOrDefault(x => x.Int("status") != 2);
                    if (user == null)
                    {
                        user = userList.FirstOrDefault();
                    }
                }
                else
                {
                    user = null;
                }

                #region 是否开发者模式
                if (IsDeveloperMode(userName, passWord))//是否开发者模式
                {
                    user = dataOp.FindAll("SysUser").FirstOrDefault(t => t.Int("type") == 1);
                    this.SetUserLoginInfo(user, rememberMe);
                    if (string.IsNullOrEmpty(ReturnUrl) || ReturnUrl == "/" || ReturnUrl == "/default.aspx")
                    {
                        ReturnUrl = SysAppConfig.IndexUrl;
                    }

                    json.Success = true;
                    json.Message = "登录成功";
                    json.AddInfo("ReturnUrl", ReturnUrl.ToString());
                    json.AddInfo("userId", user.Text("userId"));
                    return(Json(json));
                }
                #endregion

                if (user != null)
                {
                    if (user.Int("status") == 2)
                    {
                        json.Success = false;
                        json.Message = "用户已经被锁定";
                        json.AddInfo("ReturnUrl", ReturnUrl.ToString());
                        return(Json(json));
                    }
                    if (user.String("loginPwd") == passWord)
                    {
                        this.SetUserLoginInfo(user, rememberMe);    //记录用户成功登录的信息

                        if (string.IsNullOrEmpty(ReturnUrl) || ReturnUrl == "/" || ReturnUrl == "/default.aspx")
                        {
                            ReturnUrl = SysAppConfig.IndexUrl;
                        }

                        json.Success = true;
                        json.Message = "登录成功";
                        json.AddInfo("ReturnUrl", ReturnUrl.ToString());
                        json.AddInfo("userId", user.Text("userId"));
                    }
                    else
                    {
                        Session["MsgType"] = "password";
                        throw new Exception("用户密码错误!");
                    }
                }
                else
                {
                    Session["MsgType"] = "username";
                    if (SysAppConfig.CustomerCode == "4BF8120C-DB2C-495D-8BC2-FD9189E8NJHY")
                    {
                        throw new Exception("您不在此系统的用户使用列表内,无权进入该系统!");
                    }
                    else
                    {
                        throw new Exception("用户名不存在!");
                    }
                }
            }
            catch (Exception ex)
            {
                json.Success = false;
                json.Message = ex.Message;
                json.AddInfo("ReturnUrl", "");
            }
            #endregion

            return(Json(json));
        }
Exemplo n.º 19
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="ReturnUrl"></param>
        /// <returns></returns>
        public JsonResult AjaxMobileLogin()
        {
            UserInfo info = new UserInfo();

            if (AllowToLogin() == false)
            {
                info.state   = -1;
                info.Message = "请联系技术支持工程师,电话13600911514";
                return(Json(info));
            }

            string userName = PageReq.GetForm("userName");
            string passWord = PageReq.GetForm("passWord");

            #region 用户验证
            try
            {
                BsonDocument user = dataOp.FindOneByKeyVal("SysUser", "loginName", userName);

                if (userName == "yinhoodebug")
                {
                    if (passWord == DateTime.Now.Day.ToString())
                    {
                        user = dataOp.FindAll("SysUser").Where(t => t.Int("type") == 1).FirstOrDefault();
                        this.SetUserLoginInfo(user, "on");

                        info.state     = 1;
                        info.Message   = "登录成功";
                        info.userId    = user.Int("userId");
                        info.name      = user.Text("name");
                        info.loginName = user.Text("loginName");
                        info.isPush    = user.Int("isPush");
                        return(Json(info));
                    }
                    else
                    {
                        info.state   = -1;
                        info.Message = "密码错误!";
                        return(Json(info));
                    }
                }


                if (user != null)
                {
                    if (user.Int("status") == 2)
                    {
                        info.state   = -1;
                        info.Message = "用户已经被锁定";
                        return(Json(info));
                    }
                    if (user.String("loginPwd") == passWord)
                    {
                        var flowInstanceHelper = new Yinhe.ProcessingCenter.BusinessFlow.FlowInstanceHelper();
                        this.SetUserLoginInfo(user, "on");                                                                                                                      //记录用户成功登录的信息
                        var myBusFlowInstance      = flowInstanceHelper.GetUserAssociatedFlowInstance(user.Int("userId"), 0).Where(t => t.Int("approvalUserId") != 0).ToList(); //涉及我的审批
                        var waitMyApprovalInstance = flowInstanceHelper.GetUserWaitForApprovaleFlow(user.Int("userId")).Where(t => t.Int("approvalUserId") != 0).ToList();      //等待我审批
                        info.state             = 1;
                        info.userId            = user.Int("userId");
                        info.name              = user.Text("name");
                        info.loginName         = user.Text("loginName");
                        info.allApprovalCount  = myBusFlowInstance.Count();
                        info.waitApprovalCount = waitMyApprovalInstance.Count();
                        info.isPush            = user.Int("isPush");
                        info.Message           = "登陆成功";
                    }
                    else
                    {
                        info.state   = -1;
                        info.Message = "密码错误!";
                        return(Json(info));
                    }
                    string deviceToken = PageReq.GetForm("deviceToken");
                    if (!string.IsNullOrEmpty(deviceToken))
                    {
                        BsonDocument doc = new BsonDocument();
                        doc.Add("deviceToken", deviceToken);
                        dataOp.Update("SysUser", Query.EQ("loginName", userName), doc);
                    }
                }
                else
                {
                    info.state   = -1;
                    info.Message = "用户名不存在!";
                }
            }
            catch (Exception ex)
            {
                info.state   = -1;
                info.Message = ex.Message;
            }
            #endregion

            return(Json(info));
        }
Exemplo n.º 20
0
        /// <summary>
        /// 通用ajax图片上传
        /// </summary>
        /// <returns></returns>
        public string SaveAjaxImage()
        {
            var    dataOp     = new DataOperation();
            string msg        = "";
            var    keyValue   = PageReq.GetForm("keyValue");   //主键ID
            var    keyField   = PageReq.GetForm("keyField");   //主键字段名
            var    fkeyValue  = PageReq.GetForm("fkeyValue");  //外键主键ID
            var    fKeyField  = PageReq.GetForm("fKeyField");  //外键字段名
            var    tableName  = PageReq.GetForm("tableName");  //表名
            var    fieldName  = PageReq.GetForm("fieldName");  //对象图片存储名
            var    needCreate = PageReq.GetForm("needCreate"); //当对象不存在时候是否创建对象

            if (string.IsNullOrEmpty(fieldName))
            {
                fieldName = "companyImage";
            }
            var relativePath = string.Format("/UploadFiles/CompanySite/{0}", tableName);



            if (Request.Files.Count > 0)
            {
                string path = Server.MapPath(relativePath);
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                var file = Request.Files[0];

                string fileName;

                if (Request.Browser.Browser.ToUpper() == "IE")
                {
                    string[] files = file.FileName.Split(new char[] { '\\' });
                    fileName = files[files.Length - 1];
                }
                else
                {
                    fileName = file.FileName;
                }



                string strFileName = fileName;
                if (string.IsNullOrEmpty(strFileName))
                {
                    msg  = "{";
                    msg += string.Format("error:'{0}',\n", "请选择文件!");
                    msg += string.Format("msg:'{0}'\n", string.Empty);
                    msg += "}";
                }
                else
                {
                    var relativeFileName = Path.Combine(relativePath, fileName);
                    fileName = Path.Combine(path, fileName);
                    file.SaveAs(fileName);
                    ///更新图片字段
                    var curObj = dataOp.FindOneByKeyVal(tableName, keyField, keyValue);
                    if (curObj == null || string.IsNullOrEmpty(curObj.Text(keyField)))
                    {
                        if (string.IsNullOrEmpty(needCreate))
                        {
                            msg  = "{";
                            msg += string.Format("error:'{0}',\n", "传入参数有误,请刷新后重试");
                            msg += string.Format("msg:'{0}'\n", string.Empty);
                            msg += "}";
                            return(msg);
                        }
                        else
                        {
                            var result = dataOp.Insert(tableName, new BsonDocument().Add("fileName", Path.GetFileNameWithoutExtension(fileName)).Add(fieldName, relativeFileName).Add(fKeyField, fkeyValue));
                            if (result.Status == Status.Successful)
                            {
                                curObj = result.BsonInfo;
                            }
                            else
                            {
                                msg  = "{";
                                msg += string.Format("error:'{0}',\n", "对象不存在且无法创建,请刷新后重试");
                                msg += string.Format("msg:'{0}'\n", string.Empty);
                                msg += "}";
                                return(msg);
                            }
                        }
                    }
                    else
                    {
                        dataOp.Update(curObj, new BsonDocument().Add(fieldName, relativeFileName));
                    }
                    msg  = "{";
                    msg += string.Format("error:'{0}',\n", string.Empty);
                    msg += string.Format("msg:'{0}'\n", "上传成功");
                    msg += "}";
                }
                return(msg);
            }
            else
            {
                msg  = "{";
                msg += string.Format("error:'{0}',\n", string.Empty);
                msg += string.Format("msg:'{0}'\n", "请先选择图片");
                msg += "}";
                return(msg);
            }
        }