コード例 #1
0
ファイル: FieldControl.cs プロジェクト: jiaping/JPCMS
        /// <summary>
        /// 取得当前控件的Param值
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        protected string GetParam(string name)
        {
            string param = Control.Params[name];

            if (String.IsNullOrEmpty(param))
            {
                We7DataColumn dc = PanelContext.DataSet.Tables[0].Columns[Control.Name];
                param = dc != null ? dc.Params[name] : "";
            }
            return(param);
        }
コード例 #2
0
ファイル: InsertHandle.cs プロジェクト: jiaping/JPCMS
        void BuildParameters(StringBuilder sb, DataField df)
        {
            We7DataColumn dc = df.Column;

            if (dc.Direction == ParameterDirection.ReturnValue)
            {
                return;
            }
            string _f0 = AddParameter(df);

            AddSplitString(sb, _f0);
        }
コード例 #3
0
ファイル: BaseHandle.cs プロジェクト: jiaping/JPCMS
        string MakeCondition(Criteria ct)
        {
            StringBuilder _f0 = new StringBuilder();

            // If the CriteraType is None, we don't put this as a condition
            if (ct.Type != CriteriaType.None)
            {
                if (!Columns.Contains(ct.Name))
                {
                    throw new ArgumentException("在数据集中不存在当前字段:" + ct.Name);
                }
                We7DataColumn dc = Columns[ct.Name];
                if (dc.Direction == ParameterDirection.ReturnValue)
                {
                    throw new ArgumentException("不能使用ReturnValue字段作为查询字段:" + ct.Name);
                }

                string t  = Connect.Driver.GetCriteria(ct.Type);
                string pn = AddParameter(dc, ct.Value);
                _f0.Append(String.Format(" {0} {1} {2} ", connect.Driver.FormatField(ct.Adorn, dc.Name, ct.Start, ct.Length), t, pn));
            }

            if (ct.Criterias.Count > 0)
            {
                string _f1 = ct.Mode == CriteriaMode.And ? " AND " : " OR ";
                if (ct.Type != CriteriaType.None)
                {
                    _f0.Append(_f1);
                }

                bool _f2 = ct.Criterias.Count > 1;
                if (_f2)
                {
                    _f0.Append("(");
                }

                _f0.Append(MakeCondition(ct.Criterias[0]));

                for (int i = 1; i < ct.Criterias.Count; i++)
                {
                    Criteria _f3 = ct.Criterias[i];
                    _f0.Append(_f1);
                    _f0.Append(MakeCondition(_f3));
                }

                if (_f2)
                {
                    _f0.Append(")");
                }
            }
            return(_f0.ToString());
        }
コード例 #4
0
ファイル: GetEntityValue.cs プロジェクト: jiaping/JPCMS
 public object Convert(We7DataColumn column, DataRow row, string[] fields, object extobj)
 {
     if (fields != null && fields.Length > 0 & extobj != null)
     {
         Type         type = extobj.GetType();
         PropertyInfo prop = type.GetProperty(fields[0]);
         if (prop != null)
         {
             return(prop.GetValue(extobj, null));
         }
     }
     return(DBNull.Value);
 }
コード例 #5
0
ファイル: BaseWidgetList.cs プロジェクト: jiaping/JPCMS
        /// <summary>
        /// 将字段转为值
        /// </summary>
        /// <param name="modelName"></param>
        /// <param name="field"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        protected object ConvertValue(string modelName, string field, string value)
        {
            ModelInfo model = ModelHelper.GetModelInfo(modelName);
            if (model == null)
                throw new ArgumentException("当前模型[" + modelName + "]不存在。");

            object result = null;
            We7DataColumn dc = model.DataSet.Tables[0].Columns[field];
            if (dc != null)
            {
                result = TypeConverter.StrToObjectByTypeCode(value, dc.DataType);
            }
            return result;
        }
