public override void DoRequest(HttpContext ctx)
        {
            if (string.IsNullOrEmpty(SessionVal.UserId))
            {
                ctx.Response.Write(new AjaxResult
                                   {
                                       Success = false,
                                       Message = "你还没有登录"
                                   }.ToString());
                ctx.Response.End();
            }

             var action = QueryStringVal.Action;
            if (string.IsNullOrEmpty(action)) action = FormVal.Action;
            switch (action)
            {
                case "ChangePassword":
                    var message=SystemUserLogic.ChangePwd(100000,FormVal.OldPsw,FormVal.NewPsw);
                    var result = new AjaxResult();
                    if(string.IsNullOrEmpty(message))
                    {
                        result.Success = true;
                        result.Message = "密码修改成功";
                    }
                    else
                    {
                        result.Success = false;
                        result.Message = message;
                    }
                    ctx.Response.Write(result.ToString());
                    break;
            }

            ctx.Response.End();
        }
Esempio n. 2
0
        public ActionResult Edit(int id,string title,string description)
        {
            var result = new AjaxResult();

            var package = Manager.Packages.Find(id);
            if(package==null|| package.UserID!=Security.User.ID)
            {
                result.Success = false;
                result.Message = "错误操作";
                return JsonContent(result);
            }

            title=title.Trim();

            var exist = Manager.Packages.Items.Where(p => p.Title == title && p.UserID == Security.User.ID && p.ID != package.ID).Count() > 0;
            if(exist)
            {
                result.Success = false;
                result.Message = "已经存在同名图包";
                return JsonContent(result);
            }

            package.Title = title;
            package.Description = description;
            Manager.Packages.Update(package);

            return JsonContent(result);
        }
Esempio n. 3
0
        public ActionResult Create(string title, string description)
        {
            var result = new AjaxResult();

            title = title.Trim();
            var exist = Manager.Packages.Items.Where(p => p.UserID == Security.User.ID && p.Title == title).Count() > 0;
            if (exist)
            {
                result.Success = false;
                result.Message = "已经存在同名图包";
                return JsonContent(result);
            }

            var package = new DAL.Package
            {
                Title = title,
                UserID = Security.User.ID,
                HasCover = false,
                Description = description,
                LastModify = new DateTime(1999, 1, 1)
            };
            Manager.Packages.Add(package);

            result.Data = new { id=package.ID,title=package.Title };

            return JsonContent(result);
        }
Esempio n. 4
0
        public ActionResult Index(int packageId = 0, string description = "", string source = "", string from = "")
        {
            description = description.Trim();
            source = source.Trim();
            from = from.Trim();

            var result = new AjaxResult();
            //判断图包是否存在
            var package = Manager.Packages.Find(packageId);
            if (package == null)
            {
                result.Success = false;
                result.Message = "图包不存在";
                return Json(result);
            }
            //判断是否有添加图片的权限
            if (package.UserID != Security.User.ID)
            {
                result.Success = false;
                result.Message = "无操作权限";
                return Json(result);
            }

            Manager.Picks.Add(from, source, packageId, description);

            return Json(result);
        }
Esempio n. 5
0
        public ActionResult Upload(string filename,int chunk,int chunks,HttpPostedFileBase file)
        {
            var result = new AjaxResult();
            using (var fs = System.IO.File.Create(string.Format("~/temp/{0)_{1}", filename, chunk).MapPath()))
            {
                fs.Write(file.InputStream);
            }

            if (chunk == chunks - 1)
            {
                var mergePath = string.Format("~/temp/{0}", filename).MapPath();
                using (var fs = System.IO.File.Create(mergePath))
                {
                    for (int i = 0; i < chunks; i++)
                    {
                        var chunkPath = string.Format("~/temp/{0)_{1}", filename, i).MapPath();
                        using (var cf = System.IO.File.OpenRead(chunkPath))
                        {
                            fs.Write(cf);
                        }
                        System.IO.File.Delete(chunkPath);
                    }
                    result.Data = filename;
                }

                System.IO.File.Delete(mergePath);
            }
            return Json(result);
        }
Esempio n. 6
0
        public ActionResult Index(string name, int chunk, int chunks, HttpPostedFileBase data)
        {
            var result = new AjaxResult();
            var path = Server.MapPath("~/temp/");
            using (var fs = System.IO.File.Create(path + name + "_" + chunk))
            {
                fs.Write(data.InputStream);
            }

            if (chunk == chunks - 1)
            {
                var mergePath = path + name;
                using (var fs = System.IO.File.Create(mergePath))
                {
                    for (int i = 0; i < chunks; i++)
                    {
                        var chunkPath = path + name + "_" + i;
                        using (var cf = System.IO.File.OpenRead(chunkPath))
                        {
                            fs.Write(cf);
                        }
                        System.IO.File.Delete(chunkPath);
                    }

                    var file = Manager.Files.Add(fs);
                    result.Data = new { id = file.ID };
                }

                System.IO.File.Delete(mergePath);
            }

            return Json(result);
        }
Esempio n. 7
0
        private AjaxResult Del(int id)
        {
            BLL.BLLBase bll = new BLLBase();
            AjaxResult re = null;

            var ctx = new Common.DataContext();

            ctx.BeginTransaction();
            try
            {
                bll.Update(ctx, new Model.Channel() {ID = id, State = 255});

                ctx.CommitTransaction();

                re = new AjaxResult() {Success = 1};
            }
            catch (Exception ex)
            {
                ctx.RollBackTransaction();

                re = new AjaxResult() {Success = 0, Message = "操作失败,原因:" + ex.Message};
            }
            finally
            {
                ctx.CloseConnection();
            }

            return re;
        }
Esempio n. 8
0
        private AjaxResult ResetPwd(int id)
        {
            BLL.BLLBase bll = new BLLBase();
            AjaxResult re = null;

            this.ctx.BeginTransaction();
            try
            {
                bll.Update(this.ctx, new Admin() {ID = id, Password = PubFunc.Md5("123456")});

                this.ctx.CommitTransaction();

                re = new AjaxResult() { Success = 1 };
            }
            catch (Exception ex)
            {
                this.ctx.RollBackTransaction();

                re = new AjaxResult() { Success = 0, Message = "操作失败,原因:" + ex.Message };
            }
            finally
            {
                this.ctx.CloseConnection();
            }

            return re;
        }
