public void SaveActivity(AuditReport report)
 {
     report.Id = Guid.NewGuid();
     db.AuditReport.Add(report);
     db.SaveChanges();
     db.Dispose();
 }
Exemplo n.º 2
0
        public AuditReport Update(AuditReport obj)
        {
            AuditReportBO auditreportBO = new AuditReportBO(obj);

            auditreportDao.Update(auditreportBO);
            return(obj);
        }
Exemplo n.º 3
0
 protected void btnAddReport_Click(object sender, EventArgs e)
 {
     if (memVal.OrgId > 0)
     {
         AuditReport report = new AuditReport();
         report.EnterpriseId         = Convert.ToInt32(memVal.OrgId);
         report.AuditYear            = Convert.ToInt32(ddlAuditYear.SelectedValue);
         report.DataYear             = Convert.ToInt32(ddlDataYear.SelectedValue);
         report.AuditConsultancyName = txtAuditConsultant.Text.Trim();
         report.Address       = txtAddress.Text.Trim();
         report.AuditorName   = txtAuditor.Text.Trim();
         report.AuditingScope = txtAuditScope.Text.Trim();
         report.ShiftNo       = Convert.ToInt32(rbtShiftNo.SelectedValue);
         report.AuditorCode   = txtAuditorCode.Text.Trim();
         report.TaxNo         = txtMST.Text.Trim();
         int ret = new AuditReportService().Insert(report);
         if (ret > 0)
         {
             Response.Redirect(ResolveUrl("~") + "bao-cao-so-kiem-toan-nl-" + ret + ".aspx");
         }
         else
         {
             ScriptManager.RegisterStartupScript(this, GetType(), "addReport", "ShowDialogAuditReport();", true);
         }
     }
 }
      public IHttpActionResult auditReport(Guid orgId, Guid projId, Guid? locId) {
        DateTime? startDate = grabStartDate();
        if (!startDate.HasValue)
          return Ok();

        return Ok(AuditReport.build(orgId, projId, locId, startDate.Value));
      } // auditReport
      public HttpResponseMessage auditReportCsv(Guid orgId, Guid projId, Guid? locId) {
        DateTime startDate = grabStartDate().Value;

        var response = csvStream("auditReport.csv", new PushStreamContent((stream, Content, context) => {
          var writer = new StreamWriter(stream);
          AuditReport.buildCSV(writer, orgId, projId, locId, startDate);
        }));

        return response;
      } // auditReportCsv
Exemplo n.º 6
0
        public AuditService(IFileStreamAdapter fileStreamAdapter, IXmlSerializerAdapter xmlSerializerAdapter)
        {
            _fileStreamAdapter    = fileStreamAdapter;
            _xmlSerializerAdapter = xmlSerializerAdapter;

            _auditReport = new AuditReport
            {
                AuditDate      = DateTime.Now,
                AuditErrorList = new List <AuditError>()
            };
        }