コード例 #6
0
ファイル: BaseHandle.cs プロジェクト: jiaping/JPCMS
        protected string AddParameter(We7DataColumn dc, object v)
        {
            string        _f0 = String.Format("{0}P{1}", Prefix, parametersCount++);
            DataParameter _f1 = new DataParameter();

            _f1.DbType        = ModelDBHelper.ConvertTypeCodeToDbType(dc.DataType);
            _f1.ParameterName = _f0;
            _f1.Value         = v;
            _f1.SourceColumn  = dc.Name;
            _f1.Size          = dc.MaxLength;
            _f1.IsNullable    = dc.Nullable;
            SQL.Parameters.Add(_f1);
            return(_f0);
        }
コード例 #7
0
        string AddParameter(We7DataColumn dc, object v, SqlStatement sql, ref int parametersCount)
        {
            string        _f0 = String.Format("{0}P{1}", Prefix, parametersCount++);
            DataParameter _f1 = new DataParameter();

            _f1.DbType        = ConvertTypeCodeToDbType(dc.DataType);
            _f1.ParameterName = _f0;
            _f1.Value         = v;
            _f1.SourceColumn  = dc.Name;
            _f1.Size          = dc.MaxLength;
            _f1.IsNullable    = true;
            sql.Parameters.Add(_f1);
            return(_f0);
        }
コード例 #8
0
ファイル: ModelControlField.cs プロジェクト: jiaping/JPCMS
 public sealed override void InitializeCell(DataControlFieldCell cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex)
 {
     RowIndex   = rowIndex;
     HeaderText = String.IsNullOrEmpty(Column.Params["lheader"]) ? Column.Label : Column.Params["lheader"];
     if (String.IsNullOrEmpty(HeaderText) && DataSet != null && DataSet.Tables.Count > 0)
     {
         We7DataColumn col = DataSet.Tables[0].Columns[Column.Name];
         if (col != null)
         {
             HeaderText = col.Label;
         }
     }
     base.InitializeCell(cell, cellType, rowState, rowIndex);
     InitializeCell(cell, cellType, rowState);
 }
コード例 #9
0
ファイル: TagFormatConverter.cs プロジェクト: jiaping/JPCMS
        public object Convert(We7DataColumn column, DataRow row, string[] fields, object extobj)
        {
            Type type = extobj.GetType();

            if (type != null)
            {
                string       tagfield = fields != null && fields.Length > 0 ? fields[0] : "Tags";
                PropertyInfo prop     = type.GetProperty(tagfield);
                if (prop != null)
                {
                    string tags = prop.GetValue(extobj, null) as string;
                    return(Format(tags));
                }
            }
            return(String.Empty);
        }
コード例 #10
0
        public static void DealSystemColumn(ColumnInfoCollection cols, ModelInfo model)
        {
            ColumnInfoCollection tplCols = GetTemplateColumns();

            foreach (ColumnInfo col in cols)
            {
                We7DataColumn dc = model.DataSet.Tables[0].Columns[col.Name];
                if (dc != null && dc.IsSystem && dc.List && tplCols[col.Name] != null)
                {
                    col.Expression  = tplCols[col.Name].Expression;
                    col.Params      = tplCols[col.Name].Params;
                    col.Type        = tplCols[col.Name].Type;
                    col.Mapping     = tplCols[col.Name].Mapping;
                    col.ConvertType = tplCols[col.Name].ConvertType;
                }
            }
        }
