public IRequest Marshall(DeleteAttributesRequest deleteAttributesRequest)
        {
            IRequest request = new DefaultRequest(deleteAttributesRequest, "AmazonSimpleDB");

            request.Parameters.Add("Action", "DeleteAttributes");
            request.Parameters.Add("Version", "2009-04-15");
            if (deleteAttributesRequest != null && deleteAttributesRequest.IsSetDomainName())
            {
                request.Parameters.Add("DomainName", StringUtils.FromString(deleteAttributesRequest.DomainName));
            }
            if (deleteAttributesRequest != null && deleteAttributesRequest.IsSetItemName())
            {
                request.Parameters.Add("ItemName", StringUtils.FromString(deleteAttributesRequest.ItemName));
            }

            if (deleteAttributesRequest != null)
            {
                List <Attribute> attributesList = deleteAttributesRequest.Attributes;
                int attributesListIndex         = 1;
                foreach (Attribute attributesListValue in attributesList)
                {
                    if (attributesListValue != null && attributesListValue.IsSetName())
                    {
                        request.Parameters.Add("Attribute." + attributesListIndex + ".Name", StringUtils.FromString(attributesListValue.Name));
                    }
                    if (attributesListValue != null && attributesListValue.IsSetAlternateNameEncoding())
                    {
                        request.Parameters.Add("Attribute." + attributesListIndex + ".AlternateNameEncoding", StringUtils.FromString(attributesListValue.AlternateNameEncoding));
                    }
                    if (attributesListValue != null && attributesListValue.IsSetValue())
                    {
                        request.Parameters.Add("Attribute." + attributesListIndex + ".Value", StringUtils.FromString(attributesListValue.Value));
                    }
                    if (attributesListValue != null && attributesListValue.IsSetAlternateValueEncoding())
                    {
                        request.Parameters.Add("Attribute." + attributesListIndex + ".AlternateValueEncoding", StringUtils.FromString(attributesListValue.AlternateValueEncoding));
                    }

                    attributesListIndex++;
                }
            }
            if (deleteAttributesRequest != null)
            {
                UpdateCondition expected = deleteAttributesRequest.Expected;
                if (expected != null && expected.IsSetName())
                {
                    request.Parameters.Add("Expected.Name", StringUtils.FromString(expected.Name));
                }
                if (expected != null && expected.IsSetValue())
                {
                    request.Parameters.Add("Expected.Value", StringUtils.FromString(expected.Value));
                }
                if (expected != null && expected.IsSetExists())
                {
                    request.Parameters.Add("Expected.Exists", StringUtils.FromBool(expected.Exists));
                }
            }

            return(request);
        }
Пример #2
0
        public UpdateConditionForm(FormClose hClose, ReturnToMenu hReturn, UpdateCondition hUpdate)
        {
            handleClose           = hClose;
            handleReturnToMenu    = hReturn;
            handleUpdateCondition = hUpdate;

            InitializeComponent();
            BackColor = Color.SteelBlue;
        }
        public IRequest Marshall(PutAttributesRequest putAttributesRequest)
        {
            IRequest request = new DefaultRequest(putAttributesRequest, "AmazonSimpleDB");

            request.Parameters.Add("Action", "PutAttributes");
            request.Parameters.Add("Version", "2009-04-15");
            if (putAttributesRequest != null && putAttributesRequest.IsSetDomainName())
            {
                request.Parameters.Add("DomainName", StringUtils.FromString(putAttributesRequest.DomainName));
            }
            if (putAttributesRequest != null && putAttributesRequest.IsSetItemName())
            {
                request.Parameters.Add("ItemName", StringUtils.FromString(putAttributesRequest.ItemName));
            }

            if (putAttributesRequest != null)
            {
                List <ReplaceableAttribute> attributesList = putAttributesRequest.Attributes;
                int attributesListIndex = 1;
                foreach (ReplaceableAttribute attributesListValue in attributesList)
                {
                    if (attributesListValue != null && attributesListValue.IsSetName())
                    {
                        request.Parameters.Add("Attribute." + attributesListIndex + ".Name", StringUtils.FromString(attributesListValue.Name));
                    }
                    if (attributesListValue != null && attributesListValue.IsSetValue())
                    {
                        request.Parameters.Add("Attribute." + attributesListIndex + ".Value", StringUtils.FromString(attributesListValue.Value));
                    }
                    if (attributesListValue != null && attributesListValue.IsSetReplace())
                    {
                        request.Parameters.Add("Attribute." + attributesListIndex + ".Replace", StringUtils.FromBool(attributesListValue.Replace));
                    }

                    attributesListIndex++;
                }
            }
            if (putAttributesRequest != null)
            {
                UpdateCondition expected = putAttributesRequest.Expected;
                if (expected != null && expected.IsSetName())
                {
                    request.Parameters.Add("Expected.Name", StringUtils.FromString(expected.Name));
                }
                if (expected != null && expected.IsSetValue())
                {
                    request.Parameters.Add("Expected.Value", StringUtils.FromString(expected.Value));
                }
                if (expected != null && expected.IsSetExists())
                {
                    request.Parameters.Add("Expected.Exists", StringUtils.FromBool(expected.Exists));
                }
            }

            return(request);
        }
