Esempio n. 1
0
        public bool CanPolicySummary(HeaderDto headerDto)
        {
            if (this.HeaderData.HeaderID == 0)
            {
                return false;
            }

            return !this.IsBusy && this.HeaderData.HeaderID!=0;
        }
        /// <summary>
        /// Liefert die Commits mit dem dazugehörigen Developer
        /// </summary>
        public static Commit[] ReadFromCsv()
        {
            string        filePath = MyFile.GetFullNameInApplicationTree(Filename);
            List <Commit> commits  = new List <Commit>();
            Dictionary <string, Developer> developers = new Dictionary <string, Developer>();

            if (File.Exists(filePath) == false)
            {
                throw new Exception("File does not exist");
            }

            string[]  lines     = File.ReadAllLines(filePath, Encoding.UTF8);
            HeaderDto headerDto = null;
            FooterDto footerDto = null;

            foreach (string line in lines)
            {
                string[] data = line.Split(',');

                headerDto = MyParser.TryParseCommitHeader(line);
                if (headerDto != null)
                {
                    Developer developer;
                    if (developers.TryGetValue(headerDto.DeveloperName, out developer) == false)
                    {
                        developer = new Developer
                        {
                            Name = headerDto.DeveloperName
                        };
                        developers[headerDto.DeveloperName] = developer;
                    }

                    commits.Add(new Commit
                    {
                        HashCode     = headerDto.HashCode,
                        Developer    = developer,
                        Date         = headerDto.CommitDate,
                        Message      = headerDto.Message,
                        FilesChanges = 0,
                        Insertions   = 0,
                        Deletions    = 0
                    });
                }

                footerDto = MyParser.TryParseCommitFooter(line);
                if (footerDto != null && commits.Count > 0)
                {
                    Commit lastCommit = commits.Last();
                    lastCommit.FilesChanges = footerDto.FilesChanges;
                    lastCommit.Insertions   = footerDto.Insertions;
                    lastCommit.Deletions    = footerDto.Deletions;
                }
            }
            return(commits.ToArray());
        }
Esempio n. 3
0
        public static HeaderDto ToDto(this Header header)
        {
            if (header == null)
            {
                return(null);
            }

            HeaderDto dto = new HeaderDto();

            dto.Name  = header.Name;
            dto.Value = header.Value;

            return(dto);
        }
Esempio n. 4
0
        public ActionResult Header()
        {
            var Logginuser   = _userAppService.GetLoggedInUser();
            var userInfo     = _userAppService.GetUserLogidInInfo();
            var finacialYear = _financialYearAppService.GetActiveFinancialYear();

            var header = new HeaderDto {
                dealers       = _dealerAppService.GetTotalDealerByStationId(_stationAppService.GetStation(Logginuser.StationId), finacialYear),
                licenses      = _licenseAppService.GetTotalLicenseByStationId(Logginuser.StationId),
                bills         = _billAppService.GetTotalBillsByStation(_stationAppService.GetStation(Logginuser.StationId), finacialYear),
                financialYear = _financialYearAppService.GetActiveFinancialYear(),
                UserInfo      = userInfo
            };

            return(PartialView("_Header", header));
        }
        public List <HeaderDto> GetHeadList(DateTime startdate, DateTime endDate)
        {
            DateTime startDate_Temp = GetWeekFirstDay(startdate);
            DateTime endDate_Temp   = GetWeekLastDay(endDate);

            List <HeaderDto> list = new List <HeaderDto>();

            while (startDate_Temp < endDate_Temp)
            {
                HeaderDto dto = new HeaderDto();
                dto.StartDate = startDate_Temp;
                dto.EndDate   = startDate_Temp.AddDays(6);
                dto.Display   = dto.StartDate.Month + "." + dto.StartDate.Day + "-" + dto.EndDate.Month + "." + dto.EndDate.Day;
                list.Add(dto);
                startDate_Temp = dto.EndDate.AddDays(1);
            }

            return(list);
        }
        public void Post(PathValues pathValues)
        {
            document = new PdfDocument();
            try
            {
                logger.Trace($"start processing file:{pathValues.Path} at {DateTime.Now.ToString("yyyy/MM/dd-hh:mm:ss")}");
                var fileName = Path.GetFileName(pathValues.Path);

                helper        = new ApplicationHelper();
                verizonReader = new VerizonReader(document, pathValues.Path);
                FileDto          file    = new FileDto();
                HeaderDto        header  = new HeaderDto();
                List <DetailDto> details = new List <DetailDto>();
                var preBuildText         = helper.Prebuild(document, pathValues.Path);
                if (preBuildText.Any())
                {
                    header = verizonReader.GetHeaderValues(preBuildText);
                    file   = verizonReader.GetFileValues(fileName);
                    var detailList = helper.ReadDetails(document, pathValues);
                    details = verizonReader.GetDetailValues(detailList, document, pathValues.Path);
                }

                verizonReader.PlainTextConstructor(file, header, details, pathValues.Path, pathValues.OutputPath, pathValues.ProcessedFilesPath, pathValues.FailedFiles);
                logger.Trace($"finished processing file:{pathValues.Path} at {DateTime.Now.ToString("yyyy/MM/dd-hh:mm:ss")}");
            }
            catch (Exception ex)
            {
                document.Close();
                var fileName = Path.GetFileName(pathValues.Path);

                if (ex.Message == Constants.ErrorMessage1 || ex.Message == Constants.ErrorMessage2 || ex.Message == Constants.ErrorMessage3)
                {
                    System.IO.File.Move(pathValues.Path, $@"{pathValues.CorruptedFiles}\{fileName}", true);
                    logger.Error($"{ex.Message} in file {pathValues.Path} \\n\\n {ex.StackTrace}");
                }
                else
                {
                    System.IO.File.Move(pathValues.Path, $@"{pathValues.FailedFiles}\{fileName}", true);
                    logger.Error($"{ex.Message} in file {pathValues.Path} \\n\\n {ex.StackTrace}");
                }
            }
        }
