Ejemplo n.º 1
0
 public void ReceiveMember(MessageMember m)
 {
     if (m.Message == "Add")
     {
         members.Add(new Member(m.FirstName, m.LastName, m.Email));
         add.Close();
         //Add new member and then save it to the data base
         members.Save();
         this.RaisePropertyChanged(() => members.Members);
     }
     else if (m.Message.Equals("Close"))
     {
         if (add != null)
         {
             add.Close();
         }
         else if (update != null)
         {
             update.Close();
         }
     }
     else if (m.Message.Equals("Update"))
     {
         members.Update(selected, m);
         update.Close();
         members.Save();
         this.RaisePropertyChanged(() => members.Members);
     }
 }
Ejemplo n.º 2
0
        public static void Update()
        {
            var          webClient    = new WebClient();
            UpdateWindow updateWindow = null;

            try
            {
                var json          = webClient.DownloadString("https://loriswit.com/rlcm/latest.json");
                var latestVersion = new JavaScriptSerializer().Deserialize <Version>(json);

                if (App.Version.Number >= latestVersion.Number)
                {
                    return;
                }

                updateWindow = new UpdateWindow(latestVersion);
                updateWindow.Show();

                var path    = Environment.GetCommandLineArgs().First();
                var oldPath = path + "_tmp.exe";
                var newPath = path + "_" + latestVersion.Number + ".exe";

                // delete temporary files in case they still exist
                File.Delete(newPath);
                File.Delete(oldPath);

                webClient.DownloadFile(latestVersion.Url, newPath);

                // if download succeeded, rename the current program
                File.Move(path, oldPath);
                File.Move(newPath, path);

                // start the new version
                var process = new Process {
                    StartInfo = { FileName = path, Arguments = "--updated" }
                };
                process.Start();

                Application.Current.Shutdown();
            }
            catch (WebException)
            {
                // ignore failed update
            }
            finally
            {
                updateWindow?.Close();
            }
        }
Ejemplo n.º 3
0
        protected void UpdateFile_Click(object sender, DirectEventArgs e)
        {
            string uid = upload_uid.Text;

            try
            {
                string filename    = Path.GetFileName(FileUploadField1.PostedFile.FileName);
                string contentType = FileUploadField1.PostedFile.ContentType;
                using (Stream fs = FileUploadField1.PostedFile.InputStream)
                {
                    using (BinaryReader br = new BinaryReader(fs))
                    {
                        byte[] bytes = br.ReadBytes((Int32)fs.Length);
                        using (MySqlConnection con = new MySqlConnection(MySqlString))
                        {
                            string query = "UPDATE pat_monthdoc SET Month=@Month, Name=@FileName, Content=@Content, Size=@FileSize, SaveDateTime=@SaveDateTime, User=@UserName ";
                            query += "WHERE uid=" + uid;
                            using (MySqlCommand cmd = new MySqlCommand(query))
                            {
                                cmd.Connection = con;
                                cmd.Parameters.AddWithValue("@Month", UYearMonth.Text);
                                cmd.Parameters.AddWithValue("@FileName", filename);
                                cmd.Parameters.AddWithValue("@Content", bytes);
                                cmd.Parameters.AddWithValue("@FileSize", bytes.Length.ToString());
                                cmd.Parameters.AddWithValue("@SaveDateTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                                cmd.Parameters.AddWithValue("@UserName", _USER_NAME);
                                con.Open();
                                cmd.ExecuteNonQuery();
                                con.Close();
                            }
                        }
                    }
                }
                Common._NotificationShow("上传成功");
                UpdateWindow.Close();
                show_grid();
            }
            catch (Exception ex)
            {
                Common._ErrorMsgShow("上传失败:" + ex.Message.ToString());
            }
        }