Exemplo n.º 7
0
    void Load_Play()
    {
        DataTable dt = new DataTable();

        dt.Columns.Add(new DataColumn("ShowName", typeof(string)));
        dt.Columns.Add(new DataColumn("Location", typeof(string)));
        dt.Columns.Add(new DataColumn("Show Date", typeof(string)));
        dt.Columns.Add(new DataColumn("Show Time", typeof(string)));
        dt.Columns.Add(new DataColumn("Show Time Code", typeof(string)));
        dt.Columns.Add(new DataColumn("locationcode", typeof(string)));
        AuditReport ar       = new AuditReport();
        DateTime    PlayDate = DateTime.Now;

        ar.Date = Convert.ToDateTime(PlayDate.ToString());
        Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Start Load Play");
        DataTable dtlocation = VistaBOL.Select_Play();

        if (dtlocation != null && dtlocation.Rows.Count > 0)
        {
            foreach (DataRow dr in dtlocation.Rows)
            {
                ar.ShowName = dr[0].ToString();
                DataTable dtAudi = VistaBOL.Select_Audi(ar.ShowName.ToString());
                foreach (DataRow dr1 in dtAudi.Rows)
                {
                    ar.LocationText  = dr1[1].ToString();
                    ar.LocationValue = dr1[0].ToString();
                    DataTable drtime = VistaBOL.Select_PlayTime_Audit(ar.LocationValue, ar.ShowName, ar.Date.ToString("dd/MM/yyyy"));
                    foreach (DataRow dr2 in drtime.Rows)
                    {
                        ar.Timetext  = Convert.ToDateTime(dr2[0].ToString());
                        ar.Timevalue = dr2[1].ToString();
                        dt.Rows.Add(ar.ShowName, ar.LocationText, ar.Date.ToString("ddd, MMM dd,yyyy"), ar.Timetext.ToShortTimeString(), ar.Timevalue, ar.LocationValue);
                    }
                }
            }
        }
        DataSet ds = new DataSet();

        ds.Tables.Add(dt);
        GridView_ShowDetail.DataSource = ds.Tables[0];
        GridView_ShowDetail.DataBind();
    }
        public static void SaveAuditReport(string userId, string OperationName, string beforeChange, string afterChange)
        {
            HttpBrowserCapabilities bc = HttpContext.Current.Request.Browser;

            AuditReport report = new AuditReport {
                EmployeeId    = userId,
                IpAddress     = HttpContext.Current.Request.UserHostAddress,
                MacAddress    = GetMACAddress(),
                OS            = GetUserPlatform(),
                OperationType = OperationName,
                Browser       = bc.Browser + " " + bc.Version,
                RequestedPath = HttpContext.Current.Request.Url.AbsolutePath,
                DateTimeStamp = System.DateTime.Now,
                BeforeChange  = beforeChange,
                AfterChange   = afterChange
            };

            AuditActivities activity = new AuditActivities();

            activity.SaveActivity(report);
        }
Exemplo n.º 9
0
 void Load_Play()
 {
     DataTable dt = new DataTable();
     dt.Columns.Add(new DataColumn("ShowName", typeof(string)));
     dt.Columns.Add(new DataColumn("Location", typeof(string)));
     dt.Columns.Add(new DataColumn("Show Date", typeof(string)));
     dt.Columns.Add(new DataColumn("Show Time", typeof(string)));
     dt.Columns.Add(new DataColumn("Show Time Code", typeof(string)));
     dt.Columns.Add(new DataColumn("locationcode", typeof(string)));
     AuditReport ar = new AuditReport();
     DateTime PlayDate = DateTime.Now;
     ar.Date = Convert.ToDateTime(PlayDate.ToString());
     Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write("Start Load Play");
     DataTable dtlocation = VistaBOL.Select_Play();
     if (dtlocation != null && dtlocation.Rows.Count > 0)
     {
         foreach (DataRow dr in dtlocation.Rows)
         {
             ar.ShowName = dr[0].ToString();
             DataTable dtAudi = VistaBOL.Select_Audi(ar.ShowName.ToString());
             foreach (DataRow dr1 in dtAudi.Rows)
             {
                 ar.LocationText = dr1[1].ToString();
                 ar.LocationValue = dr1[0].ToString();
                 DataTable drtime = VistaBOL.Select_PlayTime_Audit(ar.LocationValue, ar.ShowName, ar.Date.ToString("dd/MM/yyyy"));
                 foreach (DataRow dr2 in drtime.Rows)
                 {
                     ar.Timetext = Convert.ToDateTime(dr2[0].ToString());
                     ar.Timevalue = dr2[1].ToString();
                     dt.Rows.Add(ar.ShowName, ar.LocationText, ar.Date.ToString("ddd, MMM dd,yyyy"), ar.Timetext.ToShortTimeString(), ar.Timevalue, ar.LocationValue);
                 }
             }
     
         }
     }
     DataSet ds = new DataSet();
     ds.Tables.Add(dt);
     GridView_ShowDetail.DataSource = ds.Tables[0];
     GridView_ShowDetail.DataBind();
 }