Esempio n. 7
0
        public bool CanUpdateFromGenius(HeaderDto headerDto)
        {
            ////GetLatestVersion rename GetContextVersion
            if (headerDto == null || this.TryGetFields == null || headerDto.GetContextVersion() == null) 
            {
                return false;
            }

            ////if (!this.HeaderData.ExternalDataSource.Equals("GENIUS"))
            ////{
            ////    return false;
            ////}

            if (this.HeaderData.HeaderStatusThreshold >= 30)
            {
                return false;
            }

            return !this.IsBusy && headerDto.Data.CheckIsEditable();
        }
Esempio n. 8
0
        public HeadersForm()
        {
            _view = new HeadersFormView();

            Func <string, BaseUnboundColumnBuilder <HeaderDto> > build = x => UnboundDataGridColumnBuilder.For <HeaderDto>(x);

            Headers = DataGridModel <HeaderDto> .CreateAndBindNonReloadable(
                _view.Items,
                (el, theaderHeight, _) => //most of the time you would use Toolkit.DefaultTableBodyHeightProvider()
                el.GetAvailableHeightForFormElement(0, 2) - theaderHeight - _view.Help.Widget.OffsetHeight,
                new List <IDataGridColumn <HeaderDto> > {
                build("#")
                .WithValueLocalized(x => Headers.Items.IndexOf(x) + 1)
                .Build(),
                build("Id")
                .WithValueLocalized(x => x.Id)
                .TransformableDefault()
                .Build(),
                build("Name")
                .WithValue(x => x.Name)
                .TransformableDefault()
                .Build()
            }).Item1;

            Headers.Selected.Changed += (_, __, ___) => {
                if (Headers.Selected.Length != 1)
                {
                    return;
                }
                ChoosenHeader = Headers.Selected.First();
                Ended?.Invoke(this, Outcome.ChoosenHeader);
            };
            Headers.Activated.Changed += (sender, oldValue, newValue, errors, isUserChange) => {
                if (newValue == null)
                {
                    return;
                }
                ChoosenHeader = Headers.Activated.Value;
                Ended?.Invoke(this, Outcome.ChoosenHeader);
            };
        }
Esempio n. 9
0
        internal void Generate(string secretKey, bool resetTokenIdentifier = true)
        {
            if (resetTokenIdentifier)
            {
                TokenIdentifier = GetTokenIdentifier(_tokenIdentifierPrefix);
            }

            try
            {
                var dto = new HeaderDto()
                {
                    CustomerId      = CustomerId,
                    EventId         = EventId,
                    TokenIdentifier = TokenIdentifier,
                    Issued          = (new DateTimeOffset(Issued)).ToUnixTimeMilliseconds(),
                    Expires         = Expires == DateTime.MaxValue ? null : (long?)(new DateTimeOffset(Expires)).ToUnixTimeMilliseconds(),
                    Encryption      = EncryptionType.AES256.ToString(),
                    TokenVersion    = TokenVersion.QT1.ToString(),
                    IpAddress       = IpAddress,
                    XForwardedFor   = XForwardedFor
                };

                string serialized = dto.Serialize() + ".";
                if (Payload != null)
                {
                    serialized = serialized + Payload.EncryptAndEncode(secretKey, TokenIdentifier);
                }
                TokenWithoutHash = serialized;

                HashCode = Base64UrlEncoding.Encode(ShaHashing.GenerateHash(secretKey, TokenWithoutHash));
            }
            catch (Exception ex)
            {
                throw new TokenSerializationException(ex);
            }
        }
Esempio n. 10
0
 public void OnPolicySummary(HeaderDto header)
 {
     InvokeEvent(this.OnPolicySummaryClick, new CommandEventArgs<HeaderDto>(header));
 }
