예제 #1
0
 /// <summary>
 /// 发布文章任务
 /// </summary>
 private void RunBase_Publish(object args)
 {
     while (true)
     {
         if (this.Stopped)
         {
             break;
         }
         WebSiteHelper model = null;
         lock (queuePublishItem) {
             if (queuePublishItem.Count > 0)
             {
                 model = queuePublishItem.Dequeue();
             }
         }
         if (model != null)
         {
             if (!listPublishItem.Contains(model))
             {
                 listPublishItem.Add(model);
                 PublishTask PublishTask = new PublishTask();
                 PublishTask.PublishOP = PublishOP;
                 PublishTask.OverOP    = OverOP;
                 PublishTask.ThreadSendContent(model);
             }
         }
         Thread.Sleep(100);
     }
 }
예제 #2
0
        //請求授權時執行
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            //獲得url請求裡的controller和action
            string controllerName =
                filterContext.RouteData.Values["controller"].ToString().ToString();
            Feature feature = WebSiteHelper.GetFeature();

            featureAccess = false;
            switch (controllerName)
            {
            case "Infors":
                if (feature.FeatInfor)
                {
                    featureAccess = true;
                }
                break;

            case "LogRecords":
                if (feature.FeatLogRec)
                {
                    featureAccess = true;
                }
                break;

            default:
                break;
            }


            base.OnAuthorization(filterContext);//進入AuthorizeCore
        }
예제 #3
0
        public ActionResult Login([Bind(Include = "Name,Password")] Member m)
        {
            //驗證帳密
            var member = accountService.Login(m);

            if (member != null)
            {
                //Authenticaion
                WebSiteHelper.Authentication(member);
                //Authenticaion



                if (!member.Name.Equals("admin"))
                {
                    string controllerName = WebSiteHelper.GetFeature(member.Name).GetFirstAccessFeature();
                    if (controllerName != null)
                    {
                        return(RedirectToAction("Index", controllerName));
                    }
                    else
                    {
                        return(RedirectToAction("Logout", "Home"));
                    }
                }
                return(RedirectToAction("Index", "Members"));
            }
            else
            {
                ViewBag.errorMsg = "wrong name or password";
            }
            return(View());
        }
예제 #4
0
 public ActionResult Login(string username, string password, int isPersistent = 0)
 {
     using (BasicDB db = new BasicDB(false))
     {
         if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
         {
             ViewBag.Error = "The username and password can not be empty";
         }
         else
         {
             MldAdmin model = adminDal.Query("name=@1 and pwd=@2", username, Common.Encryption.GetAdminPwd(password));
             if (model != null)
             {
                 if (model.IsLock == 1)
                 {
                     ViewBag.Error = "Sorry, your account has been locked up";
                 }
                 else
                 {
                     WebSiteHelper.Login(model.Name, ((EnumAdminRole)model.Rid).ToString(), Convert.ToBoolean(isPersistent));
                     model.LastLoginTime = DateTime.Now;
                     model.LastLoginIP   = HttpHelper.Context.Request.UserHostAddress;
                     adminDal.Update(model);
                     return(Redirect("/WebAdmin/Home/Welcome"));
                 }
             }
             else
             {
                 ViewBag.Error = "The username or password is incorrect, please reenter it";
             }
         }
     }
     return(View());
 }
        /// <summary>
        /// 网站编辑加载
        /// </summary>
        private void Bind_DataEdit(string UUId)
        {
            WebSiteHelper model = Common.GetList <WebSiteHelper>(p => p.Uuid == UUId).SingleOrDefault();

            this.txtID.Text = model.Uuid.ToString();
            //this.txtClassID.Text = model.ClassID.ToString();
            this.cmbClassID.SelectedValue = model.ClassID.ToString();
            this.txtWebSiteName.Text      = model.WebSiteName;
            this.txtWebSiteUrl.Text       = model.WebSiteUrl;
            this.txtWebSiteLoginUrl.Text  = model.WebSiteLoginUrl;
            this.txtLoginUserName.Text    = model.LoginUserName;
            this.txtLoginUserPwd.Text     = model.LoginUserPwd;
            this.cmbPublishName.Text      = model.PublishName;
            //this.txtCookiesValue.Text = model.CookiesValue;
            //this.txtIsCookie.Text = model.IsCookie.ToString();
            //this.txtStatus.Text = model.Status.ToString();
            this.chkIsLinkPic.Checked      = model.IsLinkPic.ToString() == "1" ? true : false;
            this.chkIsLinkWord.Checked     = model.IsLinkWord.ToString() == "1" ? true : false;
            this.chkIsLinkPdf.Checked      = model.IsLinkPdf.ToString() == "1" ? true : false;
            this.chkIsLinkVideo.Checked    = model.IsLinkVideo.ToString() == "1" ? true : false;
            this.chkIsTitleFalse.Checked   = model.IsTitleFalse.ToString() == "1" ? true : false;
            this.chkIsContentFalse.Checked = model.IsContentFalse.ToString() == "1" ? true : false;
            this.chkIsAddTask.Checked      = model.IsAddTask.ToString() == "1" ? true : false;
            //

            int DataSourceType = model.DataSourceType.Value;

            if (DataSourceType == 1)
            {
                this.rbtnDataSourceType1.Checked = true;
            }
            if (DataSourceType == 2)
            {
                this.rbtnDataSourceType2.Checked = true;
            }
            if (DataSourceType == 3)
            {
                this.rbtnDataSourceType3.Checked = true;
            }
            if (DataSourceType == 4)
            {
                this.rbtnDataSourceType4.Checked = true;
            }
            this.cmbDataType.Text       = model.DataType;
            this.txtDataLinkUrl.Text    = model.DataLinkUrl;
            this.txtDataQuerySQL.Text   = model.DataQuerySQL;
            this.txtFileSourcePath.Text = model.FileSourcePath;


            this.chkStatus.Checked = model.Status == 1 ? true : false;
        }