コード例 #11
0
        void SingleTableLinkTo(PanelContext data, We7DataTable dt, string id)
        {
            DataTable datatables = DbHelper.Query(String.Format("SELECT * FROM [{0}] WHERE [ID]='{1}'", data.Table.Name, id));

            if (datatables.Rows.Count > 0)
            {
                DataRow       row = datatables.Rows[0];
                We7DataColumn dc1 = dt.Columns.IndexOfMappingField("ContentUrl");
                We7DataColumn dc2 = data.Table.Columns.IndexOfMappingField("OwnerID");
                if (dc1 != null && dc2 != null)
                {
                    StringBuilder sbFields = new StringBuilder();
                    StringBuilder sbValues = new StringBuilder();
                    sbFields.Append("[ID],");
                    sbValues.Append("'" + We7Helper.CreateNewID() + "',");

                    Channel ch = HelperFactory.Instance.GetHelper <ChannelHelper>().GetChannel(row[dc2.Name].ToString(), null);
                    sbFields.AppendFormat("[{0}],", dc1.Name);
                    sbValues.AppendFormat("{0},", String.Format("{0}{1}.{2}", ch.FullUrl, We7Helper.GUIDToFormatString(row["ID"].ToString()), GeneralConfigs.GetConfig().UrlFormat));

                    dc1 = dt.Columns.IndexOfMappingField("Title");
                    dc2 = data.Table.Columns.IndexOfMappingField("Title");
                    if (dc1 != null && dc2 != null)
                    {
                        sbFields.AppendFormat("[{0}],", dc1.Name);
                        sbValues.AppendFormat("'{0}',", row[dc2.Name]);
                    }

                    dc1 = dt.Columns.IndexOfMappingField("ContentType");
                    dc2 = data.Table.Columns.IndexOfMappingField("ContentType");
                    if (dc1 != null && dc2 != null)
                    {
                        sbFields.AppendFormat("[{0}],", dc1.Name);
                        sbValues.AppendFormat("{0},", (int)TypeOfArticle.LinkArticle);
                    }

                    Utils.TrimEndStringBuilder(sbFields, ",");
                    Utils.TrimEndStringBuilder(sbValues, ",");
                    string sql = String.Format("INSERT INTO [{0}]({1}) VALUES({2})", dt.Name, sbFields, sbValues);
                    if (DbHelper.CheckTableExits(data.Table.Name))
                    {
                        DbHelper.ExecuteSql(sql);
                    }
                }
            }
        }
コード例 #12
0
ファイル: ListSelectHandle.cs プロジェクト: jiaping/JPCMS
        protected override void Build()
        {
            if (String.IsNullOrEmpty(Fields))
            {
                BuildFields();
            }
            else
            {
                FormatFields();
            }
            if (ConditonCriteria != null)
            {
                BuildCindition();
            }
            else
            {
                Condition = String.Empty;
            }
            List <Order> os = new List <Order>();

            foreach (Order o in OrderList)
            {
                if (!Columns.Contains(o.Name))
                {
                    throw new ArgumentException("数据集中不存在当前字段:" + o.Name);
                }
                We7DataColumn dc = Columns[o.Name];
                if (dc.Direction == ParameterDirection.ReturnValue)
                {
                    throw new ArgumentException("不能使用ReturnValue字段作为排序字段:" + o.Name);
                }
                os.Add(new Order(o.Name, o.Mode));
            }
            if (os.Count == 0 && From <= 0)
            {
                os = BuildOrderList();
            }
            SQL.SqlClause = Connect.Driver.BuildPaging(
                Connect.Driver.FormatTable(ModelTable.Name), Fields, Condition, os, From, Count);
        }
コード例 #13
0
ファイル: MySqlSQLBuilder.cs プロジェクト: jiaping/JPCMS
        StringBuilder BuilderWhereSqlByDataKey(PanelContext data, IDataParameterCollection parameters, string prefix)
        {
            if (data.Panel.Context.DataKeys == null)
            {
                Logger.Error(this.GetType() + "::不存在主键字段");
                throw new Exception("不存在主键");
            }
            StringBuilder sqlwehre = new StringBuilder();

            for (int i = 0; i < data.Panel.Context.DataKeys.Length; i++)
            {
                if (i == 0)
                {
                    sqlwehre.Append(" WHERE ");
                }
                else
                {
                    sqlwehre.Append(" AND ");
                }

                string fieldname = data.Panel.Context.DataKeys[i];
                string paramname = String.Format("@{0}{1}", prefix, fieldname);
                sqlwehre.AppendFormat(" {0}={1} ", fieldname, paramname);
                We7DataColumn column = data.DataSet.Tables[0].Columns[fieldname];
                if (column != null && column.DataType == TypeCode.DateTime)
                {
                    MySqlParameter param = new MySqlParameter(column.Name, MySqlDbType.DateTime);
                    param.Value = data.DataKey[fieldname];
                    parameters.Add(param);
                }
                else
                {
                    parameters.Add(new MySqlParameter(paramname, data.DataKey[fieldname]));
                }
            }
            return(sqlwehre);
        }
