Exemple #1
0
        public object Do(PanelContext data)
        {
            ModelDBHelper subHelper = ModelDBHelper.Create(data.ModelName);
            DataTable     db        = subHelper.Query(new Criteria(CriteriaType.Equals, "ID", data.DataKey.Value), new List <Order> {
                new Order("ID")
            });

            DbProvider.Instance(data.Model.Type).Delete(data);
            foreach (We7Control ctrl in ModelHelper.GetPanelContext(data.ModelName, "edit").Panel.EditInfo.Controls)
            {
                if (!string.IsNullOrEmpty(ctrl.Params["count"]))
                {
                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic.Add(string.Format("{0}_Count", data.Model.Name),
                            subHelper.Count(new Criteria(CriteriaType.Equals, ctrl.Name, db.Rows[0][ctrl.Name])));
                    ModelDBHelper helper = ModelDBHelper.Create(ctrl.Params["model"]);
                    helper.Update(dic, new Criteria(CriteriaType.Equals, ctrl.Params["valuefield"], db.Rows[0][ctrl.Name]));
                }
                string fileurl = HttpContext.Current.Server.MapPath(db.Rows[0][ctrl.Name].ToString());
                if (ctrl.Type == "MultiUploadify" && File.Exists(fileurl))
                {
                    File.Delete(fileurl);
                    File.Delete(fileurl.Insert(fileurl.LastIndexOf('.'), "_thumb"));
                }
            }
            CacheRecord.Create(data.ModelName).Release();
            return(null);
        }
Exemple #2
0
        /// <summary>
        /// 执行操作
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public object Do(PanelContext data)
        {
            ModelDBHelper  subHelper = ModelDBHelper.Create(data.ModelName);
            List <DataKey> dataKeys  = data.State as List <DataKey>;

            if (dataKeys.Count == 0)
            {
                return(null);
            }
            DataTable db = subHelper.Query(new Criteria(CriteriaType.Equals, "ID", dataKeys[0].Value), new List <Order> {
                new Order("ID")
            });
            ModelDBHelper temhelper     = null;
            string        columnMapping = string.Empty;

            if (dataKeys != null)
            {
                foreach (We7DataColumn column in data.DataSet.Tables[0].Columns)
                {
                    if (column.Name.Contains("_Count"))
                    {
                        temhelper     = ModelDBHelper.Create(data.Model.GroupName + "." + column.Name.Remove(column.Name.IndexOf("_Count")));
                        columnMapping = column.Mapping;
                    }
                }
                foreach (DataKey key in dataKeys)
                {
                    if (temhelper != null)
                    {
                        DataTable dt = subHelper.Query(new Criteria(CriteriaType.Equals, "ID", key.Value), new List <Order> {
                            new Order("ID")
                        });
                        temhelper.Delete(new Criteria(CriteriaType.Equals, columnMapping.Split('|')[0], dt.Rows[0][columnMapping.Split('|')[1]]));
                    }
                    data.DataKey = key;
                    DbProvider.Instance(data.Model.Type).Delete(data);
                }
                data.DataKey = null;
            }
            foreach (We7Control ctrl in ModelHelper.GetPanelContext(data.ModelName, "edit").Panel.EditInfo.Controls)
            {
                if (!string.IsNullOrEmpty(ctrl.Params["count"]))
                {
                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic.Add(string.Format("{0}_Count", data.Model.Name),
                            subHelper.Count(new Criteria(CriteriaType.Equals, ctrl.Name, db.Rows[0][ctrl.Name])));
                    ModelDBHelper helper = ModelDBHelper.Create(ctrl.Params["model"]);
                    helper.Update(dic, new Criteria(CriteriaType.Equals, ctrl.Params["valuefield"], db.Rows[0][ctrl.Name]));
                }
                string fileurl = HttpContext.Current.Server.MapPath(db.Rows[0][ctrl.Name].ToString());
                if (ctrl.Type == "MultiUploadify" && File.Exists(fileurl))
                {
                    File.Delete(fileurl);
                    File.Delete(fileurl.Insert(fileurl.LastIndexOf('.'), "_thumb"));
                }
            }
            CacheRecord.Create(data.ModelName).Release();
            return(null);
        }
