Пример #1
0
        public FormMailTrigger()
        {
            InitializeComponent();
            this.Show();
            fmtl = new FormMailTriggerLogic();

            //Act.DataLoginAct.Read();

            UserData.Init().Email = "oleg";
            tb_mail.Text = UserData.GetUserData().Email;

            DataLoginModel dataLogin = new DataLoginModel("*****@*****.**", "1234");

            GLogin.Init();
            GLogin.Glogin.CreateGmailService();
            GMessage gMessage = new GMessage(GLogin.Glogin.GmailService, dataLogin);

            string str = gMessage.GetMessageRaw(gMessage.Find(new GRule("TestTag", "testpath"), gMessage.GetMessages()));



            //UserData.GetUserData().CreateGmailService();
            //UserData.GetUserData().ListMessagesMatchungQuerty(UserData.GetUserData().GmailService, "me", String.Empty);



            //Google.Apis.Gmail.v1.Data.Message mes = UserData.GetMessage(UserData.GetUserData().GmailService, "*****@*****.**", "0");
            //tb_mail.Text = mes.Payload.Headers.ToString();
        }
Пример #2
0
        private async void FormMailTriggerLogic_Load(object sender, EventArgs e)
        {
            this.notifyIcon.Icon = new Icon(Application.StartupPath + "\\" + "MTP-beta-icon.ico");
            this.notifyIcon.Text = "Mail Trigger Parser";

            if (GLogin.Glogin == null)
            {
                GLogin.Init();
                await GLogin.Glogin.CreateCredential();

                GLogin.Glogin.CreateGmailService();
            }

            gMessage = new GMessage(GLogin.Glogin.GmailService);

            calculate = new Calculate(GLogin.Glogin.GmailService);
            calculate.callbackFileName    += Calculate_callbackFileName;
            calculate.callbackProgressBar += Calculate_callbackProgressBar;
            calculate.callbackAlert       += Calculate_callbackAlert;

            this.Deactivate += FormMailTriggerLogic_Deactivate;

            if (AutoRun.IsEnabled())
            {
                btn_start.Enabled = false;
                btn_stop.Enabled  = true;
                thread            = new Thread(new ThreadStart(calculate.Run));
                thread.Start();

                cb_autorun.Checked = true;
                this.WindowState   = FormWindowState.Minimized;
                this.ShowInTaskbar = false;
            }
            else
            {
                btn_stop.Enabled   = false;
                cb_autorun.Checked = false;
            }


            dataGridView.Rows.Clear();

            l_version.Text = /* "Version : " + */ "beta " + Application.ProductVersion.ToString();
            var data = await GLogin.Glogin.GmailService.Users.GetProfile("me").ExecuteAsync();

            l_mail.Text              = data.EmailAddress;
            l_status.Text            = "tap start";
            l_processedMessages.Text = "0";

            foreach (string str in GRule.GetFiles())
            {
                RowAdd(FileParser.Reads <GRule>(str));
            }
            GRule.SetChange(false);

            this.Select();
        }
Пример #3
0
 public async Task <JsonResult> BasicGoogleVerify(GLogin verify)
 {
     return(Json(new GLogin
     {
         Token = verify.Token,
         Gid = verify.Gid,
         IsAuthenticated = await AuthUtils.VerifySocialTokenAsync(verify.Token, verify.Gid)
     }));
 }
Пример #4
0
 private async void FormMailTrigger_Load(object sender, EventArgs e)
 {
     GLogin.Init();
     //while (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
     if (Act.AutoRun.IsEnabled())
     {
         this.Opacity       = 0.0f;
         this.ShowInTaskbar = false;
     }
 }
Пример #5
0
        private async void btnUpload_ClickAsync(object sender, EventArgs e)
        {
            if (grdList.SelectedRows.Count == 0)
            {
                MessageBox.Show("لطفاً ابتدا فایل معادل اطلاعات همگام‌سازی را اضافه کرده، آن را انتخاب کنید.");
                return;
            }

            PoemAudio poemAudio = grdList.SelectedRows[0].Tag as PoemAudio;

            if (!poemAudio.IsSynced)
            {
                MessageBox.Show("لطفا ابتدا خوانش را همگام کنید.");
                return;
            }

            if (Path.GetExtension(poemAudio.FilePath).ToLower() != ".mp3")
            {
                MessageBox.Show("تنها پسوند mp3 برای فایلهای صوتی قابل بارگذاری است.", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading);
                return;
            }

            if (!File.Exists(poemAudio.FilePath))
            {
                MessageBox.Show("فایل صوتی متناظر وجود ندارد.", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading);
                return;
            }

            bool valid = await TokenIsValid();

            if (!valid)
            {
                using (GLogin gLogin = new GLogin())
                    if (gLogin.ShowDialog(this) != DialogResult.OK)
                    {
                        Cursor = Cursors.Default;
                        Application.DoEvents();
                        return;
                    }
                if (!await TokenIsValid())
                {
                    Cursor = Cursors.Default;
                    Application.DoEvents();
                    return;
                }
            }
            Cursor = Cursors.Default;
            Application.DoEvents();
            if (string.IsNullOrEmpty(Properties.Settings.Default.MuseumToken))
            {
                return;
            }

            if (string.IsNullOrEmpty(Properties.Settings.Default.DefProfile))
            {
                MessageBox.Show("لطفا به پیشخان وارد شوید و در قسمت نمایه‌ها، نمایه‌ای را به عنوان نمایهٔ پیش‌فرض تعریف یا فعال کنید.", "خطا", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading);
                Process.Start("https://gaudiopanel.ganjoor.net");
                return;
            }

            bool replaceOldAudio = false;

            using (ConfirmAudioUpload confirmDlg = new ConfirmAudioUpload(Properties.Settings.Default.DefProfile))
            {
                var res = confirmDlg.ShowDialog(this);
                if (res == DialogResult.Cancel)
                {
                    return;
                }
                replaceOldAudio = res == DialogResult.Yes;
            }


            using (HttpClient httpClient = new HttpClient())
            {
                httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Properties.Settings.Default.MuseumToken);

                Cursor = Cursors.WaitCursor;
                Application.DoEvents();

                MultipartFormDataContent form = new MultipartFormDataContent();

                string xmlTempPath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());

                PoemAudioListProcessor.Save(xmlTempPath, poemAudio, false);
                byte[] xmlFileContent = File.ReadAllBytes(xmlTempPath);
                File.Delete(xmlTempPath);
                form.Add(new ByteArrayContent(xmlFileContent, 0, xmlFileContent.Length), $"{Path.GetFileNameWithoutExtension(poemAudio.FilePath)}.xml", $"{Path.GetFileNameWithoutExtension(poemAudio.FilePath)}.xml");


                byte[] mp3FileContent = File.ReadAllBytes(poemAudio.FilePath);
                form.Add(new ByteArrayContent(mp3FileContent, 0, mp3FileContent.Length), Path.GetFileName(poemAudio.FilePath), Path.GetFileName(poemAudio.FilePath));

                HttpResponseMessage response = await httpClient.PostAsync($"{Properties.Settings.Default.GanjoorServiceUrl}/api/audio?replace={replaceOldAudio}", form);

                if (response.StatusCode != HttpStatusCode.OK)
                {
                    Cursor = Cursors.Default;
                    MessageBox.Show(await response.Content.ReadAsStringAsync());
                    return;
                }

                response.EnsureSuccessStatusCode();
            }

            Cursor = Cursors.Default;

            MessageBox.Show("ارسال به سایت به درستی انجام شد.", "اعلان", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign);
        }