コード例 #14
0
ファイル: EditField.aspx.cs プロジェクト: jiaping/JPCMS
        //编辑绑定

        private void EditBind()
        {
            if (Action == ActionType.Edit)
            {
                We7DataColumn column = new We7DataColumn();
                column = Model.DataSet.Tables[0].Columns[FieldName];


                this.FieldNameTextBox.Text             = column.Name;
                this.FieldNameTextBox.Enabled          = false;
                this.FieldDataTypeDropDownList.Enabled = false;
                this.MaxlengthTextBox.Enabled          = false;

                if (!string.IsNullOrEmpty(column.Label))
                {
                    this.FieldLabelTextBox.Text = column.Label;
                }
                else
                {
                    this.FieldLabelTextBox.Text = column.Name;
                }

                try
                {
                    this.FieldDataTypeDropDownList.SelectedValue = column.DataType.ToString();
                    if (column.DataType.ToString().ToLower() == "string")
                    {
                        this.div_maxlength.Visible = true;
                        this.MaxlengthTextBox.Text = column.MaxLength.ToString();
                    }
                    else
                    {
                        this.div_maxlength.Visible = false;
                    }
                }
                catch { this.FieldDataTypeDropDownList.SelectedValue = "String";
                        if (column.DataType.ToString().ToLower() == "string")
                        {
                            this.div_maxlength.Visible = true;
                            this.MaxlengthTextBox.Text = column.MaxLength.ToString();
                        }
                        else
                        {
                            this.div_maxlength.Visible = false;
                        } }

                string[] mappings = GetMappingFileds(Model.Type);
                if (column.Mapping == "Title")
                {
                    //标题
                    TitleCheckBox.Checked = true;
                }

                for (int i = 0; i < mappings.Length; i++)
                {
                    if (!string.IsNullOrEmpty(column.Mapping) && mappings[i].ToLower() == column.Mapping.ToLower())
                    {
                        SearchFieldCheckBox.Checked = true;
                    }
                }
            }
        }
コード例 #15
0
ファイル: EditField.aspx.cs プロジェクト: jiaping/JPCMS
        //保存字段
        protected void Save()
        {
            //获取对应的modelinfo
            ModelInfo modelInfo = ModelHelper.GetModelInfoByName(ModelName);

            if (modelInfo == null)
            {
                return;
            }
            We7DataColumn column = new We7DataColumn();

            column.DataType = (TypeCode)Enum.Parse(typeof(TypeCode), FieldDataTypeDropDownList.SelectedValue, true);

            if (column.DataType == TypeCode.String)
            {
                column.MaxLength = int.Parse(this.MaxlengthTextBox.Text.Trim());
            }
            column.Label = FieldLabelTextBox.Text.Trim();
            column.Name  = FieldNameTextBox.Text.Trim();

            ParameterDirection direction = ParameterDirection.Input;
            string             mapping   = string.Empty;

            if (TitleCheckBox.Checked)
            {
                direction = ParameterDirection.Output;
                if (hasTitle(modelInfo))
                {
                    Messages.ShowError("已经拥有标题项!");
                    return;
                }
                mapping = "Title";
            }
            if (!TitleCheckBox.Checked && SearchFieldCheckBox.Checked)
            {
                int count = 0;
                direction = ParameterDirection.Output;
                mapping   = GetMapping(modelInfo, out count);

                if (string.IsNullOrEmpty(mapping))
                {
                    Messages.ShowError("已经拥有最大查询项:" + count + "!");
                    return;
                }
            }
            column.Direction = direction;
            //column.Require = true;
            column.Mapping = mapping;
            //TODO::tedyding 是否存在Tables 以及多个表
            if (modelInfo.DataSet.Tables == null)
            {
                We7.Model.Core.We7DataTable table = new We7DataTable();
                modelInfo.DataSet.Tables.Add(table);
            }


            modelInfo.DataSet.Tables[0].Columns.AddOrUpdate(column);

            if (string.IsNullOrEmpty(this.FieldNameTextBox.Text.Trim()))
            {
                Messages.ShowError("字段名称不能为空!");
                return;
            }
            bool success = ModelHelper.SaveModelInfo(modelInfo, ModelName);

            if (success)
            {
                if (Action == ActionType.Add)
                {
                    Messages.ShowMessage("添加成功!");
                }
                else if (Action == ActionType.Edit)
                {
                    Messages.ShowMessage("修改成功!");
                }
            }
            else
            {
                if (Action == ActionType.Add)
                {
                    Messages.ShowError("添加失败!");
                }
                else if (Action == ActionType.Edit)
                {
                    Messages.ShowError("修改失败!");
                }
            }
        }
