private void Update()
 {
     try
     {
         ErrorMessage = WarningMessage = InfoMessage = string.Empty;
         var studentObj = new Student
         {
             RollNo         = _rollNo,
             StudentName    = _studentname,
             BranchName     = _branchName,
             RegistrationID = _registrationId
         };
         if (UpdateDetails.UpdateStudentDetails(studentObj))
         {
             InfoMessage = studentObj.ToString();
             GetAllStudents();
         }
         else
         {
             WarningMessage = "Not able to update student details.";
         }
     }
     catch (Exception e)
     {
         ErrorMessage = e.Message.ToString();
         logmsg.Log(LogMessage.LogType.Error, e.ToString());
     }
 }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            AccountNoText.Text = Constant.accountno;
            if (!IsPostBack)
            {
                CustomerText.EnableViewState = true;
                AgeText.EnableViewState      = true;
                AddressText.EnableViewState  = true;
                EmailText.EnableViewState    = true;
                CityText.EnableViewState     = true;
                GenderText.EnableViewState   = true;
                AccntBalText.EnableViewState = true;

                ud = ad.updatepageload();

                AccountNoText.Text = Constant.accountno;
                CustomerText.Text  = ud.CustomerName;
                AgeText.Text       = ud.Age;
                AddressText.Text   = ud.Address;
                EmailText.Text     = ud.EmailId;
                CityText.Text      = ud.City;
                GenderText.Text    = ud.Gender;
                AccntBalText.Text  = ud.AccountBalance;
            }
        }
Пример #3
0
        public async Task <UpdateDetails> CheckUpdatesAsync(PackageModel model)
        {
            try
            {
                var result = new UpdateDetails();
                var sql    = "SELECT PACKAGE_NAME, VERSION, APK_URL, CREATION_DATE " +
                             "FROM IFSAPP.UPDATE_MANAGER_TAB  " +
                             "WHERE  PACKAGE_NAME='" + model.PackageName + "' " +
                             "ORDER BY CREATION_DATE DESC " +
                             "OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY";

                var dt = await _oracleProvider.QueryAsync(_userData, sql);

                if (dt != null && dt.Rows.Count > 0)
                {
                    var row = dt.Rows[0];
                    result = new UpdateDetails()
                    {
                        PackageName  = row["PACKAGE_NAME"].ToString(),
                        Version      = row["VERSION"].ToString(),
                        Url          = row["APK_URL"].ToString(),
                        CreationDate = DateTime.Parse(row["CREATION_DATE"].ToString()),
                        UpToDate     = model.Version.Equals(row["VERSION"])
                    };
                }
                return(result);
            }
            catch (Exception ex)
            {
                throw ExceptionHelper.Throw(ex, typeof(UpdateManagerRepository).Name, "CheckUpdatesAsync");
            }
        }
