コード例 #1
0
        internal string GetClass()
        {
            using (var temp = StringPool.Borrow())
            {
                var sb = temp.Item;
                sb.Append("m-portlet");

                if (this.Border)
                {
                    sb.Append(" m-portlet--bordered");
                }
                if (this.Semi)
                {
                    sb.Append(" m-portlet--bordered-semi");
                }
                if (this.Rounded)
                {
                    sb.Append(" m-portlet--rounded");
                }
                if (!this.Air)
                {
                    sb.Append(" m-portlet--unair");
                }
                if (this.SmallHead)
                {
                    sb.Append(" m-portlet--head-sm");
                }
                if (!string.IsNullOrEmpty(this.BgColor))
                {
                    sb.AppendFormat(" m--bg-{0}", this.BgColor);
                }

                return(sb.ToString());
            }
        }
コード例 #2
0
        private string GetFrontCode()
        {
            using (var temp = StringPool.Borrow())
            {
                var code = temp.Item;
                code.AppendFormat("<{0}", this.TagName);

                OutputProperties(code, UIElement.IdProperty,
                                 UIElement.NameProperty,
                                 UIElement.StyleProperty,
                                 UIElement.ClassProperty);

                var proxyCode = this.ProxyCode;
                if (!string.IsNullOrEmpty(proxyCode) && !this.ProxyCodeIsExpression())
                {
                    code.AppendFormat(" data-proxy=\"{0}\"", proxyCode);
                }

                //if (!string.IsNullOrEmpty(this.Name))
                //    code.AppendFormat(" name=\"{0}\"", this.Name);

                //if (!string.IsNullOrEmpty(this.Style))
                //    code.AppendFormat(" style=\"{0}\"", this.Style);

                OutputAttributes(code);

                if (this.IsSingNode &&
                    !string.Equals(this.TagName, "form", StringComparison.OrdinalIgnoreCase))     //修复form的BUG
                {
                    code.Append("/");
                }
                code.Append(">");
                return(code.ToString());
            }
        }
コード例 #3
0
 public void Reset()
 {
     using (var temp = StringPool.Borrow())
     {
         var code = temp.Item;
         code.AppendFormat("{0}.proxy().reset();", this.Id);
         this.View.WriteCode(code.ToString());
     }
 }
コード例 #4
0
ファイル: JSON.cs プロジェクト: rajeshwarn/CodeArt-Framework
 public static string WriteValue(object value)
 {
     using (var temp = StringPool.Borrow())
     {
         var sb = temp.Item;
         WriteValue(sb, value);
         return(sb.ToString());
     }
 }
コード例 #5
0
 public void Set(DTObjects values)
 {
     using (var temp = StringPool.Borrow())
     {
         var code = temp.Item;
         code.AppendFormat("{0}.proxy().set({1});", this.Id, values.GetCode(false));
         this.View.WriteCode(code.ToString());
     }
 }
コード例 #6
0
ファイル: Alert.cs プロジェクト: rajeshwarn/CodeArt-Framework
        internal string GetClass()
        {
            using (var temp = StringPool.Borrow())
            {
                var sb = temp.Item;
                sb.Append("alert m-alert");
                if (this.Outline == 1)
                {
                    sb.Append(" m-alert--outline");
                }
                else if (this.Outline == 2)
                {
                    sb.Append(" m-alert--outline m-alert--outline-2x");
                }

                if (this.Air)
                {
                    sb.Append(" m-alert--air");
                }

                if (!string.IsNullOrEmpty(this.Shape))
                {
                    sb.Append(" m-alert--square");
                }

                if (!string.IsNullOrEmpty(this.Color))
                {
                    if (this.Color == "default")
                    {
                        sb.Append(" m-alert--default");
                    }
                    else
                    {
                        sb.AppendFormat(" alert-{0}", this.Color);
                    }
                }

                if (!string.IsNullOrEmpty(this.Icon))
                {
                    sb.Append(" m-alert--icon");
                }

                if (this.Close)
                {
                    sb.Append(" alert-dismissible fade show");
                }

                if (this.Hide)
                {
                    sb.Append(" m--hide");
                }

                return(sb.ToString());
            }
        }
