Exemplo n.º 1
0
 public override bool Delete(We7.Model.Core.PanelContext data)
 {
     try
     {
         string adviceid = data.DataKey["ID"] as string;
         AdviceFactory.Create().DeleteAdvice(adviceid);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(true);
 }
        /// <summary>
        /// Registers static interceptors defined by attributes on the specified method.
        /// </summary>
        /// <param name="type">The type whose activation plan is being manipulated.</param>
        /// <param name="method">The method that may be intercepted.</param>
        /// <param name="attributes">The interception attributes that apply.</param>
        protected virtual void RegisterMethodInterceptors(Type type,
                                                          MethodInfo method,
                                                          ICollection <InterceptAttributeBase> attributes)
        {
            foreach (InterceptAttributeBase attribute in attributes)
            {
                IAdvice advice = AdviceFactory.Create(method);

                advice.Callback = attribute.CreateInterceptor;
                advice.Order    = attribute.Order;

                AdviceRegistry.Register(advice);
            }
        }
Exemplo n.º 3
0
 public static IObjectClickHelper Create(string modelName)
 {
     if (string.IsNullOrEmpty(modelName))
     {
         return(HelperFactory.Instance.GetHelper <ArticleHelper>());
     }
     else if (String.Compare(modelName, "Advice", true) == 0)
     {
         return(AdviceFactory.Create() as IObjectClickHelper);
     }
     else
     {
         return(HelperFactory.Instance.GetHelper <ArticleHelper>());
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 添加记录过程
        /// </summary>
        /// <param name="url">文章url</param>
        protected void AddClick(string url)
        {
            //从URL获取文章SN
            string ArticleID = ArticleHelper.GetArticleIDFromURL(url);

            //string ArticleID = ArticleHelper.GetArticleIDBySN(SN);
            if (!string.IsNullOrEmpty(ArticleID))
            {
                //获取文章实体
                Article article = ArticleHelper.GetArticle(ArticleID);
                if (article != null)
                {
                    //保存日记录
                    ClickRecords cr = new ClickRecords();
                    cr.ObjectID   = article.ID;
                    cr.VisitDate  = ClickRecordHelper.ConvertIntegerFromDate(DateTime.Now);
                    cr.ObjectType = String.IsNullOrEmpty(article.ModelName)? "Article" :article.ModelName;
                    ClickRecordHelper.SaveClickRecord(cr);

                    //获取点击量报表
                    Dictionary <string, int> dictReports
                        = ClickRecordHelper.GetObjectClickReport(cr.ObjectType, article.ID);
                    //通过工厂获取具体的Helper
                    IObjectClickHelper helper = ClickHelperFactory.Create(article.ModelName);
                    helper.UpdateClicks(article.ModelName, article.ID, dictReports);
                }
                else
                {
                    AdviceInfo advice = AdviceFactory.Create().GetAdvice(ArticleID);
                    if (advice != null)
                    {
                        //保存日记录
                        ClickRecords cr = new ClickRecords();
                        cr.ObjectID   = advice.ID;
                        cr.VisitDate  = ClickRecordHelper.ConvertIntegerFromDate(DateTime.Now);
                        cr.ObjectType = "Advice";
                        ClickRecordHelper.SaveClickRecord(cr);

                        //获取点击量报表
                        Dictionary <string, int> dictReports
                            = ClickRecordHelper.GetObjectClickReport(cr.ObjectType, advice.ID);

                        IObjectClickHelper helper = ClickHelperFactory.Create(cr.ObjectType);
                        helper.UpdateClicks(cr.ObjectType, cr.ObjectID, dictReports);
                    }
                }
            }
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Clear();
            context.Response.Expires = -1;

            string        pwd    = context.Request["pwd"];
            string        id     = context.Request["id"];
            IAdviceHelper helper = AdviceFactory.Create();
            AdviceInfo    advice = helper.GetAdvice(id);

            if (advice != null && advice.MyQueryPwd == pwd)
            {
                context.Response.Write("true");
            }
            else
            {
                context.Response.Write("false");
            }
        }
Exemplo n.º 8
0
        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))
            {
                AdviceInfo advice = AdviceFactory.Create().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);
        }
Exemplo n.º 9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         string id   = Request["id"];
         string type = Request["type"];
         if (!String.IsNullOrEmpty(id))
         {
             try
             {
                 IAdviceHelper helper = AdviceFactory.Create();
                 AdviceInfo    advice = helper.GetAdvice(id);
                 if (advice != null)
                 {
                     helper.UpdateAdviceState(id, 2);
                     ProccessMsg.Redirect(1, advice.TypeID, "受理成功!");
                 }
                 else
                 {
                     ProccessMsg.Redirect(0, advice.TypeID, "当前记录不存在!");
                 }
             }
             catch (System.Threading.ThreadAbortException ex)
             {
             }
             catch (Exception ex)
             {
                 ProccessMsg.Redirect(0, String.Empty, "应用程序错误!错误原因:" + ex.Message);
             }
         }
         else
         {
             ProccessMsg.Redirect(2, String.Empty, "当前记录不存在!");
         }
     }
 }