Пример #4
0
        /**
         * Convert DeleteAttributesRequest to name value pairs
         */
        private static IDictionary <string, string> ConvertDeleteAttributes(DeleteAttributesRequest request)
        {
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["Action"] = "DeleteAttributes";
            if (request.IsSetDomainName())
            {
                parameters["DomainName"] = request.DomainName;
            }
            if (request.IsSetItemName())
            {
                parameters["ItemName"] = request.ItemName;
            }
            List <Attribute> deleteAttributesRequestAttributeList = request.Attribute;
            int deleteAttributesRequestAttributeListIndex         = 1;

            foreach (Attribute deleteAttributesRequestAttribute in deleteAttributesRequestAttributeList)
            {
                if (deleteAttributesRequestAttribute.IsSetName())
                {
                    parameters[String.Concat("Attribute", ".", deleteAttributesRequestAttributeListIndex, ".", "Name")] = deleteAttributesRequestAttribute.Name;
                }
                if (deleteAttributesRequestAttribute.IsSetValue())
                {
                    parameters[String.Concat("Attribute", ".", deleteAttributesRequestAttributeListIndex, ".", "Value")] = deleteAttributesRequestAttribute.Value;
                }
                if (deleteAttributesRequestAttribute.IsSetNameEncoding())
                {
                    parameters[String.Concat("Attribute", ".", deleteAttributesRequestAttributeListIndex, ".", "NameEncoding")] = deleteAttributesRequestAttribute.NameEncoding;
                }
                if (deleteAttributesRequestAttribute.IsSetValueEncoding())
                {
                    parameters[String.Concat("Attribute", ".", deleteAttributesRequestAttributeListIndex, ".", "ValueEncoding")] = deleteAttributesRequestAttribute.ValueEncoding;
                }

                deleteAttributesRequestAttributeListIndex++;
            }
            if (request.IsSetExpected())
            {
                UpdateCondition deleteAttributesRequestExpected = request.Expected;
                if (deleteAttributesRequestExpected.IsSetName())
                {
                    parameters[String.Concat("Expected", ".", "Name")] = deleteAttributesRequestExpected.Name;
                }
                if (deleteAttributesRequestExpected.IsSetValue())
                {
                    parameters[String.Concat("Expected", ".", "Value")] = deleteAttributesRequestExpected.Value;
                }
                if (deleteAttributesRequestExpected.IsSetExists())
                {
                    parameters[String.Concat("Expected", ".", "Exists")] = deleteAttributesRequestExpected.Exists.ToString().ToLower(CultureInfo.InvariantCulture);
                }
            }

            return(parameters);
        }
