private async void Btn_next_Click(object sender, RoutedEventArgs e)
        {
            string t   = Global.APIUri;//temp delete
            int    chk = 0;

            try
            {
                if (tb_activationkey.Text.Trim() != "".Trim() && tb_serverUri.Text.Trim() != "".Trim())
                {
                    AvtivateServer ac = new AvtivateServer();
                    Global.APIUri = tb_serverUri.Text + @"/api/";
                    chk           = await ac.checkconn();

                    //string res=  await ac.checkincconn();

                    //   MessageBox.Show(chk.ToString());
                    //
                    chk = await ac.StatSendserverkey(tb_activationkey.Text, "all");

                    //   MessageBox.Show(chk.ToString());

                    if (chk <= 0)
                    {
                        string message = "inc(" + chk + ")";

                        string messagecode = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(message));
                        //  tb_activationkey.Text = messagecode;


                        string msg = "The Activation not complete (Error code:" + messagecode + ")";


                        Toaster.ShowWarning(Window.GetWindow(this), message: msg, animation: ToasterAnimation.FadeIn);
                    }

                    else
                    {
                        Toaster.ShowSuccess(Window.GetWindow(this), message: "The Activation done successfuly", animation: ToasterAnimation.FadeIn);
                    }
                }
            }
            catch (Exception ex)
            {
                Global.APIUri = t;//temp delete
                Toaster.ShowWarning(Window.GetWindow(this), message: "The server Not Found", animation: ToasterAnimation.FadeIn);
            }
        }
        private async void Btn_upgrade_Click(object sender, RoutedEventArgs e)
        {                                                       //upgrade
            int    chk           = 0;
            string activationkey = progDetails.packageSaleCode; //get from info

            if (progDetails.isOnlineServer.Value)               //online
            {
                try
                {
                    if (activationkey.Trim() != "".Trim())
                    {
                        AvtivateServer ac = new AvtivateServer();

                        chk = await ac.checkconn();

                        chk = await ac.StatSendserverkey(activationkey, "up");

                        // //change      chk = 3;
                        //nochange     chk = 2;

                        if (chk <= 0)
                        {
                            string message = "inc(" + chk + ")";

                            string messagecode = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(message));

                            string msg = MainWindow.resourcemanager.GetString("trUpgradeNotCompleted") + "(" +
                                         MainWindow.resourcemanager.GetString("trErrorCode") + ":" + messagecode + ")";

                            Toaster.ShowWarning(Window.GetWindow(this), message: msg, animation: ToasterAnimation.FadeIn);
                        }

                        else
                        {
                            if (chk == 3)
                            {
                                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trUpgradeCompleted"), animation: ToasterAnimation.FadeIn);
                                progDetails = await progDetailsModel.getCurrentInfo();

                                this.DataContext = progDetails;
                            }
                            else if (chk == 2)
                            {
                                Toaster.ShowSuccess(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trNoChanges"), animation: ToasterAnimation.FadeIn);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Toaster.ShowWarning(Window.GetWindow(this), message: MainWindow.resourcemanager.GetString("trServerNotFount"), animation: ToasterAnimation.FadeIn);
                }
            }
            else//offline
            {
                // start activate

                chk = 0;
                string message = "";
                try
                {
                    bool           isServerActivated = true;
                    AvtivateServer ac          = new AvtivateServer();
                    string         activeState = "up";
                    int            activematch = 0;

                    string filepath = "";
                    openFileDialog.Filter = "INC|*.ac; ";
                    SendDetail customerdata = new SendDetail();
                    SendDetail dc           = new SendDetail();
                    if (openFileDialog.ShowDialog() == true)
                    {
                        filepath = openFileDialog.FileName;

                        //   bool resr = ReportCls.decodefile(filepath, @"D:\stringlist.txt");//comment

                        string objectstr = "";

                        objectstr = ReportCls.decodetoString(filepath);

                        dc = JsonConvert.DeserializeObject <SendDetail>(objectstr, new JsonSerializerSettings {
                            DateParseHandling = DateParseHandling.None
                        });
                        packagesSend pss = new packagesSend();

                        pss = dc.packageSend;
                        isServerActivated = dc.packageSend.isServerActivated;
                        pss.activeApp     = "-";

                        dc.packageSend = pss;

                        // string activeState = "";
                        if (dc.packageSend.activeState == activeState)
                        {
                            activematch  = 1;
                            customerdata = await ac.OfflineActivate(dc, activeState);
                        }
                        else
                        {
                            Toaster.ShowWarning(Window.GetWindow(this), message: "The file isn't upgrade file", animation: ToasterAnimation.FadeIn);
                        }
                    }

                    // upload

                    if (activematch == 1)
                    {
                        if (customerdata.packageSend.result > 0)
                        {
                            // if first activate OR upgrade  show save dialoge to save customer data in file
                            saveFileDialog.Filter = "File|*.ac;";
                            if (saveFileDialog.ShowDialog() == true)
                            {
                                string DestPath = saveFileDialog.FileName;

                                string myContent = JsonConvert.SerializeObject(customerdata);

                                bool res = false;

                                res = ReportCls.encodestring(myContent, DestPath);

                                if (res)
                                {
                                    //     //done
                                    //   MessageBox.Show("Success");
                                    Toaster.ShowSuccess(Window.GetWindow(this), message: "Success", animation: ToasterAnimation.FadeIn);
                                }
                                else
                                {
                                    Toaster.ShowWarning(Window.GetWindow(this), message: "Error", animation: ToasterAnimation.FadeIn);
                                    //   MessageBox.Show("Error");
                                }
                            }
                        }
                        else
                        {
                            //   MessageBox.Show(customerdata.packageSend.result.ToString());
                            string msg = "NOT complete - " + customerdata.packageSend.result.ToString();
                            Toaster.ShowWarning(Window.GetWindow(this), msg, animation: ToasterAnimation.FadeIn);
                        }
                    }
                    else
                    {
                        //close
                    }

                    //end uploaa
                }
                catch (Exception ex)
                {
                    Toaster.ShowWarning(Window.GetWindow(this), message: "The server Not Found", animation: ToasterAnimation.FadeIn);
                }


                //end activate
            }
        }