public override System.Data.DataTable Query(We7.Model.Core.PanelContext data, out int recordcount, ref int pageindex) { DataSet ds = CreateDataSet(data.Model); recordcount = GetCount(data); int startindex, itemscount; We7.Framework.Util.Utils.BuidlPagerParam(recordcount, data.PageSize, ref pageindex, out startindex, out itemscount); List <Advice> list = AdviceHelper.Assistant.List <Advice>(CreateCriteria(data), new Order[] { new Order("Updated", OrderMode.Desc) }, startindex, itemscount); foreach (Advice a in list) { if (String.IsNullOrEmpty(a.ModelXml)) { continue; } ReadXml(ds, a.ModelXml); DataRowCollection rows = ds.Tables[data.Table.Name].Rows; if (rows.Count > 0) { rows[rows.Count - 1][OBJECTCOLUMN] = a; } } return(ds.Tables[data.Table.Name]); }
/// <summary> /// 保存当前行记录 /// </summary> /// <param name="ctx">当前数据项</param> public static void SaveContext(PanelContext ctx) { ctx.Row["ID"] = Utils.CreateGUID(); ICommand command = CommandFactory.GetCommand("add"); command.Do(ctx); }
public static PanelContext GetPanelContext(string modelName, string panelName) { ModelInfo model = GetModelInfo(modelName); PanelContext ctx = model[panelName]; ctx.Objects = new Hashtable(); ctx.Row = new DataFieldCollection(); ctx.PageIndex = 0; ctx.Model = model; return(model[panelName]); }
public override bool Update(We7.Model.Core.PanelContext data) { string id = GetValue <string>(data, "ID"); Advice advice = AdviceHelper.GetAdvice(id); if (advice == null) { Insert(data); } else { advice.Title = GetValue <string>(data, "Title"); advice.UserID = GetValue <string>(data, "UserID"); advice.Content = GetValue <string>(data, "Content"); advice.Updated = DateTime.Now; advice.Name = GetValue <string>(data, "Name"); advice.Email = GetValue <string>(data, "Email"); advice.Address = GetValue <string>(data, "Address"); advice.Phone = GetValue <string>(data, "Phone"); advice.Fax = GetValue <string>(data, "Fax"); int isshow; Int32.TryParse(GetValue <string>(data, "IsShow"), out isshow); string stateStr = StateMgr.StateProcess(advice.EnumState, EnumLibrary.Business.AdviceDisplay, isshow); advice.IsShow = isshow; advice.EnumState = stateStr; advice.Display1 = GetValue <string>(data, "Display1"); advice.Display2 = GetValue <string>(data, "Display2"); advice.Display3 = GetValue <string>(data, "Display3"); //下面是添加模型信息 string config, schema; advice.ModelXml = GetModelDataXml(data, advice.ModelXml, out schema, out config);//获取模型数据 advice.ModelConfig = config; advice.ModelName = data.ModelName; advice.ModelSchema = schema; advice.TypeID = data.Objects["AdviceTypeID"] as string; List <string> udpatedFields = new List <string>() { "ModelXml", "ModelName", "ModelSchema", "TypeID", "Title", "UserID", "Content", "Updated", "Name", "Email", "Phone", "Address", "Fax", "Display1", "Display2", "Display3" }; if (!String.IsNullOrEmpty(GetValue <string>(data, "IsShow"))) { udpatedFields.Add("IsShow"); } AdviceHelper.UpdateAdvice(advice, udpatedFields.ToArray()); SetValue(data, "ID", advice.ID); } return(true); }
public override bool Delete(We7.Model.Core.PanelContext data) { try { string adviceid = data.DataKey["ID"] as string; AdviceHelper.DeleteAdvice(adviceid); } catch (Exception ex) { throw ex; } return(true); }
public override bool Insert(We7.Model.Core.PanelContext data) { AdviceInfo advice = new AdviceInfo(); advice.Title = GetValue <string>(data, "Title"); advice.UserID = GetValue <string>(data, "UserID"); advice.Content = GetValue <string>(data, "Content"); advice.Created = DateTime.Now; advice.Name = GetValue <string>(data, "Name"); advice.Email = GetValue <string>(data, "Email"); advice.Address = GetValue <string>(data, "Address"); advice.Phone = GetValue <string>(data, "Phone"); advice.Fax = GetValue <string>(data, "Fax"); advice.RelationID = GetValue <string>(data, "RelationID"); advice.State = 0; //待受理 int isshow; Int32.TryParse(GetValue <string>(data, "IsShow"), out isshow); advice.IsShow = isshow; advice.Display1 = GetValue <string>(data, "Display1"); advice.Display2 = GetValue <string>(data, "Display2"); advice.Display3 = GetValue <string>(data, "Display3"); advice.MyQueryPwd = We7Helper.CreateNewID().Substring(1, 8); //下面是添加模型信息 string config, schema; advice.ModelXml = GetModelDataXml(data, advice.ModelXml, out schema, out config);//获取模型数据 advice.ModelConfig = config; advice.ModelName = data.ModelName; advice.ModelSchema = schema; advice.TypeID = data.Objects["AdviceTypeID"] as string; advice.Public = GetValue <int>(data, "Public"); AdviceFactory.Create().AddAdvice(advice); SetValue(data, "ID", advice.ID); try { AdviceHelper.SendNotifyMail(advice.ID); } catch { } finally { } return(true); }
public override bool Update(We7.Model.Core.PanelContext data) { IAdviceHelper helper = AdviceFactory.Create(); string id = GetValue <string>(data, "ID"); AdviceInfo advice = helper.GetAdvice(id); if (advice == null) { Insert(data); } else { advice.Title = GetValue <string>(data, "Title"); advice.UserID = GetValue <string>(data, "UserID"); advice.Content = GetValue <string>(data, "Content"); advice.Name = GetValue <string>(data, "Name"); advice.Email = GetValue <string>(data, "Email"); advice.Address = GetValue <string>(data, "Address"); advice.Phone = GetValue <string>(data, "Phone"); advice.Fax = GetValue <string>(data, "Fax"); advice.Public = GetValue <int>(data, "Public"); int isshow; Int32.TryParse(GetValue <string>(data, "IsShow"), out isshow); advice.IsShow = isshow; advice.Display1 = GetValue <string>(data, "Display1"); advice.Display2 = GetValue <string>(data, "Display2"); advice.Display3 = GetValue <string>(data, "Display3"); //下面是添加模型信息 string config, schema; advice.ModelXml = GetModelDataXml(data, advice.ModelXml, out schema, out config);//获取模型数据 advice.ModelConfig = config; advice.ModelName = data.ModelName; advice.ModelSchema = schema; advice.TypeID = data.Objects["AdviceTypeID"] as string; helper.UpdateAdvice(advice); SetValue(data, "ID", advice.ID); } return(true); }
public override System.Data.DataRow Get(We7.Model.Core.PanelContext data) { DataRow row = null; string id = data.DataKey["ID"] as string; if (!String.IsNullOrEmpty(id)) { Advice advice = AdviceHelper.GetAdvice(id); if (advice != null && !String.IsNullOrEmpty(advice.ModelXml)) { DataSet ds = CreateDataSet(data.Model); ReadXml(ds, advice.ModelXml); row = ds.Tables[0].Rows.Count > 0 ? ds.Tables[0].Rows[0] : null; if (row != null) { row[OBJECTCOLUMN] = advice; } } } return(row); }
/// <summary> /// 用数据行更新模型数据 /// </summary> /// <param name="data">模型数据</param> /// <param name="row"></param> public static void UpdateFields(PanelContext data, DataRow row) { data.Row.Clear(); if (row == null) { foreach (We7DataColumn field in data.Table.Columns) { data.Row[field] = null; } } else { foreach (We7DataColumn field in data.Table.Columns) { if (field.Direction != ParameterDirection.ReturnValue) { data.Row[field] = row[field.Name]; } } } }
public abstract DataRow Get(We7.Model.Core.PanelContext data);
public UIHelper(Page page, PanelContext ctx) : this(page) { panelContext = ctx; }
public override int GetCount(We7.Model.Core.PanelContext data) { return(HelperFactory.Instance.Assistant.Count <AdviceInfo>(CreateCriteria(data))); }
/// <summary> /// 扩展数据表格 /// </summary> /// <param name="dt"></param> /// <param name="data"></param> public static void ExtendDataTable(DataTable dt, PanelContext data) { ExtendDataTable(dt, data.Table.Columns); }
/// <summary> /// 模型事件参数 /// </summary> /// <param name="commandNamd">命令名称</param> /// <param name="args">命令参数</param> /// <param name="data">模型数据</param> public ModelEventArgs(string commandName, object commandArgs, PanelContext data) { CommandName = commandName; CommandArguments = commandArgs; PanelContext = data; }
public abstract bool Insert(We7.Model.Core.PanelContext data);
public override int GetCount(We7.Model.Core.PanelContext data) { return(AdviceHelper.Assistant.Count <Advice>(CreateCriteria(data))); }
public abstract bool Delete(We7.Model.Core.PanelContext data);
public abstract DataTable Query(We7.Model.Core.PanelContext data, out int recordcount, ref int pageindex);
public abstract int GetCount(We7.Model.Core.PanelContext data);
/// <summary> /// 模型事件参数 /// </summary> /// <param name="commandNamd">命令名称</param> /// <param name="data">模型数据</param> public ModelEventArgs(string commandName, PanelContext data) : this(commandName, "", data) { }
public bool InsertEmailAdvice(We7.Model.Core.PanelContext data) { Advice advice = new Advice(); advice.OwnID = Security.CurrentAccountID; //advice.TypeID = GetAdviceTypeID(data.ModelName); //advice.ID = GetValue<string>(data, "ID"); advice.Title = GetValue <string>(data, "Title"); advice.UserID = GetValue <string>(data, "UserID"); advice.Content = GetValue <string>(data, "Content"); advice.CreateDate = DateTime.Now; advice.Updated = DateTime.Now; advice.Name = GetValue <string>(data, "Name"); advice.Email = GetValue <string>(data, "Email"); advice.Address = GetValue <string>(data, "Address"); advice.Phone = GetValue <string>(data, "Phone"); advice.Fax = GetValue <string>(data, "Fax"); advice.State = (int)AdviceState.WaitAccept; advice.SN = AdviceHelper.CreateArticleSN(); int isshow; Int32.TryParse(GetValue <string>(data, "IsShow"), out isshow); string stateStr = StateMgr.StateProcess(advice.EnumState, EnumLibrary.Business.AdviceDisplay, isshow); advice.IsShow = isshow; advice.EnumState = stateStr; advice.Display1 = GetValue <string>(data, "Display1"); advice.Display2 = GetValue <string>(data, "Display2"); advice.Display3 = GetValue <string>(data, "Display3"); if (advice.SN < 100000) { advice.SN = advice.SN + 100000; } advice.MyQueryPwd = We7Helper.CreateNewID().Substring(1, 8); //下面是添加模型信息 string config, schema; advice.ModelXml = GetModelDataXml(data, advice.ModelXml, out schema, out config);//获取模型数据 advice.ModelConfig = config; advice.ModelName = data.ModelName; advice.ModelSchema = schema; advice.TypeID = GetValue <string>(data, "TypeID"); if (String.IsNullOrEmpty(advice.TypeID)) { AdviceType type = AdviceTypeHelper.GetAdviceTypeByModelName(data.ModelName); if (type != null) { advice.TypeID = type.ID; } } AdviceHelper.AddAdvice(advice); SetValue(data, "ID", advice.ID); try { AdviceHelper.SendNotifyMail(advice.ID); } catch { } finally { } return(true); }
/// <summary> /// 获取导入数据项 /// </summary> /// <param name="modelName">模型名称</param> /// <param name="panelName">面板名称</param> /// <returns></returns> public static DataFieldCollection GetImportRow(string modelName, out PanelContext pctx) { pctx = ModelHelper.GetPanelContext(modelName, "edit"); return(pctx.Row); }