Example #1
0
        public ActionResult Delete(int?currentPageNum, int?pageSize, string Key)
        {
            ScheduleConfigInfo sci = ScheduleConfigs.GetConfig();

            sci.Events = sci.Events.Where(p => p.Key != Key).ToArray();
            ScheduleConfigs.SaveConfig(sci);

            return(RedirectToAction("Index", new { currentPageNum = currentPageNum.Value, pageSize = pageSize.Value }));
        }
Example #2
0
        public CustomJsonResult AjaxEdit(ScheduledEvents model)
        {
            var key = LRequest.GetFormString("Key");

            #region MyRegion
            ScheduleConfigInfo sci = ScheduleConfigs.GetConfig();
            foreach (EventInfo ev1 in sci.Events)
            {
                if (ev1.Key == model.Key.Trim())
                {
                    ModelState.AddModelError("Key", "消息:计划任务名称已经存在!");
                    //return RedirectToAction("Index", new { currentPageNum = model.CurrentPageNum, pageSize = model.PageSize });
                }
            }
            foreach (EventInfo ev1 in sci.Events)
            {
                if (ev1.Key == key)
                {
                    ev1.Key          = model.Key.Trim();
                    ev1.ScheduleType = model.ScheduleType.Trim();

                    if (model.ExetimeType)
                    {
                        ev1.TimeOfDay = model.hour * 60 + model.minute;
                        ev1.Minutes   = sci.TimerMinutesInterval;
                    }
                    else
                    {
                        if (model.timeserval < sci.TimerMinutesInterval)
                        {
                            ev1.Minutes = sci.TimerMinutesInterval;
                        }
                        else
                        {
                            ev1.Minutes = model.timeserval;
                        }
                        ev1.TimeOfDay = -1;
                    }
                    if (!ev1.IsSystemEvent)
                    {
                        ev1.Enabled = model.Enable;
                    }
                    break;
                }
            }
            ScheduleConfigs.SaveConfig(sci);
            #endregion

            var result = new Result(true);

            var json = new CustomJsonResult();
            json.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            json.Data = result;

            return(json);
        }
Example #3
0
        public CustomJsonResult AjaxAdd(ScheduledEvents model, FormCollection collection)
        {
            int Entity_ExetimeType = 0;

            if (collection.GetValues("Entity.ExetimeType") != null)
            {
                Entity_ExetimeType = int.Parse(collection.GetValue("Entity.ExetimeType").AttemptedValue);
            }

            #region MyRegion
            ScheduleConfigInfo sci = ScheduleConfigs.GetConfig();
            foreach (EventInfo ev1 in sci.Events)
            {
                if (ev1.Key == model.Key.Trim())
                {
                    ModelState.AddModelError("Key", "消息:计划任务名称已经存在!");
                    //return RedirectToAction("Index", new { currentPageNum = model.CurrentPageNum, pageSize = model.PageSize });
                }
            }

            EventInfo ev = new EventInfo();
            ev.Key            = model.Key;
            ev.Enabled        = true;
            ev.IsSystemEvent  = false;
            ev.ScheduleType   = model.ScheduleType.ToString();
            model.ExetimeType = Entity_ExetimeType == 0 ? false : true;

            if (model.ExetimeType)
            {
                ev.TimeOfDay = model.hour * 60 + model.minute;
                ev.Minutes   = sci.TimerMinutesInterval;
            }
            else
            {
                ev.Minutes   = model.timeserval;
                ev.TimeOfDay = -1;
            }
            EventInfo[] es = new EventInfo[sci.Events.Length + 1];
            for (int i = 0; i < sci.Events.Length; i++)
            {
                es[i] = sci.Events[i];
            }
            es[es.Length - 1] = ev;
            sci.Events        = es;
            ScheduleConfigs.SaveConfig(sci);
            #endregion

            var result = new Result(true);

            var json = new CustomJsonResult();
            json.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            json.Data = result;

            return(json);
        }
