예제 #1
0
        /// <summary>
        /// 确认导入语言包事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void dpSave_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            UC_ImportLan uc_Import = LanManagerWindow.dpDetail.Children[0] as UC_ImportLan;

            BeginImportLanguagePackage(uc_Import);

            //LanManagerWindow.spOperator.Children.RemoveAt(1);
            //UC_DBOpeartionDefault defaultWin = new UC_DBOpeartionDefault(LanManagerWindow);
            //LanManagerWindow.spOperator.Children.Add(defaultWin);
            //LanManagerWindow.dpDetail.Children.Clear();
        }
예제 #2
0
        private void BeginImportLanguagePackage(UC_ImportLan uc_Import)
        {
            string LStrLanguagePackageFile = string.Empty;
            string LStrDecryptionPassword  = string.Empty;

            bool   LBoolCallReturn = true;
            string LStrCallReturn  = string.Empty;

            bool LBoolIsAllowImport = false;

            Stream LStreamXmlBody = null;

            try
            {
                #region 导入信息的逻辑判断
                LStrLanguagePackageFile = uc_Import.txtLanFile.Text;
                if (string.IsNullOrEmpty(LStrLanguagePackageFile))
                {
                    MessageBox.Show(this.TryFindResource("FilePathNotNull").ToString(),
                                    this.TryFindResource("ErrorMsgTitle").ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                if (uc_Import.txtLanPwd.IsEnabled == false)
                {
                    LStrDecryptionPassword = "******";
                }
                else
                {
                    LStrDecryptionPassword = uc_Import.txtLanPwd.Password.Trim();
                }
                if (string.IsNullOrEmpty(LStrDecryptionPassword))
                {
                    MessageBox.Show(this.TryFindResource("LanFilePwdNotNull").ToString(),
                                    this.TryFindResource("ErrorMsgTitle").ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                LBoolCallReturn = uc_Import.TryDecryptionLanguagePackage(LStrLanguagePackageFile, LStrDecryptionPassword, ref LStrCallReturn);
                if (!LBoolCallReturn)
                {
                    MessageBox.Show(this.TryFindResource("SaveFileError").ToString(),
                                    this.TryFindResource("ErrorMsgTitle").ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                foreach (string LStrSingleLanguageCode in IListStrAllowSurportLanguageCode)
                {
                    if (LStrSingleLanguageCode == LStrCallReturn)
                    {
                        LBoolIsAllowImport = true; break;
                    }
                }
                strImportLanguageType = LStrCallReturn;

                if (!LBoolIsAllowImport)
                {
                    string strError = string.Format(this.TryFindResource("Error001").ToString(), LStrCallReturn);
                    MessageBox.Show(strError,
                                    this.TryFindResource("ErrorMsgTitle").ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                string           strMsg            = string.Format(this.TryFindResource("Confirm001").ToString(), LStrCallReturn);
                MessageBoxResult LMessageBoxResult = MessageBox.Show(strMsg,
                                                                     this.TryFindResource("ErrorMsgTitle").ToString(), MessageBoxButton.YesNo, MessageBoxImage.Question);
                if (LMessageBoxResult != MessageBoxResult.Yes)
                {
                    return;
                }
                //IStrLanguageCode = LStrCallReturn;
                #endregion

                // this.MainPanel.IsEnabled = false;

                #region 导入数据的读取到XmlNode
                XmlDocument LXmlDocTableDataLoaded = new XmlDocument();
                LStreamXmlBody = new MemoryStream(Encoding.UTF8.GetBytes(uc_Import.IStrLanguagePackageBody));
                LXmlDocTableDataLoaded.Load(LStreamXmlBody);
                IXMLNodeTableDataRowsList = LXmlDocTableDataLoaded.SelectSingleNode("LanguageDataRowsList");
                IIntAllRows = IXMLNodeTableDataRowsList.ChildNodes.Count;

                ComboBoxItem LComboBoxItem = uc_Import.cmbImoprtOptions.SelectedItem as ComboBoxItem;
                IStrImportOptions = LComboBoxItem.DataContext.ToString();
                #endregion

                IBoolHaveError = false;
                IIntCurrentRow = 0;
                if (IStrImportOptions == "Refresh")
                {
                    ImportOtionsIsOnlyRefresh();
                }
                else
                {
                    ImportOtionsIsAppendUpdate();
                }
            }
            catch (Exception ex)
            {
                LanManagerWindow.IsEnabled = true;

                MessageBox.Show(ex.Message,
                                this.TryFindResource("ErrorMsgTitle").ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }