Exemplo n.º 1
0
        public void BindingUpgradeGroup(UpgradeGroup group)
        {
            Guard.ArgumentNotNull(group, "Upgrade group.");

            txtGroupName.Text = group.Name;
            txtTarget.Text = group.Target;

            lvItems.Items.Clear();
            foreach (UpgradeItem upItem in group.Items) {
                ListViewItem item = new ListViewItem(upItem.Name, 1);
                item.Tag = upItem;
                lvItems.Items.Add(item);
            }
        }
Exemplo n.º 2
0
        private void UpgradeFiles(UpgradeGroup group)
        {
            logger.Info(String.Format("׼��������:{0} ", group.Name));

            // �������µ�Ŀ���ļ���
            string targetPath = group.Target.IndexOf("${RootPath}") != -1 ? Path.Combine(ROOT_PATH, group.Target.Substring(11, group.Target.Length - 11)) : group.Target;
            if (!Directory.Exists(targetPath))
                Directory.CreateDirectory(targetPath);

            foreach (UpgradeItem item in group.Items)
            {
                string srcfile = Path.Combine(upgradePath, item.Name);
                string tarfile = Path.Combine(targetPath, item.Name);
                if (!File.Exists(srcfile))
                {
                    logger.Info(String.Format("���� {0} ���ɹ����´��ļ�ʧ��", item.Name));
                    continue;
                }

                try
                {
                    logger.Info(String.Format("ɾ�������µľɰ汾�ļ� {0}", tarfile));
                    File.Delete(tarfile);
                    logger.Info(String.Format("�����ļ� {0}", item.Name));
                    File.Move(srcfile, tarfile);
                    logger.Info(String.Format("�����ļ� {0} �ɹ�", item.Name));
                }
                catch (Exception ex)
                {
                    logger.Info(String.Format("�����ļ� {0} ʧ��,����ԭ��Ϊ:", item.Name, ex.Message));
                }
            }
            logger.Info(String.Format("��ɸ�����:{0} ", group.Name));
        }
Exemplo n.º 3
0
        private void UpdateUpgradeGroup()
        {
            if (String.IsNullOrEmpty(txtGroupName.Text) || String.IsNullOrEmpty(txtTarget.Text))
            {
                XtraMessageBox.Show("����Ϊ������Ŀ���ṩһ�����ƺ�Ŀ���ļ���λ�á�");
                txtGroupName.Focus();
                return;
            }
            int index = -1;
            foreach (ListViewItem item in lvGroups.Items)
            {
                if (item.Text == txtGroupName.Text)
                {
                    index = item.Index;
                    lvGroups.Items.Remove(item);
                    break;
                }
            }

            UpgradeGroup group = new UpgradeGroup(txtGroupName.Text.Trim(), txtTarget.Text.Trim());
            foreach (ListViewItem item in lvItems.Items)
                group.Items.Add(item.Tag as UpgradeItem);
            ListViewItem groupItem = new ListViewItem(group.Name, 0);
            groupItem.Tag = group;
            if (index != -1)
                lvGroups.Items.Insert(index, groupItem);
            else
                lvGroups.Items.Add(groupItem);
            upgradeItemChanged = false;
        }
Exemplo n.º 4
0
        /// <summary>
        /// ѡ��������Ŀ����ڳ���
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DevExpress.XtraEditors.Controls.ButtonPressedEventArgs"/> instance containing the event data.</param>
        private void txtStartUpApp_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            OpenFileDialog opendlg = new OpenFileDialog();
            opendlg.Multiselect = false;
            opendlg.Title = "ѡ��";
            opendlg.Filter = "��ִ�г���(*.exe)|*.exe";
            if (opendlg.ShowDialog() == DialogResult.OK) {
                txtStartUpApp.Text = Path.GetFileName(opendlg.FileName);
                txtProduct.Text = Path.GetFileNameWithoutExtension(opendlg.FileName);

                // ��������Ŀ�в�������������
                UpgradeGroup group = new UpgradeGroup("StartUp", "${RootPath}");
                group.Items.Add(new UpgradeItem(opendlg.FileName));
                foreach (ListViewItem item in lvGroups.Items) {
                    UpgradeGroup gr = item.Tag as UpgradeGroup;
                    if (gr != null && gr.Name == "StartUp") {
                        lvGroups.Items.Remove(item);
                        break;
                    }
                }
                ListViewItem groupItem = new ListViewItem(group.Name);
                groupItem.Tag = group;
                lvGroups.Items.Insert(0, groupItem);
                BindingUpgradeGroup(group);

                try {
                    AssemblyName assemblyName = Assembly.ReflectionOnlyLoadFrom(opendlg.FileName).GetName();
                    txtVersion.Text = assemblyName.Version.ToString();
                }
                catch {
                    UpgradeProject proj = Presenter.UpgradeService.GetUpgradeProject(txtProduct.Text.Trim()); // �ӷ������������ݿ��л�ȡ�µİ汾��
                    if (proj != null) {
                        Version ver = new Version(proj.Version);
                        txtVersion.Text = String.Format("{0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Build, ver.Revision + 1);
                    }
                    else
                        txtVersion.Text = "1.0.0.0";
                }
            }
            txtUpgradeUrl.Text = Presenter.UpgradeSetting.UpgradeUrl;
            txtUpgradeUrl.SelectAll();
            txtUpgradeUrl.Focus();
        }