Example #4
0
        public ActionResult Edit(AddOrEditViewModel <ScheduledEvents> model, FormCollection collection)
        {
            var key = LRequest.GetFormString("Key");

            #region MyRegion
            ScheduleConfigInfo sci = ScheduleConfigs.GetConfig();
            foreach (EventInfo ev1 in sci.Events)
            {
                if (ev1.Key == model.Entity.Key.Trim())
                {
                    ModelState.AddModelError("Key", "消息:计划任务名称已经存在!");
                    return(RedirectToAction("Index", new { currentPageNum = model.CurrentPageNum, pageSize = model.PageSize }));
                }
            }
            foreach (EventInfo ev1 in sci.Events)
            {
                if (ev1.Key == key)
                {
                    ev1.Key          = model.Entity.Key.Trim();
                    ev1.ScheduleType = model.Entity.ScheduleType.Trim();

                    if (model.Entity.ExetimeType)
                    {
                        ev1.TimeOfDay = model.Entity.hour * 60 + model.Entity.minute;
                        ev1.Minutes   = sci.TimerMinutesInterval;
                    }
                    else
                    {
                        if (model.Entity.timeserval < sci.TimerMinutesInterval)
                        {
                            ev1.Minutes = sci.TimerMinutesInterval;
                        }
                        else
                        {
                            ev1.Minutes = model.Entity.timeserval;
                        }
                        ev1.TimeOfDay = -1;
                    }
                    if (!ev1.IsSystemEvent)
                    {
                        ev1.Enabled = model.Entity.Enable;
                    }
                    break;
                }
            }
            ScheduleConfigs.SaveConfig(sci);
            #endregion
            return(RedirectToAction("Index", new { currentPageNum = model.CurrentPageNum, pageSize = model.PageSize }));
        }
Example #5
0
        public CustomJsonResult AjaxDelete(string Key)
        {
            ScheduleConfigInfo sci = ScheduleConfigs.GetConfig();

            sci.Events = sci.Events.Where(p => p.Key != Key).ToArray();
            ScheduleConfigs.SaveConfig(sci);

            var result = new Result(true);

            var json = new CustomJsonResult();

            json.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            json.Data = result;

            return(json);
        }
Example #6
0
        /// <summary>
        /// 建立邀请计划任务
        /// </summary>
        private void CreateInvitationSchedule()
        {
            ScheduleConfigInfo sci = ScheduleConfigs.GetConfig();

            //检查该事件是否存在
            foreach (Discuz.Config.Event ev1 in sci.Events)
            {
                if (ev1.Key == "InvitationEvent")
                {
                    return;
                }
            }

            //建立新的邀请计划任务
            Discuz.Config.Event ev = new Discuz.Config.Event();
            ev.Key           = "InvitationEvent";
            ev.Enabled       = true;
            ev.IsSystemEvent = true;
            ev.ScheduleType  = "Discuz.Event.InvitationEvent, Discuz.Event";
            ev.TimeOfDay     = 2;
            ev.Minutes       = 1;
            ScheduleConfigs.SaveConfig(sci);
        }
