Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string temp_id = Request.Form["temp_id"] != null ? Request.Form["temp_id"].ToString() : "-1";
                if (temp_id.Trim() == "")
                {
                    temp_id = "-1";
                }
                string news_id = Request.Form["news_id"] != null ? Request.Form["news_id"].ToString() : "-1";
                if (news_id.Trim() == "")
                {
                    news_id = "-1";
                }
                string cat_id       = Request.Form["cat_id"] != null ? Request.Form["cat_id"].ToString() : "";
                string news_title   = Request.Form["title"] != null ? Request.Form["title"].ToString() : "";
                string news_sapo    = Request.Form["news_sapo"] != null ? Request.Form["news_sapo"].ToString() : "";
                string news_image   = Request.Form["news_image"] != null ? Request.Form["news_image"].ToString() : "";
                string news_content = Request.Form["news_content"] != null ? Request.Form["news_content"].ToString() : "";


                if (!DraftHelper.CheckExistTempID(Convert.ToInt64(temp_id)))
                {
                    DraftHelper.InsertNewsTemp(Convert.ToInt64(temp_id), Convert.ToInt64(news_id), cat_id, news_title, news_image, news_sapo, news_content);
                }
                else
                {
                    DraftHelper.UpdateNewsTemp(Convert.ToInt64(temp_id), Convert.ToInt64(news_id), cat_id, news_title, news_image, news_sapo, news_content);
                }
            }
        }
Пример #2
0
    protected void butSaveDraft_Click(object sender, EventArgs e)
    {
        GetArticleInfo();
        Draft draft = new Draft();

        if (article_title.Equals("") || article_content.Equals(""))
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('标题跟内容不能为空!')", true);
        }
        else
        {
            if (article_title.Length > 30)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('标题长度已超过30!')", true);
            }
            else
            {
                if (UserInfo())
                {
                    userName = HttpUtility.UrlDecode(Request.Cookies["USERINFO"]["NAME"]);
                    User user = UserHelper.GetUserInfoByUserName(userName); // 获取用户信息

                    draft.userId      = user.userID;
                    draft.Title       = article_title;
                    draft.Content     = article_content;
                    draft.Type        = article_type;
                    draft.Tag         = article_tag;
                    draft.create_time = DateUtils.GetNowTime();

                    if (draftId != null && draftId != "" && Regex.IsMatch(draftId, @"^\d+$"))
                    {
                        // 更新草稿
                        if (DraftHelper.UpdateDraft(draft, user.userID, int.Parse(draftId)))
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('草稿保存成功!')", true);
                        }
                        else
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('草稿保存失败!')", true);
                        }
                    }
                    else if (DraftHelper.InsertNewDraft(draft))
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('草稿保存成功!')", true);
                    }
                    else
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('草稿保存失败!')", true);
                    }
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('请先登录!')", true);
                }
            }
        }
    }
Пример #3
0
 protected void Repeater_Draft_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "Edit")
     {
         Response.Redirect("MyEditor.aspx?draftId=" + e.CommandArgument);
     }
     else if (e.CommandName == "Delete")
     {
         if (DraftHelper.DeleteDraftById(int.Parse(e.CommandArgument.ToString())))
         {
             this.DataBindToDraftRepeater();
         }
     }
 }
Пример #4
0
    /// <summary>
    /// 从数据库加载草稿
    /// </summary>
    /// <param name="draftId"></param>
    private void LoadDraft(int draftId)
    {
        if (UserInfo())
        {
            User user = UserHelper.GetUserInfoByUserName(userName);

            Draft draft = DraftHelper.GetDraftById(draftId, user.userID);
            if (draft != null)
            {
                txtTitle.Text        = draft.Title;
                content.Text         = draft.Content;
                ArticleTypeList.Text = draft.Type;
                ArticleTagList.Text  = draft.Tag;
            }
        }
    }
Пример #5
0
    /// <summary>
    /// 根据当前登录用户Id获取用户草稿信息
    /// 并将数据绑定到 Repeater_Draft控件上
    /// </summary>
    private void DataBindToDraftRepeater()
    {
        User      user       = null;
        DataTable draftTable = null;

        if (Request.Cookies["USERINFO"] != null)
        {
            user = UserHelper.GetUserInfoByUserName(
                HttpUtility.UrlDecode(Request.Cookies["USERINFO"]["NAME"]));
        }
        if (user != null)
        {
            draftTable = DraftHelper.GetAllDraftByUserId(user.userID);
        }

        if (draftTable != null)
        {
            Repeater_Draft.DataSource = draftTable;
            Repeater_Draft.DataBind();
        }
    }