Esempio n. 9
0
    public string GetTweets(string ids)
    {
        var result = new AjaxResult();

        var tweets = Ops.GetTweets.GetMany(ids.Split(','));
        result.Data = tweets;

        return result.ToString();
    }
        public JsonResult PersonalSettingsSearchPage(string licenceNumber, string gpsCodeStr, string page, string rows)
        {
            AjaxResult ar = new AjaxResult();
            try
            {
                rows = "10";
                if (string.IsNullOrEmpty(page) || string.IsNullOrEmpty(rows))
                {
                    page = "1";
                }
                int pageIndex = Convert.ToInt32(page);
                int pageSize = Convert.ToInt32(rows);
                int rowIndex = (pageIndex - 1) * pageSize;

                int total = 0;
                List<VPersonalSetting> pdl = ModelFacade.Position.PositionModel.PersonalSettingSearch(Passport.UserCode,
                    licenceNumber.Trim(), ltGPSTypeId, RowIndex, PageSize, out total
                    );
                if (pdl != null && total > 0)
                {
                    var query = from u in pdl
                                select new
                                {
                                    cell = new string[]{
                                    u.VehicleCode.ToString(),
                                    "",
                                    u.GpsCode,
                                    u.GpsTypeID.ToString(),
                                    u.IsEnable.ToString(),
                                    !string.IsNullOrEmpty(u.OpenResultContent)?u.OpenResultContent:"",
                                    u.VehicleInfo,
                                    u.LastSetTime.HasValue?u.LastSetTime.Value.ToString("yyyy-MM-dd HH:mm:ss"):""
                                }
                                };

                    ar.Data = new
                    {
                        total = total / Convert.ToInt32(pageSize) + 1,
                        page = pageIndex,
                        records = total,
                        rows = query.Take(total)
                    };
                    ar.State = AjaxResultState.Success;
                    return Json(ar, JsonRequestBehavior.AllowGet);
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                ar.State = AjaxResultState.Error;
                ar.Message = ex.Message;
                return Json(ar, JsonRequestBehavior.AllowGet);
            }
            ar.State = AjaxResultState.Error;
            return Json(ar, JsonRequestBehavior.AllowGet);
        }
Esempio n. 11
0
 public JsonResult Push(string msg, string user)
 {
     AjaxResult result = new AjaxResult();
     try
     {
         PushHub pushHub = new PushHub();
         pushHub.Send(user, msg);
     }
     catch (Exception e)
     {
         result.IsSuccess = false;
     }
     return Json(result, JsonRequestBehavior.AllowGet);
 }
 public ActionResult Delete(string fileKey)
 {
     var result = new AjaxResult();
     try
     {
         _fileUploadService.Delete(fileKey);
         result.IsSuccess = true;
     }
     catch (Exception ex)
     {
         result.ErrorMessage = ex.Message;
     }
     return Json(result);
 }
Esempio n. 13
0
 public ActionResult Delete(int articleId)
 {
     var result = new AjaxResult();
     try
     {
         _articleRuService.Delete(articleId);
         result.IsSuccess = true;
     }
     catch (Exception exception)
     {
         result.ErrorMessage = exception.Message;
     }
     return Json(result);
 }
Esempio n. 14
0
        public ActionResult Add(List<int> fileid, int packageid, List<string> filename, string description)
        {
            var result = new AjaxResult();

            var package = Manager.Packages.Find(packageid);
            if(package==null || package.UserID!=Security.User.ID)
            {
                result.Message = "错误操作";
                result.Success = false;
                return JsonContent(result);
            }

            var images = new List<Image>();
            if (string.IsNullOrWhiteSpace(description) == false)
            {
                for (int i = 0; i < filename.Count; i++)
                {
                    filename[i] = description;
                }
            }

            var validFileIds = Manager.Files.Items.Where(f => fileid.Contains(f.ID)).Select(f=>f.ID).ToList();

            foreach (var id in validFileIds)
            {
                var index = fileid.IndexOf(id);
                if (index == -1)
                    continue;

                var image = new Image();
                image.FileID = fileid[index];
                image.Description = filename[index];
                image.PackageID = packageid;
                image.UserID = Security.User.ID;
                images.Add(image);
            }

            try
            {
                Manager.Images.AddRange(images);
            }
            catch (Exception ex)
            {
                result.Success = false;
                result.Message = ex.Message;
            }

            return JsonContent(result);
        }
Esempio n. 15
0
 public ActionResult Edit(ArticleRu model)
 {
     var result = new AjaxResult();
     try
     {
         model.Content = HttpUtility.UrlDecode(model.Content);
         model.UpdateTimestamp = DateTime.Now;
         _articleRuService.Update(model);
         result.IsSuccess = true;
     }
     catch (Exception exception)
     {
         result.ErrorMessage = exception.Message;
     }
     return Json(result);
 }
Esempio n. 16
0
 public ActionResult Edit(CustomContentViewModel model)
 {
     model.Content = HttpUtility.UrlDecode(model.Content);
     var result = new AjaxResult();
     try
     {
         var contentKey = string.Format("{0}_{1}", model.GroupName, model.Key);
         _customContentService.Set(contentKey, model.Content);
         result.IsSuccess = true;
     }
     catch (Exception exception)
     {
         result.ErrorMessage = exception.Message;
     }
     return Json(result);
 }
Esempio n. 17
0
    public string TweetsSince(string since)
    {
        AjaxResult result = new AjaxResult();
        long lSince = 0;
        bool validSince = long.TryParse(since, out lSince);

        if (lSince > 0)
        {
            result.Data = Ops.GetTweets.GetTweetsSince(since);
        }
        else
        {
            result.Data = Ops.GetTweets.GetMaxSince();
        }
        return result.ToString();
    }
Esempio n. 18
0
 public ActionResult Login(string email, string password, bool remember = false)
 {
     var result = new AjaxResult();
     email = email.Trim();
     var user = Manager.Users.Items.Where(u => u.Email == email).FirstOrDefault();
     if (user == null || user.Password != (password + user.Salt).MD5())
     {
         result.Success = false;
         result.Message = "邮箱或密码错误";
     }
     else
     {
         Security.Login(user.ID, remember);
     }
     return JsonContent(result);
 }
Esempio n. 19
0
        public ActionResult Add(Product model)
        {
            var result = new AjaxResult();
            try
            {
                model.Desc = HttpUtility.UrlDecode(model.Desc);
                model.UpdateTimestamp = DateTime.Now;
                _productService.Create(model);
                result.IsSuccess = true;
            }
            catch (Exception exception)
            {
                result.ErrorMessage = exception.Message;
            }

            return Json(result);
        }
Esempio n. 20
0
        public ActionResult Signup(string email, string name, string password1, string password2)
        {
            var result = new AjaxResult();

            if (password1 != password2)
            {
                result.Success = false;
                result.Message = "两次输入的密码不一样";
                return JsonContent(result);
            }

            email = email.Trim();
            var emailExist = Manager.Users.Items.Where(u => u.Email == email).Count() > 0;
            if (emailExist)
            {
                result.Success = false;
                result.Message = "邮箱已使用";
                return JsonContent(result);
            }

            name = name.Trim();
            var nameExist = Manager.Users.Items.Where(u => u.Name == name).Count() > 0;
            if (nameExist)
            {
                result.Success = false;
                result.Message = "昵称已使用";
                return JsonContent(result);
            }

            var salt = Guid.NewGuid().ToByteArray().ToHexString();
            var password = (password1 + salt).MD5();

            var user = new User
            {
                Name = name,
                Email = email,
                Password = password,
                Salt = salt,
                UseDefaultHead=true
            };

            Manager.Users.Add(user);

            return JsonContent(result);
        }
Esempio n. 21
0
 public ActionResult GetMileageDetail(string vehicleCodes, string vLicenceNumbers, string beginTime, string endTime)
 {
     AjaxResult ar = new AjaxResult();
     try
     {
         var result = ModelFacade.Report.ReportSummaryModel.GetMileageDetailReportList(Passport.TenantCode, vehicleCodes, vLicenceNumbers, Convert.ToDateTime(beginTime), Convert.ToDateTime(endTime));
         ar.Data = result;
         ar.State = AjaxResultState.Success;
         return Json(ar, JsonRequestBehavior.AllowGet);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
         ar.Message = ex.Message;
         ar.State = AjaxResultState.Error;
         return Json(ar, JsonRequestBehavior.AllowGet);
     }
 }
Esempio n. 22
0
        public ActionResult CancelPraise(int id)
        {
            var result = new AjaxResult();

            var image = Manager.Images.Find(id);

            if (image == null)
            {
                result.Success = false;
                result.Message = "错误操作";
                return JsonContent(result);
            }

            var praise = Manager.Praises.Items.Where(p => p.ImageID == image.ID && p.UserID == Security.User.ID).FirstOrDefault();
            if (praise != null)
                Manager.Praises.Remove(praise);

            var count = Manager.Praises.Items.Where(p => p.ImageID == image.ID).Count();
            result.Data = new { count };

            return JsonContent(result);
        }
Esempio n. 23
0
        public ActionResult Resave(ImageModalModel model)
        {
            var result = new AjaxResult();

            var image = Manager.Images.Find(model.ID);
            if (image == null)
            {
                result.Success = false;
                result.Message = "错误操作";
                return JsonContent(result);
            }

            var package = Manager.Packages.Find(model.PackageID);
            if (package == null || package.UserID != Security.User.ID)
            {
                result.Success = false;
                result.Message = "错误操作";
                return JsonContent(result);
            }

            var nImage = new DAL.Image
            {
                UserID = Security.User.ID,
                PackageID = package.ID,
                CreatedTime = DateTime.Now,
                FromUrlID = image.FromUrlID,
                Description = model.Description,
                FileID = image.FileID
            };
            Manager.Images.Add(nImage);
            Manager.ResaveChains.Add(new ResaveChain { Parent = image.ID, Child = nImage.ID });

            return JsonContent(result);
        }
Esempio n. 24
0
        public ActionResult Delete(int id)
        {
            var result = new AjaxResult();

            var image = Manager.Images.Find(id);
            if (image == null || image.UserID != Security.User.ID)
            {
                result.Success = false;
                result.Message = "错误操作";
                return JsonContent(result);
            }

            Manager.Images.Remove(image);

            //返回跳转网址
            result.Data = new { url = string.Format("/package/{0}", image.PackageID) };

            return JsonContent(result);
        }
        public ActionResult FileUpload(FormCollection form)
        {
            HttpFileCollectionBase files = Request.Files;
            var file = files[0];

            if (file == null)
            {
                return(Json(AjaxResult.Error("未找到需要上传的图片")));
            }
            if (file.ContentLength <= 0)
            {
                return(Json(AjaxResult.Error("未找到需要上传的图片")));
            }
            var extension = Path.GetExtension(file.FileName);

            if (extension != null)
            {
                extension = extension.ToLower();
            }
            if (extension == ".jpg" || extension == ".jpeg" || extension == ".png" || extension == ".gif" || extension == ".dwg")
            {
                //上传原图
                string folder = Server.MapPath("~/Upload/gx/");
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                string originalPath = folder + Guid.NewGuid() + Path.GetExtension(file.FileName);
                file.SaveAs(originalPath);
                GX_YSZLFILE yszlfile = new GX_YSZLFILE();
                yszlfile.ID         = new Common().GetRandom();
                yszlfile.TYPE       = ConvertUtility.ToDecimal(Request["type"]);
                yszlfile.FILEURL    = originalPath;
                yszlfile.XMYSXXID   = ConvertUtility.ToDecimal(form["gcxmid"]);
                yszlfile.CREATEBY   = CurrentUser.UserName;
                yszlfile.UPLOADTIME = DateTime.Now;
                yszlfile.FILEZT     = "1";
                yszlfile.FILENAME   = file.FileName.Substring(0, file.FileName.LastIndexOf('.'));
                yszlfile.FILESIZE   = file.ContentLength;
                gxYszlfileBusiness.AddEntity(yszlfile);
                return(Json(gxYszlfileBusiness.SaveChange() > 0 ? AjaxResult.Success("图片上传成功") : AjaxResult.Error("图片上传失败")));
            }
            else
            {
                return(Json(AjaxResult.Error("上传的图片格式有误")));
            }
        }
Esempio n. 26
0
 public AjaxResult DeleteCustomer(string id)
 {
     AjaxResult response = new AjaxResult();
     try
     {
         var customer = (from c in this.DBContext.Customers where c.CustomerID == id select c).First();
         this.DBContext.Customers.DeleteOnSubmit(customer);
         this.DBContext.SubmitChanges();
     }
     catch (Exception e)
     {
         response.ErrorMessage = e.ToString();
     }
     return response;
 }
Esempio n. 27
0
        public ActionResult Create(string formeditor, Templet templet, LoginUser user, List <FieldDto> selects)
        {
            AjaxResult result = new AjaxResult("保存成功!");

            #region 是否已存在

            Templet isExists = null;

            if (templet.TempletId > 0)
            {
                isExists = _unitOfWork.TempletRepository.GetBy(m => m.TempletName == templet.TempletName && m.FxtCompanyId == user.FxtCompanyId && m.Vaild == 1 && m.TempletId != templet.TempletId);
            }
            else
            {
                isExists = _unitOfWork.TempletRepository.GetBy(m => m.TempletName == templet.TempletName && m.FxtCompanyId == user.FxtCompanyId && m.Vaild == 1);
            }

            if (isExists != null)
            {
                result.Result = false;

                result.Message = "模板已存在!";

                return(AjaxJson(result));
            }

            #endregion

            #region

            //var templet = new Templet();

            //获取分组标签
            var pregGroup = @"<fieldset.*?</fieldset>";

            MatchCollection matchs = Regex.Matches(formeditor, pregGroup);

            //必选
            List <string> isselects = new List <string>();

            if (matchs != null && matchs.Count > 0)
            {
                for (int i = 0; i < matchs.Count; i++)
                {
                    //取分组
                    var pregGroupName = "groupname=\"(.?|.+?)\"";

                    Match gourpMatch = Regex.Match(matchs[i].Value, pregGroupName);

                    if (!gourpMatch.Value.IsNullOrEmpty())
                    {
                        string groupName = gourpMatch.Value.Split('=')[1].Replace(@"\", "").Replace("\"", "");

                        if (!groupName.IsNullOrEmpty())
                        {
                            var fieldGroup = new FieldGroup();

                            fieldGroup.FieldGroupName = groupName;

                            fieldGroup.Sort = i;

                            fieldGroup.AddUser = user.UserName;

                            fieldGroup.AddTime = DateTime.Now;

                            fieldGroup.Vaild = 1;

                            _unitOfWork.FieldGroupRepository.Delete(m => m.TempletId == templet.TempletId);

                            templet.FieldGroups = templet.FieldGroups == null ? new List <FieldGroup>() : templet.FieldGroups;
                            //templet.FieldGroups = new List<FieldGroup>();

                            templet.FieldGroups.Add(fieldGroup);

                            //获取字段标签
                            var preg = @"<(img|input|textarea|select|fieldset).*?(</select>|</textarea>|</fieldset>|>)";

                            MatchCollection fieldMatchs = Regex.Matches(matchs[i].Value, preg);

                            if (fieldMatchs != null && fieldMatchs.Count > 0)
                            {
                                for (int f = 0; f < fieldMatchs.Count; f++)
                                {
                                    //取字段
                                    var pregFieldName = "fieldname=\"(.?|.+?)\"";

                                    Match fieldMatch = Regex.Match(fieldMatchs[f].Value, pregFieldName);

                                    if (!string.IsNullOrEmpty(fieldMatch.Value))
                                    {
                                        string fieldName = fieldMatch.Value.Split('=')[1].Replace(@"\", "").Replace("\"", "");

                                        if (!fieldName.IsNullOrEmpty())
                                        {
                                            //字段类型
                                            var pregFieldType = "fieldtype=\"(.?|.+?)\"";

                                            Match fieldTypeMatch = Regex.Match(fieldMatchs[f].Value, pregFieldType);

                                            string fieldType = fieldTypeMatch.Value.Split('=')[1].Replace(@"\", "").Replace("\"", "");

                                            //标题
                                            var pregFieldTitle = "title=\"(.?|.+?)\"";

                                            Match fieldTitleMatch = Regex.Match(fieldMatchs[f].Value, pregFieldTitle);

                                            string fieldTitle = fieldTitleMatch.Value.Split('=')[1].Replace(@"\", "").Replace("\"", "");

                                            //字段最大长度
                                            var pregFieldMaxLength = "fieldmaxlength=\"(.?|.+?)\"";

                                            Match fieldMaxLengthMatch = Regex.Match(fieldMatchs[f].Value, pregFieldMaxLength);

                                            string[] fieldMaxLengths = fieldMaxLengthMatch.Value.Split('=');

                                            string fieldMaxLength = fieldMaxLengths.Length > 1 ? fieldMaxLengths[1].Replace(@"\", "").Replace("\"", "") : "";

                                            //字段最小长度
                                            var pregFieldMinLength = "fieldminlength=\"(.?|.+?)\"";

                                            Match fieldMinLengthMatch = Regex.Match(fieldMatchs[f].Value, pregFieldMinLength);

                                            string[] fieldMinLengths = fieldMinLengthMatch.Value.Split('=');

                                            string fieldMinLength = fieldMinLengths.Length > 1 ? fieldMaxLengths[1].Replace(@"\", "").Replace("\"", "") : "";

                                            //必填
                                            var pregFieldIsRequire = "fieldisrequire=\"(.?|.+?)\"";

                                            Match pregFieldIsRequireMatch = Regex.Match(fieldMatchs[f].Value, pregFieldIsRequire);

                                            string[] fieldIsRequires = pregFieldIsRequireMatch.Value.Split('=');

                                            string fieldIsRequire = fieldIsRequires.Length > 1 ? fieldIsRequires[1].Replace(@"\", "").Replace("\"", "") : "";

                                            //可空
                                            var pregFieldIsNull = "fieldisnull=\"(.?|.+?)\"";

                                            Match pregFieldIsNullMatch = Regex.Match(fieldMatchs[f].Value, pregFieldIsNull);

                                            string[] fieldIsNulls = pregFieldIsNullMatch.Value.Split('=');

                                            string fieldIsNull = fieldIsNulls.Length > 1 ? fieldIsNulls[1].Replace(@"\", "").Replace("\"", "") : "";

                                            //必选
                                            var pregFieldIsSelect = "fieldisselect=\"(.?|.+?)\"";

                                            Match pregFieldIsSelectMatch = Regex.Match(fieldMatchs[f].Value, pregFieldIsSelect);

                                            string[] fieldIsSelects = pregFieldIsSelectMatch.Value.Split('=');

                                            string fieldIsSelect = fieldIsSelects.Length > 1 ? fieldIsSelects[1].Replace(@"\", "").Replace("\"", "") : "";

                                            //字段值类型
                                            var pregFieldEditextType = "fieldeditexttype=\"(.?|.+?)\"";

                                            Match pregFieldEditextTypeMatch = Regex.Match(fieldMatchs[f].Value, pregFieldEditextType);

                                            string[] fieldeditexttypes = pregFieldEditextTypeMatch.Value.Split('=');

                                            string fieldeditexttype = fieldeditexttypes.Length > 1 ? fieldeditexttypes[1].Replace(@"\", "").Replace("\"", "") : "";

                                            //默认值
                                            var pregfielddefultvalue = "fielddefultvalue=\"(.?|.+?)\"";

                                            Match pregfielddefultvalueMatch = Regex.Match(fieldMatchs[f].Value, pregfielddefultvalue);

                                            string[] fielddefultvalues = pregfielddefultvalueMatch.Value.Split('=');

                                            string fielddefultvalue = fielddefultvalues.Length > 1 ? fielddefultvalues[1].Replace(@"\", "").Replace("\"", "") : "";

                                            //选项值
                                            //var pregfieldchoise = "fieldchoise=\"(.?|.+?)\"";

                                            //Match pregfieldchoiseMatch = Regex.Match(fieldMatchs[f].Value, pregfieldchoise);

                                            //string[] fieldchoises = pregfieldchoiseMatch.Value.Split('=');

                                            //string fieldchoise = fieldchoises.Length > 1 ? fieldchoises[1].Replace(@"\", "").Replace("\"", "") : "";

                                            var field = new Field();

                                            field.FieldName = fieldName;

                                            field.Title = fieldTitle;

                                            int maxlength = 0;
                                            if (int.TryParse(fieldMaxLength, out maxlength))
                                            {
                                                field.MaxLength = maxlength;
                                            }

                                            int minlength = 0;
                                            if (int.TryParse(fieldMinLength, out maxlength))
                                            {
                                                field.MinLength = minlength;
                                            }

                                            int isrequire = 0;
                                            if (int.TryParse(fieldIsRequire, out isrequire))
                                            {
                                                field.IsRequired = isrequire;
                                            }
                                            else
                                            {
                                                field.IsRequired = 0;
                                            }

                                            int isnull = 0;
                                            if (int.TryParse(fieldIsNull, out isnull))
                                            {
                                                field.IsNull = isnull;
                                            }
                                            else
                                            {
                                                field.IsNull = 0;
                                            }

                                            int editexttype = 0;
                                            if (int.TryParse(fieldeditexttype, out editexttype))
                                            {
                                                field.EdiTextType = editexttype;
                                            }

                                            int isselect = 0;
                                            if (int.TryParse(fieldIsSelect, out isselect) && isselect > 0)
                                            {
                                                isselects.Add(fieldName);
                                                field.IsSelect = isselect;
                                            }
                                            else
                                            {
                                                field.IsSelect = 0;
                                            }

                                            field.DefaultValue = fielddefultvalue;

                                            //field.Choise = fieldchoise;

                                            int filetype = 0;
                                            if (int.TryParse(fieldType, out filetype))
                                            {
                                                field.FieldType = filetype;

                                                switch (filetype)
                                                {
                                                case 1:
                                                    field.Type = "E";
                                                    break;

                                                case 2:
                                                    field.Type = "T";
                                                    break;

                                                case 3:
                                                    field.Type = "R";
                                                    break;

                                                case 5:
                                                    field.Type = "C";
                                                    break;

                                                case 6:
                                                    field.Type = "DT";
                                                    break;

                                                default:
                                                    break;
                                                }
                                            }

                                            field.Sort = f;

                                            field.AddUser = user.UserName;

                                            field.AddTime = DateTime.Now;

                                            field.Vaild = 1;

                                            _unitOfWork.FieldRepository.Delete(m => m.FieldGroupId == fieldGroup.FieldGroupId);

                                            fieldGroup.Fields = fieldGroup.Fields == null ? new List <Field>() : fieldGroup.Fields;
                                            //fieldGroup.Fields = new List<Field>();

                                            fieldGroup.Fields.Add(field);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //必选
            if (selects != null && selects.Count() > 0)
            {
                var isse = selects.Select(m => m.FieldName).Except(isselects);

                if (isse != null && isse.Count() > 0)
                {
                    string msg = string.Join(",", selects.Where(m => isse.Contains(m.FieldName)).Select(m => m.Title));

                    result.Result = false;

                    result.Message = "请选择必选字段:" + msg;

                    return(AjaxJson(result));
                }
            }

            //templet.TempletName = formname;

            if (templet.TempletId > 0)
            {
                templet.SaveUser = user.UserName;

                templet.SaveTime = DateTime.Now;
            }
            else
            {
                templet.AddUser = user.UserName;

                templet.AddTime = DateTime.Now;

                //templet.DatType = datType;

                templet.FxtCompanyId = user.FxtCompanyId;

                templet.Vaild = 1;

                _unitOfWork.TempletRepository.Insert(templet);
            }

            _unitOfWork.Commit();

            #endregion

            return(AjaxJson(result));
        }
Esempio n. 28
0
        public AjaxResult GetCustZZSView([FromBody] dynamic Json)
        {
            #region //参数


            string zsh     = Json.zsh;     //证书号
            string batch   = Json.batch;   //批号
            string stlgrd  = Json.stlgrd;  //钢种
            string stove   = Json.stove;   //炉号
            string stdcode = Json.stdcode; //执行标准
            string zldj    = Json.zldj;    //质量等级
            string fyd     = Json.fyd;     //发运单号
            string type    = Json.type;    //8线材/6钢坯
            #endregion

            #region //数据操作



            var cust = BaseUser.CustFile;

            string result = string.Empty;

            if (!string.IsNullOrEmpty(zsh.ToString()))
            {
                string cpt = string.Empty;

                string strpdf = string.Empty;

                DataTable dtpdf = tqc_zzs_file.GetList(batch.ToString(), stlgrd.ToString(), stove.ToString(), stdcode.ToString()).Tables[0];
                if (dtpdf.Rows.Count > 0)
                {
                    strpdf = dtpdf.Rows[0]["PDF"].ToString();
                }


                string[] dj = { "B1", "B2", "C1", "C2" };

                if (dj.Contains(zldj.ToString()))
                {
                    cpt = "ZZS_YCDY_BHG.cpt";
                    string[]      arr     = { fyd.ToString(), zsh.ToString() };
                    StringBuilder strHtml = new StringBuilder();

                    strHtml.AppendFormat("http://60.6.254.52:8685/webroot/decision/view/report?viewlet=xgcap/" + cpt + "&FYD={0}&ZSH={1}", arr);

                    result = strHtml.ToString();
                }
                else
                {
                    string printType = trc_roll_prodcut.GetZZSType(stlgrd.ToString(), stdcode.ToString());
                    switch (printType)
                    {
                    case "1":
                        cpt = "ZZS_YCDY_YL.cpt";
                        break;

                    case "2":
                        cpt = "ZZS_YCDY_RZ_YL.cpt";
                        break;

                    case "3":
                        cpt = "ZZS_YCDY_D_YL.cpt";
                        break;

                    case "4":
                        cpt = "ZZS_YCDY_YL_RBZH.cpt";
                        break;

                    default:
                        cpt = "ZZS_YCDY_YL.cpt";
                        break;
                    }

                    string rownum = trc_roll_prodcut.GetZZSPrintRowNum(stlgrd.ToString(), stdcode.ToString());

                    string[]      arr     = { fyd.ToString(), rownum, zsh.ToString() };
                    StringBuilder strHtml = new StringBuilder();

                    if (type.ToString() == "8")
                    {
                        strHtml.AppendFormat("http://60.6.254.52:8685/webroot/decision/view/report?viewlet=xgcap/" + cpt + "&FYD={0}&COU={1}&ZSH={2}", arr);
                    }
                    else
                    {
                        cpt = "ZZS_YCDY_GP_YL.cpt";
                        strHtml.AppendFormat("http://60.6.254.52:8685/webroot/decision/view/report?viewlet=xgcap/" + cpt + "&FYD={0}&COU={1}&ZSH={2}", arr);
                    }



                    //if (!string.IsNullOrEmpty(strpdf))
                    //{
                    //    string pdfpath = NF.Framework.StringFormat.ResolveUrl(strpdf);
                    //    strHtml.AppendFormat(" &nbsp;<a href='{0}' target=\"_blank\" class=\"btn btn-success btn-xs\">金相图片</a>", pdfpath);
                    //}


                    result = strHtml.ToString();
                }
            }

            AjaxResult result2 = new AjaxResult();
            result2.Code   = DoResult.Success;
            result2.Result = result;
            #endregion

            return(result2);
        }
Esempio n. 29
0
        /// <summary>
        /// 修改数据
        /// </summary>
        public AjaxResult Update(TbSupplyList model, List <TbSupplyListDetail> items, List <TbSupplyListDetailHistory> items2)
        {
            using (DbTrans trans = Db.Context.BeginTransaction())//使用事务
            {
                try
                {
                    var modelNew = Repository <TbSupplyList> .First(p => p.ID == model.ID);

                    modelNew.HasSupplierTotal = model.HasSupplierTotal;
                    int count = 0;
                    if (items.Count > 0)
                    {
                        for (int i = 0; i < items.Count; i++)
                        {
                            if (items[i].HasSupplier >= 0 && items[i].HasSupplier < items[i].BatchPlanQuantity)
                            {
                                count += 1;
                            }
                        }
                    }
                    if (count == 0)
                    {
                        model.StateCode          = "已供货";
                        model.SupplyCompleteTime = DateTime.Now;//供货完成时间
                        Repository <TbSupplyList> .Update(trans, model, p => p.ID == model.ID);

                        if (items != null && items.Count > 0)
                        {
                            Repository <TbSupplyListDetail> .Delete(trans, p => p.BatchPlanNum == items[0].BatchPlanNum);

                            //添加明细信息
                            Repository <TbSupplyListDetail> .Insert(trans, items);

                            Repository <TbSupplyListDetailHistory> .Delete(trans, p => p.BatchPlanNum == items[0].BatchPlanNum);

                            //添加明细信息
                            Repository <TbSupplyListDetailHistory> .Insert(trans, items2);
                        }
                        //SendMsg(modelNew, trans);
                    }
                    if (count > 0)
                    {
                        model.StateCode = "部分供货";
                        Repository <TbSupplyList> .Update(trans, model, p => p.ID == model.ID);

                        if (items != null && items.Count > 0)
                        {
                            Repository <TbSupplyListDetail> .Delete(trans, p => p.BatchPlanNum == items[0].BatchPlanNum);

                            //添加明细信息
                            Repository <TbSupplyListDetail> .Insert(trans, items);

                            Repository <TbSupplyListDetailHistory> .Delete(trans, p => p.BatchPlanNum == items[0].BatchPlanNum);

                            //添加明细信息
                            Repository <TbSupplyListDetailHistory> .Insert(trans, items2);
                        }
                        //SendMsg(modelNew, trans);
                    }
                    trans.Commit();//提交事务
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    return(AjaxResult.Error(ex.ToString()));
                }
                finally
                {
                    trans.Close();
                }
                return(AjaxResult.Success());
            }
        }
Esempio n. 30
0
        public ActionResult AddOrEdit(int id = 0)
        {
            var mile = _menuDal.Get <Menu>(id);

            return(Json(AjaxResult.Success(mile), JsonRequestBehavior.AllowGet));
        }
Esempio n. 31
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.IsPostBack)
            {
                this.id = this.Request.Form["id"];
                var txtLgName = this.Request.Form["txtLgName"];
                var txtName   = this.Request.Form["txtName"];
                var txtEmail  = this.Request.Form["txtMail"];
                var txtMob    = this.Request.Form["txtMob"];
                var txtQQ     = this.Request.Form["txtQQ"];
                var txtRemark = this.Request.Form["txtRemark"];
                var txtState  = this.ddlState.SelectedValue;

                var dt = new Model.Admin()
                {
                    ID         = int.Parse(this.id),
                    Email      = txtEmail,
                    LoginName  = txtLgName,
                    ModifyDate = DateTime.Now,
                    Name       = txtName,
                    Mob        = txtMob,
                    QQ         = txtQQ,
                    Remark     = txtRemark,
                    State      = int.Parse(txtState)
                };

                DataContext dc = new DataContext();

                AjaxResult response = null;
                dc.BeginTransaction();
                try
                {
                    var bll = new BLL.BLLBase();
                    bll.Update(dc, dt);

                    dc.CommitTransaction();

                    response = new AjaxResult()
                    {
                        Success = 1, Message = "操作成功", Data = this.id
                    };
                }
                catch (Exception exception)
                {
                    dc.RollBackTransaction();
                    response = new AjaxResult()
                    {
                        Success = 0, Message = "操作失败:" + exception.Message, Data = 0
                    };
                }
                finally
                {
                    dc.CloseConnection();
                }

                this.Response.Write(common.Common.GetJSMsgBox(response.Message));
            }
            else
            {
                this.id = this.Request.QueryString["id"];
                if (!string.IsNullOrEmpty(this.id))
                {
                    var ctx = new DataContext();

                    var dt = ctx.ExecuteDataTable(
                        "SELECT [LoginName],[Password],[Name],[Mob],[Email],[QQ],[Remark],[State],[CreateDate],[ModifyDate] From [Admin] Where id=" +
                        this.id + " and [state]<>255");

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        this.LoginName = dt.Rows[0]["LoginName"].ToString();
                        this.Name      = dt.Rows[0]["Name"].ToString();
                        this.Mob       = dt.Rows[0]["Mob"].ToString();
                        this.Email     = dt.Rows[0]["Email"].ToString();
                        this.QQ        = dt.Rows[0]["QQ"].ToString();
                        this.Remark    = dt.Rows[0]["Remark"].ToString();
                        this.State     = dt.Rows[0]["State"].ToString();

                        this.ddlState.Items.Add(new ListItem("正常", "0"));
                        this.ddlState.Items.Add(new ListItem("锁定", "1"));
                        this.ddlState.SelectedValue = this.State;
                    }
                    else
                    {
                        this.Response.Write(common.Common.GetJSMsgBox("没有获取到用户信息"));
                    }
                }
            }
        }
Esempio n. 32
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public AjaxResult Add(C_S_AppVersion entity)
        {
            DataTable dt = SqlHelper.ExecuteDataTable("select * from C_S_Application where ApplicationId = @ApplicationId", new SqlParameter[] { new SqlParameter("ApplicationId", entity.ApplicationId) });

            entity.Create();
            AjaxResult msg    = new AjaxResult();
            string     sqlStr = @"INSERT INTO dbo.C_S_AppVersion(AppVersionId,ApplicationId,VersionCode,AppFileName,
                                     AppDirectory,AppSize,Remark,CreateBy,CreateTime)
                                VALUES  ( @AppVersionId , @ApplicationId , 
                                          @VersionCode ,  @AppFileName , 
                                          @AppDirectory ,  @AppSize , 
                                          @Remark ,  @CreateBy ,  @CreateTime)";

            SqlParameter[] parameter =
            {
                new SqlParameter("AppVersionId",  entity.AppVersionId),
                new SqlParameter("ApplicationId", entity.ApplicationId),
                new SqlParameter("VersionCode",   entity.VersionCode),
                new SqlParameter("AppFileName",   entity.AppFileName),
                new SqlParameter("AppDirectory",  entity.AppDirectory),
                new SqlParameter("AppSize",       entity.AppSize),
                new SqlParameter("Remark",        entity.Remark),
                new SqlParameter("CreateBy",      entity.CreateBy),
                new SqlParameter("CreateTime",    entity.CreateTime)
            };
            int result = SqlHelper.ExecuteNonQuery(sqlStr, parameter);

            if (result == 1)
            {
                msg.data    = "";
                msg.state   = "success";
                msg.message = "新增成功!";

                #region ===========记录操作日志=============
                C_S_Log log = new C_S_Log()
                {
                    OperateType     = 0,//上传
                    OperateUserId   = entity.CreateBy,
                    ApplicationId   = entity.ApplicationId,
                    Content         = "上传应用",
                    ApplicationCode = "",
                    IPAddress       = Net.Ip,
                    MachineName     = Net.Host
                };

                if (dt.Rows.Count > 0)
                {
                    log.ApplicationCode = dt.Rows[0]["ApplicationCode"].ToString();
                }

                CSLog_BLL.Add(log);
                #endregion =================================
            }
            else
            {
                msg.data    = "";
                msg.state   = "error";
                msg.message = "新增失败!";
            }
            return(msg);
        }
Esempio n. 33
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="appVersionId"></param>
        /// <returns></returns>
        public AjaxResult Delete(string appVersionId)
        {
            AjaxResult msg = new AjaxResult();

            try
            {
                string         sqlStr1   = "select * from C_S_AppVersion where AppVersionId = @AppVersionId";
                SqlParameter[] parameter = { new SqlParameter("AppVersionId", appVersionId) };
                DataTable      dt        = SqlHelper.ExecuteDataTable(sqlStr1, parameter);

                if (dt.Rows.Count > 0)
                {
                    string applicationId = dt.Rows[0]["ApplicationId"].ToString();


                    DataTable dt_app = SqlHelper.ExecuteDataTable("select * from C_S_Application where ApplicationId = @ApplicationId", new SqlParameter[] { new SqlParameter("ApplicationId", applicationId) });

                    //先删除版本文件数据再删除应用版本数据
                    string sqlStr = @"delete C_S_VersionFile where AppVersionId = @AppVersionId
                                      ;delete C_S_AppVersion where AppVersionId = @AppVersionId";

                    string path = dt.Rows[0]["AppDirectory"].ToString();

                    SqlParameter[] parameter1 = { new SqlParameter("AppVersionId", appVersionId) };

                    int result = SqlHelper.ExecuteNonQuery(sqlStr, parameter1);

                    if (result > 0)
                    {
                        msg.data    = "";
                        msg.state   = "success";
                        msg.message = "删除成功!";

                        #region ===========记录操作日志=================
                        C_S_Log log = new C_S_Log()
                        {
                            OperateType     = 3,//移除
                            OperateUserId   = OperatorProvider.Provider.GetCurrent().UserName,
                            ApplicationId   = applicationId,
                            Content         = "删除版本",
                            ApplicationCode = "",
                            IPAddress       = Net.Ip,
                            MachineName     = Net.Host
                        };

                        if (dt.Rows.Count > 0)
                        {
                            log.ApplicationCode = dt_app.Rows[0]["ApplicationCode"].ToString();
                        }
                        CSLog_BLL.Add(log);
                        #endregion ======================================
                    }
                    else
                    {
                        msg.data    = "";
                        msg.state   = "error";
                        msg.message = "删除失败!";
                    }
                }
                else
                {
                    msg.data    = "";
                    msg.state   = "success";
                    msg.message = "已删除";
                }
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                msg.data    = "";
                msg.state   = "error";
                msg.message = "删除失败,程序发生异常!";
            }

            return(msg);
        }
Esempio n. 34
0
        public JsonResult Login(loginModel model)
        {
            string     username = model.username, password = model.password, viewId = model.viewId, projId = model.projId;
            AjaxResult error = new AjaxResult {
                state = ResultType.error.ToString(), message = "登录失败"
            };
            AjaxResult success = new AjaxResult {
                state = ResultType.success.ToString(), message = "登录成功"
            };
            var           result    = error.SetMsg("禁止登录");
            LogonLogModel logEntity = new LogonLogModel();

            logEntity.LogType = DbLogType.Login.ToString();
            try
            {
                ScadaFlowProjectModel Project = null;
                if (viewId != null && viewId != "" && viewId != "0")
                {
                    ScadaFlowViewModel view = ViewServer.GetByWhere(" where  ViewId='" + viewId + "'").First();
                    if (view != null)
                    {
                        Project      = ProjectServer.GetByWhere(" where ProjectId='" + view.ProjectId + "'").First();
                        model.projId = Project.Id.ToString();
                        model.viewId = view.ViewId;
                    }
                    string nickname = "";
                    bool   isUser   = ProjectServer.LoginOn(username, password, Project.Id.ToString(), out nickname);
                    if (isUser == true)
                    {
                        OperatorModel operatorModel = new OperatorModel();
                        operatorModel.UserId             = 0;
                        operatorModel.Account            = username;
                        operatorModel.RealName           = nickname;
                        operatorModel.HeadIcon           = "";
                        operatorModel.RoleId             = 0;
                        operatorModel.LoginIPAddress     = Net.Ip;
                        operatorModel.LoginIPAddressName = Net.GetLocation(Net.Ip);
                        OperatorFlowProvider.Provider.AddCurrent(operatorModel);
                        logEntity.Account     = username;
                        logEntity.RealName    = nickname;
                        logEntity.Description = Project.Title + "(" + Project.Id + ")工程的 " + nickname + "登陆成功!";
                        LogonLogService.WriteDbLog(logEntity);
                        result      = success.SetMsg(nickname + "登陆成功");
                        result.data = Json(model).Data;

                        return(Json(result));
                    }
                    else
                    {
                        result = error.SetMsg("用户名或密码错误");
                        return(Json(result));
                    }
                }
                else
                {
                    logEntity.Account     = username;
                    logEntity.RealName    = username;
                    logEntity.Description = "登录失败,登录页面不存在";
                    LogonLogService.WriteDbLog(logEntity);
                    result = error.SetMsg(logEntity.Description);
                    return(Json(result));
                }
            }
            catch (Exception ex)
            {
                logEntity.Account     = username;
                logEntity.RealName    = username;
                logEntity.Description = "登录失败," + ex.Message;
                LogonLogService.WriteDbLog(logEntity);
                result = error.SetMsg(logEntity.Description);

                return(Json(result));
            }
        }
Esempio n. 35
0
        public ActionResult SubmitLogin(string userName, string password)
        {
            AjaxResult res = _homeBus.SubmitLogin(userName, password);

            return(Content(res.ToJson()));
        }
Esempio n. 36
0
        public ActionResult Manage(UserInfo userinfo)
        {
            //key大于0 说明是修改操作
            var service = Container.GetService <IUserService>();
            var data    = new AjaxResult();

            if (userinfo.Key > 0)
            {
                var user = service.GetModels(u => u.keyid == userinfo.Key).FirstOrDefault();
                if (user != null)
                {
                    user.C_Name      = userinfo.Name;
                    user.C_LoginName = userinfo.LoginName;
                    user.C_PassWord  = new DES().DesEncrypt(userinfo.PassWord);
                    user.C_Sex       = userinfo.Sex;
                    if (userinfo.Photo != null)
                    {
                        var buff = new byte[userinfo.Photo.InputStream.Length];
                        userinfo.Photo.InputStream.Read(buff, 0, buff.Length);
                        user.C_Photo = buff;
                    }
                    user.C_UpdatedDate = DateTime.Now;
                    var result = service.Update(user);

                    data.State = result;
                    if (data.State)
                    {
                        data.Message = "修改成功";
                    }
                    else
                    {
                        data.Message = "修改失败";
                    }
                    return(Content(data.ToJson()));
                }
                else
                {
                    return(Content(new AjaxResult()
                    {
                        State = false, Message = "修改失败,不存在的用户", Data = ""
                    }.ToJson()));
                }
            }
            else
            {
                var user = new tbl_User();
                user.C_Name        = userinfo.Name;
                user.C_Enabled     = true;
                user.C_LoginName   = userinfo.LoginName;
                user.C_PassWord    = new DES().DesEncrypt(userinfo.PassWord);
                user.C_CreatedDate = DateTime.Now;
                user.C_Sex         = userinfo.Sex;
                if (userinfo.Photo != null)
                {
                    var buff = new byte[userinfo.Photo.ContentLength];
                    userinfo.Photo.InputStream.Read(buff, 0, buff.Length);
                    user.C_Photo = buff;
                }
                else
                {
                    user.C_Photo = null;
                }

                var result = service.Add(user);
                data.State = result;
                if (data.State)
                {
                    data.Message = "添加成功";
                }
                else
                {
                    data.Message = "添加失败";
                }
                return(Content(data.ToJson()));
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            string _actionType = context.Request.Params["action"].ToStringOrDefault("UnKown");

            if (_actionType.CompareIgnoreCase("getLocationList"))
            {
                int _pageIndex = context.Request.Params["PageIndex"].ToInt32OrDefault(1),
                    _pageSize  = context.Request.Params["PageSize"].ToInt32OrDefault(10);
                SqlServerDataOperator _helper     = new SqlServerDataOperator(@"Server=YANZHIWEI-IT-PC\SQLEXPRESS;database=Northwind;user id=sa;Password=sasa");
                PagedList <Order>     _pageResult = _helper.ExecutePageQuery <Order>("[Orders]", "*", "OrderID", OrderType.Desc, string.Empty, _pageSize, _pageIndex);
                AjaxResult            _result     = new AjaxResult(string.Empty, AjaxResultType.Success, _pageResult);
                string _json = SerializeHelper.JsonSerialize(new JsonPagedList <Order>(_pageResult)).ParseJsonDateTime();
                context.Response.Write(_json);
            }
            else if (_actionType.CompareIgnoreCase("exportLocationExcel"))
            {
                SqlServerDataOperator _helper     = new SqlServerDataOperator(@"Server=YANZHIWEI-IT-PC\SQLEXPRESS;database=JooWMS;user id=sa;Password=sasa");
                PagedList <Location>  _pageResult = _helper.ExecutePageQuery <Location>("[Location]", "*", "ID", OrderType.Desc, string.Empty, 10, 1);
                DataTable             _result     = GeneralMapper.ToDataTable <Location>(_pageResult, new string[4] {
                    "LocalNum", "LocalBarCode", "LocalName", "StorageNum"
                });
                string _filePath = context.Server.MapPath("~/UploadFiles/");

                if (!Directory.Exists(_filePath))
                {
                    Directory.CreateDirectory(_filePath);
                }

                string _filename = string.Format("库位管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));
                NPOIExcel.ToExcel(_result, "库位管理", "库位", Path.Combine(_filePath, _filename));
                context.CreateResponse(("/UploadFiles/" + _filename).Escape(), AjaxResultType.Success, string.Empty);
            }
            else
            {
                context.ExecutePageQuery <Person>((pageLength, pageIndex, orderIndex, orderBy) =>
                {
                    var persons = GetPersons();
                    Func <Person, object> order = p =>
                    {
                        if (orderIndex == 0)
                        {
                            return(p.Id);
                        }

                        return(p.Name);
                    };

                    if ("desc" == orderBy)
                    {
                        persons = persons.OrderByDescending(order);
                    }
                    else
                    {
                        persons = persons.OrderBy(order);
                    }

                    //错误测试
                    //DataTablePageResult result = new DataTablePageResult();
                    //result.ExecuteMessage = "测试错误";
                    //result.ExecuteState = HttpStatusCode.BadGateway;
                    //正确测试
                    DataTablePageResult result  = new DataTablePageResult();
                    result.iTotalDisplayRecords = persons.Count();
                    List <Person> _personList   = new List <Person>();
                    result.iTotalRecords        = persons.Count();
                    result.aaData       = persons.Skip(pageIndex).Take(pageLength);
                    result.ExecuteState = HttpStatusCode.OK;
                    return(result);
                });
                // // Those parameters are sent by the plugin
                // var iDisplayLength = int.Parse(context.Request["iDisplayLength"]);
                // var iDisplayStart = int.Parse(context.Request["iDisplayStart"]);
                // var iSortCol = int.Parse(context.Request["iSortCol_0"]);
                // var iSortDir = context.Request["sSortDir_0"];
                // // Fetch the data from a repository (in my case in-memory)
                // var persons = GetPersons();
                // // Define an order function based on the iSortCol parameter
                // Func<Person, object> order = p =>
                // {
                //     if (iSortCol == 0)
                //     {
                //         return p.Id;
                //     }
                //     return p.Name;
                // };
                // // Define the order direction based on the iSortDir parameter
                // if ("desc" == iSortDir)
                // {
                //     persons = persons.OrderByDescending(order);
                // }
                // else
                // {
                //     persons = persons.OrderBy(order);
                // }
                // // prepare an anonymous object for JSON serialization
                // var result = new
                // {
                //     iTotalRecords = persons.Count(),
                //     iTotalDisplayRecords = persons.Count(),
                //     aaData = persons
                //         .Skip(iDisplayStart)
                //         .Take(iDisplayLength)
                // };
                // //var serializer = new JavaScriptSerializer();
                //// var json = SerializationHelper.JsonSerialize(result);// serializer.Serialize(result);
                //  context.CreateResponse(result, System.Net.HttpStatusCode.OK);
                // //context.Response.ContentType = "application/json";
                // //context.Response.Write(json);
            }
        }
Esempio n. 38
0
 public string RetweetRankings()
 {
     var result = new AjaxResult();
     result.Data = Ops.RetweetRankings.Get();
     return result.ToString();
 }
Esempio n. 39
0
        public async Task <JsonResult> AddAnswer(AddCommentViewModel model)
        {
            var result = new AjaxResult();

            if (ModelState.IsValid)
            {
                #region ValidaCheckList
                //var tareas = await db.PQRSRecordTareas.Where(pt => pt.PQRSRecordId == model.PQRSRecordId && pt.PQRSRecordOrder == model.PQRSRecordOrder).ToListAsync();

                if (model.TipoComentario == TipoComentario.Approval)
                {
                    if (model.Tareas == null)
                    {
                        model.Tareas = new List <PQRSRecordTareas>();
                    }

                    bool   flagTareas = true;
                    string msgTareas  = "";
                    foreach (var t in model.Tareas)
                    {
                        if (t.Requerido && !t.Terminado)
                        {
                            flagTareas = false;
                            msgTareas += $" Task: '{t.Descripcion}' is required to advance" + System.Environment.NewLine;
                        }
                    }

                    if (!flagTareas)
                    {
                        return(Json(result.False(msgTareas), JsonRequestBehavior.AllowGet));
                    }
                }
                #endregion

                // Crear Comment (primer paso Success)
                PQRSRecordComentario nPQRSComment = new PQRSRecordComentario();
                nPQRSComment.PQRSRecordId    = model.PQRSRecordId;
                nPQRSComment.PQRSRecordOrder = model.PQRSRecordOrder;
                nPQRSComment.UsuarioId       = Seguridadcll.Usuario.UsuarioId;
                nPQRSComment.FechaCreacion   = DateTime.Now;
                nPQRSComment.Comentario      = model.Comment;
                nPQRSComment.TipoComentario  = model.TipoComentario;
                db.PQRSRecordComentarios.Add(nPQRSComment);
                await db.SaveChangesAsync();

                AddLog("PQRS/AddAnswer", nPQRSComment.Id, nPQRSComment);
                if (model.PQRSRecordDocumentos != null)
                {
                    await SaveDocuments(nPQRSComment.Id, model.PQRSRecordDocumentos);
                }
                if (model.Files != null)
                {
                    await UploadFiles(nPQRSComment.Id, model.Files);
                }

                if (model.Tareas != null)
                {
                    await SaveCheckList(model.Tareas);
                }
                if (model.Condiciones != null)
                {
                    foreach (var c in model.Condiciones)
                    {
                        await SaveConditions(c.Condiciones);
                    }
                }


                //Users in step
                var usuarioStep = await db.PQRSRecordUsuarios
                                  .Where(pu => pu.PQRSRecordId == model.PQRSRecordId && pu.PQRSRecordOrder == model.PQRSRecordOrder && pu.UsuarioId == Seguridadcll.Usuario.UsuarioId)
                                  .FirstOrDefaultAsync();

                if (usuarioStep != null)
                {
                    if (model.TipoComentario == TipoComentario.Approval)
                    {
                        //usuarioStep.EstadoUsuarioFlujoPQRS = EstadoUsuarioFlujoPQRS.Approved;
                        usuarioStep.EstadoUsuarioFlujoPQRS = EstadoUsuarioFlujoPQRS.Done;
                    }
                    else if (model.TipoComentario == TipoComentario.Rejection)
                    {
                        //usuarioStep.EstadoUsuarioFlujoPQRS = EstadoUsuarioFlujoPQRS.Rejected;
                        usuarioStep.EstadoUsuarioFlujoPQRS = EstadoUsuarioFlujoPQRS.Returned;
                    }
                    else if (model.TipoComentario == TipoComentario.Close)
                    {
                        usuarioStep.EstadoUsuarioFlujoPQRS = EstadoUsuarioFlujoPQRS.Closed;
                    }
                    db.Entry(usuarioStep).State = EntityState.Modified;
                    await db.SaveChangesAsync();
                }

                API.PQRSController ApiPQRS = new API.PQRSController();
                if (model.TipoComentario == TipoComentario.Close)
                {
                    await ApiPQRS.CloseFlow(model.TipoComentario, model.PQRSRecordId, model.PQRSRecordOrder);

                    //Notificación Close Flow
                    ApiPQRS.SendNotificationEmailTask(API.PQRSController.TipoNotificacion.Close, model.TipoComentario, model.TipoPQRS, model.PQRSRecordId, model.PQRSRecordOrder, model.DataId, nPQRSComment.Id, Seguridadcll.Usuario.UsuarioNombre, Seguridadcll.Aplicacion.Link);
                }
                else
                {
                    await ApiPQRS.ChangeStep(model.TipoComentario, model.PQRSRecordId, model.PQRSRecordOrder, model.DataId, model.TipoPQRS);

                    //Notificación Current Step
                    ApiPQRS.SendNotificationEmailTask(API.PQRSController.TipoNotificacion.CurrentStep, model.TipoComentario, model.TipoPQRS, model.PQRSRecordId, model.PQRSRecordOrder, model.DataId, nPQRSComment.Id, Seguridadcll.Usuario.UsuarioNombre, Seguridadcll.Aplicacion.Link);
                }

                await ApiPQRS.CompleteFormat(model.TipoPQRS, model.DataId);
            }
            else
            {
                return(Json(result.False("All fields are required."), JsonRequestBehavior.AllowGet));
            }


            return(Json(result.True(), JsonRequestBehavior.AllowGet));
        }
Esempio n. 40
0
 public AjaxResultModel <dynamic> Post(string loginName, string pwd)
 {
     return(AjaxResult.Success <dynamic>("登录成功" + loginName, new { token = "123456789" }));
 }
Esempio n. 41
0
        public AjaxResult GetWWZZH([FromBody] dynamic Json)
        {
            AjaxResult result = new AjaxResult();
            var        vUser  = (NF.Framework.CurrentUser)HttpContext.Current.Session["CurrentUser"];

            if (vUser == null)
            {
                result.Code   = DoResult.OverTime;
                result.Result = JsonConvert.SerializeObject("");
                return(result);
            }
            var zsNo = "";
            var mod  = new Mod_TMD_ZZS_REPRINT();

            #region 参数
            string strWhere = " and t.C_TYPE=2 and t.C_SPEC='" + Json.spec + "' and t.C_STL_GRD='" + Json.stlgrd
                              + "' and t.C_STD_CODE='" + Json.stdcode + "' and t.C_DISPATCH_ID='" + Json.fyd + "' and t.C_LIC_PLA_NO='" + Json.flaNo + "'";
            DataTable dt = tmd_dispatch.GetRePrintList(strWhere).Tables[0];
            if (dt.Rows.Count > 0)
            {
                mod.C_certificate_no = dt.Rows[0]["c_certificate_no"].ToString();
                if (dt.Rows[0]["c_attestor"].ToString().Trim() == "")
                {
                    mod.C_attestor = Json.empname;
                    var dtTime = DateTime.Now;
                    mod.D_visa_dt = dtTime;
                    tmd_dispatch.UpdateWWVTAndAttor(mod.C_certificate_no, mod.C_attestor, dtTime);
                }
                else
                {
                    mod.C_attestor = dt.Rows[0]["c_attestor"].ToString();
                    mod.D_visa_dt  = DateTime.Parse(dt.Rows[0]["d_visa_dt"].ToString());
                }
            }
            else
            {
                zsNo = randomnumber.GetZZS();
                mod  = new Mod_TMD_ZZS_REPRINT()
                {
                    C_lic_pla_no      = Json.flaNo,
                    C_stl_grd         = Json.stlgrd,    //钢种
                    C_std_code        = Json.stdcode,   //执行标准
                    C_dispatch_id     = Json.fyd,       //发运单号
                    C_spec            = Json.spec,      //规格
                    C_attestor        = Json.empname,   //签证人
                    C_print_templates = Json.mb,        //模板
                    C_print_type      = Json.printType, //打印
                    C_certificate_no  = zsNo,
                    D_mod_dt          = DateTime.Now,
                    D_visa_dt         = DateTime.Now,
                    C_remark          = Json.bz,
                    N_status          = 1,
                    N_type            = 2,
                    C_emp_id          = vUser.Name
                };
                if (!string.IsNullOrEmpty(mod.C_attestor))
                {
                    tmd_dispatch.AddRePrint(mod);
                }
            }
            #endregion

            result.Code   = DoResult.Success;
            result.Result = JsonConvert.SerializeObject(mod);
            return(result);
        }
Esempio n. 42
0
        public ActionResult GetMenuList()
        {
            Dictionary <string, string> dicMenu = new Dictionary <string, string>();
            string sessionId = Request.Cookies["sessionId"].Value;
            //根据该值查Memcache.
            object obj = Common.MemcacheHelper.Get(sessionId);

            if (obj != null)
            {
                Users LoginUser = Common.SerializeHelper.DeserializeToObject <Users>(obj.ToString());
                switch (LoginUser.Right)
                {
                case UserRight.超级管理员:
                    dicMenu = _MenuService.GetMenuByRight(UserRight.超级管理员);
                    //strMenuList = @"<li><a href=""/SVNOperation/Index"">SVN操作</a></li>
                    //           <li><a href=""/ProjectOperation/Index"">编译</a></li>
                    //           <li><a href=""/Home/Index"">打包</a></li>
                    //           <li><a href=""/Home/Index"">打包记录</a></li>
                    //           <li><a href=""/TaskOperation/Index"">任务列表</a></li>
                    //           <li><a href=""/Background/Index"">后台管理</a></li>
                    //         ";
                    break;

                case UserRight.普通用户:
                    dicMenu = _MenuService.GetMenuByRight(UserRight.普通用户);
                    //strMenuList = @"<li><a href=""/SVNOperation/Index"">SVN操作</a></li>
                    //           <li><a href=""/ProjectOperation/Index"">编译</a></li>
                    //           <li><a href=""/Home/Index"">打包</a></li>
                    //           <li><a href=""/Home/Index"">打包记录</a></li>
                    //           <li><a href=""/TaskOperation/Index"">任务列表</a></li>
                    //         ";
                    break;

                case UserRight.游客:
                    dicMenu = _MenuService.GetMenuByRight(UserRight.游客);
                    //strMenuList = @"
                    //           <li><a href=""/Home/Index"">打包记录</a></li>
                    //           <li><a href=""/TaskOperation/Index"">任务列表</a></li>
                    //         ";
                    break;
                }
            }

            StringBuilder strMenu    = new StringBuilder();
            AjaxResult    ajaxResult = null;

            if (dicMenu.Count > 0)
            {
                foreach (var menu in dicMenu)
                {
                    strMenu.Append("<li>");
                    strMenu.Append("<a href=" + menu.Value + ">");
                    strMenu.Append(menu.Key);
                    strMenu.Append("</a></li>");
                }
                ajaxResult = new AjaxResult()
                {
                    Result    = DoResult.Success,
                    PromptMsg = "成功",
                    Tag       = strMenu.ToString()
                };
            }
            else
            {
                ajaxResult = new AjaxResult()
                {
                    Result    = DoResult.Failed,
                    PromptMsg = "失败",
                };
            }

            return(Json(ajaxResult, JsonRequestBehavior.AllowGet));
        }
Esempio n. 43
0
        public async Task <AjaxResult> Pass(string Id)
        {
            var        _Op       = _provider.GetRequiredService <IOperator>();
            var        _checkSvc = _provider.GetRequiredService <ITD_CheckDataBusiness>();
            AjaxResult result    = new AjaxResult();

            try
            {
                var entity = await _tD_CheckBus.GetTheDataAsync(Id);

                entity.Status      = 1;
                entity.AuditeTime  = DateTime.Now;
                entity.AuditUserId = _Op.UserId;

                var checkDataList = await _checkSvc.AllCheckDataListAsync(entity.Id);

                //库存更新数据
                var localData = (from u in checkDataList
                                 where u.DisNum.HasValue
                                 select new BusinessInfo()
                {
                    ActionType = 2,
                    BarCode = u.BarCode,
                    BatchNo = u.BatchNo,
                    LocalId = u.localId,
                    MaterialId = u.MaterialId,
                    MeasureId = u.MeasureId,
                    Num = Convert.ToDouble(u.DisNum),
                    StorId = u.StorId,
                    ZoneId = u.ZoneId,
                    TrayId = u.TrayId
                }).ToList();

                //台账数据
                var recordData = (from u in checkDataList
                                  where u.DisNum.HasValue
                                  select new IT_RecordBook()
                {
                    Id = IdHelper.GetId(),
                    BarCode = u.BarCode,
                    BatchNo = u.BatchNo,
                    CreateTime = DateTime.Now,
                    CreatorId = _Op.UserId,
                    Deleted = false,
                    FromLocalId = u.localId,
                    FromStorId = u.StorId,
                    MaterialId = u.MaterialId,
                    MeasureId = u.MeasureId,
                    Num = System.Math.Abs(Convert.ToDouble(u.DisNum)),
                    RefCode = entity.RefCode,
                    Type = Convert.ToDouble(u.DisNum) > 0 ? "Panying" : "Deficit"
                }).ToList();

                await _tD_CheckBus.PassHandleAsync(entity, localData, recordData);

                result.Success = true;
            }
            catch (Exception e)
            {
                result.Success   = false;
                result.ErrorCode = 502;
                result.Msg       = e.Message;
            }

            return(result);
        }
Esempio n. 44
0
        //[AuthorizeFilterAttribute(NowRequestType = RequestType.AJAX, NowFunctionPageUrl = WebCommon.Url_Role_Index, AndNowFunctionCodes = new int[] { SYSCodeManager.FunOperCode_3 })]
        public ActionResult Save(SYS_Role role, int[] menu, string[] function)
        {
            var result = new AjaxResult("保存成功!");

            #region 菜单
            if (menu == null)
            {
                menu = new int[0];
            }

            var menuDelete = role.RoleMenus.Select(m => m.MenuID).Except(menu).ToList();

            var menuAdd = menu.Except(role.RoleMenus.Select(m => m.MenuID)).ToList();

            if (menuDelete != null && menuDelete.Count() > 0)
            {
                _unitOfWork.SysRoleMenuRepository.Delete(m => menuDelete.Contains(m.MenuID) && m.RoleID == role.Id);
            }
            if (menuAdd != null && menuAdd.Count() > 0)
            {
                foreach (var item in menuAdd)
                {
                    role.RoleMenus.Add(new SYS_Role_Menu()
                    {
                        CityID       = 0,
                        FxtCompanyID = role.FxtCompanyID,
                        MenuID       = item,
                        RoleID       = role.Id,
                    });
                }
            }
            #endregion

            #region 权限
            if (function == null)
            {
                function = new string[0];
            }
            //循环所有菜单
            var menus = _unitOfWork.SysMenuRepository.Get(m => m.Valid == 1);

            if (menus != null && menus.Count() > 0)
            {
                foreach (var ms in menus)
                {
                    //处理权限
                    var tFunctions = function.Where(m => m.StartsWith(ms.Id.ToString() + "#"));
                    //新的权限
                    var roleMenuFunctions = new List <SYS_Role_Menu_Function>();

                    if (tFunctions != null && tFunctions.Count() > 0)
                    {
                        foreach (var tf in tFunctions)
                        {
                            var menuFuncs = tf.Split(new string[] { "#" }, StringSplitOptions.RemoveEmptyEntries);

                            roleMenuFunctions.Add(new SYS_Role_Menu_Function()
                            {
                                RoleMenuID   = int.Parse(menuFuncs[1]),
                                FunctionCode = int.Parse(menuFuncs[2])
                            }
                                                  );
                        }
                    }

                    var tRoleMenu = role.RoleMenus.Where(m => m.MenuID == ms.Id && m.RoleID == role.Id).FirstOrDefault();

                    if (tRoleMenu != null)
                    {
                        if (tRoleMenu.Functions == null && roleMenuFunctions.Count == 0)
                        {
                            continue;
                        }

                        if (tRoleMenu.Functions == null)
                        {
                            tRoleMenu.Functions = new List <SYS_Role_Menu_Function>();
                        }

                        var old = tRoleMenu.Functions.Select(m => new SYS_Role_Menu_Function()
                        {
                            RoleMenuID = m.RoleMenuID, FunctionCode = m.FunctionCode
                        }).ToList();

                        var now = roleMenuFunctions.Where(m => m.RoleMenuID == tRoleMenu.Id).ToList();

                        var functionDelete = old.Except(now).ToList();

                        var functionAdd = now.Except(old).ToList();

                        if (functionDelete != null && functionDelete.Count() > 0)
                        {
                            var fds = functionDelete.Select(m => m.FunctionCode);

                            _unitOfWork.SysRoleMenuFunctionRepository.Delete(m => fds.Contains(m.FunctionCode) && m.RoleMenuID == tRoleMenu.Id);
                        }

                        if (functionAdd != null && functionAdd.Count() > 0)
                        {
                            foreach (var fa in functionAdd)
                            {
                                tRoleMenu.Functions.Add(new SYS_Role_Menu_Function()
                                {
                                    CityID       = 0,
                                    FxtCompanyID = role.FxtCompanyID,
                                    FunctionCode = fa.FunctionCode,
                                    RoleMenuID   = tRoleMenu.Id,
                                    Valid        = 1
                                });
                            }
                        }
                    }
                }
            }
            #endregion

            _unitOfWork.Commit();

            return(AjaxJson(result));
        }
        public async Task <JsonResult> Pay(string DisCountTitle, string OrderId, CancellationToken cancellationToken)
        {
            AjaxResult     result   = new AjaxResult("Error");
            PayInput       input    = new PayInput();
            PaymentRequest response = new PaymentRequest();
            CustomUser     user     = new CustomUser();
            DisCount       DisCount = new DisCount();

            if (string.IsNullOrEmpty(OrderId))
            {
                result.Errors.Add("اطلاعات ارسالی صحیح نیس");
                return(new JsonResult(result));
            }

            Order order = await orderRepository.GetByIdAsync(Guid.Parse(OrderId), cancellationToken);

            if (order == null)
            {
                result.Errors.Add("اطلاعات ارسالی صحیح نیس");
                return(new JsonResult(result));
            }

            input.Deposits = order.TotalPrice;

            if (!string.IsNullOrEmpty(DisCountTitle))
            {
                DisCount = await disCountRepository.GetByTitle(DisCountTitle.Trim(), cancellationToken);

                input.Deposits = DisCount != null?DisCountHelper.ComputeDisCount(DisCount, order.TotalPrice) : order.TotalPrice;
            }

            if (User.Identity.IsAuthenticated)
            {
                user = await customUserManager.GetUserAsync(User);
            }
            else
            {
                string anonymousUserId = cookieManager.Get <string>("LocalhostCart");

                user = await orderRepository.GetAnonymousUser(anonymousUserId, cancellationToken);
            }

            input.Deposits = DisCountHelper.WithdrawFromWallet(user, input.Deposits);

            input.PhoneNumber = user?.PhoneNumber;

            if (input.Deposits >= 1000)
            {
                input.Redirect    = siteSetting.BuyCourseCallBackUrl;
                input.Description = "تصویه صورت حساب با احتساب تخفیف و کسر از کیف پولتان";
                response          = await payment.PayAsync(input, cancellationToken);
            }
            else
            {
                result.Status               = "Success";
                result.RedirectUrl          = "";
                result.MessageWhenSuccessed = " مبلغ با محاسبه تخفیف و کسر از کیف پول پرداخت شد";
                DisCount.Count              = DisCount.Count > 0 ? --DisCount.Count : DisCount.Count;
                await customUserManager.UpdateAsync(user);

                order.IsBought = true;
                await disCountRepository.UpdateAsync(DisCount, cancellationToken);

                return(new JsonResult(result));
            }
            if (Assert.NotNull(response) && response.Status == 1 && Assert.NotNull(response.Token))
            {
                result.Status      = "Success";
                result.RedirectUrl = siteSetting.RedirectUrl + response.Token;
                user.PaymentToken  = response.Token;
                DisCount.Count     = DisCount.Count > 0 ? DisCount.Count-- : DisCount.Count;
                await customUserManager.UpdateAsync(user);

                order.IsBought = true;
                await disCountRepository.UpdateAsync(DisCount, cancellationToken);

                return(new JsonResult(result));
            }
            else
            {
                result.Errors.Add("عملیات پرداخت با شکست مواجه شد لطفا بعدا امتحان کنید");
                result.Errors.Add(response.ErrorMessage);
            }

            return(new JsonResult(result));
        }
        public ActionResult Add(FormCollection form, GX_XLZX gxXlzx)
        {
            gxXlzx.ID         = new Common().GetRandom();
            gxXlzx.NAME       = form["name"];
            gxXlzx.ROLEID     = ConvertUtility.ToDecimal(form["roleId"]);
            gxXlzx.CREATEBY   = CurrentUser.UserName;
            gxXlzx.CREATETIME = DateTime.Now;
            gxXlzxBusiness.AddEntity(gxXlzx);

            return(Json(gxXlzxBusiness.SaveChange() > 0 ? AjaxResult.Error("数据操作成功!") : AjaxResult.Error("数据操作失败!")));
        }
 public ActionResult Save()
 {
     try
     {
         var gcxmid = ConvertUtility.ToDecimal(Request["id"]);
         GxLeaveOpinionBusiness opinionBusiness = new GxLeaveOpinionBusiness();
         GX_LEAVEOPINION        oLeaveopinion   = new GX_LEAVEOPINION();
         oLeaveopinion.APPINSTANCEID = gcxmid;
         opinionBusiness.Add(oLeaveopinion);
         return(Json(opinionBusiness.SaveChange() > 0 ? AjaxResult.Success("数据提交成功") : AjaxResult.Error("数据提交失败")));
     }
     catch (Exception ex)
     {
         return(Json(AjaxResult.Error("数据提交失败:" + (ex.InnerException == null ? ex.Message : ex.InnerException.Message))));
     }
 }
        public ActionResult Edit(FormCollection form, GX_XLZX gxXlzx)
        {
            decimal id    = ConvertUtility.ToDecimal(form["Id"]);
            var     model = gxXlzxBusiness.Find(id);

            if (model == null)
            {
                return(Json(AjaxResult.Error("未找到需要更新的数据!")));
            }
            gxXlzx.NAME       = form["name"];
            gxXlzx.ROLEID     = ConvertUtility.ToDecimal(form["roleId"]);
            gxXlzx.CREATEBY   = model.CREATEBY;
            gxXlzx.CREATETIME = model.CREATETIME;
            gxXlzx.MODIFYBY   = CurrentUser.UserName;
            gxXlzx.MODIFYTIME = DateTime.Now;
            gxXlzxBusiness.UpdateEntity(gxXlzx);
            return(Json(gxXlzxBusiness.SaveChange() > 0 ? AjaxResult.Error("数据操作成功!") : AjaxResult.Error("数据操作失败!")));
        }
Esempio n. 49
0
        public ActionResult Edit(ImageModalModel model)
        {
            var result = new AjaxResult();

            var image = Manager.Images.Find(model.ID);
            if (image == null || image.UserID != Security.User.ID)
            {
                result.Success = false;
                result.Message = "错误操作";
                return JsonContent(result);
            }

            var package = Manager.Packages.Find(model.PackageID);
            if (package == null || package.UserID != Security.User.ID)
            {
                result.Success = false;
                result.Message = "错误操作";
                return JsonContent(result);
            }

            image.PackageID = package.ID;
            image.Description = model.Description;

            Manager.Images.Update(image);

            return JsonContent(result);
        }
    private void Submit()
    {
        AjaxResult result = new AjaxResult();

        result.IsSuccess = false;
        result.Msg       = "提交失败!";
        var planid = Request.Form["id"] != null?Convert.ToInt32(Request.Form["id"]) : 0;

        var model = bll.Get(planid);

        try
        {
            model.Status = 2;
            #region 审核部门判断
            if (model.IsUrgentTask)
            {
                if (model.IsCrossArea)
                {
                    model.AuditName = "运行管理中心审批";
                }
                else
                {
                    model.AuditName = "分局站审批";
                }
            }
            else
            {
                //飞行日期跨度是否超过7天
                if (model.IsCrossDay)
                {
                    if (model.IsCrossArea)
                    {
                        model.AuditName = "运行管理中心审批";
                    }
                    else
                    {
                        model.AuditName = "分局站审批";
                    }
                    model.AuditName += "或空管部审批";
                }
                else
                {
                    if (model.IsCrossArea)
                    {
                        model.AuditName = "运行管理中心审批";
                    }
                    else
                    {
                        model.AuditName = "分局站审批";
                    }
                }
            }

            if (bll.Update(model))
            {
                result.IsSuccess = true;
                result.Msg       = "提交成功!";
            }
            #endregion
        }
        catch (Exception e)
        {
            result.IsSuccess = false;
            result.Msg       = "提交失败!";
        }
        Response.Clear();
        Response.Write(result.ToJsonString());
        Response.ContentType = "application/json";
        Response.End();
    }
        public ActionResult OprRw(FormCollection form)
        {
            var id    = ConvertUtility.ToDecimal(form["gcxmid"]);
            var model = gxProjectBusniess.Find(id);

            if (model == null)
            {
                return(Json(AjaxResult.Error("未找到分配的项目")));
            }
            //线路中心
            model.XLZX = form["CheckMan"];
            //分配的人员
            model.YSRY = form["LineServiceCenter"];
            gxProjectBusniess.Update(model);
            return(Json(gxProjectBusniess.SaveChange() > 0 ? AjaxResult.Success("任务分配操作成功") : AjaxResult.Error("任务分配操作失败")));
        }
Esempio n. 52
0
        public static string ApiService(string service, string method, object param)
        {
            AuditingManager auditing = new AuditingManager();
            AjaxResult result = null;
                auditing.Start(service, method, param.ToString());
            try
            {
                var dataResult = ServiceController.Instance.Execute(service, method, param, RequestType.ServiceFile);
                result = new AjaxResult()
                {
                    IsSuccess = true,
                    Result = dataResult
                };
            }
            catch (Exception ex)
            {
                var except = ex.InnerException ?? ex;

                result = new AjaxResult()
                {
                    IsSuccess = false,
                    Result = null,
                    Errors = new Errors()
                    {
                        Message = except.Message,
                        //CallStack = except.StackTrace
                    }
                };


                if (except.GetType() == typeof (UserFriendlyException))
                {
                    result.Errors.IsFriendlyError = true;
                }
                else if (except.GetType() == typeof (AuthorizationException))
                {
                    result.Errors.IsFriendlyError = false;
                    result.IsAuthorized = false;
                }
                if (except.GetType() == typeof (UserFriendlyException))
                {
                    var exc = except as UserFriendlyException;
                    var newExc = exc?.InnerException ?? exc;
                    auditing.Exception(newExc?.Message + newExc?.StackTrace);
                    try
                    {
                        Logger.Error(newExc?.Message, newExc);
                    }
                    catch (Exception)
                    {
                        auditing._auditInfo.Exception += "Logs文件夹没有权限。";
                    }
                }
                else
                {
                    auditing.Exception(ex.Message + ex.StackTrace);
                    try
                    {
                        Logger.Error(ex.Message, ex);
                    }
                    catch (Exception)
                    {
                        auditing._auditInfo.Exception += "Logs文件夹没有权限。";
                    }
                }
               
            }
            var responseStr = JsonConvert.SerializeObject(result, new JsonSerializerSettings()
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            });
            auditing.Stop(responseStr);
            return responseStr;
        }
Esempio n. 53
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if(IsPostBack)
            {
                AjaxResult response = null;

                var txtLgName = Request.Form["txtLgName"];
                var txtPwd = Request.Form["txtPwd"];
                var txtName = Request.Form["txtName"];
                var txtEmail = Request.Form["txtMail"];
                var txtQQ = Request.Form["txtQQ"];
                var txtMob = Request.Form["txtMob"];
                var txtRemark = Request.Form["txtRemark"];

                if (string.IsNullOrEmpty(txtLgName))
                {
                    response = new AjaxResult() {Success = 0, Message = "登录名不能为空。"};
                    this.Response.Write(common.Common.GetJSMsgBox(response.Message));
                    return;
                }

                if (string.IsNullOrEmpty(txtPwd))
                {
                    response = new AjaxResult() { Success = 0, Message = "密码不能为空。" };
                    this.Response.Write(common.Common.GetJSMsgBox(response.Message));
                    return;
                }

                if (string.IsNullOrEmpty(txtName))
                {
                    response = new AjaxResult() { Success = 0, Message = "用户名不能为空。" };
                    this.Response.Write(common.Common.GetJSMsgBox(response.Message));
                    return;
                }

                var dt = new Model.Admin()
                             {
                                 CreateDate = DateTime.Now,
                                 Email = txtEmail,
                                 LoginName = txtLgName,
                                 ModifyDate = DateTime.Now,
                                 Name = txtName,
                                 Password = PubFunc.Md5(txtPwd),
                                 QQ = txtQQ,
                                 Mob = txtMob,
                                 Remark = txtRemark
                             };

                DataContext dc=new DataContext();

                dc.BeginTransaction();
                try
                {
                    var bll = new BLL.BLLBase();
                    var id = bll.Add(dc, dt);

                    dc.CommitTransaction();

                    response = new AjaxResult() {Success = 1, Message = "操作成功", Data = id};
                }
                catch(Exception exception)
                {
                    dc.RollBackTransaction();
                    response = new AjaxResult() { Success = 0, Message = "操作失败:"+exception.Message, Data = 0 };
                }
                finally
                {
                    dc.CloseConnection();
                }

                this.Response.Write(common.Common.GetJSMsgBox(response.Message));
            }
        }
Esempio n. 54
0
        public AjaxResultModel <dynamic> Get(string token)
        {
            List <dynamic> menus = GetMenus();

            return(AjaxResult.Success <dynamic>(new { name = "renfusuai", roles = new string[] { "admin" }, menus }));
        }
Esempio n. 55
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var bll = new BLL.BLLBase();
                var chtb = bll.Select(ctx, new Channel() { ID = Convert.ToInt32(Request.QueryString["id"]), State = 0 });

                if (chtb != null && chtb.Rows.Count > 0)
                {
                    channel = chtb.ToList<Model.Channel>()[0];
                    img_1.ImgUrls = channel.ImageUrl;
                    var tb =
                        ctx.ExecuteDataTable(
                            "Select * From Channel where State<>255 and ParentId=0 and [Type] in (1,2)");

                    ddlParentId.Items.Add(new ListItem("顶级栏目", "0"));

                    if (tb != null && tb.Rows.Count > 0)
                    {
                        var channels = tb.ToList<Model.Channel>();
                        foreach (var pchannel in channels)
                        {
                            var item = new ListItem(pchannel.Name, pchannel.ID.ToString());
                            item.Attributes.Add("type", pchannel.Type.ToString());
                            ddlParentId.Items.Add(item);
                            if (pchannel.ID == channel.ParentId)
                            {
                                item.Selected = true;
                            }
                        }
                    }

                    ddlType.Items.Add(new ListItem("栏目列表页", "2"));
                    ddlType.Items.Add(new ListItem("内容列表页", "1"));
                    ddlType.Items.Add(new ListItem("单独内容页", "0"));
                }
            }
            else
            {
                AjaxResult response = null;

                var id = Request.Form["id"];
                var txtParentId = Request.Form["ctl00$ContentPlaceHolder1$ddlParentId"];
                var txtName = Request.Form["txtName"];
                var txtCode = Request.Form["txtCode"];
                var txtType = Request.Form["ctl00$ContentPlaceHolder1$ddlType"];
                var sltContentType = Request.Form["sltContentType"];
                var txtState = Request.Form["sltState"];
                var txtRemark = Request.Form["txtRemark"];
                var txtSort = Request.Form["txtSort"];
                var imageUrl = !string.IsNullOrEmpty(Request.Form["hifShowImage"])
                                   ? common.Common.UploadImagePath + Request.Form["hifShowImage"]
                                   : "";

                if (string.IsNullOrEmpty(txtCode))
                {
                    response = new AjaxResult() { Success = 0, Message = "代号不能为空!" };
                    this.Response.Write(common.Common.GetJSMsgBox(response.Message));
                    return;
                }

                if (string.IsNullOrEmpty(txtType))
                {
                    response = new AjaxResult() { Success = 0, Message = "类别不能为空。" };
                    this.Response.Write(common.Common.GetJSMsgBox(response.Message));
                    return;
                }

                if (string.IsNullOrEmpty(sltContentType))
                {
                    response = new AjaxResult() { Success = 0, Message = "内容类型不能为空。" };
                    this.Response.Write(common.Common.GetJSMsgBox(response.Message));
                    return;
                }

                if (string.IsNullOrEmpty(txtName))
                {
                    response = new AjaxResult() { Success = 0, Message = "用户名不能为空。" };
                    this.Response.Write(common.Common.GetJSMsgBox(response.Message));
                    return;
                }

                var dt = new Model.Channel()
                             {
                                 ID = Convert.ToInt32(id),
                                 Type = Convert.ToInt16(txtType),
                                 Code = txtCode,
                                 ModifyDate = DateTime.Now,
                                 Name = txtName,
                                 ContentType = Convert.ToInt16(sltContentType),
                                 ModifiedBy = (Session["LoginAdmin"] as Model.Admin).ID,
                                 Remark = txtRemark,
                                 ImageUrl = imageUrl,
                                 ParentId = Convert.ToInt16(txtParentId),
                                 State = Convert.ToInt16(txtState),
                                 Sort = Convert.ToInt16(txtSort),
                             };

                ctx.BeginTransaction();
                try
                {
                    var bll = new BLL.BLLBase();
                    bll.Update(ctx, dt);

                    ctx.CommitTransaction();

                    response = new AjaxResult() { Success = 1, Message = "操作成功", Data = id };
                }
                catch (Exception exception)
                {
                    ctx.RollBackTransaction();
                    response = new AjaxResult() { Success = 0, Message = "操作失败:" + exception.Message, Data = 0 };
                }
                finally
                {
                    ctx.CloseConnection();
                }

                this.Response.Write(common.Common.GetJSMsgBox(response.Message));
            }
        }
Esempio n. 56
0
        public ActionResult LoadData(int pageIndex, int pageSize, int departmentId, string uName, UserCenter_LoginUserInfo loginUserInfo)
        {
            var result = new AjaxResult("");

            var surveystFilter = PredicateBuilder.True <AllotFlow>();

            surveystFilter = surveystFilter.And(m => m.CityId == loginUserInfo.NowCityId && m.FxtCompanyId == loginUserInfo.FxtCompanyId);

            #region 小组
            if (departmentId > 0)
            {
                //小组下所有用户
                var departmentUser = _unitOfWork.DepartmentUserRepository.Get()
                                     .Where(m => m.FxtCompanyID == loginUserInfo.FxtCompanyId && m.CityID == loginUserInfo.NowCityId &&
                                            m.DepartmentID == departmentId).ToList();
                var userids = departmentUser.Select(m => m.UserName);
                if (userids.Count() > 0)
                {
                    surveystFilter = surveystFilter.And(m => userids.Contains(m.SurveyUserName));
                }
                else
                {
                    return(AjaxJson(result));
                }
            }
            if (!uName.IsNullOrEmpty())
            {
                surveystFilter = surveystFilter.And(m => m.SurveyUserTrueName.Contains(uName));
            }
            #endregion

            #region 权限
            List <int> functionCodes = _unitOfWork.FunctionService.GetAllBy(loginUserInfo.UserName, loginUserInfo.FxtCompanyId, loginUserInfo.NowCityId, WebCommon.Url_AllotFlowInfo_AllotFlowManager)
                                       .Select(m => m.FunctionCode).ToList();
            if (functionCodes.Contains(SYSCodeManager.FunOperCode_3))//全部
            {
            }
            else if (functionCodes.Contains(SYSCodeManager.FunOperCode_2))//小组内
            {
                var nowDepartment = _unitOfWork.DepartmentUserRepository.Get(m => (m.FxtCompanyID == loginUserInfo.FxtCompanyId || m.FxtCompanyID == 0) &&
                                                                             (m.CityID == loginUserInfo.NowCityId || m.CityID == 0) &&
                                                                             m.UserName == loginUserInfo.UserName).FirstOrDefault();

                //小组下所有用户
                var departmentUser = _unitOfWork.DepartmentUserRepository.Get()
                                     .Where(m => m.FxtCompanyID == loginUserInfo.FxtCompanyId && m.CityID == loginUserInfo.NowCityId &&
                                            m.DepartmentID == nowDepartment.DepartmentID).ToList();
                var userids = departmentUser.Select(m => m.UserName);
                if (userids.Count() > 0)
                {
                    surveystFilter = surveystFilter.And(m => userids.Contains(m.SurveyUserName));
                }
                else
                {
                    return(AjaxJson(result));
                }
            }
            #endregion

            var surveys   = _unitOfWork.AllotFlowRepository.Get(surveystFilter);
            var projects  = _unitOfWork.ProjectRepository.Get(m => m.CityID == loginUserInfo.NowCityId && m.FxtCompanyId == loginUserInfo.FxtCompanyId);
            var buildings = _unitOfWork.BuildingRepository.Get(m => m.CityID == loginUserInfo.NowCityId && m.FxtCompanyId == loginUserInfo.FxtCompanyId);
            var data      = from s in surveys
                            group s by new { SurveyUserName = s.SurveyUserName, SurveyUserTrueName = s.SurveyUserTrueName } into us
            where us.Key.SurveyUserName != "" && us.Key.SurveyUserName != null
                select new SurveyCountDto()
            {
                ToSurveyCount               = us.Where(m => m.StateCode == SYSCodeManager.STATECODE_2).Count(),
                InTheSurveyCount            = us.Where(m => m.StateCode == SYSCodeManager.STATECODE_4).Count(),
                HaveSurveyCount             = us.Where(m => m.StateCode == SYSCodeManager.STATECODE_5).Count(),
                PendingApprovalCount        = us.Where(m => m.StateCode == SYSCodeManager.STATECODE_6).Count(),
                PassedApprovalCount         = us.Where(m => m.StateCode == SYSCodeManager.STATECODE_8).Count(),
                AlreadyStorageCount         = us.Where(m => m.StateCode == SYSCodeManager.STATECODE_10).Count(),
                SurveyUserName              = us.Key.SurveyUserName,
                SurveyUserTrueName          = us.Key.SurveyUserTrueName,
                AlreadyStorageBuildingCount = (from u in us
                                               join p in projects on u.DatId equals p.ProjectId
                                               join b in buildings on p.ProjectId equals b.ProjectId
                                               where u.StateCode == SYSCodeManager.STATECODE_10
                                               select b).Count()
            };
            var recordcount = data.Count();
            var list        = data.OrderByDescending(m => m.AlreadyStorageCount).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
            result.Data = new { list = list, recordcount = recordcount };
            return(AjaxJson(result));
        }
Esempio n. 57
0
        public ActionResult Import(Information InformationModel, List <FormModel> CustomItemModel)
        {
            AjaxResult ar = new AjaxResult();

            if (InformationModel == null)
            {
                ar.state   = ResultType.error.ToString();
                ar.message = "提交数据有误,添加新纪录失败";
                return(Json(ar, JsonRequestBehavior.AllowGet));
            }

            try
            {
                var currentUser = LoginManager.GetCurrentUser();
                if (!_informationBLL.IsExsit(InformationModel.Phone,
                                             InformationModel.QQ, InformationModel.WebCat, currentUser.CompanyCode))
                {
                    #region 注释
                    //var state = _informationBLL.AddInformation(InformationModel, currentUser.Account, currentUser.CompanyCode);
                    //if (state == OperatorState.empty)
                    //{
                    //    ar.state = ResultType.error.ToString();
                    //    ar.message = "提交的数据为空,添加新纪录失败";
                    //}
                    //else if (state == OperatorState.error)
                    //{
                    //    ar.state = ResultType.error.ToString();
                    //    ar.message = "添加新纪录失败";
                    //}
                    //else if (state == OperatorState.success)
                    //{
                    //    //ar.state = ResultType.success.ToString();
                    //    //ar.message = "添加新纪录成功";
                    //}
                    #endregion

                    using (var db = new DCSDBContext())
                    {
                        #region 开始一个事务
                        using (var trans = db.Database.BeginTransaction())
                        {
                            try
                            {
                                InformationModel.InsertMember = InformationModel.UsageMember = currentUser.Account;
                                InformationModel.State        = (int)InformatinState.UnAssigned;
                                InformationModel.InsertTime   = DateTime.Now;
                                InformationModel.UpdateTime   = DateTime.Now;
                                InformationModel.CompanyCode  = currentUser.CompanyCode;
                                InformationModel.DataCode     = "DC" + currentUser.CompanyCode + TimeManager.GetTimeSpan() + RandomManager.GenerateRandom(5);

                                db.Informations.Add(InformationModel);

                                List <CustomItem> customItemList = new List <CustomItem>();
                                _customItemBLL.GetCustomItems(currentUser.Account, ref customItemList);

                                foreach (var item in customItemList)
                                {
                                    var             cm = CustomItemModel.Where(n => n.name == item.ItemName).SingleOrDefault();
                                    CustomItemValue cv = new CustomItemValue();

                                    cv.InforId      = InformationModel.Id;
                                    cv.InsertTime   = cv.UpdateTime = DateTime.Now;
                                    cv.IsDeleted    = false;
                                    cv.ItemValue    = cm.value ?? "";
                                    cv.CustomItemId = item.Id;
                                    cv.ItemName     = item.ItemName;

                                    db.CustomItemValues.Add(cv);
                                }

                                db.SaveChanges();

                                // 修改用户的以收集数据的数量  + 1
                                currentUser.Cocount += 1;
                                db.Set <Member>().Attach(currentUser);
                                db.Entry(currentUser).State = System.Data.Entity.EntityState.Modified;

                                db.SaveChanges();

                                trans.Commit();

                                ar.state   = ResultType.success.ToString();
                                ar.message = "添加成功";
                            }
                            catch (Exception ex)
                            {
                                LogHelper.writeLog_error(ex.Message);
                                LogHelper.writeLog_error(ex.StackTrace);

                                trans.Rollback();
                                ar.state   = ResultType.error.ToString();
                                ar.message = "添加失败,数据已回滚";
                            }
                        }
                        #endregion
                    }
                }
                else
                {
                    ar.state   = ResultType.error.ToString();
                    ar.message = "已存在相同记录,添加新纪录失败";
                }
            }
            catch (Exception ex)
            {
                LogHelper.writeLog_error(ex.Message);
                LogHelper.writeLog_error(ex.StackTrace);

                ar.state   = ResultType.error.ToString();
                ar.message = "系统错误,添加新纪录失败";
            }
            return(Json(ar, JsonRequestBehavior.AllowGet));
        }
        private string GetWeChatUserID(ActionExecutingContext filterContext)
        {
            //var objLoginInfo = Session["UserInfo"] as WechatUser;

            //LogManager.GetLogger(this.GetType()).Debug("objLoginInfo : " + (objLoginInfo == null?"NULL":objLoginInfo.WeChatUserID));
            ////判断用户是否为空
            //if (objLoginInfo == null)

            //LogManager.GetLogger(this.GetType()).Debug("objLoginInfo is null");

            //判断是否已经登陆
            var User = GetLoginUserInfo();

            if (!string.IsNullOrEmpty(User) && (objLoginInfo.Id > 0 || Request["_Callback"] == "1" || Request.Url.AbsoluteUri.Contains("_Callback=1")) /*防止死循环*/)
            {
                return(User);
            }


            string strToUrl = Request.RawUrl.Replace(":5001", ""); //处理反向代理

            Session["ReturnUrl"] = strToUrl;                       // Request.Url.ToString();
            var    weChatConfig = WeChatCommonService.GetWeChatConfigByID(AppId);
            string strUrl;

            string strRet     = CommonService.GetSysConfig("UserBackUrl", "");
            string webUrl     = CommonService.GetSysConfig("WeChatUrl", "");
            string strBackUrl = string.Format("{0}{1}?wechatid={2}", webUrl, strRet.Trim('/'), AppId);

            log.Debug("UrlStart :" + strBackUrl);



            //服务号
            if (weChatConfig.IsCorp.HasValue && !weChatConfig.IsCorp.Value)
            {
                strUrl = Innocellence.Weixin.MP.AdvancedAPIs.OAuthApi.GetAuthorizeUrl(weChatConfig.WeixinCorpId, strBackUrl, Guid.NewGuid().ToString(), Weixin.MP.OAuthScope.snsapi_base);
            }
            else //企业号
            {
                //string strRet = WebConfigurationManager.AppSettings["UserBackUrl"];
                //string webUrl = CommonService.GetSysConfig("WeChatUrl", "");

                // string strBackUrl = string.Format("{0}{1}?wechatid={2}", webUrl, strRet, AppId);

                //log.Debug("UrlStart :" + strBackUrl);
                //strUrl = OAuth2Api.GetCode(weChatConfig.WeixinCorpId, strBackUrl, Server.UrlEncode(strToUrl));
                strUrl = OAuth2Api.GetCode(weChatConfig.WeixinCorpId, strBackUrl, Guid.NewGuid().ToString());
            }

            log.Debug(strUrl);

            if (filterContext.RequestContext.HttpContext.Request.IsAjaxRequest())
            {
                AjaxResult <int> result = new AjaxResult <int>();
                result.Message       = new JsonMessage((int)HttpStatusCode.Unauthorized, strUrl);
                filterContext.Result = Json(result, JsonRequestBehavior.AllowGet);
            }
            else
            {
                log.Debug("filterContext.Result : " + strUrl);
                filterContext.Result = new RedirectResult(strUrl);
            }

            //if (null != filterContext.ActionDescriptor && "WxDetail".Equals(filterContext.ActionDescriptor.ActionName, StringComparison.OrdinalIgnoreCase))
            //{
            //    backRedirectUrl = strUrl;
            //    log.Debug("backRedirectUrl : " + backRedirectUrl);
            //}
            return(string.Empty);
        }
Esempio n. 59
0
        public static AjaxResult AddRentRecord(string name, string idcard)
        {
            string sql = "select * from rent_rentattribute where (('" + DateTime.Now + "'>=RRAStartDate and '" + DateTime.Now.ToString() + "'< RRAEndDate)" +
                         " or ('" + DateTime.Now.AddDays(4).ToString() + "'>RRAStartDate and '" + DateTime.Now.AddDays(4).ToString() + "'<=RRAEndDate) or ('" + DateTime.Now.ToString() + "'<RRAStartDate and '" + DateTime.Now.AddDays(4).ToString() + "'>RRAEndDate)) and rrastatus not in ('5','7','8','9') order by RRACreatedDate desc";
            DataTable dt1 = MySQLHelper.ExecuteDataset(MySQLHelper.SqlConnString, MySQLHelper.CreateCommand(sql)).Tables[0];

            Dictionary <string, string> used = new Dictionary <string, string>();
            Dictionary <string, string> all  = new Dictionary <string, string>();
            Dictionary <string, string> left = new Dictionary <string, string>();

            foreach (DataRow r in dt1.Rows)
            {
                used.Add(r["rraId"].ToString(), r["RentNO"].ToString());
            }

            sql = "select * from v_RentDetail_view where RIDCard=(select idcard from CF_User where LoginName='" + LigerRM.Common.SysContext.CurrentUserName + "')";
            DataTable dt = DB.ExecuteDataSet(sql).Tables[0];

            foreach (DataRow r in dt.Rows)
            {
                all.Add(r["rid"].ToString(), r["RentNO"].ToString());
            }

            foreach (KeyValuePair <string, string> p in all)
            {
                if (!used.Values.Contains(p.Value))
                {
                    left.Add(p.Key, p.Value);
                }
            }

            string rentNo = string.Empty;

            if (left.Count == 0)
            {
                Random ran   = new Random(1);
                int    index = ran.Next(0, all.Count);
                rentNo = dt.Rows[index]["RentNO"].ToString();
            }
            else
            {
                Random ran   = new Random(1);
                int    index = ran.Next(0, left.Count);
                rentNo = left.Values.ToList()[index];
            }
            RentInfo rentInfo = new RentInfo(rentNo);
            //租户身份扫描

            RentAttributeHelper rentAttributeHelper = new RentAttributeHelper();

            RentAttribute rentAttribute = new RentAttribute(rentInfo.RentNo);

            rentAttribute.RentNo             = rentInfo.RentNo;
            rentAttribute.RRAContactName     = name;
            rentAttribute.RRAContactTel      = string.Empty;
            rentAttribute.RRANationName      = string.Empty;
            rentAttribute.RRAIDCard          = idcard;
            rentAttribute.RRentPrice         = Convert.ToDecimal(rentInfo.RLocationDescription);
            rentAttribute.RRAContactProvince = string.Empty;
            rentAttribute.RRAStartDate       = DateTime.Now;
            rentAttribute.RRAEndDate         = DateTime.Now.AddDays(4);
            rentAttribute.RRADescription     = string.Empty;
            rentAttribute.Status             = ((int)RentAttributeHelper.AttributeStatus.Complete).ToString();
            rentAttribute.RRACreatedBy       = SysContext.CurrentUserName;
            rentAttribute.RRACreatedDate     = System.DateTime.Now;
            RentAttributeHelper helper = new RentAttributeHelper();
            string number = helper.AddRentAttribute(rentAttribute);

            //写入华泽数据
            helper.UploadDataToHZ(number, rentInfo.RentNo);
            return(AjaxResult.Success());
        }
Esempio n. 60
0
 public BaseContoller()
 {
     _ajaxResult = new AjaxResult();
 }