Example #7
0
        protected void savepassportinfo_Click(object sender, EventArgs e)
        {
            ScheduleConfigInfo sci = ScheduleConfigs.GetConfig();

            if (key.Text.Trim() == "")
            {
                base.RegisterStartupScript("PAGE", "alert('计划任务名称不能为空!');");
                return;
            }
            if (scheduletype.Text.Trim() == "")
            {
                base.RegisterStartupScript("PAGE", "alert('计划任务类型不能为空!');");
                return;
            }
            if (type2.Checked && (timeserval.Text == "" || !Utils.IsNumeric(timeserval.Text)))
            {
                base.RegisterStartupScript("PAGE", "alert('周期执行时间必须为数值!');");
                return;
            }
            if (DNTRequest.GetString("keyid") == "")
            {
                foreach (Discuz.Config.Event ev1 in sci.Events)
                {
                    if (ev1.Key == key.Text.Trim())
                    {
                        base.RegisterStartupScript("PAGE", "alert('计划任务名称已经存在!');");
                        return;
                    }
                }
                Discuz.Config.Event ev = new Discuz.Config.Event();
                ev.Key           = key.Text;
                ev.Enabled       = true;
                ev.IsSystemEvent = false;
                ev.ScheduleType  = scheduletype.Text.Trim();
                if (type1.Checked)
                {
                    ev.TimeOfDay = int.Parse(hour.Text) * 60 + int.Parse(minute.Text);
                    ev.Minutes   = sci.TimerMinutesInterval;
                }
                else
                {
                    ev.Minutes   = int.Parse(timeserval.Text.Trim());
                    ev.TimeOfDay = -1;
                }
                Discuz.Config.Event[] es = new Discuz.Config.Event[sci.Events.Length + 1];
                for (int i = 0; i < sci.Events.Length; i++)
                {
                    es[i] = sci.Events[i];
                }
                es[es.Length - 1] = ev;
                sci.Events        = es;
            }
            else
            {
                foreach (Discuz.Config.Event ev1 in sci.Events)
                {
                    if (key.Text.Trim() != oldkey.Value && ev1.Key == key.Text.Trim())
                    {
                        base.RegisterStartupScript("PAGE", "alert('计划任务名称已经存在!');");
                        return;
                    }
                }
                foreach (Discuz.Config.Event ev1 in sci.Events)
                {
                    if (ev1.Key == oldkey.Value)
                    {
                        ev1.Key          = key.Text.Trim();
                        ev1.ScheduleType = scheduletype.Text.Trim();
                        if (type1.Checked)
                        {
                            ev1.TimeOfDay = int.Parse(hour.Text) * 60 + int.Parse(minute.Text);
                            ev1.Minutes   = sci.TimerMinutesInterval;
                        }
                        else
                        {
                            if (int.Parse(timeserval.Text.Trim()) < sci.TimerMinutesInterval)
                            {
                                ev1.Minutes = sci.TimerMinutesInterval;
                            }
                            else
                            {
                                ev1.Minutes = int.Parse(timeserval.Text.Trim());
                            }
                            ev1.TimeOfDay = -1;
                        }
                        if (!ev1.IsSystemEvent)
                        {
                            if (eventenable.Items[0].Selected)
                            {
                                ev1.Enabled = true;
                            }
                            else
                            {
                                ev1.Enabled = false;
                            }
                        }
                        break;
                    }
                }
            }
            ScheduleConfigs.SaveConfig(sci);
            Response.Redirect("global_schedulemanage.aspx");
        }