예제 #6
0
        /// <summary>
        /// 发布文章
        /// </summary>
        /// <param name="model"></param>
        public void ThreadSendContent(WebSiteHelper model)
        {
            ModelWebSite = model;
            int DataSourceType = ModelWebSite.DataSourceType.Value;

            if (DataSourceType == 2)
            {
                MeOutPut.Message = string.Format("网站名称:{0} 网站地址:{1} 信息:{2} 发布失败!",
                                                 ModelWebSite.WebSiteName, ModelWebSite.WebSiteUrl, "索引获取数据接口正在开发中..,");
                PublishOP(this, MeOutPut);
                return;
            }
            SendArticleContentClassList(DataSourceType);
        }
예제 #7
0
        private void SendArticleContent(WebSiteHelper model, string Title, string Content, string ClassName, string ClassID)
        {
            ModelWebSite = model;
            try {
                LoadPublishModule(ModelWebSite.PublishName);
                if (iPublish != null)
                {
                    //OutFalseOriginal(ref Title, ref Content);
                    Title   = Title.Replace("'", "''");
                    Content = Content.Replace("'", "''");

                    mGatherItem         = new ModelGatherItem();
                    mGatherItem.Title   = Title;
                    mGatherItem.Content = Content;

                    mClassList           = new ModelClassItem();
                    mClassList.ClassID   = ClassID;
                    mClassList.ClassName = ClassName;

                    iPublish.Publish_OutResult = OPR_SendData;
                    iPublish.Publish_Init(ModelWebSite.WebSiteUrl,
                                          ModelWebSite.WebSiteLoginUrl,
                                          ModelWebSite.LoginUserName,
                                          ModelWebSite.LoginUserPwd,
                                          0,
                                          string.Empty);
                    iPublish.Publish_Type = PublishType.PostData;
                    iPublish.Publish_PostData(mGatherItem, mClassList);
                }
                else
                {
                    MeOutPut.Message = string.Format("插件不存在!或者插件有误!");
                    if (PublishOP != null)
                    {
                        PublishOP(this, MeOutPut);
                    }
                }
            }
            catch (Exception ex) {
                MeOutPut.Message = string.Format("网站名称:{0} 网站地址:{1} 信息:{2} 发布失败!",
                                                 ModelWebSite.WebSiteName, ModelWebSite.WebSiteUrl, ex.Message);
                if (PublishOP != null)
                {
                    PublishOP(this, MeOutPut);
                }
            }
        }