Пример #5
0
 /// <summary>
 /// Start a process to move from the given position to (x,y). The move is made moveStep by moveStep.
 /// </summary>
 /// <param name="position">Origin position</param>
 /// <param name="callback">Lambda function that will be called when the process is over</param>
 /// <param name="force">When true force the initial position to origin</param>
 public void ComeFrom(Position position, Callback callback, bool force = true)
 {
     this.otherPosition = position;
     moveCallback       = callback;
     moveCondition      = UpdateCondition.COMING;
     if (force)
     {
         percentMove.Set(0);
     }
 }
Пример #6
0
 /// <summary>
 /// Start a process to move from the (x,y) to given position. The move is made moveStep by moveStep.
 /// </summary>
 /// <param name="position">Destiny position</param>
 /// <param name="callback">Lambda function that will be called when the process is over</param>
 /// <param name="force">When true force the initial position to (x,y)</param>
 public void GoTo(Position position, Callback callback, bool force = true)
 {
     this.otherPosition = position;
     moveCallback       = callback;
     moveCondition      = UpdateCondition.GOING;
     if (force)
     {
         percentMove.Set(percentMove.Max() - 1);
     }
 }
Пример #7
0
        private static IDictionary <string, string> ConvertDeleteAttributes(DeleteAttributesRequest request)
        {
            IDictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary["Action"] = "DeleteAttributes";
            if (request.IsSetDomainName())
            {
                dictionary["DomainName"] = request.DomainName;
            }
            if (request.IsSetItemName())
            {
                dictionary["ItemName"] = request.ItemName;
            }
            List <Amazon.SimpleDB.Model.Attribute> list = request.Attribute;
            int num = 1;

            foreach (Amazon.SimpleDB.Model.Attribute attribute in list)
            {
                if (attribute.IsSetName())
                {
                    dictionary[string.Concat(new object[] { "Attribute", ".", num, ".", "Name" })] = attribute.Name;
                }
                if (attribute.IsSetValue())
                {
                    dictionary[string.Concat(new object[] { "Attribute", ".", num, ".", "Value" })] = attribute.Value;
                }
                if (attribute.IsSetNameEncoding())
                {
                    dictionary[string.Concat(new object[] { "Attribute", ".", num, ".", "NameEncoding" })] = attribute.NameEncoding;
                }
                if (attribute.IsSetValueEncoding())
                {
                    dictionary[string.Concat(new object[] { "Attribute", ".", num, ".", "ValueEncoding" })] = attribute.ValueEncoding;
                }
                num++;
            }
            if (request.IsSetExpected())
            {
                UpdateCondition expected = request.Expected;
                if (expected.IsSetName())
                {
                    dictionary["Expected" + "." + "Name"] = expected.Name;
                }
                if (expected.IsSetValue())
                {
                    dictionary["Expected" + "." + "Value"] = expected.Value;
                }
                if (expected.IsSetExists())
                {
                    dictionary["Expected" + "." + "Exists"] = expected.Exists.ToString().ToLower();
                }
            }
            return(dictionary);
        }