Esempio n. 11
0
 public void OnUpdateFromGenius(HeaderDto header)
 {
     InvokeEvent(this.OnUpdateFromGeniusClick, new CommandEventArgs<HeaderDto>(header));
 }
Esempio n. 12
0
        public static IEnqueueToken Parse(string tokenString, string secretKey)
        {
            if (string.IsNullOrEmpty(secretKey))
            {
                throw new ArgumentException("Invalid secret key", nameof(secretKey));
            }

            if (string.IsNullOrEmpty(tokenString))
            {
                throw new ArgumentException("Invalid token", nameof(tokenString));
            }

            var tokenParts  = tokenString.Split('.');
            var headerPart  = tokenParts[0];
            var payloadPart = tokenParts[1];
            var hashPart    = tokenParts[2];

            if (string.IsNullOrEmpty(headerPart))
            {
                throw new ArgumentException("Invalid token", nameof(tokenString));
            }
            if (string.IsNullOrEmpty(hashPart))
            {
                throw new ArgumentException("Invalid token", nameof(tokenString));
            }

            var token = headerPart + "." + payloadPart;

            var expectedHash = Base64UrlEncoding.Encode(ShaHashing.GenerateHash(secretKey, token));

            if (expectedHash != hashPart)
            {
                throw new InvalidHashException();
            }

            try
            {
                var headerModel = HeaderDto.DeserializeHeader(headerPart);

                EnqueueTokenPayload payload = null;
                if (!string.IsNullOrEmpty(payloadPart))
                {
                    payload = EnqueueTokenPayload.Deserialize(payloadPart, secretKey, headerModel.TokenIdentifier);
                }

                return(new EnqueueToken(
                           headerModel.TokenIdentifier,
                           headerModel.CustomerId,
                           headerModel.EventId,
                           DateTimeOffset.FromUnixTimeMilliseconds(headerModel.Issued).DateTime,
                           headerModel.Expires.HasValue
                        ? new DateTime?(DateTimeOffset.FromUnixTimeMilliseconds(headerModel.Expires.Value).DateTime)
                        : null,
                           headerModel.IpAddress,
                           headerModel.XForwardedFor,
                           payload)
                {
                    TokenWithoutHash = token,
                    HashCode = expectedHash
                });
            }
            catch (Exception ex)
            {
                throw new TokenDeserializationException("Unable to deserialize token", ex);
            }
        }
Esempio n. 13
0
        public async Task <ExcelExportForChartDto> ExcelExport(int workerID, int btnID)
        {
            var iotModel = await _repoCycleTime.FindAll().Where(x => x.datetime.Date == DateTime.Now.Date && x.BtnID == btnID && x.cycleTime > 0 && x.cycleTime <= 90).OrderBy(x => x.datetime).ToArrayAsync();

            var button = await _repoBtn.FindAll().Include(x => x.Worker).FirstOrDefaultAsync(x => x.WorkerID == workerID);

            var header = new HeaderDto {
                Type  = "FullName",
                Value = button.Worker.FullName
            };
            var header2 = new HeaderDto
            {
                Type  = "Operation",
                Value = button.Worker.Operation
            };
            var header3 = new HeaderForDataDto
            {
                PressTime = "Press Time",
                CT        = "Cycle Time",
                TT        = "TAKT Time",
                Standard  = "Standard",
                AVG       = "AVG"
            };
            var result = new ExcelExportForChartDto();
            var list   = new List <ExcelExportDto>();
            var length = iotModel.Length;

            for (int i = 0; i <= length - 1; i++)
            {
                var item1  = iotModel[i].datetime;
                var index2 = i + 1;
                if (i == 0)
                {
                    // list.Add(new ExcelExportDto { PressTime = item1.ToString("HH:mm:ss")});
                }
                else if (index2 == length)
                {
                    // list.Add(new ExcelExportDto { PressTime = item1.ToString("HH:mm:ss")});
                }
                else
                {
                    var    item2     = iotModel[i + 1].datetime;
                    var    cycleTime = item2 - item1;
                    double avg       = 0;
                    if (list.Count == 0)
                    {
                        avg = cycleTime.TotalSeconds;
                    }
                    else
                    {
                        avg = Math.Round((list.Sum(x => x.CT) + cycleTime.TotalSeconds) / i, 1);
                    }
                    list.Add(new ExcelExportDto {
                        PressTime = item1.ToString("HH:mm:ss"),
                        CT        = cycleTime.TotalSeconds,
                        TT        = button.TaktTime,
                        Standard  = button.Standard,
                        AVG       = avg
                    });
                }
            }
            result.Header1             = header;
            result.Header2             = header2;
            result.HeaderForDataDto    = header3;
            result.DataExcelExportDtos = list;
            return(result);
        }