Esempio n. 1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Does the import.
		/// </summary>
		/// <param name="dlg">The progress dialog.</param>
		/// <param name="parameters">The parameters: 1) runToCompletion flag, 2) array of
		/// LanguageMappings, 3) start phase.</param>
		/// <returns>Returns <c>true</c> if we did the complete import, false if we
		/// quit early.</returns>
		/// ------------------------------------------------------------------------------------
		public object Import(IAdvInd4 dlg, params object[] parameters)
		{
			Debug.Assert(parameters.Length == 3);
			bool runToCompletion = (bool)parameters[0];
			m_languageMappings = (LanguageMapping[])parameters[1];
			int startPhase = (int)parameters[2];
			m_ai = dlg as IAdvInd;
			m_LinguaLinksXmlFileName = m_nextInput;

			m_sErrorMsg = ITextStrings.ksTransformProblem;
			m_shownProgress = m_phaseProgressStart = 0;
			m_phaseProgressEnd = 150;
			if (startPhase < 2)
			{
				dlg.Title = ITextStrings.ksLLImportProgress;
				dlg.Message = ITextStrings.ksLLImportPhase1;
				m_sErrorMsg = ITextStrings.ksTransformProblem1;
				if (!Convert1())
					return false;
			}
			else
			{
				m_ai.Step(150);
			}
			if (m_fCancel)
				return false;

			if (startPhase < 3)
			{
				m_sErrorMsg = ITextStrings.ksTransformProblem2;
				dlg.Message = ITextStrings.ksLLImportPhase2;
				Convert2();
			}
			m_ai.Step(75);
			if (m_fCancel)
				return false;

			if (startPhase < 4)
			{
				m_sErrorMsg = ITextStrings.ksTransformProblem3;
				dlg.Message = ITextStrings.ksLLImportPhase3;
				Convert3();
			}
			m_ai.Step(75);
			if (m_fCancel)
				return false;

			// There should be some contents in the phase 3 file if
			// the process is valid and is using a valid file.
			// Make sure the file isn't empty and show msg if it is.
			FileInfo fi = new FileInfo(m_sTempDir + "LLPhase3Output.xml");
			if (fi.Length == 0)
			{
				ReportError(String.Format(ITextStrings.ksInvalidLLFile, m_LinguaLinksXmlFileName),
					ITextStrings.ksLLImport);
				throw new InvalidDataException();
			}

			// There's no way to cancel from here on out.
			if (dlg is ProgressDialogWithTask)
				((ProgressDialogWithTask)dlg).CancelButtonVisible = false;

			if (runToCompletion)
			{
				m_sErrorMsg = ITextStrings.ksXMLParsingProblem4;
				dlg.Message = ITextStrings.ksLLImportPhase4;
				if (Convert4())
				{

					m_sErrorMsg = ITextStrings.ksFinishLLTextsProblem5;
					dlg.Message = ITextStrings.ksLLImportPhase5;
					m_shownProgress = m_phaseProgressStart = dlg.Position;
					m_phaseProgressEnd = 500;
					Convert5();
					return true;
				}
			}
			return false;
		}
Esempio n. 2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Loads FieldWorks data into the cache from the result set defined by the SQL
		/// statement. In this implementation we do nothing here.
		/// </summary>
		/// <param name="bstrSqlStmt"></param>
		/// <param name="_dcs"></param>
		/// <param name="hvoBase"></param>
		/// <param name="nrowMax"></param>
		/// <param name="_advi"></param>
		/// <param name="fNotifyChange"></param>
		/// ------------------------------------------------------------------------------------
		public void Load(string bstrSqlStmt, IDbColSpec _dcs, int hvoBase, int nrowMax, IAdvInd _advi, bool fNotifyChange)
		{
			CheckDisposed();
		}