コード例 #16
0
        public string AddSingleDataColumn(string model, string label, string name, string title, string search, string dataType, int maxLength)
        {
            //获取对应的modelinfo
            ModelInfo modelInfo = ModelHelper.GetModelInfoByName(model);

            bool success = false;

            AjaxMessage ajaxMessage = new AjaxMessage();

            ajaxMessage.Success = success;

            if (modelInfo == null)
            {
                ajaxMessage.Message = "模型对象为空!";
                return(JavaScriptConvert.SerializeObject(ajaxMessage));
            }

            if (CheckRepetColumn(modelInfo, delegate(We7DataColumn dc)
            {
                return(dc.Label == label);
            }))
            {
                ajaxMessage.Message = "当前中文名称已存在";
                return(JavaScriptConvert.SerializeObject(ajaxMessage));
            }

            if (CheckRepetColumn(modelInfo, delegate(We7DataColumn dc)
            {
                return(String.Compare(dc.Name, name, true) == 0);
            }))
            {
                ajaxMessage.Message = "当前英文名已存在";
                return(JavaScriptConvert.SerializeObject(ajaxMessage));
            }


            We7DataColumn column = new We7DataColumn();

            column.DataType = (TypeCode)Enum.Parse(typeof(TypeCode), dataType, true);
            if (column.DataType == TypeCode.String)
            {
                column.MaxLength = maxLength;
            }
            ParameterDirection direction = ParameterDirection.Input;
            string             mapping   = string.Empty;

            if (title == "true")
            {
                direction = ParameterDirection.Output;
                if (hasTitle(modelInfo))
                {
                    ajaxMessage.Message = "已经拥有标题项!";
                    return(JavaScriptConvert.SerializeObject(ajaxMessage));
                }
                mapping = "Title";
            }
            if (title != "true" && search == "true")
            {
                int count = 0;
                direction = ParameterDirection.Output;
                mapping   = GetMapping(modelInfo, out count);

                if (string.IsNullOrEmpty(mapping))
                {
                    ajaxMessage.Message = "已经拥有最大查询项:" + count.ToString();
                    return(JavaScriptConvert.SerializeObject(ajaxMessage));
                }
            }
            column.Direction = direction;
            column.Label     = label;
            column.Name      = name;
            //column.Require = true;
            column.Mapping = mapping;


            //TODO::tedyding 是否存在Tables 以及多个表
            if (modelInfo.DataSet.Tables == null)
            {
                We7.Model.Core.We7DataTable table = new We7DataTable();
                modelInfo.DataSet.Tables.Add(table);
            }

            modelInfo.DataSet.Tables[0].Columns.AddOrUpdate(column);


            success = ModelHelper.SaveModelInfo(modelInfo, model);
            if (success)
            {
                ajaxMessage.Success = success;
                ajaxMessage.Message = "添加成功!";
            }
            else
            {
                ajaxMessage.Message = "添加失败!";
            }
            return(JavaScriptConvert.SerializeObject(ajaxMessage));
        }
コード例 #17
0
ファイル: SearchBar.cs プロジェクト: jiaping/JPCMS
        string GetMapping(string key)
        {
            We7DataColumn dc = ctx.Model.DataSet.Tables[0].Columns[key];

            return(dc != null && !string.IsNullOrEmpty(dc.Mapping) ? dc.Mapping : key);
        }