コード例 #1
0
        int nFirstCntRecords = 3;         // количество первых записей для наборного текстового значения


        public frmSelectOneInputDocument(Form _parentForm, bool _useCheck, InputDocument _oInputDocument)
        {
            oInputDocumentList = new InputDocument();
            oInputDocumentCur  = new InputDocument();
            if (oInputDocumentList.ErrorNumber != 0 ||
                oInputDocumentCur.ErrorNumber != 0)
            {
                IsValid = false;
            }

            oHost = new Host();
            if (oHost.ErrorNumber != 0)
            {
                IsValid = false;
            }

            if (IsValid)
            {
                InitializeComponent();

                parentForm     = _parentForm;
                useCheck       = _useCheck;
                oInputDocument = _oInputDocument;
            }
        }
コード例 #2
0
        public frmInputsDocumentsEdit(int _nInputDocumentID)
        {
            nInputDocumentID = _nInputDocumentID;

            oInputDocument = new InputDocument();
            if (oInputDocument.ErrorNumber != 0)
            {
                IsValid = false;
            }

            if (IsValid)
            {
                oCurrency = new Currency();
                if (oCurrency.ErrorNumber != 0)
                {
                    IsValid = false;
                }
            }

            if (IsValid)
            {
                InitializeComponent();
            }

            nUserHostID = ((RFMFormMain)Application.OpenForms[0]).UserInfo.HostID;
        }
コード例 #3
0
        public frmInputsDocumentsEdit(int _nInputID, int _nInputDocumentID)
        {
            nInputDocumentID = _nInputDocumentID;
            nInputID         = _nInputID;

            oInputDocument = new InputDocument();
            if (oInputDocument.ErrorNumber != 0)
            {
                IsValid = false;
            }

            if (IsValid)
            {
                oCurrency = new Currency();
                if (oCurrency.ErrorNumber != 0)
                {
                    IsValid = false;
                }
            }

            if (IsValid)
            {
                oInput = new Input();
                if (oInput.ErrorNumber != 0)
                {
                    IsValid = false;
                }
            }

            if (IsValid)
            {
                InitializeComponent();
            }
        }
コード例 #4
0
 public async Task SaveOutputAsync(InputDocument inputDoc, InputChapter chapter, string output)
 {
     var fileName = Path.GetFileNameWithoutExtension(inputDoc.FilePath);
     var path     = Path.Combine(Path.GetDirectoryName(inputDoc.FilePath),
                                 $"{fileName}_chapter{chapter.ChapterNo}_output.html");
     await File.WriteAllTextAsync(path, output);
 }
コード例 #5
0
        public static async Task CheckinFromDrive(this Record record, string driveId, string token, bool saveRecord = false)
        {
            string downloadUrl = GraphApiHelper.GetOneDriveItemContentIdUrl(driveId);

            var fileResult = await ODataHelper.GetItem <OneDriveItem>(GraphApiHelper.GetOneDriveItemIdUrl(driveId), token, null);

            string filePath = Path.Combine(TrimApplication.WebServerWorkPath, fileResult.Name);


            await ODataHelper.GetItem <string>(downloadUrl, token, filePath);

            var inputDocument = new InputDocument(filePath);


            inputDocument.CheckinAs = record.SuggestedFileName;
            record.SetDocument(inputDocument, true, false, "checkin from Word Online");

            string pdfPath = Path.Combine(TrimApplication.WebServerWorkPath, Path.ChangeExtension(fileResult.Name, "pdf"));
            string pdfUrl  = GraphApiHelper.GetOneDriveItemContentIdUrl(driveId, "pdf");
            await ODataHelper.GetItem <string>(pdfUrl, token, pdfPath);


            var rendition = record.ChildRenditions.NewRendition(pdfPath, RenditionType.Longevity, "Preview");


            if (saveRecord)
            {
                record.Save();

                File.Delete(filePath);
                File.Delete(pdfPath);
            }
            return;
        }
コード例 #6
0
        public static string getExemplarDisplay(FeatureMetaData[] FEATURES, Corpus corpus, IList <int> Y, int corpusVectorIndex)
        {
            int[]         X        = corpus.featureVectors[corpusVectorIndex];
            InputDocument doc      = corpus.documentsPerExemplar[corpusVectorIndex];
            string        features = Trainer._toString(FEATURES, doc, X);
            int           line     = X[Trainer.INDEX_INFO_LINE];
            string        lineText = doc.getLine(line);
            int           col      = X[Trainer.INDEX_INFO_CHARPOS];

            // insert a dot right before char position
            if (!string.ReferenceEquals(lineText, null))
            {
                lineText = lineText.Substring(0, col) + '\u00B7' + lineText.Substring(col, lineText.Length - col);
            }
            int    cat = Y[corpusVectorIndex];
            string displayCat;

            if ((cat & 0xFF) == Trainer.CAT_INJECT_WS || (cat & 0xFF) == Trainer.CAT_INJECT_NL)
            {
                displayCat = Formatter.getWSCategoryStr(cat);
            }
            else
            {
                displayCat = Formatter.getHPosCategoryStr(cat);
            }

            return(string.Format("{0} {1,9} {2}", features, displayCat, lineText));
        }
コード例 #7
0
        public frmOutputsInputsCarries()
        {
            oOutputCur = new Output();
            if (oOutputCur.ErrorNumber != 0)
            {
                IsValid = false;
            }

            oInputCur = new Input();
            if (oInputCur.ErrorNumber != 0)
            {
                IsValid = false;
            }

            if (IsValid)
            {
                oOutputDocumentInOutput = new OutputDocument();
                if (oOutputDocumentInOutput.ErrorNumber != 0)
                {
                    IsValid = false;
                }
            }

            if (IsValid)
            {
                oInputDocumentInInput = new InputDocument();
                if (oInputDocumentInInput.ErrorNumber != 0)
                {
                    IsValid = false;
                }
            }

            oOutputDocumentCur = new OutputDocument();
            if (oOutputDocumentCur.ErrorNumber != 0)
            {
                IsValid = false;
            }

            oTrip = new Trip();
            if (oTrip.ErrorNumber != 0)
            {
                IsValid = false;
            }

            oReportOutput         = new Report();
            oReportOutputDocument = new Report();
            oReportInput          = new Report();
            if (oReportOutput.ErrorNumber != 0 ||
                oReportOutputDocument.ErrorNumber != 0 ||
                oReportInput.ErrorNumber != 0)
            {
                IsValid = false;
            }

            if (IsValid)
            {
                InitializeComponent();
            }
        }
コード例 #8
0
 public ApiDescriptionReader(InputDocument apiInput, List <InputDocument> fixupInputs = null)
 {
     apiDoc = apiInput ?? throw new ArgumentNullException(nameof(apiInput));
     if (fixupInputs != null && fixupInputs.Count > 0)
     {
         fixupDocs = fixupInputs;
     }
 }
コード例 #9
0
        public void Process(InputDocument inputDocument)
        {
            string currentFullFilePath = Path.Combine(path, inputDocument.DocumentName);

            string destinationFullFilePath = Path.Combine(destinationPath, inputDocument.DocumentName);

            File.Move(currentFullFilePath, destinationFullFilePath);
        }
コード例 #10
0
 public IEnumerable <PhotoFile> GatherPhotoPaths(InputDocument inputDoc, string[] fileNames)
 {
     return(from pp in inputDoc.PhotoPaths
            from filePath in Directory.GetFiles(pp, "*.*", SearchOption.AllDirectories)
            let fileName = Path.GetFileNameWithoutExtension(filePath)
                           where fileNames.Any(f => fileName.Equals(f, StringComparison.OrdinalIgnoreCase))
                           select CreatePhotoFile(fileName.ToLower(), filePath));
 }
コード例 #11
0
        public virtual Triple <Formatter, float, float> validate(LangDescriptor language, IList <InputDocument> documents, string fileToExclude, int k, FeatureMetaData[] injectWSFeatures, FeatureMetaData[] alignmentFeatures, string outputDir, bool computeEditDistance, bool collectAnalysis)
        {
            string path = System.IO.Path.GetFullPath(fileToExclude);
            IList <InputDocument> others   = BuffUtils.filter(documents, d => !d.fileName.Equals(path));
            IList <InputDocument> excluded = BuffUtils.filter(documents, d => d.fileName.Equals(path));

            Debug.Assert(others.Count == documents.Count - 1);
            //		kNNClassifier.resetCache();
            if (excluded.Count == 0)
            {
                Console.Error.WriteLine("Doc not in corpus: " + path);
                return(null);
            }
            InputDocument testDoc = excluded[0];
            DateTime      start   = System.DateTime.Now;
            Corpus        corpus  = new Corpus(others, language);

            corpus.train();
            DateTime      stop         = System.DateTime.Now;
            Formatter     formatter    = new Formatter(corpus, language.indentSize, k, injectWSFeatures, alignmentFeatures);
            InputDocument originalDoc  = testDoc;
            DateTime      format_start = System.DateTime.Now;
            string        output       = formatter.format(testDoc, collectAnalysis);
            DateTime      format_stop  = System.DateTime.Now;
            float         editDistance = 0;

            if (computeEditDistance)
            {
                editDistance = Dbg.normalizedLevenshteinDistance(testDoc.content, output);
            }
            ClassificationAnalysis analysis = new ClassificationAnalysis(originalDoc, formatter.AnalysisPerToken);

            Console.WriteLine(testDoc.fileName + ": edit distance = " + editDistance + ", error rate = " + analysis.ErrorRate);
            if (!string.ReferenceEquals(outputDir, null))
            {
                string dir = outputDir + "/" + language.name + "/" + Tool.version;
                if (!System.IO.Directory.Exists(dir))
                {
                    System.IO.Directory.CreateDirectory(dir);
                }
                org.antlr.codebuff.misc.Utils.writeFile(dir + "/" + System.IO.Path.GetFileName(testDoc.fileName), output);
            }
            var tms = (stop - start);
            var fms = format_stop - format_start;

            trainingTimes.Add((double)tms.Milliseconds);
            float tokensPerMS = testDoc.tokens.Size / (float)fms.TotalMilliseconds;

            formattingTokensPerMS.Add((double)tokensPerMS);
            Console.Write("Training time = {0:D} ms, formatting {1:D} ms, {2,5:F3} tokens/ms ({3:D} tokens)\n", tms, fms, tokensPerMS, testDoc.tokens.Size);
            //		System.out.printf("classify calls %d, hits %d rate %f\n",
            //		                  kNNClassifier.nClassifyCalls, kNNClassifier.nClassifyCacheHits,
            //		                  kNNClassifier.nClassifyCacheHits/(float) kNNClassifier.nClassifyCalls);
            //		System.out.printf("kNN calls %d, hits %d rate %f\n",
            //						  kNNClassifier.nNNCalls, kNNClassifier.nNNCacheHits,
            //						  kNNClassifier.nNNCacheHits/(float) kNNClassifier.nNNCalls);
            return(new Triple <Formatter, float, float>(formatter, editDistance, analysis.ErrorRate));
        }
コード例 #12
0
        /// <summary>
        /// Select one document at random, then n others w/o replacement as corpus </summary>
        public virtual org.antlr.codebuff.misc.Pair <InputDocument, IList <InputDocument> > selectSample(IList <InputDocument> documents, int n)
        {
            int                   i            = random.Next(documents.Count);
            InputDocument         testDoc      = documents[i];
            IList <InputDocument> others       = BuffUtils.filter(documents, d => d != testDoc);
            IList <InputDocument> corpusSubset = getRandomDocuments(others, n);

            return(new org.antlr.codebuff.misc.Pair <InputDocument, IList <InputDocument> >(testDoc, corpusSubset));
        }
コード例 #13
0
        public void Process(InputDocument inputDocument)
        {
            string[] words = wordsExtractor.GetWords(inputDocument.DocumentContent);

            documentWithExtractedWordsStore.Store(
                new InputDocumentWithExtractedWords(
                    inputDocument,
                    words));
        }
コード例 #14
0
        public static void Main(string[] args)
        {
            string         langname     = args[0].Substring(1);
            string         testFilename = args[1];
            LangDescriptor language     = null;

            for (int i = 0; i < languages.length; i++)
            {
                if (languages[i].name.Equals(langname))
                {
                    language = languages[i];
                    break;
                }
            }
            if (language == null)
            {
                Log.WriteLine("Language " + langname + " unknown");
                return;
            }

            // load all files up front
            DateTime              load_start = System.DateTime.Now;
            IList <string>        allFiles   = Tool.getFilenames(language.corpusDir, language.fileRegex);
            IList <InputDocument> documents  = Tool.load(allFiles, language);
            DateTime              load_stop  = System.DateTime.Now;
            DateTime              load_time  = (load_stop - load_start) / 1000000;

            Log.Write("Loaded {0:D} files in {1:D}ms\n", documents.Count, load_time);

            string path = System.IO.Path.GetFullPath(testFilename);
            IList <InputDocument> others   = BuffUtils.filter(documents, d => !d.fileName.Equals(path));
            IList <InputDocument> excluded = BuffUtils.filter(documents, d => d.fileName.Equals(path));

            Debug.Assert(others.Count == documents.Count - 1);
            if (excluded.Count == 0)
            {
                Log.WriteLine("Doc not in corpus: " + path);
                return;
            }
            InputDocument testDoc = excluded[0];

            IList <int> training   = new List <int>();
            IList <int> formatting = new List <int>();

            for (int i = 1; i <= TRIALS; i++)
            {
                org.antlr.codebuff.misc.Pair <int, int> timing = test(language, others, testDoc);
                training.Add(timing.a);
                formatting.Add(timing.b);
            }
            // drop first four
            training   = training.subList(5, training.Count);
            formatting = formatting.subList(5, formatting.Count);
            Log.Write("median of [5:{0:D}] training {1:D}ms\n", TRIALS - 1, BuffUtils.median(training));
            Log.Write("median of [5:{0:D}] formatting {1:D}ms\n", TRIALS - 1, BuffUtils.median(formatting));
        }
コード例 #15
0
        public object Post(CommitRequest request)
        {
            // Locate record by URI
            long uri = request.Uri;

            if (uri <= 0)
            {
                throw new ApplicationException($"Invalid URI: {uri}");
            }

            Record   record       = new Record(Database, uri);
            Location trimUser     = Database.CurrentUser;
            Location checkedOutTo = record.CheckedOutTo;

            string checkoutPath = record.CheckedOutPath;

            // Abort if not checked out to current user.
            if (checkedOutTo == null || (checkedOutTo != null && checkedOutTo.Uri != trimUser.Uri))
            {
                throw new ApplicationException("Document is not checked out to requesting user.");
            }


            if (!checkoutPath.StartsWith(SHARED_DIR))
            {
                throw new ApplicationException("Document is not checked out to the shared path.");
            }

            if (!System.IO.File.Exists(checkoutPath))
            {
                throw new ApplicationException($"Document is already checked out to '{trimUser.Name}' but working copy can't be found in expected location '{checkoutPath}' on server.");
            }

            // Electronic document was found.  Now update revision, check in document and return response.
            InputDocument inpDoc = new InputDocument(checkoutPath);

            inpDoc.CheckinAs = Path.GetFileName(record.ESource); // Preserve original file name when checking back in
            record.SetDocument(inpDoc, request.NewRevision, request.KeepCheckedOut, request.Comments);
            record.Save();                                       // Calling record.SetCheckedOutPath(WEBDAV_CHECKOUT_PATH) below prevents the new revision from being saved, so save the record first.
            if (request.KeepCheckedOut)
            {
                // SetDocument overrides checkedoutpath, so call this function to set it back to how we want it and save the record again
                // TODO - ask Rory why it works this way
                record.SetCheckedOutPath(checkoutPath);
                record.Save();
            }
            // Remove document from webdav if checking back in
            if (!request.KeepCheckedOut)
            {
                File.Delete(checkoutPath);
            }

            return(new CommitResponse());
        }
コード例 #16
0
 public async Task <IActionResult> Get([FromBody] InputDocument xmlDoc)
 {
     try
     {
         return(Ok(new { status = "success", result = await _iIutDocument.GetReferences(xmlDoc) }));
     }
     catch (System.Exception e)
     {
         return(BadRequest(new { status = "error", message = e.Message }));
     }
 }
コード例 #17
0
 public void PrintInputInfo(InputDocument input)
 {
     Console.ForegroundColor = ConsoleColor.DarkGray;
     Console.WriteLine("Document information:");
     WritePropertyLine("  ° Album name:\t", input.AlbumName);
     foreach (var photoPath in input.PhotoPaths)
     {
         WritePropertyLine("  ° Photo path:\t", photoPath);
     }
     Console.WriteLine();
     Console.ForegroundColor = _defaultColor;
 }
コード例 #18
0
        public InputChapter AskUserForChapter(InputDocument input)
        {
            Console.WriteLine("Select a chapter:");
            for (var i = 0; i < input.Chapters.Length; i++)
            {
                Write(true, new [] { $"  {i+1}", $". {input.Chapters[i].Title}" },
                      ConsoleColor.Magenta, Console.ForegroundColor);
            }
            var chapterIndex = int.Parse(Console.ReadLine());

            return(input.Chapters[chapterIndex - 1]);
        }
コード例 #19
0
        public int Default(InputDocument pInputDocument)
        {
            if (pInputDocument == null || pInputDocument.DeclarationList.Declaration.Command != "DEFAULT")
            {
                return(-1);
            }

            if (pInputDocument == null || pInputDocument.DeclarationList.Declaration.DeclarationHeader.SiteID != "DUB")
            {
                return(-2);
            }

            return(0);
        }
コード例 #20
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            InputDocument inputDocument = InputDocumentMapper.ReadValues(this.dgwInputDocument, true);

            if (inputDocument != null)
            {
                this.dgwInputDocument.Rows.Clear();
                this.Close();
            }
            else
            {
                MessageBox.Show(this, "Не сте попълнили задължителните полета!", "",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #21
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting XML Parser");

            Console.WriteLine("Opening the input file");
            StreamReader lStreamReader = new StreamReader("InputFile.xml");

            Console.WriteLine("Parsing XML File");
            InputDocument lInputDocument = ParseXML.Parse <InputDocument>(lStreamReader);

            PrintResult(lInputDocument);

            Console.WriteLine("XML Parser execution has finished");
            Console.ReadLine();
        }
コード例 #22
0
        public async Task <string> ValidateStatus(InputDocument xmlDoc)
        {
            string message = "The document was structured correctly.";

            if (xmlDoc?.DeclarationList?.Declaration?.Command.ToLower() != "default")
            {
                message = "Invalid command specified.";
            }
            else if (xmlDoc?.DeclarationList?.Declaration?.DeclarationHeader?.SiteID?.ToLower() != "dub")
            {
                message = "Invalid Site specified.";
            }

            return(message);
        }
コード例 #23
0
        protected virtual void ApplyFixups(XDocument doc, InputDocument fixup)
        {
            if (fixup == null)
            {
                return;
            }

            var applier = CreateFixupApplier(doc, XDocument.Load(fixup.Stream), fixup.Path);

            if (applier == null)
            {
                throw new InvalidOperationException("No fixup applier instance");
            }
            applier.Apply();
        }
コード例 #24
0
        public ActionResult Post([FromBody] XElement document)
        {
            var checkConstraints = new InputDocument {
                Command = "DEFAULT", SiteId = "DUB"
            };
            var result      = xmlOperations.XmlValidationOperation(document, checkConstraints);
            var finalResult = $"The XLM is valid if(0)  = {result.XmlValid}, The Command is valid if (0), otherwise (-1)   = " +
                              $"{ result.DeclarationCommand}, The Command is valid if (0), otherwise (-2)   = {result.SiteId}";

            if (result.XmlValid == "0" && result.DeclarationCommand == "0" && result.SiteId == "0")
            {
                return(Ok(finalResult));
            }

            return(BadRequest(finalResult));
        }
コード例 #25
0
 public async Task <IActionResult> Post([FromBody] InputDocument xmlDoc)
 {
     try
     {
         if (xmlDoc != null)
         {
             return(Ok(new { status = 0, message = await _iIutDocument.ValidateStatus(xmlDoc) }));
         }
         else
         {
             return(BadRequest(new { status = "error", message = "Invalid XML." }));
         }
     }
     catch (System.Exception e)
     {
         return(BadRequest(new { status = "error", message = e.Message }));
     }
 }
コード例 #26
0
        static void PrintResult(InputDocument pInputDocument)
        {
            if (pInputDocument == null ||
                pInputDocument.DeclarationList == null ||
                pInputDocument.DeclarationList.Declaration == null ||
                pInputDocument.DeclarationList.Declaration.DeclarationHeader == null)
            {
                Console.WriteLine("Error during file parsing");
                return;
            }

            string[] lCodes = new string[] { "MWB", "TRV", "CAR" };

            foreach (Reference lReference in pInputDocument.DeclarationList.Declaration.DeclarationHeader.Reference.Where(x => lCodes.Contains(x.RefCode)))
            {
                Console.WriteLine(lReference.RefText);
            }
        }
コード例 #27
0
        private static void Migrate()
        {
            string connectionString = "Data Source=yfdev.cloudapp.net;Initial Catalog=SCC_ECM;Persist Security Info=True;User ID=EPL;Password=Password1!";
            using (SqlConnection con = new SqlConnection(connectionString))
            {
                con.Open();
                using (SqlCommand command = new SqlCommand("SELECT top 25 * FROM View_1", con))
                using (SqlDataReader reader = command.ExecuteReader())
                {
                    using (Database db = new Database())
                    {
                        db.Id = "03";
                        db.Connect();
                        while (reader.Read())
                        {
                            RecordType rt = new RecordType(db, 16);
                            Record rCont = GetFolderUri(reader.GetString(6), reader.GetString(7), db);
                            if (rCont != null)
                            {

                                Record r = new Record(rt);
                                r.Container = rCont;
                                r.LongNumber = reader.GetInt32(0).ToString();
                                r.Title = reader.GetString(1);
                                r.DateCreated = (TrimDateTime)reader.GetDateTime(2);
                                string loc = "D:\\" + reader.GetString(3);
                                if (File.Exists(loc))
                                {
                                    InputDocument id = new InputDocument(loc);
                                    r.SetDocument(id, false, false, "Migrated from ECM t1");
                                }

                                r.Save();
                                Console.WriteLine("Record Created: " + r.Number);
                            }
                            else
                            {
                                Console.WriteLine("Could not find folder");
                            }
                        }
                    }
                }
            }
        }
コード例 #28
0
        private void btnInputDocumentSelect_Click(object sender, EventArgs e)
        {
            InputDocument oInputDocument = new InputDocument();

            oInputDocument.FilterDateBeg = DateTime.Today.AddMonths(-1);
            oInputDocument.FilterDateEnd = DateTime.Today;
            if (StartForm(new frmSelectOneInputDocument(this, false, oInputDocument)) == DialogResult.Yes)
            {
                oInputDocument.ID = _SelectedInputDocumentID;
                oInputDocument.FillData();
                if ((_SelectedInputDocumentID != null) && (oInputDocument.MainTable.Rows.Count > 0))
                {
                    txtInputDocument.Text = oInputDocument.MainTable.Rows[0]["ID"].ToString() + " [" +
                                            ((DateTime)oInputDocument.MainTable.Rows[0]["DateInput"]).ToShortDateString() + "] " +
                                            oInputDocument.MainTable.Rows[0]["PartnerSourceName"].ToString();
                    btnInputSelect.Enabled = btnInputClear.Enabled = false;
                }
            }
        }
コード例 #29
0
        public IActionResult Post(InputDocument inputDocument)
        {
            try
            {
                if (inputDocument.DeclarationList.Declaration.Command != "DEFAULT")
                {
                    return(StatusCode(-1));
                }
                if (inputDocument.DeclarationList.Declaration.DeclarationHeader.SiteID != "DUB")
                {
                    return(StatusCode(-2));
                }

                return(StatusCode(0));
            }
            catch (Exception e)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError));
            }
        }
