Esempio n. 1
0
        private void btn1_Click_1(object sender, RoutedEventArgs e)
        {
            ThirdPage th = new ThirdPage();

            th.Show();
            this.Hide();
        }
Esempio n. 2
0
 private void  btn2_Click(object sender, RoutedEventArgs e)
 {
     if (ckBox1.IsChecked == false || ckBox2.IsChecked == false || ckBox3.IsChecked == false)
     {
         DialogResult m;
         m = System.Windows.Forms.MessageBox.Show("Please review and accept the following terms before continuing.", "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
         if (m == System.Windows.Forms.DialogResult.Yes)
         {
             ckBox1.IsChecked = true;
             ckBox2.IsChecked = true;
             ckBox3.IsChecked = true;
         }
     }
     else if (ckBox1.IsChecked == true & ckBox2.IsChecked == true & ckBox3.IsChecked == true)
     {
         ThirdPage th = new ThirdPage();
         th.Show();
         this.Hide();
     }
 }
Esempio n. 3
0
        private Task testFuctions(string fid, string c_id, string ttid, string tcid, int map_id)
        {
            return(Task.Run(async() =>
            {
                string stacd = "2";
                string token7 = GetToken(stacd);

                List <MapUser> ue = GetUsrMap();
                List <MapMenUser> ftemail = new List <MapMenUser>();;
                MigrationStep step3 = new MigrationStep();
                if (ue.Count > 0 & ue != null)
                {
                    string stacdc = "1";
                    string token4 = GetToken(stacdc);
                    string stacd1 = "2";
                    string token3 = GetToken(stacd1);
                    for (int i = 0; i < ue.Count; i++)
                    {
                        MapMenUser ftuser = new MapMenUser();
                        UserInfoItem fuser = step3.GetUserByEmail(token3, ue[i].femail);
                        UserInfoItem tuser = step3.GetUserByEmail(token4, ue[i].temail);
                        ftuser.fid = fuser.id;
                        ftuser.fdisname = fuser.displayName;
                        ftuser.femail = fuser.mail;
                        ftuser.tid = tuser.id;
                        ftuser.tdisname = tuser.displayName;
                        ftuser.temail = tuser.mail;

                        ftemail.Add(ftuser);
                    }
                }

                if (!String.IsNullOrEmpty(token7))
                {
                    GetChatContent step2 = new GetChatContent();
                    List <MesageItem> messages = step2.GetChanelMessages(token7, fid, c_id);
                    Comparison <MesageItem> comparison = new Comparison <MesageItem>((MesageItem x, MesageItem y) =>
                    {
                        if (x.id < y.id)
                        {
                            return -1;
                        }
                        else if (x.id == y.id)
                        {
                            return 0;
                        }
                        else
                        {
                            return 1;
                        }
                    });
                    messages.Sort(comparison);

                    for (int i = 0; i < messages.Count; i++)
                    {
                        string user1 = step2.GetUserEmail(token7, messages[i]);
                        string usr1 = GetUsrMapemail(user1);
                        string token3 = GetUsrToken(usr1);

                        string oneaccess = "";
                        if (String.IsNullOrEmpty(token3))
                        {
                            string sta_cd = "1";
                            con.Open();
                            SqlCommand cmd2 = new SqlCommand("select_token", con);
                            cmd2.CommandType = CommandType.StoredProcedure;
                            cmd2.Parameters.AddWithValue("@sta_cd", sta_cd);
                            using (SqlDataReader reader = cmd2.ExecuteReader())
                            {
                                if (reader.Read())
                                {
                                    token1 = reader["access_token"].ToString();
                                    ppwd = reader["p_pwd"].ToString();
                                    cid = reader["c_id"].ToString();
                                    cs = reader["c_cs"].ToString();
                                    tid = reader["t_id"].ToString();
                                }
                            }
                            con.Close();
                            oneaccess = step3.GetOneAccessToken(usr1, ppwd, cid, cs, tid);
                        }
                        else
                        {
                            oneaccess = token3;
                        }

                        MesageItem mesaft = step3.ClearfyContent(messages[i]);

                        var res = step2.SendMessageDe(oneaccess, ttid, tcid, mesaft, ftemail);
                        if (res == null)
                        {
                            System.Windows.Forms.MessageBox.Show("One message throw an error");
                            continue;
                        }

                        long new_m_id = res.id;

                        List <MesageItem> replies = step2.GetMessagesReply(token7, fid, c_id, messages[i].id.ToString());

                        if (replies.Count > 0)
                        {
                            Comparison <MesageItem> comparison1 = new Comparison <MesageItem>((MesageItem x, MesageItem y) =>
                            {
                                if (x.id < y.id)
                                {
                                    return -1;
                                }
                                else if (x.id == y.id)
                                {
                                    return 0;
                                }
                                else
                                {
                                    return 1;
                                }
                            });
                            replies.Sort(comparison1);

                            foreach (MesageItem reply in replies)
                            {
                                MesageItem newreply = step3.ClearfyContent(reply);
                                long mesid = new_m_id;
                                string user2 = step2.GetUserEmail(token7, reply);
                                string usr2 = GetUsrMapemail(user2);
                                string token6 = GetUsrToken(usr2);

                                string oaccess = "";
                                if (String.IsNullOrEmpty(token6))
                                {
                                    string sta_cd = "1";
                                    con.Open();
                                    SqlCommand cmd2 = new SqlCommand("select_token", con);
                                    cmd2.CommandType = CommandType.StoredProcedure;
                                    cmd2.Parameters.AddWithValue("@sta_cd", sta_cd);
                                    using (SqlDataReader reader = cmd2.ExecuteReader())
                                    {
                                        if (reader.Read())
                                        {
                                            token1 = reader["access_token"].ToString();
                                            ppwd = reader["p_pwd"].ToString();
                                            cid = reader["c_id"].ToString();
                                            cs = reader["c_cs"].ToString();
                                            tid = reader["t_id"].ToString();
                                        }
                                    }
                                    con.Close();
                                    oaccess = step3.GetOneAccessToken(usr2, ppwd, cid, cs, tid);
                                }
                                else
                                {
                                    oaccess = token6;
                                }
                                if (ftemail.Count > 0 & ftemail != null)
                                {
                                    if (!step2.ReplyMessageDe(oaccess, ttid, tcid, mesid, newreply, ftemail))
                                    {
                                        System.Windows.Forms.MessageBox.Show("Send a reply error");
                                        continue;
                                    }
                                }
                                else
                                {
                                    System.Windows.Forms.MessageBox.Show("Access token expired, please sign in again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    Thread.Sleep(200);
                                    var account = await App.PublicClientApp.GetAccountsAsync();
                                    if (account.Any())
                                    {
                                        try
                                        {
                                            await App.PublicClientApp.RemoveAsync(account.FirstOrDefault());
                                            con.Open();
                                            SqlCommand cmd1 = new SqlCommand("user_del", con);
                                            cmd1.CommandType = CommandType.StoredProcedure;
                                            cmd1.ExecuteNonQuery();
                                            con.Close();


                                            ThirdPage th = new ThirdPage();
                                            th.Show();
                                            this.Hide();
                                        }
                                        catch (MsalException ex)
                                        {
                                            System.Windows.Forms.MessageBox.Show(ex.Message);
                                        }
                                    }
                                    else
                                    {
                                        ThirdPage th = new ThirdPage();
                                        th.Show();
                                        this.Hide();
                                    }
                                    break;
                                }
                            }
                        }
                        int c = i + 1;
                        SetprogressBar1(c, messages.Count);
                        Thread.Sleep(5);
                    }
                    con.Open();
                    SqlCommand cmd6 = new SqlCommand("upt_map", con);
                    cmd6.CommandType = CommandType.StoredProcedure;
                    cmd6.Parameters.AddWithValue("@map_id", map_id);
                    cmd6.Parameters.AddWithValue("@cnt_mes", "");
                    cmd6.ExecuteNonQuery();
                    con.Close();
                }
                else
                {
                    System.Windows.Forms.MessageBox.Show("Access token expired, please sign in again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Thread.Sleep(200);
                    var account = await App.PublicClientApp.GetAccountsAsync();
                    if (account.Any())
                    {
                        try
                        {
                            await App.PublicClientApp.RemoveAsync(account.FirstOrDefault());
                            con.Open();
                            SqlCommand cmd1 = new SqlCommand("user_del", con);
                            cmd1.CommandType = CommandType.StoredProcedure;
                            cmd1.ExecuteNonQuery();
                            con.Close();


                            ThirdPage th = new ThirdPage();
                            th.Show();
                            this.Hide();
                        }
                        catch (MsalException ex)
                        {
                            System.Windows.Forms.MessageBox.Show(ex.Message);
                        }
                    }
                    else
                    {
                        ThirdPage th = new ThirdPage();
                        th.Show();
                        this.Hide();
                    }
                }
            }));
        }
Esempio n. 4
0
        private async void ThreadProcess(object obj)
        {
            string sta_cd = "1";
            string token2 = GetToken(sta_cd);

            con.Open();
            SqlCommand cmd = new SqlCommand("map_id_select", con);

            cmd.CommandType = CommandType.StoredProcedure;
            using (IDataReader dr = cmd.ExecuteReader())
            {
                while (dr.Read())
                {
                    TeamChanelItem f = new TeamChanelItem();

                    f.fTid   = dr[0].ToString();
                    f.fCid   = dr[1].ToString();
                    f.tTid   = dr[2].ToString();
                    f.tCid   = dr[3].ToString();
                    f.map_id = dr[4].ToString();
                    maplist.Add(f);
                }
            }
            con.Close();

            if (!String.IsNullOrEmpty(token2))
            {
                for (int i = 0; i < maplist.Count; i++)
                {
                    string ftid  = maplist[i].fTid;
                    string fcid  = maplist[i].fCid;
                    string ttid  = maplist[i].tTid;
                    string tcid  = maplist[i].tCid;
                    string mp_id = maplist[i].map_id;
                    int    x     = int.Parse(mp_id);
                    await testFuctions(ftid, fcid, ttid, tcid, x);

                    int c = i + 1;
                    SetprogressBar(c, maplist.Count);
                }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Access token expired, please sign in again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Thread.Sleep(200);
                var account = await App.PublicClientApp.GetAccountsAsync();

                if (account.Any())
                {
                    try
                    {
                        await App.PublicClientApp.RemoveAsync(account.FirstOrDefault());

                        con.Open();
                        SqlCommand cmd1 = new SqlCommand("user_del", con);
                        cmd1.CommandType = CommandType.StoredProcedure;
                        cmd1.ExecuteNonQuery();
                        con.Close();


                        ThirdPage th = new ThirdPage();
                        th.Show();
                        this.Hide();
                    }
                    catch (MsalException ex)
                    {
                        System.Windows.Forms.MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    ThirdPage th = new ThirdPage();
                    th.Show();
                    this.Hide();
                }
            }
            Thread.Sleep(200);
        }