public override void OnActionExecuted(ActionExecutedContext filterContext) { var actionName = filterContext.ActionDescriptor.ActionName; if (actionName.ToLower().Contains("update") || actionName.ToLower().Contains("insert") || actionName.ToLower().Contains("delete") || actionName.ToLower().Contains("remove") || actionName.ToLower().Contains("add") || actionName.ToLower().Contains("eidt") || actionName.ToLower().Contains("synchron")) { //get the ClientCookies; var cookis = filterContext.HttpContext.Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; if (String.IsNullOrEmpty(cookis)) { filterContext.HttpContext.Response.Redirect("~/Login/Index"); return; } var serializer = new JavaScriptSerializer(); var decCookies = CryptTools.Decrypt(cookis); var curUserInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model; IDictionary <string, string> ls = new Dictionary <string, string>(); if (curUserInfo != null) { ls.Add("User_Account", curUserInfo.User_Account); ls.Add("Display_Name", curUserInfo.Display_Name); } ls.Add("Model_Name", filterContext.ActionDescriptor.ControllerDescriptor.ControllerName); ls.Add("Action_Name", filterContext.ActionDescriptor.ActionName); ls.Add("IP_Address", filterContext.HttpContext.Request.UserHostAddress); ls.Add("Operating_Date", filterContext.HttpContext.Timestamp.ToString("yyyy-MM-dd HH:mm:ss")); NBCMSLoggerManager.NBCMSLogger("Operating", "", ls); } base.OnActionExecuted(filterContext); }
/// <summary> /// 更新HMNUMCosting的信息,用于HMNUM Management页面的的inline-edit的编辑更新 /// 需要注意的是每一次的跟新都将在库表新增一条价格信息,影响将来报表的生成。 /// CreateDate:2013年11月13日6:00:34 /// </summary> /// <param name="model"></param> /// <param name="costing"></param> /// <returns></returns> public ActionResult EditHMNUMCosting(CMS_HMNUM_Model model, CMS_HM_Costing_Model costing) { try { string cookis = Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; var serializer = new JavaScriptSerializer(); string decCookies = CryptTools.Decrypt(cookis); User_Profile_Model curUserInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model; HMNUMServices hSvr = new HMNUMServices(); Boolean isCreated = hSvr.EditHMNUMCosting(model, costing, curUserInfo.User_Account); return(Json(new NBCMSResultJson { Status = isCreated == true ? StatusType.OK : StatusType.Error, Data = isCreated == true ? "Done" : "Fail to udate current HM#'s costing" })); } catch (Exception ex) { NBCMSLoggerManager.Error(""); NBCMSLoggerManager.Error(ex.Message); NBCMSLoggerManager.Error(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
/// <summary> /// Get Role List by User /// </summary> /// <returns></returns> public ActionResult GetRoleInUser(String user_guid) { try { if (string.IsNullOrEmpty(user_guid)) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request is illegal!" })); } var cookis = Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; var serializer = new JavaScriptSerializer(); var decCookies = CryptTools.Decrypt(cookis); var curUserInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model; var uiSvr = new UserInfoServices(); var list = uiSvr.GetAllRolesWithUser(new Guid(user_guid)); return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = list })); } catch (Exception ex) { NBCMSLoggerManager.Fatal(ex.Message); NBCMSLoggerManager.Fatal(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { if (bindingContext.Model != null) { throw new InvalidOperationException("Cannot update instances"); } var reqDecCookies = controllerContext.HttpContext.Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; //if (reqDecCookies.Trim() == string.Empty) reqDecCookies is null, Trim() will trigger null reference object! 2014年5月20日 if (string.IsNullOrEmpty(reqDecCookies)) { //执行的顺序是: IModelerBinder-->Filter-->controller,action.所以直接返回null可以的 //controllerContext.HttpContext.Response.Redirect("~/Login/Index"); return(null); } var serializer = new JavaScriptSerializer(); var decCookies = CryptTools.Decrypt(reqDecCookies); var userCache = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model; //if (userCache == null) //{ // //controllerContext.HttpContext.Response.Redirect("~/Login/Index"); // return null; //} //return userCache; return(userCache ?? null); }
public ProductInfo GetLicenseInfo() { var licenseFilePath = Path.Combine(AppContext.BaseDirectory, @"License"); if (!File.Exists(licenseFilePath)) { throw new LicenseException(StringLocal.Format("License file not found or no license.")); } ProductInfo productInfo; try { var fileInfo = File.ReadAllText(licenseFilePath); productInfo = JsonHelper.DeserializeObject <ProductInfo>(CryptTools.Decrypt(fileInfo, LicenseManager.Secret)); } catch (Exception) { throw new LicenseException(StringLocal.Format("License file not found or no license.")); } if (string.IsNullOrEmpty(productInfo.MainBoardSerialNumber)) { throw new LicenseException(StringLocal.Format("Main board serial number is null or empty.")); } return(productInfo); }
/// <summary> /// Change1:新增重复插入判断(ChannleName).2014年2月20日 /// </summary> /// <param name="model"></param> /// <returns></returns> public ActionResult AddChannel(Channel_Model model) { try { if (model == null) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request is illegal!" })); } var cookis = Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; var serializer = new JavaScriptSerializer(); var decCookies = CryptTools.Decrypt(cookis); var curUserInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model; var cis = new ChannelInfoServices(); //if(curUserInfo==null) //{ // return Json(new NBCMSResultJson // { // Status = StatusType.Exception, // Data = "aa" // }); //} var msg = string.Empty; if (cis.AddChannel(model, curUserInfo.User_Account, ref msg)) { return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "Successfully add Channel" })); } else { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = msg == string.Empty ? "faile to add new Channel" : msg })); } } catch (Exception ex) { NBCMSLoggerManager.Fatal(ex.Message); NBCMSLoggerManager.Fatal(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
public ActionResult DeleteRole(Security_Role_Model model) { try { if (model == null) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request is illegal!" })); } if (model.Role_GUID == null) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request paramter is null!" })); } string cookis = Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; var serializer = new JavaScriptSerializer(); string decCookies = CryptTools.Decrypt(cookis); User_Profile_Model curUserInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model; RoleInfoServices uiSvr = new RoleInfoServices(); if (uiSvr.DeleteRole(model)) { return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "Successfully delete role" })); } else { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "faile to delete role" })); } } catch (Exception ex) { NBCMSLoggerManager.Fatal(ex.Message); NBCMSLoggerManager.Fatal(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
private IdentityUser GetCurrentIdentityUser() { // 获取验证票 var ticket = HttpContext.Current.User.Identity.Name; var decryptTicket = ""; try { // 解密后的验证票 decryptTicket = CryptTools.Decrypt(ticket, Secret); } catch (ArgumentException ex) { //throw new BusinessException("无效的用户凭证"); SignOut(); RedirectLogin(); } var userContent = decryptTicket.Split('|'); if (userContent.Count() <= 0 || userContent.Count() != 2) { // throw new BusinessException("无效的用户凭证"); SignOut(); RedirectLogin(); } var userRole = (UserLoginRole)Enum.Parse(typeof(UserLoginRole), userContent[1]); /*if (userRole == UserLoginRole.Admin) * { * throw new BusinessException("暂不支持管理员凭证"); * * }*/ if (userRole == UserLoginRole.User || userRole == UserLoginRole.Admin) { // 用户 var userId = int.Parse(userContent[0]); return(UserRepository.FindAll().Where(m => m.Id == userId). Select(user => new IdentityUser { CreateDate = user.CreateDate, ID = user.Id, RealName = user.RealName, UserName = user.UserName, Domain = user.Domain, BlogDesc = user.BlogDesc, BlogName = user.BlogName, UserLoginRole = GetUserLoginRole(user.UserRole) }).FirstOrDefault()); } SignOut(); throw new BusinessException("无效的用户凭证"); }
/// <summary> /// Add New User /// </summary> /// <param name="model"></param> /// <returns></returns> public ActionResult AddUser(User_Profile_Model model) { try { if (model == null) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request is illegal!" })); } if (model.User_Account == null) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request paramter is null!" })); } var cookis = Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; var serializer = new JavaScriptSerializer(); var decCookies = CryptTools.Decrypt(cookis); var curUserInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model; var uiSvr = new UserInfoServices(); //user is exiting if (uiSvr.IsExistUser(model.User_Account)) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "user account is exiting" })); } if (uiSvr.AddUser(model, curUserInfo.User_Account)) { return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "Successfully add user" })); } return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "faile to add new user" })); } catch (Exception ex) { NBCMSLoggerManager.Fatal(ex.Message); NBCMSLoggerManager.Fatal(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
//public void SendToEcomByModel(CMS_SKU_Model SKUModel) //{ // string Send2eComPath = ""; // var imageName = ""; // var ImageStoragePath = System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["ImageStoragePath"]); // if (SKUModel.pMedia != null) // { // imageName = SKUModel.pMedia.HMNUM + "\\" + SKUModel.pMedia.ImgName + SKUModel.pMedia.fileFormat; // Send2eComPath = Path.Combine(ImageStoragePath, imageName); // } // SKUModel.Send2eComPath = Send2eComPath; // new ICMSECOM.BLL.Insert2EComServices().Processing(SKUModel); //} /// <summary> /// 根据传递进来的Cookie的字符串解析成强类型返回。 /// 不移动到BLL层的原因之一是 JavaScriptSerializer 是在Syetm.web这个命名空间下... /// CreateDate:2014年3月19日. /// </summary> /// <param name="cookie"></param> /// <returns></returns> public User_Profile_Model GetCurrentUserbyCookie(string cookie) { var serializer = new JavaScriptSerializer(); var decCookies = CryptTools.Decrypt(cookie); var useInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model ?? new User_Profile_Model { User_Account = "unknow" }; return(useInfo); }
public ActionResult UpdateRoleInUser(String User_Guid) { try { var sRoleses = Request["ArrRoles[]"]; if (string.IsNullOrEmpty(User_Guid)) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request is illegal!" })); } var cookis = Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; var serializer = new JavaScriptSerializer(); var decCookies = CryptTools.Decrypt(cookis); var rSvr = new RoleInfoServices(); if (sRoleses == null) { if (rSvr.DeleteAllRoleByUser(new Guid(User_Guid))) { return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "Successfully update user's role" })); } return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "faile to update user's role" })); } var arrRoles = sRoleses.Split(','); if (rSvr.UpdateRoleInUser(arrRoles, new Guid(User_Guid))) { return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "Successfully update user's role" })); } return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "faile to update user's role" })); } catch (Exception ex) { NBCMSLoggerManager.Fatal(ex.Message); NBCMSLoggerManager.Fatal(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
// private static Logger log = LogManager.GetCurrentClassLogger(); /// <summary> /// User Management Model /// </summary> /// <returns></returns> public ActionResult UserManagement() { var cookis = Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; var serializer = new JavaScriptSerializer(); var decCookies = CryptTools.Decrypt(cookis); var curUserInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model; ViewBag.AllUserStatus = serializer.Serialize(new UserInfoServices().GetAllUserStatus()); //通过ViewBag动态获取Channnel列表数据 2013年10月31日16:12:53 Lee ViewBag.ChannelList = serializer.Serialize(new ProductCommonServices().GetAllChannels(curUserInfo != null && curUserInfo.IsChannelControl, curUserInfo.User_Guid)); return(View()); }
/// <summary> /// 触发CMS和WebPO的账号进行数据同步。由于一开始CMS设置了自己的用户信息,并且使用GUID进行关联。 /// 后来要求用户统一在WEBPO进行设置,而WebPO采用自增长而非GUID的方式记录数据。因此需要采取一种 /// 同步机制而不是简单的View视图关联.... /// /// Author:Lee Date:2013年10月22日11:56:03 /// </summary> /// <returns></returns> public ActionResult UserSynchWithWebPo() { try { var cookis = Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; var serializer = new JavaScriptSerializer(); var decCookies = CryptTools.Decrypt(cookis); var curUserInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model; var uSvr = new UserInfoServices(); var affectedRows = 0; if (curUserInfo != null) { uSvr.UserSynchWithWebPO(curUserInfo.User_Account, out affectedRows); } return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "Synchronizing Successfully" })); //if (retVal > 0) //{ // return Json(new NBCMSResultJson // { // Status = StatusType.OK, // Data = "Synchronizing Successfully" // }); //} //else //{ // return Json(new NBCMSResultJson // { // Status = StatusType.Error, // Data = "There is no data need to synchronizes" // }); //} } catch (Exception ex)//如果存储过程内部发生错,就跳到这里来了。。。。无数据返回-1 { NBCMSLoggerManager.Fatal(ex.Message); NBCMSLoggerManager.Fatal(ex.StackTrace); NBCMSLoggerManager.Fatal(ex.Source); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
public ActionResult UpdateMenu(Menu_Resource_Model model) { try { if (model == null) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request is illegal!" })); } if (model.MR_ID == 0) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request paramter is null!" })); } string cookis = Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; var serializer = new JavaScriptSerializer(); string decCookies = CryptTools.Decrypt(cookis); User_Profile_Model curUserInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model; MenuServices mns = new MenuServices(); if (mns.EditMenu(model, curUserInfo.User_Account)) { return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "Successfully edit menu" })); } else { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "faile to edit menu" })); } } catch (Exception ex) { NBCMSLoggerManager.Fatal(ex.Message); NBCMSLoggerManager.Fatal(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
public override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); //return; //拿到当前请求的URL地址 var requestUrl = filterContext.HttpContext.Request.Path; //对Login页面不做过滤,不能用StartWith,如果设置为二级目录,//localhost:1234/CMS/Login/Index,这时候就彻底悲剧了! //if (requestUrl.StartsWith("/Login/", StringComparison.InvariantCultureIgnoreCase)) if (requestUrl.ToUpper().Contains("/LOGIN/")) { return; } //get the ClientCookies; /*Login的时候出现Network error错误是因为这里coolis获取到有值,而页面恰好处于/CMS/这样的请求中...解决方法:全部关闭Browser再登陆OK * 2013年10月15日12:56:38 Lee */ var cookis = filterContext.HttpContext.Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; if (String.IsNullOrEmpty(cookis)) { filterContext.HttpContext.Response.Redirect("~/Login/Index"); return; } //如果是默认的地址,强制转向Main页面,原因是为了seajs的客户端“./”需要明确的获取到当前的controller/action,否则会报错 if (String.CompareOrdinal(requestUrl, "/") == 0 && !String.IsNullOrEmpty(cookis)) { filterContext.HttpContext.Response.Redirect("~/Main/Index"); return; } var serializer = new JavaScriptSerializer(); var decCookies = CryptTools.Decrypt(cookis); var curUserInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model; // curUserInfo = filterContext.HttpContext.Session["userInfo"] as User_Profile_Model; if (curUserInfo == null) { filterContext.HttpContext.Response.Redirect("~/Login/Index"); return; } base.OnActionExecuting(filterContext); }
public ActionResult EditBrand(Brands_Info_Model model) { try { if (model == null) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request is illegal!" })); } var cookis = Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; var serializer = new JavaScriptSerializer(); var decCookies = CryptTools.Decrypt(cookis); var curUserInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model; var bis = new BrandInfoServices(); var msg = string.Empty; if (curUserInfo != null && bis.EditBrand(model, curUserInfo.User_Account, ref msg)) { return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "Successfully edit brand" })); } return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = msg == string.Empty ? "faile to add new brand" : msg })); } catch (Exception ex) { NBCMSLoggerManager.Fatal(ex.Message); NBCMSLoggerManager.Fatal(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
/// <summary> /// Delete a user by guid /// </summary> /// <param name="model"></param> /// <returns></returns> public ActionResult DeleteUser(User_Profile_Model model) { try { if (model == null) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request is illegal!" })); } var cookis = Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; var serializer = new JavaScriptSerializer(); var decCookies = CryptTools.Decrypt(cookis); var uiSvr = new UserInfoServices(); if (uiSvr.DeleteUser(model)) { return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "Successfully delete user" })); } else { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "faile to delete user" })); } } catch (Exception ex) { NBCMSLoggerManager.Fatal(ex.Message); NBCMSLoggerManager.Fatal(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
/// <summary> /// 在服务器端接受到客户端消息派发之前截获,做安全性验证之类的处理 /// </summary> /// <param name="reply"></param> /// <param name="correlationState"></param> object IDispatchMessageInspector.AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, IClientChannel channel, InstanceContext instanceContext) { string userName, passWord, isLocal; userName = GetHeadContent("UserName"); passWord = GetHeadContent("Password"); isLocal = GetHeadContent("IsLocal"); //LocalCall if (isLocal == "YES") { return(null); } string[] strs = request.Headers.Action.Split('/'); string requestMethod = strs[strs.Length - 1]; //当请求为如下方法时,不预先截获消息进行验证 if (requestMethod.ToLower() == "loginin") { return(null); } if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(passWord)) { throw new ArgumentNullException(); } //解密用户信息 userName = CryptTools.Decrypt(userName, CryptConstants.PassKey); //验证用户信息 //string message; //SupplierUser user = SupplierUser.Sign(userName, passWord, out message); //if (user == null) // throw new System.Exception(message); return(null); }
public ActionResult UserLogout() { try { string cookiName = ConfigurationManager.AppSettings["userInfoCookiesKey"]; string cookis = Request[cookiName]; var serializer = new JavaScriptSerializer(); string decCookies = CryptTools.Decrypt(cookis); User_Profile_Model userInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model; UserInfoServices userInfoSvr = new UserInfoServices(); //userInfoSvr.UpdateUserStats("1", userInfo.User_Account); //remove方法只是不让服务器向客户机发送那个被删除的cookie,与此cookie留不留在客户机里无关 Response.Cookies.Remove(cookiName); Response.Cookies[cookiName].Expires = DateTime.Now.AddDays(-1); //FormsAuthentication.SignOut(); // HttpContext.Response.Redirect("~/Login/Index"); return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "User Logout successfully!" })); } catch (Exception ex) { NBCMSLoggerManager.Error(ex.Message); NBCMSLoggerManager.Error(ex.Source); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
public void GenernateLicenseWithRegister() { var registerFilePath = Path.Combine(AppContext.BaseDirectory, @"Register"); if (!File.Exists(registerFilePath)) { throw new LicenseException(StringLocal.Format("Register file not found.")); } ProductInfo productInfo; try { var fileInfo = File.ReadAllText(registerFilePath); productInfo = JsonHelper.DeserializeObject <ProductInfo>(CryptTools.Decrypt(fileInfo, LicenseManager.SecretRegister)); } catch (Exception) { throw new LicenseException(StringLocal.Format("License file not found or no license.")); } CryptTools.Encrypt(JsonHelper.SerializeObject(productInfo), LicenseManager.SecretRegister); var licenseFilePath = Path.Combine(AppContext.BaseDirectory, @"License"); File.WriteAllText(licenseFilePath, CryptTools.Encrypt(JsonHelper.SerializeObject(productInfo), LicenseManager.Secret)); }
/// <summary> /// 目前都是用这个方法. /// Change1:新增从SKUOrder页面上传之后,需要做的相关逻辑的操作(关联当前SKU)2014年1月24日16:05:24 /// </summary> /// <param name="context"></param> /// <param name="statuses"></param> private void UploadWholeFile(HttpContext context, List <FilesStatus> statuses) { Image imgInfo = null; try { string cookis = context.Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; var serializer = new JavaScriptSerializer(); string decCookies = CryptTools.Decrypt(cookis); User_Profile_Model userInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model; MediaServices mSvr = new MediaServices(); var ProductID = context.Request.Form["ProductID"]; //根据HMNUM拼凑当前需要存储的文件夹路径 var HMNUM = context.Request.Form["HMNUM"]; var curStorageRoot = Path.Combine(StorageRoot, HMNUM) + "/";//当前HM#图像的存储总地址 // ReqIndicator, 0:默认,1:HMNUM页面 2:SKUOrdr页面 var strIndicator = context.Request.Form["ReqIndicator"]; int ReqIndicator = 0; int.TryParse(strIndicator, out ReqIndicator); long SKUID = 0; if (ReqIndicator == 2) { var strWPID = context.Request.Form["SKUID"]; long.TryParse(strWPID, out SKUID); } //如果这些路径不存在,则创建之。 if (!Directory.Exists(curStorageRoot)) { Directory.CreateDirectory(curStorageRoot); } for (int i = 0; i < context.Request.Files.Count; i++) { var file = context.Request.Files[i]; var SerialNum = context.Request.Form["SerialNum"].Split(',')[i]; //用户标识当前HM关联图像的序列值,给前端重命名的时候使用! var imgSize = context.Request.Form["imgSize"].Split(',')[i]; //该图像多大,比如100MB var rename = context.Request["rename"].Split(',')[i]; //获取客户端重命名的名称 var extension = Path.GetExtension(file.FileName); //获取图像扩展名 var fullPath = curStorageRoot + rename + extension; var thumbPath = curStorageRoot + rename + "_th" + extension; file.SaveAs(fullPath); // SendSmallImage(fullPath, thumbPath, 160); SamllImageGengeratedFixedHW(fullPath, thumbPath, 200, 200); //Save image infor to database imgInfo = Image.FromFile(fullPath); long newID = 0; var newMedia = new MediaLibrary_Model { ProductID = Convert.ToInt64(ProductID), HMNUM = HMNUM, SerialNum = Convert.ToInt32(SerialNum), ImgName = rename, MediaType = 1, fileFormat = extension, fileSize = imgSize, fileWidth = imgInfo.Width, fileHeight = imgInfo.Height, Description = "" }; if (ReqIndicator == 2) { mSvr.addMediaLibraryWithSKURelation(newMedia, userInfo.User_Account, SKUID, out newID); } else { mSvr.addMediaLibrary(newMedia, userInfo.User_Account, out newID); } imgInfo.Dispose(); //string fullName = Path.GetFileName(file.FileName); //备注:newID即指 新增的MediaID statuses.Add(new FilesStatus(rename + extension, file.ContentLength, fullPath, newID, HMNUM)); } } catch (Exception ex) { if (imgInfo != null) { imgInfo.Dispose(); } NBCMSLoggerManager.Error("UploadWholeFile"); NBCMSLoggerManager.Error(ex.Message); NBCMSLoggerManager.Error(ex.StackTrace); NBCMSLoggerManager.Error(ex.Source); } }
public ActionResult AddRole(Security_Role_Model model) { try { if (model == null) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request is illegal!" })); } if (model.Role_Name == null) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Role Name cannot be empty!" })); } string cookis = Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; var serializer = new JavaScriptSerializer(); string decCookies = CryptTools.Decrypt(cookis); User_Profile_Model curUserInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model; RoleInfoServices iSvr = new RoleInfoServices(); //user is exiting if (iSvr.IsExistUser(model.Role_Name)) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "this role is exiting" })); } if (iSvr.AddRole(model, curUserInfo.User_Account)) { return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "Successfully add user" })); } else { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "faile to add new user" })); } } catch (Exception ex) { NBCMSLoggerManager.Fatal(ex.Message); NBCMSLoggerManager.Fatal(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
public ActionResult UserRoleUpdate(string Role_Guid) { try { string sRoleses = Request["menuGuids[]"]; if (string.IsNullOrEmpty(Role_Guid)) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request is illegal!" })); } string cookis = Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; var serializer = new JavaScriptSerializer(); string decCookies = CryptTools.Decrypt(cookis); User_Profile_Model curUserInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model; MenuServices mSvr = new MenuServices(); if (sRoleses == null) { if (mSvr.DeleteAllRoleByUser(new Guid(Role_Guid))) { return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "Successfully update user's role" })); } else { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "faile to update user's role" })); } } string[] arrRoles = sRoleses.Split(','); if (mSvr.UpdateRoleInUser(arrRoles, new Guid(Role_Guid))) { return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = "Successfully update Role's menu" })); } else { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "faile to update Role's menu" })); } } catch (Exception ex) { NBCMSLoggerManager.Fatal(ex.Message); NBCMSLoggerManager.Fatal(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }
/// <summary> /// Get data for Role Modeling to displaying Role's Menu /// </summary> /// <param name="Role_Guid">Role_Guid request from client</param> /// <returns>json:Correspond with jQuery easyUI tree-grid format (if have children, included _parentId)</returns> public ActionResult RoleMenusLoading(String Role_Guid) { try { if (string.IsNullOrEmpty(Role_Guid)) { return(Json(new NBCMSResultJson { Status = StatusType.Error, Data = "Request is illegal!" })); } string cookis = Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]; var serializer = new JavaScriptSerializer(); string decCookies = CryptTools.Decrypt(cookis); User_Profile_Model curUserInfo = serializer.Deserialize(decCookies, typeof(User_Profile_Model)) as User_Profile_Model; RoleInfoServices rSvg = new RoleInfoServices(); List <Object> result = new List <object>(); foreach (Menu_Resource_Model m in rSvg.GetAllMenusWithUser(new Guid(Role_Guid))) { if (m.ParentMenuID == "0") { result.Add(new { // icon = m.icon, MenuID = m.MenuID, ParentMenuID = m.ParentMenuID, MenuUrl = m.MenuUrl, MR_ID = m.MR_ID, //name = m.MenuName, 2014年2月8日11:54:18 name = m.name, SortNo = m.SortNo, Visible = m.Visible, Memo = m.Memo, Role_Checked = m.Role_Checked }); } else { result.Add(new { //icon = m.icon, MenuID = m.MenuID, _parentId = m.ParentMenuID,//tree-grid must have those formate... ParentMenuID = m.ParentMenuID, MenuUrl = m.MenuUrl, MR_ID = m.MR_ID, //name = m.MenuName, name = m.name, SortNo = m.SortNo, Visible = m.Visible, Memo = m.Memo, Role_Checked = m.Role_Checked }); } } return(Json(new NBCMSResultJson { Status = StatusType.OK, Data = new { total = result.Count, rows = result } })); } catch (Exception ex) { NBCMSLoggerManager.Fatal(ex.Message); NBCMSLoggerManager.Fatal(ex.StackTrace); NBCMSLoggerManager.Error(""); return(Json(new NBCMSResultJson { Status = StatusType.Exception, Data = ex.Message })); } }