Ejemplo n.º 1
0
 public static void ShowWaiting(String tipInfo = null)
 {
     if (Current == null)
     {
         Current        = new WaitingForm();
         Current.Click += Current_Click;
         Shade          = new ShadeForm();
         Shade.Click   += Shade_Click;
     }
     ShowingErrorState = false;
     if (!Current.Visible)
     {
         Shade.TopMost           = true;
         Current.TopMost         = true;
         Current.Size            = MainForm.Current.Size;
         Shade.Size              = MainForm.Current.Size;
         Current.TipInfo         = tipInfo;
         Current.DesktopLocation = MainForm.Current.DesktopLocation;
         Shade.DesktopLocation   = Current.DesktopLocation;
         if (!ToolBox.IsDebugMode())
         {
             Shade.Show();
         }
         Current.Show();
     }
 }
Ejemplo n.º 2
0
        private async void _btnAddPerformance_Click(Object sender, EventArgs e)
        {
            var templateInfo = this.GetPerformanceTemplateInfo();

            if (templateInfo == null)
            {
                return;
            }
            var dataItems = this.BuildPerformanceDataItems(templateInfo);

            if (dataItems != null && dataItems.Count > 0)
            {
                this._sfSavePerformanceFile.FileName = Config <UserInfoConfig> .Current.GetDefaultPerformanceTile();

                var    result   = this._sfSavePerformanceFile.ShowDialog();
                String savePath = this._sfSavePerformanceFile.FileName;
                WaitingForm.ShowWaiting("正在保存绩效文件...");
                await this.TemplateManager.FillDataItemsAsync(templateInfo, dataItems, savePath, true);

                //添加至发信附件
                EmailAttachmentInfo attachmentInfo = new EmailAttachmentInfo(savePath);
                this._lbSendAttachments.AddFirstAttachmentInfo(attachmentInfo);
                WaitingForm.HideWaiting();
            }
        }
Ejemplo n.º 3
0
        private async void _btnOpenFile_Click(Object sender, EventArgs e)
        {
            var attachmentInfo = this._lbReceviceAttachments.SelectedEmailAttachmentInfo;

            if (attachmentInfo == null)
            {
                return;
            }
            WaitingForm.ShowWaiting();
            await ToolBox.OpenFile(attachmentInfo.SavePath);

            WaitingForm.HideWaiting();
        }
        private async void _btnConfirm_Click(Object sender, EventArgs e)
        {
            var info = this.CreateSendEmailInfo();

            if (info == null)
            {
                return;
            }
            WaitingForm.ShowWaiting("正在发送邮件...");
            info.IsRespectivelySend = this._lbSendAttachments.DrawReceiver;
            await MainForm.Current.EmailDataManager.SendEmailAsync(info);

            WaitingForm.HideWaiting();

            this.ConfirmClose();
        }
Ejemplo n.º 5
0
        private async void _lbAttachments_SelectedIndexChanged(Object sender, EventArgs e)
        {
            //如果附件未保存附件信息
            var attachmentInfo = this._lbReceviceAttachments.SelectedEmailAttachmentInfo;

            if (attachmentInfo == null)
            {
                return;
            }
            if (!attachmentInfo.IsSaved)
            {
                WaitingForm.ShowWaiting("正在保存附件...");
                await attachmentInfo.SaveAysnc();

                this._lbReceviceAttachments.RefreshItemDraw(this._lbReceviceAttachments.SelectedIndex);
                WaitingForm.HideWaiting();
            }
        }
Ejemplo n.º 6
0
        private async void _lbEmails_SelectedIndexChanged(Object sender, EventArgs e)
        {
            var dataInfo = this._lbEmails.SelectedEmailDataInfo;

            if (dataInfo == null)
            {
                return;
            }
            this._lblSubject.Text = dataInfo.Title;
            this._lblSender.Text  = dataInfo.From;
            if (!dataInfo.IsDownloadedMail)
            {
                WaitingForm.ShowWaiting("正在下载邮件...");
                await dataInfo.DownloadAsync();

                this._lbEmails.RefreshItemDraw(this._lbEmails.SelectedIndex);
                WaitingForm.HideWaiting();
            }
            this._lbReceviceAttachments.ShowAttachmentInfo(dataInfo.AttachmentInfos);
        }
Ejemplo n.º 7
0
        private async void _btnGetEmails_Click(Object sender, EventArgs e)
        {
            try
            {
                if (this.EmailDataManager == null)
                {
                    return;
                }
                WaitingForm.ShowWaiting("正在获取邮件信息...");
                var config      = Config <EmailFilterConfig> .Current;
                var currenttime = DateTime.Now;
                var result      = await this.EmailDataManager.GetMailDataInfosAsync(
                    currenttime.AddDays(config.CollectRecentDays * -1),
                    currenttime,
                    config.TitleKeywords);

                this._lbEmails.AddShowEmailInfos(result);
                WaitingForm.HideWaiting();
            }
            catch
            {
            }
        }
