Esempio n. 1
0
 public ReturnAdorner(TextBox adornedElement, ReturnValue operation)
     : base(adornedElement)
 {
     this.text.FontSize = adornedElement.FontSize * 0.80;
     this.text.Text = "return " + operation.Value;
     this.border.Child = this.text;
 }
Esempio n. 2
0
 public ReturnValue AddOrEdit(LoginUser entity)
 {
     ReturnValue retValue = new ReturnValue();
     using (LoginUserDal dal = new LoginUserDal())
     {
         if (entity.ID < 1)//添加
         {
             if (dal.Add(entity))
             {
                 retValue.IsExists = true;
                 retValue.Message = "添加用户成功";
             }
             else
             {
                 retValue.IsExists = false;
                 retValue.Message = "添加用户失败";
             }
         }
         else//修改
         {
             if (dal.Modify(entity))
             {
                 retValue.IsExists = true;
                 retValue.Message = "修改用户成功";
             }
             else
             {
                 retValue.IsExists = false;
                 retValue.Message = "修改用户失败";
             }
         }
     }
     return retValue;
 }
Esempio n. 3
0
        public ActionResult AddOrEdit()
        {
            ReturnValue retValue = new ReturnValue();

            Article entity = new Article();
            entity.ID = CodeNote.Common.ConvertWrap.ToInt(Request["articleid"]);
            entity.Subject = Request["subject"];
            entity.Body = CodeNote.Common.StringFilter.ClearHtml(Request["body"],true);
            entity.CategoryID = Request["category"];
            entity.Tag = Request["artitag"];
            entity.CreateID = CurUser.ID;
            entity.CreateDate = DateTime.Now;
            entity.ModDate = entity.CreateDate;

            retValue = ArtMg.AddOrEdit(entity);

            if (retValue.IsExists)
            {//添加标签或修改标签
                TagInfoManager tagMg = new TagInfoManager();
                Models.Constans.TagType tagType = Constans.TagType.UserTag;
                if (CurUser != null && CurUser.Type == (int)Constans.UserType.Administrators)
                {
                    tagType = Constans.TagType.SysTag;
                }
                tagMg.AddTag(entity.Tag, (int)tagType);
                CodeNote.Luc.ArtilceLuc artLuc = new Luc.ArtilceLuc();
                artLuc.ModifyIndex(retValue.Get<VwArticle>("vw"));
            }

            return View("Result", new ReturnMessage(Request, "提示消息", retValue));
        }
        public override Expression VisitReturnValue(ReturnValue returnValue)
        {
            // return a default value of the same type as the return value
            TypeNode returnType = returnValue.Type;
            ITypeParameter itp = returnType as ITypeParameter;
            if (itp != null)
            {
                Local loc = new Local(returnType);

                UnaryExpression loca = new UnaryExpression(loc, NodeType.AddressOf, loc.Type.GetReferenceType());
                StatementList statements = new StatementList(2);

                statements.Add(new AssignmentStatement(new AddressDereference(loca, returnType, false, 0),
                    new Literal(null, SystemTypes.Object)));

                statements.Add(new ExpressionStatement(loc));

                return new BlockExpression(new Block(statements), returnType);
            }

            if (returnType.IsValueType)
                return new Literal(0, returnType);
            
            return new Literal(null, returnType);
        }
