Beispiel #1
0
        /// <summary>
        /// Удаление дублирующих строк в списке по дате.
        /// </summary>
        /// <returns>Список строк.</returns>
        private List <string> RemoveDuplicateLinesByDate(List <string> listRandom)
        {
            int        nextItem;
            DateTime   date     = new DateTime();
            DateTime   nextDate = new DateTime();
            ReportLine repLine  = new ReportLine();

            for (int i = 0; i < listRandom.Count; i++)
            {
                nextItem = i + 1;

                if (nextItem < listRandom.Count)
                {
                    date     = repLine.GetDateFromString(listRandom[i]);
                    nextDate = repLine.GetDateFromString(listRandom[nextItem]);

                    if (date == nextDate)
                    {
                        listRandom.RemoveAt(nextItem);
                        i--;
                    }
                }
            }
            return(listRandom);
        }
        public ActionResult DeletePost(ReportLine pt)
        {
            List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();

            LogList.Add(new LogTypeViewModel
            {
                ExObj = pt,
            });

            _ReportLineService.Delete(pt);
            XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

            try
            {
                _unitOfWork.Save();
            }

            catch (Exception ex)
            {
                string message = _exception.HandleException(ex);
                ModelState.AddModelError("", message);
                return(View("_Create", pt));
            }

            LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
            {
                DocTypeId       = new DocumentTypeService(_unitOfWork).Find(TransactionDoctypeConstants.Report).DocumentTypeId,
                DocId           = pt.ReportHeaderId,
                DocLineId       = pt.ReportLineId,
                ActivityType    = (int)ActivityTypeContants.Deleted,
                xEModifications = Modifications,
            }));

            return(Json(new { success = true }));
        }