コード例 #7
0
 private string GetItemMetadataCode(string listTypeName, DTObject item)
 {
     using (var temp = StringPool.Borrow())
     {
         var code = temp.Item;
         code.Append("{item:");
         code.Append(item.GetCode(false));
         code.Append("}");
         return(code.ToString());
     }
 }
コード例 #8
0
        /// <summary>
        /// 绑定选项,请确保<paramref name="data"/>里有成员为rows的集合作为绑定项
        /// </summary>
        /// <param name="data"></param>
        public void Options(DTObject data)
        {
            using (var temp = StringPool.Borrow())
            {
                var code = temp.Item;

                code.AppendFormat("{0}.proxy().options({1}.rows);", this.Id, data.GetCode(false, false));

                this.View.WriteCode(code.ToString());
            }
        }
コード例 #9
0
        /// <summary>
        /// 绘制脚本回调
        /// </summary>
        public void DrawScriptCallback(IScriptView view)
        {
            var output = view.Output();

            using (var temp = StringPool.Borrow())
            {
                StringBuilder code = temp.Item;
                code.Append("<script>$(document).ready(function () { ");
                code.AppendFormat("$$view.callback({0});", output.GetCode());
                code.Append(" });</script>");
                this.DrawLine(code.ToString(), DrawOrigin.Bottom);
            }
        }
コード例 #10
0
 protected override void OnGotProxyCode(ref object baseValue)
 {
     using (var temp = StringPool.Borrow())
     {
         var sb = temp.Item;
         sb.Append("{");
         sb.Append("give:new $$metronic.datatable(");
         sb.Append(GetConfigCode());
         sb.Append("),'datatable':true");
         sb.Append("}");
         baseValue = sb.ToString();
     }
 }
コード例 #11
0
ファイル: JSON.cs プロジェクト: rajeshwarn/CodeArt-Framework
 /// <summary>
 ///
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public static string GetCode(object value)
 {
     using (var temp = StringPool.Borrow())
     {
         var sb = temp.Item;
         try
         {
             WriteValue(sb, value);
         }
         catch (Exception ex)
         {
             throw ex;
         }
         return(sb.ToString());
     }
 }
コード例 #12
0
        public object Convert(object value, object parameter)
        {
            var d = RenderContext.Current.BelongTemplate.TemplateParent;

            using (var temp = StringPool.Borrow())
            {
                var code = temp.Item;
                code.Append("{rules:{");
                FillRulesCode(d, code);
                code.Append("},");
                code.Append("messages:{");
                FillMessagesCode(d, code);
                code.Append("}}");
                return(code.ToString());
            }
        }
コード例 #13
0
        private string GetColumnTemplateCode(UIElementCollection content)
        {
            string code = string.Empty;

            using (var temp = StringPool.Borrow())
            {
                var sb = temp.Item;
                foreach (UIElement item in content)
                {
                    var ec = XamlUtil.GetCode(item);
                    sb.AppendLine(ec);
                }
                code = sb.ToString();
            }
            return(code);
        }
コード例 #14
0
        public object Convert(object value, object parameter)
        {
            var d      = RenderContext.Current.BelongTemplate.TemplateParent as Dropzone;
            var headrs = d.Headers;

            using (var temp = StringPool.Borrow())
            {
                var code = temp.Item;
                code.Append("{");
                foreach (DropzoneHeader header in headrs)
                {
                    code.AppendFormat("{0}:'{1}',", header.Key, JSON.GetCode(header.Value).Trim('"'));
                }
                code.Append("}");
                return(code.ToString());
            }
        }
コード例 #15
0
        private void DrawColumnTemplate(UIElementCollection content, int columnIndex, PageBrush brush)
        {
            string code = string.Empty;

            using (var temp = StringPool.Borrow())
            {
                var sb = temp.Item;
                sb.AppendLine("<script>");
                sb.AppendFormat("function {0}()", GetTemplateFunction(columnIndex));
                sb.Append("{");
                sb.AppendLine();
                sb.AppendFormat("return {0};", JSON.GetCode(GetColumnTemplateCode(content)));
                sb.AppendLine();
                sb.AppendLine("}");
                sb.Append("</script>");
                code = sb.ToString();
            }
            brush.DrawLine(code, DrawOrigin.Bottom);
        }