Пример #8
0
        /**
         * Convert PutAttributesRequest to name value pairs
         */
        private static IDictionary <string, string> ConvertPutAttributes(PutAttributesRequest request)
        {
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["Action"] = "PutAttributes";
            if (request.IsSetDomainName())
            {
                parameters["DomainName"] = request.DomainName;
            }
            if (request.IsSetItemName())
            {
                parameters["ItemName"] = request.ItemName;
            }
            List <ReplaceableAttribute> putAttributesRequestAttributeList = request.Attribute;
            int putAttributesRequestAttributeListIndex = 1;

            foreach (ReplaceableAttribute putAttributesRequestAttribute in putAttributesRequestAttributeList)
            {
                if (putAttributesRequestAttribute.IsSetName())
                {
                    parameters[String.Concat("Attribute", ".", putAttributesRequestAttributeListIndex, ".", "Name")] = putAttributesRequestAttribute.Name;
                }
                if (putAttributesRequestAttribute.IsSetValue())
                {
                    parameters[String.Concat("Attribute", ".", putAttributesRequestAttributeListIndex, ".", "Value")] = putAttributesRequestAttribute.Value;
                }
                if (putAttributesRequestAttribute.IsSetReplace())
                {
                    parameters[String.Concat("Attribute", ".", putAttributesRequestAttributeListIndex,
                                             ".", "Replace")] = putAttributesRequestAttribute.Replace.ToString().ToLower(CultureInfo.InvariantCulture);
                }

                putAttributesRequestAttributeListIndex++;
            }
            if (request.IsSetExpected())
            {
                UpdateCondition putAttributesRequestExpected = request.Expected;
                if (putAttributesRequestExpected.IsSetName())
                {
                    parameters[String.Concat("Expected", ".", "Name")] = putAttributesRequestExpected.Name;
                }
                if (putAttributesRequestExpected.IsSetValue())
                {
                    parameters[String.Concat("Expected", ".", "Value")] = putAttributesRequestExpected.Value;
                }
                if (putAttributesRequestExpected.IsSetExists())
                {
                    parameters[String.Concat("Expected", ".", "Exists")] = putAttributesRequestExpected.Exists.ToString().ToLower(CultureInfo.InvariantCulture);
                }
            }

            return(parameters);
        }
Пример #9
0
    public void CopyValues(Area template)
    {
        centerPosition = template.centerPosition;
        size           = template.size;
        growStep       = template.growStep;
        moveStep       = template.moveStep;
        parent         = template.parent;

        percentSizeHeigth.Set(percentSizeWidth.Max() - 1);
        percentSizeWidth.Set(percentSizeWidth.Max() - 1);

        sizeConditionWidth  = UpdateCondition.STOPPED;
        sizeConditionHeight = UpdateCondition.STOPPED;
        moveCondition       = UpdateCondition.STOPPED;
    }
Пример #10
0
 /// <summary>
 /// Start a process to reduce the area growStep by growStep.
 /// </summary>
 /// <param name="width">True if width should grow</param>
 /// <param name="heigth">True if heigth should grow</param>
 /// <param name="callback">Lambda function that will be called when the process is over</param>
 /// <param name="force">When true force the current size to 100%</param>
 public void Grow(bool width, bool heigth, Callback callback, bool force = false)
 {
     sizeConditionWidth  = (width) ? UpdateCondition.COMING : UpdateCondition.STOPPED;
     sizeConditionHeight = (heigth) ? UpdateCondition.COMING : UpdateCondition.STOPPED;
     sizeCallback        = callback;
     if (force)
     {
         if (width)
         {
             percentSizeWidth.Set(0);
         }
         if (heigth)
         {
             percentSizeHeigth.Set(0);
         }
     }
 }
Пример #11
0
 /// <summary>
 /// Start a process to reduce the area growStep by growStep.
 /// </summary>
 /// <param name="width">True if width should reduce</param>
 /// <param name="heigth">True if heigth should reduce</param>
 /// <param name="callback">Lambda function that will be called when the process is over</param>
 /// <param name="force">When true force the current size to 100%</param>
 public void Reduce(bool width, bool heigth, Callback callback, bool force = false)
 {
     sizeConditionWidth  = (width) ? UpdateCondition.GOING : UpdateCondition.STOPPED;
     sizeConditionHeight = (heigth) ? UpdateCondition.GOING : UpdateCondition.STOPPED;
     sizeCallback        = callback;
     if (force)
     {
         if (width)
         {
             percentSizeWidth.Set(percentSizeWidth.Max() - 1);
         }
         if (heigth)
         {
             percentSizeHeigth.Set(percentSizeHeigth.Max() - 1);
         }
     }
 }