Exemplo n.º 10
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        LinkButton         btnDelete = (LinkButton)sender;
        AuditReportService faqsBSO   = new AuditReportService();
        AuditReport        report    = faqsBSO.FindByKey(Convert.ToInt32(btnDelete.CommandArgument));

        if (report != null && report.Status > 0)
        {
            if (faqsBSO.Delete(Convert.ToInt32(btnDelete.CommandArgument)) > 0)
            {
                BindData();
            }
            else
            {
                Tool.Message(this.Page, "Xóa không thành công. Vui lòng thử lại");
            }
        }
        else
        {
            Tool.Message(this.Page, "Báo cáo đã được gửi đi đang được duyệt, bạn không thể xóa báo cáo này.");
        }
    }
        public void AuditTrail(string actionPerformed, string userId)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
                    IPAddress   ipAddress  = ipHostInfo.AddressList[1];

                    var audit = new AuditReport()
                    {
                        ActionPerformed = actionPerformed,
                        UserId          = userId,
                        SystemIpAddress = ipAddress.ToString(),
                    };
                    AuditReportRepository.InsertObject(audit);
                    Save();
                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 12
0
        public int Insert(AuditReport obj)
        {
            AuditReportBO auditreportBO = new AuditReportBO(obj);

            return(auditreportDao.Insert(auditreportBO));
        }