コード例 #16
0
        public object Convert(object value, object parameter)
        {
            var modal = RenderContext.Current.BelongTemplate.TemplateParent as Modal;

            using (var temp = StringPool.Borrow())
            {
                var sb = temp.Item;
                sb.Append("modal-dialog");
                if (!string.IsNullOrEmpty(modal.Size))
                {
                    sb.AppendFormat(" modal-{0}", modal.Size);
                }
                if (modal.Center)
                {
                    sb.Append(" modal-dialog-centered");
                }
                return(sb.ToString());
            }
        }
コード例 #17
0
        private string InternalGetCode(bool sequential, bool outputKey, Func <DTEntity, string> getMemberCode)
        {
            using (var temp = StringPool.Borrow())
            {
                StringBuilder code = temp.Item;
                if (outputKey && !string.IsNullOrEmpty(this.Name))
                {
                    code.AppendFormat("\"{0}\"", this.Name);
                }

                if (code.Length > 0)
                {
                    code.Append(":");
                }

                if (this.IsSingleValue())
                {
                    code.Append(getMemberCode(_entities[0]));
                }
                else
                {
                    code.Append("{");

                    IEnumerable <DTEntity> members = sequential ? _entities.OrderBy((m) =>
                    {
                        return(m.Name);
                    }) : (IEnumerable <DTEntity>)_entities;

                    foreach (var member in members)
                    {
                        var memberCode = getMemberCode(member);
                        code.Append(memberCode);
                        code.Append(",");
                    }
                    if (_entities.Count > 0)
                    {
                        code.Length--;
                    }
                    code.Append("}");
                }
                return(code.ToString());
            }
        }
コード例 #18
0
        /// <summary>
        /// 回退字符
        /// </summary>
        /// <param name="count">需要回退的字符个数</param>
        public void Backspace(int count)
        {
            var index = _data.Count - 1;
            var end   = false;

            while (index >= 0)
            {
                using (var temp = StringPool.Borrow())
                {
                    var code = temp.Item;
                    code.Append(_data[index]);

                    while (code.Length > 0)
                    {
                        var c = code[code.Length - 1];
                        if (c == '\r' || c == '\n' || c == ' ')
                        {
                            code.Length--;                                     //自动过滤空白字符
                        }
                        else
                        {
                            code.Length--;
                            count--;

                            if (count == 0)
                            {
                                _data[index] = code.ToString();
                                end          = true;
                                break;
                            }
                        }
                    }
                }

                if (end)
                {
                    break;
                }
                _data.RemoveAt(index); //代码如果能成功运行到此处,代表code已经被减完了,所以移除
                index--;
            }
        }
コード例 #19
0
 private string GetConfigCode()
 {
     using (var temp = StringPool.Borrow())
     {
         var sb = temp.Item;
         sb.Append("{");
         sb.Append("columns:[");
         for (var i = 0; i < this.Columns.Count; i++)
         {
             var column = this.Columns[i] as DataTableColumn;
             FillColumnCode(column, i, sb);
             sb.Append(",");
         }
         if (this.Columns.Count > 0)
         {
             sb.Length--;
         }
         sb.Append("],");
         sb.AppendFormat("pagination:{0}", this.Pagination.ToString().ToLower());
         sb.Append("}");
         return(sb.ToString());
     }
 }