Esempio n. 3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// does the import
        /// </summary>
        /// <param name="dlg">The progress dialog.</param>
        /// <param name="parameters">The parameters: 1) runToCompletion, 2) last step,
        /// 3) start phase, 4) database file name, 5) number of entries, 6) true to display
        /// the import report, 7) name of phase 1 HTML report file, 8) name of phase 1 file.
        /// </param>
        /// <returns><c>true</c> if import was successful, otherwise <c>false</c>.</returns>
        /// ------------------------------------------------------------------------------------
        public object Import(IAdvInd4 dlg, params object[] parameters)
        {
            Debug.Assert(parameters.Length == 8);
            bool   runToCompletion  = (bool)parameters[0];
            int    lastStep         = (int)parameters[1];
            int    startPhase       = (int)parameters[2];
            string databaseFileName = (string)parameters[3];
            int    cEntries         = (int)parameters[4];

            m_fDisplayImportReport = (bool)parameters[5];
            m_sPhase1HtmlReport    = (string)parameters[6];
            m_sPhase1FileName      = (string)parameters[7];

            string sErrorMsg          = LexTextControls.ksTransformProblem_X;
            bool   fAttemptedXml      = false;
            bool   fXmlOk             = false;
            string processedInputFile = databaseFileName;
            string sPhase1Output      = Path.Combine(m_sTempDir, s_sPhase1FileName);
            string sPhase2Output      = Path.Combine(m_sTempDir, s_sPhase2FileName);
            string sPhase3Output      = Path.Combine(m_sTempDir, s_sPhase3FileName);

            m_sPhase4Output = Path.Combine(m_sTempDir, s_sPhase4FileName);

            try
            {
                // if starting with a phase file, rename the phase file with the input file
                switch (startPhase)
                {
                case 1: sPhase1Output = databaseFileName; break;

                case 2: sPhase2Output = databaseFileName; break;

                case 3: sPhase3Output = databaseFileName; break;

                case 4: m_sPhase4Output = databaseFileName; break;

                default: break;                         // no renaming needed
                }

                IAdvInd ai = dlg as IAdvInd;

                if (startPhase < 2)
                {
                    dlg.Title = String.Format(LexTextControls.ksImportingXEntriesFromY,
                                              cEntries, processedInputFile);
                    dlg.Message = String.Format(LexTextControls.ksPhase1ofX_Preview, lastStep);
                    sErrorMsg   = LexTextControls.ksTransformProblemPhase1_X;
                    DoTransform(m_sBuildPhase2XSLT, sPhase1Output, m_sPhase2XSLT);
                }
                ai.Step(10);
                if (m_fCancel)
                {
                    return(false);
                }

                sErrorMsg   = LexTextControls.ksTransformProblemPhase2_X;
                dlg.Message = String.Format(LexTextControls.ksPhase2ofX, lastStep);
                if (startPhase < 2)
                {
                    DoTransform(m_sPhase2XSLT, sPhase1Output, sPhase2Output);
                }
                ai.Step(10);
                if (m_fCancel)
                {
                    return(false);
                }

                sErrorMsg   = LexTextControls.ksTransformProblemPhase3_X;
                dlg.Message = String.Format(LexTextControls.ksPhase3ofX, lastStep);
                if (startPhase < 3)
                {
                    DoTransform(m_sPhase3XSLT, sPhase2Output, sPhase3Output);
                }
                ai.Step(10);
                if (m_fCancel)
                {
                    return(false);
                }

                sErrorMsg   = LexTextControls.ksTransformProblemPhase4_X;
                dlg.Message = String.Format(LexTextControls.ksPhase4ofX, lastStep);
                if (startPhase < 4)
                {
                    DoTransform(m_sPhase4XSLT, sPhase3Output, m_sPhase4Output);
                }
                ai.Step(20);
                if (m_fCancel)
                {
                    return(false);
                }

                if (runToCompletion)
                {
                    sErrorMsg   = LexTextControls.ksXmlParsingProblem5_X;
                    dlg.Message = LexTextControls.ksPhase5of5_LoadingData;
                    IFwXmlData2 fxd = FwXmlDataClass.Create();
                    fxd.Open(m_cache.ServerName, m_cache.DatabaseName);
                    int hvoOwner = m_cache.LangProject.LexDbOA.Hvo;
                    int flid     = (int)LexDb.LexDbTags.
                                   kflidEntries;
                    if (m_fCancel)
                    {
                        return(false);
                    }
                    ai.Step(1);
                    // There's no way to cancel from here on out.
                    if (dlg is ProgressDialogWithTask)
                    {
                        ((ProgressDialogWithTask)dlg).CancelButtonVisible = false;
                    }
                    fAttemptedXml = true;
                    if (startPhase == 4 && processedInputFile.Length == 0)
                    {
                        processedInputFile = m_sPhase4Output;
                    }
                    fxd.put_BaseImportDirectory(processedInputFile.Substring(0,
                                                                             processedInputFile.LastIndexOfAny(new char[2] {
                        '\\', '/'
                    })));
                    fxd.ImportXmlObject(m_sPhase4Output, hvoOwner, flid, ai);
                    fXmlOk    = true;
                    sErrorMsg = LexTextControls.ksLogFileProblem5_X;
                    ProcessLogFile(processedInputFile, startPhase);
                    return(true);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Error: " + ex.Message);

                ReportError(string.Format(sErrorMsg, ex.Message), LexTextControls.ksUnhandledError);

                if (fAttemptedXml && !fXmlOk)
                {
                    // We want to see the log file even (especially) if the Xml blows up.
                    ProcessLogFile(processedInputFile, startPhase);
                }
            }

            return(false);
        }
Esempio n. 4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <param name="_rghvo"></param>
		/// <param name="_rgclsid"></param>
		/// <param name="chvo"></param>
		/// <param name="_dts"></param>
		/// <param name="_advi"></param>
		/// <param name="fIncludeOwnedObjects"></param>
		/// ------------------------------------------------------------------------------------
		public void LoadData(int[] _rghvo, int[] _rgclsid, int chvo, IVwDataSpec _dts, IAdvInd _advi, bool fIncludeOwnedObjects)
		{
			CheckDisposed();
			throw new NotImplementedException();
		}