Exemplo n.º 1
0
        public void AddFormatValuesToChores(List <Chore> chores)
        {
            List <FormatValue> FormatValues = new List <FormatValue>();

            foreach (Chore chore in chores)
            {
                List <Guid> formatLabelIds = GetFormatLabelId(chore.GenericChoreId);
                if (formatLabelIds == null)
                {
                    continue;
                }
                foreach (Guid formatLabelId in formatLabelIds)
                {
                    FormatValue formatValue = new FormatValue()
                    {
                        Id            = Guid.NewGuid(),
                        EntityStatus  = EntityStatus.Active,
                        ChoreId       = chore.Id,
                        FormatLabelId = formatLabelId,
                    };

                    FormatValues.Add(formatValue);
                }
            }
            InsertFormatValuesToDatabase(FormatValues);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextEditingElement&lt;CONTROLTYPE&gt;"/> class.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <param name="control">The control.</param>
        protected TextEditingElement([NotNull] IPropertyAccessor property,
                                     [NotNull] CONTROLTYPE control)
            : base(property, control)
        {
            SetupEvents(control);

            if (CoercionUtility.IsNumeric(property.PropertyType))
            {
                SetRightAligned(control);
            }

            if (property.PropertyType == typeof(string))
            {
                int?length = MaximumStringLengthAttribute.GetLength(
                    property.InnerProperty);

                if (length.HasValue)
                {
                    SetMaximumLength(length.Value);
                }
            }

            _coercion = delegate(IPropertyAccessor accessor, string rawValue)
            {
                // default coercion
                return(CoercionUtility.Coerce(accessor, rawValue));
            };

            _format = delegate(object o) { return(o.ToString()); };
        }
Exemplo n.º 3
0
        public InputMessageForm(string caption, FormatValue fv)
        {
            InitializeComponent();
            ControlsUtil.SetBackColor(this.Controls);
            this.pnPrincipal.Text = caption;

            if (fv == FormatValue.Decimal)
            {
                tfValue.Properties.Mask.EditMask = "c2";
                tfValue.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
            }
            else if (fv == FormatValue.Integer)
            {
                tfValue.Properties.Mask.EditMask = "n2";
                tfValue.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
            }
            else if (fv == FormatValue.String)
            {
                tfValue.Properties.Mask.EditMask = "";
                tfValue.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.None;
            }
            tfValue.Properties.Mask.UseMaskAsDisplayFormat = true;
            if (Value != null)
            {
                tfValue.EditValue = Value;
            }
        }
Exemplo n.º 4
0
        public InputMessageForm(string caption, FormatValue fv)
        {
            InitializeComponent();
            ControlsUtil.SetBackColor(this.Controls);
            this.pnPrincipal.Text = caption;

            if (fv == FormatValue.Decimal)
            {
                tfValue.Properties.Mask.EditMask = "c2";
                tfValue.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
            }
            else if (fv == FormatValue.Integer)
            {
                tfValue.Properties.Mask.EditMask = "n2";
                tfValue.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
            }
            else if (fv == FormatValue.String)
            {
                tfValue.Properties.Mask.EditMask = "";
                tfValue.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.None;
            }
            tfValue.Properties.Mask.UseMaskAsDisplayFormat = true;
            if (Value != null)
            {
                tfValue.EditValue = Value;
            }
        }
Exemplo n.º 5
0
 public async Task <ActionResult <FormatValue> > PostFormat(FormatValue format)
 {
     return(await Task.Run(() =>
     {
         var output = _formatValuesService.Add(format);
         return new ActionResult <FormatValue>(output);
     }));
 }
Exemplo n.º 6
0
        public int Insert(Category entity)
        {
            SqlParameter[] sqlParameters = new SqlParameter[]
            {
                new SqlParameter("Name", entity.Name),
                new SqlParameter("MetaTitle", FormatValue.ConvertToLink(entity.Name)),
                new SqlParameter("Image", entity.Image)
            };

            return(db.Database.SqlQuery <int>("uspInsertCategory @Name, @MetaTitle, @Image", sqlParameters).SingleOrDefault());
        }
Exemplo n.º 7
0
        public int Insert(Publisher entity)
        {
            SqlParameter[] sqlParameters = new SqlParameter[]
            {
                new SqlParameter("Name", entity.Name),
                new SqlParameter("MetaTitle", FormatValue.ConvertToLink(entity.Name)),
                new SqlParameter("Address", entity.Address != null ? entity.Address : DBNull.Value.ToString()),
                new SqlParameter("Phone", entity.Phone != null ? entity.Phone : DBNull.Value.ToString()),
                new SqlParameter("Email", entity.Email != null ? entity.Email : DBNull.Value.ToString())
            };

            return(db.Database.ExecuteSqlCommand("uspInsertPublisher @Name, @MetaTitle, @Address, @Phone, @Email", sqlParameters));
        }
Exemplo n.º 8
0
        protected override void Render(HtmlTextWriter writer)
        {
            writer.Write("<div id={0} data-control='Chart' data-charttype='{1}' data-charvalueformat='{2}' data-chartname='{3}' data-chart-showLegend='{4}'{5}{6}{7}{8}{9}{10}{11}>",
                         UniqueID, tipoChart.ToString(), FormatValue.ToString(), ID, ShowLegend,
                         Click != null ? $" data-chart-serverclick=\"{Page.ClientScript.GetPostBackEventReference(this, RaiseEvents.OnClickEvent.ToString())}\" " : "",
                         !string.IsNullOrWhiteSpace(ClientClick) ? $" data-chart-clientclick=\"{ClientClick}\" " : "",
                         $" data-chart-angle='{Angle}' ",
                         $" data-chart-innerRadius='{InnerRadius}' ",
                         $" data-chart-depth3D='{Depth3D}' ",
                         $" data-chart-hasAuxDisplay='{!string.IsNullOrWhiteSpace(ChartAuxDisplay)}'",
                         !string.IsNullOrWhiteSpace(LoadJSFunction) ? $"data-chart-loadfunction={LoadJSFunction}" : "");
            writer.Write("<div class='value' style='display:none;'>[{0}]</div>", sbData);
            writer.Write("<div class='xaxis' style='display:none;'>[{0}]</div>", String.Join(",", dic.Select(p => "[" + p.Value + ",\"" + p.Key + "\"]")));
            writer.Write("<div class='axesGuides' style='display:none;'>[{0}]</div>", jsonFixedLines);
            base.Render(writer);

            writer.Write("</div>");
        }
        /// <inheritdoc />
        public string Render(IPropertyContainer source)
        {
            if (CustomRender != null)
            {
                return(CustomRender(Property, source));
            }

            string textValue = NullValue;

            IPropertyValue <T> propertyValue = source.GetPropertyValue(Property, SearchOptions ?? Metadata.SearchOptions.ExistingOnlyWithParent);

            if (propertyValue.HasValue())
            {
                T value = propertyValue.Value;
                textValue = FormatValue?.Invoke(value, source) ?? DoDefaultFormatting(value);
            }

            return(textValue);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 同步调用返回
        /// </summary>
        /// <typeparam name="Mode"></typeparam>
        /// <typeparam name="Result"></typeparam>
        /// <param name="action"></param>
        /// <returns></returns>
        public Result Call <Mode, Result>(Expression <Func <Mode, Result> > action)
        {
            MethodCallExpression body = action.Body as MethodCallExpression;

            List <RPCArgument> argumentlist = new List <RPCArgument>();

            var parameters = body.Method.GetParameters();

            for (int i = 0; i < parameters.Length; i++)
            {
                dynamic p = Expression.Call(FormatValue.GetMethodInfo(body.Arguments[i].Type), body.Arguments[i]);
                dynamic x = Expression.Lambda <Func <dynamic> >(p).Compile()();

                RPCArgument tmp = new RPCArgument();
                tmp.type    = body.Arguments[i].Type;
                tmp.RefType = parameters[i].ParameterType;
                tmp.Value   = Serialization.PackSingleObject(body.Arguments[i].Type, x);
                argumentlist.Add(tmp);
            }

            object[] args;

            Result res = CallMethod <Result>(body.Object.Type.Name, body.Method.Name, argumentlist, out args);

            if (args != null)
            {
                if (args.Length == body.Arguments.Count)
                {
                    for (int i = 0; i < args.Length; i++)
                    {
                        if (body.Arguments[i].NodeType == ExpressionType.MemberAccess)
                        {
                            var set = Expression.Assign(body.Arguments[i], Expression.Constant(args[i]));

                            Expression.Lambda <Action>(set).Compile()();
                        }
                    }
                }
            }

            return(res);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 异步调用,返回值后调用 Callback
        /// </summary>
        /// <typeparam name="Mode"></typeparam>
        /// <typeparam name="Result"></typeparam>
        /// <param name="action"></param>
        /// <param name="Callback"></param>
        public void CallAsyn <Mode, Result>(Expression <Func <Mode, Result> > action, Action <AsynReturn> Callback)
        {
            MethodCallExpression body = action.Body as MethodCallExpression;

            List <RPCArgument> argumentlist = new List <RPCArgument>();

            var parameters = body.Method.GetParameters();

            for (int i = 0; i < parameters.Length; i++)
            {
                dynamic p = Expression.Call(FormatValue.GetMethodInfo(body.Arguments[i].Type), body.Arguments[i]);
                dynamic x = Expression.Lambda <Func <dynamic> >(p).Compile()();

                RPCArgument tmp = new RPCArgument();
                tmp.type    = body.Arguments[i].Type;
                tmp.RefType = parameters[i].ParameterType;
                tmp.Value   = Serialization.PackSingleObject(body.Arguments[i].Type, x);
                argumentlist.Add(tmp);
            }



            RPCCallPack call = new RPCCallPack()
            {
                Id           = MakeID.GetID(),
                CallTime     = DateTime.Now,
                CallModule   = body.Object.Type.Name,
                Method       = body.Method.Name,
                Arguments    = argumentlist,
                IsNeedReturn = true,
            };

            byte[] data = BufferFormat.FormatFCA(call);

            if (CallBufferOutSend != null)
            {
                CallBufferOutSend(data);
            }


            AsynRetrunDiy.AddOrUpdate(call.Id, Callback, (a, b) => Callback);
        }
Exemplo n.º 12
0
        public int Insert(Book model)
        {
            SqlParameter[] sqlParameters = new SqlParameter[]
            {
                new SqlParameter("Title", model.Title),
                new SqlParameter("MetaTitle", FormatValue.ConvertToLink(model.Title)),
                new SqlParameter("Image", model.Image),
                new SqlParameter("Authors", model.Authors),
                new SqlParameter("CategoryId", model.CategoryId),
                new SqlParameter("PublisherId", model.PublisherId),
                new SqlParameter("Quantity", model.Quantity),
                new SqlParameter("PageNumber", model.PageNumber),
                new SqlParameter("Size", model.Size),
                new SqlParameter("Weight", model.Weight),
                new SqlParameter("PublishYear", model.PublishYear),
                new SqlParameter("Description", model.Description == null ? DBNull.Value.ToString() : model.Description),
                new SqlParameter("Status", model.Status),
            };

            return(db.Database.SqlQuery <int>("uspInsertBook @Title, @MetaTitle, @Image, @Authors, @CategoryId, @PublisherId, @Quantity, @PageNumber, @Size, @Weight, @PublishYear, @Description, @Status", sqlParameters).SingleOrDefault());
        }
Exemplo n.º 13
0
 public void Format(StringBuilder builder, bool logic = true)
 {
     if (logic)
     {
         builder.Append($" {Logic.Format()} ");
     }
     builder.Append($"{((Group & QueryGroup.Begin) != 0 ? "(" : "")}{FormatName ?? Name} {Comparer.Format()} {FormatValue()}{((Group & QueryGroup.End) != 0 ? ")" : "")}");
 }