예제 #8
0
        /// <summary>
        /// 发布信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void backgroundWorker_Send_DoWork(object sender, DoWorkEventArgs e)
        {
            try {
                this.btnSave.Invoke(new MethodInvoker(delegate() {
                    this.Save_CheckBoxList();
                    int num = 0;
                    for (int i = 0; i < checkedListBox_WebSiteClassList.Items.Count; i++)
                    {
                        if (checkedListBox_WebSiteClassList.GetItemChecked(i))
                        {
                            num++;
                            ModelWebSiteChecked model = (ModelWebSiteChecked)this.checkedListBox_WebSiteClassList.Items[0];
                            string[] ArrValue         = model.Value.Split(new string[] { "→" }, StringSplitOptions.None);
                            WebSiteHelper ModelSite   = Common.GetList <WebSiteHelper>(p => p.Uuid == ArrValue[1]).SingleOrDefault();
                            string[] ArrClassName     = model.Name.Split(new string[] { "→" }, StringSplitOptions.None);

                            ListItem LiClassList    = new ListItem(ArrValue[2], ArrClassName[2]);
                            PublishTask PublishTask = new PublishTask();
                            PublishTask.PublishOP   = PublishOP;
                            PublishTask.CommonSendContent(ModelSite, this.Title, this.Content, LiClassList.Text, LiClassList.Value);
                        }
                    }
                    if (num == 0)
                    {
                        if (MessageBox.Show("你没有选择一个选择保存文章!确定要这样!", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.OK)
                        {
                            this.Close();
                            this.Dispose();
                        }
                    }
                    else
                    {
                        this.Close();
                        this.Dispose();
                    }
                }));
            }
            catch (Exception ex) {
                MessageBox.Show("文章发布出错!" + ex.Message + ex.InnerException + ex.StackTrace + ex.Source,
                                "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                Log4Helper.Write(LogLevel.Error, ex);
            }
        }
예제 #9
0
        protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
        {
            Feature feature        = WebSiteHelper.GetFeature();
            string  controllerName = feature.GetFirstAccessFeature();

            if (controllerName != null)
            {
                //導到別頁
                filterContext.HttpContext.Response.RedirectToRoute(new { controller = controllerName, action = "Index" });
            }
            else
            {
                //用URL
                filterContext.HttpContext.Response.Redirect("~/Home/Logout");
            }


            //filterContext.Result = new ViewResult { ViewName = AuthorizationFailView };
        }
        /// <summary>
        /// 提交窗体
        /// </summary>
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            errorProvider.Clear();
            if (string.IsNullOrEmpty(this.cmbClassID.Text))
            {
                errorProvider.SetError(this.cmbClassID, "站群分类不能为空!");
                return;
            }

            if (string.IsNullOrEmpty(this.txtWebSiteName.Text))
            {
                errorProvider.SetError(this.txtWebSiteName, "网站名称不能为空!");
                return;
            }

            if (string.IsNullOrEmpty(this.txtWebSiteUrl.Text))
            {
                errorProvider.SetError(this.txtWebSiteUrl, "网站地址不能为空!");
                return;
            }

            if (string.IsNullOrEmpty(this.txtWebSiteLoginUrl.Text))
            {
                errorProvider.SetError(this.txtWebSiteLoginUrl, "网站后台目录不能为空!");
                return;
            }

            if (string.IsNullOrEmpty(this.cmbPublishName.Text))
            {
                errorProvider.SetError(this.cmbPublishName, "网站发布模块需要选择!");
                return;
            }

            if (string.IsNullOrEmpty(this.txtLoginUserName.Text))
            {
                errorProvider.SetError(this.txtLoginUserName, "网站登录用户名不能为空!");
                return;
            }

            if (string.IsNullOrEmpty(this.txtLoginUserPwd.Text))
            {
                errorProvider.SetError(this.txtLoginUserPwd, "网站登录密码不能为空!");
                return;
            }

            WebSiteHelper model = new WebSiteHelper();
            string        UUID  = this.txtID.Text;

            if (!string.IsNullOrEmpty(UUID))
            {
                model = Common.GetList <WebSiteHelper>(p => p.Uuid == this.txtID.Text).SingleOrDefault();
            }
            model.ID              = 0;
            model.ClassID         = this.cmbClassID.SelectedValue.ToString();
            model.WebSiteName     = this.txtWebSiteName.Text;
            model.WebSiteUrl      = this.txtWebSiteUrl.Text;
            model.WebSiteLoginUrl = this.txtWebSiteLoginUrl.Text;
            model.PublishName     = this.cmbPublishName.Text;
            model.LoginUserName   = this.txtLoginUserName.Text;
            model.LoginUserPwd    = this.txtLoginUserPwd.Text;
            //
            model.IsLinkPic      = this.chkIsLinkPic.Checked ? 1 : 0;
            model.IsLinkWord     = this.chkIsLinkWord.Checked ? 1 : 0;
            model.IsLinkPdf      = this.chkIsLinkPdf.Checked ? 1 : 0;
            model.IsLinkVideo    = this.chkIsLinkVideo.Checked ? 1 : 0;
            model.IsTitleFalse   = this.chkIsTitleFalse.Checked ? 1 : 0;
            model.IsContentFalse = this.chkIsContentFalse.Checked ? 1 : 0;
            model.IsAddTask      = this.chkIsAddTask.Checked ? 1 : 0;
            model.AddDateTime    = DateTime.Now.ToString();

            #region 2011  2 22
            int DataSourceType = 0;
            if (this.rbtnDataSourceType1.Checked)
            {
                DataSourceType = 1;
            }
            if (this.rbtnDataSourceType2.Checked)
            {
                DataSourceType = 2;
            }
            if (this.rbtnDataSourceType3.Checked)
            {
                DataSourceType = 3;
            }
            if (this.rbtnDataSourceType4.Checked)
            {
                DataSourceType = 4;
            }
            model.DataSourceType = DataSourceType;
            model.DataType       = this.cmbDataType.Text;
            model.DataLinkUrl    = this.txtDataLinkUrl.Text;
            model.DataQuerySQL   = this.txtDataQuerySQL.Text;
            model.FileSourcePath = this.txtFileSourcePath.Text;
            #endregion

            model.Status = this.chkStatus.Checked ? 1 : 0;
            if (string.IsNullOrEmpty(UUID))
            {
                model.IsCookie = 0;
                model.Status   = 1;
                Common.Update <WebSiteHelper>(model);
                if (OO != null)
                {
                    OO(this, "添加成功!", Common.Option.add);
                }
            }
            else
            {
                Common.Update <WebSiteHelper>(model);
                if (OO != null)
                {
                    OO(this, "修改成功!", Common.Option.edit);
                }
            }
            //增加数据备份
            //PublishTask task = new PublishTask();
            //task.CreateDataFile(UUID.ToString());
            this.Close();
            this.Dispose();
        }
예제 #11
0
 /// <summary>
 /// 发布文章外部入口
 /// </summary>
 /// <param name="model"></param>
 /// <param name="Title"></param>
 /// <param name="Content"></param>
 /// <param name="ClassName"></param>
 /// <param name="ClassID"></param>
 public void CommonSendContent(WebSiteHelper model,
                               string Title, string Content, string ClassName, string ClassID)
 {
     this.SendArticleContent(model, Title, Content, ClassName, ClassID);
 }
예제 #12
0
 private void OverOP(WebSiteHelper model)
 {
     listPublishItem.Remove(model);
 }
예제 #13
0
        protected string ConvertObjetToJSON(object objectTobeJSON)
        {
            WebSiteHelper webSiteHelper = new WebSiteHelper();

            return(webSiteHelper.ConvertObjetToJSON(objectTobeJSON));
        }
예제 #14
0
 public ActionResult LogOut()
 {
     WebSiteHelper.LogOut();
     return(Redirect("/WebAdmin/Home/login"));
 }
예제 #15
0
 public CareerVeeam()
 {
     Domain        = WebSiteHelper.GetDomainByWebSiteAttribute(this);
     JobSearchPage = new JobSearchPage(WebSiteHelper.GetWebPageAttributes(this, nameof(JobSearchPage)), Domain);
 }