Beispiel #3
0
        /// <summary>
        /// Загрузка списка отработанных часов по конкретному сотруднику из файла.
        /// </summary>
        /// <param name="employee"></param>
        /// <returns>Список строк.</returns>
        public List <string> LoadListOfWorkingHoursForSpecificEmployee(Employee employee)
        {
            // Список строк отработанных часов по конкретному сотруднику.
            List <string> listHoursWorked = new List <string>();

            try
            {
                using (StreamReader sr = new StreamReader(_path))
                {
                    string line;

                    // Считываем строку из файла пока строки не закончатся.
                    while ((line = sr.ReadLine()) != null)
                    {
                        ReportLine reportLine = new ReportLine();

                        if (reportLine.CompareNameAndSurname(line, employee))
                        {
                            listHoursWorked.Add(line);
                        }
                    }

                    return(listHoursWorked);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(listHoursWorked);
        }
Beispiel #4
0
            private void AddBreakdown(ReportLine h3, string title, Sql where, string fieldName, string breakdownBy)
            {
                string fieldAggregate = "sum(" + fieldName + ")";

                if (fieldName == "COUNT")
                {
                    fieldAggregate = "count(*)";
                }
                else if (fieldName.StartsWith("COUNT"))
                {
                    fieldAggregate = fieldName;
                }
                Sql sql  = new Sql("select " + fieldAggregate + " as Amt from ").AddSql(where);
                var norm = AddLine(h3, title, sql.FetchNumber().ToInt());

                if (breakdownBy != null)
                {
                    sql = new Sql().AddRawSqlString("select " + breakdownBy + " as Title, " + fieldAggregate + " as Amt from ").AddSql(where);
                    if (fieldName.DoesntContain("COUNT"))
                    {
                        sql.Add("and " + fieldName + " is not null and " + fieldName + " <> 0");
                    }
                    sql.AddRawSqlString("group by " + breakdownBy + " order by " + fieldAggregate + " desc");
                    AddSubLines(norm, "By Contractor", sql);
                }
            }
        public void CopyReport(ReportCopyViewModel vm, string UserName)
        {
            List <ReportLineViewModel> temp = GetReportLineList(vm.CopyHeaderId).ToList();

            foreach (var item in temp)
            {
                ReportLine line = new ReportLine();
                line.ReportHeaderId  = vm.ReportHeaderId;
                line.DataType        = item.DataType;
                line.Type            = item.Type;
                line.ServiceFuncGet  = item.ServiceFuncGet;
                line.ServiceFuncSet  = item.ServiceFuncSet;
                line.CacheKey        = item.CacheKey;
                line.Serial          = item.Serial;
                line.FieldName       = item.FieldName;
                line.DisplayName     = item.DisplayName;
                line.NoOfCharToEnter = item.NoOfCharToEnter;
                line.CreatedBy       = UserName;
                line.CreatedDate     = DateTime.Now;
                line.ModifiedBy      = UserName;
                line.ModifiedDate    = DateTime.Now;

                Create(line);
            }
            _unitOfWork.Save();
        }
        public ReportLineViewModel(ReportLine reportLine)
        {
            reportLine = reportLine ?? throw new ArgumentNullException(nameof(reportLine));

            if (IsPlugin(reportLine))
            {
                Name       = reportLine.Name.Replace("Plugins", "").Replace("Plugin", "") + ": ";
                reportLine = reportLine.Children.Single();
            }

            Id    = reportLine.Id;
            Name += reportLine.Name;
            Value = reportLine.Value;

            if (reportLine.Children == null || reportLine.Children.Count <= 0)
            {
                return;
            }

            Children = reportLine.Children
                       .OrderBy(x => x.Order)
                       .Select(x => new ReportLineViewModel(x)).ToArray();

            if (reportLine.IsTable)
            {
                TableHeaders = Children[0].Children?.Select(x => x.Name).ToArray() ?? new[] { "Name" };
            }
            else
            {
                IsDictionary = Children.All(x => x.Name != null && x.Value != null && x.Children == null);
            }
        }
        // GET: /ProductMaster/Create

        public ActionResult _Create(int id)
        {
            ReportLine line = new ReportLine();

            line.ReportHeaderId = id;
            return(PartialView("_Create", line));
        }
        public ActionResult Copy(ReportCopyViewModel vm)//header id
        {
            if (ModelState.IsValid)
            {
                List <ReportLine> temp = _ReportLineService.GetReportLineList(vm.CopyHeaderId).ToList();

                foreach (var item in temp)
                {
                    ReportLine line = new ReportLine();
                    line.ReportHeaderId  = vm.ReportHeaderId;
                    line.DataType        = item.DataType;
                    line.Type            = item.Type;
                    line.ServiceFuncGet  = item.ServiceFuncGet;
                    line.ServiceFuncSet  = item.ServiceFuncSet;
                    line.CacheKey        = item.CacheKey;
                    line.Serial          = item.Serial;
                    line.FieldName       = item.FieldName;
                    line.DisplayName     = item.DisplayName;
                    line.NoOfCharToEnter = item.NoOfCharToEnter;
                    line.CreatedBy       = User.Identity.Name;
                    line.CreatedDate     = DateTime.Now;
                    line.ModifiedBy      = User.Identity.Name;
                    line.ModifiedDate    = DateTime.Now;

                    _ReportLineService.Create(line);
                    _unitOfWork.Save();
                }
                return(RedirectToAction("Index", new { id = vm.ReportHeaderId }).Success("Date Copied Successfully"));
            }
            ViewBag.ReporList = new ReportHeaderService(_unitOfWork).GetReportHeaderList().ToList();
            return(View(vm));
        }
        public ReportLineViewModel Create(ReportLineViewModel pt, string UserName)
        {
            ReportLine obj = Mapper.Map <ReportLine>(pt);

            obj.CreatedDate  = DateTime.Now;
            obj.ModifiedDate = DateTime.Now;
            obj.CreatedBy    = UserName;
            obj.ModifiedBy   = UserName;
            obj.ObjectState  = Model.ObjectState.Added;
            Create(obj);

            _unitOfWork.Save();

            pt.ReportLineId = obj.ReportLineId;

            _logger.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
            {
                DocTypeId    = _DocumentTypeService.Find(TransactionDoctypeConstants.Report).DocumentTypeId,
                DocId        = pt.ReportHeaderId,
                DocLineId    = pt.ReportLineId,
                ActivityType = (int)ActivityTypeContants.Added,
            }));

            return(pt);
        }