Exemplo n.º 13
0
    private void BindReportInfo()
    {
        if (ReportId > 0)
        {
            try
            {
                AuditReport        report    = new AuditReport();
                AuditReportService reportBSO = new AuditReportService();
                report = reportBSO.FindByKey(ReportId);
                if (report != null)
                {
                    if (report.Status == 1 || report.Status == 3)
                    {
                        btnSend.Visible    = true;
                        btnConfirm.Visible = true;
                    }
                    else
                    {
                        btnSend.Visible    = false;
                        btnConfirm.Visible = false;
                    }
                    if (report.PathFile != "")
                    {
                        lbtDownload.Text    = report.PathFile;
                        lbtDownload.Visible = true;
                    }
                    else
                    {
                        lbtDownload.Visible = false;
                    }
                    if (report.EnterpriseId > 0)
                    {
                        Enterprise enter = new EnterpriseService().FindByKey((report.EnterpriseId));
                        if (enter != null)
                        {
                            ltEnterpriseName.Text        = enter.Title;
                            ucEnergyConsume.CustomerCode = enter.CustomerCode;

                            ltAreaName.Text = "------";
                            if (enter.AreaId > 0)
                            {
                                Area area = new Area();
                                area = new AreaService().FindByKey(enter.AreaId);
                                if (area != null)
                                {
                                    ltAreaName.Text = area.AreaName;
                                }
                            }
                            ltSubAreaName.Text = "------";
                            if (enter.SubAreaId > 0)
                            {
                                Area area = new Area();
                                area = new AreaService().FindByKey(enter.SubAreaId);
                                if (area != null)
                                {
                                    ltSubAreaName.Text = area.AreaName;
                                }
                            }
                            ltProvinceName.Text = "------";
                            if (enter.ProvinceId > 0)
                            {
                                Province area = new Province();
                                area = new ProvinceService().FindByKey(enter.ProvinceId);
                                if (area != null)
                                {
                                    ltProvinceName.Text = area.ProvinceName;
                                }
                            }
                            ltDistrictName.Text = "------";
                            if (enter.DistrictId > 0)
                            {
                                District area = new District();
                                area = new DistrictService().FindByKey(enter.DistrictId);
                                if (area != null)
                                {
                                    ltDistrictName.Text = area.DistrictName;
                                }
                            }
                            ltTaxNo.Text       = enter.TaxCode;
                            ltAddress.Text     = enter.Address;
                            ltEmail.Text       = enter.Email;
                            ltFaxNo.Text       = enter.Fax;
                            ltPhoneNumber.Text = enter.Phone;
                            ltResponsible.Text = enter.ManPerson;

                            ltParentName.Text     = enter.ParentName;
                            ltProvinceParent.Text = "------";
                            if (enter.ManProvinceId > 0)
                            {
                                Province area = new Province();
                                area = new ProvinceService().FindByKey(enter.ManProvinceId);
                                if (area != null)
                                {
                                    ltProvinceParent.Text = area.ProvinceName;
                                }
                            }

                            //ltDistrictParent.Text = ddlDistrictReporter.SelectedItem.Text;
                            ltDistrictParent.Text = "------";
                            if (enter.ManDistrictId > 0)
                            {
                                District area = new District();
                                area = new DistrictService().FindByKey(enter.ManDistrictId);
                                if (area != null)
                                {
                                    ltDistrictParent.Text = area.DistrictName;
                                }
                            }

                            ltEmailParent.Text   = enter.ManEmail;
                            ltFaxParent.Text     = enter.ManFax;
                            ltAddressParent.Text = enter.ManAddress;
                            ltPhoneParent.Text   = enter.ManPhone;
                            ltCustomerCode.Text  = enter.CustomerCode;
                        }
                    }
                    ucElectrictSystem.ReportYear = report.AuditYear;
                    ucElectrictSystem.AllowEdit  = AllowEdit;
                    ucElectrictSystem.ReportId   = ReportId;

                    ucAuditSolution.ReportYear = report.AuditYear;
                    ucAuditSolution.AllowEdit  = AllowEdit;
                    ucAuditSolution.ReportId   = ReportId;

                    ucAuditProduct.ReportYear = report.AuditYear;
                    ucAuditProduct.AllowEdit  = AllowEdit;
                    ucAuditProduct.ReportId   = ReportId;

                    ucAuditOperationArea.ReportYear = report.AuditYear;
                    ucAuditOperationArea.AllowEdit  = AllowEdit;
                    ucAuditOperationArea.ReportId   = ReportId;

                    ucEnergyConsume.ReportYear = report.AuditYear;
                    ucEnergyConsume.AllowEdit  = AllowEdit;
                    ucEnergyConsume.ReportId   = ReportId;

                    ucEnergyQuota.ReportYear = report.AuditYear;
                    ucEnergyQuota.AllowEdit  = AllowEdit;
                    ucEnergyQuota.ReportId   = ReportId;

                    //if (memVal.OrgId > 0 && report.Or != Convert.ToInt32(memVal.OrgId))//Neu
                    //    Response.Redirect(ResolveUrl("~"));
                    AuditYearReport  = report.AuditYear;
                    ltAuditYear.Text = AuditYearReport.ToString();


                    ltAuditYear.Text = AuditYearReport.ToString();
                    ltDataYear.Text  = report.DataYear.ToString();

                    ltAuditUnit.Text    = report.AuditConsultancyName;
                    ltAuditAddress.Text = report.Address;

                    ltAuditor.Text    = report.AuditorName;
                    ltAuditScope.Text = report.AuditingScope;
                    ltShiftNo1.Text   = "";
                    ltShiftNo2.Text   = "";
                    ltShiftNo3.Text   = "";
                    if (report.ShiftNo == 0)
                    {
                        ltShiftNo1.Text = "X";
                    }
                    else
                    {
                        if (report.ShiftNo == 1)
                        {
                            ltShiftNo2.Text = "X";
                        }
                        else
                        {
                            ltShiftNo3.Text = "X";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                clientview.Text = ex.Message.ToString();
            }
        }
    }
Exemplo n.º 14
0
        public void SaveAuditReport(string suite, string database)
        {
            bool VersionLessThan(string version1, string version2)
            {
                try
                {
                    _processRunner.RunShell($"dpkg --compare-versions \"{version1}\" \"lt\" \"{version2}\"", new RunnerOptions
                    {
                        LogCommandOnError = false
                    });
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }

            // Make sure dpkg --compare-versions works
            if (!VersionLessThan("1", "2") || VersionLessThan("2", "1"))
            {
                throw new Exception("dpkg --compare-versions appears to not be working.");
            }

            var packageName = "ansible";

            var securityDb = new SecurityDb(database);

            var imageLock = GetImageLock();

            var auditReport = new AuditReport();

            foreach (var package in imageLock.InstalledPackages)
            {
                var sourcePackage = package.Value.Source;
                if (sourcePackage == null || sourcePackage.Name.IsNullOrEmpty() ||
                    sourcePackage.Version.IsNullOrEmpty())
                {
                    continue;
                }

                // Here is a description of how these issues are associated with versions/releases.
                // 1. If a package note has no release, it means that package note applies to all versions.
                // 2. If that package note has a fixed version of "0", it means that it isn't affected.
                // 3. If the package note has a fixed version of null, it means that it is affected (or hasn't been determined yet).
                // Then, if there is a package note for a specific release, it overrides 1-3 on a per-suite level.
                var bugNames = securityDb.GetPackageNotesForPackage(sourcePackage.Name).Select(x => x.BugName).Distinct().ToList();

                foreach (var bugName in bugNames)
                {
                    var packageNote = securityDb.GetPackageNoteForBugInSuite(sourcePackage.Name, bugName, suite);
                    if (packageNote == null)
                    {
                        packageNote = securityDb.GetPackageNoteForBugInAllSuites(sourcePackage.Name, bugName);
                    }

                    if (packageNote == null)
                    {
                        continue;
                    }

                    if (packageNote.FixedVersion == "0")
                    {
                        // Explicitly marked as "not affected!"
                        continue;
                    }

                    void TrackBug()
                    {
                        var auditSourcePackage = auditReport.Sources.SingleOrDefault(x =>
                                                                                     x.Name == sourcePackage.Name && x.Version == sourcePackage.Version);

                        if (auditSourcePackage == null)
                        {
                            auditSourcePackage = new AuditReport.AuditSourcePackage
                            {
                                Name    = sourcePackage.Name,
                                Version = sourcePackage.Version
                            };
                            auditReport.Sources.Add(auditSourcePackage);
                        }
                        auditSourcePackage.Binaries[package.Key] = package.Value.Version;

                        if (auditSourcePackage.Vulnerabilities.Any(x => x.Name == bugName))
                        {
                            return;
                        }

                        var bug     = securityDb.GetBug(packageNote.BugName);
                        var nvdData = securityDb.GetNvdData(bug.Name);

                        var vulnerability = new AuditReport.Vulnerability
                        {
                            Name        = packageNote.BugName,
                            Description = bug.Description,
                            Severity    = packageNote.Urgency
                        };

                        if (nvdData != null)
                        {
                            vulnerability.Description = nvdData.CveDescription;
                            vulnerability.NvdSeverity = nvdData.Severity;
                        }

                        if (vulnerability.Name.StartsWith("DSA") || vulnerability.Name.StartsWith("DLA"))
                        {
                            var references = securityDb.GetReferences(bug.Name);
                            if (references.Count > 0)
                            {
                                vulnerability.References = references;
                            }
                        }

                        vulnerability.FixedVersion = packageNote.FixedVersion;
                        if (string.IsNullOrEmpty(vulnerability.FixedVersion))
                        {
                            vulnerability.FixedVersion = "NONE";
                        }

                        var noDsa = securityDb.GetNoDsaInfoForPackage(sourcePackage.Name, bugName, suite);

                        if (noDsa != null)
                        {
                            vulnerability.NoDsa = new AuditReport.NoDsa
                            {
                                Comment = string.IsNullOrEmpty(noDsa.Comment) ? null : noDsa.Comment,
                                Reason  = string.IsNullOrEmpty(noDsa.Reason) ? null : noDsa.Reason
                            };
                        }

                        var bugNotes = securityDb.GetBugNotes(bug.Name);

                        var notes        = new List <string>();
                        var packageRegex = new Regex(@"^(?:\[([a-z]+)\]\s)?-\s([A-Za-z0-9:.+-]+)\s+<([a-z-]+)>\s*(?:\s\((.*)\))?$", RegexOptions.Compiled);

                        foreach (var bugNote in bugNotes)
                        {
                            var match = packageRegex.Match(bugNote.Comment);
                            if (match.Success)
                            {
                                continue;
                            }

                            notes.Add(bugNote.Comment);
                        }

                        if (notes.Count > 0)
                        {
                            vulnerability.Notes = notes;
                        }

                        auditSourcePackage.Vulnerabilities.Add(vulnerability);
                    }

                    if (string.IsNullOrEmpty(packageNote.FixedVersion))
                    {
                        // Marked as affected, with no fixed version.
                        TrackBug();
                    }
                    else
                    {
                        // Has a fixed version.
                        if (VersionLessThan(package.Value.Version.Version, packageNote.FixedVersion))
                        {
                            // And we don't have it!
                            TrackBug();
                        }
                    }
                }
            }

            var file = Path.Combine(_workspaceConfig.RootDirectory, "debian-audit.json");

            if (File.Exists(file))
            {
                File.Delete(file);
            }
            File.WriteAllText(file, JsonConvert.SerializeObject(auditReport, _jsonSerializerSettings));
        }
Exemplo n.º 15
0
        private void AuditLogPrintBt_Click(object sender, EventArgs e)
        {
            var form = new AuditReport();

            form.ShowDialog(this);
        }
Exemplo n.º 16
0
        public override int SaveChanges()
        {
            List <AuditReport> tAuditReport = new List <AuditReport>();

            foreach (var tEntry in ChangeTracker.Entries())
            {
                if ((tEntry.State == EntityState.Added || tEntry.State == EntityState.Modified || tEntry.State == EntityState.Deleted) && tEntry.Entity is IAuditedEntity)
                {
                    string entityName    = tEntry.Entity.GetType().Name;
                    string entityType    = tEntry.State.ToString();
                    var    tempKeyEntity = tEntry.Entity.GetType().GetProperties().Where(x => x.CustomAttributes.Where(y => y.AttributeType.Name == "KeyAttribute").Count() > 0).FirstOrDefault();
                    string primaryKey    = "0";

                    if (tempKeyEntity != null && tEntry.State != EntityState.Added)
                    {
                        primaryKey = tempKeyEntity.GetValue(tEntry.Entity).ToString();
                    }

                    if (tEntry.State == EntityState.Deleted)
                    {
                        AuditReport tReport = new AuditReport()
                        {
                            PrimaryKey = primaryKey,
                            EntityName = entityName,
                            Type       = entityType
                        };
                        tAuditReport.Add(tReport);
                    }
                    else
                    {
                        foreach (var prop in tEntry.Properties)
                        {
                            if (tEntry.State == EntityState.Modified && prop.CurrentValue.ToString() == prop.OriginalValue.ToString())
                            {
                                continue;
                            }

                            AuditReport tReport = new AuditReport()
                            {
                                PrimaryKey = primaryKey,
                                EntityName = entityName,
                                Type       = entityType,
                                NewValue   = prop.CurrentValue.ToString(),
                                Column     = prop.Metadata.Name
                            };

                            if (tEntry.State == EntityState.Modified)
                            {
                                tReport.OldValue = prop.OriginalValue.ToString();
                            }

                            tAuditReport.Add(tReport);
                        }
                    }
                }

                if (tEntry.State == EntityState.Added)
                {
                    if (tEntry.Entity is IAuditedEntity)
                    {
                        IAuditedEntity tempEntity = (IAuditedEntity)tEntry.Entity;

                        tempEntity.AddedBy   = 1;
                        tempEntity.AddedDate = DateTime.Now;
                    }
                }
                else if (tEntry.State == EntityState.Modified)
                {
                    if (tEntry.Entity is IAuditedEntity)
                    {
                        IAuditedEntity tempEntity = (IAuditedEntity)tEntry.Entity;

                        tempEntity.UpdatedBy  = 1;
                        tempEntity.UpdateDate = DateTime.Now;
                    }
                }
                else if (tEntry.State == EntityState.Deleted)
                {
                    tEntry.Reload();
                    tEntry.State = EntityState.Modified;

                    if (tEntry.Entity is ISoftDelete)
                    {
                        IAuditedEntity tempEntity = (IAuditedEntity)tEntry.Entity;
                        tempEntity.DeletedBy   = 1;
                        tempEntity.DeletedDate = DateTime.Now;

                        ISoftDelete softDeleteEntity = (ISoftDelete)tEntry.Entity;
                        tempEntity.IsDeleted = true;
                    }
                }
            }

            AuditReport.AddRange(tAuditReport);
            return(base.SaveChanges());
        }
Exemplo n.º 17
0
 protected void btn_edit_Click(object sender, EventArgs e)
 {
     try
     {
         AuditReportService reportBSO = new AuditReportService();
         AuditReport        report    = new AuditReport();
         report = reportBSO.FindByKey(ReportId);
         if (report != null)
         {
             report.EnterpriseId         = Convert.ToInt32(memVal.OrgId);
             report.AuditYear            = Convert.ToInt32(ddlAuditYear.SelectedValue);
             report.DataYear             = Convert.ToInt32(ddlDataYear.SelectedValue);
             report.AuditConsultancyName = txtAuditConsultant.Text.Trim();
             report.Address       = txtAddress.Text.Trim();
             report.AuditorName   = txtAuditor.Text.Trim();
             report.AuditingScope = txtAuditScope.Text.Trim();
             report.ShiftNo       = Convert.ToInt32(rbtShiftNo.SelectedValue);
             report.AuditorCode   = txtAuditorCode.Text.Trim();
             report.TaxNo         = txtMST.Text.Trim();
             report.Id            = ReportId;
             string strPath     = Server.MapPath("~/UserFile/Report/");
             string strFilename = "";
             if (fAttach.HasFile)
             {
                 Random rand = new Random();
                 strFilename = memVal.UserName + "_BCKT_" + AuditYearReport + "_" + rand.Next(100) + System.IO.Path.GetExtension(fAttach.FileName).ToLower();
                 if (System.IO.File.Exists(strPath + strFilename))
                 {
                     strFilename = memVal.UserName + "_BCKT_" + AuditYearReport + "_" + rand.Next(100) + System.IO.Path.GetExtension(fAttach.FileName).ToLower();
                 }
                 fAttach.PostedFile.SaveAs(strPath + strFilename);
                 ReportAttachFile reportAtt = new ReportAttachFile();
                 reportAtt.ReportId   = ReportId;
                 reportAtt.PathFile   = strFilename;
                 reportAtt.Created    = DateTime.Now;
                 reportAtt.ActionName = "DN đã gửi kèm file báo cáo";
                 reportAtt.Comment    = txtContent.Text;
                 reportAtt.UserId     = memVal.UserId;
                 reportAtt.UserName   = memVal.UserName;
                 reportAtt.ReportType = Convert.ToInt32(LogType.AUDITREPORT);
                 new ReportAttachFileService().Insert(reportAtt);
             }
             report.PathFile = strFilename;
             if (reportBSO.Update(report) != null)
             {
                 clientview.Text = "<div class='alert alert-sm alert-success bg-gradient'>Cập nhật Thành công !</div>";
                 BindInfoLabel();
                 lbtDownload.Text = strFilename;
                 ltAttach.Text    = strFilename;
             }
             else
             {
                 clientview.Text = "<div class='alert alert-sm alert-danger bg-gradient'>Cập nhật không Thành công !</div>";
             }
         }
     }
     catch (Exception ex)
     {
         log.Error("Loi khong cap nhat duoc bao cao: ", ex);
     }
 }
Exemplo n.º 18
0
        static AuditReport GenerateReport(Type viewType, Type handler)
        {
            var report = new AuditReport
            {
                View    = viewType.Name,
                Handler = handler.FullName,
            };

            if (viewType.BaseType != null)
            {
                var baseHandler = Registrar.Handlers.GetRendererType(viewType);
                if (baseHandler != null)
                {
                    var baseReport = GenerateReport(viewType.BaseType, baseHandler);
                    foreach (var p in baseReport.HandledProperties)
                    {
                        if (!report.HandledProperties.Contains(p))
                        {
                            report.HandledProperties.Add(p);
                        }
                    }
                    foreach (var p in baseReport.UnHandledProperties)
                    {
                        if (!report.UnHandledProperties.Contains(p))
                        {
                            report.UnHandledProperties.Add(p);
                        }
                    }
                }
            }


            WatchedProperties.TryGetValue(viewType, out var watchedProps);

            var mapper = handler.GetField("Mapper", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);

            if (mapper != null)
            {
                var map         = mapper.GetValue(null);
                var mapKeysProp = map.GetType().GetProperty("Keys", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
                var keys        = (mapKeysProp.GetValue(map) as IEnumerable <string>).ToList();

                if (watchedProps != null)
                {
                    foreach (var prop in watchedProps)
                    {
                        if (keys.Contains(prop))
                        {
                            if (!report.HandledProperties.Contains(prop))
                            {
                                report.HandledProperties.Add(prop);
                            }
                            if (report.UnHandledProperties.Contains(prop))
                            {
                                report.UnHandledProperties.Remove(prop);
                            }
                        }
                        else if (!report.HandledProperties.Contains(prop))
                        {
                            report.UnHandledProperties.Add(prop);
                        }
                    }
                }
                foreach (var key in keys)
                {
                    if (!report.HandledProperties.Contains(key))
                    {
                        report.HandledProperties.Contains(key);
                    }
                }
            }
            else
            {
                if (watchedProps != null)
                {
                    foreach (var prop in watchedProps)
                    {
                        if (!report.HandledProperties.Contains(prop))
                        {
                            report.UnHandledProperties.Add(prop);
                        }
                    }
                }
                report.MissingMapper = true;
            }
            report.HandledProperties   = report.HandledProperties.Distinct().ToList();
            report.UnHandledProperties = report.UnHandledProperties.Distinct().ToList();
            return(report);
        }
Exemplo n.º 19
0
    private void BindReportInfo()
    {
        if (ReportId > 0)
        {
            btn_edit2.Visible = true;
            AllowEdit         = true;
            try
            {
                AuditReport        report    = new AuditReport();
                AuditReportService reportBSO = new AuditReportService();
                report = reportBSO.FindByKey(ReportId);
                if (report != null)
                {
                    if (memVal.OrgId > 0)
                    {
                        Enterprise enter = new EnterpriseService().FindByKey((memVal.OrgId));
                        if (enter != null)
                        {
                            ucEnergyConsume.CustomerCode = enter.CustomerCode;
                        }
                    }
                    if (report.Status == 0 || report.Status == 2)
                    {
                        AllowEdit = true;
                    }
                    else
                    {
                        AllowEdit = false;
                    }
                    btnAddPlan.Visible = btnSaveEquipment.Visible = btnEditBasicInfo.Visible = btnSend.Visible = btn_edit2.Visible = AllowEdit;

                    txtAuditConsultant.Text    = report.AuditConsultancyName;
                    txtAddress.Text            = report.Address;
                    txtAuditor.Text            = report.AuditorName;
                    txtAuditScope.Text         = report.AuditingScope;
                    rbtShiftNo.SelectedValue   = report.ShiftNo.ToString();
                    ddlAuditYear.SelectedValue = report.AuditYear.ToString();
                    ddlDataYear.SelectedValue  = report.DataYear.ToString();
                    txtAuditorCode.Text        = report.AuditorCode;
                    txtMST.Text = report.TaxNo;
                    if (report.PathFile != "")
                    {
                        lbtDownload.Text    = report.PathFile;
                        lbtDownload.Visible = true;
                        ltAttach.Text       = report.PathFile;
                    }
                    else
                    {
                        lbtDownload.Visible = false;
                        ltAttach.Text       = "Chọn file đính kèm";
                    }

                    ucElectrictSystem.ReportYear = report.AuditYear;
                    ucElectrictSystem.AllowEdit  = AllowEdit;
                    ucElectrictSystem.ReportId   = ReportId;

                    ucAuditSolution.ReportYear = report.AuditYear;
                    ucAuditSolution.AllowEdit  = AllowEdit;
                    ucAuditSolution.ReportId   = ReportId;

                    ucAuditProduct.ReportYear = report.AuditYear;
                    ucAuditProduct.AllowEdit  = AllowEdit;
                    ucAuditProduct.ReportId   = ReportId;

                    ucAuditOperationArea.ReportYear = report.AuditYear;
                    ucAuditOperationArea.AllowEdit  = AllowEdit;
                    ucAuditOperationArea.ReportId   = ReportId;

                    ucEnergyConsume.ReportYear = report.AuditYear;
                    ucEnergyConsume.AllowEdit  = AllowEdit;
                    ucEnergyConsume.ReportId   = ReportId;

                    ucEnergyQuota.ReportYear = report.AuditYear;
                    ucEnergyQuota.AllowEdit  = AllowEdit;
                    ucEnergyQuota.ReportId   = ReportId;

                    ucAuditDevice.ReportYear = report.AuditYear;
                    ucAuditDevice.AllowEdit  = AllowEdit;
                    ucAuditDevice.ReportId   = ReportId;

                    if (memVal.OrgId > 0 && report.EnterpriseId != memVal.OrgId)//Neu
                    {
                        Response.Redirect(ResolveUrl("~"));
                    }
                    AuditYearReport  = report.AuditYear;
                    ltAuditYear.Text = AuditYearReport.ToString();
                    BindInfoLabel();
                }
            }
            catch (Exception ex)
            {
                clientview.Text = ex.Message.ToString();
            }
        }
    }