Esempio n. 5
0
 public void Merge(ReturnValue returnObject)
 {
     if (returnObject != null && returnObject.Type != null)
     {
         ReturnItems.Add(returnObject.Type, returnObject.Value);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Instantiates UpdateItemRequest with the parameterized properties
 /// </summary>
 /// <param name="tableName">The name of the table containing the item to update.</param>
 /// <param name="key">The primary key of the item to be updated. Each element consists of an attribute name and a value for that attribute. For the primary key, you must provide all of the attributes. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for both the partition key and the sort key.</param>
 /// <param name="attributeUpdates"><important> This is a legacy parameter, for backward compatibility. New applications should use <i>UpdateExpression</i> instead. Do not combine legacy parameters and expression parameters in a single API call; otherwise, DynamoDB will return a <i>ValidationException</i> exception. This parameter can be used for modifying top-level attributes; however, it does not support individual list or map elements. </important> The names of attributes to be modified, the action to perform on each, and the new value for each. If you are updating an attribute that is an index key attribute for any indexes on that table, the attribute type must match the index key type defined in the <i>AttributesDefinition</i> of the table description. You can use <i>UpdateItem</i> to update any non-key attributes. Attribute values cannot be null. String and Binary type attributes must have lengths greater than zero. Set type attributes must not be empty. Requests with empty values will be rejected with a <i>ValidationException</i> exception. Each <i>AttributeUpdates</i> element consists of an attribute name to modify, along with the following: <ul> <li>  <i>Value</i> - The new value, if applicable, for this attribute. </li> <li>  <i>Action</i> - A value that specifies how to perform the update. This action is only valid for an existing attribute whose data type is Number or is a set; do not use <code>ADD</code> for other data types.  If an item with the specified primary key is found in the table, the following values perform the following actions: <ul> <li>  <code>PUT</code> - Adds the specified attribute to the item. If the attribute already exists, it is replaced by the new value.  </li> <li>  <code>DELETE</code> - Removes the attribute and its value, if no value is specified for <code>DELETE</code>. The data type of the specified value must match the existing value's data type. If a set of values is specified, then those values are subtracted from the old set. For example, if the attribute value was the set <code>[a,b,c]</code> and the <code>DELETE</code> action specifies <code>[a,c]</code>, then the final attribute value is <code>[b]</code>. Specifying an empty set is an error. </li> <li>  <code>ADD</code> - Adds the specified value to the item, if the attribute does not already exist. If the attribute does exist, then the behavior of <code>ADD</code> depends on the data type of the attribute: <ul> <li> If the existing attribute is a number, and if <i>Value</i> is also a number, then <i>Value</i> is mathematically added to the existing attribute. If <i>Value</i> is a negative number, then it is subtracted from the existing attribute. <note> If you use <code>ADD</code> to increment or decrement a number value for an item that doesn't exist before the update, DynamoDB uses 0 as the initial value. Similarly, if you use <code>ADD</code> for an existing item to increment or decrement an attribute value that doesn't exist before the update, DynamoDB uses <code>0</code> as the initial value. For example, suppose that the item you want to update doesn't have an attribute named <i>itemcount</i>, but you decide to <code>ADD</code> the number <code>3</code> to this attribute anyway. DynamoDB will create the <i>itemcount</i> attribute, set its initial value to <code>0</code>, and finally add <code>3</code> to it. The result will be a new <i>itemcount</i> attribute, with a value of <code>3</code>. </note> </li> <li> If the existing data type is a set, and if <i>Value</i> is also a set, then <i>Value</i> is appended to the existing set. For example, if the attribute value is the set <code>[1,2]</code>, and the <code>ADD</code> action specified <code>[3]</code>, then the final attribute value is <code>[1,2,3]</code>. An error occurs if an <code>ADD</code> action is specified for a set attribute and the attribute type specified does not match the existing set type.  Both sets must have the same primitive data type. For example, if the existing data type is a set of strings, <i>Value</i> must also be a set of strings. </li> </ul> </li> </ul> If no item with the specified key is found in the table, the following values perform the following actions: <ul> <li>  <code>PUT</code> - Causes DynamoDB to create a new item with the specified primary key, and then adds the attribute.  </li> <li>  <code>DELETE</code> - Nothing happens, because attributes cannot be deleted from a nonexistent item. The operation succeeds, but DynamoDB does not create a new item. </li> <li>  <code>ADD</code> - Causes DynamoDB to create an item with the supplied primary key and number (or set of numbers) for the attribute value. The only data types allowed are Number and Number Set. </li> </ul> </li> </ul> If you provide any attributes that are part of an index key, then the data types for those attributes must match those of the schema in the table's attribute definition.</param>
 /// <param name="returnValues">Use <i>ReturnValues</i> if you want to get the item attributes as they appeared either before or after they were updated. For <i>UpdateItem</i>, the valid values are: <ul> <li>  <code>NONE</code> - If <i>ReturnValues</i> is not specified, or if its value is <code>NONE</code>, then nothing is returned. (This setting is the default for <i>ReturnValues</i>.) </li> <li>  <code>ALL_OLD</code> - If <i>UpdateItem</i> overwrote an attribute name-value pair, then the content of the old item is returned. </li> <li>  <code>UPDATED_OLD</code> - The old versions of only the updated attributes are returned. </li> <li>  <code>ALL_NEW</code> - All of the attributes of the new version of the item are returned. </li> <li>  <code>UPDATED_NEW</code> - The new versions of only the updated attributes are returned. </li> </ul> There is no additional cost associated with requesting a return value aside from the small network and processing overhead of receiving a larger response. No Read Capacity Units are consumed. Values returned are strongly consistent</param>
 public UpdateItemRequest(string tableName, Dictionary<string, AttributeValue> key, Dictionary<string, AttributeValueUpdate> attributeUpdates, ReturnValue returnValues)
 {
     _tableName = tableName;
     _key = key;
     _attributeUpdates = attributeUpdates;
     _returnValues = returnValues;
 }
Esempio n. 7
0
        public ActionResult deletelab(string sn)
        {
            ReturnValue r;
            if (sn != null && sn.ToString() != "")
            {
                var guid = WebRequest.GetString("guid", true);
                Guid g = Guid.Parse(guid);
                try
                {
                    var b = diagnosticService.DeleteTestAnalysisReport(g, sn);
                    if (b != "")
                    {
                        LogHelper.Info(Masterpage.CurrUser.alias, "501027:客户," + Masterpage.CurrUser.client_code + ",删除诊断的实验分析报告,报告编号为:" + sn);
                        string path = ConfigurationManager.AppSettings["CustomerRes"] + Masterpage.CurrUser.client_code + "/files/diagnostic/" + b;
                        FileHelper.DeleteFile(path);
                        r = new ReturnValue { message = "", status = "ok" };
                    }
                    else r = new ReturnValue { message = "删除失败", status = "error" };
                }
                catch
                {
                    LogHelper.Info(Masterpage.CurrUser.alias, "501027:客户," + Masterpage.CurrUser.client_code + ",删除诊断的实验分析报告失败,缺少参数,报告编号为:" + sn);
                    r = new ReturnValue { message = "参数错误", status = "error" };
                }
            }
            else
            {
                LogHelper.Info(Masterpage.CurrUser.alias, "501027:客户," + Masterpage.CurrUser.client_code + ",删除诊断的实验分析报告失败,缺少参数,报告编号为:" + sn);
                r = new ReturnValue { message = "缺少参数", status = "error" };
            }

            return Json(r, JsonRequestBehavior.AllowGet);
        }
Esempio n. 8
0
 public ReturnValue Login(string userNameOrEmail, string password, string ip)
 {
     ReturnValue retValue = new ReturnValue();
     using (LoginUserDal dal = new LoginUserDal())
     {
         LoginUser user = dal.Get(userNameOrEmail);
         //加密比较
         if (user != null)
         {
             if (user.PassWord != password)
             {
                 retValue.IsExists = false;
                 retValue.Message = "密码输入错误";
                 return retValue;
             }
             retValue.IsExists = true;
             retValue.Message = "登录成功";
             retValue.RetObjec = user;
             //修改用登陆信息
             user.LastLoginDate = DateTime.Now;
             user.LastLoginIP = ip;
             dal.Modify(user);
         }
         else
         {
             retValue.IsExists = false;
             retValue.Message = "此用户不存在";
             return retValue;
         }
     }
     return retValue;
 }
Esempio n. 9
0
static void Main()
{
ReturnValue val = new ReturnValue(GetInteger);
Console.WriteLine(val());
AddString addstr = null;
parDel(addstr, "khan");
Console.WriteLine(parDel(addstr, "Khan"));
}
Esempio n. 10
0
 public ActionResult autopost()
 {
     ReturnValue r = new ReturnValue();
     r.status = "ok";
     r.message = SessionHelper.SessionId;
     Session["autopostsession"] = r.message;
     return Json(r, JsonRequestBehavior.AllowGet);
 }
Esempio n. 11
0
        public void Can_set_value()
        {
            var expected = DateTime.Now;

            var value = new ReturnValue();
            value.SetValue(expected);

            Assert.AreEqual(typeof (DateTime), value.Type);
            Assert.AreEqual(expected, value.Value);
        }
Esempio n. 12
0
        public void SaveVariableToMemorySpace()
        {
            MemorySpaceNodeListCache cache = new MemorySpaceNodeListCache();

            AST root = new AST();
            MemorySpace memorySpace = new MemorySpace("globals", root, new Scope(Scope.ScopeType.MAIN_SCOPE, "blah"), cache);
            ReturnValue val = new ReturnValue(5.9f);
            memorySpace.setValue("x", val);
            Assert.AreEqual(ReturnValueType.NUMBER, memorySpace.getValue("x").getReturnValueType());
            Assert.AreEqual(5.9f, memorySpace.getValue("x").NumberValue);
        }
Esempio n. 13
0
 public ActionResult delemployee()
 {
     Employee one = new Employee();
     string guid = WebRequest.GetString("guid", true);
     ReturnValue r = new ReturnValue { status = "ok" };
     Guid g = Guid.Empty;
     g = Guid.Parse(guid);
     _employeeservice.DeleteEmployee(g);
     LogHelper.BackInfo("4-3", Masterpage.AdminCurrUser.userid, "删除员工:" + g);
     return Json(r, JsonRequestBehavior.AllowGet);
 }
Esempio n. 14
0
        /// <summary>
        /// Handles the function return value.
        /// May throw Exception if the result is not Ok
        /// </summary>
        /// <param name="functionReturnValue">EDSDK function return value.</param>
        /// <exception cref="EDSDKException">if the functionReturnValue is not "Ok".</exception>
        /// <remarks></remarks>
        public static void HandleFunctionReturnValue(ReturnValue functionReturnValue)
        {
            // This is a good return value
            if (functionReturnValue == ReturnValue.Ok)
            {
                // Return and proceed
                return;
            }

            // If we end up with this section, the return value represents one of the Failure Return values.
            throw new EDSDKException(functionReturnValue);
        }
Esempio n. 15
0
        /// <summary>
        /// Handles the function return value.
        /// May throw Exception if the result is not Ok
        /// </summary>
        /// <param name="functionReturnValue">EDSDK function return value.</param>
        /// <exception cref="EDSDKException">if the functionReturnValue is not "Ok".</exception>
        /// <remarks></remarks>
        public void HandleFunctionReturnValue(ReturnValue functionReturnValue)
        {
            // This is a good return value
            if (functionReturnValue == ReturnValue.Ok || functionReturnValue == ReturnValue.DeviceBusy)
            {
                // Return and proceed
                return;
            }

            _onError(functionReturnValue);
            // If we end up with this section, the return value represents one of the Failure Return values.
            //throw new EDSDKException(functionReturnValue); //todo maybe later
        }
Esempio n. 16
0
        public ActionResult Add(string nick, string email, string body, int articleID)
        {
            Reply entity = new Reply();
            entity.ArticleID = articleID;
            entity.Body = CodeNote.Common.StringFilter.ClearHtml(body);
            entity.Nick = nick;
            entity.Email = email;
            entity.CreateDate = DateTime.Now;
            if (CurUser != null)
            {
                entity.CreateID = CurUser.ID;
            }

            ReturnValue retValue = new ReturnValue();
            retValue = this.ReplayMg.Add(entity);
            return Json(retValue);
        }
Esempio n. 17
0
        public ReturnValue Add(Reply entity)
        {
            ReturnValue retValue = new ReturnValue();
            if (entity.ArticleID < 1)
            {
                retValue.IsExists = false;
                retValue.Message = "回复对象未知";
                return retValue;
            }
            if (string.IsNullOrEmpty(entity.Nick))
            {
                retValue.IsExists = false;
                retValue.Message = "请输入昵称";
                return retValue;
            }
            if (string.IsNullOrEmpty(entity.Email))
            {
                retValue.IsExists = false;
                retValue.Message = "请输入电子邮件地址";
                return retValue;
            }
            if (string.IsNullOrEmpty(entity.Body))
            {
                retValue.IsExists = false;
                retValue.Message = "请输入回复内容";
                return retValue;
            }

            using (ReplyDal dal = new ReplyDal())
            {
                if (dal.Add(entity))
                {
                    retValue.IsExists = true;
                    retValue.Message = "回复成功";
                }
                else
                {
                    retValue.IsExists = false;
                    retValue.Message = "回复失败";
                }

            }
            return retValue;
        }
Esempio n. 18
0
        public ActionResult AddNew(T_Album iAlbum)
        {
            ReturnValue<bool> result = new ReturnValue<bool>(false, "");

            if (ModelState.IsValid)
            {
                result = _service.AddNewAlbum(iAlbum);
            }
            if (result.RetValue)
            {
                return RedirectToAction("List", "Album");
            }
            else
            {
                // Get Album_List again
                ModelState.AddModelError("Error", result.Msg);
                return View(iAlbum);
            }
        }
Esempio n. 19
0
        public ActionResult AddNew(T_Config iConfig)
        {
            ReturnValue<bool> result = new ReturnValue<bool>(false, "");

            if (ModelState.IsValid)
            {
                result = _configServices.AddNewConfig(iConfig);
            }
            if (result.RetValue)
            {
                return RedirectToAction("List", "Config");
            }
            else
            {
                // Get Config_List again
                ModelState.AddModelError("Error", result.Msg);
                return View(iConfig);
            }
        }
Esempio n. 20
0
        public ReturnValue AddOrEdit(Html html)
        {
            ReturnValue retValue = new ReturnValue();
            if (html == null || html.ArtID < 0)
            {
                retValue.IsExists = false;
                retValue.Message = "html 信息为空";
                return retValue;
            }
            Html old = this.Get(html.ArtID);

            using (HtmlDal dal = new HtmlDal())
            {
                if (old == null)
                {
                    if (dal.Add(html))
                    {
                        retValue.IsExists = true;
                        retValue.Message = "页面信息添加成功";
                    }
                    else
                    {
                        retValue.IsExists = false;
                        retValue.Message = "页面信息添加失败";
                    }
                }
                else//修改
                {
                    if (dal.Modify(html))
                    {
                        retValue.IsExists = true;
                        retValue.Message = "页面信息修改成功";
                    }
                    else
                    {
                        retValue.IsExists = false;
                        retValue.Message = "页面信息修改失败";
                    }
                }
            }
            return retValue;
        }
Esempio n. 21
0
 public ActionResult AddNew(T_Menu iMenu)
 {
     ReturnValue<bool> result = new ReturnValue<bool>(false, "");
     if (ModelState.IsValid)
     {
         iMenu.ParentPath = _menuServices.GetPath(iMenu.ParentID);
         result = _menuServices.AddNewMenu(iMenu);
     }
     if (result.RetValue)
     {
         return RedirectToAction("List", "Menu");
     }
     else
     {
         // Get Menu_List again
         ModelState.AddModelError("Error", result.Msg);
         IEnumerable<T_Menu> MenuList = _menuServices.GetAllForDisplay();
         ViewBag.ParentID = new SelectList(_menuServices.GetAllForDisplay().OrderBy(m => m.ParentPath), "Id", "Title");
         return View(iMenu);
     }
 }
Esempio n. 22
0
 /// <summary>
 /// 添加标签信息
 /// </summary>
 /// <param name="tagNamestr"></param>
 /// <param name="tagType"></param>
 /// <returns></returns>
 public ReturnValue AddTag(string tagNamestr, int tagType)
 {
     string[] tags = tagNamestr.Split(new char[] { ' ', ',', '-', ';' });
     ReturnValue retValue = new ReturnValue();
     using (TagInfoDal dal = new TagInfoDal())
     {
         foreach (string item in tags)
         {
             if (dal.AddTag(item, tagType))
             {
                 retValue.PutValue("ok", retValue.GetInt("ok") + 1);
             }
             else
             {
                 retValue.PutValue("error", retValue.GetInt("error") + 1);
             }
         }
     }
     log.Info(string.Format("Add Tags : ok {0} ,error {1}", retValue.GetInt("ok"), retValue.GetInt("error")));
     return retValue;
 }
Esempio n. 23
0
        public ActionResult AddNew(T_Adver iAdver)
        {
            // Upload the image
            HttpPostedFileBase file = Request.Files["ImageData"];
            string PathReturn = UploadAdverImage(file);
            iAdver.ImagePath = PathReturn;
            ReturnValue<bool> result = new ReturnValue<bool>(false, "");

            if (ModelState.IsValid)
            {
                result = _AdverServices.AddNewAdver(iAdver);
            }
            if (result.RetValue)
            {
                return RedirectToAction("List", "Adver");
            }
            else
            {
                // Get Adver_List again
                ModelState.AddModelError("Error", result.Msg);
                return View(iAdver);
            }
        }
Esempio n. 24
0
 public ActionResult DoLogin(string name, string password)
 {
     ReturnValue retValue = new ReturnValue();
     if (string.IsNullOrEmpty(name))
     {
         retValue.IsExists = false;
         retValue.Message = "请输入登录名";
         return View("Result", new ReturnMessage(Request, "登录消息", retValue));
     }
     if (string.IsNullOrEmpty(password))
     {
         retValue.IsExists = false;
         retValue.Message = "请输入密码";
         return View("Result", new ReturnMessage(Request, "登录消息", retValue));
     }
     retValue = LoginUserMg.Login(name, CodeNote.Common.Encryption.MD5(password), Request.UserHostAddress);
     if (retValue.IsExists)
     {
         Common.SessionWrap.Add(Web.Models.Constans.USER_SESSION_KEY, retValue.RetObjec);
         return RedirectToAction("Index", "Account");
     }
     return View("Result", new ReturnMessage(Request, "登录消息", retValue));
 }
Esempio n. 25
0
        public ActionResult AddNew(T_Slide iSlide)
        {
            // Upload the image
            HttpPostedFileBase file = Request.Files["ImageData"];
            string PathReturn = UploadSlideImage(file);
            iSlide.ImagePath = PathReturn;
            ReturnValue<bool> result = new ReturnValue<bool>(false, "");

            if (ModelState.IsValid)
            {
                result = _SlideServices.AddNewSlide(iSlide);
            }
            if (result.RetValue)
            {
                return RedirectToAction("List", "Slide");
            }
            else
            {
                SlideViewModel Model = new SlideViewModel(iSlide, _slideGroupServices.GetAll());
                // Get Slide_List again
                ModelState.AddModelError("Error", result.Msg);
                return View(Model);
            }
        }
Esempio n. 26
0
 /// <summary>
 /// Instantiates PutItemRequest with the parameterized properties
 /// </summary>
 /// <param name="tableName">The name of the table to contain the item.</param>
 /// <param name="item">A map of attribute name/value pairs, one for each attribute. Only the primary key attributes are required; you can optionally provide other attribute name-value pairs for the item. You must provide all of the attributes for the primary key. For example, with a hash type primary key, you only need to specify the hash attribute. For a hash-and-range type primary key, you must specify both the hash attribute and the range attribute. If you specify any attributes that are part of an index key, then the data types for those attributes must match those of the schema in the table's attribute definition. For more information about primary keys, see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DataModel.html#DataModelPrimaryKey">Primary Key</a> in the <i>Amazon DynamoDB Developer Guide</i>. Each element in the <i>Item</i> map is an <i>AttributeValue</i> object.</param>
 /// <param name="returnValues">Use <i>ReturnValues</i> if you want to get the item attributes as they appeared before they were updated with the <i>PutItem</i> request. For <i>PutItem</i>, the valid values are: <ul> <li> <code>NONE</code> - If <i>ReturnValues</i> is not specified, or if its value is <code>NONE</code>, then nothing is returned. (This setting is the default for <i>ReturnValues</i>.) </li> <li> <code>ALL_OLD</code> - If <i>PutItem</i> overwrote an attribute name-value pair, then the content of the old item is returned. </li> </ul></param>
 public PutItemRequest(string tableName, Dictionary<string, AttributeValue> item, ReturnValue returnValues)
 {
     _tableName = tableName;
     _item = item;
     _returnValues = returnValues;
 }
Esempio n. 27
0
        public JsonResult DoEdit()
        {
            Entity.Category entity = new Entity.Category();
            entity.ParentID = Request["parentid"];
            entity.CategoryID = Request["categoryID"];
            if (entity.ParentID == entity.CategoryID)
            {
                entity.ParentID = "0";
            }
            if (entity.ParentID.Length == entity.CategoryID.Length)
            {
                entity.ParentID = entity.CategoryID.Substring(entity.CategoryID.IndexOf("-"));
            }

            entity.Name = Request["name"];
            entity.Title = Request["title"];
            entity.Count = 0;
            entity.Status = 0;
            entity.IsHot = false;
            entity.CreateDate = DateTime.Now;
            entity.CreateID = this.CurUser.ID;

            ReturnValue retValue = new ReturnValue();
            retValue = this.CategoryMg.AddOrEdit(entity);
            return Json(retValue);
        }
Esempio n. 28
0
 /// <summary>
 /// 删除分类信息
 /// </summary>
 /// <param name="ids"></param>
 /// <returns></returns>
 public JsonResult DelCategory(string ids)
 {
     ReturnValue retValue = new ReturnValue();
     retValue = CategoryMg.Delete(ids);
     return Json(retValue);
 }
Esempio n. 29
0
        public static ReturnValue login(double userId, int hour)
        {
            string      ip   = Tools.IPToNumber("127.0.0.1").ToString();//  Tools.IPToNumber(M5.PageContext.Current.Request.UserHostAddress).ToString();
            ReturnValue err  = new ReturnValue();
            UserInfo    info = UserClass.get(userId);

            /*if (!info.ipAccess(M5.PageContext.Current.Request.UserHostAddress))
             * {
             *  err.errNo = -1;
             *  err.errMsg = "您的ip不能登陆";
             *  return err;
             * }*/
            err.errNo = 0;
            //添加登陆信息
            //添加登陆日志
            string sessionId = (M5.PageContext.Current.Request.Cookies["M5_SessionId"] == null) ? "" : M5.PageContext.Current.Request.Cookies["M5_SessionId"];

            if (sessionId == "")
            {
                sessionId = Tools.GetId();
                M5.PageContext.Current.Response.Cookies.Append("M5_SessionId", sessionId);
            }
            Sql.ExecuteNonQuery("update m_admin set loginDateTime=loginDateTime where id=@id", new MySqlParameter[] {
                new MySqlParameter("id", userId),
                new MySqlParameter("loginDateTime", DateTime.Now),
            });
            Sql.ExecuteNonQuery("delete from logininfo where logindate<@logindate or sessionId=@sessionId", new MySqlParameter[] {
                new MySqlParameter("sessionId", sessionId),
                new MySqlParameter("logindate", DateTime.Now.AddHours(-1)),
            });        //删除超时用户及重登陆用户
            Sql.ExecuteNonQuery("insert logininfo (sessionId,ip,logindate,userid)values(@sessionId,@ip,@logindate,@userId)",
                                new MySqlParameter[] {
                new MySqlParameter("sessionId", sessionId),
                new MySqlParameter("ip", ip),
                new MySqlParameter("userId", userId),
                new MySqlParameter("logindate", DateTime.Now),
            });
            err.userData = info;
            if (info.classId == 0)
            {
                M5.PageContext.Current.Response.Cookies.Append("M5_Login", "true");
            }
            else
            {
                M5.PageContext.Current.Response.Cookies.Append("M5_Login", "");
            }
            M5.PageContext.Current.Response.Cookies.Append("u_name", HttpUtility.UrlEncode(info.username));
            M5.PageContext.Current.Response.Cookies.Append("u_id", info.id.ToString());

            /*HttpCookie cook = new HttpCookie("u_name");
             * if (hour > 0) cook.Expires = System.DateTime.Now.AddHours(hour);
             * cook.Value = HttpUtility.UrlEncode(info.username);
             * PageContext.Current.Response.Cookies.Add(cook);
             * cook = new HttpCookie("u_id");
             * if (hour > 0) cook.Expires = System.DateTime.Now.AddHours(hour);
             * cook.Value = info.id.ToString();
             * PageContext.Current.Response.Cookies.Add(cook);*/

            //PageContext.Current.Response.Cookies["u_name"].Value = HttpUtility.UrlEncode(info.username);
            //PageContext.Current.Response.Cookies["u_id"].Value = info.id.ToString();
            Tools.writeLog("login", info.username + "登陆成功");
            return(err);
        }
Esempio n. 30
0
        public static ReturnValue manageLogin(string uname, string pword, int hour)
        {
            string          ip     = "0";//API.IPToNumber(M5.PageContext.Current.Request.UserHostAddress).ToString();
            ReturnValue     err    = new ReturnValue();
            string          pword2 = "";
            double          userId = 0;
            MySqlDataReader rs     = Sql.ExecuteReader("select id,pword from m_admin where status=1 and classId=0 and uname=@uname", new MySqlParameter[] { new MySqlParameter("uname", uname) });

            if (rs.Read())
            {
                pword2 = rs[1].ToString();
                userId = rs.GetDouble(0);
            }
            rs.Close();
            #region 用户不存在
            if (userId == 0)
            {
                Tools.writeLog("login", uname + "用户名密码错误");
                err.errNo  = -1;
                err.errMsg = "用户名密码错误";
                return(err);
            }
            #endregion
            #region 出错次数过多ip封锁
            Sql.ExecuteNonQuery("delete from invalid_login where createdate<@createdate ", new MySqlParameter[] {
                new MySqlParameter("createdate", DateTime.Now.AddHours(-3))
            });//清空3天前的登陆错误日志
            rs = Sql.ExecuteReader("select ip from invalid_login where createdate>@createdate and uname=@uname and ip=@ip and count>10", new MySqlParameter[] {
                new MySqlParameter("uname", uname),
                new MySqlParameter("ip", ip),
                new MySqlParameter("createdate", DateTime.Now.AddHours(-2))
            });
            if (rs.Read())
            {
                err.errNo = -1; err.errMsg = "由于您登录后台错误次数过多,系统自动屏蔽您的登录!";
            }
            rs.Close();
            if (err.errNo < 0)
            {
                return(err);
            }
            #endregion

            if (pword.Encryption(Config.webId).MD5() == pword2)
            {
                return(login(userId, hour));
            }
            else
            {
                #region 密码错误
                MySqlParameter[] p = new MySqlParameter[] {
                    new MySqlParameter("ip", ip),
                    new MySqlParameter("uname", uname),
                    new MySqlParameter("createdate", DateTime.Now)
                };
                rs = Sql.ExecuteReader("select ip from invalid_login where uname=@uname and ip=@ip", p);
                if (rs.Read())
                {
                    Sql.ExecuteNonQuery("update invalid_login set count=count+1 where uname=@uname and ip=@ip", p);
                }
                else
                {
                    Sql.ExecuteNonQuery("insert into invalid_login (ip,uname,count,createdate)values(@ip,@uname,1,@createdate)", p);
                }
                rs.Close();
                Tools.writeLog("login", uname + "用户名密码错误");
                err.errNo  = -1;
                err.errMsg = "用户名密码错误";
                #endregion
            }
            return(err);
        }
Esempio n. 31
0
 /// <summary>
 /// Instantiates UpdateItemRequest with the parameterized properties
 /// </summary>
 /// <param name="tableName">The name of the table containing the item to update.</param>
 /// <param name="key">The primary key of the item to be updated. Each element consists of an attribute name and a value for that attribute. For the primary key, you must provide all of the attributes. For example, with a simple primary key, you only need to provide a value for the partition key. For a composite primary key, you must provide values for both the partition key and the sort key.</param>
 /// <param name="attributeUpdates">This is a legacy parameter. Use <code>UpdateExpression</code> instead. For more information, see <a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/LegacyConditionalParameters.AttributeUpdates.html">AttributeUpdates</a> in the <i>Amazon DynamoDB Developer Guide</i>.</param>
 /// <param name="returnValues">Use <code>ReturnValues</code> if you want to get the item attributes as they appear before or after they are updated. For <code>UpdateItem</code>, the valid values are: <ul> <li>  <code>NONE</code> - If <code>ReturnValues</code> is not specified, or if its value is <code>NONE</code>, then nothing is returned. (This setting is the default for <code>ReturnValues</code>.) </li> <li>  <code>ALL_OLD</code> - Returns all of the attributes of the item, as they appeared before the UpdateItem operation. </li> <li>  <code>UPDATED_OLD</code> - Returns only the updated attributes, as they appeared before the UpdateItem operation. </li> <li>  <code>ALL_NEW</code> - Returns all of the attributes of the item, as they appear after the UpdateItem operation. </li> <li>  <code>UPDATED_NEW</code> - Returns only the updated attributes, as they appear after the UpdateItem operation. </li> </ul> There is no additional cost associated with requesting a return value aside from the small network and processing overhead of receiving a larger response. No read capacity units are consumed. The values returned are strongly consistent.</param>
 public UpdateItemRequest(string tableName, Dictionary <string, AttributeValue> key, Dictionary <string, AttributeValueUpdate> attributeUpdates, ReturnValue returnValues)
 {
     _tableName        = tableName;
     _key              = key;
     _attributeUpdates = attributeUpdates;
     _returnValues     = returnValues;
 }
 public override void VisitReturnValue(ReturnValue returnValue)
 {
     this.errorHandler(new Error(1023, "Result() can be used only in Ensures.", lastSC));
 }
            public override void VisitReturnValue(ReturnValue returnValue)
            {
                if (returnValue == null) return;

                var type = returnValue.Type;
                
                if (type == null) return;

                CheckProperUseOfReturnValueHelper(type);
            }
Esempio n. 34
0
        /// <summary>
        /// 接收数据回调处理
        /// </summary>
        /// <param name="data">输出数据</param>
        internal override void OnReceive(ref SubArray <byte> data)
        {
            Callback <ReturnValue <outputParameterType> > callback = Callback;

            if (callback != null)
            {
                ReturnValue <outputParameterType> outputParameter = new ReturnValue <outputParameterType>();
                if (CommandInfo.TaskType == ClientTaskType.Synchronous)
                {
                    try
                    {
                        onReceive(ref data, ref outputParameter);
                    }
                    catch (Exception error)
                    {
                        Socket.Log.Exception(error, null, LogLevel.Exception | LogLevel.AutoCSer);
                    }
                    finally { callback.Call(ref outputParameter); }
                }
                else
                {
                    try
                    {
                        onReceive(ref data, ref outputParameter);
                    }
                    catch (Exception error)
                    {
                        outputParameter.Type  = ReturnType.ClientException;
                        outputParameter.Value = default(outputParameterType);
                        Socket.Log.Exception(error, null, LogLevel.Exception | LogLevel.AutoCSer);
                    }
                    int       isOutput  = 1;
                    Exception exception = null;
                    OutputLock.Enter();
                    try
                    {
                        if (outputParameters.FreeCount == 0)
                        {
                            OutputLock.SleepFlag = 1;
                        }
                        outputParameters.Add(outputParameter);
                        isOutput      = this.isOutput;
                        this.isOutput = 1;
                    }
                    catch (Exception error) { exception = error; }
                    finally
                    {
                        OutputLock.ExitSleepFlag();
                        if (exception != null)
                        {
                            Socket.Log.Exception(exception, null, LogLevel.Exception | LogLevel.AutoCSer);
                        }
                    }
                    if (isOutput == 0)
                    {
                        switch (CommandInfo.TaskType)
                        {
                        case ClientTaskType.ThreadPool: if (!System.Threading.ThreadPool.QueueUserWorkItem(threadPoolOnReceive))
                            {
                                AutoCSer.Threading.TaskSwitchThreadArray.Default.CurrentThread.Add(this);
                            }
                            return;

                        case ClientTaskType.Timeout: AutoCSer.Threading.TaskSwitchThreadArray.Default.CurrentThread.Add(this); return;

                        case ClientTaskType.TcpTask: ClientCallThreadArray.Default.CurrentThread.Add(this); return;

                        case ClientTaskType.TcpQueue: ClientCallQueue.Default.Add(this); return;
                        }
                    }
                }
            }
        }