Пример #12
0
        /// <summary>
        /// 修改记录
        /// </summary>
        /// <param name="obj">修改的对象</param>
        /// <param name="scopeList">条件列表</param>
        /// <param name="setList">Set值列表</param>
        /// <param name="optimisticConcurrency">是否进行并发控制</param>
        /// <returns></returns>
        public int Update(EntityBase obj, ScopeList scopeList, ValueSetList setList, bool optimisticConcurrency)
        {
            StringBuilder sql  = new StringBuilder(500);
            ParamList     list = new ParamList();

            StringBuilder where = new StringBuilder(500);
            //where.Append("1=1");
            Type type = EntityInfo.EntityType;
            List <VersionInfo> lstVersionInfo = null;
            int index = 0;

            KeyWordInfomation keyinfo = BQLValueItem.GetKeyInfo().Clone() as KeyWordInfomation;

            keyinfo.ParamList   = list;
            keyinfo.OutPutModle = false;
            if (obj != null)
            {
                if (!(obj is IEntityProxy))
                {
                    throw new System.InvalidCastException("Update的实体类型必须为代理类,请用CH.Create<T>创建实体或者使用查询出来的实体来更新");
                }
                ///读取属性别名
                foreach (EntityPropertyInfo info in EntityInfo.PropertyInfo)
                {
                    object curValue = info.GetValue(obj);
                    if (!info.ReadOnly)
                    {
                        if (optimisticConcurrency == true && info.IsVersion) //并发控制
                        {
                            object newValue = FillUpdateConcurrency(sql, info, list, curValue, ref index);
                            FillWhereConcurrency(where, info, list, curValue, ref index);
                            if (lstVersionInfo == null)
                            {
                                lstVersionInfo = new List <VersionInfo>();
                            }
                            lstVersionInfo.Add(new VersionInfo(info, curValue, newValue));//添加信息
                        }
                        else
                        {
                            //string paramVal = CurEntityInfo.DBInfo.CurrentDbAdapter.FormatValueName(DataAccessCommon.FormatParam(info.ParamName, index));
                            //string paramKey = CurEntityInfo.DBInfo.CurrentDbAdapter.FormatParamKeyName(DataAccessCommon.FormatParam(info.ParamName, index));
                            if (info.IsNormal)
                            {
                                //if (obj._dicUpdateProperty___ == null || obj._dicUpdateProperty___.Count == 0)
                                //{
                                //    //if (DefaultType.IsDefaultValue(curValue))
                                //    //{
                                //    continue;
                                //    //}
                                //}
                                if (!obj.HasPropertyChange(info.PropertyName))
                                {
                                    continue;
                                }
                                if (setList != null)
                                {
                                    BQLValueItem bvalue = null;
                                    if (setList.TryGetValue(info.PropertyName, out bvalue))
                                    {
                                        continue;
                                    }
                                }
                                sql.Append(",");
                                sql.Append(EntityInfo.DBInfo.CurrentDbAdapter.FormatParam(info.ParamName));
                                sql.Append("=");
                                if (curValue != null)
                                {
                                    DBParameter dbPrm = list.NewParameter(info.SqlType, curValue, EntityInfo.DBInfo);
                                    sql.Append(dbPrm.ValueName);
                                }
                                else
                                {
                                    sql.Append("null");
                                }
                            }
                        }
                    }

                    if (info.IsPrimaryKey && scopeList == null)//当不强制指定条件时候,用主键做更新条件
                    {
                        //if (DefaultType.IsDefaultValue(curValue))
                        //{
                        //    continue;
                        //}
                        //if (obj._dicUpdateProperty___ != null)
                        //{
                        //    if (!obj._dicUpdateProperty___.ContainsKey(info.PropertyName))
                        //    {
                        //        continue;
                        //    }
                        //}

                        DBParameter dbPrm = list.NewParameter(info.SqlType, curValue, EntityInfo.DBInfo);
                        where.Append(" and ");
                        where.Append(EntityInfo.DBInfo.CurrentDbAdapter.FormatParam(info.ParamName));
                        where.Append("=");
                        where.Append(dbPrm.ValueName);
                        //primaryKeyValue=curValue;
                    }
                    index++;
                }
            }
            if (setList != null)
            {
                foreach (KeyValuePair <string, BQLValueItem> kvp in setList)
                {
                    EntityPropertyInfo epinfo = EntityInfo.PropertyInfo[kvp.Key];
                    if (epinfo == null)
                    {
                        throw new Exception("实体:" + EntityInfo.EntityType.FullName + "  找不到属性:" + kvp.Key);
                    }
                    sql.Append(",");
                    sql.Append(EntityInfo.DBInfo.CurrentDbAdapter.FormatParam(epinfo.ParamName));
                    sql.Append("=");
                    sql.Append(kvp.Value.DisplayValue(keyinfo));
                }
            }
            where.Append(DataAccessCommon.FillCondition(EntityInfo, list, scopeList));
            if (sql.Length <= 0)
            {
                return(0);
            }
            else
            {
                sql.Remove(0, 1);
            }
            UpdateCondition con = new UpdateCondition(EntityInfo.DBInfo);

            con.Tables.Append(EntityInfo.DBInfo.CurrentDbAdapter.FormatTableName(EntityInfo.TableName));
            con.UpdateSetValue.Append(sql);
            con.Condition.Append("1=1");

            con.Condition.Append(where);

            int ret = -1;
            Dictionary <string, bool> cacheTables = null;

            cacheTables = _oper.DBInfo.QueryCache.CreateMap(EntityInfo.TableName);

            ret = ExecuteCommand(con.GetSql(true), list, CommandType.Text, cacheTables);
            if (obj != null && obj._dicUpdateProperty___ != null)
            {
                obj._dicUpdateProperty___.Clear();
            }
            if (lstVersionInfo != null && lstVersionInfo.Count > 0)
            {
                foreach (VersionInfo info in lstVersionInfo)
                {
                    info.Info.SetValue(obj, info.NewValue);
                }
            }

            return(ret);
        }