Пример #6
0
        public MainWindow(
            //OptionsWindow optionsWindow,
            IOptionsMonitor <ConfigModelApp> configApp,
            ICollection <Card> allCards,
            MainWindowVM viewModel,
            ProcessMonitor processMonitor,
            LogFileZipper zipper,
            ServerApiCaller api,
            StartupShortcutManager startupManager,
            LogSplitter logSplitter,
            MtgaResourcesLocator resourcesLocator,
            FileMonitor fileMonitor,
            DraftHelper draftHelper,
            //LogProcessor logProcessor,
            ReaderMtgaOutputLog readerMtgaOutputLog,
            //CacheSingleton<ICollection<Card>> allCards,
            InGameTracker inMatchTracker,
            ExternalProviderTokenManager tokenManager,
            PasswordHasher passwordHasher,
            NotifyIconManager notifyIconManager,
            CacheSingleton <Dictionary <string, DraftRatings> > draftRatings
            )
        {
            this.configApp = configApp.CurrentValue;
            //optionsWindow.Init(this.configApp);
            //optionsWindow.Owner = Window.GetWindow(this);
            //this.optionsWindow = optionsWindow;

            this.reader         = readerMtgaOutputLog;
            this.processMonitor = processMonitor;
            processMonitor.OnProcessMonitorStatusChanged += OnProcessMonitorStatusChanged;
            this.zipper           = zipper;
            this.api              = api;
            this.startupManager   = startupManager;
            this.logSplitter      = logSplitter;
            this.resourcesLocator = resourcesLocator;
            this.fileMonitor      = fileMonitor;
            fileMonitor.OnFileSizeChangedNewText += OnFileSizeChangedNewText;
            this.draftHelper = draftHelper;
            //this.logProcessor = logProcessor;
            this.inGameTracker     = inMatchTracker;
            this.tokenManager      = tokenManager;
            this.passwordHasher    = passwordHasher;
            this.notifyIconManager = notifyIconManager;
            this.draftRatings      = draftRatings;
            this.resourcesLocator.LocateLogFilePath(this.configApp);
            this.resourcesLocator.LocateGameClientFilePath(this.configApp);

            fileMonitor.SetFilePath(this.configApp.LogFilePath);
            //viewModel.ValidateUserId(this.configApp.UserId);
            viewModel.Opacity = this.configApp.Opacity;
            vm          = viewModel;
            DataContext = vm;

            InitializeComponent();

            ucWelcome.Init(tokenManager);
            ucPlaying.Init(vm, this.configApp.WindowSettingsOpponentCards);

            //trayIcon = new System.Windows.Forms.NotifyIcon { Text = "MTGAHelper Tracker" };
            //trayIcon.Icon = new System.Drawing.Icon(Application.GetResourceStream(new Uri("pack://application:,,,/Assets/Images/wcC.ico")).Stream);
            //trayIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(TrayIcon_MouseClick);
            //trayIcon.ContextMenu = new System.Windows.Forms.ContextMenu(new System.Windows.Forms.MenuItem[]
            //{
            //    new System.Windows.Forms.MenuItem("Quit", new EventHandler(TrayIcon_Quit))
            //});

            statusBarTop.Init(this, vm /*, draftHelper, logProcessor, this.configApp.UserId,*/);
            ucReady.Init(this.configApp.GameFilePath);
            ucDraftHelper.Init(allCards, vm.DraftingVM);
            //ucPlaying.Init(vm);

            ucDraftHelper.SetPopupRatingsSource(this.configApp.ShowLimitedRatings, this.configApp.ShowLimitedRatingsSource);

            this.processMonitor.Start(new System.Threading.CancellationToken());
            this.fileMonitor.Start(new System.Threading.CancellationToken());

            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(200)
            };

            timer.Tick += (object sender, EventArgs e) =>
            {
                vm.SetCardsDraftFromBuffered();
                vm.SetCardsInMatchTrackingFromBuffered();
            };
            timer.Start();

            var timerTokenRefresh = new DispatcherTimer {
                Interval = TimeSpan.FromMinutes(9)
            };

            timerTokenRefresh.Tick += (object sender, EventArgs e) =>
            {
                RefreshAccessToken();
            };
            timerTokenRefresh.Start();
        }