private static void UpdateBasedOnExcelFile(List <IssueItem> issuesInRedmineProject,
                                                   List <StatItem> statItems,
                                                   bool allWithinDirectory)
        {
            //********************************************************************************************************/
            //read data from Excel
            List <string> filesToProcess = null;

            if (allWithinDirectory)
            {
                filesToProcess = Directory.EnumerateFiles(MOM_FILES_DIR, "*.xlsx").ToList();
            }
            else
            {
                filesToProcess = new List <string>();
                filesToProcess.Add(MOM_FILE_PATH);
            }

            foreach (string singleXSLXfile in filesToProcess)
            {
                var xlsx = new LinqToExcel.ExcelQueryFactory(singleXSLXfile);

                output.WriteLine("File: {0}", singleXSLXfile);

                foreach (string tabName in xlsx.GetWorksheetNames())
                {
                    output.WriteLine("--------------------------------------------");
                    output.WriteLine("Processing of {0}...", tabName);
                    output.WriteLine("--------------------------------------------");

                    StatItem statItem = new StatItem(tabName);
                    statItem.Env = tabName;

                    var query =
                        from row in xlsx.Worksheet(tabName)
                        let item = new
                    {
                        ProblemID   = row["Problem ID"].Cast <string>(),
                        ProblemCode = row["Problem Code"].Cast <string>(),
                        MessageId   = row["Message ID"].Cast <string>(),
                        EventCode   = row["Event Code"].Cast <string>(),
                        Details     = row["Details"].Cast <string>(),
                        SenderCode  = row["Sender Code"].Cast <string>(),
                    }
                    select item;

                    IdentifiableName p = IdentifiableName.Create <Project>(Consts.PROJECT_NAMES.MOM.PROBLEMS);
                    foreach (var itemFromExcel in query)
                    {
                        //look for the item in RM
                        var redmineIssue = issuesInRedmineProject.Where(issueFromRedmine => issueFromRedmine.Env == tabName && issueFromRedmine.ProblemId == itemFromExcel.ProblemID).FirstOrDefault();

                        if (redmineIssue != null && string.IsNullOrEmpty(redmineIssue.SenderCode))
                        {
                            if (!string.IsNullOrEmpty(itemFromExcel.SenderCode))
                            {
                                var issue = RMManegerService.RMManager.GetObject <Issue>(redmineIssue.Id.ToString(), null);

                                issue.Subject = issue.Subject + string.Format(" - {0}", itemFromExcel.SenderCode);

                                RMManegerService.RMManager.UpdateObject(redmineIssue.Id.ToString(), issue);
                                redmineIssue.SenderCode = itemFromExcel.SenderCode;

                                statItem.Updated++;
                                //  string subject = redmineIssue.sub
                                //string subject = string.Format("{0} - {1} - {2} - {3} - {4}", tabName, itemFromExcel.ProblemID, itemFromExcel.EventCode, itemFromExcel.ProblemCode, itemFromExcel.SenderCode);
                            }
                            else
                            {
                                statItem.NotUpdated++;
                            }
                        }
                        else
                        {
                            statItem.NotUpdated++;
                        }
                    }
                    statItems.Add(statItem);
                }
            }
        }
        private static void ProcessExcelFile(List <IssueItem> issuesInRedmineProject, List <StatItem> statItems, List <string> envsNotExistingInConfigs)
        {
            //********************************************************************************************************/
            //read data from Excel
            var xlsx = new LinqToExcel.ExcelQueryFactory(MOM_FILE_PATH);

            foreach (string tabName in xlsx.GetWorksheetNames())
            {
                output.WriteLine("--------------------------------------------");
                output.WriteLine("Processing of {0}...", tabName);
                output.WriteLine("--------------------------------------------");

                MOMEnvSettings momEnvSettings = null;
                if (!MOM_ENV_SETTINGS.TryGetValue(tabName, out momEnvSettings))
                {
                    output.WriteLine("No MOMEnvSettings for {0}", tabName);
                    envsNotExistingInConfigs.Add(tabName);
                    //output.ReadKey();
                }
                else
                {
                    output.WriteLine("Start processing: {0}", tabName);

                    StatItem statItem = new StatItem();
                    statItem.Env = tabName;

                    var query =
                        from row in xlsx.Worksheet(tabName)
                        let item = new
                    {
                        ProblemID   = row["Problem ID"].Cast <string>(),
                        ProblemCode = row["Problem Code"].Cast <string>(),
                        MessageId   = row["Message ID"].Cast <string>(),
                        EventCode   = row["Event Code"].Cast <string>(),
                        Details     = row["Details"].Cast <string>(),
                        SenderCode  = row["Sender Code"].Cast <string>(),
                    }
                    select item;

                    IdentifiableName p = IdentifiableName.Create <Project>(Consts.PROJECT_NAMES.MOM.PROBLEMS);
                    foreach (var itemFromExcel in query)
                    {
                        string subject = string.Format("{0} - {1} - {2} - {3} - {4}", tabName, itemFromExcel.ProblemID, itemFromExcel.EventCode, itemFromExcel.ProblemCode, itemFromExcel.SenderCode);

                        //check if such the item exists in the Redmine project
                        var redmineIssue = issuesInRedmineProject.Where(issueFromRedmine => issueFromRedmine.Env == tabName && issueFromRedmine.ProblemId == itemFromExcel.ProblemID);
                        if (redmineIssue.Count() == 0)
                        {
                            string details = string.Format("{0}\r\nMessage link: {1}\r\nProblem link: {2}", itemFromExcel.Details, momEnvSettings.GetMessageLink(itemFromExcel.MessageId), momEnvSettings.GetProblemLink(itemFromExcel.MessageId));

                            var newIssue = new Issue {
                                Subject = subject, Project = p, Description = details
                            };
                            RMManegerService.RMManager.CreateObject(newIssue);

                            //add a new item to local cached items from redmine
                            IssueItem item = new IssueItem();

                            item.Env       = tabName;
                            item.ProblemId = itemFromExcel.ProblemID;

                            issuesInRedmineProject.Add(item);

                            statItem.Added++;
                        }
                        else
                        {
                            output.WriteLine("Issue exists! {0}", subject);
                            statItem.AlreadyExisted++;
                        }
                    }
                    statItems.Add(statItem);
                }
            }
        }