Exemple #3
0
        public void ModelSort(string model, string data)
        {
            ModelDBHelper helper            = ModelDBHelper.Create(model);
            Dictionary <string, object> dic = new Dictionary <string, object>();

            foreach (string d in data.Split('|'))
            {
                string[] dd = d.Split(':');
                if (dd.Length != 2)
                {
                    continue;
                }
                dic.Clear();
                dic.Add("Index", dd[1]);
                helper.Update(dic, new Criteria(CriteriaType.Equals, "ID", dd[0]));
            }
        }
Exemple #4
0
        public object Do(PanelContext data)
        {
            DbProvider.Instance(data.Model.Type).Insert(data);
            foreach (We7Control ctrl in data.Panel.EditInfo.Controls)
            {
                if (!string.IsNullOrEmpty(ctrl.Params["count"]))
                {
                    Dictionary <string, object> dic = new Dictionary <string, object>();
                    dic.Add(string.Format("{0}_Count", data.Model.Name), ModelDBHelper.Create(data.ModelName).Count(new Criteria(CriteriaType.Equals, ctrl.Name, data.Row[ctrl.Name])));
                    ModelDBHelper helper = ModelDBHelper.Create(ctrl.Params["model"]);
                    helper.Update(dic, new Criteria(CriteriaType.Equals, ctrl.Params["valuefield"], data.Row[ctrl.Name]));
                }
            }

            CacheRecord.Create(data.ModelName).Release();
            return(null);
        }
Exemple #5
0
        protected override void OnInitData()
        {
            ModelDBHelper helper = ModelDBHelper.Create(ModelName);
            Criteria      c      = CreateEntryCriteria();
            DataTable     dt     = helper.Query(CreateEntryCriteria(), CreateOrders(), 0, 0);

            Item = dt.Rows.Count > 0 ? dt.Rows[0] : dt.NewRow();

            //更新点击次数
            if (dt.Columns.Contains("Clicks"))
            {
                Dictionary <string, object> dic = new Dictionary <string, object>();
                int clicks = Item["Clicks"].Equals(DBNull.Value) ? 0 : Convert.ToInt32(Item["Clicks"]);
                clicks++;
                dic.Add("Clicks", clicks);
                helper.Update(dic, c);
            }
        }
Exemple #6
0
        protected override void OnInitData()
        {
            ModelDBHelper helper = ModelDBHelper.Create(ModelName);
            Criteria      c      = CreateEntryCriteria();
            DataTable     dt     = helper.Query(c, CreateOrders(), 0, 0, Fields);

            if (null != dt)
            {
                JoinEx               joinex  = new JoinEx();
                MoldPanel            mp      = new MoldPanel();
                ColumnInfoCollection columns = mp.GetPanelContext(ModelName, "list").Panel.ListInfo.Groups[0].Columns;
                foreach (ColumnInfo item in columns)
                {
                    if (!string.IsNullOrEmpty(item.Params["model"]))
                    {
                        joinex.JoinInfo.Add(item.Name, new JoinEx()
                        {
                            MainField = item.Name, PriMaryKeyName = item.Params["valuefield"], ToField = item.Params["textfield"], ToTableName = item.Params["model"]
                        });
                    }
                }
                if (joinex.JoinInfo != null && joinex.JoinInfo.Count > 0)
                {
                    DataBaseAssistant db = new DataBaseAssistant();
                    dt = db.Join(dt, joinex);
                }
            }

            /*end*/
            Item = dt != null && dt.Rows.Count > 0 ? dt.Rows[0] : dt.NewRow();

            //更新点击次数
            if (dt.Columns.Contains("Clicks"))
            {
                Dictionary <string, object> dic = new Dictionary <string, object>();
                int clicks = Item["Clicks"].Equals(DBNull.Value) ? 0 : Convert.ToInt32(Item["Clicks"]);
                clicks++;
                dic.Add("Clicks", clicks);
                helper.Update(dic, c);
            }
        }