Ejemplo n.º 8
0
        private async void AsyncLoadConfigInfo(Object sender, EventArgs e)
        {
            WaitingForm.ShowWaiting();
            await Config <UserInfoConfig> .LoadAsync();

            await Config <EmailFilterConfig> .LoadAsync();

            await Config <EmailReceiverConfig> .LoadAsync();

            this.TemplateManager = new PerformanceTemplateManager();
            this.TemplateManager.Init();
            //加载本地的绩效模板信息
            this.PerformanceTemplateInfos = await this.TemplateManager.GetPerformanceTemplateInfosAsync();


            if (Config <UserInfoConfig> .Current.IsVaild())
            {
                this.EmailDataManager = new EmailDataManager(
                    Config <UserInfoConfig> .Current.EmailAddress,
                    Config <UserInfoConfig> .Current.Password);
                this.EmailDataManager.Init();
                var filterConfig = Config <EmailFilterConfig> .Current;
                var currentTime  = DateTime.Now;
                //加载本地的邮件信息
                var emailInfos = await this.EmailDataManager.GetDownloadMailDataInfosAsync(
                    currentTime.AddDays(filterConfig.CollectRecentDays * -1),
                    currentTime,
                    filterConfig.TitleKeywords,
                    true
                    );

                this._lbEmails.ShowEmailInfos(emailInfos);
            }
            WaitingForm.HideWaiting();
            this._ofSelectSendAttachment.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            this._sfSavePerformanceFile.InitialDirectory  = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
        }
Ejemplo n.º 9
0
        internal async Task EditPerformanceFileAsync(String filePath)
        {
            String ext = Path.GetExtension(filePath).ToLower();

            if (ext != ".docx")
            {
                WaitingForm.ShowErrorInfo("请选择 .docx 类型的文件!");
                return;
            }
            var templateInfo = this.GetPerformanceTemplateInfo();

            if (templateInfo == null)
            {
                WaitingForm.ShowErrorInfo("没有可用的绩效模板!");
                return;
            }
            WaitingForm.ShowWaiting("正在提取绩效信息...");
            var dataItems = await this.TemplateManager.ExtractDataItemsAsync(templateInfo, filePath);

            if (dataItems.Count == 0)
            {
                WaitingForm.ShowErrorInfo("未能从文件中提取到数据!");
                return;
            }
            WaitingForm.HideWaiting();
            var newDataItems = this.BuildPerformanceDataItems(templateInfo, dataItems);

            if (newDataItems == null)
            {
                return;
            }
            WaitingForm.ShowWaiting("正在保存编辑信息...");
            await this.TemplateManager.FillDataItemsAsync(templateInfo, newDataItems, filePath, true);

            WaitingForm.HideWaiting();
        }
Ejemplo n.º 10
0
        private async void _btnDownloadAllAttacment_Click(Object sender, EventArgs e)
        {
            var dataInfos = this._lbEmails.EmailDataInfos;

            if (dataInfos.Count == 0)
            {
                return;
            }

            WaitingForm.ShowWaiting();
            foreach (var info in dataInfos)
            {
                //若邮件未下载,则先下载
                if (!info.IsDownloadedMail)
                {
                    WaitingForm.ShowTipInfo($"正在下载邮件:{info.Title} ...");
                    await info.DownloadAsync();
                }
                if (info.AttachmentInfos.Count == 0)
                {
                    continue;
                }

                foreach (var attachInfo in info.AttachmentInfos)
                {
                    //若附件未保存则先保存
                    if (!attachInfo.IsSaved)
                    {
                        WaitingForm.ShowTipInfo($"正在保存附件:{attachInfo.Name} ...");
                        await attachInfo.SaveAysnc();
                    }
                    this._lbSendAttachments.AddFirstAttachmentInfo(attachInfo, true);
                }
            }
            WaitingForm.HideWaiting();
        }
Ejemplo n.º 11
0
 private static void CurrentDomain_UnhandledException(Object sender, UnhandledExceptionEventArgs e)
 {
     WaitingForm.HideWaiting();
     MessageBox.Show("系统发生了异常!");
 }
Ejemplo n.º 12
0
 private static void Application_ThreadException(Object sender, System.Threading.ThreadExceptionEventArgs e)
 {
     WaitingForm.HideWaiting();
     MessageBox.Show("系统发生了异常!");
 }