コード例 #30
0
ファイル: CreateDoc.cs プロジェクト: hayans/MF-Code
        private void btnCreateDoc_Click(object sender, EventArgs e)
        {
            try
            {
                using (Database db = new Database())
                {
                    db.Id = ConfigurationManager.AppSettings["dbid"];
                    if (db.IsValid)//check whether db is valid, if not show error message
                    {
                        FileInfo fi = new FileInfo(txtFilePath.Text.Trim());

                        //define record type
                        RecordType recType = new RecordType(db, ConfigurationManager.AppSettings["recordType"]);

                        HP.HPTRIM.SDK.Record rd = new Record(recType);
                        rd.Title = fi.Name;

                        HP.HPTRIM.SDK.InputDocument objDoc = new InputDocument();
                        objDoc.SetAsFile(txtFilePath.Text.Trim());


                        rd.Author = db.CurrentUser;
                        rd.SetDocument(objDoc, false, false, "Created via SDK");
                        rd.Save();

                        MessageBox.Show("Newly created document Record Number: " + rd.Number.ToString());
                        //nullify used objects before exit, so that  GC can collect it
                        rd     = null;
                        objDoc = null;
                    }
                    else
                    {
                        MessageBox.Show("Loader database error: " + db.ErrorMessage);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #31
0
        public async Task <string[, ]> GetReferences(InputDocument xmlDoc)
        {
            var references = xmlDoc?.DeclarationList?.Declaration?.DeclarationHeader?.Reference.Where(x => x.RefCode.Equals("MWB") || x.RefCode.Equals("TRV") || x.RefCode.Equals("CAR"));

            string[,] RefTexts = new string[references.Count(), 2];

            if (references != null)
            {
                int i = 0;
                foreach (var item in references)
                {
                    RefTexts[i, 0] = item.RefCode;
                    if (item.RefText != null)
                    {
                        RefTexts[i, 1] = item.RefText;
                    }
                    i++;
                }
            }
            return(RefTexts);
        }
コード例 #32
0
        static void Main(string[] args)
        {
            //TrimApplication.Initialize();
            //using (Database db = new Database())
            //{
            //Origin m_origin = null;
            //BulkDataLoader m_loader = null;

            //m_origin = db.FindTrimObjectByName(BaseObjectTypes.Origin, "ECM bulk load") as Origin;

            //if (m_origin == null)
            //{
            //    m_origin = new Origin(db, OriginType.Custom1);

            //    m_origin.Name = "ECM bulk load";
            //    m_origin.OriginLocation = "SQL Extracts";
            //    m_origin.DefaultRecordType = db.FindTrimObjectByUri(BaseObjectTypes.RecordType, 2) as RecordType;
            //    m_origin.Save();
            //    Console.WriteLine("origin check, new: " + m_origin.Name);
            //}
            //else
            //{
            //    Console.WriteLine("origin check: " + m_origin.Name);
            //}
            //m_loader = new BulkDataLoader(m_origin);
            //if (!m_loader.Initialise())
            //{
            //    // this sample has no way of dealing with the error.
            //    Console.WriteLine(m_loader.ErrorMessage);
            //    return;
            //}
            //Console.WriteLine("Starting migration run ...");
            //m_loader.StartRun("Input Data", @"C:\Temp");
            ////
            //InputDocument doc = new InputDocument();
            //doc.SetAsFile(@"D:\SCC\ECM\0BF\00FB6A59.001.jpg");

            //bool updateRec = m_loader.UpdateDocument(366008, doc, BulkLoaderCopyMode.WindowsCopy);
            //m_loader.EndRun();
            //if(updateRec)
            //{
            //    m_loader.ProcessAccumulatedData();

            //    Int64 runHistoryUri = m_loader.RunHistoryUri;

            //}
            //}
            try
            {
                List<newRevision> lstRev = new List<newRevision>();
                using (SqlConnection con = new SqlConnection("Data Source=Cl1025;Initial Catalog=StagingMove;Integrated Security=True"))
                {
                    con.Open();
                    //Console.WriteLine("Connected to SQL 1025");
                    Console.WriteLine("Export Batch?");
                    string strBatch = Console.ReadLine();
                    Console.WriteLine("Offset?");
                    string strOffset = Console.ReadLine();
                    Console.WriteLine("Fetch?");
                    string strFetch = Console.ReadLine();
                    string strbatch = "[Extract Remainder DIFF]";
                    //Console.WriteLine("Enter SQL string");
                    //string sqlstring = "Select [STD:DocumentSetID], [STD:version], [Volume:StorageLocation], [Volume:Filename] from " + strBatch + " group by [STD:DocumentSetID], [Volume:StorageLocation], [Volume:Filename], [STD:version] Having Max([STD:version]) > 1 and [Volume:Filename] is not null Order by[STD:DocumentSetID] desc, [STD:version] OFFSET " + strOffset + " ROWS FETCH NEXT " + strFetch + " ROWS ONLY";
                    //string sqlstring = "SELECT dbo.Eri.[STD:DocumentSetID], dbo.Eri.[STD:Version], dbo.Eri.[Volume:StorageLocation], dbo.Eri.[Volume:Filename], M.MaxVersion, M.RmRevisions FROM from INNER JOIN dbo.ECM_MasterCheck AS M ON dbo.Eri.[STD:DocumentSetID] = M.DocumentSetID GROUP BY dbo.Eri.[STD: DocumentSetID], dbo.Eri.[Volume: StorageLocation], dbo.Eri.[Volume: Filename], dbo.Eri.[STD: Version], M.RmRevisions, M.MaxVersion HAVING (MAX(dbo.Eri.[STD: Version]) > 1) AND (M.MaxVersion > M.RmRevisions) ORDER BY dbo.Eri.[STD:DocumentSetID] DESC, dbo.Eri.[STD:Version] OFFSET " + strOffset + " ROWS FETCH NEXT " + strFetch + " ROWS ONLY";
                    //string sqlstring = "SELECT E.[STD:DocumentSetID], E.[STD:Version], E.[Volume:StorageLocation], E.[Volume:Filename] FROM " + strBatch + " AS E INNER JOIN dbo.ECM_MasterCheck AS M ON E.[STD:DocumentSetID] = M.DocumentSetID GROUP BY E.[STD:DocumentSetID], E.[Volume:StorageLocation], E.[Volume:Filename], E.[STD:Version], M.RmRevisions, M.MaxVersion, M.Pass HAVING (MAX(E.[STD:Version]) > 1) AND(M.MaxVersion > M.RmRevisions) AND M.Pass = 1 ORDER BY E.[STD:DocumentSetID] DESC, E.[STD:Version] OFFSET " + strOffset + " ROWS FETCH NEXT " + strFetch + " ROWS ONLY";
                    string sqlstring = "SELECT E.[STD:DocumentSetID], E.[STD:Version], E.[Volume:StorageLocation], E.[Volume:Filename] FROM " + strbatch + " AS E INNER JOIN dbo.ECM_MasterCheck AS M ON E.[STD:DocumentSetID] = M.DocumentSetID GROUP BY E.[STD:DocumentSetID], E.[Volume:StorageLocation], E.[Volume:Filename], E.[STD:Version], M.RmRevisions, M.MaxVersion, M.Pass, Duplicate HAVING (M.MaxVersion > M.RmRevisions) AND M.Pass = 2 and Duplicate = 0 ORDER BY E.[STD:DocumentSetID] DESC, E.[STD:Version]";
                    //List<ECMMigration> lstecm = new List<ECMMigration>();dgdg

                    //
                    using (SqlCommand command = new SqlCommand(sqlstring, con))
                    {
                        DataSet dataSet = new DataSet();

                        DataTable dt = new DataTable();
                        //DataTable dtt = extension.

                        SqlDataAdapter da = new SqlDataAdapter();
                        da.SelectCommand = command;
                        da.Fill(dt);
                        SqlDataReader reader = command.ExecuteReader();

                        while (reader.Read())
                        {
                            newRevision nr = new newRevision();
                            nr.DocSetID = reader.GetInt32(0).ToString();
                            nr.revision = reader.GetInt16(1);
                            nr.Location = reader.GetString(2);
                            nr.Filename = reader.GetString(3);
                            lstRev.Add(nr);
                        }
                    }
                }
                Console.WriteLine("Sql query transfered to List, total to process: " + lstRev.Count().ToString());
                int icount = 0;
                int iDocSource = 0;
                string strTotalList = lstRev.Count().ToString();
                TrimApplication.Initialize();
                //Record r = new Record(db)eq3
                foreach (newRevision rr in lstRev)
                {
                    icount++;
                    using (Database db = new Database())
                    {
                        //string strStorageLoc = FindMappedStorage(rr.Location) + "\\" + rr.Filename; ;
                        //string strStorageLoc2 = FindMappedStorageNas(rr.Location) + "\\" + rr.Filename;
                        ////string strStorageLoc = @"D:\SCC\ECM\0BF\00FB8C37.001.pdf";
                        //if (File.Exists(strStorageLoc))
                        //{
                        //    //Look for alternative
                        //    iDocSource = 1;
                        //}
                        //else if (File.Exists(strStorageLoc2))
                        //{
                        //    iDocSource = 2;
                        //}
                        //else
                        //{
                        //    iDocSource = 0;
                        //    Console.WriteLine("Document could not be found");
                        //    //Loggitt("Document  " + strStorageLoc + "  could not be found", "Revision load error");
                        //}
                        //if (iDocSource > 0)
                        //{
                        string strStorageLoc = FindMappedAllStorage(rr.Filename);
                        if (strStorageLoc != null)
                        {
                            Record r = (Record)db.FindTrimObjectByName(BaseObjectTypes.Record, rr.DocSetID);
                            if (r != null)
                            {
                                if (r.RevisionNumber < rr.revision)
                                {
                                    try
                                    {
                                        if (r.DateRegistered <= r.DateReceived)
                                        {
                                            DateTime tdtDateReceived = r.DateReceived;
                                            r.DateRegistered = (TrimDateTime)tdtDateReceived.AddHours(1);
                                        }
                                        r.Save();

                                        InputDocument doc = new InputDocument();
                                        doc.SetAsFile(strStorageLoc);
                                        r.SetDocument(doc, true, false, "Add new ECM revision - migration");
                                        r.Save();
                                        Console.WriteLine("Added new revision " + rr.revision.ToString() + " to record " + rr.DocSetID + ", item " + icount.ToString() + " of " + strTotalList);
                                        deleteEcmSource(strStorageLoc);
                                        //Console.ReadLine();
                                    }
                                    catch (Exception exp)
                                    {
                                        Console.WriteLine("Record number " + rr.DocSetID + "  could not be added");
                                        Loggitt("Record number " + rr.DocSetID + "  could not be added - Error: " + exp.Message.ToString(), "Revision load error");
                                        //Console.ReadLine();

                                    }
                                }
                            }
                            else
                            {
                                Console.WriteLine("Record number " + rr.DocSetID + "  could not be found");
                                //Console.ReadLine();
                                // Loggitt("Record number " + rr.DocSetID + "  could not be found", "Revision load error");
                            }
                        }
                        else
                        {
                            Console.WriteLine("Record " + rr.DocSetID + "  document could not be found");
                            //Console.ReadLine();
                        }
                    }

                }

            }
            catch (Exception exp)
            {
                Console.WriteLine("Error: "+exp.Message.ToString());
                Loggitt(exp.Message.ToString(), "Revision load error");
                Console.ReadLine();

            }
        }
コード例 #33
0
        private static void processtoEddie(List<ECMMigration> lstecm)
        {
            Console.WriteLine("Moved into RM processing");
            string strTotal = lstecm.Count.ToString();
            int iCount = 0;
            TrimApplication.Initialize();
            //Parallel.ForEach(lstecm, new ParallelOptions { MaxDegreeOfParallelism = 6 }, (ecm) =>

            DateTime dt1 = DateTime.Now;

            using (Database db = new Database())
            {
                FieldDefinition fd_ECMApplicationRAM_Application_Number = new FieldDefinition(db, "Application Number List");
                FieldDefinition fd_ECMBarCodeBarCodeString = new FieldDefinition(db, "ECM BarCode:BarCodeString");
                FieldDefinition fd_ECMBCSRetention_Period = new FieldDefinition(db, "ECM BCS:Retention_Period");
                FieldDefinition fd_ECMCaseCaseDescription = new FieldDefinition(db, "ECM Case:CaseDescription");
                FieldDefinition fd_ECMCaseCaseName = new FieldDefinition(db, "ECM Case:CaseName");
                FieldDefinition fd_ECMCaseCaseNumber = new FieldDefinition(db, "ECM Case:CaseNumber");
                FieldDefinition fd_ECMCaseCaseOfficer = new FieldDefinition(db, "ECM Case:CaseOfficer");
                FieldDefinition fd_ECMCaseCaseStatus = new FieldDefinition(db, "ECM Case:CaseStatus");
                FieldDefinition fd_ECMCaseCaseType = new FieldDefinition(db, "ECM Case:CaseType");
                FieldDefinition fd_ECMCaseEndDate = new FieldDefinition(db, "ECM Case:EndDate");
                FieldDefinition fd_ECMCaseStartDate = new FieldDefinition(db, "ECM Case:StartDate");
                //FieldDefinition fd_ECMCorrespondentDescription = new FieldDefinition(db, "ECM Correspondent:Description");
                FieldDefinition fd_ECMECMDriveID = new FieldDefinition(db, "ECM ECMDriveID");
                FieldDefinition fd_ECMEmployeeCommencement_Date = new FieldDefinition(db, "ECM Employee:Commencement_Date");
                FieldDefinition fd_ECMEmployeeEmployee_Given_Name = new FieldDefinition(db, "ECM Employee:Employee_Given_Name");
                FieldDefinition fd_ECMEmployeeEmployee_Surname = new FieldDefinition(db, "ECM Employee:Employee_Surname");
                FieldDefinition fd_ECMEmployeeEmployeeCode = new FieldDefinition(db, "ECM Employee:EmployeeCode");
                FieldDefinition fd_ECmEmployeeHR_Case_Description = new FieldDefinition(db, "ECm Employee:HR_Case_Description");
                FieldDefinition fd_ECMEmployeePreferred_Name = new FieldDefinition(db, "ECM Employee:Preferred_Name");
                FieldDefinition fd_ECMEmployeeStatus = new FieldDefinition(db, "ECM Employee:Status");
                FieldDefinition fd_ECMEmployeeTermination_Date = new FieldDefinition(db, "ECM Employee:Termination_Date");
                FieldDefinition fd_ECMFileName = new FieldDefinition(db, "ECM FileName");
                FieldDefinition fd_ECMFileNetFoldername = new FieldDefinition(db, "ECM FileNet:Foldername");
                FieldDefinition fd_ECMHR_Case_Code = new FieldDefinition(db, "ECM HR_Case_Code");
                FieldDefinition fd_ECMInfoExpertLevel1_Name = new FieldDefinition(db, "ECM InfoExpert:Level1_Name");
                FieldDefinition fd_ECMInfoExpertLevel2_Name = new FieldDefinition(db, "ECM InfoExpert:Level2_Name");
                FieldDefinition fd_ECMInfoExpertLevel3_Description = new FieldDefinition(db, "ECM InfoExpert:Level3_Description");
                FieldDefinition fd_ECMInfoExpertLevel3_Name = new FieldDefinition(db, "ECM InfoExpert:Level3_Name");
                FieldDefinition fd_ECMInfoExpertLevel4_Description = new FieldDefinition(db, "ECM InfoExpert:Level4_Description");
                FieldDefinition fd_ECMInfoExpertLevel4_Name = new FieldDefinition(db, "ECM InfoExpert:Level4_Name");
                FieldDefinition fd_ECMInfoExpertLevel5_Description = new FieldDefinition(db, "ECM InfoExpert:Level5_Description");
                FieldDefinition fd_ECMInfoExpertLevel5_Name = new FieldDefinition(db, "ECM InfoExpert:Level5_Name");
                FieldDefinition fd_ECMInfringementInfringementID = new FieldDefinition(db, "ECM Infringement:InfringementID");
                FieldDefinition fd_ECMNotes = new FieldDefinition(db, "ECM Notes");
                FieldDefinition fd_ECMPositionClose_Date = new FieldDefinition(db, "ECM Position:Close_Date");
                FieldDefinition fd_ECMPositionOpen_Date = new FieldDefinition(db, "ECM Position:Open_Date");
                FieldDefinition fd_ECMPositionPosition_ID = new FieldDefinition(db, "ECM Position:Position_ID");
                FieldDefinition fd_ECMPositionPosition_Title = new FieldDefinition(db, "ECM Position:Position_Title");
                FieldDefinition fd_ECMPositionVacancy_ID = new FieldDefinition(db, "ECM Position:Vacancy_ID");
                FieldDefinition fd_ECMPositionVacancy_Status = new FieldDefinition(db, "ECM Position:Vacancy_Status");
                FieldDefinition fd_ECMProjectAndContractProject_Name = new FieldDefinition(db, "ECM ProjectAndContract:[Project_Name");
                FieldDefinition fd_ECMProjectAndContractContract_or_Activity_Desc = new FieldDefinition(db, "ECM ProjectAndContract:Contract_or_Activity_Desc");
                FieldDefinition fd_ECMProjectAndContractContract_or_Activity_Name = new FieldDefinition(db, "ECM ProjectAndContract:Contract_or_Activity_Name");
                FieldDefinition fd_ECMProjectAndContractContract_or_Activity_No = new FieldDefinition(db, "ECM ProjectAndContract:Contract_or_Activity_No");
                FieldDefinition fd_ECMProjectAndContractEnd_Date = new FieldDefinition(db, "ECM ProjectAndContract:End_Date");
                FieldDefinition fd_ECMProjectAndContractProject_Description = new FieldDefinition(db, "ECM ProjectAndContract:Project_Description");
                FieldDefinition fd_ECMProjectAndContractProject_End_Date = new FieldDefinition(db, "ECM ProjectAndContract:Project_End_Date");
                FieldDefinition fd_ECMProjectAndContractProject_Officer = new FieldDefinition(db, "ECM ProjectAndContract:Project_Officer");
                FieldDefinition fd_ECMProjectAndContractProject_Start_Date = new FieldDefinition(db, "ECM ProjectAndContract:Project_Start_Date");
                FieldDefinition fd_ECMProjectAndContractProjectNo = new FieldDefinition(db, "ECM ProjectAndContract:ProjectNo");
                FieldDefinition fd_ECMProjectAndContractResponsible_Officer = new FieldDefinition(db, "ECM ProjectAndContract:Responsible_Officer");
                FieldDefinition fd_ECMProjectAndContractStart_Date = new FieldDefinition(db, "ECM ProjectAndContract:Start_Date");
                FieldDefinition fd_ECMProjectAndContractStatus = new FieldDefinition(db, "ECM ProjectAndContract:Status");
                FieldDefinition fd_ECMPropertyHouse_No = new FieldDefinition(db, "ECM Property:House_No");
                FieldDefinition fd_ECMPropertyHouse_No_Suffix = new FieldDefinition(db, "ECM Property:House_No_Suffix");
                FieldDefinition fd_ECMPropertyHouse_No_To = new FieldDefinition(db, "ECM Property:House_No_To");
                FieldDefinition fd_ECMPropertyHouse_No_To_Suffix = new FieldDefinition(db, "ECM Property:House_No_To_Suffix");
                FieldDefinition fd_ECMPropertyLocality_Name = new FieldDefinition(db, "ECM Property:Locality_Name");
                FieldDefinition fd_ECMPropertyPostcode = new FieldDefinition(db, "ECM Property:Postcode");
                FieldDefinition fd_ECMPropertyProperty_Name = new FieldDefinition(db, "ECM Property:Property_Name");
                FieldDefinition fd_ECMPropertyProperty_No = new FieldDefinition(db, "Property Number List");
                FieldDefinition fd_ECMPropertyStreet_Name = new FieldDefinition(db, "ECM Property:Street_Name");
                FieldDefinition fd_ECMPropertyUnit_No = new FieldDefinition(db, "ECM Property:Unit_No");
                FieldDefinition fd_ECMPropertyUnit_No_Suffix = new FieldDefinition(db, "ECM Property:Unit_No_Suffix");
                //FieldDefinition fd_ECMreference = new FieldDefinition(db, "ECM reference");
                FieldDefinition fd_ECMRelatedDocDocSetID = new FieldDefinition(db, "ECM RelatedDoc:DocSetID");
                FieldDefinition fd_ECMSTDAllRevTitle = new FieldDefinition(db, "ECM STD:AllRevTitle");
                FieldDefinition fd_ECMSTDApplicationNo = new FieldDefinition(db, "ECM STD:ApplicationNo");
                FieldDefinition fd_ECMSTDBusinessCode = new FieldDefinition(db, "ECM STD:BusinessCode");
                FieldDefinition fd_ECMSTDClassName = new FieldDefinition(db, "ECM STD:ClassName");
                FieldDefinition fd_ECMSTDCorrespondant = new FieldDefinition(db, "ECM STD:Correspondant");
                FieldDefinition fd_ECMSTDCustomerRequest = new FieldDefinition(db, "ECM STD:CustomerRequest");
                FieldDefinition fd_ECMSTDDateLastAccessed = new FieldDefinition(db, "ECM STD:DateLastAccessed");
                FieldDefinition fd_ECMSTDDateReceived = new FieldDefinition(db, "ECM STD:DateReceived");
                FieldDefinition fd_ECMSTDDateRegistered = new FieldDefinition(db, "ECM STD:DateRegistered");
                FieldDefinition fd_ECMSTDDeclaredDate = new FieldDefinition(db, "ECM STD:DeclaredDate");
                FieldDefinition fd_ECMSTDDestructionDue = new FieldDefinition(db, "ECM STD:DestructionDue");
                FieldDefinition fd_ECMSTDDocumentDate = new FieldDefinition(db, "ECM STD:DocumentDate");
                FieldDefinition fd_ECMSTDDocumentType = new FieldDefinition(db, "ECM STD:DocumentType");
                FieldDefinition fd_ECMSTDExternalReference = new FieldDefinition(db, "ECM STD:ExternalReference");
                FieldDefinition fd_ECMSTDInfringementNo = new FieldDefinition(db, "Infringement Number");
                FieldDefinition fd_ECMSTDInternalReference = new FieldDefinition(db, "ECM STD:InternalReference");
                FieldDefinition fd_ECMSTDInternalScanRequest = new FieldDefinition(db, "ECM STD:InternalScanRequest");
                FieldDefinition fd_ECMSTDJobNo = new FieldDefinition(db, "ECM STD:JobNo");
                FieldDefinition fd_ECMSTDOtherReferences = new FieldDefinition(db, "ECM STD:OtherReferences");
                FieldDefinition fd_ECMSTDPropertyNo = new FieldDefinition(db, "ECM STD:PropertyNo");
                FieldDefinition fd_ECMSTDSummaryText = new FieldDefinition(db, "ECM STD:SummaryText");
                FieldDefinition fd_ECMStreetsLocality = new FieldDefinition(db, "ECM Streets:Locality");
                FieldDefinition fd_ECMStreetsPostcode = new FieldDefinition(db, "ECM Streets:Postcode");
                FieldDefinition fd_ECMStreetsStreet_Name = new FieldDefinition(db, "ECM Streets:Street_Name");
                FieldDefinition fd_ECMUserGroupsDescription = new FieldDefinition(db, "ECM UserGroups:Description");
                FieldDefinition fd_ECMUserGroupsExtNo = new FieldDefinition(db, "ECM UserGroups:ExtNo");
                FieldDefinition fd_ECMUserGroupsGivenName = new FieldDefinition(db, "ECM UserGroups:GivenName");
                FieldDefinition fd_ECMUserGroupsOrgEmail = new FieldDefinition(db, "ECM UserGroups:OrgEmail");
                FieldDefinition fd_ECMUserGroupsSurname = new FieldDefinition(db, "ECM UserGroups:Surname");
                FieldDefinition fd_ECMVolumeFilename = new FieldDefinition(db, "ECM Volume:Filename");
                FieldDefinition fd_ECMVolumeLastModified = new FieldDefinition(db, "ECM Volume:LastModified");
                FieldDefinition fd_ECMVolumeMedia = new FieldDefinition(db, "ECM Volume:Media");
                FieldDefinition fd_ECMVolumePrimaryCacheName = new FieldDefinition(db, "ECM Volume:PrimaryCacheName");
                FieldDefinition fd_ECMVolumeRenditionTypeName = new FieldDefinition(db, "ECM Volume:RenditionTypeName");
                FieldDefinition fd_ECMVolumeShareDrive = new FieldDefinition(db, "ECM Volume:ShareDrive");
                FieldDefinition fd_ECMVolumeSize = new FieldDefinition(db, "ECM Volume:Size");
                FieldDefinition fd_ECMVolumeStatus = new FieldDefinition(db, "ECM Volume:Status");
                FieldDefinition fd_ECMVolumeStorageLocation = new FieldDefinition(db, "ECM Volume:StorageLocation");
                //FieldDefinition fd_ECMVolumeUpdatable = new FieldDefinition(db, "ECM Volume:Updatable");
                //
                RecordType rt = new RecordType(db, 16);
                //Console.WriteLine("Processing {0} on thread {1}", filename, Thread.CurrentThread.ManagedThreadId);



                //});

                foreach (ECMMigration ecm in lstecm)
                {
                    iCount++;
                    DateTime dt2 = DateTime.Now;
                    TimeSpan result = dt2 - dt1;
                    Console.WriteLine("Processing {0} - Number {1} of {2}, time since start {3} - batch offset {4}, Fetch {5} ({6})", ecm.DocSetID, iCount.ToString(), strTotal, result.TotalMinutes.ToString(), strOffset, strFetch, (Convert.ToInt32(strOffset) + iCount).ToString());
                    try
                    {
                        Record reccheck = (Record)db.FindTrimObjectByName(BaseObjectTypes.Record, ecm.DocSetID);
                        //if (reccheck == null)
                        //{
                        string strStorageLoc = FindMappedStorage(ecm.ECMVolumeStorageLocation) + "\\" + ecm.ECMVolumeFilename;
                        if (File.Exists(strStorageLoc))
                        {
                            Record reccont = GetFolderUri(ecm.ECMBCSFunction_Name + " - " + ecm.ECMBCSActivity_Name.Replace("-", "~"), ecm.ECMBCSSubject_Name, db);
                            if (reccont != null)
                            {
                                string fTitle;
                                if (ecm.ECMDescription == null)
                                {
                                    fTitle = "Record description from ECM Export is Null";
                                    //strErrorCol = strErrorCol + "Ecm description to Title issue: Description Null for record no " + h.DocSetID.ToString() + Environment.NewLine;
                                }
                                else
                                {
                                    if (ecm.ECMDescription.Length > 253)
                                    {
                                        fTitle = ecm.ECMDescription.Substring(0, 253);
                                        //strErrorCol = strErrorCol + "Ecm description to Title issue: Description greater then 254 ch, description truncated for record no " + h.DocSetID.ToString() + Environment.NewLine;
                                    }
                                    else if (ecm.ECMDescription.Length < 1)
                                    {
                                        fTitle = "Record description from ECM Export is Empty";
                                        //strErrorCol = strErrorCol + "Ecm description to Title issue: Description blank for record no " + h.DocSetID.ToString() + Environment.NewLine;
                                    }
                                    else
                                    {
                                        fTitle = ecm.ECMDescription;
                                    }
                                }

                                Record rec = null;
                                if (reccheck == null)
                                {
                                    rec = new Record(rt);
                                    rec.Container = reccont;
                                }
                                else
                                {
                                    rec = reccheck;
                                }



                                rec.Title = fTitle;
                                rec.DateCreated = (TrimDateTime)ecm.ECMSTDDocumentDate;
                                rec.SetNotes("Migrated from EMS T1", NotesUpdateType.AppendOnly);
                                rec.LongNumber = ecm.DocSetID;
                                //
                                rec.SetFieldValue(fd_ECMApplicationRAM_Application_Number, UserFieldValue.FromDotNetObject(ecm.ECMApplicationRAM_Application_Number));
                                rec.SetFieldValue(fd_ECMBarCodeBarCodeString, UserFieldValue.FromDotNetObject(ecm.ECMBarCodeBarCodeString));
                                rec.SetFieldValue(fd_ECMBCSRetention_Period, UserFieldValue.FromDotNetObject(ecm.ECMBCSRetention_Period));
                                rec.SetFieldValue(fd_ECMCaseCaseDescription, UserFieldValue.FromDotNetObject(ecm.ECMCaseCaseDescription));
                                rec.SetFieldValue(fd_ECMCaseCaseName, UserFieldValue.FromDotNetObject(ecm.ECMCaseCaseName));
                                rec.SetFieldValue(fd_ECMCaseCaseNumber, UserFieldValue.FromDotNetObject(ecm.ECMCaseCaseNumber));
                                rec.SetFieldValue(fd_ECMCaseCaseOfficer, UserFieldValue.FromDotNetObject(ecm.ECMCaseCaseOfficer));
                                rec.SetFieldValue(fd_ECMCaseCaseStatus, UserFieldValue.FromDotNetObject(ecm.ECMCaseCaseStatus));
                                rec.SetFieldValue(fd_ECMCaseCaseType, UserFieldValue.FromDotNetObject(ecm.ECMCaseCaseType));
                                rec.SetFieldValue(fd_ECMCaseEndDate, UserFieldValue.FromDotNetObject(ecm.ECMCaseEndDate));
                                rec.SetFieldValue(fd_ECMCaseStartDate, UserFieldValue.FromDotNetObject(ecm.ECMCaseStartDate));
                                //rec.SetFieldValue(fd_ECMCorrespondentDescription, UserFieldValue.FromDotNetObject(ecm.ECMCorrespondentDescription));
                                //rec.SetFieldValue(fd_ECMECMDriveID, UserFieldValue.FromDotNetObject(ecm.ECMECMDriveID));
                                rec.SetFieldValue(fd_ECMEmployeeCommencement_Date, UserFieldValue.FromDotNetObject(ecm.ECMEmployeeCommencement_Date));
                                rec.SetFieldValue(fd_ECMEmployeeEmployee_Given_Name, UserFieldValue.FromDotNetObject(ecm.ECMEmployeeEmployee_Given_Name));
                                rec.SetFieldValue(fd_ECMEmployeeEmployee_Surname, UserFieldValue.FromDotNetObject(ecm.ECMEmployeeEmployee_Surname));
                                rec.SetFieldValue(fd_ECMEmployeeEmployeeCode, UserFieldValue.FromDotNetObject(ecm.ECMEmployeeEmployeeCode));
                                rec.SetFieldValue(fd_ECmEmployeeHR_Case_Description, UserFieldValue.FromDotNetObject(ecm.ECmEmployeeHR_Case_Description));
                                rec.SetFieldValue(fd_ECMEmployeePreferred_Name, UserFieldValue.FromDotNetObject(ecm.ECMEmployeePreferred_Name));
                                rec.SetFieldValue(fd_ECMEmployeeStatus, UserFieldValue.FromDotNetObject(ecm.ECMEmployeeStatus));
                                rec.SetFieldValue(fd_ECMEmployeeTermination_Date, UserFieldValue.FromDotNetObject(ecm.ECMEmployeeTermination_Date));
                                rec.SetFieldValue(fd_ECMFileName, UserFieldValue.FromDotNetObject(ecm.ECMFileName));
                                rec.SetFieldValue(fd_ECMFileNetFoldername, UserFieldValue.FromDotNetObject(ecm.ECMFileNetFoldername));
                                rec.SetFieldValue(fd_ECMHR_Case_Code, UserFieldValue.FromDotNetObject(ecm.ECMHR_Case_Code));
                                rec.SetFieldValue(fd_ECMInfoExpertLevel1_Name, UserFieldValue.FromDotNetObject(ecm.ECMInfoExpertLevel1_Name));
                                rec.SetFieldValue(fd_ECMInfoExpertLevel2_Name, UserFieldValue.FromDotNetObject(ecm.ECMInfoExpertLevel2_Name));
                                rec.SetFieldValue(fd_ECMInfoExpertLevel3_Description, UserFieldValue.FromDotNetObject(ecm.ECMInfoExpertLevel3_Description));
                                rec.SetFieldValue(fd_ECMInfoExpertLevel3_Name, UserFieldValue.FromDotNetObject(ecm.ECMInfoExpertLevel3_Name));
                                rec.SetFieldValue(fd_ECMInfoExpertLevel4_Description, UserFieldValue.FromDotNetObject(ecm.ECMInfoExpertLevel4_Description));
                                rec.SetFieldValue(fd_ECMInfoExpertLevel4_Name, UserFieldValue.FromDotNetObject(ecm.ECMInfoExpertLevel4_Name));
                                rec.SetFieldValue(fd_ECMInfoExpertLevel5_Description, UserFieldValue.FromDotNetObject(ecm.ECMInfoExpertLevel5_Description));
                                rec.SetFieldValue(fd_ECMInfoExpertLevel5_Name, UserFieldValue.FromDotNetObject(ecm.ECMInfoExpertLevel5_Name));
                                rec.SetFieldValue(fd_ECMInfringementInfringementID, UserFieldValue.FromDotNetObject(ecm.ECMInfringementInfringementID));
                                rec.SetFieldValue(fd_ECMNotes, UserFieldValue.FromDotNetObject(ecm.ECMNotes));
                                rec.SetFieldValue(fd_ECMPositionClose_Date, UserFieldValue.FromDotNetObject(ecm.ECMPositionClose_Date));
                                rec.SetFieldValue(fd_ECMPositionOpen_Date, UserFieldValue.FromDotNetObject(ecm.ECMPositionOpen_Date));
                                rec.SetFieldValue(fd_ECMPositionPosition_ID, UserFieldValue.FromDotNetObject(ecm.ECMPositionPosition_ID));
                                rec.SetFieldValue(fd_ECMPositionPosition_Title, UserFieldValue.FromDotNetObject(ecm.ECMPositionPosition_Title));
                                rec.SetFieldValue(fd_ECMPositionVacancy_ID, UserFieldValue.FromDotNetObject(ecm.ECMPositionVacancy_ID));
                                rec.SetFieldValue(fd_ECMPositionVacancy_Status, UserFieldValue.FromDotNetObject(ecm.ECMPositionVacancy_Status));
                                rec.SetFieldValue(fd_ECMProjectAndContractProject_Name, UserFieldValue.FromDotNetObject(ecm.ECMProjectAndContractProject_Name));
                                rec.SetFieldValue(fd_ECMProjectAndContractContract_or_Activity_Desc, UserFieldValue.FromDotNetObject(ecm.ECMProjectAndContractContract_or_Activity_Desc));
                                rec.SetFieldValue(fd_ECMProjectAndContractContract_or_Activity_Name, UserFieldValue.FromDotNetObject(ecm.ECMProjectAndContractContract_or_Activity_Name));
                                rec.SetFieldValue(fd_ECMProjectAndContractContract_or_Activity_No, UserFieldValue.FromDotNetObject(ecm.ECMProjectAndContractContract_or_Activity_No));
                                rec.SetFieldValue(fd_ECMProjectAndContractEnd_Date, UserFieldValue.FromDotNetObject(ecm.ECMProjectAndContractEnd_Date));
                                rec.SetFieldValue(fd_ECMProjectAndContractProject_Description, UserFieldValue.FromDotNetObject(ecm.ECMProjectAndContractProject_Description));
                                rec.SetFieldValue(fd_ECMProjectAndContractProject_End_Date, UserFieldValue.FromDotNetObject(ecm.ECMProjectAndContractProject_End_Date));
                                rec.SetFieldValue(fd_ECMProjectAndContractProject_Officer, UserFieldValue.FromDotNetObject(ecm.ECMProjectAndContractProject_Officer));
                                rec.SetFieldValue(fd_ECMProjectAndContractProject_Start_Date, UserFieldValue.FromDotNetObject(ecm.ECMProjectAndContractProject_Start_Date));
                                rec.SetFieldValue(fd_ECMProjectAndContractProjectNo, UserFieldValue.FromDotNetObject(ecm.ECMProjectAndContractProjectNo));
                                rec.SetFieldValue(fd_ECMProjectAndContractResponsible_Officer, UserFieldValue.FromDotNetObject(ecm.ECMProjectAndContractResponsible_Officer));
                                rec.SetFieldValue(fd_ECMProjectAndContractStart_Date, UserFieldValue.FromDotNetObject(ecm.ECMProjectAndContractStart_Date));
                                rec.SetFieldValue(fd_ECMProjectAndContractStatus, UserFieldValue.FromDotNetObject(ecm.ECMProjectAndContractStatus));
                                rec.SetFieldValue(fd_ECMPropertyHouse_No, UserFieldValue.FromDotNetObject(ecm.ECMPropertyHouse_No));
                                rec.SetFieldValue(fd_ECMPropertyHouse_No_Suffix, UserFieldValue.FromDotNetObject(ecm.ECMPropertyHouse_No_Suffix));
                                //rec.SetFieldValue(fd_ECMPropertyHouse_No_To, UserFieldValue.FromDotNetObject(ecm.ECMPropertyHouse_No_To));
                                rec.SetFieldValue(fd_ECMPropertyHouse_No_To_Suffix, UserFieldValue.FromDotNetObject(ecm.ECMPropertyHouse_No_To_Suffix));
                                rec.SetFieldValue(fd_ECMPropertyLocality_Name, UserFieldValue.FromDotNetObject(ecm.ECMPropertyLocality_Name));
                                rec.SetFieldValue(fd_ECMPropertyPostcode, UserFieldValue.FromDotNetObject(ecm.ECMPropertyPostcode));
                                rec.SetFieldValue(fd_ECMPropertyProperty_Name, UserFieldValue.FromDotNetObject(ecm.ECMPropertyProperty_Name));
                                rec.SetFieldValue(fd_ECMPropertyProperty_No, UserFieldValue.FromDotNetObject(ecm.ECMPropertyProperty_No));
                                rec.SetFieldValue(fd_ECMPropertyStreet_Name, UserFieldValue.FromDotNetObject(ecm.ECMPropertyStreet_Name));
                                rec.SetFieldValue(fd_ECMPropertyUnit_No, UserFieldValue.FromDotNetObject(ecm.ECMPropertyUnit_No));
                                rec.SetFieldValue(fd_ECMPropertyUnit_No_Suffix, UserFieldValue.FromDotNetObject(ecm.ECMPropertyUnit_No_Suffix));
                                //rec.SetFieldValue(fd_ECMreference, UserFieldValue.FromDotNetObject(ecm.ECMreference));
                                rec.SetFieldValue(fd_ECMRelatedDocDocSetID, UserFieldValue.FromDotNetObject(ecm.ECMRelatedDocDocSetID));
                                rec.SetFieldValue(fd_ECMSTDAllRevTitle, UserFieldValue.FromDotNetObject(ecm.ECMSTDAllRevTitle));
                                rec.SetFieldValue(fd_ECMSTDApplicationNo, UserFieldValue.FromDotNetObject(ecm.ECMSTDApplicationNo));
                                rec.SetFieldValue(fd_ECMSTDBusinessCode, UserFieldValue.FromDotNetObject(ecm.ECMSTDBusinessCode));
                                rec.SetFieldValue(fd_ECMSTDClassName, UserFieldValue.FromDotNetObject(ecm.ECMSTDClassName));
                                rec.SetFieldValue(fd_ECMSTDCorrespondant, UserFieldValue.FromDotNetObject(ecm.ECMSTDCorrespondant));
                                rec.SetFieldValue(fd_ECMSTDCustomerRequest, UserFieldValue.FromDotNetObject(ecm.ECMSTDCustomerRequest));
                                rec.SetFieldValue(fd_ECMSTDDateLastAccessed, UserFieldValue.FromDotNetObject(ecm.ECMSTDDateLastAccessed));
                                rec.SetFieldValue(fd_ECMSTDDateReceived, UserFieldValue.FromDotNetObject(ecm.ECMSTDDateReceived));
                                rec.SetFieldValue(fd_ECMSTDDateRegistered, UserFieldValue.FromDotNetObject(ecm.ECMSTDDateRegistered));
                                rec.SetFieldValue(fd_ECMSTDDeclaredDate, UserFieldValue.FromDotNetObject(ecm.ECMSTDDeclaredDate));
                                rec.SetFieldValue(fd_ECMSTDDestructionDue, UserFieldValue.FromDotNetObject(ecm.ECMSTDDestructionDue));
                                rec.SetFieldValue(fd_ECMSTDDocumentDate, UserFieldValue.FromDotNetObject(ecm.ECMSTDDocumentDate));
                                rec.SetFieldValue(fd_ECMSTDDocumentType, UserFieldValue.FromDotNetObject(ecm.ECMSTDDocumentType));
                                rec.SetFieldValue(fd_ECMSTDExternalReference, UserFieldValue.FromDotNetObject(ecm.ECMSTDExternalReference));
                                rec.SetFieldValue(fd_ECMSTDInfringementNo, UserFieldValue.FromDotNetObject(ecm.ECMSTDInfringementNo));
                                rec.SetFieldValue(fd_ECMSTDInternalReference, UserFieldValue.FromDotNetObject(ecm.ECMSTDInternalReference));
                                rec.SetFieldValue(fd_ECMSTDInternalScanRequest, UserFieldValue.FromDotNetObject(ecm.ECMSTDInternalScanRequest));
                                rec.SetFieldValue(fd_ECMSTDJobNo, UserFieldValue.FromDotNetObject(ecm.ECMSTDJobNo));
                                rec.SetFieldValue(fd_ECMSTDOtherReferences, UserFieldValue.FromDotNetObject(ecm.ECMSTDOtherReferences));
                                rec.SetFieldValue(fd_ECMSTDPropertyNo, UserFieldValue.FromDotNetObject(ecm.ECMSTDPropertyNo));
                                rec.SetFieldValue(fd_ECMSTDSummaryText, UserFieldValue.FromDotNetObject(ecm.ECMSTDSummaryText));
                                rec.SetFieldValue(fd_ECMStreetsLocality, UserFieldValue.FromDotNetObject(ecm.ECMStreetsLocality));
                                rec.SetFieldValue(fd_ECMStreetsPostcode, UserFieldValue.FromDotNetObject(ecm.ECMStreetsPostcode));
                                rec.SetFieldValue(fd_ECMStreetsStreet_Name, UserFieldValue.FromDotNetObject(ecm.ECMStreetsStreet_Name));
                                rec.SetFieldValue(fd_ECMUserGroupsDescription, UserFieldValue.FromDotNetObject(ecm.ECMUserGroupsDescription));
                                rec.SetFieldValue(fd_ECMUserGroupsExtNo, UserFieldValue.FromDotNetObject(ecm.ECMUserGroupsExtNo));
                                rec.SetFieldValue(fd_ECMUserGroupsGivenName, UserFieldValue.FromDotNetObject(ecm.ECMUserGroupsGivenName));
                                rec.SetFieldValue(fd_ECMUserGroupsOrgEmail, UserFieldValue.FromDotNetObject(ecm.ECMUserGroupsOrgEmail));
                                rec.SetFieldValue(fd_ECMUserGroupsSurname, UserFieldValue.FromDotNetObject(ecm.ECMUserGroupsSurname));
                                rec.SetFieldValue(fd_ECMVolumeFilename, UserFieldValue.FromDotNetObject(ecm.ECMVolumeFilename));
                                rec.SetFieldValue(fd_ECMVolumeLastModified, UserFieldValue.FromDotNetObject(ecm.ECMVolumeLastModified));
                                rec.SetFieldValue(fd_ECMVolumeMedia, UserFieldValue.FromDotNetObject(ecm.ECMVolumeMedia));
                                rec.SetFieldValue(fd_ECMVolumePrimaryCacheName, UserFieldValue.FromDotNetObject(ecm.ECMVolumePrimaryCacheName));
                                rec.SetFieldValue(fd_ECMVolumeRenditionTypeName, UserFieldValue.FromDotNetObject(ecm.ECMVolumeRenditionTypeName));
                                rec.SetFieldValue(fd_ECMVolumeShareDrive, UserFieldValue.FromDotNetObject(ecm.ECMVolumeShareDrive));
                                rec.SetFieldValue(fd_ECMVolumeSize, UserFieldValue.FromDotNetObject(ecm.ECMVolumeSize));
                                rec.SetFieldValue(fd_ECMVolumeStatus, UserFieldValue.FromDotNetObject(ecm.ECMVolumeStatus));
                                rec.SetFieldValue(fd_ECMVolumeStorageLocation, UserFieldValue.FromDotNetObject(ecm.ECMVolumeStorageLocation));
                                //rec.SetFieldValue(fd_ECMVolumeUpdatable, UserFieldValue.FromDotNetObject(ecm.ECMVolumeUpdatable));
                                try
                                {
                                    InputDocument doc = new InputDocument();
                                    doc.SetAsFile(strStorageLoc);
                                    rec.SetDocument(doc, false, false, "Imported from ECM");
                                    rec.Save();
                                    deleteEcmSource(strStorageLoc);
                                    Console.WriteLine("New record created: " + rec.Number);
                                    UpdateMasterinRM(rec);
                                }
                                catch (Exception exp)
                                {
                                    Console.WriteLine("Save new record error: " + exp.Message.ToString());
                                    UpdateMasterNoRm(ecm.DocSetID, 0);
                                    Loggitt("Record number " + ecm.DocSetID + "  could not be added - record save: " + exp.Message.ToString() + Environment.NewLine + iCount.ToString() + " " + strTotal + "" + result.TotalMinutes.ToString() + " " + (Convert.ToInt32(strOffset) + iCount).ToString(), "ECM Migrate issue");

                                }
                            }
                            else
                            {
                                Console.WriteLine("Cant find ECM container in Eddie: " + ecm.ECMBCSFunction_Name + " - " + ecm.ECMBCSActivity_Name.Replace("-", "~"));
                            }

                        }
                        else
                        {
                            Console.WriteLine("ECM electronic document cant be found: " + strStorageLoc);
                            UpdateMasterNoRm(ecm.DocSetID, 1);
                            // UpdateMasterinRMnoDoc()
                        }

                        //}
                        //else
                        //{
                        //    Console.WriteLine("ECM record already exists: " + ecm.DocSetID);
                        //    UpdateMasterinRM(reccheck);
                        //}

                    }
                    catch (Exception exp)
                    {
                        Console.WriteLine("Outer look error: " + exp.Message.ToString());
                        Loggitt("Record number " + ecm.DocSetID + "  could not be added -  Outer Error: " + exp.Message.ToString() + Environment.NewLine + iCount.ToString() + " " + strTotal + "" + result.TotalMinutes.ToString() + " " + (Convert.ToInt32(strOffset) + iCount).ToString(), "ECM Migrate issue");
                        //Console.ReadLine();
                    }
                }
            }
            //});

        }
コード例 #34
0
        static void Main(string[] args)
        {
            List<RM> lstRm = new List<RM>();
            //string connectionString = "Data Source=MSI-GS60;Initial Catalog=SCC_Dev;Integrated Security=True";
            string connectionString = "Data Source=Cl1025;Initial Catalog=StagingMove;Integrated Security=True";
            //string Sql = "SELECT R.recordId, R.uri, E.reVersions FROM dbo.TSRECORD AS R LEFT OUTER JOIN dbo.TSRECELEC AS E ON R.uri = E.uri WHERE (R.rcRecTypeUri = 16) and E.reVersions is null";
            string Sql = "SELECT top 5000 dbo.Elai.[STD:DocumentSetID], dbo.Elai.[Volume:StorageLocation], dbo.Elai.[Volume:Filename] FROM dbo.ECM_MasterCheck AS M INNER JOIN dbo.Elai ON M.DocumentSetID = dbo.Elai.[STD:DocumentSetID] WHERE (M.RMUri IS NOT NULL) AND (M.RmRevisions = 0) AND (M.Issue <> 1) AND Pass = 1 order by dbo.Elai.[STD:DocumentSetID] Desc";
            //WHERE(R.rcRecTypeUri = 21)"
            using (SqlConnection con = new SqlConnection(connectionString))
            {
                con.Open();
                //Console.WriteLine("Enter SQL string");
                //List<ECMMigration> lstecm = new List<ECMMigration>();
                using (SqlCommand command = new SqlCommand(Sql, con))
                {
                    command.CommandTimeout = 0;
                    //DataSet dataSet = new DataSet();
                    //DataTable dt = new DataTable();
                    //SqlDataAdapter da = new SqlDataAdapter();
                    //da.SelectCommand = command;
                    //da.Fill(dt);
                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        //Console.WriteLine("Record: " + reader.GetString(0));
                        RM rm = new RM();
                        rm.recordid = reader.GetInt32(0).ToString();
                        rm.Storage = reader.GetString(1);
                        rm.FileName = reader.GetString(2);
                        lstRm.Add(rm);
                    }
                }
            }
            Console.WriteLine("Closed sql connection");
                using (Database db = new Database())
                {
                int iprocesscnt = 0;
                string iTotalcnt = lstRm.Count.ToString();
                foreach (RM rm in lstRm)
                    {
                    //Console.WriteLine("Record: " + rm.recordid);
                    iprocesscnt++;
                        //try
                        //{
                        Record rec = (Record)db.FindTrimObjectByName(BaseObjectTypes.Record, rm.recordid);
                        //if (reccheck == null)
                        //{
                        string strStorageLoc = FindMappedStorage(rm.Storage) + "\\" + rm.FileName;
                    OriginHistory oh = new OriginHistory(db, 34343);
                    
                        if (rec != null)
                        {
                            if (File.Exists(strStorageLoc))
                            {
                                try
                                {
                                    if (rec.DateRegistered <= rec.DateReceived)
                                    {
                                        DateTime tdtDateReceived = rec.DateReceived;
                                        rec.DateRegistered = (TrimDateTime)tdtDateReceived.AddHours(1);
                                        rec.Save();
                                    }
                                    InputDocument doc = new InputDocument();
                                    doc.SetAsFile(strStorageLoc);
                                    rec.SetDocument(doc, false, false, "Imported from ECM");
                                    rec.Save();
                                    deleteEcmSource(strStorageLoc);

                                Console.WriteLine("Eddie record "+iprocesscnt+" of "+iTotalcnt.ToString()+": updated with file: " + rec.Number);
                                    UpdateMasterinRM(rec, 0);
                                }
                                catch (Exception exp)
                                {
                                    Console.WriteLine("Save record attachment error: " + exp.Message.ToString());
                                    //UpdateMasterNoRm(rm.recordid, 2);
                                    UpdateMasterinRM(rec, 2);
                                }
                            }
                            else
                            {
                                UpdateMasterinRM(rec, 1);
                            }
                        }
                        else
                        {
                            UpdateMasterNoRm(rm.recordid, 0);
                        }
                        //}


                        //        UpdateMasterinRM(rm);
                    }
                //}
                //using (var bulkCopy = new SqlBulkCopy(connectionString, SqlBulkCopyOptions.KeepNulls & SqlBulkCopyOptions.KeepIdentity))
                //{
                //    bulkCopy.BatchSize = CustomerList.Count;
                //    bulkCopy.DestinationTableName = "dbo.tCustomers";
                //    bulkCopy.ColumnMappings.Clear();
                //    bulkCopy.ColumnMappings.Add("CustomerID", "CustomerID");
                //    bulkCopy.ColumnMappings.Add("FirstName", "FirstName");
                //    bulkCopy.ColumnMappings.Add("LastName", "LastName");
                //    bulkCopy.ColumnMappings.Add("Address1", "Address1");
                //    bulkCopy.ColumnMappings.Add("Address2", "Address2");
                //    bulkCopy.WriteToServer(CustomerList);
                //}
                //BulkOperation 
                //SqlBulkCopy bc = new SqlBulkCopy(con);

                //var bulk = new BulkOperation(con);
                //bulk.BulkInsert(dt);
                //bulk.BulkUpdate(dt);
            }
            Console.WriteLine("Records: " + lstRm.Count().ToString());
            Console.ReadLine();
            //
            //   TrimApplication.Initialize();
            //using (Database db = new Database())
            //{
            //    db.Connect();

            //    TrimMainObjectSearch objs = new TrimMainObjectSearch(db, BaseObjectTypes.Record);
            //    //objs.SetSearchString("type:21 and not electronic");
            //    objs.SelectAll();
            //    foreach (Record r in objs)
            //    {
            //        Console.WriteLine("Record: " + r.Number);
            //    }

            //}
        }
コード例 #35
0
        public bool run(Database db)
        {
            
            try
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                Console.WriteLine("Initialise BulkDataLoader ...");
                // create an origin to use for this sample. Look it up first just so you can rerun the code.
                m_origin = db.FindTrimObjectByName(BaseObjectTypes.Origin, "ECM bulk load") as Origin;

                //Console.WriteLine("origin check: " + m_origin.)
                //Console.ReadLine();
                if (m_origin == null)
                {
                    m_origin = new Origin(db, OriginType.Custom1);

                    m_origin.Name = "ECM bulk load";
                    m_origin.OriginLocation = "SQL Extracts";
                    // sample code assumes you have a record type defined called "Document"
                    m_origin.DefaultRecordType = db.FindTrimObjectByUri(BaseObjectTypes.RecordType, 16) as RecordType;
                    // don't bother with other origin defaults for the sample, just save it so we can use it
                    //m_origin.DefaultContainer = db.FindTrimObjectByUri(BaseObjectTypes.Record, 148020) as Record;

                    m_origin.Save();
                    Console.WriteLine("origin check, new: " + m_origin.Name);
                }
                else
                {
                    Console.WriteLine("origin check: " + m_origin.Name);
                }
                m_loader = new BulkDataLoader(m_origin);
                if (!m_loader.Initialise())
                {
                    // this sample has no way of dealing with the error.
                    Console.WriteLine(m_loader.ErrorMessage);
                    return false;
                }
                Console.WriteLine("Starting migration run ...");
                //Console.ReadLine();
                m_loader.StartRun("Input Data", @"C:\Temp");
                
                //13 13 HP TRIM Bulk Data Importing Programming Guide
                // setup the property array that will be used to transfer record metadata
                PropertyOrFieldValue[] recordFields = new PropertyOrFieldValue[111];
                recordFields[0] = new PropertyOrFieldValue(PropertyIds.RecordTitle);
                recordFields[1] = new PropertyOrFieldValue(PropertyIds.RecordDateCreated);
                recordFields[2] = new PropertyOrFieldValue(PropertyIds.RecordNotes);
                recordFields[3] = new PropertyOrFieldValue(PropertyIds.RecordContainer);
                recordFields[4] = new PropertyOrFieldValue(PropertyIds.RecordNumber);
                recordFields[110] = new PropertyOrFieldValue(PropertyIds.RecordBarcode);

                //
                FieldDefinition fd_ECMApplicationRAM_Application_Number = new FieldDefinition(db, "Application Number List");
                recordFields[5] = new PropertyOrFieldValue(fd_ECMApplicationRAM_Application_Number);

                FieldDefinition fd_ECMBarCodeBarCodeString = new FieldDefinition(db, "ECM BarCode:BarCodeString");
                recordFields[6] = new PropertyOrFieldValue(fd_ECMBarCodeBarCodeString);

                FieldDefinition fd_ECMBCSRetention_Period = new FieldDefinition(db, "ECM BCS:Retention_Period");
                recordFields[7] = new PropertyOrFieldValue(fd_ECMBCSRetention_Period);

                FieldDefinition fd_ECMCaseCaseDescription = new FieldDefinition(db, "ECM Case:CaseDescription");
                recordFields[8] = new PropertyOrFieldValue(fd_ECMCaseCaseDescription);

                FieldDefinition fd_ECMCaseCaseName = new FieldDefinition(db, "ECM Case:CaseName");
                recordFields[9] = new PropertyOrFieldValue(fd_ECMCaseCaseName);

                FieldDefinition fd_ECMCaseCaseNumber = new FieldDefinition(db, "ECM Case:CaseNumber");
                recordFields[10] = new PropertyOrFieldValue(fd_ECMCaseCaseNumber);

                FieldDefinition fd_ECMCaseCaseOfficer = new FieldDefinition(db, "ECM Case:CaseOfficer");
                recordFields[11] = new PropertyOrFieldValue(fd_ECMCaseCaseOfficer);

                FieldDefinition fd_ECMCaseCaseStatus = new FieldDefinition(db, "ECM Case:CaseStatus");
                recordFields[12] = new PropertyOrFieldValue(fd_ECMCaseCaseStatus);

                FieldDefinition fd_ECMCaseCaseType = new FieldDefinition(db, "ECM Case:CaseType");
                recordFields[13] = new PropertyOrFieldValue(fd_ECMCaseCaseType);

                FieldDefinition fd_ECMCaseEndDate = new FieldDefinition(db, "ECM Case:EndDate");
                recordFields[14] = new PropertyOrFieldValue(fd_ECMCaseEndDate);

                FieldDefinition fd_ECMCaseStartDate = new FieldDefinition(db, "ECM Case:StartDate");
                recordFields[15] = new PropertyOrFieldValue(fd_ECMCaseStartDate);

                FieldDefinition fd_ECMCorrespondentDescription = new FieldDefinition(db, "ECM Correspondent:Description");
                recordFields[16] = new PropertyOrFieldValue(fd_ECMCorrespondentDescription);

                FieldDefinition fd_ECMECMDriveID = new FieldDefinition(db, "ECM ECMDriveID");
                recordFields[17] = new PropertyOrFieldValue(fd_ECMECMDriveID);

                FieldDefinition fd_ECMEmployeeCommencement_Date = new FieldDefinition(db, "ECM Employee:Commencement_Date");
                recordFields[18] = new PropertyOrFieldValue(fd_ECMEmployeeCommencement_Date);

                FieldDefinition fd_ECMEmployeeEmployee_Given_Name = new FieldDefinition(db, "ECM Employee:Employee_Given_Name");
                recordFields[19] = new PropertyOrFieldValue(fd_ECMEmployeeEmployee_Given_Name);

                FieldDefinition fd_ECMEmployeeEmployee_Surname = new FieldDefinition(db, "ECM Employee:Employee_Surname");
                recordFields[20] = new PropertyOrFieldValue(fd_ECMEmployeeEmployee_Surname);

                FieldDefinition fd_ECMEmployeeEmployeeCode = new FieldDefinition(db, "ECM Employee:EmployeeCode");
                recordFields[21] = new PropertyOrFieldValue(fd_ECMEmployeeEmployeeCode);

                FieldDefinition fd_ECmEmployeeHR_Case_Description = new FieldDefinition(db, "ECm Employee:HR_Case_Description");
                recordFields[22] = new PropertyOrFieldValue(fd_ECmEmployeeHR_Case_Description);

                FieldDefinition fd_ECMEmployeePreferred_Name = new FieldDefinition(db, "ECM Employee:Preferred_Name");
                recordFields[23] = new PropertyOrFieldValue(fd_ECMEmployeePreferred_Name);

                FieldDefinition fd_ECMEmployeeStatus = new FieldDefinition(db, "ECM Employee:Status");
                recordFields[24] = new PropertyOrFieldValue(fd_ECMEmployeeStatus);

                FieldDefinition fd_ECMEmployeeTermination_Date = new FieldDefinition(db, "ECM Employee:Termination_Date");
                recordFields[25] = new PropertyOrFieldValue(fd_ECMEmployeeTermination_Date);

                FieldDefinition fd_ECMFileName = new FieldDefinition(db, "ECM FileName");
                recordFields[26] = new PropertyOrFieldValue(fd_ECMFileName);

                FieldDefinition fd_ECMFileNetFoldername = new FieldDefinition(db, "ECM FileNet:Foldername");
                recordFields[27] = new PropertyOrFieldValue(fd_ECMFileNetFoldername);

                FieldDefinition fd_ECMHR_Case_Code = new FieldDefinition(db, "ECM HR_Case_Code");
                recordFields[28] = new PropertyOrFieldValue(fd_ECMHR_Case_Code);

                FieldDefinition fd_ECMInfoExpertLevel1_Name = new FieldDefinition(db, "ECM InfoExpert:Level1_Name");
                recordFields[29] = new PropertyOrFieldValue(fd_ECMInfoExpertLevel1_Name);

                FieldDefinition fd_ECMInfoExpertLevel2_Name = new FieldDefinition(db, "ECM InfoExpert:Level2_Name");
                recordFields[30] = new PropertyOrFieldValue(fd_ECMInfoExpertLevel2_Name);

                FieldDefinition fd_ECMInfoExpertLevel3_Description = new FieldDefinition(db, "ECM InfoExpert:Level3_Description");
                recordFields[31] = new PropertyOrFieldValue(fd_ECMInfoExpertLevel3_Description);

                FieldDefinition fd_ECMInfoExpertLevel3_Name = new FieldDefinition(db, "ECM InfoExpert:Level3_Name");
                recordFields[32] = new PropertyOrFieldValue(fd_ECMInfoExpertLevel3_Name);

                FieldDefinition fd_ECMInfoExpertLevel4_Description = new FieldDefinition(db, "ECM InfoExpert:Level4_Description");
                recordFields[33] = new PropertyOrFieldValue(fd_ECMInfoExpertLevel4_Description);

                FieldDefinition fd_ECMInfoExpertLevel4_Name = new FieldDefinition(db, "ECM InfoExpert:Level4_Name");
                recordFields[34] = new PropertyOrFieldValue(fd_ECMInfoExpertLevel4_Name);

                FieldDefinition fd_ECMInfoExpertLevel5_Description = new FieldDefinition(db, "ECM InfoExpert:Level5_Description");
                recordFields[35] = new PropertyOrFieldValue(fd_ECMInfoExpertLevel5_Description);

                FieldDefinition fd_ECMInfoExpertLevel5_Name = new FieldDefinition(db, "ECM InfoExpert:Level5_Name");
                recordFields[36] = new PropertyOrFieldValue(fd_ECMInfoExpertLevel5_Name);

                FieldDefinition fd_ECMInfringementInfringementID = new FieldDefinition(db, "ECM Infringement:InfringementID");
                recordFields[37] = new PropertyOrFieldValue(fd_ECMInfringementInfringementID);

                FieldDefinition fd_ECMNotes = new FieldDefinition(db, "ECM Notes");
                recordFields[38] = new PropertyOrFieldValue(fd_ECMNotes);

                FieldDefinition fd_ECMPositionClose_Date = new FieldDefinition(db, "ECM Position:Close_Date");
                recordFields[39] = new PropertyOrFieldValue(fd_ECMPositionClose_Date);

                FieldDefinition fd_ECMPositionOpen_Date = new FieldDefinition(db, "ECM Position:Open_Date");
                recordFields[40] = new PropertyOrFieldValue(fd_ECMPositionOpen_Date);

                FieldDefinition fd_ECMPositionPosition_ID = new FieldDefinition(db, "ECM Position:Position_ID");
                recordFields[41] = new PropertyOrFieldValue(fd_ECMPositionPosition_ID);

                FieldDefinition fd_ECMPositionPosition_Title = new FieldDefinition(db, "ECM Position:Position_Title");
                recordFields[42] = new PropertyOrFieldValue(fd_ECMPositionPosition_Title);

                FieldDefinition fd_ECMPositionVacancy_ID = new FieldDefinition(db, "ECM Position:Vacancy_ID");
                recordFields[43] = new PropertyOrFieldValue(fd_ECMPositionVacancy_ID);

                FieldDefinition fd_ECMPositionVacancy_Status = new FieldDefinition(db, "ECM Position:Vacancy_Status");
                recordFields[44] = new PropertyOrFieldValue(fd_ECMPositionVacancy_Status);

                FieldDefinition fd_ECMProjectAndContractProject_Name = new FieldDefinition(db, "ECM ProjectAndContract:[Project_Name");
                recordFields[45] = new PropertyOrFieldValue(fd_ECMProjectAndContractProject_Name);

                FieldDefinition fd_ECMProjectAndContractContract_or_Activity_Desc = new FieldDefinition(db, "ECM ProjectAndContract:Contract_or_Activity_Desc");
                recordFields[46] = new PropertyOrFieldValue(fd_ECMProjectAndContractContract_or_Activity_Desc);

                FieldDefinition fd_ECMProjectAndContractContract_or_Activity_Name = new FieldDefinition(db, "ECM ProjectAndContract:Contract_or_Activity_Name");
                recordFields[47] = new PropertyOrFieldValue(fd_ECMProjectAndContractContract_or_Activity_Name);

                FieldDefinition fd_ECMProjectAndContractContract_or_Activity_No = new FieldDefinition(db, "ECM ProjectAndContract:Contract_or_Activity_No");
                recordFields[48] = new PropertyOrFieldValue(fd_ECMProjectAndContractContract_or_Activity_No);

                FieldDefinition fd_ECMProjectAndContractEnd_Date = new FieldDefinition(db, "ECM ProjectAndContract:End_Date");
                recordFields[49] = new PropertyOrFieldValue(fd_ECMProjectAndContractEnd_Date);

                FieldDefinition fd_ECMProjectAndContractProject_Description = new FieldDefinition(db, "ECM ProjectAndContract:Project_Description");
                recordFields[50] = new PropertyOrFieldValue(fd_ECMProjectAndContractProject_Description);

                FieldDefinition fd_ECMProjectAndContractProject_End_Date = new FieldDefinition(db, "ECM ProjectAndContract:Project_End_Date");
                recordFields[51] = new PropertyOrFieldValue(fd_ECMProjectAndContractProject_End_Date);

                FieldDefinition fd_ECMProjectAndContractProject_Officer = new FieldDefinition(db, "ECM ProjectAndContract:Project_Officer");
                recordFields[52] = new PropertyOrFieldValue(fd_ECMProjectAndContractProject_Officer);

                FieldDefinition fd_ECMProjectAndContractProject_Start_Date = new FieldDefinition(db, "ECM ProjectAndContract:Project_Start_Date");
                recordFields[53] = new PropertyOrFieldValue(fd_ECMProjectAndContractProject_Start_Date);

                FieldDefinition fd_ECMProjectAndContractProjectNo = new FieldDefinition(db, "ECM ProjectAndContract:ProjectNo");
                recordFields[54] = new PropertyOrFieldValue(fd_ECMProjectAndContractProjectNo);

                FieldDefinition fd_ECMProjectAndContractResponsible_Officer = new FieldDefinition(db, "ECM ProjectAndContract:Responsible_Officer");
                recordFields[55] = new PropertyOrFieldValue(fd_ECMProjectAndContractResponsible_Officer);

                FieldDefinition fd_ECMProjectAndContractStart_Date = new FieldDefinition(db, "ECM ProjectAndContract:Start_Date");
                recordFields[56] = new PropertyOrFieldValue(fd_ECMProjectAndContractStart_Date);

                FieldDefinition fd_ECMProjectAndContractStatus = new FieldDefinition(db, "ECM ProjectAndContract:Status");
                recordFields[57] = new PropertyOrFieldValue(fd_ECMProjectAndContractStatus);

                FieldDefinition fd_ECMPropertyHouse_No = new FieldDefinition(db, "ECM Property:House_No");
                recordFields[58] = new PropertyOrFieldValue(fd_ECMPropertyHouse_No);

                FieldDefinition fd_ECMPropertyHouse_No_Suffix = new FieldDefinition(db, "ECM Property:House_No_Suffix");
                recordFields[59] = new PropertyOrFieldValue(fd_ECMPropertyHouse_No_Suffix);

                FieldDefinition fd_ECMPropertyHouse_No_To = new FieldDefinition(db, "ECM Property:House_No_To");
                recordFields[60] = new PropertyOrFieldValue(fd_ECMPropertyHouse_No_To);

                FieldDefinition fd_ECMPropertyHouse_No_To_Suffix = new FieldDefinition(db, "ECM Property:House_No_To_Suffix");
                recordFields[61] = new PropertyOrFieldValue(fd_ECMPropertyHouse_No_To_Suffix);

                FieldDefinition fd_ECMPropertyLocality_Name = new FieldDefinition(db, "ECM Property:Locality_Name");
                recordFields[62] = new PropertyOrFieldValue(fd_ECMPropertyLocality_Name);

                FieldDefinition fd_ECMPropertyPostcode = new FieldDefinition(db, "ECM Property:Postcode");
                recordFields[63] = new PropertyOrFieldValue(fd_ECMPropertyPostcode);

                FieldDefinition fd_ECMPropertyProperty_Name = new FieldDefinition(db, "ECM Property:Property_Name");
                recordFields[64] = new PropertyOrFieldValue(fd_ECMPropertyProperty_Name);

                FieldDefinition fd_ECMPropertyProperty_No = new FieldDefinition(db, "Property Number List");
                recordFields[65] = new PropertyOrFieldValue(fd_ECMPropertyProperty_No);

                FieldDefinition fd_ECMPropertyStreet_Name = new FieldDefinition(db, "ECM Property:Street_Name");
                recordFields[66] = new PropertyOrFieldValue(fd_ECMPropertyStreet_Name);

                FieldDefinition fd_ECMPropertyUnit_No = new FieldDefinition(db, "ECM Property:Unit_No");
                recordFields[67] = new PropertyOrFieldValue(fd_ECMPropertyUnit_No);

                FieldDefinition fd_ECMPropertyUnit_No_Suffix = new FieldDefinition(db, "ECM Property:Unit_No_Suffix");
                recordFields[68] = new PropertyOrFieldValue(fd_ECMPropertyUnit_No_Suffix);

                FieldDefinition fd_ECMreference = new FieldDefinition(db, "ECM reference");
                recordFields[69] = new PropertyOrFieldValue(fd_ECMreference);

                FieldDefinition fd_ECMRelatedDocDocSetID = new FieldDefinition(db, "ECM RelatedDoc:DocSetID");
                recordFields[70] = new PropertyOrFieldValue(fd_ECMRelatedDocDocSetID);

                FieldDefinition fd_ECMSTDAllRevTitle = new FieldDefinition(db, "ECM STD:AllRevTitle");
                recordFields[71] = new PropertyOrFieldValue(fd_ECMSTDAllRevTitle);

                FieldDefinition fd_ECMSTDApplicationNo = new FieldDefinition(db, "ECM STD:ApplicationNo");
                recordFields[72] = new PropertyOrFieldValue(fd_ECMSTDApplicationNo);

                FieldDefinition fd_ECMSTDBusinessCode = new FieldDefinition(db, "ECM STD:BusinessCode");
                recordFields[73] = new PropertyOrFieldValue(fd_ECMSTDBusinessCode);

                FieldDefinition fd_ECMSTDClassName = new FieldDefinition(db, "ECM STD:ClassName");
                recordFields[74] = new PropertyOrFieldValue(fd_ECMSTDClassName);

                FieldDefinition fd_ECMSTDCorrespondant = new FieldDefinition(db, "ECM STD:Correspondant");
                recordFields[75] = new PropertyOrFieldValue(fd_ECMSTDCorrespondant);

                FieldDefinition fd_ECMSTDCustomerRequest = new FieldDefinition(db, "ECM STD:CustomerRequest");
                recordFields[76] = new PropertyOrFieldValue(fd_ECMSTDCustomerRequest);

                FieldDefinition fd_ECMSTDDateLastAccessed = new FieldDefinition(db, "ECM STD:DateLastAccessed");
                recordFields[77] = new PropertyOrFieldValue(fd_ECMSTDDateLastAccessed);

                FieldDefinition fd_ECMSTDDateReceived = new FieldDefinition(db, "ECM STD:DateReceived");
                recordFields[78] = new PropertyOrFieldValue(fd_ECMSTDDateReceived);

                FieldDefinition fd_ECMSTDDateRegistered = new FieldDefinition(db, "ECM STD:DateRegistered");
                recordFields[79] = new PropertyOrFieldValue(fd_ECMSTDDateRegistered);

                FieldDefinition fd_ECMSTDDeclaredDate = new FieldDefinition(db, "ECM STD:DeclaredDate");
                recordFields[80] = new PropertyOrFieldValue(fd_ECMSTDDeclaredDate);

                FieldDefinition fd_ECMSTDDestructionDue = new FieldDefinition(db, "ECM STD:DestructionDue");
                recordFields[81] = new PropertyOrFieldValue(fd_ECMSTDDestructionDue);

                FieldDefinition fd_ECMSTDDocumentDate = new FieldDefinition(db, "ECM STD:DocumentDate");
                recordFields[82] = new PropertyOrFieldValue(fd_ECMSTDDocumentDate);

                FieldDefinition fd_ECMSTDDocumentType = new FieldDefinition(db, "ECM STD:DocumentType");
                recordFields[83] = new PropertyOrFieldValue(fd_ECMSTDDocumentType);

                FieldDefinition fd_ECMSTDExternalReference = new FieldDefinition(db, "ECM STD:ExternalReference");
                recordFields[84] = new PropertyOrFieldValue(fd_ECMSTDExternalReference);

                FieldDefinition fd_ECMSTDInfringementNo = new FieldDefinition(db, "Infringement Number");
                recordFields[85] = new PropertyOrFieldValue(fd_ECMSTDInfringementNo);

                FieldDefinition fd_ECMSTDInternalReference = new FieldDefinition(db, "ECM STD:InternalReference");
                recordFields[86] = new PropertyOrFieldValue(fd_ECMSTDInternalReference);

                FieldDefinition fd_ECMSTDInternalScanRequest = new FieldDefinition(db, "ECM STD:InternalScanRequest");
                recordFields[87] = new PropertyOrFieldValue(fd_ECMSTDInternalScanRequest);

                FieldDefinition fd_ECMSTDJobNo = new FieldDefinition(db, "ECM STD:JobNo");
                recordFields[88] = new PropertyOrFieldValue(fd_ECMSTDJobNo);

                FieldDefinition fd_ECMSTDOtherReferences = new FieldDefinition(db, "ECM STD:OtherReferences");
                recordFields[89] = new PropertyOrFieldValue(fd_ECMSTDOtherReferences);

                FieldDefinition fd_ECMSTDPropertyNo = new FieldDefinition(db, "ECM STD:PropertyNo");
                recordFields[90] = new PropertyOrFieldValue(fd_ECMSTDPropertyNo);

                FieldDefinition fd_ECMSTDSummaryText = new FieldDefinition(db, "ECM STD:SummaryText");
                recordFields[91] = new PropertyOrFieldValue(fd_ECMSTDSummaryText);

                FieldDefinition fd_ECMStreetsLocality = new FieldDefinition(db, "ECM Streets:Locality");
                recordFields[92] = new PropertyOrFieldValue(fd_ECMStreetsLocality);

                FieldDefinition fd_ECMStreetsPostcode = new FieldDefinition(db, "ECM Streets:Postcode");
                recordFields[93] = new PropertyOrFieldValue(fd_ECMStreetsPostcode);

                FieldDefinition fd_ECMStreetsStreet_Name = new FieldDefinition(db, "ECM Streets:Street_Name");
                recordFields[94] = new PropertyOrFieldValue(fd_ECMStreetsStreet_Name);

                FieldDefinition fd_ECMUserGroupsDescription = new FieldDefinition(db, "ECM UserGroups:Description");
                recordFields[95] = new PropertyOrFieldValue(fd_ECMUserGroupsDescription);

                FieldDefinition fd_ECMUserGroupsExtNo = new FieldDefinition(db, "ECM UserGroups:ExtNo");
                recordFields[96] = new PropertyOrFieldValue(fd_ECMUserGroupsExtNo);

                FieldDefinition fd_ECMUserGroupsGivenName = new FieldDefinition(db, "ECM UserGroups:GivenName");
                recordFields[97] = new PropertyOrFieldValue(fd_ECMUserGroupsGivenName);

                FieldDefinition fd_ECMUserGroupsOrgEmail = new FieldDefinition(db, "ECM UserGroups:OrgEmail");
                recordFields[98] = new PropertyOrFieldValue(fd_ECMUserGroupsOrgEmail);

                FieldDefinition fd_ECMUserGroupsSurname = new FieldDefinition(db, "ECM UserGroups:Surname");
                recordFields[99] = new PropertyOrFieldValue(fd_ECMUserGroupsSurname);

                FieldDefinition fd_ECMVolumeFilename = new FieldDefinition(db, "ECM Volume:Filename");
                recordFields[100] = new PropertyOrFieldValue(fd_ECMVolumeFilename);

                FieldDefinition fd_ECMVolumeLastModified = new FieldDefinition(db, "ECM Volume:LastModified");
                recordFields[101] = new PropertyOrFieldValue(fd_ECMVolumeLastModified);

                FieldDefinition fd_ECMVolumeMedia = new FieldDefinition(db, "ECM Volume:Media");
                recordFields[102] = new PropertyOrFieldValue(fd_ECMVolumeMedia);

                FieldDefinition fd_ECMVolumePrimaryCacheName = new FieldDefinition(db, "ECM Volume:PrimaryCacheName");
                recordFields[103] = new PropertyOrFieldValue(fd_ECMVolumePrimaryCacheName);

                FieldDefinition fd_ECMVolumeRenditionTypeName = new FieldDefinition(db, "ECM Volume:RenditionTypeName");
                recordFields[104] = new PropertyOrFieldValue(fd_ECMVolumeRenditionTypeName);

                FieldDefinition fd_ECMVolumeShareDrive = new FieldDefinition(db, "ECM Volume:ShareDrive");
                recordFields[105] = new PropertyOrFieldValue(fd_ECMVolumeShareDrive);

                FieldDefinition fd_ECMVolumeSize = new FieldDefinition(db, "ECM Volume:Size");
                recordFields[106] = new PropertyOrFieldValue(fd_ECMVolumeSize);

                FieldDefinition fd_ECMVolumeStatus = new FieldDefinition(db, "ECM Volume:Status");
                recordFields[107] = new PropertyOrFieldValue(fd_ECMVolumeStatus);

                FieldDefinition fd_ECMVolumeStorageLocation = new FieldDefinition(db, "ECM Volume:StorageLocation");
                recordFields[108] = new PropertyOrFieldValue(fd_ECMVolumeStorageLocation);

                FieldDefinition fd_ECMVolumeUpdatable = new FieldDefinition(db, "ECM Volume:Updatable");
                recordFields[109] = new PropertyOrFieldValue(fd_ECMVolumeUpdatable);
                
                Console.WriteLine("Connected to SQL 1025");
                //Console.WriteLine("Export Batch?");
                //string strBatch = Console.ReadLine();
                Console.WriteLine("Offset?");
                string strOffset = Console.ReadLine();
                Console.WriteLine("Fetch?");
                string strFetch = Console.ReadLine();
                Console.WriteLine("Class");
                string strClass = Console.ReadLine();
                //SELECT * FROM [Extract Public Indexed] E INNER JOIN dbo.ECM_MasterCheck AS M ON E.[STD:DocumentSetID] = M.DocumentSetID WHERE E.ID IN (SELECT MIN(ID) AS ID FROM [Extract Public Indexed] GROUP BY[STD: DocumentID]) AND (M.RMUri IS NULL) AND(E.[STD:Version] = 1) AND (M.Pass = 1) Order by[STD:DocumentSetID] desc
                //SELECT * FROM [Extract Public Zip Indexed] E INNER JOIN dbo.ECM_MasterCheck AS M ON E.[STD:DocumentSetID] = M.DocumentSetID WHERE E.ID IN (SELECT MIN(ID) AS ID FROM [Extract Public Zip Indexed] GROUP BY[STD: DocumentID]) AND (M.RMUri IS NULL) AND(E.[STD:Version] = 1) AND (M.Pass = 1) Order by[STD:DocumentSetID] desc
                //SELECT * FROM [Elai] E INNER JOIN dbo.ECM_MasterCheck AS M ON E.[STD:DocumentSetID] = M.DocumentSetID WHERE E.ID IN (SELECT MIN(ID) AS ID FROM [Elai] GROUP BY[STD: DocumentID]) AND(M.RMUri IS NULL) AND(E.[STD:Version] = 1) AND (M.Pass = 1) Order by[STD:DocumentSetID] desc
                //SELECT * FROM [Elpi] E INNER JOIN dbo.ECM_MasterCheck AS M ON E.[STD:DocumentSetID] = M.DocumentSetID WHERE E.ID IN (SELECT MIN(ID) AS ID FROM [Elpi] GROUP BY[STD: DocumentID]) AND(M.RMUri IS NULL) AND(E.[STD:Version] = 1) AND (M.Pass = 1) Order by[STD:DocumentSetID] desc

                //                SELECT* FROM[Extract Public Zip Indexed] E INNER JOIN dbo.ECM_MasterCheck AS M ON E.[STD: DocumentSetID] = M.DocumentSetID
                //WHERE E.ID IN (SELECT MIN(ID) AS ID FROM[Extract Public Zip Indexed]
                //GROUP BY[STD: DocumentID])
                //AND(M.RMUri IS NULL)
                //AND(E.[STD: Version] = 1)
                //AND(M.Pass = 1)
                //Order by[STD:DocumentSetID] desc

                //SELECT* FROM Elai E INNER JOIN dbo.ECM_MasterCheck AS M ON E.[STD: DocumentSetID] = M.DocumentSetID
                //WHERE E.ID IN (SELECT MIN(ID) AS ID FROM Elai
                //GROUP BY[STD: DocumentID])
                //AND(M.RMUri IS NULL)
                //AND(E.[STD: Version] = 1)
                //AND(M.Pass = 1)
                //Order by[STD:DocumentSetID] desc

                //SELECT* FROM Elpi E INNER JOIN dbo.ECM_MasterCheck AS M ON E.[STD: DocumentSetID] = M.DocumentSetID
                //WHERE E.ID IN (SELECT MIN(ID) AS ID FROM Elpi
                //GROUP BY[STD: DocumentID])
                //AND(M.RMUri IS NULL)
                //AND(E.[STD: Version] = 1)
                //AND(M.Pass = 1)
                //Order by[STD:DocumentSetID] desc
                //string strSql = "Select * from [eri] Where [STD:Version] = 1 and [STD:DocumentSetID] in (Select DocumentSetID from ECM_MasterCheck Where OrigBatch = 'Extract Remainder' and rmuri is null) Order by [ID] OFFSET "+ strOffset + " ROWS FETCH NEXT "+ strFetch + " ROWS ONLY";
                //string strSql = "Select * from [eri] Where ID in(SELECT MIN(ID) AS ID FROM [eri] GROUP BY [STD:DocumentID]) and [STD:Version] = 1 and [STD:DocumentSetID] in (Select DocumentSetID from ECM_MasterCheck Where OrigBatch = 'Extract Remainder' and rmuri is null and issue = 0) Order by [STD:DocumentSetID] OFFSET " + strOffset + " ROWS FETCH NEXT " + strFetch + " ROWS ONLY";
                //string strSql = "Select * from [eri] Where ID in(SELECT MIN(ID) AS ID FROM [eri] GROUP BY [STD:DocumentID]) and [STD:Version] = 1 and [STD:DocumentSetID] in (Select DocumentSetID from ECM_MasterCheck Where OrigBatch = 'Extract Remainder' and rmuri is null and Pass = 1) and [STD:ClassName] = \"All Access\" Order by [STD:DocumentSetID] Desc OFFSET " + strOffset + " ROWS FETCH NEXT " + strFetch + " ROWS ONLY";
                string strSql = "SELECT * FROM Elai E INNER JOIN dbo.ECM_MasterCheck AS M ON E.[STD:DocumentSetID] = M.DocumentSetID WHERE E.ID IN (SELECT MIN(ID) AS ID FROM Elai GROUP BY [STD:DocumentID]) AND (M.RMUri IS NULL) AND (E.[STD:Version] = 1) AND (M.Pass = 1) Order by [STD:DocumentSetID] desc OFFSET " + strOffset + " ROWS FETCH NEXT " + strFetch + " ROWS ONLY";
                List<ECMMigration> lstecm = new List<ECMMigration>();
                using (SqlConnection con = new SqlConnection("Data Source=Cl1025;Initial Catalog=StagingMove;Integrated Security=True"))
                {
                    con.Open();
                    using (SqlCommand command = new SqlCommand(strSql, con))
                    {
                        //DataSet dataSet = new DataSet();
                        //DataTable dt = new DataTable();
                        //SqlDataAdapter da = new SqlDataAdapter();
                        //da.SelectCommand = command;
                        //da.Fill(dt);
                        SqlDataReader reader = command.ExecuteReader();
                        //
                        int ECMSTDDocumentSetID = reader.GetOrdinal("STD:DocumentSetID");
                        int ECMSTDDocumentDescription = reader.GetOrdinal("STD:DocumentDescription");
                        int ECMBCSFunction_Name = reader.GetOrdinal("BCS:Function_Name");
                        int ECMBCSActivity_Name = reader.GetOrdinal("BCS:Activity_Name");
                        int ECMBCSSubject_Name = reader.GetOrdinal("BCS:Subject_Name");
                        int ECMSTDVersion = reader.GetOrdinal("STD:Version");
                        //BCS: Activity_Name

                        //Auto Create
                        int ECMApplicationRAM_Application_Number = reader.GetOrdinal("Application:RAM_Application_Number");
                        int ECMBarCodeBarCodeString = reader.GetOrdinal("BarCode:BarCodeString");
                        int ECMBCSRetention_Period = reader.GetOrdinal("BCS:Retention_Period");
                        int ECMCaseCaseDescription = reader.GetOrdinal("Case:CaseDescription");
                        int ECMCaseCaseName = reader.GetOrdinal("Case:CaseName");
                        int ECMCaseCaseNumber = reader.GetOrdinal("Case:CaseNumber");
                        int ECMCaseCaseOfficer = reader.GetOrdinal("Case:CaseOfficer");
                        int ECMCaseCaseStatus = reader.GetOrdinal("Case:CaseStatus");
                        int ECMCaseCaseType = reader.GetOrdinal("Case:CaseType");
                        int ECMCaseEndDate = reader.GetOrdinal("Case:EndDate");
                        int ECMCaseStartDate = reader.GetOrdinal("Case:StartDate");
                        //int ECMCorrespondentDescription = reader.GetOrdinal("Correspondent:Description");
                        int ECMECMDriveID = reader.GetOrdinal("ECMDriveID");
                        int ECMEmployeeCommencement_Date = reader.GetOrdinal("Employee:Commencement_Date");
                        int ECMEmployeeEmployee_Given_Name = reader.GetOrdinal("Employee:Employee_Given_Name");
                        int ECMEmployeeEmployee_Surname = reader.GetOrdinal("Employee:Employee_Surname");
                        int ECMEmployeeEmployeeCode = reader.GetOrdinal("Employee:EmployeeCode");
                        int ECmEmployeeHR_Case_Description = reader.GetOrdinal("Employee:HR_Case_Description");
                        int ECMEmployeePreferred_Name = reader.GetOrdinal("Employee:Preferred_Name");
                        int ECMEmployeeStatus = reader.GetOrdinal("Employee:Status");
                        int ECMEmployeeTermination_Date = reader.GetOrdinal("Employee:Termination_Date");
                        //int ECMFileName = reader.GetOrdinal("FileName");
                        int ECMFileNetFoldername = reader.GetOrdinal("FileNet:Foldername");
                        int ECMHR_Case_Code = reader.GetOrdinal("HR_Case_Code");
                        int ECMInfoExpertLevel1_Name = reader.GetOrdinal("InfoExpert:Level1_Name");
                        int ECMInfoExpertLevel2_Name = reader.GetOrdinal("InfoExpert:Level2_Name");
                        int ECMInfoExpertLevel3_Description = reader.GetOrdinal("InfoExpert:Level3_Description");
                        int ECMInfoExpertLevel3_Name = reader.GetOrdinal("InfoExpert:Level3_Name");
                        int ECMInfoExpertLevel4_Description = reader.GetOrdinal("InfoExpert:Level4_Description");
                        int ECMInfoExpertLevel4_Name = reader.GetOrdinal("InfoExpert:Level4_Name");
                        int ECMInfoExpertLevel5_Description = reader.GetOrdinal("InfoExpert:Level5_Description");
                        int ECMInfoExpertLevel5_Name = reader.GetOrdinal("InfoExpert:Level5_Name");
                        int ECMInfringementInfringementID = reader.GetOrdinal("Infringement:InfringementID");
                        int ECMNotes = reader.GetOrdinal("Notes");
                        int ECMPositionClose_Date = reader.GetOrdinal("Position:Close_Date");
                        int ECMPositionOpen_Date = reader.GetOrdinal("Position:Open_Date");
                        int ECMPositionPosition_ID = reader.GetOrdinal("Position:Position_ID");
                        int ECMPositionPosition_Title = reader.GetOrdinal("Position:Position_Title");
                        int ECMPositionVacancy_ID = reader.GetOrdinal("Position:Vacancy_ID");
                        int ECMPositionVacancy_Status = reader.GetOrdinal("Position:Vacancy_Status");
                        int ECMProjectAndContractProject_Name = reader.GetOrdinal("ProjectAndContract:[Project_Name");
                        int ECMProjectAndContractContract_or_Activity_Desc = reader.GetOrdinal("ProjectAndContract:Contract_or_Activity_Desc");
                        int ECMProjectAndContractContract_or_Activity_Name = reader.GetOrdinal("ProjectAndContract:Contract_or_Activity_Name");
                        int ECMProjectAndContractContract_or_Activity_No = reader.GetOrdinal("ProjectAndContract:Contract_or_Activity_No");
                        int ECMProjectAndContractEnd_Date = reader.GetOrdinal("ProjectAndContract:End_Date");
                        int ECMProjectAndContractProject_Description = reader.GetOrdinal("ProjectAndContract:Project_Description");
                        int ECMProjectAndContractProject_End_Date = reader.GetOrdinal("ProjectAndContract:Project_End_Date");
                        int ECMProjectAndContractProject_Officer = reader.GetOrdinal("ProjectAndContract:Project_Officer");
                        int ECMProjectAndContractProject_Start_Date = reader.GetOrdinal("ProjectAndContract:Project_Start_Date");
                        int ECMProjectAndContractProjectNo = reader.GetOrdinal("ProjectAndContract:ProjectNo");
                        int ECMProjectAndContractResponsible_Officer = reader.GetOrdinal("ProjectAndContract:Responsible_Officer");
                        int ECMProjectAndContractStart_Date = reader.GetOrdinal("ProjectAndContract:Start_Date");
                        int ECMProjectAndContractStatus = reader.GetOrdinal("ProjectAndContract:Status");
                        int ECMPropertyHouse_No = reader.GetOrdinal("Property:House_No");
                        int ECMPropertyHouse_No_Suffix = reader.GetOrdinal("Property:House_No_Suffix");
                        int ECMPropertyHouse_No_To = reader.GetOrdinal("Property:House_No_To");
                        int ECMPropertyHouse_No_To_Suffix = reader.GetOrdinal("Property:House_No_To_Suffix");
                        int ECMPropertyLocality_Name = reader.GetOrdinal("Property:Locality_Name");
                        int ECMPropertyPostcode = reader.GetOrdinal("Property:Postcode");
                        int ECMPropertyProperty_Name = reader.GetOrdinal("Property:Property_Name");
                        int ECMPropertyProperty_No = reader.GetOrdinal("Property:Property_No");
                        int ECMPropertyStreet_Name = reader.GetOrdinal("Property:Street_Name");
                        int ECMPropertyUnit_No = reader.GetOrdinal("Property:Unit_No");
                        int ECMPropertyUnit_No_Suffix = reader.GetOrdinal("Property:Unit_No_Suffix");
                        //int ECMreference = reader.GetOrdinal("reference");
                        int ECMRelatedDocDocSetID = reader.GetOrdinal("RelatedDoc:DocSetID");
                        int ECMSTDAllRevTitle = reader.GetOrdinal("STD:AllRevTitle");
                        int ECMSTDApplicationNo = reader.GetOrdinal("STD:ApplicationNo");
                        int ECMSTDBusinessCode = reader.GetOrdinal("STD:BusinessCode");
                        int ECMSTDClassName = reader.GetOrdinal("STD:ClassName");
                        int ECMSTDCorrespondant = reader.GetOrdinal("STD:Correspondant");
                        int ECMSTDCustomerRequest = reader.GetOrdinal("STD:CustomerRequest");
                        int ECMSTDDateLastAccessed = reader.GetOrdinal("STD:DateLastAccessed");
                        int ECMSTDDateReceived = reader.GetOrdinal("STD:DateReceived");
                        int ECMSTDDateRegistered = reader.GetOrdinal("STD:DateRegistered");
                        int ECMSTDDeclaredDate = reader.GetOrdinal("STD:DeclaredDate");
                        int ECMSTDDestructionDue = reader.GetOrdinal("STD:DestructionDue");
                        int ECMSTDDocumentDate = reader.GetOrdinal("STD:DocumentDate");
                        int ECMSTDDocumentType = reader.GetOrdinal("STD:DocumentType");
                        int ECMSTDExternalReference = reader.GetOrdinal("STD:ExternalReference");
                        int ECMSTDInfringementNo = reader.GetOrdinal("STD:InfringementNo");
                        int ECMSTDInternalReference = reader.GetOrdinal("STD:InternalReference");
                        int ECMSTDInternalScanRequest = reader.GetOrdinal("STD:InternalScanRequest");
                        int ECMSTDJobNo = reader.GetOrdinal("STD:JobNo");
                        int ECMSTDOtherReferences = reader.GetOrdinal("STD:OtherReferences");
                        int ECMSTDPropertyNo = reader.GetOrdinal("STD:PropertyNo");
                        int ECMSTDSummaryText = reader.GetOrdinal("STD:SummaryText");
                        int ECMStreetsLocality = reader.GetOrdinal("Streets:Locality");
                        int ECMStreetsPostcode = reader.GetOrdinal("Streets:Postcode");
                        int ECMStreetsStreet_Name = reader.GetOrdinal("Streets:Street_Name");
                        int ECMUserGroupsDescription = reader.GetOrdinal("UserGroups:Description");
                        int ECMUserGroupsExtNo = reader.GetOrdinal("UserGroups:ExtNo");
                        int ECMUserGroupsGivenName = reader.GetOrdinal("UserGroups:GivenName");
                        int ECMUserGroupsOrgEmail = reader.GetOrdinal("UserGroups:OrgEmail");
                        int ECMUserGroupsSurname = reader.GetOrdinal("UserGroups:Surname");
                        int ECMVolumeFilename = reader.GetOrdinal("Volume:Filename");
                        int ECMVolumeLastModified = reader.GetOrdinal("Volume:LastModified");
                        int ECMVolumeMedia = reader.GetOrdinal("Volume:Media");
                        int ECMVolumePrimaryCacheName = reader.GetOrdinal("Volume:PrimaryCacheName");
                        int ECMVolumeRenditionTypeName = reader.GetOrdinal("Volume:RenditionTypeName");
                        int ECMVolumeShareDrive = reader.GetOrdinal("Volume:ShareDrive");
                        int ECMVolumeSize = reader.GetOrdinal("Volume:Size");
                        int ECMVolumeStatus = reader.GetOrdinal("Volume:Status");
                        int ECMVolumeStorageLocation = reader.GetOrdinal("Volume:StorageLocation");
                        int ECMVolumeUpdatable = reader.GetOrdinal("Volume:Updatable");
                        //
                        while (reader.Read())
                        {
                            //Console.WriteLine(reader.GetString(8));
                            //Console.WriteLine("ECMVolumeFilename={0}", reader.GetString(ECMVolumeFilename));
                            ECMMigration ecm = new ECMMigration();
                            ecm.DocSetID = reader.GetInt32(ECMSTDDocumentSetID).ToString();
                            ecm.ECMDescription = reader.GetString(ECMSTDDocumentDescription);
                            ecm.ECMBCSFunction_Name = reader.GetString(ECMBCSFunction_Name);
                            ecm.ECMBCSActivity_Name = reader.GetString(ECMBCSActivity_Name);
                            ecm.ECMBCSSubject_Name = reader.GetString(ECMBCSSubject_Name);
                            ecm.ECMSTDVersion = reader.GetInt16(ECMSTDVersion);
                            //AutoCreate
                            try { if (reader.IsDBNull(ECMApplicationRAM_Application_Number) == false) { ecm.ECMApplicationRAM_Application_Number = reader.GetString(ECMApplicationRAM_Application_Number); } } catch { Console.WriteLine("Data convert problem with ECMApplicationRAM_Application_Number"); }
                            try { if (reader.IsDBNull(ECMBarCodeBarCodeString) == false) { ecm.ECMBarCodeBarCodeString = reader.GetString(ECMBarCodeBarCodeString); } } catch { Console.WriteLine("Data convert problem with ECMBarCodeBarCodeString"); }
                            try { if (reader.IsDBNull(ECMBCSRetention_Period) == false) { ecm.ECMBCSRetention_Period = reader.GetString(ECMBCSRetention_Period); } } catch { Console.WriteLine("Data convert problem with ECMBCSRetention_Period"); }
                            try { if (reader.IsDBNull(ECMCaseCaseDescription) == false) { ecm.ECMCaseCaseDescription = reader.GetString(ECMCaseCaseDescription); } } catch { Console.WriteLine("Data convert problem with ECMCaseCaseDescription"); }
                            try { if (reader.IsDBNull(ECMCaseCaseName) == false) { ecm.ECMCaseCaseName = reader.GetString(ECMCaseCaseName); } } catch { Console.WriteLine("Data convert problem with ECMCaseCaseName"); }
                            try { if (reader.IsDBNull(ECMCaseCaseNumber) == false) { ecm.ECMCaseCaseNumber = reader.GetString(ECMCaseCaseNumber); } } catch { Console.WriteLine("Data convert problem with ECMCaseCaseNumber"); }
                            try { if (reader.IsDBNull(ECMCaseCaseOfficer) == false) { ecm.ECMCaseCaseOfficer = reader.GetString(ECMCaseCaseOfficer); } } catch { Console.WriteLine("Data convert problem with ECMCaseCaseOfficer"); }
                            try { if (reader.IsDBNull(ECMCaseCaseStatus) == false) { ecm.ECMCaseCaseStatus = reader.GetString(ECMCaseCaseStatus); } } catch { Console.WriteLine("Data convert problem with ECMCaseCaseStatus"); }
                            try { if (reader.IsDBNull(ECMCaseCaseType) == false) { ecm.ECMCaseCaseType = reader.GetString(ECMCaseCaseType); } } catch { Console.WriteLine("Data convert problem with ECMCaseCaseType"); }
                            try { if (reader.IsDBNull(ECMCaseEndDate) == false) { ecm.ECMCaseEndDate = reader.GetDateTime(ECMCaseEndDate); } } catch { Console.WriteLine("Data convert problem with ECMCaseEndDate"); }
                            try { if (reader.IsDBNull(ECMCaseStartDate) == false) { ecm.ECMCaseStartDate = reader.GetDateTime(ECMCaseStartDate); } } catch { Console.WriteLine("Data convert problem with ECMCaseStartDate"); }
                            //try { if (reader.IsDBNull(ECMCorrespondentDescription) == false) { ecm.ECMCorrespondentDescription = reader.GetString(ECMCorrespondentDescription); } } catch { Console.WriteLine("Data convert problem with ECMCorrespondentDescription"); }
                            try { if (reader.IsDBNull(ECMECMDriveID) == false) { ecm.ECMECMDriveID = reader.GetInt32(ECMECMDriveID); } } catch { Console.WriteLine("Data convert problem with ECMECMDriveID"); }
                            try { if (reader.IsDBNull(ECMEmployeeCommencement_Date) == false) { ecm.ECMEmployeeCommencement_Date = reader.GetDateTime(ECMEmployeeCommencement_Date); } } catch { Console.WriteLine("Data convert problem with ECMEmployeeCommencement_Date"); }
                            try { if (reader.IsDBNull(ECMEmployeeEmployee_Given_Name) == false) { ecm.ECMEmployeeEmployee_Given_Name = reader.GetString(ECMEmployeeEmployee_Given_Name); } } catch { Console.WriteLine("Data convert problem with ECMEmployeeEmployee_Given_Name"); }
                            try { if (reader.IsDBNull(ECMEmployeeEmployee_Surname) == false) { ecm.ECMEmployeeEmployee_Surname = reader.GetString(ECMEmployeeEmployee_Surname); } } catch { Console.WriteLine("Data convert problem with ECMEmployeeEmployee_Surname"); }
                            try { if (reader.IsDBNull(ECMEmployeeEmployeeCode) == false) { ecm.ECMEmployeeEmployeeCode = reader.GetString(ECMEmployeeEmployeeCode); } } catch { Console.WriteLine("Data convert problem with ECMEmployeeEmployeeCode"); }
                            try { if (reader.IsDBNull(ECmEmployeeHR_Case_Description) == false) { ecm.ECmEmployeeHR_Case_Description = reader.GetString(ECmEmployeeHR_Case_Description); } } catch { Console.WriteLine("Data convert problem with ECmEmployeeHR_Case_Description"); }
                            try { if (reader.IsDBNull(ECMEmployeePreferred_Name) == false) { ecm.ECMEmployeePreferred_Name = reader.GetString(ECMEmployeePreferred_Name); } } catch { Console.WriteLine("Data convert problem with ECMEmployeePreferred_Name"); }
                            try { if (reader.IsDBNull(ECMEmployeeStatus) == false) { ecm.ECMEmployeeStatus = reader.GetString(ECMEmployeeStatus); } } catch { Console.WriteLine("Data convert problem with ECMEmployeeStatus"); }
                            try { if (reader.IsDBNull(ECMEmployeeTermination_Date) == false) { ecm.ECMEmployeeTermination_Date = reader.GetDateTime(ECMEmployeeTermination_Date); } } catch { Console.WriteLine("Data convert problem with ECMEmployeeTermination_Date"); }
                            //try { if (reader.IsDBNull(ECMFileName) == false) { ecm.ECMFileName = reader.GetString(ECMFileName); } } catch { Console.WriteLine("Data convert problem with ECMFileName"); }
                            try { if (reader.IsDBNull(ECMFileNetFoldername) == false) { ecm.ECMFileNetFoldername = reader.GetString(ECMFileNetFoldername); } } catch { Console.WriteLine("Data convert problem with ECMFileNetFoldername"); }
                            try { if (reader.IsDBNull(ECMHR_Case_Code) == false) { ecm.ECMHR_Case_Code = reader.GetString(ECMHR_Case_Code); } } catch { Console.WriteLine("Data convert problem with ECMHR_Case_Code"); }
                            try { if (reader.IsDBNull(ECMInfoExpertLevel1_Name) == false) { ecm.ECMInfoExpertLevel1_Name = reader.GetString(ECMInfoExpertLevel1_Name); } } catch { Console.WriteLine("Data convert problem with ECMInfoExpertLevel1_Name"); }
                            try { if (reader.IsDBNull(ECMInfoExpertLevel2_Name) == false) { ecm.ECMInfoExpertLevel2_Name = reader.GetString(ECMInfoExpertLevel2_Name); } } catch { Console.WriteLine("Data convert problem with ECMInfoExpertLevel2_Name"); }
                            try { if (reader.IsDBNull(ECMInfoExpertLevel3_Description) == false) { ecm.ECMInfoExpertLevel3_Description = reader.GetString(ECMInfoExpertLevel3_Description); } } catch { Console.WriteLine("Data convert problem with ECMInfoExpertLevel3_Description"); }
                            try { if (reader.IsDBNull(ECMInfoExpertLevel3_Name) == false) { ecm.ECMInfoExpertLevel3_Name = reader.GetString(ECMInfoExpertLevel3_Name); } } catch { Console.WriteLine("Data convert problem with ECMInfoExpertLevel3_Name"); }
                            try { if (reader.IsDBNull(ECMInfoExpertLevel4_Description) == false) { ecm.ECMInfoExpertLevel4_Description = reader.GetString(ECMInfoExpertLevel4_Description); } } catch { Console.WriteLine("Data convert problem with ECMInfoExpertLevel4_Description"); }
                            try { if (reader.IsDBNull(ECMInfoExpertLevel4_Name) == false) { ecm.ECMInfoExpertLevel4_Name = reader.GetString(ECMInfoExpertLevel4_Name); } } catch { Console.WriteLine("Data convert problem with ECMInfoExpertLevel4_Name"); }
                            try { if (reader.IsDBNull(ECMInfoExpertLevel5_Description) == false) { ecm.ECMInfoExpertLevel5_Description = reader.GetString(ECMInfoExpertLevel5_Description); } } catch { Console.WriteLine("Data convert problem with ECMInfoExpertLevel5_Description"); }
                            try { if (reader.IsDBNull(ECMInfoExpertLevel5_Name) == false) { ecm.ECMInfoExpertLevel5_Name = reader.GetString(ECMInfoExpertLevel5_Name); } } catch { Console.WriteLine("Data convert problem with ECMInfoExpertLevel5_Name"); }
                            try { if (reader.IsDBNull(ECMInfringementInfringementID) == false) { ecm.ECMInfringementInfringementID = reader.GetString(ECMInfringementInfringementID); } } catch { Console.WriteLine("Data convert problem with ECMInfringementInfringementID"); }
                            try { if (reader.IsDBNull(ECMNotes) == false) { ecm.ECMNotes = reader.GetString(ECMNotes); } } catch { Console.WriteLine("Data convert problem with ECMNotes"); }
                            try { if (reader.IsDBNull(ECMPositionClose_Date) == false) { ecm.ECMPositionClose_Date = reader.GetDateTime(ECMPositionClose_Date); } } catch { Console.WriteLine("Data convert problem with ECMPositionClose_Date"); }
                            try { if (reader.IsDBNull(ECMPositionOpen_Date) == false) { ecm.ECMPositionOpen_Date = reader.GetDateTime(ECMPositionOpen_Date); } } catch { Console.WriteLine("Data convert problem with ECMPositionOpen_Date"); }
                            try { if (reader.IsDBNull(ECMPositionPosition_ID) == false) { ecm.ECMPositionPosition_ID = reader.GetString(ECMPositionPosition_ID); } } catch { Console.WriteLine("Data convert problem with ECMPositionPosition_ID"); }
                            try { if (reader.IsDBNull(ECMPositionPosition_Title) == false) { ecm.ECMPositionPosition_Title = reader.GetString(ECMPositionPosition_Title); } } catch { Console.WriteLine("Data convert problem with ECMPositionPosition_Title"); }
                            try { if (reader.IsDBNull(ECMPositionVacancy_ID) == false) { ecm.ECMPositionVacancy_ID = reader.GetString(ECMPositionVacancy_ID); } } catch { Console.WriteLine("Data convert problem with ECMPositionVacancy_ID"); }
                            try { if (reader.IsDBNull(ECMPositionVacancy_Status) == false) { ecm.ECMPositionVacancy_Status = reader.GetString(ECMPositionVacancy_Status); } } catch { Console.WriteLine("Data convert problem with ECMPositionVacancy_Status"); }
                            try { if (reader.IsDBNull(ECMProjectAndContractProject_Name) == false) { ecm.ECMProjectAndContractProject_Name = reader.GetString(ECMProjectAndContractProject_Name); } } catch { Console.WriteLine("Data convert problem with ECMProjectAndContractProject_Name"); }
                            try { if (reader.IsDBNull(ECMProjectAndContractContract_or_Activity_Desc) == false) { ecm.ECMProjectAndContractContract_or_Activity_Desc = reader.GetString(ECMProjectAndContractContract_or_Activity_Desc); } } catch { Console.WriteLine("Data convert problem with ECMProjectAndContractContract_or_Activity_Desc"); }
                            try { if (reader.IsDBNull(ECMProjectAndContractContract_or_Activity_Name) == false) { ecm.ECMProjectAndContractContract_or_Activity_Name = reader.GetString(ECMProjectAndContractContract_or_Activity_Name); } } catch { Console.WriteLine("Data convert problem with ECMProjectAndContractContract_or_Activity_Name"); }
                            try { if (reader.IsDBNull(ECMProjectAndContractContract_or_Activity_No) == false) { ecm.ECMProjectAndContractContract_or_Activity_No = reader.GetString(ECMProjectAndContractContract_or_Activity_No); } } catch { Console.WriteLine("Data convert problem with ECMProjectAndContractContract_or_Activity_No"); }
                            try { if (reader.IsDBNull(ECMProjectAndContractEnd_Date) == false) { ecm.ECMProjectAndContractEnd_Date = reader.GetDateTime(ECMProjectAndContractEnd_Date); } } catch { Console.WriteLine("Data convert problem with ECMProjectAndContractEnd_Date"); }
                            try { if (reader.IsDBNull(ECMProjectAndContractProject_Description) == false) { ecm.ECMProjectAndContractProject_Description = reader.GetString(ECMProjectAndContractProject_Description); } } catch { Console.WriteLine("Data convert problem with ECMProjectAndContractProject_Description"); }
                            try { if (reader.IsDBNull(ECMProjectAndContractProject_End_Date) == false) { ecm.ECMProjectAndContractProject_End_Date = reader.GetDateTime(ECMProjectAndContractProject_End_Date); } } catch { Console.WriteLine("Data convert problem with ECMProjectAndContractProject_End_Date"); }
                            try { if (reader.IsDBNull(ECMProjectAndContractProject_Officer) == false) { ecm.ECMProjectAndContractProject_Officer = reader.GetString(ECMProjectAndContractProject_Officer); } } catch { Console.WriteLine("Data convert problem with ECMProjectAndContractProject_Officer"); }
                            try { if (reader.IsDBNull(ECMProjectAndContractProject_Start_Date) == false) { ecm.ECMProjectAndContractProject_Start_Date = reader.GetDateTime(ECMProjectAndContractProject_Start_Date); } } catch { Console.WriteLine("Data convert problem with ECMProjectAndContractProject_Start_Date"); }
                            try { if (reader.IsDBNull(ECMProjectAndContractProjectNo) == false) { ecm.ECMProjectAndContractProjectNo = reader.GetString(ECMProjectAndContractProjectNo); } } catch { Console.WriteLine("Data convert problem with ECMProjectAndContractProjectNo"); }
                            try { if (reader.IsDBNull(ECMProjectAndContractResponsible_Officer) == false) { ecm.ECMProjectAndContractResponsible_Officer = reader.GetString(ECMProjectAndContractResponsible_Officer); } } catch { Console.WriteLine("Data convert problem with ECMProjectAndContractResponsible_Officer"); }
                            try { if (reader.IsDBNull(ECMProjectAndContractStart_Date) == false) { ecm.ECMProjectAndContractStart_Date = reader.GetDateTime(ECMProjectAndContractStart_Date); } } catch { Console.WriteLine("Data convert problem with ECMProjectAndContractStart_Date"); }
                            try { if (reader.IsDBNull(ECMProjectAndContractStatus) == false) { ecm.ECMProjectAndContractStatus = reader.GetString(ECMProjectAndContractStatus); } } catch { Console.WriteLine("Data convert problem with ECMProjectAndContractStatus"); }
                            try { if (reader.IsDBNull(ECMPropertyHouse_No) == false) { ecm.ECMPropertyHouse_No = reader.GetString(ECMPropertyHouse_No); } } catch { Console.WriteLine("Data convert problem with ECMPropertyHouse_No"); }
                            try { if (reader.IsDBNull(ECMPropertyHouse_No_Suffix) == false) { ecm.ECMPropertyHouse_No_Suffix = reader.GetString(ECMPropertyHouse_No_Suffix); } } catch { Console.WriteLine("Data convert problem with ECMPropertyHouse_No_Suffix"); }
                            try { if (reader.IsDBNull(ECMPropertyHouse_No_To) == false) { ecm.ECMPropertyHouse_No_To = reader.GetString(ECMPropertyHouse_No_To); } } catch { Console.WriteLine("Data convert problem with ECMPropertyHouse_No_To"); }
                            try { if (reader.IsDBNull(ECMPropertyHouse_No_To_Suffix) == false) { ecm.ECMPropertyHouse_No_To_Suffix = reader.GetString(ECMPropertyHouse_No_To_Suffix); } } catch { Console.WriteLine("Data convert problem with ECMPropertyHouse_No_To_Suffix"); }
                            try { if (reader.IsDBNull(ECMPropertyLocality_Name) == false) { ecm.ECMPropertyLocality_Name = reader.GetString(ECMPropertyLocality_Name); } } catch { Console.WriteLine("Data convert problem with ECMPropertyLocality_Name"); }
                            try { if (reader.IsDBNull(ECMPropertyPostcode) == false) { ecm.ECMPropertyPostcode = reader.GetString(ECMPropertyPostcode); } } catch { Console.WriteLine("Data convert problem with ECMPropertyPostcode"); }
                            try { if (reader.IsDBNull(ECMPropertyProperty_Name) == false) { ecm.ECMPropertyProperty_Name = reader.GetString(ECMPropertyProperty_Name); } } catch { Console.WriteLine("Data convert problem with ECMPropertyProperty_Name"); }
                            try { if (reader.IsDBNull(ECMPropertyProperty_No) == false) { ecm.ECMPropertyProperty_No = reader.GetString(ECMPropertyProperty_No); } } catch { Console.WriteLine("Data convert problem with ECMPropertyProperty_No"); }
                            try { if (reader.IsDBNull(ECMPropertyStreet_Name) == false) { ecm.ECMPropertyStreet_Name = reader.GetString(ECMPropertyStreet_Name); } } catch { Console.WriteLine("Data convert problem with ECMPropertyStreet_Name"); }
                            try { if (reader.IsDBNull(ECMPropertyUnit_No) == false) { ecm.ECMPropertyUnit_No = reader.GetString(ECMPropertyUnit_No); } } catch { Console.WriteLine("Data convert problem with ECMPropertyUnit_No"); }
                            try { if (reader.IsDBNull(ECMPropertyUnit_No_Suffix) == false) { ecm.ECMPropertyUnit_No_Suffix = reader.GetString(ECMPropertyUnit_No_Suffix); } } catch { Console.WriteLine("Data convert problem with ECMPropertyUnit_No_Suffix"); }
                            //try { if (reader.IsDBNull(ECMreference) == false) { ecm.ECMreference = reader.GetInt32(ECMreference); } } catch { Console.WriteLine("Data convert problem with ECMreference"); }
                            try { if (reader.IsDBNull(ECMRelatedDocDocSetID) == false) { ecm.ECMRelatedDocDocSetID = reader.GetInt32(ECMRelatedDocDocSetID); } } catch { Console.WriteLine("Data convert problem with ECMRelatedDocDocSetID"); }
                            try { if (reader.IsDBNull(ECMSTDAllRevTitle) == false) { ecm.ECMSTDAllRevTitle = reader.GetString(ECMSTDAllRevTitle); } } catch { Console.WriteLine("Data convert problem with ECMSTDAllRevTitle"); }
                            try { if (reader.IsDBNull(ECMSTDApplicationNo) == false) { ecm.ECMSTDApplicationNo = reader.GetString(ECMSTDApplicationNo); } } catch { Console.WriteLine("Data convert problem with ECMSTDApplicationNo"); }
                            try { if (reader.IsDBNull(ECMSTDBusinessCode) == false) { ecm.ECMSTDBusinessCode = reader.GetString(ECMSTDBusinessCode); } } catch { Console.WriteLine("Data convert problem with ECMSTDBusinessCode"); }
                            try { if (reader.IsDBNull(ECMSTDClassName) == false) { ecm.ECMSTDClassName = reader.GetString(ECMSTDClassName); } } catch { Console.WriteLine("Data convert problem with ECMSTDClassName"); }
                            try { if (reader.IsDBNull(ECMSTDCorrespondant) == false) { ecm.ECMSTDCorrespondant = reader.GetString(ECMSTDCorrespondant); } } catch { Console.WriteLine("Data convert problem with ECMSTDCorrespondant"); }
                            try { if (reader.IsDBNull(ECMSTDCustomerRequest) == false) { ecm.ECMSTDCustomerRequest = reader.GetString(ECMSTDCustomerRequest); } } catch { Console.WriteLine("Data convert problem with ECMSTDCustomerRequest"); }
                            try { if (reader.IsDBNull(ECMSTDDateLastAccessed) == false) { ecm.ECMSTDDateLastAccessed = reader.GetDateTime(ECMSTDDateLastAccessed); } } catch { Console.WriteLine("Data convert problem with ECMSTDDateLastAccessed"); }
                            try { if (reader.IsDBNull(ECMSTDDateReceived) == false) { ecm.ECMSTDDateReceived = reader.GetDateTime(ECMSTDDateReceived); } } catch { Console.WriteLine("Data convert problem with ECMSTDDateReceived"); }
                            try { if (reader.IsDBNull(ECMSTDDateRegistered) == false) { ecm.ECMSTDDateRegistered = reader.GetDateTime(ECMSTDDateRegistered); } } catch { Console.WriteLine("Data convert problem with ECMSTDDateRegistered"); }
                            try { if (reader.IsDBNull(ECMSTDDeclaredDate) == false) { ecm.ECMSTDDeclaredDate = reader.GetDateTime(ECMSTDDeclaredDate); } } catch { Console.WriteLine("Data convert problem with ECMSTDDeclaredDate"); }
                            try { if (reader.IsDBNull(ECMSTDDestructionDue) == false) { ecm.ECMSTDDestructionDue = reader.GetDateTime(ECMSTDDestructionDue); } } catch { Console.WriteLine("Data convert problem with ECMSTDDestructionDue"); }
                            try { if (reader.IsDBNull(ECMSTDDocumentDate) == false) { ecm.ECMSTDDocumentDate = reader.GetDateTime(ECMSTDDocumentDate); } } catch { Console.WriteLine("Data convert problem with ECMSTDDocumentDate"); }
                            try { if (reader.IsDBNull(ECMSTDDocumentType) == false) { ecm.ECMSTDDocumentType = reader.GetString(ECMSTDDocumentType); } } catch { Console.WriteLine("Data convert problem with ECMSTDDocumentType"); }
                            try { if (reader.IsDBNull(ECMSTDExternalReference) == false) { ecm.ECMSTDExternalReference = reader.GetString(ECMSTDExternalReference); } } catch { Console.WriteLine("Data convert problem with ECMSTDExternalReference"); }
                            try { if (reader.IsDBNull(ECMSTDInfringementNo) == false) { ecm.ECMSTDInfringementNo = reader.GetString(ECMSTDInfringementNo); } } catch { Console.WriteLine("Data convert problem with ECMSTDInfringementNo"); }
                            try { if (reader.IsDBNull(ECMSTDInternalReference) == false) { ecm.ECMSTDInternalReference = reader.GetString(ECMSTDInternalReference); } } catch { Console.WriteLine("Data convert problem with ECMSTDInternalReference"); }
                            try { if (reader.IsDBNull(ECMSTDInternalScanRequest) == false) { ecm.ECMSTDInternalScanRequest = reader.GetString(ECMSTDInternalScanRequest); } } catch { Console.WriteLine("Data convert problem with ECMSTDInternalScanRequest"); }
                            try { if (reader.IsDBNull(ECMSTDJobNo) == false) { ecm.ECMSTDJobNo = reader.GetString(ECMSTDJobNo); } } catch { Console.WriteLine("Data convert problem with ECMSTDJobNo"); }
                            try { if (reader.IsDBNull(ECMSTDOtherReferences) == false) { ecm.ECMSTDOtherReferences = reader.GetString(ECMSTDOtherReferences); } } catch { Console.WriteLine("Data convert problem with ECMSTDOtherReferences"); }
                            try { if (reader.IsDBNull(ECMSTDPropertyNo) == false) { ecm.ECMSTDPropertyNo = reader.GetString(ECMSTDPropertyNo); } } catch { Console.WriteLine("Data convert problem with ECMSTDPropertyNo"); }
                            try { if (reader.IsDBNull(ECMSTDSummaryText) == false) { ecm.ECMSTDSummaryText = reader.GetInt32(ECMSTDSummaryText); } } catch { Console.WriteLine("Data convert problem with ECMSTDSummaryText"); }
                            try { if (reader.IsDBNull(ECMStreetsLocality) == false) { ecm.ECMStreetsLocality = reader.GetString(ECMStreetsLocality); } } catch { Console.WriteLine("Data convert problem with ECMStreetsLocality"); }
                            try { if (reader.IsDBNull(ECMStreetsPostcode) == false) { ecm.ECMStreetsPostcode = reader.GetString(ECMStreetsPostcode); } } catch { Console.WriteLine("Data convert problem with ECMStreetsPostcode"); }
                            try { if (reader.IsDBNull(ECMStreetsStreet_Name) == false) { ecm.ECMStreetsStreet_Name = reader.GetString(ECMStreetsStreet_Name); } } catch { Console.WriteLine("Data convert problem with ECMStreetsStreet_Name"); }
                            try { if (reader.IsDBNull(ECMUserGroupsDescription) == false) { ecm.ECMUserGroupsDescription = reader.GetString(ECMUserGroupsDescription); } } catch { Console.WriteLine("Data convert problem with ECMUserGroupsDescription"); }
                            try { if (reader.IsDBNull(ECMUserGroupsExtNo) == false) { ecm.ECMUserGroupsExtNo = reader.GetString(ECMUserGroupsExtNo); } } catch { Console.WriteLine("Data convert problem with ECMUserGroupsExtNo"); }
                            try { if (reader.IsDBNull(ECMUserGroupsGivenName) == false) { ecm.ECMUserGroupsGivenName = reader.GetString(ECMUserGroupsGivenName); } } catch { Console.WriteLine("Data convert problem with ECMUserGroupsGivenName"); }
                            try { if (reader.IsDBNull(ECMUserGroupsOrgEmail) == false) { ecm.ECMUserGroupsOrgEmail = reader.GetString(ECMUserGroupsOrgEmail); } } catch { Console.WriteLine("Data convert problem with ECMUserGroupsOrgEmail"); }
                            try { if (reader.IsDBNull(ECMUserGroupsSurname) == false) { ecm.ECMUserGroupsSurname = reader.GetString(ECMUserGroupsSurname); } } catch { Console.WriteLine("Data convert problem with ECMUserGroupsSurname"); }
                            try { if (reader.IsDBNull(ECMVolumeFilename) == false) { ecm.ECMVolumeFilename = reader.GetString(ECMVolumeFilename); } } catch { Console.WriteLine("Data convert problem with ECMVolumeFilename"); }
                            try { if (reader.IsDBNull(ECMVolumeLastModified) == false) { ecm.ECMVolumeLastModified = reader.GetDateTime(ECMVolumeLastModified); } } catch { Console.WriteLine("Data convert problem with ECMVolumeLastModified"); }
                            try { if (reader.IsDBNull(ECMVolumeMedia) == false) { ecm.ECMVolumeMedia = reader.GetString(ECMVolumeMedia); } } catch { Console.WriteLine("Data convert problem with ECMVolumeMedia"); }
                            try { if (reader.IsDBNull(ECMVolumePrimaryCacheName) == false) { ecm.ECMVolumePrimaryCacheName = reader.GetString(ECMVolumePrimaryCacheName); } } catch { Console.WriteLine("Data convert problem with ECMVolumePrimaryCacheName"); }
                            try { if (reader.IsDBNull(ECMVolumeRenditionTypeName) == false) { ecm.ECMVolumeRenditionTypeName = reader.GetString(ECMVolumeRenditionTypeName); } } catch { Console.WriteLine("Data convert problem with ECMVolumeRenditionTypeName"); }
                            try { if (reader.IsDBNull(ECMVolumeShareDrive) == false) { ecm.ECMVolumeShareDrive = reader.GetString(ECMVolumeShareDrive); } } catch { Console.WriteLine("Data convert problem with ECMVolumeShareDrive"); }
                            try { if (reader.IsDBNull(ECMVolumeSize) == false) { ecm.ECMVolumeSize = reader.GetInt32(ECMVolumeSize); } } catch { Console.WriteLine("Data convert problem with ECMVolumeSize"); }
                            try { if (reader.IsDBNull(ECMVolumeStatus) == false) { ecm.ECMVolumeStatus = reader.GetString(ECMVolumeStatus); } } catch { Console.WriteLine("Data convert problem with ECMVolumeStatus"); }
                            try { if (reader.IsDBNull(ECMVolumeStorageLocation) == false) { ecm.ECMVolumeStorageLocation = reader.GetString(ECMVolumeStorageLocation); } } catch { Console.WriteLine("Data convert problem with ECMVolumeStorageLocation"); }

                            lstecm.Add(ecm);

                        }
                    }

                    //con.Close();
                    //con.Dispose();
                }

                    string strIndexLoc = null;
                    //Console.WriteLine("Enter the network location of the index");
                    //string strInloc = Console.ReadLine();
                    //Console.WriteLine("Copy documents or remove");
                    //BulkLoaderCopyMode windowsmode = BulkLoaderCopyMode.WindowsCopy;
                    //switch (Console.ReadLine())
                    //{
                    //    case "C":
                    //        windowsmode = BulkLoaderCopyMode.WindowsCopy;
                    //        break;
                    //    case "R":
                    //        windowsmode = BulkLoaderCopyMode.WindowsMove;
                    //        break;
                    //    default:
                    //        windowsmode = BulkLoaderCopyMode.WindowsCopy;
                    //        break;
                    //}
                    //Console.ReadLine();
                    //if (!Directory.Exists(strInloc))
                    //{
                    //    strInloc = null;
                    //}

                    string strTotal = lstecm.Count().ToString();
                    int intCount = 0;

                //int intMaxVersion = lstecm.Max(x => x.ECMSTDVersion);
                //for (int i = 1; i < intMaxVersion; i++)
                //{

                //}
                int iDocSource = 0;
                foreach (ECMMigration h in lstecm)
                {
                    intCount = intCount + 1;
                    try
                    {
                        if (m_loader.FindRecord(h.DocSetID.ToString()) == 0)
                        {
                            string strStorageLoc = FindMappedStorage(h.ECMVolumeStorageLocation) + "\\" + h.ECMVolumeFilename;
                            string strStorageLoc2 = FindMappedStorageNas(h.ECMVolumeStorageLocation) + "\\" + h.ECMVolumeFilename;
                            if (File.Exists(strStorageLoc))
                            {
                                //Look for alternative
                                iDocSource = 1;
                            }
                            else if(File.Exists(strStorageLoc2))
                            {
                                iDocSource = 2;
                                //strStorageLoc = FindMappedStorage(h.ECMVolumeStorageLocation) + "\\" + h.ECMVolumeFilename;
                            }
                            else
                            {
                                iDocSource = 0;
                                Console.WriteLine("File does not exist: " + strStorageLoc+" or "+strStorageLoc2);
                                strErrorCol = strErrorCol + "File does not exist: " + strStorageLoc + " or " + strStorageLoc2 + Environment.NewLine;
                            }
                            if (iDocSource > 0)
                            {

                                Record reccont = GetFolderUri(h.ECMBCSFunction_Name + " - " + h.ECMBCSActivity_Name.Replace("-", "~"), h.ECMBCSSubject_Name, db);
                                if (reccont != null)
                                {
                                    string fTitle;
                                    if (h.ECMDescription == null)
                                    {
                                        fTitle = "Record description from ECM Export is Null";
                                        strErrorCol = strErrorCol + "Ecm description to Title issue: Description Null for record no " + h.DocSetID.ToString() + Environment.NewLine;
                                    }
                                    else
                                    {
                                        if (h.ECMDescription.Length > 253)
                                        {
                                            fTitle = h.ECMDescription.Substring(0, 253);
                                            strErrorCol = strErrorCol + "Ecm description to Title issue: Description greater then 254 ch, description truncated for record no " + h.DocSetID.ToString() + Environment.NewLine;
                                        }
                                        else if (h.ECMDescription.Length < 1)
                                        {
                                            fTitle = "Record description from ECM Export is Empty";
                                            strErrorCol = strErrorCol + "Ecm description to Title issue: Description blank for record no " + h.DocSetID.ToString() + Environment.NewLine;
                                        }
                                        else
                                        {
                                            fTitle = h.ECMDescription;
                                        }
                                    }
                                    recordFields[0].SetValue(fTitle); //Title
                                    recordFields[1].SetValue((TrimDateTime)h.ECMSTDDocumentDate);
                                    //recordFields[1].SetValue((TrimDateTime)DateTime.Now);
                                    recordFields[2].SetValue("Migrated from EMS T1 using " + m_origin.Name);
                                    recordFields[3].SetValue(reccont.Uri); //Container
                                    recordFields[4].SetValue(h.DocSetID); //record Number
                                    try
                                    {
                                        recordFields[110].SetValue(h.ECMBarCodeBarCodeString);
                                    }
                                    catch (Exception exp)
                                    {
                                        strErrorCol = strErrorCol + "ECMBarCodeBarCodeString error " + exp.Message.ToString() + Environment.NewLine;
                                    }
                                    //recordFields[111].SetValue((DateTime)h.ECMSTDDateLastAccessed);
                                    //recordFields[111].SetValue((TrimDateTime)h.ECMSTDDateLastAccessed);

                                    if (h.ECMSTDDocumentDate != null) { recordFields[1].SetValue((TrimDateTime)h.ECMSTDDocumentDate); } else { recordFields[5].ClearValue(); }//ECMApplicationRAM_Application_Number
                                                                                                                                                                              //Auto generated
                                    if (h.ECMApplicationRAM_Application_Number != null) { recordFields[5].SetValue(h.ECMApplicationRAM_Application_Number); } else { recordFields[5].ClearValue(); }//ECMApplicationRAM_Application_Number
                                    if (h.ECMBarCodeBarCodeString != null) { recordFields[6].SetValue(h.ECMBarCodeBarCodeString); } else { recordFields[6].ClearValue(); }//ECMBarCodeBarCodeString
                                    if (h.ECMBCSRetention_Period != null) { recordFields[7].SetValue(h.ECMBCSRetention_Period); } else { recordFields[7].ClearValue(); }//ECMBCSRetention_Period
                                    if (h.ECMCaseCaseDescription != null) { recordFields[8].SetValue(h.ECMCaseCaseDescription); } else { recordFields[8].ClearValue(); }//ECMCaseCaseDescription
                                    if (h.ECMCaseCaseName != null) { recordFields[9].SetValue(h.ECMCaseCaseName); } else { recordFields[9].ClearValue(); }//ECMCaseCaseName
                                    if (h.ECMCaseCaseNumber != null) { recordFields[10].SetValue(h.ECMCaseCaseNumber); } else { recordFields[10].ClearValue(); }//ECMCaseCaseNumber
                                    if (h.ECMCaseCaseOfficer != null) { recordFields[11].SetValue(h.ECMCaseCaseOfficer); } else { recordFields[11].ClearValue(); }//ECMCaseCaseOfficer
                                    if (h.ECMCaseCaseStatus != null) { recordFields[12].SetValue(h.ECMCaseCaseStatus); } else { recordFields[12].ClearValue(); }//ECMCaseCaseStatus
                                    if (h.ECMCaseCaseType != null) { recordFields[13].SetValue(h.ECMCaseCaseType); } else { recordFields[13].ClearValue(); }//ECMCaseCaseType
                                    if (h.ECMCaseEndDate != null) { recordFields[14].SetValue(h.ECMCaseEndDate); } else { recordFields[14].ClearValue(); }//ECMCaseEndDate
                                    if (h.ECMCaseStartDate != null) { recordFields[15].SetValue(h.ECMCaseStartDate); } else { recordFields[15].ClearValue(); }//ECMCaseStartDate
                                    if (h.ECMCorrespondentDescription != null) { recordFields[16].SetValue(h.ECMCorrespondentDescription); } else { recordFields[16].ClearValue(); }//ECMCorrespondentDescription
                                                                                                                                                                                    //if (h.ECMECMDriveID != null) { recordFields[17].SetValue(h.ECMECMDriveID); } else { recordFields[17].ClearValue(); }//ECMECMDriveID
                                    if (h.ECMEmployeeCommencement_Date != null) { recordFields[18].SetValue(h.ECMEmployeeCommencement_Date); } else { recordFields[18].ClearValue(); }//ECMEmployeeCommencement_Date
                                    if (h.ECMEmployeeEmployee_Given_Name != null) { recordFields[19].SetValue(h.ECMEmployeeEmployee_Given_Name); } else { recordFields[19].ClearValue(); }//ECMEmployeeEmployee_Given_Name
                                    if (h.ECMEmployeeEmployee_Surname != null) { recordFields[20].SetValue(h.ECMEmployeeEmployee_Surname); } else { recordFields[20].ClearValue(); }//ECMEmployeeEmployee_Surname
                                    if (h.ECMEmployeeEmployeeCode != null) { recordFields[21].SetValue(h.ECMEmployeeEmployeeCode); } else { recordFields[21].ClearValue(); }//ECMEmployeeEmployeeCode
                                    if (h.ECmEmployeeHR_Case_Description != null) { recordFields[22].SetValue(h.ECmEmployeeHR_Case_Description); } else { recordFields[22].ClearValue(); }//ECmEmployeeHR_Case_Description
                                    if (h.ECMEmployeePreferred_Name != null) { recordFields[23].SetValue(h.ECMEmployeePreferred_Name); } else { recordFields[23].ClearValue(); }//ECMEmployeePreferred_Name
                                    if (h.ECMEmployeeStatus != null) { recordFields[24].SetValue(h.ECMEmployeeStatus); } else { recordFields[24].ClearValue(); }//ECMEmployeeStatus
                                    if (h.ECMEmployeeTermination_Date != null) { recordFields[25].SetValue(h.ECMEmployeeTermination_Date); } else { recordFields[25].ClearValue(); }//ECMEmployeeTermination_Date
                                    if (h.ECMFileName != null) { recordFields[26].SetValue(h.ECMFileName); } else { recordFields[26].ClearValue(); }//ECMFileName
                                    if (h.ECMFileNetFoldername != null) { recordFields[27].SetValue(h.ECMFileNetFoldername); } else { recordFields[27].ClearValue(); }//ECMFileNetFoldername
                                    if (h.ECMHR_Case_Code != null) { recordFields[28].SetValue(h.ECMHR_Case_Code); } else { recordFields[28].ClearValue(); }//ECMHR_Case_Code
                                    if (h.ECMInfoExpertLevel1_Name != null) { recordFields[29].SetValue(h.ECMInfoExpertLevel1_Name); } else { recordFields[29].ClearValue(); }//ECMInfoExpertLevel1_Name
                                    if (h.ECMInfoExpertLevel2_Name != null) { recordFields[30].SetValue(h.ECMInfoExpertLevel2_Name); } else { recordFields[30].ClearValue(); }//ECMInfoExpertLevel2_Name
                                    if (h.ECMInfoExpertLevel3_Description != null) { recordFields[31].SetValue(h.ECMInfoExpertLevel3_Description); } else { recordFields[31].ClearValue(); }//ECMInfoExpertLevel3_Description
                                    if (h.ECMInfoExpertLevel3_Name != null) { recordFields[32].SetValue(h.ECMInfoExpertLevel3_Name); } else { recordFields[32].ClearValue(); }//ECMInfoExpertLevel3_Name
                                    if (h.ECMInfoExpertLevel4_Description != null) { recordFields[33].SetValue(h.ECMInfoExpertLevel4_Description); } else { recordFields[33].ClearValue(); }//ECMInfoExpertLevel4_Description
                                    if (h.ECMInfoExpertLevel4_Name != null) { recordFields[34].SetValue(h.ECMInfoExpertLevel4_Name); } else { recordFields[34].ClearValue(); }//ECMInfoExpertLevel4_Name
                                    if (h.ECMInfoExpertLevel5_Description != null) { recordFields[35].SetValue(h.ECMInfoExpertLevel5_Description); } else { recordFields[35].ClearValue(); }//ECMInfoExpertLevel5_Description
                                    if (h.ECMInfoExpertLevel5_Name != null) { recordFields[36].SetValue(h.ECMInfoExpertLevel5_Name); } else { recordFields[36].ClearValue(); }//ECMInfoExpertLevel5_Name
                                    if (h.ECMInfringementInfringementID != null) { recordFields[37].SetValue(h.ECMInfringementInfringementID); } else { recordFields[37].ClearValue(); }//ECMInfringementInfringementID
                                    if (h.ECMNotes != null) { recordFields[38].SetValue(h.ECMNotes); } else { recordFields[38].ClearValue(); }//ECMNotes
                                    if (h.ECMPositionClose_Date != null) { recordFields[39].SetValue(h.ECMPositionClose_Date); } else { recordFields[39].ClearValue(); }//ECMPositionClose_Date
                                    if (h.ECMPositionOpen_Date != null) { recordFields[40].SetValue(h.ECMPositionOpen_Date); } else { recordFields[40].ClearValue(); }//ECMPositionOpen_Date
                                    if (h.ECMPositionPosition_ID != null) { recordFields[41].SetValue(h.ECMPositionPosition_ID); } else { recordFields[41].ClearValue(); }//ECMPositionPosition_ID
                                    if (h.ECMPositionPosition_Title != null) { recordFields[42].SetValue(h.ECMPositionPosition_Title); } else { recordFields[42].ClearValue(); }//ECMPositionPosition_Title
                                    if (h.ECMPositionVacancy_ID != null) { recordFields[43].SetValue(h.ECMPositionVacancy_ID); } else { recordFields[43].ClearValue(); }//ECMPositionVacancy_ID
                                    if (h.ECMPositionVacancy_Status != null) { recordFields[44].SetValue(h.ECMPositionVacancy_Status); } else { recordFields[44].ClearValue(); }//ECMPositionVacancy_Status
                                    if (h.ECMProjectAndContractProject_Name != null) { recordFields[45].SetValue(h.ECMProjectAndContractProject_Name); } else { recordFields[45].ClearValue(); }//ECMProjectAndContractProject_Name
                                    if (h.ECMProjectAndContractContract_or_Activity_Desc != null) { recordFields[46].SetValue(h.ECMProjectAndContractContract_or_Activity_Desc); } else { recordFields[46].ClearValue(); }//ECMProjectAndContractContract_or_Activity_Desc
                                    if (h.ECMProjectAndContractContract_or_Activity_Name != null) { recordFields[47].SetValue(h.ECMProjectAndContractContract_or_Activity_Name); } else { recordFields[47].ClearValue(); }//ECMProjectAndContractContract_or_Activity_Name
                                    if (h.ECMProjectAndContractContract_or_Activity_No != null) { recordFields[48].SetValue(h.ECMProjectAndContractContract_or_Activity_No); } else { recordFields[48].ClearValue(); }//ECMProjectAndContractContract_or_Activity_No
                                    if (h.ECMProjectAndContractEnd_Date != null) { recordFields[49].SetValue(h.ECMProjectAndContractEnd_Date); } else { recordFields[49].ClearValue(); }//ECMProjectAndContractEnd_Date
                                    if (h.ECMProjectAndContractProject_Description != null) { recordFields[50].SetValue(h.ECMProjectAndContractProject_Description); } else { recordFields[50].ClearValue(); }//ECMProjectAndContractProject_Description
                                    if (h.ECMProjectAndContractProject_End_Date != null) { recordFields[51].SetValue(h.ECMProjectAndContractProject_End_Date); } else { recordFields[51].ClearValue(); }//ECMProjectAndContractProject_End_Date
                                    if (h.ECMProjectAndContractProject_Officer != null) { recordFields[52].SetValue(h.ECMProjectAndContractProject_Officer); } else { recordFields[52].ClearValue(); }//ECMProjectAndContractProject_Officer
                                    if (h.ECMProjectAndContractProject_Start_Date != null) { recordFields[53].SetValue(h.ECMProjectAndContractProject_Start_Date); } else { recordFields[53].ClearValue(); }//ECMProjectAndContractProject_Start_Date
                                    if (h.ECMProjectAndContractProjectNo != null) { recordFields[54].SetValue(h.ECMProjectAndContractProjectNo); } else { recordFields[54].ClearValue(); }//ECMProjectAndContractProjectNo
                                    if (h.ECMProjectAndContractResponsible_Officer != null) { recordFields[55].SetValue(h.ECMProjectAndContractResponsible_Officer); } else { recordFields[55].ClearValue(); }//ECMProjectAndContractResponsible_Officer
                                    if (h.ECMProjectAndContractStart_Date != null) { recordFields[56].SetValue(h.ECMProjectAndContractStart_Date); } else { recordFields[56].ClearValue(); }//ECMProjectAndContractStart_Date
                                    if (h.ECMProjectAndContractStatus != null) { recordFields[57].SetValue(h.ECMProjectAndContractStatus); } else { recordFields[57].ClearValue(); }//ECMProjectAndContractStatus
                                    if (h.ECMPropertyHouse_No != null) { recordFields[58].SetValue(h.ECMPropertyHouse_No); } else { recordFields[58].ClearValue(); }//ECMPropertyHouse_No
                                    if (h.ECMPropertyHouse_No_Suffix != null) { recordFields[59].SetValue(h.ECMPropertyHouse_No_Suffix); } else { recordFields[59].ClearValue(); }//ECMPropertyHouse_No_Suffix
                                    if (h.ECMPropertyHouse_No_To != null) { recordFields[60].SetValue(h.ECMPropertyHouse_No_To); } else { recordFields[60].ClearValue(); }//ECMPropertyHouse_No_To
                                    if (h.ECMPropertyHouse_No_To_Suffix != null) { recordFields[61].SetValue(h.ECMPropertyHouse_No_To_Suffix); } else { recordFields[61].ClearValue(); }//ECMPropertyHouse_No_To_Suffix
                                    if (h.ECMPropertyLocality_Name != null) { recordFields[62].SetValue(h.ECMPropertyLocality_Name); } else { recordFields[62].ClearValue(); }//ECMPropertyLocality_Name
                                    if (h.ECMPropertyPostcode != null) { recordFields[63].SetValue(h.ECMPropertyPostcode); } else { recordFields[63].ClearValue(); }//ECMPropertyPostcode
                                    if (h.ECMPropertyProperty_Name != null) { recordFields[64].SetValue(h.ECMPropertyProperty_Name); } else { recordFields[64].ClearValue(); }//ECMPropertyProperty_Name
                                    if (h.ECMPropertyProperty_No != null) { recordFields[65].SetValue(h.ECMPropertyProperty_No); } else { recordFields[65].ClearValue(); }//ECMPropertyProperty_No
                                    if (h.ECMPropertyStreet_Name != null) { recordFields[66].SetValue(h.ECMPropertyStreet_Name); } else { recordFields[66].ClearValue(); }//ECMPropertyStreet_Name
                                    if (h.ECMPropertyUnit_No != null) { recordFields[67].SetValue(h.ECMPropertyUnit_No); } else { recordFields[67].ClearValue(); }//ECMPropertyUnit_No
                                    if (h.ECMPropertyUnit_No_Suffix != null) { recordFields[68].SetValue(h.ECMPropertyUnit_No_Suffix); } else { recordFields[68].ClearValue(); }//ECMPropertyUnit_No_Suffix
                                                                                                                                                                                //if (h.ECMreference != null) { recordFields[69].SetValue(h.ECMreference); } else { recordFields[69].ClearValue(); }//ECMreference
                                                                                                                                                                                //if (h.ECMRelatedDocDocSetID != null) { recordFields[70].SetValue(h.ECMRelatedDocDocSetID); } else { recordFields[70].ClearValue(); }//ECMRelatedDocDocSetID
                                    if (h.ECMSTDAllRevTitle != null) { recordFields[71].SetValue(h.ECMSTDAllRevTitle); } else { recordFields[71].ClearValue(); }//ECMSTDAllRevTitle
                                    if (h.ECMSTDApplicationNo != null) { recordFields[72].SetValue(h.ECMSTDApplicationNo); } else { recordFields[72].ClearValue(); }//ECMSTDApplicationNo
                                    if (h.ECMSTDBusinessCode != null) { recordFields[73].SetValue(h.ECMSTDBusinessCode); } else { recordFields[73].ClearValue(); }//ECMSTDBusinessCode
                                    if (h.ECMSTDClassName != null) { recordFields[74].SetValue(h.ECMSTDClassName); } else { recordFields[74].ClearValue(); }//ECMSTDClassName
                                    if (h.ECMSTDCorrespondant != null) { recordFields[75].SetValue(h.ECMSTDCorrespondant); } else { recordFields[75].ClearValue(); }//ECMSTDCorrespondant
                                    if (h.ECMSTDCustomerRequest != null) { recordFields[76].SetValue(h.ECMSTDCustomerRequest); } else { recordFields[76].ClearValue(); }//ECMSTDCustomerRequest
                                    if (h.ECMSTDDateLastAccessed != null) { recordFields[77].SetValue(h.ECMSTDDateLastAccessed); } else { recordFields[77].ClearValue(); }//ECMSTDDateLastAccessed
                                    if (h.ECMSTDDateReceived != null) { recordFields[78].SetValue(h.ECMSTDDateReceived); } else { recordFields[78].ClearValue(); }//ECMSTDDateReceived
                                    if (h.ECMSTDDateRegistered != null) { recordFields[79].SetValue(h.ECMSTDDateRegistered); } else { recordFields[79].ClearValue(); }//ECMSTDDateRegistered
                                    if (h.ECMSTDDeclaredDate != null) { recordFields[80].SetValue(h.ECMSTDDeclaredDate); } else { recordFields[80].ClearValue(); }//ECMSTDDeclaredDate
                                    if (h.ECMSTDDestructionDue != null) { recordFields[81].SetValue(h.ECMSTDDestructionDue); } else { recordFields[81].ClearValue(); }//ECMSTDDestructionDue
                                    if (h.ECMSTDDocumentDate != null) { recordFields[82].SetValue(h.ECMSTDDocumentDate); } else { recordFields[82].ClearValue(); }//ECMSTDDocumentDate
                                    if (h.ECMSTDDocumentType != null) { recordFields[83].SetValue(h.ECMSTDDocumentType); } else { recordFields[83].ClearValue(); }//ECMSTDDocumentType
                                    if (h.ECMSTDExternalReference != null) { recordFields[84].SetValue(h.ECMSTDExternalReference); } else { recordFields[84].ClearValue(); }//ECMSTDExternalReference
                                    if (h.ECMSTDInfringementNo != null) { recordFields[85].SetValue(h.ECMSTDInfringementNo); } else { recordFields[85].ClearValue(); }//ECMSTDInfringementNo
                                    if (h.ECMSTDInternalReference != null) { recordFields[86].SetValue(h.ECMSTDInternalReference); } else { recordFields[86].ClearValue(); }//ECMSTDInternalReference
                                    if (h.ECMSTDInternalScanRequest != null) { recordFields[87].SetValue(h.ECMSTDInternalScanRequest); } else { recordFields[87].ClearValue(); }//ECMSTDInternalScanRequest
                                    if (h.ECMSTDJobNo != null) { recordFields[88].SetValue(h.ECMSTDJobNo); } else { recordFields[88].ClearValue(); }//ECMSTDJobNo
                                    if (h.ECMSTDOtherReferences != null) { recordFields[89].SetValue(h.ECMSTDOtherReferences); } else { recordFields[89].ClearValue(); }//ECMSTDOtherReferences
                                    if (h.ECMSTDPropertyNo != null) { recordFields[90].SetValue(h.ECMSTDPropertyNo); } else { recordFields[90].ClearValue(); }//ECMSTDPropertyNo
                                    if (h.ECMSTDSummaryText != 0) { recordFields[91].SetValue(h.ECMSTDSummaryText); } else { recordFields[91].ClearValue(); }//ECMSTDSummaryText
                                    if (h.ECMStreetsLocality != null) { recordFields[92].SetValue(h.ECMStreetsLocality); } else { recordFields[92].ClearValue(); }//ECMStreetsLocality
                                    if (h.ECMStreetsPostcode != null) { recordFields[93].SetValue(h.ECMStreetsPostcode); } else { recordFields[93].ClearValue(); }//ECMStreetsPostcode
                                    if (h.ECMStreetsStreet_Name != null) { recordFields[94].SetValue(h.ECMStreetsStreet_Name); } else { recordFields[94].ClearValue(); }//ECMStreetsStreet_Name
                                    if (h.ECMUserGroupsDescription != null) { recordFields[95].SetValue(h.ECMUserGroupsDescription); } else { recordFields[95].ClearValue(); }//ECMUserGroupsDescription
                                    if (h.ECMUserGroupsExtNo != null) { recordFields[96].SetValue(h.ECMUserGroupsExtNo); } else { recordFields[96].ClearValue(); }//ECMUserGroupsExtNo
                                    if (h.ECMUserGroupsGivenName != null) { recordFields[97].SetValue(h.ECMUserGroupsGivenName); } else { recordFields[97].ClearValue(); }//ECMUserGroupsGivenName
                                    if (h.ECMUserGroupsOrgEmail != null) { recordFields[98].SetValue(h.ECMUserGroupsOrgEmail); } else { recordFields[98].ClearValue(); }//ECMUserGroupsOrgEmail
                                    if (h.ECMUserGroupsSurname != null) { recordFields[99].SetValue(h.ECMUserGroupsSurname); } else { recordFields[99].ClearValue(); }//ECMUserGroupsSurname
                                    if (h.ECMVolumeFilename != null) { recordFields[100].SetValue(h.ECMVolumeFilename); } else { recordFields[100].ClearValue(); }//ECMVolumeFilename
                                    if (h.ECMVolumeLastModified != null) { recordFields[101].SetValue(h.ECMVolumeLastModified); } else { recordFields[101].ClearValue(); }//ECMVolumeLastModified
                                    if (h.ECMVolumeMedia != null) { recordFields[102].SetValue(h.ECMVolumeMedia); } else { recordFields[102].ClearValue(); }//ECMVolumeMedia
                                    if (h.ECMVolumePrimaryCacheName != null) { recordFields[103].SetValue(h.ECMVolumePrimaryCacheName); } else { recordFields[103].ClearValue(); }//ECMVolumePrimaryCacheName
                                    if (h.ECMVolumeRenditionTypeName != null) { recordFields[104].SetValue(h.ECMVolumeRenditionTypeName); } else { recordFields[104].ClearValue(); }//ECMVolumeRenditionTypeName
                                    if (h.ECMVolumeShareDrive != null) { recordFields[105].SetValue(h.ECMVolumeShareDrive); } else { recordFields[105].ClearValue(); }//ECMVolumeShareDrive
                                                                                                                                                                      //if (h.ECMVolumeSize != null) { recordFields[106].SetValue(h.ECMVolumeSize); } else { recordFields[106].ClearValue(); }//ECMVolumeSize
                                    if (h.ECMVolumeStatus != null) { recordFields[107].SetValue(h.ECMVolumeStatus); } else { recordFields[107].ClearValue(); }//ECMVolumeStatus
                                    if (h.ECMVolumeStorageLocation != null) { recordFields[108].SetValue(h.ECMVolumeStorageLocation); } else { recordFields[108].ClearValue(); }//ECMVolumeStorageLocation
                                                                                                                                                                                //if (h.ECMVolumeUpdatable != null) { recordFields[109].SetValue(h.ECMVolumeUpdatable); } else { recordFields[109].ClearValue(); }//ECMVolumeUpdatable

                                    Record importRec = m_loader.NewRecord();
                                    importRec.DateReceived = h.ECMSTDDateReceived;
                                    //SecurityLevel sl = new SecurityLevel(db, 2);
                                    //importRec.SecurityProfile.SecurityLevel = sl;

                                    var imax = lstecm.Where(x => x.DocSetID == h.DocSetID).Max(x => x.ECMSTDVersion);
                                    //if (imax == 1)
                                    //{
                                    //    importRec.SetAsFinal(false);
                                    //    importRec.DateFinalized = (TrimDateTime)h.ECMSTDDateLastAccessed;
                                    //}


                                    InputDocument doc = new InputDocument();
                                    
                                    if (iDocSource == 1)
                                    {
                                        doc.SetAsFile(strStorageLoc);
                                        m_loader.SetDocument(importRec, doc, BulkLoaderCopyMode.WindowsCopy);
                                    }
                                    else if (iDocSource == 2)
                                    {
                                        doc.SetAsFile(strStorageLoc2);
                                        m_loader.SetDocument(importRec, doc, BulkLoaderCopyMode.WindowsCopy);
                                    }
                                    //}

                                    m_loader.SetProperties(importRec, recordFields);
                                    m_loader.SubmitRecord(importRec);

                                    if (m_loader.Error.Bad == true)
                                    {
                                        Console.WriteLine("Error -  " + m_loader.Error.Message + " " + m_loader.Error.Source);
                                        //strErrorCol = strErrorCol + "Loader Error: " + h.DocSetID.ToString() + ", " + " ECMDescription: " + h.ECMDescription + " Bcs: " + h.Bcs + " Folder" + h.Folder + " reccont.Uri:" + reccont.Uri.ToString() + " - " + m_loader.Error.Message + Environment.NewLine;
                                    }
                                    else
                                    {
                                        Console.WriteLine("Imported ECM T1 record " + h.DocSetID.ToString() + " Row " + intCount.ToString() + " of " + strTotal);

                                    }
                                }
                                else
                                {
                                    Console.WriteLine("Could no find folder: " + h.DocSetID.ToString());
                                    strErrorCol = strErrorCol + "Cant find folder to set: " + h.DocSetID.ToString() + " - " + m_loader.Error.Message + Environment.NewLine;
                                }
                            }
                        }
                        else
                        {
                            Console.WriteLine("Record already Exists " + h.DocSetID.ToString() + " Row " + intCount.ToString() + " of " + strTotal);
                            strErrorCol = strErrorCol + "Record already Exists " + h.DocSetID.ToString() + " Row " + intCount.ToString() + " of " + strTotal + Environment.NewLine;

                        }
                    }
                    catch (Exception exp)
                    {
                        Loggitt("ReadLine Error: " + exp.Message.ToString(), " DocSetID: " + h.DocSetID + ", ECMDescription: " + h.ECMDescription + ", GetString(2): " + h.ECMSTDDocumentDate.ToString() + ", FileLocation: " + h.ECMVolumeFilename + ", STDDateLastAccessed: " + h.ECMSTDDateLastAccessed.ToString() + ", STDDateRegistered: " + h.ECMSTDDateRegistered.ToString() + ", Bcs: " + h.ECMBCSActivity_Name + " - " + h.ECMBCSFunction_Name + ", Folder:" + h.ECMBCSSubject_Name);
                    }
                }

                stopwatch.Stop();
                    //Console.WriteLine("Process import batch? Enter to continue.");
                    //Console.ReadLine();
                    
                    m_loader.ProcessAccumulatedData();
                
                    Int64 runHistoryUri = m_loader.RunHistoryUri;


                    Console.WriteLine("Processing complete ...");
                    m_loader.EndRun();

                    TimeSpan ts = stopwatch.Elapsed;

                    string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
                    Console.WriteLine("Process Time " + elapsedTime);
                    var sdsd = m_loader.ErrorMessage;
                    // just for interest, lets look at the origin history object and output what it did
                    OriginHistory hist = new OriginHistory(db, runHistoryUri);
                
                    Console.WriteLine("Number of records created ..... " + System.Convert.ToString(hist.RecordsCreated));
                    Loggitt("Bulk loading run:" + Environment.NewLine + "Number of records created: " + hist.RecordsCreated.ToString() + Environment.NewLine + "Time to run: " + elapsedTime + Environment.NewLine + "Loader errors: " + sdsd + Environment.NewLine + "Records in error: : " + hist.RecordsInError.ToString() + Environment.NewLine + Environment.NewLine + strErrorCol, "BulkLoader Log");

            }
            catch (Exception exp)
            {
                Loggitt("Main Error: " + exp.Message.ToString(), "Error");
            }
            return true;
        }
コード例 #36
0
        private static void processtoEddie(List<ECMMigration> lstecm)
        {
            Console.WriteLine("Moved into RM processing");
            string strTotal = lstecm.Count.ToString();
            int iCount = 0;
            TrimApplication.Initialize();
            //Parallel.ForEach(lstecm, new ParallelOptions { MaxDegreeOfParallelism = 6 }, (ecm) =>

            DateTime dt1 = DateTime.Now;

            using (Database db = new Database())
            {
                FieldDefinition fd_ECMApplicationRAM_Application_Number = new FieldDefinition(db, "Application Number List");
                FieldDefinition fd_ECMBarCodeBarCodeString = new FieldDefinition(db, "ECM BarCode:BarCodeString");
                FieldDefinition fd_ECMBCSRetention_Period = new FieldDefinition(db, "ECM BCS:Retention_Period");
                FieldDefinition fd_ECMCaseCaseDescription = new FieldDefinition(db, "ECM Case:CaseDescription");
                FieldDefinition fd_ECMCaseCaseName = new FieldDefinition(db, "ECM Case:CaseName");
                FieldDefinition fd_ECMCaseCaseNumber = new FieldDefinition(db, "ECM Case:CaseNumber");
                FieldDefinition fd_ECMCaseCaseOfficer = new FieldDefinition(db, "ECM Case:CaseOfficer");
                FieldDefinition fd_ECMCaseCaseStatus = new FieldDefinition(db, "ECM Case:CaseStatus");
                FieldDefinition fd_ECMCaseCaseType = new FieldDefinition(db, "ECM Case:CaseType");
                FieldDefinition fd_ECMCaseEndDate = new FieldDefinition(db, "ECM Case:EndDate");
                FieldDefinition fd_ECMCaseStartDate = new FieldDefinition(db, "ECM Case:StartDate");
                //FieldDefinition fd_ECMCorrespondentDescription = new FieldDefinition(db, "ECM Correspondent:Description");
                FieldDefinition fd_ECMECMDriveID = new FieldDefinition(db, "ECM ECMDriveID");
                FieldDefinition fd_ECMEmployeeCommencement_Date = new FieldDefinition(db, "ECM Employee:Commencement_Date");
                FieldDefinition fd_ECMEmployeeEmployee_Given_Name = new FieldDefinition(db, "ECM Employee:Employee_Given_Name");
                FieldDefinition fd_ECMEmployeeEmployee_Surname = new FieldDefinition(db, "ECM Employee:Employee_Surname");
                FieldDefinition fd_ECMEmployeeEmployeeCode = new FieldDefinition(db, "ECM Employee:EmployeeCode");
                FieldDefinition fd_ECmEmployeeHR_Case_Description = new FieldDefinition(db, "ECm Employee:HR_Case_Description");
                FieldDefinition fd_ECMEmployeePreferred_Name = new FieldDefinition(db, "ECM Employee:Preferred_Name");
                FieldDefinition fd_ECMEmployeeStatus = new FieldDefinition(db, "ECM Employee:Status");
                FieldDefinition fd_ECMEmployeeTermination_Date = new FieldDefinition(db, "ECM Employee:Termination_Date");
                FieldDefinition fd_ECMFileName = new FieldDefinition(db, "ECM FileName");
                FieldDefinition fd_ECMFileNetFoldername = new FieldDefinition(db, "ECM FileNet:Foldername");
                FieldDefinition fd_ECMHR_Case_Code = new FieldDefinition(db, "ECM HR_Case_Code");
                FieldDefinition fd_ECMInfoExpertLevel1_Name = new FieldDefinition(db, "ECM InfoExpert:Level1_Name");
                FieldDefinition fd_ECMInfoExpertLevel2_Name = new FieldDefinition(db, "ECM InfoExpert:Level2_Name");
                FieldDefinition fd_ECMInfoExpertLevel3_Description = new FieldDefinition(db, "ECM InfoExpert:Level3_Description");
                FieldDefinition fd_ECMInfoExpertLevel3_Name = new FieldDefinition(db, "ECM InfoExpert:Level3_Name");
                FieldDefinition fd_ECMInfoExpertLevel4_Description = new FieldDefinition(db, "ECM InfoExpert:Level4_Description");
                FieldDefinition fd_ECMInfoExpertLevel4_Name = new FieldDefinition(db, "ECM InfoExpert:Level4_Name");
                FieldDefinition fd_ECMInfoExpertLevel5_Description = new FieldDefinition(db, "ECM InfoExpert:Level5_Description");
                FieldDefinition fd_ECMInfoExpertLevel5_Name = new FieldDefinition(db, "ECM InfoExpert:Level5_Name");
                FieldDefinition fd_ECMInfringementInfringementID = new FieldDefinition(db, "ECM Infringement:InfringementID");
                FieldDefinition fd_ECMNotes = new FieldDefinition(db, "ECM Notes");
                FieldDefinition fd_ECMPositionClose_Date = new FieldDefinition(db, "ECM Position:Close_Date");
                FieldDefinition fd_ECMPositionOpen_Date = new FieldDefinition(db, "ECM Position:Open_Date");
                FieldDefinition fd_ECMPositionPosition_ID = new FieldDefinition(db, "ECM Position:Position_ID");
                FieldDefinition fd_ECMPositionPosition_Title = new FieldDefinition(db, "ECM Position:Position_Title");
                FieldDefinition fd_ECMPositionVacancy_ID = new FieldDefinition(db, "ECM Position:Vacancy_ID");
                FieldDefinition fd_ECMPositionVacancy_Status = new FieldDefinition(db, "ECM Position:Vacancy_Status");
                FieldDefinition fd_ECMProjectAndContractProject_Name = new FieldDefinition(db, "ECM ProjectAndContract:[Project_Name");
                FieldDefinition fd_ECMProjectAndContractContract_or_Activity_Desc = new FieldDefinition(db, "ECM ProjectAndContract:Contract_or_Activity_Desc");
                FieldDefinition fd_ECMProjectAndContractContract_or_Activity_Name = new FieldDefinition(db, "ECM ProjectAndContract:Contract_or_Activity_Name");
                FieldDefinition fd_ECMProjectAndContractContract_or_Activity_No = new FieldDefinition(db, "ECM ProjectAndContract:Contract_or_Activity_No");
                FieldDefinition fd_ECMProjectAndContractEnd_Date = new FieldDefinition(db, "ECM ProjectAndContract:End_Date");
                FieldDefinition fd_ECMProjectAndContractProject_Description = new FieldDefinition(db, "ECM ProjectAndContract:Project_Description");
                FieldDefinition fd_ECMProjectAndContractProject_End_Date = new FieldDefinition(db, "ECM ProjectAndContract:Project_End_Date");
                FieldDefinition fd_ECMProjectAndContractProject_Officer = new FieldDefinition(db, "ECM ProjectAndContract:Project_Officer");
                FieldDefinition fd_ECMProjectAndContractProject_Start_Date = new FieldDefinition(db, "ECM ProjectAndContract:Project_Start_Date");
                FieldDefinition fd_ECMProjectAndContractProjectNo = new FieldDefinition(db, "ECM ProjectAndContract:ProjectNo");
                FieldDefinition fd_ECMProjectAndContractResponsible_Officer = new FieldDefinition(db, "ECM ProjectAndContract:Responsible_Officer");
                FieldDefinition fd_ECMProjectAndContractStart_Date = new FieldDefinition(db, "ECM ProjectAndContract:Start_Date");
                FieldDefinition fd_ECMProjectAndContractStatus = new FieldDefinition(db, "ECM ProjectAndContract:Status");
                FieldDefinition fd_ECMPropertyHouse_No = new FieldDefinition(db, "ECM Property:House_No");
                FieldDefinition fd_ECMPropertyHouse_No_Suffix = new FieldDefinition(db, "ECM Property:House_No_Suffix");
                FieldDefinition fd_ECMPropertyHouse_No_To = new FieldDefinition(db, "ECM Property:House_No_To");
                FieldDefinition fd_ECMPropertyHouse_No_To_Suffix = new FieldDefinition(db, "ECM Property:House_No_To_Suffix");
                FieldDefinition fd_ECMPropertyLocality_Name = new FieldDefinition(db, "ECM Property:Locality_Name");
                FieldDefinition fd_ECMPropertyPostcode = new FieldDefinition(db, "ECM Property:Postcode");
                FieldDefinition fd_ECMPropertyProperty_Name = new FieldDefinition(db, "ECM Property:Property_Name");
                FieldDefinition fd_ECMPropertyProperty_No = new FieldDefinition(db, "Property Number List");
                FieldDefinition fd_ECMPropertyStreet_Name = new FieldDefinition(db, "ECM Property:Street_Name");
                FieldDefinition fd_ECMPropertyUnit_No = new FieldDefinition(db, "ECM Property:Unit_No");
                FieldDefinition fd_ECMPropertyUnit_No_Suffix = new FieldDefinition(db, "ECM Property:Unit_No_Suffix");
                //FieldDefinition fd_ECMreference = new FieldDefinition(db, "ECM reference");
                FieldDefinition fd_ECMRelatedDocDocSetID = new FieldDefinition(db, "ECM RelatedDoc:DocSetID");
                FieldDefinition fd_ECMSTDAllRevTitle = new FieldDefinition(db, "ECM STD:AllRevTitle");
                FieldDefinition fd_ECMSTDApplicationNo = new FieldDefinition(db, "ECM STD:ApplicationNo");
                FieldDefinition fd_ECMSTDBusinessCode = new FieldDefinition(db, "ECM STD:BusinessCode");
                FieldDefinition fd_ECMSTDClassName = new FieldDefinition(db, "ECM STD:ClassName");
                FieldDefinition fd_ECMSTDCorrespondant = new FieldDefinition(db, "ECM STD:Correspondant");
                FieldDefinition fd_ECMSTDCustomerRequest = new FieldDefinition(db, "ECM STD:CustomerRequest");
                FieldDefinition fd_ECMSTDDateLastAccessed = new FieldDefinition(db, "ECM STD:DateLastAccessed");
                FieldDefinition fd_ECMSTDDateReceived = new FieldDefinition(db, "ECM STD:DateReceived");
                FieldDefinition fd_ECMSTDDateRegistered = new FieldDefinition(db, "ECM STD:DateRegistered");
                FieldDefinition fd_ECMSTDDeclaredDate = new FieldDefinition(db, "ECM STD:DeclaredDate");
                FieldDefinition fd_ECMSTDDestructionDue = new FieldDefinition(db, "ECM STD:DestructionDue");
                FieldDefinition fd_ECMSTDDocumentDate = new FieldDefinition(db, "ECM STD:DocumentDate");
                FieldDefinition fd_ECMSTDDocumentType = new FieldDefinition(db, "ECM STD:DocumentType");
                FieldDefinition fd_ECMSTDExternalReference = new FieldDefinition(db, "ECM STD:ExternalReference");
                FieldDefinition fd_ECMSTDInfringementNo = new FieldDefinition(db, "Infringement Number");
                FieldDefinition fd_ECMSTDInternalReference = new FieldDefinition(db, "ECM STD:InternalReference");
                FieldDefinition fd_ECMSTDInternalScanRequest = new FieldDefinition(db, "ECM STD:InternalScanRequest");
                FieldDefinition fd_ECMSTDJobNo = new FieldDefinition(db, "ECM STD:JobNo");
                FieldDefinition fd_ECMSTDOtherReferences = new FieldDefinition(db, "ECM STD:OtherReferences");
                FieldDefinition fd_ECMSTDPropertyNo = new FieldDefinition(db, "ECM STD:PropertyNo");
                FieldDefinition fd_ECMSTDSummaryText = new FieldDefinition(db, "ECM STD:SummaryText");
                FieldDefinition fd_ECMStreetsLocality = new FieldDefinition(db, "ECM Streets:Locality");
                FieldDefinition fd_ECMStreetsPostcode = new FieldDefinition(db, "ECM Streets:Postcode");
                FieldDefinition fd_ECMStreetsStreet_Name = new FieldDefinition(db, "ECM Streets:Street_Name");
                FieldDefinition fd_ECMUserGroupsDescription = new FieldDefinition(db, "ECM UserGroups:Description");
                FieldDefinition fd_ECMUserGroupsExtNo = new FieldDefinition(db, "ECM UserGroups:ExtNo");
                FieldDefinition fd_ECMUserGroupsGivenName = new FieldDefinition(db, "ECM UserGroups:GivenName");
                FieldDefinition fd_ECMUserGroupsOrgEmail = new FieldDefinition(db, "ECM UserGroups:OrgEmail");
                FieldDefinition fd_ECMUserGroupsSurname = new FieldDefinition(db, "ECM UserGroups:Surname");
                FieldDefinition fd_ECMVolumeFilename = new FieldDefinition(db, "ECM Volume:Filename");
                FieldDefinition fd_ECMVolumeLastModified = new FieldDefinition(db, "ECM Volume:LastModified");
                FieldDefinition fd_ECMVolumeMedia = new FieldDefinition(db, "ECM Volume:Media");
                FieldDefinition fd_ECMVolumePrimaryCacheName = new FieldDefinition(db, "ECM Volume:PrimaryCacheName");
                FieldDefinition fd_ECMVolumeRenditionTypeName = new FieldDefinition(db, "ECM Volume:RenditionTypeName");
                FieldDefinition fd_ECMVolumeShareDrive = new FieldDefinition(db, "ECM Volume:ShareDrive");
                FieldDefinition fd_ECMVolumeSize = new FieldDefinition(db, "ECM Volume:Size");
                FieldDefinition fd_ECMVolumeStatus = new FieldDefinition(db, "ECM Volume:Status");
                FieldDefinition fd_ECMVolumeStorageLocation = new FieldDefinition(db, "ECM Volume:StorageLocation");
                //FieldDefinition fd_ECMVolumeUpdatable = new FieldDefinition(db, "ECM Volume:Updatable");
                //
                RecordType rt = new RecordType(db, 16);
                //Console.WriteLine("Processing {0} on thread {1}", filename, Thread.CurrentThread.ManagedThreadId);



                //});

                foreach (ECMMigration ecm in lstecm)
                {
                    
                    iCount++;
                    DateTime dt2 = DateTime.Now;
                    TimeSpan result = dt2 - dt1;
                    Console.WriteLine("Processing {0} - Number {1} of {2}, time since start {3} - batch offset {4}, Fetch {5} ({6})", ecm.DocSetID, iCount.ToString(), strTotal, result.TotalMinutes.ToString(), strOffset, strFetch, (Convert.ToInt32(strOffset) + iCount).ToString());
                    try
                    {
                        Record reccheck = (Record)db.FindTrimObjectByName(BaseObjectTypes.Record, ecm.DocSetID);
                        if (reccheck != null)
                        {
                            string strStorageLoc = FindMappedStorage(ecm.ECMVolumeStorageLocation) + "\\" + ecm.ECMVolumeFilename;
                            if (File.Exists(strStorageLoc))
                            {

                                try
                                {
                                    if (reccheck.DateRegistered <= reccheck.DateReceived)
                                    {
                                        DateTime tdtDateReceived = reccheck.DateReceived;
                                        reccheck.DateRegistered = (TrimDateTime)tdtDateReceived.AddHours(1);
                                        reccheck.Save();
                                    }

                                    InputDocument doc = new InputDocument();
                                    doc.SetAsFile(strStorageLoc);
                                    reccheck.SetDocument(doc, true, false, "Imported from ECM");
                                    reccheck.Save();
                                    deleteEcmSource(strStorageLoc);
                                    Console.WriteLine("Record Updated: " + reccheck.Number);
                                    UpdateMasterinRM(reccheck);
                                }
                                catch (Exception exp)
                                {
                                    
                                   UpdateMasterNoRm(ecm.DocSetID, 0);
                                    Loggitt("Record number " + ecm.DocSetID + "  could not be added - record save: " + exp.Message.ToString() + Environment.NewLine + iCount.ToString() + " " + strTotal + "" + result.TotalMinutes.ToString() + " " + (Convert.ToInt32(strOffset) + iCount).ToString(), "ECM Migrate issue");
                                    if (bDetailMsg)
                                    {
                                        Console.WriteLine("Update record error: " + exp.Message.ToString());
                                        //Console.ReadLine();
                                    }
                                }
                            }
                            else
                            {
                                Console.WriteLine("File not available: " + strStorageLoc);
                            }

                        }
                        else
                        {
                            
                            if (bDetailMsg)
                            {
                                Console.WriteLine("ECM record does not exist: " + ecm.DocSetID);
                                //Console.ReadLine();
                            }
                            UpdateMasterinRM(reccheck);
                        }
                    }
                    catch (Exception exp)
                    {
                        Loggitt("Record number " + ecm.DocSetID + "  could not be added -  Outer Error: " + exp.Message.ToString() + Environment.NewLine + iCount.ToString() + " " + strTotal + "" + result.TotalMinutes.ToString() + " " + (Convert.ToInt32(strOffset) + iCount).ToString(), "ECM Migrate issue");
                        //Console.ReadLine();
                        if (bDetailMsg)
                        {
                            Console.WriteLine("Outer look error: " + exp.Message.ToString());
                            Console.ReadLine();
                        }
                    }
                }
            }
            //});
            Console.ReadLine();
        }