Пример #4
0
        /// <summary>
        /// Verbose description of <see cref="WindowsUpdateOperationResult"/>.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            string windowsUpdateDetails = string.Join(",\n", UpdateDetails.Select(i => i.ToString()).ToArray());

            return(string.Format("WindowsUpdateOperationResult : OperationResult {0} , OperationTime {1}, OperationType {2}, UpdateDetails {3}, NodeName {4}, WindowsUpdateQuery {5}, WindowsUpdateFrequency {6}, RebootRequired {7}",
                                 OperationResult, OperationTime, OperationType, windowsUpdateDetails, NodeName, WindowsUpdateQuery, WindowsUpdateFrequency, RebootRequired));
        }
        public static async Task <UpdateDetails> CheckForUpdateAsync(ChannelType updateChannel)
        {
            var updateDetails = new UpdateDetails();

            try
            {
                using (var httpClient = new HttpClient())
                {
                    var json = await httpClient.GetStringAsync(UpdateCheckUri);

                    var liveVersion = JsonConvert.DeserializeObject <LiveVersioning>(json);
                    var channel     = liveVersion.Channels.First(c => c.ChannelType == updateChannel);

                    UpdateNotesPath = channel.ChangeNotes;
                    UpdateExePath   = channel.Download;

                    updateDetails.UpdateAvailable = AssemblyManager.Version < channel.Version;

                    if (updateDetails.UpdateAvailable)
                    {
                        updateDetails.UpdateNotes = await GetUpdateNotes();
                    }
                }

                return(updateDetails);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #6
0
        private UpdateDetails getDetails()
        {
            UpdateDetails ud   = new UpdateDetails();
            SqlConnection conn = new SqlConnection();

            try
            {
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["Bankingsysconn"].ConnectionString;
                conn.Open();
                string        selcetAccount = Query.selectAll + Constant.accountno;
                SqlCommand    cmd           = new SqlCommand(selcetAccount, conn);
                SqlDataReader dr            = cmd.ExecuteReader();
                if (dr.Read())
                {
                    ud.CustomerName   = dr.GetValue(1).ToString();
                    ud.Age            = dr.GetValue(2).ToString();
                    ud.Address        = dr.GetValue(3).ToString();
                    ud.EmailId        = dr.GetValue(4).ToString();
                    ud.City           = dr.GetValue(5).ToString();
                    ud.Gender         = dr.GetValue(6).ToString();
                    ud.AccountBalance = dr.GetValue(7).ToString();
                }
                dr.Close();
            }
            finally
            {
                conn.Close();
            }
            return(ud);
        }
Пример #7
0
 void Start()
 {
     once = true;
     item_ingredient1_name = setName((int)item_ingredient1);
     item_ingredient2_name = setName((int)item_ingredient2);
     item_ingredient3_name = setName((int)item_ingredient3);
     updateText();
     details = GameObject.FindGameObjectWithTag("DetailsPanel").GetComponent <UpdateDetails>();
     crafter = GameObject.FindGameObjectWithTag("CraftingPanel").GetComponent <Crafting>();
 }
Пример #8
0
        private void DownloadUpdate(UpdateDetails details)
        {
            _realCloseWindow = true;
            Log.Info("Not up to date.");
            IsClosingDown = true;

            var    downloadUri = new Uri(details.InstallUrl);
            string filename    = System.IO.Path.GetFileName(downloadUri.LocalPath);

            if (details.UpdateDownloaded)
            {
                UpdateStatus("Launching Updater");
                Log.Info("Launching updater");
                Close();
                return;
            }

            UpdateStatus("Downloading new version.");

            var fd = new FileDownloader(downloadUri, Path.Combine(Directory.GetCurrentDirectory(), filename));

            progressBar1.Maximum         = 100;
            progressBar1.IsIndeterminate = false;
            progressBar1.Value           = 0;

            var myBinding = new Binding("Progress");

            myBinding.Source = fd;
            progressBar1.SetBinding(ProgressBar.ValueProperty, myBinding);

            var downloadTask = fd.Download();

            downloadTask.ContinueWith((t) =>
            {
                Log.Info("Download Complete");

                if (fd.DownloadFailed || !fd.DownloadComplete)
                {
                    Log.Info("Download Failed");
                    UpdateStatus("Downloading the new version failed. Please manually download.");
                    Program.LaunchUrl(details.InstallUrl);
                }
                else
                {
                    Log.Info("Launching updater");
                    UpdateStatus("Launching Updater");
                }
                Dispatcher.Invoke(new Action(() =>
                {
                    progressBar1.IsIndeterminate = true;
                    Close();
                }));
            });
            downloadTask.Start();
        }
        /// <summary>Shows the selected update details.</summary>
        /// <param name="sender">The object that called the event.</param>
        /// <param name="e">The <c>System.Windows.Input.MouseButtonEventArgs</c> instance containing the event data.</param>
        void ShowDetails(object sender, MouseButtonEventArgs e)
        {
            if (e.ClickCount != 2 || this.lvHiddenUpdates.SelectedIndex == -1)
            {
                return;
            }

            var details = new UpdateDetails();

            details.ShowDialog(this.hiddenUpdates[this.lvHiddenUpdates.SelectedIndex]);
        }
Пример #10
0
        public void Update(UpdateDetails updateDetails)
        {
            var entityToUpdate = _dbContext.Find <Entities.Master.UpdateDetails>(updateDetails.Id);

            if (entityToUpdate != null)
            {
                _mapper.Map(updateDetails, entityToUpdate);
                _dbContext.Update(_mapper.Map <Entities.Master.UpdateDetails>(entityToUpdate),
                                  post => post.MapTo(updateDetails), _mapper);
            }
        }
Пример #11
0
        private void DownloadUpdate(UpdateDetails details)
        {
            _realCloseWindow = true;
            Log.Info("Not up to date.");
            IsClosingDown = true;

            var    downloadUri = new Uri(details.InstallUrl);
            string filename    = System.IO.Path.GetFileName(downloadUri.LocalPath);

            if (details.UpdateDownloaded)
            {
                UpdateStatus("Launching Updater");
                Log.Info("Launching updater");
                Close();
                return;
            }

            UpdateStatus("Downloading new version.");

            var fd = new FileDownloader(downloadUri, Path.Combine(Config.Instance.Paths.UpdatesPath, filename));

            progressBar1.Maximum         = 100;
            progressBar1.IsIndeterminate = false;
            progressBar1.Value           = 0;

            var myBinding = new Binding("Progress");

            myBinding.Source = fd;
            progressBar1.SetBinding(ProgressBar.ValueProperty, myBinding);

            var downloadTask = fd.Download();

            downloadTask.ContinueWith((t) => {
                Log.Info("Download Complete");

                if (fd.DownloadFailed || !fd.DownloadComplete)
                {
                    Log.Info("Download Failed");
                    UpdateStatus("Downloading the new version failed. Please manually download.");
                    TopMostMessageBox.Show("Downloading the latest version of OCTGN failed. Please visit http://www.octgn.net to download manually.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else
                {
                    Log.Info("Launching updater");
                    UpdateStatus("Launching Updater");
                }
                Dispatcher.Invoke(new Action(() => {
                    progressBar1.IsIndeterminate = true;
                    Close();
                }));
            });
            downloadTask.Start();
        }
Пример #12
0
        /// <summary>
        /// Applies update
        /// </summary>
        /// <param name="updateId"></param>
        public void Apply(Guid updateId)
        {
            IUpdate update = GetUpdate(updateId);

            if (update is null)
            {
                throw new Exception($"Update {updateId} is not a valid update");
            }

            if (IsApplied(updateId))
            {
                return;
            }

            var missingUpdateIds = GetMissingDependentUpdates(update);

            if (missingUpdateIds.Count > 0)
            {
                throw new Exception($"Update cannot be applied because it depends on update {missingUpdateIds[0]}");
            }

            try
            {
                update.Apply();

                var updateDetails = new UpdateDetails()
                {
                    Id          = update.Id,
                    Name        = update.Name,
                    TimeApplied = DateTime.UtcNow
                };

                _updateDetailsRepository.Add(updateDetails);
                _updateDetailsRepository.SaveChanges();
            }
            catch (Exception exception)
            {
                try
                {
                    if (update.SupportsRollback)
                    {
                        update.RollBack();
                    }
                }
                catch (Exception rollBackException)
                {
                    throw new Exception($"Error applying update {update.Name}, roll back failed", rollBackException);
                }

                throw new Exception($"Error applying update {update.Name} - {exception.InnerException?.Message}", exception);
            }
        }
        private void btnLoad_Click(object sender, EventArgs e)
        {
            RegDetails objRegObject = new RegDetails();

            objRegObject.FirstName = UserGridView.SelectedRows[0].Cells["ColFirstName"].Value.ToString();
            objRegObject.LastName  = UserGridView.SelectedRows[0].Cells["ColLastName"].Value.ToString();
            objRegObject.Email     = UserGridView.SelectedRows[0].Cells["ColEmail"].Value.ToString();
            objRegObject.Mobile    = Convert.ToInt64(UserGridView.SelectedRows[0].Cells["ColMobile"].Value);
            objRegObject.UserName  = UserGridView.SelectedRows[0].Cells["ColUserName"].Value.ToString();


            UpdateDetails upobj = new UpdateDetails(objRegObject);

            upobj.Show();
            this.Hide();
        }
Пример #14
0
        public void UpdateAccount(UpdateDetails ud)
        {
            //getDetails();
            SqlConnection con = new SqlConnection();

            try
            {
                con.ConnectionString = ConfigurationManager.ConnectionStrings["Bankingsysconn"].ConnectionString;
                con.Open();
                string test;
                test = Constant.accountno;

                string        getId = Query.selectId + test;
                SqlCommand    cmd   = new SqlCommand(getId, con);
                SqlDataReader dr    = cmd.ExecuteReader();
                if (dr.Read())
                {
                    getId = dr.GetValue(0).ToString();
                }
                dr.Close();
                SqlCommand cmd1 = new SqlCommand("updatedetails", con);
                cmd1.CommandType = CommandType.StoredProcedure;
                cmd1.Parameters.AddWithValue("@AccountNo", test);
                cmd1.Parameters.AddWithValue("@Customername", ud.CustomerName);
                cmd1.Parameters.AddWithValue("@Age", ud.Age);
                cmd1.Parameters.AddWithValue("@Address", ud.Address);
                cmd1.Parameters.AddWithValue("@Emailid", ud.EmailId);
                cmd1.Parameters.AddWithValue("@City", ud.City);
                cmd1.Parameters.AddWithValue("@Gender", ud.Gender);
                cmd1.Parameters.AddWithValue("@AccountBalance", ud.AccountBalance);

                cmd1.ExecuteNonQuery();
            }

            finally
            {
                con.Close();
            }
        }
Пример #15
0
        private void ReadLastLogin()
        {
            try
            {
                if (File.Exists(xmlPath))
                {
                    var contents = File.ReadAllText(xmlPath);
                    var split    = contents.Split(";");
                    var details  = new UpdateDetails
                    {
                        Sessionid = split[0],
                        StashTabs = split[1],
                        UserName  = split[2]
                    };
                    LatestDetails = details;

                    detailsButton.Visibility = Visibility.Visible;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("UpdateDetails file changed. Please delete it from documents/harvester :)");
            }
        }
Пример #16
0
 /// <summary>Shows the selected update details.</summary>
 /// <param name="sender">The object that called the event.</param>
 /// <param name="e">The <c>System.Windows.RoutedEventArgs</c> instance containing the event data.</param>
 void ShowDetailsDialog(object sender, RoutedEventArgs e)
 {
     var details = new UpdateDetails();
     details.ShowDialog(this.hiddenUpdates[this.lvHiddenUpdates.SelectedIndex]);
 }
Пример #17
0
        private void DownloadUpdate(UpdateDetails details)
        {
            _realCloseWindow = true;
            Log.Info("Not up to date.");
            IsClosingDown = true;

            var downloadUri = new Uri(details.InstallUrl);
            string filename = System.IO.Path.GetFileName(downloadUri.LocalPath);

            if (details.UpdateDownloaded)
            {
                UpdateStatus("Launching Updater");
                Log.Info("Launching updater");
                Close();
                return;
            }

            UpdateStatus("Downloading new version.");

            var fd = new FileDownloader(downloadUri, Path.Combine(Directory.GetCurrentDirectory(), filename));

            progressBar1.Maximum = 100;
            progressBar1.IsIndeterminate = false;
            progressBar1.Value = 0;

            var myBinding = new Binding("Progress");
            myBinding.Source = fd;
            progressBar1.SetBinding(ProgressBar.ValueProperty, myBinding);

            var downloadTask = fd.Download();
            downloadTask.ContinueWith((t) =>
            {
                Log.Info("Download Complete");

                if (fd.DownloadFailed || !fd.DownloadComplete)
                {
                    Log.Info("Download Failed");
                    UpdateStatus("Downloading the new version failed. Please manually download.");
                    Program.LaunchUrl(details.InstallUrl);
                }
                else
                {
                    Log.Info("Launching updater");
                    UpdateStatus("Launching Updater");
                }
                Dispatcher.Invoke(new Action(() =>
                {
                    progressBar1.IsIndeterminate = true;
                    Close();
                }));
            });
            downloadTask.Start();
        }
Пример #18
0
 public void Add(UpdateDetails updateDetails) =>
 _dbContext.Add(_mapper.Map <Entities.Master.UpdateDetails>(updateDetails),
                post => post.MapTo(updateDetails), _mapper);
Пример #19
0
        private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {
            Log.Info("Starting");
            if (_hasLoaded)
            {
                return;
            }
            _hasLoaded = true;
            var doingTable = false;

            try
            {
                if (Environment.GetCommandLineArgs().Any(x => x.ToLowerInvariant().Contains("table")))
                {
                    doingTable = true;
                }
            }
            catch (Exception)
            {
            }
            ThreadPool.QueueUserWorkItem(s =>
            {
                UpdateStatus("Checking For Update");
                UpdateDetails updateDetails = null;
                Task.Factory.StartNew(() => { updateDetails = UpdateManager.Instance.LatestVersion; });
                //#if(!DEBUG)
                if (doingTable == false)
                {
                    this.RandomMessage();
                    for (var i = 0; i < 20; i++)
                    {
                        Thread.Sleep(250);
                        if (cancel)
                        {
                            break;
                        }
                    }
                    while (updateDetails == null)
                    {
                        Thread.Sleep(250);
                    }
                    if (updateDetails.CanUpdate)
                    {
                        Dispatcher.Invoke(new Action(() => DownloadUpdate(updateDetails)));
                        return;
                    }
                    if (cancel)
                    {
                        this.UpdateCheckDone();
                        return;
                    }
                    this.ClearGarbage();
                    //CheckForXmlSetUpdates();
                }
                while (updateDetails == null)
                {
                    Thread.Sleep(250);
                }
                if (updateDetails.CanUpdate)
                {
                    Dispatcher.Invoke(new Action(() => DownloadUpdate(updateDetails)));
                    return;
                }
                this.LoadDatabase();
                this.UpdateGames(doingTable);
                GameFeedManager.Get().OnUpdateMessage -= GrOnUpdateMessage;
                UpdateCheckDone();
            });
            lblStatus.Text = "";
            Log.Info("Finished");
        }
Пример #20
0
        void bw_DoWorkUnzip(object sender, DoWorkEventArgs e)
        {
            Exception except = null;

            string updtDetailsFilename = Path.Combine(TempDirectory, "updtdetails.udt");

            try
            {
                ExtractUpdateFile();

                try
                {
                    // remove update file (it's no longer needed)
                    File.Delete(Filename);
                }
                catch { }


                // Try to load the update details file
                if (File.Exists(updtDetailsFilename))
                {
                    UpdtDetails = UpdateDetails.Load(updtDetailsFilename);
                }
                else
                {
                    throw new Exception("The update details file \"updtdetails.udt\" is missing.");
                }


                if (Directory.Exists(Path.Combine(TempDirectory, "patches")))
                {
                    // patch the files
                    foreach (UpdateFile file in UpdtDetails.UpdateFiles)
                    {
                        if (file.DeltaPatchRelativePath != null)
                        {
                            if (IsCancelled())
                            {
                                break;
                            }

                            string tempFilename = Path.Combine(TempDirectory, file.RelativePath);

                            // create the directory to store the patched file
                            if (!Directory.Exists(Path.GetDirectoryName(tempFilename)))
                            {
                                Directory.CreateDirectory(Path.GetDirectoryName(tempFilename));
                            }

                            while (true)
                            {
                                try
                                {
                                    using (FileStream original = File.Open(FixUpdateDetailsPaths(file.RelativePath), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                                        using (FileStream patch = File.Open(Path.Combine(TempDirectory, file.DeltaPatchRelativePath), FileMode.Open, FileAccess.Read, FileShare.Read))
                                            using (FileStream target = File.Open(tempFilename, FileMode.OpenOrCreate, FileAccess.ReadWrite))
                                            {
                                                VcdiffDecoder.Decode(original, patch, target, file.NewFileAdler32);
                                            }
                                }
                                catch (IOException IOEx)
                                {
                                    int HResult = Marshal.GetHRForException(IOEx);

                                    // if sharing violation
                                    if ((HResult & 0xFFFF) == 32)
                                    {
                                        // notify main window of sharing violation
                                        bw.ReportProgress(0, new object[] { -1, -1, string.Empty, ProgressStatus.SharingViolation, FixUpdateDetailsPaths(file.RelativePath) });

                                        // sleep for 1 second
                                        Thread.Sleep(1000);

                                        // stop waiting if cancelled
                                        if (IsCancelled())
                                        {
                                            break;
                                        }

                                        // retry file patch
                                        continue;
                                    }

                                    throw new PatchApplicationException("Patch failed to apply to this file: " + FixUpdateDetailsPaths(file.RelativePath) + "\r\n\r\nBecause that file failed to patch, and there's no \"catch-all\" update to download, the update failed to apply. The failure to patch usually happens because the file was modified from the original version. Reinstall the original version of this app.\r\n\r\n\r\nInternal error: " + IOEx.Message);
                                }
                                catch (Exception ex)
                                {
                                    throw new PatchApplicationException("Patch failed to apply to this file: " + FixUpdateDetailsPaths(file.RelativePath) + "\r\n\r\nBecause that file failed to patch, and there's no \"catch-all\" update to download, the update failed to apply. The failure to patch usually happens because the file was modified from the original version. Reinstall the original version of this app.\r\n\r\n\r\nInternal error: " + ex.Message);
                                }

                                // the 'last write time' of the patch file is really the 'lwt' of the dest. file
                                File.SetLastWriteTime(tempFilename, File.GetLastWriteTime(Path.Combine(TempDirectory, file.DeltaPatchRelativePath)));

                                break;
                            }
                        }
                    }


                    try
                    {
                        // remove the patches directory (frees up a bit of space)
                        Directory.Delete(Path.Combine(TempDirectory, "patches"), true);
                    }
                    catch { }
                }
            }
            catch (BadPasswordException ex)
            {
                except = new BadPasswordException("Could not install the encrypted update because the password did not match.");
            }
            catch (Exception ex)
            {
                except = ex;
            }

            if (IsCancelled() || except != null)
            {
                // report cancellation
                bw.ReportProgress(0, new object[] { -1, -1, "Cancelling update...", ProgressStatus.None, null });

                // Delete temporary files

                if (except != null && except.GetType() != typeof(PatchApplicationException))
                {
                    // remove the entire temp directory
                    try
                    {
                        Directory.Delete(OutputDirectory, true);
                    }
                    catch { }
                }
                else
                {
                    //only 'gut' the folder leaving the server file

                    string[] dirs = Directory.GetDirectories(TempDirectory);

                    foreach (string dir in dirs)
                    {
                        // delete everything but the self-update folder (AutoUpdate specific)
                        //Note: this code might be causing the "pyramid of death". TODO: Check.
                        if (Path.GetFileName(dir) == "selfupdate")
                        {
                            continue;
                        }

                        try
                        {
                            Directory.Delete(dir, true);
                        }
                        catch { }
                    }

                    // remove the update details
                    if (File.Exists(updtDetailsFilename))
                    {
                        File.Delete(updtDetailsFilename);
                    }
                }

                bw.ReportProgress(0, new object[] { -1, -1, string.Empty, ProgressStatus.Failure, except });
            }
            else
            {
                bw.ReportProgress(0, new object[] { -1, -1, string.Empty, ProgressStatus.Success, null });
            }
        }
Пример #21
0
        void bw_DoWorkUnzip(object sender, DoWorkEventArgs e)
        {
            Exception except = null;

            try
            {
                try
                {
                    // remove update file (it's no longer needed)
                    File.Delete(Filename);
                }
                catch { }

                var zipFiles = Directory.EnumerateFiles(TempDirectory, "*.zip");
                ExtractUpdateFiles(zipFiles);

                // Delete zip files
                foreach (string zipFile in zipFiles)
                {
                    try
                    {
                        File.Delete(zipFile);
                    }
                    catch { }
                }

                // Setup update details
                UpdtDetails = new UpdateDetails();

                var folders = Directory.EnumerateDirectories(OutputDirectory);
                foreach (string folder in folders)
                {
                    var files = Directory.EnumerateFiles(folder, "*", SearchOption.AllDirectories);
                    foreach (string file in files)
                    {
                        UpdtDetails.UpdateFiles.Add(new UpdateFile()
                        {
                            Filename = file,
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                except = ex;
            }

            if (IsCancelled() || except != null)
            {
                // report cancellation
                bw.ReportProgress(0, new object[] { -1, -1, "Cancelling update...", ProgressStatus.None, null });

                // Delete temporary files

                if (except != null && except.GetType() != typeof(PatchApplicationException))
                {
                    // remove the entire temp directory
                    try
                    {
                        Directory.Delete(OutputDirectory, true);
                    }
                    catch { }
                }

                bw.ReportProgress(0, new object[] { -1, -1, string.Empty, ProgressStatus.Failure, except });
            }
            else
            {
                bw.ReportProgress(0, new object[] { -1, -1, string.Empty, ProgressStatus.Success, null });
            }
        }
Пример #22
0
        /// <summary>Shows the selected update details.</summary>
        /// <param name="sender">The object that called the event.</param>
        /// <param name="e">The <c>System.Windows.RoutedEventArgs</c> instance containing the event data.</param>
        void ShowDetailsDialog(object sender, RoutedEventArgs e)
        {
            var details = new UpdateDetails();

            details.ShowDialog(this.hiddenUpdates[this.lvHiddenUpdates.SelectedIndex]);
        }
        void bw_DoWorkSelfUpdate(object sender, DoWorkEventArgs e)
        {
            Exception except = null;

            try
            {
                // extract downloaded self update
                ExtractUpdateFile();

                try
                {
                    // remove update file (it's no longer needed)
                    File.Delete(Filename);
                }
                catch { }

                //find and forcibly close oldClientLocation
                KillProcess(OldSelfLoc, FromAutoUpdate);

                string updtDetailsFilename = Path.Combine(OutputDirectory, "updtdetails.udt");

                if (File.Exists(updtDetailsFilename))
                {
                    UpdtDetails = UpdateDetails.Load(updtDetailsFilename);

                    //remove the file to prevent conflicts with the regular product update
                    File.Delete(updtDetailsFilename);
                }


                // generate files from patches
                CreatewyUpdateFromPatch();


                //find self in Path.Combine(OutputDirectory, "base")
                UpdateFile updateFile = FindNewClient();

                int retriedTimes = 0;

                while (true)
                {
                    try
                    {
                        FileAttributes atr             = File.GetAttributes(OldSelfLoc);
                        bool           resetAttributes = (atr & FileAttributes.Hidden) != 0 || (atr & FileAttributes.ReadOnly) != 0 || (atr & FileAttributes.System) != 0;

                        // remove the ReadOnly & Hidden atributes temporarily
                        if (resetAttributes)
                        {
                            File.SetAttributes(OldSelfLoc, FileAttributes.Normal);
                        }

                        //transfer new client to the directory (Note: this assumes a standalone wyUpdate - i.e. no dependencies)
                        File.Copy(NewSelfLoc, OldSelfLoc, true);

                        if (resetAttributes)
                        {
                            File.SetAttributes(OldSelfLoc, atr);
                        }
                    }
                    catch (IOException IOEx)
                    {
                        int HResult = Marshal.GetHRForException(IOEx);

                        // if sharing violation
                        if ((HResult & 0xFFFF) == 32)
                        {
                            // sleep for 1 second
                            Thread.Sleep(1000);

                            // stop waiting if cancelled
                            if (IsCancelled())
                            {
                                break;
                            }

                            // wait a maximum of 30 seconds
                            if (retriedTimes == 30)
                            {
                                throw;
                            }

                            // otherwise, retry file copy
                            ++retriedTimes;
                            continue;
                        }

                        throw;
                    }

                    break;
                }

                // Optimize client if necessary
                if (updateFile != null)
                {
                    NGenInstall(OldSelfLoc, updateFile);
                }

                //cleanup the client update files to prevent conflicts with the product update
                File.Delete(NewSelfLoc);
                Directory.Delete(Path.Combine(OutputDirectory, "base"));
            }
            catch (Exception ex)
            {
                except = ex;
            }

            if (IsCancelled() || except != null)
            {
                // report cancellation
                bw.ReportProgress(0, new object[] { -1, -1, "Cancelling update...", ProgressStatus.None, null });

                // Delete temporary files
                if (except != null && except.GetType() != typeof(PatchApplicationException))
                {
                    // remove the entire temp directory
                    try
                    {
                        Directory.Delete(OutputDirectory, true);
                    }
                    catch { }
                }
                else
                {
                    //only 'gut' the folder leaving the server file

                    string[] dirs = Directory.GetDirectories(TempDirectory);

                    foreach (string dir in dirs)
                    {
                        try
                        {
                            Directory.Delete(dir, true);
                        }
                        catch { }
                    }
                }

                bw.ReportProgress(0, new object[] { -1, -1, string.Empty, ProgressStatus.Failure, except });
            }
            else
            {
                bw.ReportProgress(0, new object[] { -1, -1, "Self update complete", ProgressStatus.Success, null });
            }
        }
        void bw_DoWorkExtractSelfUpdate(object sender, DoWorkEventArgs e)
        {
            Exception except = null;

            try
            {
                if (!Directory.Exists(OutputDirectory))
                {
                    Directory.CreateDirectory(OutputDirectory);
                }

                //extract downloaded self update
                ExtractUpdateFile();

                try
                {
                    // remove update file (it's no longer needed)
                    File.Delete(Filename);
                }
                catch { }


                string updtDetailsFilename = Path.Combine(OutputDirectory, "updtdetails.udt");

                if (File.Exists(updtDetailsFilename))
                {
                    UpdtDetails = UpdateDetails.Load(updtDetailsFilename);
                }


                // generate files from patches
                CreatewyUpdateFromPatch();


                //find self in Path.Combine(OutputDirectory, "base")
                FindNewClient();
            }
            catch (Exception ex)
            {
                except = ex;
            }

            if (IsCancelled() || except != null)
            {
                // report cancellation
                bw.ReportProgress(0, new object[] { -1, -1, "Cancelling update...", ProgressStatus.None, null });

                // Delete temporary files
                if (except != null)
                {
                    // remove the entire temp directory
                    try
                    {
                        Directory.Delete(OutputDirectory, true);
                    }
                    catch { }
                }

                bw.ReportProgress(0, new object[] { -1, -1, string.Empty, ProgressStatus.Failure, except });
            }
            else
            {
                bw.ReportProgress(0, new object[] { -1, -1, "Self update extraction complete", ProgressStatus.Success, null });
            }
        }
        void PrepareStepOn(UpdateStepOn step)
        {
            switch (step)
            {
            case UpdateStepOn.Checking:

                ShowFrame(Frame.Checking);

                break;

            case UpdateStepOn.UpdateAvailable:

                ShowFrame(Frame.UpdateInfo);

                break;

            case UpdateStepOn.UpdateDownloaded:

                // set the update step pending (extracting)
                update.CurrentlyUpdating = UpdateOn.Extracting;

                needElevation = NeedElevationToUpdate();

                // show frame InstallUpdate
                ShowFrame(Frame.InstallUpdates);

                // put a checkmark next to downloaded
                panelDisplaying.UpdateItems[0].Status = UpdateItemStatus.Success;

                break;

            case UpdateStepOn.UpdateReadyToInstall:

                string updtDetailsFilename = Path.Combine(tempDirectory, "updtdetails.udt");

                // Try to load the update details file

                if (File.Exists(updtDetailsFilename))
                {
                    updtDetails = UpdateDetails.Load(updtDetailsFilename);
                }
                else
                {
                    throw new Exception("Update details file does not exist.");
                }

                // set the update step pending (closing processes & installing files, etc.)
                update.CurrentlyUpdating = UpdateOn.ClosingProcesses;

                needElevation = NeedElevationToUpdate();

                // show frame InstallUpdate
                ShowFrame(Frame.InstallUpdates);

                // put a checkmark next to downloaded
                panelDisplaying.UpdateItems[0].Status = UpdateItemStatus.Success;

                // set the "Extracting" text
                SetStepStatus(1, clientLang.Extract);

                break;

            default:
                throw new Exception("Can't restore from this automatic update state: " + step);
            }
        }
        void bw_DoWorkInstallSelfUpdate(object sender, DoWorkEventArgs e)
        {
            Exception except = null;

            try
            {
                string updtDetailsFilename = Path.Combine(OutputDirectory, "updtdetails.udt");

                if (File.Exists(updtDetailsFilename))
                {
                    UpdtDetails = UpdateDetails.Load(updtDetailsFilename);
                }

                //find self in Path.Combine(OutputDirectory, "base")
                UpdateFile updateFile = FindNewClient();

                //find and forcibly close oldClientLocation
                KillProcess(OldSelfLoc, FromAutoUpdate);

                int retriedTimes = 0;

                while (true)
                {
                    try
                    {
                        FileAttributes atr             = File.GetAttributes(OldSelfLoc);
                        bool           resetAttributes = (atr & FileAttributes.Hidden) != 0 || (atr & FileAttributes.ReadOnly) != 0 || (atr & FileAttributes.System) != 0;

                        // remove the ReadOnly & Hidden atributes temporarily
                        if (resetAttributes)
                        {
                            File.SetAttributes(OldSelfLoc, FileAttributes.Normal);
                        }

                        //transfer new client to the directory (Note: this assumes a standalone client - i.e. no dependencies)
                        File.Copy(NewSelfLoc, OldSelfLoc, true);

                        if (resetAttributes)
                        {
                            File.SetAttributes(OldSelfLoc, atr);
                        }
                    }
                    catch (IOException IOEx)
                    {
                        int HResult = Marshal.GetHRForException(IOEx);

                        // if sharing violation
                        if ((HResult & 0xFFFF) == 32)
                        {
                            // sleep for 1 second
                            Thread.Sleep(1000);

                            // stop waiting if cancelled
                            if (IsCancelled())
                            {
                                break;
                            }

                            // wait a maximum of 30 seconds
                            if (retriedTimes == 30)
                            {
                                throw;
                            }

                            // otherwise, retry file copy
                            ++retriedTimes;
                            continue;
                        }

                        throw;
                    }

                    break;
                }

                //Optimize client if necessary
                if (updateFile != null)
                {
                    NGenInstall(OldSelfLoc, updateFile);
                }
            }
            catch (Exception ex)
            {
                except = ex;
            }


            if (IsCancelled() || except != null)
            {
                // report cancellation
                bw.ReportProgress(0, new object[] { -1, -1, "Cancelling update...", ProgressStatus.None, null });

                // Delete temporary files
                if (except != null)
                {
                    // remove the entire temp directory
                    try
                    {
                        Directory.Delete(OutputDirectory, true);
                    }
                    catch { }
                }

                bw.ReportProgress(0, new object[] { -1, -1, string.Empty, ProgressStatus.Failure, except });
            }
            else
            {
                bw.ReportProgress(0, new object[] { -1, -1, "Self update complete", ProgressStatus.Success, null });
            }
        }
Пример #27
0
        /// <summary>Shows the selected update details.</summary>
        /// <param name="sender">The object that called the event.</param>
        /// <param name="e">The <c>System.Windows.RoutedEventArgs</c> instance containing the event data.</param>
        void ShowDetailsDialog(object sender, RoutedEventArgs e)
        {
            var details = new UpdateDetails();

            details.ShowDialog(this.updateHistory[this.lvUpdateHistory.SelectedIndex]);
        }
Пример #28
0
 public void Update(UpdateDetails update) =>
 _dbContext.Update(update);
Пример #29
0
        /// <summary>Shows the selected update details.</summary>
        /// <param name="sender">The object that called the event.</param>
        /// <param name="e">The <c>System.Windows.Input.MouseButtonEventArgs</c> instance containing the event data.</param>
        void ShowDetails(object sender, MouseButtonEventArgs e)
        {
            if (e.ClickCount != 2 || this.lvUpdateHistory.SelectedIndex == -1)
            {
                return;
            }

            var details = new UpdateDetails();
            details.ShowDialog(this.updateHistory[this.lvUpdateHistory.SelectedIndex]);
        }
Пример #30
0
 /// <summary>Shows the selected update details.</summary>
 /// <param name="sender">The object that called the event.</param>
 /// <param name="e">The <c>System.Windows.RoutedEventArgs</c> instance containing the event data.</param>
 void ShowDetailsDialog(object sender, RoutedEventArgs e)
 {
     var details = new UpdateDetails();
     details.ShowDialog(this.updateHistory[this.lvUpdateHistory.SelectedIndex]);
 }
Пример #31
0
    /// <summary>
    /// Save the current state of the game (both locally, and on Facebook)
    /// </summary>
    void Save(string persPath)
    {
        BinaryFormatter formatter = new BinaryFormatter();

        // save to database
        if (facebookProfile != null && facebookProfile.id.Length > 0)
        {
            FileStream fbFile = File.Create(persPath + "/facebook.gd");

            PlayerData fbData = new PlayerData(ShopController.theScreens, carpetColour, staffMembers, filmShowings, financeController.GetNumCoins(), currDay, financeController.GetNumPopcorn(), ShopController.otherObjects, shopController.hasUnlockedRedCarpet, isMarbleFloor, customerController.reputation, boxOfficeLevel, foodArea, shopController.postersUnlocked, options);

            formatter.Serialize(fbFile, fbData);

            fbFile.Close();

            byte[] ba = ConvertToByteArray(persPath);

            string outputting = System.Text.Encoding.UTF8.GetString(ba);

            UpdateDetails ud = new UpdateDetails();
            ud.DoUpdate(facebookProfile.id, ba);

            saveState = 1;

        }
        else
        {

            FileStream file = File.Create(persPath + "/saveState.gd");

            PlayerData data = new PlayerData(ShopController.theScreens, carpetColour, staffMembers, filmShowings, financeController.GetNumCoins(), currDay, financeController.GetNumPopcorn(), ShopController.otherObjects, shopController.hasUnlockedRedCarpet, isMarbleFloor, customerController.reputation, boxOfficeLevel, foodArea, shopController.postersUnlocked, options);

            formatter.Serialize(file, data);

            file.Close();
        }
    }
Пример #32
0
        private async void FinishButton(object sender, RoutedEventArgs e)
        {
            var button = (Button)sender;

            button.IsEnabled        = false;
            userPlane.Visibility    = Visibility.Collapsed;
            dataRec.Visibility      = Visibility.Visible;
            detailsButton.IsEnabled = false;
            if (string.IsNullOrEmpty(PoeSessIdText.Text) || string.IsNullOrEmpty(UserNameText.Text) || string.IsNullOrEmpty(StashTabIndex.Text))
            {
                MessageBox.Show("Please fill every TextBox!");
                button.IsEnabled        = true;
                detailsButton.IsEnabled = true;
                userPlane.Visibility    = Visibility.Visible;
                dataRec.Visibility      = Visibility.Collapsed;
                return;
            }

            if (!new Regex(@"^[0-9]+(\,[0-9]+)*$").IsMatch(StashTabIndex.Text))
            {
                MessageBox.Show("Please use valid numbers for the Stash Tab Index.");
                button.IsEnabled        = true;
                detailsButton.IsEnabled = true;
                userPlane.Visibility    = Visibility.Visible;
                dataRec.Visibility      = Visibility.Collapsed;
                return;
            }
            List <string> errors = new List <string>();

            Main.Harvests.Clear();

            foreach (var split in StashTabIndex.Text.Split(","))
            {
                if (!int.TryParse(split, out int res))
                {
                    errors.Add($"{split} is not a valid number for stash index \r\n");
                    continue;
                }
                if (res == 0)
                {
                    errors.Add($"Stash tab index cannot be 0 or negative! \r\n");
                    continue;
                }
                var baseAddress     = new Uri("https://www.pathofexile.com/character-window/get-stash-items?league=Harvest&tabs=0&tabIndex=" + (res - 1).ToString() + "&accountName=" + UserNameText.Text);
                var cookieContainer = new CookieContainer();
                using var handler = new HttpClientHandler()
                      {
                          CookieContainer = cookieContainer
                      };

                using var client = new HttpClient(handler)
                      {
                          BaseAddress = baseAddress
                      };
                client.DefaultRequestHeaders.Add("User-Agent", "Harvest Beta 3_3 Horticrafting station extraction tool githubdotcomslashJeyR01slashHarvester");
                cookieContainer.Add(baseAddress, new Cookie("POESESSID", PoeSessIdText.Text));
                var result = await client.PostAsync(baseAddress, null);

                if (result.IsSuccessStatusCode)
                {
                    var resp = await result.Content.ReadAsStringAsync();

                    try
                    {
                        JObject jsont = JObject.Parse(resp);

                        JArray array = (JArray)jsont["items"];

                        if (array == null || array.Count == 0)
                        {
                            errors.Add($"Couldn't find any items in the selected stash tab ({split})! \r\n");
                            Thread.Sleep(1000);
                            continue;
                        }

                        foreach (var item in array)
                        {
                            var nametoken = item["typeLine"];
                            if (nametoken == null)
                            {
                                continue;
                            }
                            var name = (string)nametoken;
                            if (name != null && name == "Horticrafting Station")
                            {
                                var mods = (JArray)item["craftedMods"];
                                if (mods != null && mods.Count != 0)
                                {
                                    var      note       = item["note"];
                                    string[] priceNotes = new string[3] {
                                        "-", "-", "-"
                                    };
                                    if (note != null)
                                    {
                                        try
                                        {
                                            var notsplit = (string)note;
                                            if (notsplit.Count(p => p == '/') == 2)
                                            {
                                                priceNotes = notsplit.Split("/");
                                            }
                                        }
                                        catch (Exception)
                                        {
                                        }
                                    }
                                    for (int i = 0; i < mods.Count; i++)
                                    {
                                        var modname = (string)mods[i];
                                        modname = modname.Replace("{", string.Empty).Replace("}", string.Empty).Replace("<white>", string.Empty);
                                        modname = modname.Remove(modname.Length - 4, 4);


                                        if (Main.Harvests.Any(p => p.Name == modname))
                                        {
                                            var craft = Main.Harvests.First(p => p.Name == modname);
                                            craft.Count++;
                                            if (priceNotes[i] != "-")
                                            {
                                                craft.SetPrice(priceNotes[i]);
                                            }
                                        }
                                        else
                                        {
                                            var craft = new HarvestData(Main.CheckBaseType(modname))
                                            {
                                                Comment = "Write a comment here!",
                                                Count   = 1,
                                                Name    = modname,
                                                //Price = "40c",
                                                //Type = Main.CheckBaseType(modname)
                                            };
                                            Main.Harvests.Add(craft);

                                            if (priceNotes[i] != "-")
                                            {
                                                craft.SetPrice(priceNotes[i]);
                                            }
                                        }

                                        //<white>{Remove} a random <white>{non-Life} modifier from an item and <white>{add} a new <white>{Life} modifier (78)
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        errors.Add($"Requesting Stash Tab {split} failed. \r\n");
                    }
                }
                else
                {
                    errors.Add($"Requesting Stash Tab {split} failed. Webserver responded with statuscode {result.StatusCode} \r\n");
                    //button.IsEnabled = true;
                    //userPlane.Visibility = Visibility.Visible;
                    //dataRec.Visibility = Visibility.Collapsed;
                    //break;
                }

                Thread.Sleep(1000); // as to not hammer the API
            }

            LatestDetails = new UpdateDetails
            {
                Sessionid = PoeSessIdText.Text,
                StashTabs = StashTabIndex.Text,
                UserName  = UserNameText.Text
            };
            SaveLastLogin();

            if (errors.Any(p => p != null))
            {
                var stringb = new StringBuilder();
                foreach (var item in errors.Where(p => p != null))
                {
                    stringb.Append(item);
                }
                MessageBox.Show(stringb.ToString());
                button.IsEnabled        = true;
                detailsButton.IsEnabled = true;
                userPlane.Visibility    = Visibility.Visible;
                dataRec.Visibility      = Visibility.Collapsed;
            }
            else
            {
                if (Main.Harvests.Any())
                {
                    MessageBox.Show("Successfully loaded the stash tabs!");
                    App.Current.Windows.OfType <PoeStashWindow>().First().Close();
                }
                else
                {
                    MessageBox.Show("Couldn't find any horti stations in the selectd stash tabs.");
                    button.IsEnabled        = true;
                    detailsButton.IsEnabled = true;
                    userPlane.Visibility    = Visibility.Visible;
                    dataRec.Visibility      = Visibility.Collapsed;
                }
            }
        }
Пример #33
0
 public void Add(UpdateDetails update) =>
 _dbContext.Add(update);