Beispiel #10
0
        internal UpdateReportLineListViewItem(int id, ReportLine reportLine)
            : base(id, 0)
        {
            ReportLine = reportLine;

            displayName = reportLine.ItemPath;
        }
        private void savingProccessing()
        {
            Report report   = new Report();
            var    workshop = ApiConnector.getWorkshop(GetDepSender.Text);

            //var workshop = ApiConnector.getWorkshop("Сборочный");

            if (workshop == null)
            {
                MessageBox.Show("Цех с таким названием не найден", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            //List<Detail> details = (List<Detail>)ApiConnector.getDetails(); // Возможно, можно удалить эту строку
            List <Workshop> workshops = (List <Workshop>)ApiConnector.getWorkshops();

            report.date               = creationDate.Value.ToString("yyyy-MM-dd");
            report.doc_num            = Convert.ToInt32(docNumber.Text);
            report.workshop_sender_pk = workshop.workshop_pk;
            report.report_lines       = new List <ReportLine>();
            for (int i = 0; i < productsGrid.Rows.Count - 1; i++)
            {
                var reportLine = new ReportLine();
                reportLine.detail_pk            = details.Find(detail => detail.detail_name == productsGrid.Rows[i].Cells[0].Value.ToString()).detail_pk;
                reportLine.produced             = Convert.ToInt32(productsGrid.Rows[i].Cells[2].Value);
                reportLine.workshop_receiver_pk = workshops.Find(workshop => workshop.workshop_name == productsGrid.Rows[i].Cells[3].Value.ToString()).workshop_pk;
                report.report_lines.Add(reportLine);
            }
            if (Parent is EditingReportForm)
            {
                for (int i = 0; i < report.report_lines.Count; i++)
                {
                    try
                    {
                        report.report_lines[i].report_line_pk = identificationTable[productsGrid.Rows[i]].report_line_pk;
                        report.report_lines[i].report_pk      = (Parent as EditingReportForm).reportLast.report_pk;
                    }
                    catch { }
                }
                report.url       = (Parent as EditingReportForm).reportLast.url;
                report.report_pk = (Parent as EditingReportForm).reportLast.report_pk;
                ApiConnector.editReport(report);
                MessageBox.Show("Рапорт был успешно изменен.", "Редактирование рапорта", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                ApiConnector.createReport(report);
                MessageBox.Show("Рапорт был успешно создан.", "Добавление рапорта", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            progressBar1.Visible = false;
            if (!(Parent is EditingReportForm))
            {
                productsGrid.Rows.Clear();
                senderComboBox.Text = "";
                docNumber.Text      = "";
                creationDate.Value  = DateTime.Now;
            }
        }
Beispiel #12
0
        /// <summary>
        /// Создать строку отчета.
        /// </summary>
        /// <returns>Строка отчета.</returns>
        private string CreateReportLine(string line)
        {
            ReportLine reportLine = new ReportLine();

            var    dataFormString = reportLine.GetDataFromString(line);
            string strReport      = $"{dataFormString.Item1.ToShortDateString()}, {dataFormString.Item4} часов, {dataFormString.Item5}";

            return(strReport);
        }
        // GET: /ProductMaster/Delete/5

        public ActionResult _Delete(int id)
        {
            ReportLine pt = _ReportLineService.GetReportLine(id);

            if (pt == null)
            {
                return(HttpNotFound());
            }
            return(PartialView("_Create", pt));
        }
Beispiel #14
0
            private void AddSubLines(ReportLine parent, string subtitle, Sql sql)
            {
                //foreach (var perdi in periods) {
                var recs = sql.GetActiveRecordList();

                foreach (var rec in recs)
                {
                    AddSubLine(parent, rec[0].ToString(), rec[1].ToInt(null));
                }

                //}
            }
Beispiel #15
0
        /// <summary>
        /// Находит дублирующие строки в списке по дате имени и фамилии, из двух строк делает одну, вторую удаляет.
        /// </summary>
        /// <param name="listHoursWorked"></param>
        /// <returns></returns>
        public List <string> FindDuplicateLines(List <string> listHoursWorked)
        {
            ReportLine repLine  = new ReportLine();
            DateTime   date     = new DateTime();
            DateTime   nextDate = new DateTime();
            int        nextItem;

            for (int i = 0; i < listHoursWorked.Count; i++)
            {
                date = repLine.GetDateFromString(listHoursWorked[i]);

                if (i < listHoursWorked.Count - 1)
                {
                    nextItem = i + 1;
                    nextDate = repLine.GetDateFromString(listHoursWorked[nextItem]);

                    if (date == nextDate)
                    {
                        var nameAndSurname     = repLine.GetNameAndSurnameFromString(listHoursWorked[i]);
                        var nextNameAndSurname = repLine.GetNameAndSurnameFromString(listHoursWorked[nextItem]);

                        // Если имя и фамилия в строке, равна имени и фамилии в селдующей строке списка.
                        if (nameAndSurname.Item1 == nextNameAndSurname.Item1 && nameAndSurname.Item2 == nextNameAndSurname.Item2)
                        {
                            // Получаем все данные из строки.
                            var data = repLine.GetDataFromString(listHoursWorked[i]);
                            // Получаем рабочие часы и задачу из следующей строки.
                            var nextData = repLine.GetHoursAndTaskFromString(listHoursWorked[nextItem]);

                            // Складываем рабочие часы из двух строк.
                            data.Item4 += nextData.Item1;
                            // Создаем новую строку с задачами из текущей строки и следующей строки.
                            data.Item5 = $"{data.Item5} {nextData.Item2}";
                            // Общее рабочее время за сутки не может привышать 24 часа.
                            if (data.Item4 > 24)
                            {
                                data.Item4 = 24;
                            }

                            // Создаем новую строку.
                            string newLine = repLine.CreateReportLine(data.Item1, data.Item2, data.Item3, data.Item4, data.Item5);
                            // Удаляем следующую строку.
                            listHoursWorked.RemoveAt(nextItem);
                            // Записываем новую строку по текущему индексу.
                            listHoursWorked[i] = newLine;

                            i--;
                        }
                    }
                }
            }
            return(listHoursWorked);
        }
Beispiel #16
0
        /// <summary>
        /// Формирование списка строк отчета за день по конкретному сотруднику.
        /// </summary>
        private void DailyReport(List <string> listHoursWorked)
        {
            ReportLine reportLine = new ReportLine();

            foreach (var str in listHoursWorked)
            {
                if (startDate == reportLine.GetDateFromString(str))
                {
                    totalHoursWorked += reportLine.GetHoursWorkedFromString(str);
                    _listReport.Add(CreateReportLine(str));
                }
            }
        }
Beispiel #17
0
        public static void deleteReportLine(ReportLine line)
        {
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(line.url);

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "DELETE";

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
            }
        }
Beispiel #18
0
        /// <summary>
        /// Установить строки за период в переменную _listReport.
        /// </summary>
        private void SetLinesForPeriod(List <string> listHoursWorked)
        {
            // Считываемая дата.
            DateTime   readDate;
            ReportLine reportLine = new ReportLine();

            foreach (var line in listHoursWorked)
            {
                readDate = reportLine.GetDateFromString(line);

                if (readDate >= startDate && readDate <= endDate)
                {
                    totalHoursWorked += reportLine.GetHoursWorkedFromString(line);
                    _listReport.Add(CreateReportLine(line));
                }
            }
        }
Beispiel #19
0
        public static void editReportLine(ReportLine line)
        {
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(line.url);

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "PUT";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = JsonConvert.SerializeObject(line);
                streamWriter.Write(json);
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
            }
        }
Beispiel #20
0
        private static ReportLine LoadReportLine(string filename)
        {
            try
            {
                using (var p = new ExcelPackage(new FileInfo(filename)))
                {
                    var summary = p.Workbook.Worksheets["Summary"];
                    var result  = new ReportLine();
                    result.FAR = summary.Cells["I10"].GetValue <double>();
                    result.FRR = summary.Cells["I11"].GetValue <double>();
                    result.AER = summary.Cells["I12"].GetValue <double>();
                    result.Key = Path.GetFileNameWithoutExtension(filename);

                    for (int row = 10; row <= 21; row++)
                    {
                        string key   = summary.Cells[row, 5].GetValue <string>();
                        string value = summary.Cells[row, 6].GetValue <string>();
                        typeof(ReportLine).GetProperty(key).SetValue(result, value);
                    }

                    for (int row = 11; row <= 13; row++)
                    {
                        string key   = summary.Cells[row, 2].GetValue <string>().Replace(":", "");
                        string value = summary.Cells[row, 3].GetValue <string>();
                        typeof(ReportLine).GetProperty(key).SetValue(result, value);
                    }

                    return(result);
                }
            }
            catch (Exception exc)
            {
                Console.WriteLine(Path.GetFileNameWithoutExtension(filename));
                Console.WriteLine(exc.Message);
                return(new ReportLine
                {
                    Key = Path.GetFileNameWithoutExtension(filename),
                    Error = exc.Message
                });
            }
        }
Beispiel #21
0
        void DoErrorDetailsTextArea(ReportLine selectedReportLine)
        {
            string errorDetailsText = selectedReportLine == null ?
                                      string.Empty : selectedReportLine.Message;

            EditorGUILayout.BeginVertical();

            GUILayout.Space(8);
            GUILayout.Label("Problem");

            mErrorDetailsScrollPosition = GUILayout.BeginScrollView(
                mErrorDetailsScrollPosition);

            GUILayout.TextArea(
                errorDetailsText, UnityStyles.TextFieldWithWrapping,
                GUILayout.ExpandHeight(true));

            GUILayout.EndScrollView();

            EditorGUILayout.EndVertical();
        }
Beispiel #22
0
            public ReportLine AddLine(string title, int?value, string format, int colIndex, int level, ReportLine parent)
            {
                //var line = Lines.Find(l=>l.Title==title && l.Format==format && l.Level==level && l.Parent==parent);
                if (level == 4 && ShowBreakdown != "Detail")
                {
                    return(null);
                }

                var line = parent.SubLines.Find(l => l.Title == title && l.Format == format);

                if (line == null)
                {
                    line = new ReportLine();
                    parent.SubLines.Add(line);
                }
                line.Parent           = parent;
                line.Title            = title;
                line.Format           = format;
                line.Level            = level;
                line.Values[colIndex] = value;

                return(line);
            }
Beispiel #23
0
        public static void createReportLine(object param)
        {
            Tuple <Report, ReportLine> paramUnpacked = (Tuple <Report, ReportLine>)param;
            Report     report         = paramUnpacked.Item1;
            ReportLine line           = paramUnpacked.Item2;
            var        httpWebRequest = (HttpWebRequest)WebRequest.Create("https://loloman.pythonanywhere.com/api/report-lines/");

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";
            line.report_pk             = report.report_pk;

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                string json = JsonConvert.SerializeObject(line);
                streamWriter.Write(json);
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
            }
        }
Beispiel #24
0
        private static ReportLine[] FindAllLines(string content)
        {
            Queue <ReportLine> lines = new Queue <ReportLine>();
            var length = content.Length;

            int startIndex = 0;

            for (int i = startIndex; i < content.Length; i++)
            {
                char c = content[i];
                if (c == '(')
                {
                    while (content[++i] != ')')
                    {
                        ;
                    }
                    continue;
                }
                if (c == '"')
                {
                    while (content[++i] != '"')
                    {
                        ;
                    }
                    continue;
                }
                if (c == '\'')
                {
                    if (content[i + 1] == '\\' && content[i + 3] == '\'')
                    {
                        i += 3;
                        continue;
                    }
                    else if (content[i + 2] == '\'')
                    {
                        i += 2;
                        continue;
                    }
                }

                if (Punctuations.Any(p => p == c))
                {
                    lines.Enqueue(new ReportLine()
                    {
                        Start = startIndex,
                        End   = i + 1
                    });

                    startIndex = i + 1;
                }
            }

            Regex postScriptComment = new Regex(@"^P\.(?:P\.)*S\.\s");

            // Clean up lines
            Stack <ReportLine> cleanLines = new Stack <ReportLine>();

            while (lines.Count > 0)
            {
                var    line       = lines.Dequeue();
                int    trueStart  = line.Start + FindLineTrueStart(content.Substring(line.Start, line.End - line.Start));
                string subContent = content.Substring(trueStart, line.End - trueStart);

                if ((
                        subContent == "Dear Princess Celestia:" ||
                        subContent == "Your faithful student,"
                        ) && lines.Count > 0)
                {
                    var nextLine = lines.Dequeue();
                    cleanLines.Push(
                        new ReportLine()
                    {
                        Start = trueStart,
                        End   = nextLine.End
                    }
                        );

                    continue;
                }

                if (subContent == "P.")
                {
                    ReportLine nextLine     = line;
                    bool       foundNewLine = false;
                    int        tempIndex    = 1;
                    while (tempIndex < lines.Count)
                    {
                        nextLine = lines.ElementAt(tempIndex++);
                        string tempContent = content.Substring(nextLine.Start, nextLine.End - nextLine.Start);

                        if (tempContent.Contains("\n"))
                        {
                            foundNewLine = true;
                            break;
                        }
                    }

                    string postContent = content.Substring(trueStart, nextLine.End - trueStart);
                    if (postScriptComment.IsMatch(postContent))
                    {
                        while (tempIndex-- > 1)
                        {
                            nextLine = lines.Dequeue();
                        }
                        nextLine = lines.Peek();

                        int end = nextLine.End;

                        if (foundNewLine)
                        {
                            string tempContent  = content.Substring(nextLine.Start, nextLine.End - nextLine.Start);
                            int    newlineIndex = tempContent.IndexOf("\n");
                            nextLine.Start = nextLine.Start + newlineIndex;
                            end            = nextLine.Start;
                        }
                        else
                        {
                            lines.Dequeue();
                        }

                        cleanLines.Push(
                            new ReportLine()
                        {
                            Start = trueStart,
                            End   = end
                        }
                            );

                        continue;
                    }
                }

                line.Start = trueStart;
                if (line.End - line.Start == 1)
                {
                    continue;                                             // Ignore empty lines
                }
                cleanLines.Push(line);
            }

            return(cleanLines.Reverse().ToArray());
        }
Beispiel #25
0
        /// <summary>
        /// Common add line method
        /// </summary>
        /// <param name="Text"></param>
        ReportLine AddLine(string Text)
        {
            if (!enabled) return null;

            ReportLine newLine = new ReportLine();
            newLine.Depth = currentDepth;
            newLine.Text = Text;
            newLine.TextMarkUp = null;
            report.Add(newLine);

            return newLine;
        }
Beispiel #26
0
        public ActionResult GridReportLayout(int?MenuId, string MenuName, int?DocTypeId)
        {
            Menu              menu   = new Menu();
            ReportHeader      header = null;
            List <ReportLine> lines  = new List <ReportLine>();

            if (MenuId != null)
            {
                menu   = new MenuService(_unitOfWork).Find((int)MenuId);
                header = new ReportHeaderService(_unitOfWork).GetReportHeaderByName(menu.MenuName);
                if (header != null)
                {
                    lines = new ReportLineService(_unitOfWork).GetReportLineList(header.ReportHeaderId).ToList();
                }
                else
                {
                    new GridReportService().GetGridReportByName(menu.MenuName, ref header, ref lines, null);
                }
            }
            else
            {
                new GridReportService().GetGridReportByName(MenuName, ref header, ref lines, null);
            }


            if (DocTypeId != null)
            {
                ReportLine ReportLineDocType = (from L in lines where L.FieldName == "DocumentType" select L).FirstOrDefault();
                ReportLineDocType.DefaultValue = DocTypeId.ToString();
            }


            Dictionary <int, string> DefaultValues = TempData["ReportLayoutDefaultValues"] as Dictionary <int, string>;

            TempData["ReportLayoutDefaultValues"] = DefaultValues;
            foreach (var item in lines)
            {
                if (DefaultValues != null && DefaultValues.ContainsKey(item.ReportLineId))
                {
                    item.DefaultValue = DefaultValues[item.ReportLineId];
                }
            }

            ReportMasterViewModel vm = new ReportMasterViewModel();

            if (TempData["closeOnSelectOption"] != null)
            {
                vm.closeOnSelect = (bool)TempData["closeOnSelectOption"];
            }

            vm.ReportHeader   = header;
            vm.ReportLine     = lines;
            vm.ReportHeaderId = header.ReportHeaderId;


            if (DocTypeId != null)
            {
                DocumentType DocType = db.DocumentType.Find(DocTypeId);
                vm.ReportTitle = DocType.DocumentTypeName + " Report";
            }

            vm.ReportHeaderCompanyDetail = new GridReportService().GetReportHeaderCompanyDetail();

            return(View(vm));
        }
Beispiel #27
0
        /// <summary>
        /// Run the report
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, System.EventArgs e)
        {
            DateTime starttime;
            DateTime endtime;

            // Check that the dates are correct
            try
            {
                starttime = DateTime.Parse(textBox1.Text);
            }
            catch
            {
                ErrorHandler.ShowInformation(ErrorHandler.ERR_DATE_WRONG);
                this.textBox1.Focus();
                this.textBox1.SelectAll();
                return;
            }
            try
            {
                endtime = DateTime.Parse(textBox2.Text).AddDays(1);
            }
            catch
            {
                ErrorHandler.ShowInformation(ErrorHandler.ERR_DATE_WRONG);
                this.textBox2.Focus();
                this.textBox2.SelectAll();
                return;
            }

            // Run report
            Report rep;

            if (ErrorHandler.ShowError(Scheme.Instance.runReport(starttime, endtime, out rep)))
            {
                return;
            }
            SortedList replist = rep.getReportLines();

            richTextBox1.Text  = "Rapport\nStartdatum: " + this.textBox1.Text + "\nSlutdatum: " + this.textBox2.Text + "\n\n";
            richTextBox1.Text += "Person/Resurs                 Timmar     Avvikelse\n\n";
            // Write all reportlines on to the textbox
            for (int i = 0; i < replist.Count; i++)
            {
                ReportLine repline = (ReportLine)replist[replist.GetKey(i)];
                richTextBox1.Text += repline.Name;
                for (int o = 0; o < 30 - repline.Name.Length; o++)
                {
                    richTextBox1.Text += " ";
                }
                richTextBox1.Text += repline.Hours;
                for (int o = 0; o < 11 - repline.Hours.ToString().Length; o++)
                {
                    richTextBox1.Text += " ";
                }
                richTextBox1.Text += repline.Deviation + "\n";
            }
            if (replist.Count == 0)
            {
                richTextBox1.Text += "Inga timmar är registrerade";
            }
        }
Beispiel #28
0
        /// <summary>
        /// Common add line method
        /// </summary>
        /// <param name="Text"></param>
        ReportLine AddLine(string Text)
        {
            if (!enabled) return null;

            string[] split = StringHelper.Split(Text, Environment.NewLine);
            ReportLine first = null;
            foreach (string s in split)
            {
                ReportLine newLine = new ReportLine();
                newLine.Depth = currentDepth;
                newLine.Text = s;
                newLine.TextMarkUp = null;
                report.Add(newLine);
                if (first == null) first = newLine;
            }

            return first;
        }
Beispiel #29
0
 /// <summary>
 /// Append an existing nested report, and the current depth.
 /// </summary>
 /// <param name="nested">Nexted report to append</param>
 public void Append(DebugReport nested)
 {
     foreach(ReportLine nestedLine in nested.Report)
     {
         ReportLine newLine = new ReportLine();
         newLine.Text = nestedLine.Text;
         newLine.Depth = currentDepth + nestedLine.Depth;
         newLine.Hints = nestedLine.Hints;
         newLine.TextMarkUp = null;
         report.Add(newLine);
     }
 }
Beispiel #30
0
 public ReportLine Create(ReportLine pt)
 {
     pt.ObjectState = ObjectState.Added;
     _unitOfWork.Repository <ReportLine>().Insert(pt);
     return(pt);
 }
Beispiel #31
0
 public ReportLine Add(ReportLine pt)
 {
     _unitOfWork.Repository <ReportLine>().Insert(pt);
     return(pt);
 }
Beispiel #32
0
 public void Update(ReportLine pt)
 {
     pt.ObjectState = ObjectState.Modified;
     _unitOfWork.Repository <ReportLine>().Update(pt);
 }
Beispiel #33
0
 public void Delete(ReportLine pt)
 {
     _unitOfWork.Repository <ReportLine>().Delete(pt);
 }