예제 #1
0
        public override object Do(PanelContext data)
        {
            string         tag      = data.Objects["tag"] as string;
            List <DataKey> dataKeys = data.State as List <DataKey>;

            if (!String.IsNullOrEmpty(tag) && dataKeys != null)
            {
                foreach (DataKey key in dataKeys)
                {
                    string  id = key["ID"] as string;
                    Article a  = ArticleHelper.GetArticle(id, null);
                    if (a != null)
                    {
                        a.Tags += String.Format("'{0}'", tag);
                        if (!String.IsNullOrEmpty(a.ModelXml))
                        {
                            DataSet ds = BaseDataProvider.CreateDataSet(data.Model);
                            BaseDataProvider.ReadXml(ds, a.ModelXml);

                            if (ds.Tables[data.Table.Name].Rows.Count > 0 && ds.Tables[data.Table.Name].Columns.Contains("Tags"))
                            {
                                ds.Tables[data.Table.Name].Rows[0]["Tags"] = a.Tags;
                                a.ModelXml = BaseDataProvider.GetXml(ds);
                            }
                        }

                        AddTagToSingleTable(data, id, a.Tags);
                        ArticleHelper.UpdateArticle(a, new string[] { "Tags", "ModelXml" });
                    }
                }
            }
            UIHelper.SendMessage("添加标签成功");
            CacheRecord.Create(data.ModelName).Release();
            return(false);
        }
예제 #2
0
        public override object Do(PanelContext data)
        {
            try
            {
                List <DataKey> dataKeys = data.State as List <DataKey>;
                if (dataKeys != null)
                {
                    foreach (DataKey key in dataKeys)
                    {
                        string  id = key["ID"] as string;
                        Article a  = ArticleHelper.GetArticle(id, null);

                        if (a != null && a.State != 2)
                        {
                            a.State = 0;

                            if (!String.IsNullOrEmpty(a.ModelXml))
                            {
                                DataSet ds = BaseDataProvider.CreateDataSet(data.Model);
                                BaseDataProvider.ReadXml(ds, a.ModelXml);

                                if (ds.Tables[data.Table.Name].Rows.Count > 0 && ds.Tables[data.Table.Name].Columns.Contains("State"))
                                {
                                    ds.Tables[data.Table.Name].Rows[0]["State"] = 0;
                                    a.ModelXml = BaseDataProvider.GetXml(ds);
                                }
                            }
                            if (DbHelper.CheckTableExits(data.Table.Name))
                            {
                                DbHelper.ExecuteSql(String.Format("UPDATE [{0}] SET [State]=0 WHERE [ID]='{1}'", data.Table.Name, id));
                            }
                            ArticleHelper.UpdateArticle(a, new string[] { "State", "ModelXml" });
                        }
                    }
                }
                UIHelper.SendMessage("取消发布成功");
                CacheRecord.Create(data.ModelName).Release();
            }
            catch (Exception ex)
            {
                UIHelper.SendError("取消发布失败:" + ex.Message);
            }
            return(null);
        }