コード例 #20
0
        public void Send(string mobileNumber, string message)
        {
            string uid = ConfigurationManager.AppSettings["sms-name"];
            string pwd = ConfigurationManager.AppSettings["sms-password"];

            using (var temp = StringPool.Borrow())
            {
                var url = temp.Item;

                url.Append("http://service.winic.org/sys_port/gateway/?");
                url.AppendFormat("id={0}", uid);
                url.AppendFormat("&pwd={0}", pwd);
                url.AppendFormat("&to={0}", mobileNumber);
                url.AppendFormat("&content={0}", message);
                url.Append("&time=");

                var data = WebUtil.SendGet(url.ToString());

                string result = System.Text.Encoding.GetEncoding("GB2312").GetString(data).Trim();

                string error = null;
                switch (result)
                {
                case "-01": error = "当前账号余额不足!"; break;

                case "-02": error = "当前用户ID错误!"; break;

                case "-03": error = "当前密码错误!"; break;

                case "-05": error = "手机号码格式不对!"; break;
                }

                if (!string.IsNullOrEmpty(error))
                {
                    throw new ApplicationException(error);
                }
            }



            //____________________________

            //MSXML2.XMLHTTP xmlhttp = new MSXML2.XMLHTTP();

            //xmlhttp.open("GET", Send_URL.ToString(), false, null, null);
            //xmlhttp.send("");
            //MSXML2.XMLDocument dom = new XMLDocument();
            //Byte[] b = (Byte[])xmlhttp.responseBody;

            //string result = System.Text.Encoding.GetEncoding("GB2312").GetString(b).Trim();

            //返回示例
            //-02   /Send:1     /Consumption:0  / Tmoney:0 / sid
            //状态码 / 发送条数 / 当次消费金额 / 总体余额 / 短信编号

            //返回状态码 信息说明
            //000 成送成功!
            //-01 当前账号余额不足!
            //-02 当前用户ID错误!
            //-03 当前密码错误!
            //-04 参数不够或参数内容的类型错误!
            //-05 手机号码格式不对!
            //-06 短信内容编码不对!
            //-07 短信内容含有敏感字符!
            //-8 无接收数据
            //-09 系统维护中..
            //-10 手机号码数量超长!(100个/次 超100个请自行做循环)
            //-11 短信内容超长!(70个字符)
            //-12 其它错误!
            //string error = null;
            //switch (result)
            //{
            //    case "-01": error = "当前账号余额不足!"; break;
            //    case "-02": error = "当前用户ID错误!"; break;
            //    case "-03": error = "当前密码错误!"; break;
            //    case "-05": error = "手机号码格式不对!"; break;
            //}

            //if (!string.IsNullOrEmpty(error)) throw new ApplicationException(error);
        }
コード例 #21
0
        internal string Process(string commandText, DynamicData param)
        {
            if (this.IsEmpty())
            {
                return(commandText);
            }

            //先处理any
            foreach (var any in _anys)
            {
                if (param.ContainsKey(any.ParamName))
                {
                    commandText = commandText.Replace(any.Placeholder, any.Content);
                }
                else
                {
                    commandText = commandText.Replace(any.Placeholder, "0=0"); //没有参数表示永远为真,这里不能替换为空文本,因为会出现where 没有条件的BUG,所以为 where 0=0
                }
            }


            foreach (var like in _likes)
            {
                var name  = like.ParamName;
                var value = param.Get(name) as string;
                if (value == null)
                {
                    continue;                //因为有any语法,所以没有传递参数也正常
                }
                if (like.After && like.Before)
                {
                    param.Set(name, string.Format("%{0}%", value));
                }
                else if (like.After)
                {
                    param.Set(name, string.Format("{0}%", value));
                }
                else if (like.Before)
                {
                    param.Set(name, string.Format("%{0}", value));
                }
            }

            foreach (var sin in _ins)
            {
                var name   = sin.ParamName;
                var values = param.Get(name) as IEnumerable;
                if (values == null)
                {
                    continue;                  //因为有any语法,所以没有传递参数也正常
                }
                param.Remove(name);

                if (values.Exists())
                {
                    using (var temp = StringPool.Borrow())
                    {
                        var code  = temp.Item;
                        int index = 0;
                        code.AppendFormat("{0} in (", sin.Field);
                        foreach (var value in values)
                        {
                            var valueName = string.Format("{0}{1}", name, index);
                            param.Add(valueName, value);
                            code.AppendFormat("@{0},", valueName);
                            index++;
                        }
                        if (code.Length > 1)
                        {
                            code.Length--;
                        }
                        code.Append(")");

                        commandText = commandText.Replace(sin.Placeholder, code.ToString());
                    }
                }
                else
                {
                    commandText = commandText.Replace(sin.Placeholder, "0=1"); //在in语句中,如果 id in (),没有任何匹配的数值条件,那么就是无匹配结果,所以0=1
                }
            }

            return(commandText);
        }