Пример #13
0
    /// <summary>
    /// Must be called if the area should move or resize
    /// </summary>
    public void Update()
    {
        switch (sizeConditionWidth)
        {
        case UpdateCondition.STOPPED:
            break;

        case UpdateCondition.GOING:
            percentSizeWidth.Update((int)(-growStep * percentSizeWidth.Max()));
            if (percentSizeWidth.Get() == 0)
            {
                sizeConditionWidth = UpdateCondition.STOPPED;
                sizeCallback();
            }
            break;

        case UpdateCondition.COMING:
            percentSizeWidth.Update((int)(growStep * percentSizeWidth.Max()));
            if (percentSizeWidth.Get() == percentSizeWidth.Max() - 1)
            {
                sizeConditionWidth = UpdateCondition.STOPPED;
                sizeCallback();
            }
            break;
        }

        switch (sizeConditionHeight)
        {
        case UpdateCondition.STOPPED:
            break;

        case UpdateCondition.GOING:
            percentSizeHeigth.Update((int)(-growStep * percentSizeHeigth.Max()));
            if (percentSizeHeigth.Get() == 0)
            {
                sizeConditionHeight = UpdateCondition.STOPPED;
                if (sizeConditionWidth == UpdateCondition.STOPPED)
                {
                    sizeCallback();
                }
            }
            break;

        case UpdateCondition.COMING:
            percentSizeHeigth.Update((int)(growStep * percentSizeHeigth.Max()));
            if (percentSizeHeigth.Get() == percentSizeHeigth.Max() - 1)
            {
                sizeConditionHeight = UpdateCondition.STOPPED;
                if (sizeConditionWidth == UpdateCondition.STOPPED)
                {
                    sizeCallback();
                }
            }
            break;
        }

        switch (moveCondition)
        {
        case UpdateCondition.STOPPED:
            break;

        case UpdateCondition.GOING:
            percentMove.Update((int)(-moveStep * percentMove.Max()));
            if (percentMove.Get() == 0)
            {
                moveCondition = UpdateCondition.STOPPED;
                moveCallback();
            }
            break;

        case UpdateCondition.COMING:
            percentMove.Update((int)(moveStep * percentMove.Max()));
            if (percentMove.Get() == percentMove.Max() - 1)
            {
                moveCondition = UpdateCondition.STOPPED;
                moveCallback();
            }
            break;
        }
    }