Example #8
0
        protected void savepassportinfo_Click(object sender, EventArgs e)
        {
            ScheduleConfigInfo sci = ScheduleConfigs.GetConfig();

            if (key.Text.Trim() == "")
            {
                base.RegisterStartupScript("PAGE", "alert('计划任务名称不能为空!');");
                return;
            }
            if (scheduletype.Text.Trim() == "")
            {
                base.RegisterStartupScript("PAGE", "alert('计划任务类型不能为空!');");
                return;
            }
            if (type2.Checked && (timeserval.Text == "" || !Utils.IsNumeric(timeserval.Text)))
            {
                base.RegisterStartupScript("PAGE", "alert('周期执行时间必须为数值!');");
                return;
            }
            if (DNTRequest.GetString("keyid") == "")
            {
                foreach (Discuz.Config.Event ev1 in sci.Events)
                {
                    if (ev1.Key == key.Text.Trim())
                    {
                        base.RegisterStartupScript("PAGE", "alert('计划任务名称已经存在!');");
                        return;
                    }
                }
                Discuz.Config.Event ev = new Discuz.Config.Event();
                ev.Key           = key.Text;
                ev.Enabled       = true;
                ev.IsSystemEvent = false;
                ev.ScheduleType  = scheduletype.Text.Trim();
                if (type1.Checked)
                {
                    ev.TimeOfDay = int.Parse(hour.Text) * 60 + int.Parse(minute.Text);
                    ev.Minutes   = sci.TimerMinutesInterval;
                }
                else
                {
                    ev.Minutes   = int.Parse(timeserval.Text.Trim());
                    ev.TimeOfDay = -1;
                }
                Discuz.Config.Event[] es = new Discuz.Config.Event[sci.Events.Length + 1];
                for (int i = 0; i < sci.Events.Length; i++)
                {
                    es[i] = sci.Events[i];
                }
                es[es.Length - 1] = ev;
                sci.Events        = es;
            }
            else
            {
                foreach (Discuz.Config.Event ev1 in sci.Events)
                {
                    if (key.Text.Trim() != oldkey.Value && ev1.Key == key.Text.Trim())
                    {
                        base.RegisterStartupScript("PAGE", "alert('计划任务名称已经存在!');");
                        return;
                    }
                }
                foreach (Discuz.Config.Event ev1 in sci.Events)
                {
                    if (ev1.Key == oldkey.Value)
                    {
                        ev1.Key          = key.Text.Trim();
                        ev1.ScheduleType = scheduletype.Text.Trim();
                        if (type1.Checked)
                        {
                            ev1.TimeOfDay = int.Parse(hour.Text) * 60 + int.Parse(minute.Text);
                            ev1.Minutes   = sci.TimerMinutesInterval;
                        }
                        else
                        {
                            if (int.Parse(timeserval.Text.Trim()) < sci.TimerMinutesInterval)
                            {
                                ev1.Minutes = sci.TimerMinutesInterval;
                            }
                            else
                            {
                                ev1.Minutes = int.Parse(timeserval.Text.Trim());
                            }
                            ev1.TimeOfDay = -1;
                        }
                        if (!ev1.IsSystemEvent)
                        {
                            if (eventenable.Items[0].Selected)
                            {
                                ev1.Enabled = true;
                            }
                            else
                            {
                                ev1.Enabled = false;
                            }
                        }
                        break;
                    }
                }
            }
            ScheduleConfigs.SaveConfig(sci);
            Response.Redirect("global_schedulemanage.aspx");
            #region

            /*if (appname.Text.Trim() == "")
             * {
             *  base.RegisterStartupScript("PAGE", "alert('整合程序名称不能为空!');");
             *  return;
             * }
             * if (appurl.Text.Trim() == "")
             * {
             *  base.RegisterStartupScript("PAGE", "alert('整合程序 Url 地址不能为空!');");
             *  return;
             * }
             * if (callbackurl.Text.Trim() == "")
             * {
             *  base.RegisterStartupScript("PAGE", "alert('登录完成后返回地址不能为空!');");
             *  return;
             * }
             * if (ipaddresses.Text.Trim() != "")
             * {
             *  foreach (string ip in ipaddresses.Text.Replace("\r\n","").Replace(" ","").Split(','))
             *  {
             *      if (!Utils.IsIP(ip))
             *      {
             *          base.RegisterStartupScript("PAGE", "alert('IP地址格式错误!');");
             *          return;
             *      }
             *  }
             * }
             * if (apikeyhidd.Value == "") //增加
             * {
             *  ApplicationInfo ai = new ApplicationInfo();
             *  ai.AppName = appname.Text;
             *  ai.AppUrl = appurl.Text;
             *  ai.APIKey = Utils.MD5(System.Guid.NewGuid().ToString());
             *  ai.Secret = Utils.MD5(System.Guid.NewGuid().ToString());
             *  ai.CallbackUrl = callbackurl.Text;
             *  ai.IPAddresses = ipaddresses.Text.Replace("\r\n","").Replace(" ","");
             *  APIConfigInfo aci = APIConfigs.GetConfig();
             *  if (aci.AppCollection == null)
             *      aci.AppCollection = new ApplicationInfoCollection();
             *  aci.AppCollection.Add(ai);
             *  APIConfigs.SaveConfig(aci);
             * }
             * else   //修改
             * {
             *  APIConfigInfo aci = APIConfigs.GetConfig();
             *  foreach (ApplicationInfo ai in aci.AppCollection)
             *  {
             *      if (ai.APIKey == apikeyhidd.Value)
             *      {
             *          ai.AppName = appname.Text;
             *          ai.AppUrl = appurl.Text;
             *          ai.CallbackUrl = callbackurl.Text;
             *          ai.IPAddresses = ipaddresses.Text.Replace("\r\n","").Replace(" ","");
             *          break;
             *      }
             *  }
             *  APIConfigs.SaveConfig(aci);
             * }
             * Response.Redirect("global_passportmanage.aspx");*/
            #endregion
        }