예제 #3
0
        /// <summary>
        /// 更新模型xml
        /// </summary>
        /// <returns></returns>
        public static void UpdataModel(IQueryCondition condition)
        {
            string ModelXml = condition.HasModelXml;  //数据模型信息

            if (!string.IsNullOrEmpty(ModelXml) && condition.OperType == Enum_operType.Update)
            {
                List <string> list = new List <string>(condition.Fields);
                list.Add(ModelXml);
                if (!list.Contains(condition.PriMaryKeyName))
                {
                    list.Add(condition.PriMaryKeyName);                                           //加上主键
                }
                MoldPanel    mp   = new MoldPanel();
                PanelContext data = mp.GetPanelContext(condition.ModelName, "list");  //设置为List类型(暂时写死)

                Criteria criteria = new Criteria(CriteriaType.None);
                criteria.Mode = CriteriaMode.Or;
                foreach (var item in condition.ID.Split(','))
                {
                    criteria.AddOr(CriteriaType.Equals, condition.PriMaryKeyName, item);
                }

                TableInfo tableinfo = new TableInfo(data.Model.Type.ToString());

                var       tablelist = getDataBase(tableinfo).IDatabase.GetDtByCondition <TableInfo>(data.Model.Type.ToString(), criteria, list.ToArray()); //获取对应字段,的table信息
                DataTable dt        = null != tablelist ? tablelist[0].Table : null;

                condition.OperType = Enum_operType.Update; //设为修改类型
                foreach (DataRow item in dt.Rows)
                {
                    if (item[ModelXml] != DBNull.Value && item != null)
                    {
                        List <FieldsDic> Fileds = new List <FieldsDic>();        // 最终字典

                        DataSet ds = BaseDataProvider.CreateDataSet(data.Model); //穿件数据集
                        BaseDataProvider.ReadXml(ds, item[ModelXml].ToString());

                        var files = condition.ConditionDic; //获取到的字典

                        if (!files.Exists(delegate(FieldsDic f) { if (string.Compare(f.Key, ModelXml, true) == 0)
                                                                  {
                                                                      return(true);
                                                                  }
                                                                  else
                                                                  {
                                                                      return(false);
                                                                  } }))                                                                                   //添加XML扩展字段
                        {
                            files.Add(new FieldsDic(ModelXml, string.Empty));
                        }
                        foreach (var file in files)
                        {
                            if (!file.Key.ToUpper().Equals(condition.PriMaryKeyName) && ds.Tables[data.Table.Name].Columns.Contains(file.Key))
                            {
                                ds.Tables[data.Table.Name].Rows[0][file.Key] = file.Value; //赋值
                                if (!Fileds.Exists(delegate(FieldsDic f) { if (string.Compare(f.Key, condition.HasModelXml, true) == 0)
                                                                           {
                                                                               return(true);
                                                                           }
                                                                           else
                                                                           {
                                                                               return(false);
                                                                           } }))
                                {
                                    files.Add(new FieldsDic(file.Key, file.Value));
                                }
                            }
                        }

                        Fileds.Find(delegate(FieldsDic f) {
                            if (string.Compare(f.Key, ModelXml, true) == 0)
                            {
                                f.Value = BaseDataProvider.GetXml(ds);    //拿到XML 赋值
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        });

                        TableInfo ti = new TableInfo(data.Model.Type.ToString(), item[condition.PriMaryKeyName].ToString(), Fileds);
                        list.Remove(condition.PriMaryKeyName);
                        TryUpData(condition, list, ti, data.Model.Type.ToString(), true);
                    }
                }
                QueryCondition.SetMessage(condition, "模型字段:" + condition.HasModelXml, false, "修改", string.Empty, dt.Rows.Count);
            }
        }
예제 #4
0
        public override object Do(PanelContext data)
        {
            string oid = data.Objects["oid"] as string;

            if (We7Helper.IsEmptyID(oid))
            {
                throw new Exception("不能移动到根栏目");
            }

            ChannelHelper chHelper = HelperFactory.GetHelper <ChannelHelper>();
            Channel       channel  = chHelper.GetChannel(oid, null);

            if (channel == null)
            {
                throw new Exception("当前栏目不存在");
            }
            if (channel.ModelName != data.ModelName)
            {
                throw new Exception("移动到的栏目类型与当前栏目类型不一致");
            }

            if (!string.IsNullOrEmpty(oid))
            {
                List <DataKey> dataKeys = data.State as List <DataKey>;
                foreach (DataKey key in dataKeys)
                {
                    string  id = key["ID"] as string;
                    Article a  = ArticleHelper.GetArticle(id);
                    if (a != null)
                    {
                        DataSet ds = BaseDataProvider.CreateDataSet(data.Model);
                        BaseDataProvider.ReadXml(ds, a.ModelXml);
                        if (ds.Tables[data.Table.Name].Rows.Count > 0)
                        {
                            DataRow row = ds.Tables[data.Table.Name].Rows[0];
                            a.OwnerID = oid;
                            if (row.Table.Columns.Contains("OwnerID"))
                            {
                                row["OwnerID"] = oid;
                            }
                            Channel ch = ChannelHelper.GetChannel(oid, null);
                            if (ch != null)
                            {
                                a.ChannelFullUrl = ch.FullUrl;
                                if (row.Table.Columns.Contains("ChannelFullUrl"))
                                {
                                    row["ChannelFullUrl"] = a.ChannelFullUrl;
                                }
                                a.ChannelName = ch.FullPath;
                                if (row.Table.Columns.Contains("ChannelName"))
                                {
                                    row["ChannelName"] = a.ChannelName;
                                }
                                a.FullChannelPath = ch.FullFolderPath;
                                if (row.Table.Columns.Contains("FullChannelPath"))
                                {
                                    row["FullChannelPath"] = a.FullChannelPath;
                                }
                            }
                            a.ModelXml = BaseDataProvider.GetXml(ds);
                        }
                    }
                    if (DbHelper.CheckTableExits(data.Table.Name))
                    {
                        DbHelper.ExecuteSql(String.Format("UPDATE [{0}] SET [OwnerID]='{2}' WHERE [ID]='{1}'", data.Table.Name, id, oid));
                    }
                    ArticleHelper.UpdateArticle(a, new string[] { "ID", "OwnerID", "ChannelFullUrl", "ChannelName", "FullChannelPath", "ModelXml" });
                    // 往全文检索里更新数据
                    ArticleIndexHelper.InsertData(id, 1);
                }
            }
            UIHelper.SendMessage("移动成功");
            CacheRecord.Create(data.ModelName).Release();
            return(null);
        }