Exemplo n.º 1
0
        public void WriteLine(ILogItem item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            var level = item.LogLevel;
            var message = item.Message;
            var phase = item.Phase;
            var file = item.File;
            var line = item.Line;
            if (level < LogLevelThreshold) return;

            var reportItem = new ReportItem
            {
                Severity = GetSeverity(level),
                Message = message,
                Source = phase,
                File = file,
                Line = line,
                DateTime = DateTime.UtcNow
            };

            _writer.WriteLine(JsonUtility.Serialize(reportItem));
        }
Exemplo n.º 2
0
        public void Equality()
        {
            var same = new ReportItem(123, false);
            var same2 = new ReportItem(123, false);
            var different = new ReportItem(456, false);

            Assert.IsTrue(same.Equals(same2));
            Assert.IsFalse(same.Equals(different));

            Assert.IsTrue(same == same2);
            Assert.IsTrue(same != different);

            Assert.AreEqual(same.GetHashCode(), same2.GetHashCode());
            Assert.AreNotEqual(same.GetHashCode(), different.GetHashCode());
        }
Exemplo n.º 3
0
        private static MachineState EmulateOpcode(ICollection<ReportItem> reportItems,
            MachineState machineState,
            Byte[] code)
        {
            var state = machineState;
            RegisterName sourceRegister, destinationRegister;
            AbstractValue sourceValue;
            Int32 index;

            var encoding = opcode.GetEncodingFor(code);
            var op = opcode.GetOperatorEffectFor(code);

            switch (encoding)
            {
                case OpcodeEncoding.rAxIv:
                case OpcodeEncoding.rAxIz:
                {
                    destinationRegister = opcode.GetDestinationRegisterFor(code);
                    var immediate = opcode.GetImmediateFor(code);
                    state = state.DoOperation(destinationRegister, op, new AbstractValue(immediate));
                    return state;
                }

                case OpcodeEncoding.rAxOv:
                {
                    state.Registers[RegisterName.EAX] = state.DataSegment[BitMath.BytesToDword(code, 1)];
                    return state;
                }

                case OpcodeEncoding.rBP:
                case OpcodeEncoding.rSI:
                case OpcodeEncoding.rSP:
                case OpcodeEncoding.rAX:
                case OpcodeEncoding.rBX:
                case OpcodeEncoding.rCX:
                case OpcodeEncoding.rDX:
                case OpcodeEncoding.Iz:
                {
                    return emulateStackEffectFor(code, state);
                }

                case OpcodeEncoding.EvIz:
                case OpcodeEncoding.EvIb:
                case OpcodeEncoding.EbIb:
                case OpcodeEncoding.EvGv:
                case OpcodeEncoding.EbGb:
                {
                    destinationRegister = opcode.GetDestinationRegisterFor(code);
                    index = 0;

                    if (ModRM.HasIndex(code))
                    {
                        index = ModRM.GetIndexFor(code);
                    }

                    if (opcode.HasImmediate(code))
                    {
                        sourceValue = new AbstractValue(opcode.GetImmediateFor(code));
                    }
                    else
                    {
                        sourceRegister = ModRM.GetGvFor(code);
                        sourceValue = state.Registers[sourceRegister];
                    }

                    ////if (ModRM.HasOffset(code))
                    ////{
                    ////    UInt32 offset = ModRM.GetOffsetFor(code);
                    ////    state.DataSegment[offset] = sourceValue;
                    ////    return state;
                    ////}

                    if (ModRM.IsEffectiveAddressDereferenced(code))
                    {
                        if (!state.Registers[destinationRegister].IsPointer)
                        {
                            throw new InvalidOperationException(
                                "Trying to dereference non-pointer in register " + destinationRegister
                                );
                        }

                        state = state.DoOperation(destinationRegister, index, op, sourceValue);
                        if (state.Registers[destinationRegister].PointsTo[index].IsOutOfBounds)
                        {
                            reportItems.Add(new ReportItem(state.InstructionPointer, sourceValue.IsTainted));
                        }
                    }
                    else
                    {
                        state = state.DoOperation(destinationRegister, op, sourceValue);
                        if (state.Registers[destinationRegister].IsOutOfBounds)
                        {
                            reportItems.Add(new ReportItem(state.InstructionPointer, sourceValue.IsTainted));
                        }
                    }

                    return state;
                }

                case OpcodeEncoding.GvEv:
                case OpcodeEncoding.GvEb:
                {
                    sourceRegister = ModRM.GetEvFor(code);
                    destinationRegister = ModRM.GetGvFor(code);
                    sourceValue = state.Registers[sourceRegister];

                    if (ModRM.HasOffset(code))
                    {
                        var offset = ModRM.GetOffsetFor(code);
                        sourceValue = state.DataSegment[offset];
                    }
                    else if (ModRM.IsEffectiveAddressDereferenced(code))
                    {
                        if (!sourceValue.IsPointer)
                        {
                            throw new InvalidOperationException(
                                String.Format("Trying to dereference null pointer in register {0}.", sourceRegister));
                        }

                        index = 0;

                        if (ModRM.HasIndex(code))
                        {
                            index = ModRM.GetIndexFor(code);
                        }

                        sourceValue = sourceValue.PointsTo[index];

                        if (sourceValue.IsOutOfBounds)
                        {
                            reportItems.Add(new ReportItem(state.InstructionPointer, sourceValue.IsTainted));
                        }
                    }

                    state = state.DoOperation(destinationRegister, op, sourceValue);
                    return state;
                }

                case OpcodeEncoding.GvM:
                {
                    // GvM, M may refer to [base register + offset]
                    if (!ModRM.IsEffectiveAddressDereferenced(code))
                    {
                        throw new InvalidOperationException("GvM must be dereferenced");
                    }

                    destinationRegister = opcode.GetDestinationRegisterFor(code);
                    AbstractValue baseRegisterValue;
                    index = 0;

                    // TODO: handle the [dword] special case
                    if (ModRM.HasSIB(code))
                    {
                        var scaledRegisterValue = state.Registers[SIB.GetScaledRegister(code)].Value;
                        var scaler = SIB.GetScaler(code);
                        baseRegisterValue = state.Registers[SIB.GetBaseRegister(code)];
                        index = (Int32)(scaledRegisterValue * scaler);
                    }
                    else
                    {
                        sourceRegister = ModRM.GetEvFor(code);
                        if (ModRM.HasIndex(code))
                        {
                            index = ModRM.GetIndexFor(code);
                        }

                        baseRegisterValue = state.Registers[sourceRegister];
                    }

                    // TODO: review these casts of index for possible elimination
                    sourceValue = new AbstractValue(
                        baseRegisterValue.PointsTo.DoOperation(
                            OperatorEffect.Add,
                            new AbstractValue((UInt32)index)
                            )
                        );

                    state = state.DoOperation(destinationRegister, OperatorEffect.Assignment, sourceValue);
                    if (state.Registers[destinationRegister].IsOutOfBounds)
                    {
                        var reportItem = new ReportItem(state.InstructionPointer, sourceValue.IsTainted);
                        reportItems.Add(reportItem);
                    }

                    return state;
                }

                case OpcodeEncoding.ObAL:
                {
                    var dwordValue = state.Registers[RegisterName.EAX];
                    var byteValue = dwordValue.TruncateValueToByte();
                    var offset = BitMath.BytesToDword(code, 1);

                    if (!state.DataSegment.ContainsKey(offset))
                    {
                        state.DataSegment[offset] = new AbstractValue();
                    }

                    state = state.DoOperation(offset, op, byteValue);
                    return state;
                }

                case OpcodeEncoding.Jz:
                {
                    // TODO: should push EIP + code.Length onto stack
                    var contractSatisfied = false;
                    var mallocContract = new MallocContract();
                    var glibcStartMainContract = new GLibcStartMainContract();
                    var contracts = new List<Contract>
                                    {
                                        mallocContract,
                                        glibcStartMainContract
                                    };

                    foreach (var contract in contracts)
                    {
                        if (contract.IsSatisfiedBy(state, code))
                        {
                            contractSatisfied = true;
                            state = contract.Execute(state);
                        }
                    }

                    if (!contractSatisfied)
                    {
                        var returnAddress = state.InstructionPointer + (UInt32)code.Length;
                        state = state.PushOntoStack(new AbstractValue(returnAddress));
                        state.InstructionPointer = opcode.GetEffectiveAddress(code, state.InstructionPointer);
                    }

                    return state;
                }

                case OpcodeEncoding.Jb:
                {
                    var offset = code[1];

                    state = state.DoOperation(op, new AbstractValue(offset));
                    state.InstructionPointer += opcode.GetInstructionLengthFor(code);

                    return state;
                }

                case OpcodeEncoding.None:
                {
                    return state;
                }

                default:
                {
                    throw new InvalidOpcodeException(code);
                }
            }
        }
Exemplo n.º 4
0
 public SprintCardRow(ReportItem workItem)
 {
     WorkItem = workItem;
 }
Exemplo n.º 5
0
 public static string GetResult(ReportItem item)
 {
     return(string.Format("[{0}] in {1}ms", item.Result, (item.EndTime - item.StartTime).Milliseconds));
 }
        public bool RegisterItem(PageItem pageItem, PageContext pageContext)
        {
            if (!this.m_itemFound && pageItem != null)
            {
                switch (this.m_eventType)
                {
                case EventType.Collect:
                {
                    ReportItemInstance instance2 = pageItem.Source.Instance;
                    if (pageContext.Labels != null)
                    {
                        pageContext.Labels.WriteDocMapLabel(instance2);
                    }
                    if (pageContext.Bookmarks != null)
                    {
                        pageContext.Bookmarks.WriteBookmark(instance2);
                    }
                    if (pageContext.PageBookmarks != null)
                    {
                        pageContext.RegisterPageBookmark(instance2);
                    }
                    if (pageItem.ItemState == PageItem.State.OnPageHidden)
                    {
                        break;
                    }
                    return(false);
                }

                case EventType.BookmarkNavigationEvent:
                {
                    ReportItemInstance instance = pageItem.Source.Instance;
                    if (instance.Bookmark != null && SPBProcessing.CompareWithOrdinalComparison(this.m_bookmarkId, instance.Bookmark, false) == 0)
                    {
                        this.m_itemFound = true;
                        this.m_itemInfo  = instance.UniqueName;
                        return(false);
                    }
                    if (pageItem.ItemState == PageItem.State.OnPageHidden)
                    {
                        break;
                    }
                    return(false);
                }

                case EventType.DrillthroughEvent:
                {
                    ReportItemInstance instance5       = pageItem.Source.Instance;
                    TextBoxInstance    textBoxInstance = instance5 as TextBoxInstance;
                    if (textBoxInstance != null)
                    {
                        AspNetCore.ReportingServices.OnDemandReportRendering.TextBox textBox = (AspNetCore.ReportingServices.OnDemandReportRendering.TextBox)pageItem.Source;
                        if (!this.HasMatchingDrillthrough(textBox.ActionInfo))
                        {
                            foreach (ParagraphInstance paragraphInstance in textBoxInstance.ParagraphInstances)
                            {
                                foreach (TextRunInstance textRunInstance in paragraphInstance.TextRunInstances)
                                {
                                    AspNetCore.ReportingServices.OnDemandReportRendering.TextRun definition = textRunInstance.Definition;
                                    if (this.HasMatchingDrillthrough(definition.ActionInfo))
                                    {
                                        return(false);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        ImageInstance imageInstance2 = instance5 as ImageInstance;
                        if (imageInstance2 != null)
                        {
                            if (!this.HasMatchingDrillthrough(imageInstance2.ActionInfoWithDynamicImageMapAreas))
                            {
                                AspNetCore.ReportingServices.OnDemandReportRendering.Image image = (AspNetCore.ReportingServices.OnDemandReportRendering.Image)pageItem.Source;
                                this.HasMatchingDrillthrough(image.ActionInfo);
                            }
                        }
                        else
                        {
                            IDynamicImageInstance dynamicImageInstance = instance5 as IDynamicImageInstance;
                            if (dynamicImageInstance != null)
                            {
                                ActionInfoWithDynamicImageMapCollection imageMaps = default(ActionInfoWithDynamicImageMapCollection);
                                using (dynamicImageInstance.GetImage(DynamicImageInstance.ImageType.PNG, out imageMaps))
                                {
                                }
                                this.HasMatchingDrillthrough(imageMaps);
                            }
                        }
                    }
                    if (this.m_itemFound)
                    {
                        return(false);
                    }
                    if (pageItem.ItemState == PageItem.State.OnPageHidden)
                    {
                        break;
                    }
                    return(false);
                }

                case EventType.DocumentMapNavigationEvent:
                {
                    ReportItemInstance instance3 = pageItem.Source.Instance;
                    if (SPBProcessing.CompareWithOrdinalComparison(this.m_itemInfo, instance3.UniqueName, true) == 0)
                    {
                        this.m_itemFound = true;
                        return(false);
                    }
                    if (pageItem.ItemState == PageItem.State.OnPageHidden)
                    {
                        break;
                    }
                    return(false);
                }

                case EventType.GetDocumentMap:
                {
                    ReportItemInstance instance4 = pageItem.Source.Instance;
                    if (pageContext.Labels != null)
                    {
                        pageContext.Labels.WriteDocMapLabel(instance4);
                    }
                    if (pageItem.ItemState == PageItem.State.OnPageHidden)
                    {
                        break;
                    }
                    return(false);
                }

                case EventType.FindChart:
                    if (pageItem.ItemState != PageItem.State.OnPageHidden)
                    {
                        ReportItem source2 = pageItem.Source;
                        if (SPBProcessing.CompareWithOrdinalComparison(this.m_itemInfo, source2.Instance.UniqueName, true) == 0)
                        {
                            this.m_itemFound = true;
                            ChartInstance chartInstance2 = source2.Instance as ChartInstance;
                            if (chartInstance2 != null)
                            {
                                this.WriteDynamicImageStream(chartInstance2.GetImage());
                            }
                        }
                    }
                    break;

                case EventType.FindGaugePanel:
                    if (pageItem.ItemState != PageItem.State.OnPageHidden)
                    {
                        ReportItem source3 = pageItem.Source;
                        if (SPBProcessing.CompareWithOrdinalComparison(this.m_itemInfo, source3.Instance.UniqueName, true) == 0)
                        {
                            this.m_itemFound = true;
                            GaugePanelInstance gaugePanelInstance2 = source3.Instance as GaugePanelInstance;
                            if (gaugePanelInstance2 != null)
                            {
                                this.WriteDynamicImageStream(gaugePanelInstance2.GetImage());
                            }
                        }
                    }
                    break;

                case EventType.FindMap:
                    if (pageItem.ItemState != PageItem.State.OnPageHidden)
                    {
                        ReportItem source5 = pageItem.Source;
                        if (SPBProcessing.CompareWithOrdinalComparison(this.m_itemInfo, source5.Instance.UniqueName, true) == 0)
                        {
                            this.m_itemFound = true;
                            MapInstance mapInstance2 = source5.Instance as MapInstance;
                            if (mapInstance2 != null)
                            {
                                this.WriteDynamicImageStream(mapInstance2.GetImage());
                            }
                        }
                    }
                    break;

                case EventType.FindImage:
                    if (pageItem.ItemState != PageItem.State.OnPageHidden)
                    {
                        ReportItem source4 = pageItem.Source;
                        if (SPBProcessing.CompareWithOrdinalComparison(this.m_itemInfo, source4.Instance.UniqueName, true) == 0)
                        {
                            this.m_itemFound = true;
                            ImageInstance imageInstance = source4.Instance as ImageInstance;
                            if (imageInstance != null)
                            {
                                Stream stream2   = this.m_createAndRegisterStream(this.m_streamName, string.Empty, null, imageInstance.MIMEType, false, StreamOper.CreateAndRegister);
                                byte[] imageData = imageInstance.ImageData;
                                if (stream2 != null && imageData != null && imageData.Length != 0)
                                {
                                    stream2.Write(imageData, 0, imageData.Length);
                                }
                            }
                        }
                    }
                    break;

                case EventType.ImageConsolidation:
                    if (pageItem.ItemState != PageItem.State.OnPageHidden)
                    {
                        ReportItem         source             = pageItem.Source;
                        GaugePanelInstance gaugePanelInstance = source.Instance as GaugePanelInstance;
                        Stream             stream             = null;
                        if (gaugePanelInstance != null)
                        {
                            stream = gaugePanelInstance.GetImage();
                        }
                        else
                        {
                            ChartInstance chartInstance = source.Instance as ChartInstance;
                            if (chartInstance != null)
                            {
                                stream = chartInstance.GetImage();
                            }
                            else
                            {
                                MapInstance mapInstance = source.Instance as MapInstance;
                                if (mapInstance != null)
                                {
                                    stream = mapInstance.GetImage();
                                }
                            }
                        }
                        if (stream != null)
                        {
                            ImageConsolidation imageConsolidation = pageContext.ImageConsolidation;
                            imageConsolidation.AppendImage(stream);
                            if (imageConsolidation.CurrentOffset >= imageConsolidation.IgnoreOffsetTill + 1 && imageConsolidation.ImageInfos.Count > 0)
                            {
                                this.m_itemFound = true;
                            }
                        }
                    }
                    break;

                default:
                    this.FindTextBox(pageItem as TextBox, pageContext);
                    break;
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 7
0
 public UnknownCardRow(ReportItem reportItem)
 {
     ReportItem = reportItem;
 }
Exemplo n.º 8
0
        private static int Main(string[] args)
        {
            var recursiveFlag    = SearchOption.TopDirectoryOnly;
            var enableCrossCheck = false;
            var rootFolder       = "";

            foreach (var argument in args)
            {
                if (argument == "-r" || argument == "/r")
                {
                    recursiveFlag = SearchOption.AllDirectories;
                }
                else if (argument == "-c" || argument == "/c")
                {
                    enableCrossCheck = true;
                }
                else if (argument == "-v" || argument == "/v")
                {
                    _verbose = true;
                }
                else if (string.IsNullOrEmpty(rootFolder))
                {
                    rootFolder = argument;
                }
            }

            if (string.IsNullOrEmpty(rootFolder))
            {
                Console.WriteLine("No root folder specified.");
                Console.WriteLine(HelpString);
                return((int)ErrorLevel.MissingRootFolder);
            }

            const string configFileType = "*.config";

            string[] dllFileType = { "*.exe", "*.dll" };
            string[] filesList;

            var outdatedList = new List <ReportItem>();

            //check .config file references
            try
            {
                filesList = Directory.GetFiles(rootFolder, configFileType, recursiveFlag);
            }
            catch (Exception e)
            {
                Console.WriteLine("File search exception: "
                                  + e
                                  + Environment.NewLine
                                  + "Possibly a file system link found.");
                return((int)ErrorLevel.FileSearchError);
            }

            var domain = new AssemblyDomain();

            Parallel.ForEach(filesList, fromFile =>
            {
                var config = new XmlDocument();

                try
                {
                    config.Load(fromFile);
                }
                catch
                {
                    // not XML file, skip it
                    return;
                }

                var assemblyNodes = config.GetElementsByTagName("dependentAssembly");
                if (assemblyNodes.Count <= 0)
                {
                    // no assembly references, skip it
                    return;
                }

                // process each assembly reference in the .config file
                foreach (XmlNode node in assemblyNodes)
                {
                    // get assembly name from config
                    var dllFileNode = node["assemblyIdentity"];
                    if (dllFileNode == null)
                    {
                        // no DLL name fixed in XML, skip it
                        continue;
                    }

                    var dllFileName = "";
                    foreach (XmlAttribute attribute in dllFileNode.Attributes)
                    {
                        if (attribute.Name == "name")
                        {
                            // DLL name tag found in XML
                            dllFileName = attribute.Value;
                            break;
                        }
                    }

                    if (string.IsNullOrEmpty(dllFileName))
                    {
                        // DLL name tag not found in XML, skip it
                        continue;
                    }

                    // get assembly version from config
                    var dllVersionNode = node["bindingRedirect"];
                    if (dllVersionNode == null)
                    {
                        // no DLL version tag found in XML
                        continue;
                    }

                    Version expectedVersion = null;
                    foreach (XmlAttribute attribute in dllVersionNode.Attributes)
                    {
                        if (attribute.Name == "newVersion")
                        {
                            try
                            {
                                expectedVersion = new Version(attribute.Value);
                            }
                            catch
                            {
                            }

                            // DLL version tag found in XML
                            break;
                        }
                    }

                    if (expectedVersion == null)
                    {
                        // DLL version tag not found in XML, skip it
                        continue;
                    }

                    // Get file version.
                    var dllFullFileName = FilePath(fromFile) + dllFileName + ".dll";
                    Version dllVersion;
                    try
                    {
                        dllVersion = AssemblyName.GetAssemblyName(dllFullFileName).Version;
                    }
                    catch
                    {
                        // no such DLL in the folder or error opening it
                        //Console.WriteLine("Can't open file: " + dllPath);
                        continue;
                    }

                    if (dllVersion == null)
                    {
                        // can't get file version, skip it
                        continue;
                    }

                    if (dllVersion < expectedVersion)
                    {
                        var fromFileItem = new FileItem(fromFile, expectedVersion);

                        var rptList = outdatedList.FindAll(x => x.AssemblyFile.FullFileName == dllFullFileName);
                        if (rptList.Count > 1)
                        {
                            Console.WriteLine("Duplicate assembly name in collection: " + dllFullFileName);
                        }

                        if (rptList.Count <= 0)
                        {
                            var rpt = new ReportItem(dllFullFileName, dllVersion);
                            rpt.CalledFromFiles.Add(fromFileItem);
                            outdatedList.Add(rpt);
                        }
                        else if (rptList.Count == 1)
                        {
                            rptList[0].CalledFromFiles.Add(fromFileItem);
                        }
                    }
                }
            });

            // collect folder assembly collection
            var assemblyList = new BlockingCollection <AssemblyInfoItem>();

            foreach (var fileType in dllFileType)
            {
                try
                {
                    filesList = Directory.GetFiles(rootFolder, fileType, recursiveFlag);
                }
                catch (Exception e)
                {
                    Console.WriteLine("File search exception: "
                                      + e
                                      + Environment.NewLine
                                      + "Possibly a file system link found.");
                    return((int)ErrorLevel.FileSearchError);
                }

                var fileNum = filesList.Length;
                foreach (var file in filesList)
                {
                    var newAssembly = domain.GetAssemblyInfo(file);
                    assemblyList.Add(newAssembly);
                    fileNum--;
                }
            }
            domain.Unload();

            var crossList = new List <CrossReportItem>();

            // check references for files grouped by folder
            while (true)
            {
                var activeFiles = assemblyList.Where(x => !x.Processed);
                if (activeFiles == null || !activeFiles.Any())
                {
                    break;
                }

                var currentPath = activeFiles.First().FilePath;
                var folderFiles = assemblyList.Where(x => x.FilePath == currentPath);
                foreach (var srcDllFile in folderFiles)
                {
                    srcDllFile.Processed = true;

                    //check cross-references for different versions
                    if (enableCrossCheck)
                    {
                        var verList = new CrossReportItem(srcDllFile.FullFileName, srcDllFile.FileVersion);
                        foreach (var refFromFile in folderFiles)
                        {
                            if (srcDllFile.FileName == refFromFile.FileName)
                            {
                                continue;
                            }

                            foreach (var referenceItem in refFromFile.ReferenceList)
                            {
                                if (referenceItem.FullFileName == srcDllFile.FileName)
                                {
                                    if (!verList.CalledFromFiles.ContainsKey(referenceItem.FileVersion))
                                    {
                                        verList.CalledFromFiles.Add(referenceItem.FileVersion, refFromFile.FileName);
                                    }
                                }
                            }
                        }

                        if (verList.CalledFromFiles.Count > 1)
                        {
                            crossList.Add(verList);
                        }
                    }

                    if (srcDllFile.ReferenceList == null || srcDllFile.ReferenceList.Count <= 0)
                    {
                        continue;
                    }

                    // check for files with version other than required by caller
                    foreach (var refFile in srcDllFile.ReferenceList)
                    {
                        var foundFiles = folderFiles.Where(x => x.FileName == refFile.FileName);
                        if (foundFiles.Any())
                        {
                            if (foundFiles.Count() > 1)
                            {
                                Console.WriteLine("Duplicate assembly name in collection: " + refFile.FileName);
                            }

                            var element = foundFiles.First();
                            if (element.FileVersion < refFile.FileVersion)
                            {
                                var fromFileItem = new FileItem(srcDllFile.FullFileName, refFile.FileVersion);

                                var rptList = outdatedList.Where(x => x.AssemblyFile.FullFileName == element.FullFileName);
                                if (!rptList.Any())
                                {
                                    var rpt = new ReportItem(element.FullFileName, element.FileVersion);
                                    rpt.CalledFromFiles.Add(fromFileItem);
                                    outdatedList.Add(rpt);
                                }
                                else
                                {
                                    rptList.First().CalledFromFiles.Add(fromFileItem);
                                }
                            }
                        }
                    }
                }
            }

            var errorLevel = ErrorLevel.NoError;

            // generate report to console
            if (crossList.Any())
            {
                Console.WriteLine("Assembly files reference check:");
                errorLevel = ErrorLevel.MultiReference;
                foreach (var reportItem in crossList)
                {
                    Console.WriteLine(reportItem.AssemblyFile + "[" + reportItem.AssemblyFileVersion + "] cross-referenced by:");
                    foreach (var fileItem in reportItem.CalledFromFiles)
                    {
                        Console.WriteLine("\tv."
                                          + fileItem.Key
                                          + " expected by "
                                          + fileItem.Value);
                    }
                }
            }

            // generate batch file to get correct files if any
            if (outdatedList.Count > 0)
            {
                Console.WriteLine("Assembly files reference check:");
                errorLevel = ErrorLevel.RecoverableErrors;
                var currentDir  = "";
                var copyCommand = new StringBuilder();
                foreach (var report in outdatedList)
                {
                    if (report.AssemblyFile.FilePath != currentDir)
                    {
                        currentDir = report.AssemblyFile.FilePath;
                        Console.WriteLine(currentDir + ":");
                    }

                    Console.WriteLine("\t"
                                      + report.AssemblyFile.FileName
                                      + " v."
                                      + report.AssemblyFile.FileVersion
                                      + " outdated");

                    foreach (var refFile in report.CalledFromFiles)
                    {
                        Console.WriteLine("\t\tv."
                                          + refFile.FileVersion
                                          + " expected by "
                                          + refFile.FileName);

                        var correctFile = assemblyList.FirstOrDefault(x => x.FileName == report.AssemblyFile.FileName && x.FileVersion == refFile.FileVersion);
                        if (correctFile != null)
                        {
                            copyCommand.AppendLine("rem v." + correctFile.FileVersion + " => " + report.AssemblyFile.FileVersion);
                            copyCommand.AppendLine("copy " + correctFile.FullFileName + " " + report.AssemblyFile.FullFileName);
                        }
                        else
                        {
                            copyCommand.AppendLine("rem v." + refFile.FileVersion + " => " + report.AssemblyFile.FileVersion);
                            copyCommand.AppendLine("rem copy " + "_from_repository_" + " " + report.AssemblyFile.FullFileName);
                            errorLevel = ErrorLevel.UnRecoverableErrors;
                        }
                    }
                }

                if (copyCommand.Length > 0)
                {
                    File.WriteAllText("fix.bat", copyCommand.ToString());
                }
            }

            return((int)errorLevel);
        }
 public static ReportItem WithReportCode(this ReportItem reportItem, Guid reportCode)
 {
     reportItem.ReportCode = reportCode;
     return(reportItem);
 }
 public static ReportItem WithDataItemCode(this ReportItem reportItem, Guid dataItemCode)
 {
     reportItem.DataItemCode = dataItemCode;
     return(reportItem);
 }
 public static ReportItem WithCode(this ReportItem reportItem, Guid code)
 {
     reportItem.Code = code;
     return(reportItem);
 }
 public static ReportItem WithReportChartSeries(this ReportItem reportItem, ICollection <ReportChartSery> reportChartSeries)
 {
     reportItem.ReportChartSeries = reportChartSeries;
     return(reportItem);
 }
 public static ReportItem WithReportCharts(this ReportItem reportItem, ICollection <ReportChart> reportCharts)
 {
     reportItem.ReportCharts = reportCharts;
     return(reportItem);
 }
 public static ReportItem WithReport(this ReportItem reportItem, Report report)
 {
     reportItem.Report = report;
     return(reportItem);
 }
 public static ReportItem WithFilters(this ReportItem reportItem, ICollection <Filter> filters)
 {
     reportItem.Filters = filters;
     return(reportItem);
 }
Exemplo n.º 16
0
        private void BindReportItem()
        {

            List<FitDemo> checkList = new List<FitDemo>();

            foreach (FitDemo item in TestList)
            {
                if (item.IsChecked == true)
                {
                    checkList.Add(item);
                }
            }

            List<EvaluteDetail> list;
            List<EvaluteDetail> listTemp = null;

            if (cbAvg.IsChecked.HasValue && cbAvg.IsChecked.Value)
            {
                if (cbMode.SelectedItem == null || ((ComboBoxItem)cbMode.SelectedItem).Tag.ToString() == "0")
                {
                    listTemp = (from od in MySession.Query<EvaluteDetail>()
                                where od.PatientID == ModuleConstant.PatientId
                                select od).OrderByDescending(x => x.EvaluteDetailDate).ToList();
                }
                else
                {
                    listTemp = (from od in MySession.Query<EvaluteDetail>()
                                where od.PatientID == ModuleConstant.PatientId
                                 && od.ActionId == Convert.ToInt32(((ComboBoxItem)cbMode.SelectedItem).Tag)
                                select od).OrderByDescending(x => x.EvaluteDetailDate).ToList();
                }

                #region 计算平均值


                //计算平均值
                Dictionary<int, float> temp = new Dictionary<int, float>();
                Dictionary<int, float> templast = new Dictionary<int, float>();
                Dictionary<int, float> tempFatigueIndex = new Dictionary<int, float>();
                for (int i = 0; i < listTemp.Count(); i++)
                {
                    if (temp.ContainsKey(listTemp[i].ActionId))
                    {
                        temp[listTemp[i].ActionId] = (temp[listTemp[i].ActionId] + listTemp[i].MaxV) / 2;
                        templast[listTemp[i].ActionId] = (templast[listTemp[i].ActionId] + listTemp[i].LastValue) / 2;
                        tempFatigueIndex[listTemp[i].ActionId] = (tempFatigueIndex[listTemp[i].ActionId] + listTemp[i].FatigueIndex) / 2;
                    }
                    else
                    {
                        temp[listTemp[i].ActionId] = listTemp[i].MaxV;
                        templast[listTemp[i].ActionId] = listTemp[i].LastValue;
                        tempFatigueIndex[listTemp[i].ActionId] = listTemp[i].FatigueIndex;
                    }
                }
                #endregion

                #region 赋值


                //赋值
                list = new List<EvaluteDetail>();
                foreach (var item in temp)
                {
                    EvaluteDetail ed = new EvaluteDetail();
                    ed.ActionId = item.Key;
                    ed.MaxV = item.Value;
                    ed.LastValue = templast[item.Key];
                    ed.FatigueIndex = tempFatigueIndex[item.Key];
                    ed.EvaluteDetailDate = DateTime.MinValue;
                    list.Add(ed);
                }
            }
            else
            {
                if (cbMode.SelectedItem == null || ((ComboBoxItem)cbMode.SelectedItem).Tag.ToString() == "0")
                {

                    list = (from od in MySession.Query<EvaluteDetail>()
                            where od.PatientID == ModuleConstant.PatientId
                            select od).OrderByDescending(x => x.EvaluteDetailDate).ToList();
                }
                else
                {
                    list = (from od in MySession.Query<EvaluteDetail>()
                            where od.PatientID == ModuleConstant.PatientId
                             && od.ActionId == Convert.ToInt32(((ComboBoxItem)cbMode.SelectedItem).Tag)
                            select od).OrderByDescending(x => x.EvaluteDetailDate).ToList();


                }
            }
            list = (from od in list
                    join q in checkList on GetDate(od.EvaluteDate) equals q.DayTime
                    select od).ToList();
                #endregion


            #region ROM赋值

            if (checkList.Count > 0)
            {
                foreach (FitDemo item in checkList)
                {
                    ReportItem reportItem = new ReportItem();
                    reportItem.Explosiveforce = GetROM(list, EvaluateActionEnum.RangeProtrusive, item.DayTime);
                    reportItem.Endurance = GetROM(list, EvaluateActionEnum.RangeBend, item.DayTime);
                    reportItem.Fatigueindex = GetROM(list, EvaluateActionEnum.RotationRangeLeft, item.DayTime);
                    reportItem.FitTime = GetROM(list, EvaluateActionEnum.RotationRangeRight, item.DayTime);
                    reportItem.ROMTime = Convert.ToDateTime(item.DayTime).ToString("yyyyMMdd");
                    List5.Add(reportItem);
                }
            }
            #endregion


            foreach (EvaluteDetail item in list)
            {
                ReportItem reportItem = new ReportItem();
                reportItem.ItemID = item.EvaluteDetailId.ToString();
                reportItem.Explosiveforce = item.MaxV.ToString();
                reportItem.Endurance = item.LastValue.ToString();
                reportItem.Fatigueindex = item.FatigueIndex.ToString();
                reportItem.FitTime = Convert.ToDateTime(item.EvaluteDetailDate).ToString("yyyyMMdd");

                if (item.ActionId == (int)EvaluateActionEnum.StrengthProtrusive)
                {
                    List1.Add(reportItem);
                }
                if (item.ActionId == (int)EvaluateActionEnum.StrengthBend)
                {
                    List2.Add(reportItem);
                }
                if (item.ActionId == (int)EvaluateActionEnum.RotationStrengthLeft)
                {
                    List3.Add(reportItem);
                }
                if (item.ActionId == (int)EvaluateActionEnum.RotationStrengthRigth)
                {
                    List4.Add(reportItem);
                }

            }
        }
Exemplo n.º 17
0
        public void WriteFormatedValue(PointInfo startPoint, PointInfo endPoint, ReportItem reportItem)
        {
            #region Variable Definition
            object[] cell = null;
            object startCell = null;
            object endCell = null;
            #endregion

            cell = this.ConvertPointToCell(startPoint, endPoint);
            startCell = cell[0];
            endCell = cell[1];

            objRange = CurSheet.get_Range(startCell, endCell);

            if (startCell.ToString() != endCell.ToString())
            {
                objRange.Merge(mValue);
            }

            switch (reportItem.ContentAlignment)
            {
                case HorizontalAlignment.Center:
                    objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                    break;
                case HorizontalAlignment.Left:
                    objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft;
                    break;
                case HorizontalAlignment.Right:
                    objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignRight;
                    break;
                default:
                    objRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft;
                    break;
            }

            if (reportItem.GetType().Name == "ReportConstantItem")
            {
                switch (((ReportConstantItem)reportItem).Style)
                {
                    case ReportConstantItem.StyleType.PageIndex:
                    case ReportConstantItem.StyleType.PageIndexAndTotalPageCount:
                        if (reportItem.Format == String.Empty)
                        {
                            objRange.Value2 = String.Format(reportItem.Format, "'" + reportItem.Value);
                        }
                        else
                        {
                            objRange.Value2 = String.Format(reportItem.Format, reportItem.Value);
                        }
                        break;
                    default:
                        objRange.Value2 = String.Format(reportItem.Format, reportItem.Value);
                        break;
                }
            }
            else
            {
                objRange.Value2 = String.Format(reportItem.Format, reportItem.Value);
            }
        }
 public static ReportItem WithIsColumnTotal(this ReportItem reportItem, Boolean isColumnTotal)
 {
     reportItem.IsColumnTotal = isColumnTotal;
     return(reportItem);
 }
 public static ReportItem WithDataItem(this ReportItem reportItem, DataItem dataItem)
 {
     reportItem.DataItem = dataItem;
     return(reportItem);
 }
 public static ReportItem WithIsFilter(this ReportItem reportItem, Boolean isFilter)
 {
     reportItem.IsFilter = isFilter;
     return(reportItem);
 }
 public ProductBacklogItemCardRow(ReportItem workItem)
 {
     WorkItem = workItem;
 }
 public static ReportItem WithSortField(this ReportItem reportItem, Int32 sortField)
 {
     reportItem.SortField = sortField;
     return(reportItem);
 }
Exemplo n.º 23
0
 public ImpedimentCardRow(ReportItem workItem)
 {
     WorkItem = workItem;
 }
 public static ReportItem WithIsChartField(this ReportItem reportItem, Boolean isChartField)
 {
     reportItem.IsChartField = isChartField;
     return(reportItem);
 }
Exemplo n.º 25
0
 public BugCardRow(ReportItem workItem)
 {
     WorkItem = workItem;
 }
Exemplo n.º 26
0
 /// <summary>
 /// Creates the editor for <see cref="DesignTextStyle"/>.
 /// </summary>
 public DesignTextStyleEditor(IServiceProvider serviceProvider, object objectItem, ReportItem reportItem, PropertyDescriptor reportItemDescriptor, PropertyDescriptor designTextStyleProperty)
     : this(serviceProvider, objectItem, designTextStyleProperty)
 {         // supports composite style properties
     _reportItem           = reportItem;
     _reportItemDescriptor = reportItemDescriptor;
 }
Exemplo n.º 27
0
 public async Task OnPostAsync(ReportItem newItem)
 {
     _context.ReportItem.Add(newItem);
     await _context.SaveChangesAsync();
 }
 public ReportItemVisibility(ReportItem owner)
 {
     this.m_owner = owner;
 }
Exemplo n.º 29
0
        private void AddInitialData(ModelBuilder builder)
        {
            int counter = 0;
            var doctor  = new Employee()
            {
                Id = ++counter, FirstName = "The", LastName = "Doctor", ManagerId = 0, Position = PositionType.Manager, ImgUrl = "https://4.bp.blogspot.com/-tWGJ-aN1PxE/WNoH4DOOYNI/AAAAAAAAVcc/7B9s7OCcDRoSI5xugYKdz2sbxKFZQRCvQCPcB/s1600/Season%2B4%2Bpromo%2B5a.jpg"
            };
            var sherlock = new Employee()
            {
                Id = ++counter, FirstName = "Sherlock", LastName = "Holmes", ManagerId = doctor.Id, Position = PositionType.Manager, ImgUrl = "https://www.fjackets.com/product_images/a/723/Benedict_Cumberbatch_Sherlock_Coat__78001_zoom.jpg"
            };
            var john = new Employee()
            {
                Id = ++counter, FirstName = "John", LastName = "Oliver", ManagerId = doctor.Id, Position = PositionType.Manager, ImgUrl = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/John_Oliver_November_2016.jpg/220px-John_Oliver_November_2016.jpg"
            };
            var matt = new Employee()
            {
                Id = ++counter, FirstName = "Matt", LastName = "Damon", ManagerId = sherlock.Id, Position = PositionType.Employee, ImgUrl = "https://musicimage.xboxlive.com/catalog/video.movie.8D6KGX06TZQG/image?locale=en-us&mode=crop&purposes=BoxArt&q=90&h=225&w=150&format=jpg"
            };
            var chris = new Employee()
            {
                Id = ++counter, FirstName = "Chris", LastName = "Pratt", ManagerId = john.Id, Position = PositionType.Employee, ImgUrl = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSlLhjtiYwT4jd3tWyuFS6Rfp7u0rTKEw8s10VXNq7gXYkxkG_s"
            };
            var will = new Employee()
            {
                Id = ++counter, FirstName = "Will", LastName = "Smith", ManagerId = john.Id, Position = PositionType.Employee, ImgUrl = "http://cdn01.cdn.justjared.com/wp-content/uploads/headlines/2011/12/men-in-black-3.jpg"
            };
            var forrest = new Employee()
            {
                Id = ++counter, FirstName = "Forrest", LastName = "Gump", ManagerId = john.Id, Position = PositionType.Employee, ImgUrl = "https://ksassets.timeincuk.net/wp/uploads/sites/55/2019/03/forrest-920x584.png"
            };

            builder.Entity <Employee>().HasData(new
            {
                doctor.Id,
                doctor.FirstName,
                doctor.LastName,
                doctor.ManagerId,
                doctor.Position,
                doctor.ImgUrl
            }, new
            {
                sherlock.Id,
                sherlock.FirstName,
                sherlock.LastName,
                sherlock.ManagerId,
                sherlock.Position,
                sherlock.ImgUrl
            }, new
            {
                john.Id,
                john.FirstName,
                john.LastName,
                john.ManagerId,
                john.Position,
                john.ImgUrl
            }, new
            {
                matt.Id,
                matt.FirstName,
                matt.LastName,
                matt.ManagerId,
                matt.Position,
                matt.ImgUrl
            }, new
            {
                chris.Id,
                chris.FirstName,
                chris.LastName,
                chris.ManagerId,
                chris.Position,
                chris.ImgUrl
            }, new
            {
                will.Id,
                will.FirstName,
                will.LastName,
                will.ManagerId,
                will.Position,
                will.ImgUrl
            }, new
            {
                forrest.Id,
                forrest.FirstName,
                forrest.LastName,
                forrest.ManagerId,
                forrest.Position,
                forrest.ImgUrl
            });

            var today   = new DateTime(DateTime.Now.Ticks);
            var report1 = new ReportItem(++counter, forrest.Id, john.Id, "Report 1 text", today.AddDays(-50));
            var report2 = new ReportItem(++counter, forrest.Id, john.Id, "Report 2 text", today.AddDays(-43));
            var report3 = new ReportItem(++counter, will.Id, john.Id, "Report 3 text", today.AddDays(-37));
            var report4 = new ReportItem(++counter, matt.Id, sherlock.Id, "Report 4 text", today.AddDays(-28));
            var report5 = new ReportItem(++counter, john.Id, doctor.Id, "Report 5 text", today.AddDays(-15));
            var report6 = new ReportItem(++counter, sherlock.Id, doctor.Id, "Report 6 text", today.AddDays(-11));

            builder.Entity <ReportItem>().HasData(
                new { report1.Id, report1.EmployeeId, report1.ManagerId, report1.ReportText, report1.IssuedDate },
                new { report2.Id, report2.EmployeeId, report2.ManagerId, report2.ReportText, report2.IssuedDate },
                new { report3.Id, report3.EmployeeId, report3.ManagerId, report3.ReportText, report3.IssuedDate },
                new { report4.Id, report4.EmployeeId, report4.ManagerId, report4.ReportText, report4.IssuedDate },
                new { report5.Id, report5.EmployeeId, report5.ManagerId, report5.ReportText, report5.IssuedDate },
                new { report6.Id, report6.EmployeeId, report6.ManagerId, report6.ReportText, report6.IssuedDate });

            var task1 = new TaskItem(++counter, forrest.Id, john.Id, "Task 1 text", today.AddDays(-20), today.AddDays(-15));
            var task2 = new TaskItem(++counter, john.Id, sherlock.Id, "Task 2 text, changed Manager", today.AddDays(-19), today.AddDays(-11));
            var task3 = new TaskItem(++counter, will.Id, john.Id, "Task 3 text", today.AddDays(-19), today.AddDays(-15));
            var task4 = new TaskItem(++counter, chris.Id, john.Id, "Task 4 text", today.AddDays(-17), today.AddDays(-12));
            var task5 = new TaskItem(++counter, matt.Id, sherlock.Id, "Task 5 text", today.AddDays(-14), today.AddDays(-8));
            var task6 = new TaskItem(++counter, matt.Id, sherlock.Id, "Task 6 text", today.AddDays(-7), today.AddDays(-3));
            var task7 = new TaskItem(++counter, sherlock.Id, doctor.Id, "Task 7 text", today.AddDays(-3), today.AddDays(5));
            var task8 = new TaskItem(++counter, john.Id, doctor.Id, "Task 8 text", today.AddDays(-2), today.AddDays(3));

            builder.Entity <TaskItem>().HasData(
                new { task1.Id, task1.EmployeeId, task1.ManagerId, task1.TaskText, task1.AssignedDate, task1.DueDate },
                new { task2.Id, task2.EmployeeId, task2.ManagerId, task2.TaskText, task2.AssignedDate, task2.DueDate },
                new { task3.Id, task3.EmployeeId, task3.ManagerId, task3.TaskText, task3.AssignedDate, task3.DueDate },
                new { task4.Id, task4.EmployeeId, task4.ManagerId, task4.TaskText, task4.AssignedDate, task4.DueDate },
                new { task5.Id, task5.EmployeeId, task5.ManagerId, task5.TaskText, task5.AssignedDate, task5.DueDate },
                new { task6.Id, task6.EmployeeId, task6.ManagerId, task6.TaskText, task6.AssignedDate, task6.DueDate },
                new { task7.Id, task7.EmployeeId, task7.ManagerId, task7.TaskText, task7.AssignedDate, task7.DueDate },
                new { task8.Id, task8.EmployeeId, task8.ManagerId, task8.TaskText, task8.AssignedDate, task8.DueDate });
        }
Exemplo n.º 30
0
 public TaskCardRow(ReportItem workItem)
 {
     WorkItem = workItem;
 }
Exemplo n.º 31
0
        public void ExportReportByExcel()
        {
            #region 清空数据
            List1.Clear();
            List2.Clear();
            List3.Clear();
            List4.Clear();
            List5.Clear();
            ReportItemList = new ObservableCollection<ReportItem>();
            #endregion

            #region 创建数据
            
            //创建导出的数据表
            ReportItem Item1 = new ReportItem();
            ReportItem Item2 = new ReportItem();
            ReportItem Item3 = new ReportItem();
            ReportItem Item4 = new ReportItem();
            ReportItem Item5 = new ReportItem();
            ReportItem ItemEmpty = new ReportItem();
            Item1.ItemID = "285e677586d64cb9a0411e782112c002";
            Item1.Explosiveforce = "前屈爆发力";
            Item1.Endurance = "前屈耐力";
            Item1.Fatigueindex = "前屈疲劳指数";
            Item1.FitTime = "测试时间";
            Item2.ItemID = "61e5836252974446b8887dfcb30938cc";
            Item2.Explosiveforce = "后伸爆发力";
            Item2.Endurance = "后伸耐力";
            Item2.Fatigueindex = "后伸疲劳指数";
            Item2.FitTime = "测试时间";
            Item3.ItemID = "0362642cd1f5440aa5ff82c782bc25e0";
            Item3.Explosiveforce = "旋转(左)爆发力";
            Item3.Endurance = "旋转(左)耐力";
            Item3.Fatigueindex = "旋转(左)疲劳指数";
            Item3.FitTime = "测试时间";
            Item4.ItemID = "1022d9a5676049aeb9cfffd1af581512";
            Item4.Explosiveforce = "旋转(右)爆发力";
            Item4.Endurance = "旋转(右)耐力";
            Item4.Fatigueindex = "旋转(右)疲劳指数";
            Item4.FitTime = "测试时间";
            Item5.ItemID = "397ff4895dbe420ba16dd45754f33e96";
            Item5.Explosiveforce = "前屈ROM";
            Item5.Endurance = "后伸ROM";
            Item5.Fatigueindex = "旋转(左)ROM";
            Item5.FitTime = "旋转(右)ROM";
            Item5.ROMTime = "测试时间";
            ItemEmpty.ItemID = "";
            ItemEmpty.Explosiveforce = "";
            ItemEmpty.Endurance = "";
            ItemEmpty.Fatigueindex = "";
            ItemEmpty.FitTime = "";
            ItemEmpty.ROMTime = "";
            
            #endregion

            #region 添加到数据
            List1.Add(Item1);
            List2.Add(Item2);
            List3.Add(Item3);
            List4.Add(Item4);
            List5.Add(Item5);
            BindReportItem();
            List1.Add(ItemEmpty);
            List2.Add(ItemEmpty);
            List3.Add(ItemEmpty);
            List4.Add(ItemEmpty);
           
           foreach (ReportItem item in List1)
           {
               ReportItemList.Add(item);
           }
           foreach (ReportItem item in List2)
           {
               ReportItemList.Add(item);
           }
           foreach (ReportItem item in List3)
           {
               ReportItemList.Add(item);
           }
           foreach (ReportItem item in List4)
           {
               ReportItemList.Add(item);
           }

           foreach (ReportItem item in List5)
           {
               ReportItemList.Add(item);
           }
            #endregion
        }
Exemplo n.º 32
0
        public ActionResult ActiveReport(SummaryReport rep)
        {
            if (ModelState.IsValid)
            {
                IEnumerable <int> serviceIds = db.Service.Select(m => m.Id);

                var actives = (from s in db.ServiceAssign
                               from c in db.Customer
                               from p in db.Service
                               where s.CustomerId == c.Id && s.NewspaperId == p.Id && s.EndedDate >= rep.EndedDate
                               select new
                {
                    customer = c,
                    ServiceAssign = s,
                    service = p
                }).GroupBy(m => m.service.Id).Select(m => new
                {
                    serviceId   = m.Key,
                    count       = m.Count(),
                    customerIds = db.ServiceAssign.Where(x => x.NewspaperId == m.Key).Select(x => x.CustomerId)
                }).ToList();

                actives = actives.Where(m => serviceIds.Contains(m.serviceId)).ToList();

                var activeCustomer = actives.Select(m => new
                {
                    service   = db.Service.Find(m.serviceId),
                    customers = db.Customer.Where(x => m.customerIds.Contains(x.Id)),
                    count     = m.count
                });

                var totals = (from s in db.ServiceAssign
                              from c in db.Customer
                              from p in db.Service
                              where s.CustomerId == c.Id && s.NewspaperId == p.Id
                              select new
                {
                    customer = c,
                    ServiceAssign = s,
                    service = p
                }).GroupBy(m => m.service.Id).Select(m => new
                {
                    serviceId   = m.Key,
                    count       = m.Count(),
                    customerIds = db.ServiceAssign.Where(x => x.NewspaperId == m.Key).Select(x => x.CustomerId)
                }).ToList();

                totals = totals.Where(m => serviceIds.Contains(m.serviceId)).ToList();

                var totalCustomers = totals.Select(m => new
                {
                    service   = db.Service.Find(m.serviceId),
                    customers = db.Customer.Where(x => m.customerIds.Contains(x.Id)),
                    count     = m.count
                });


                List <ReportItem> repItems = new List <ReportItem>();

                foreach (var item in totalCustomers)
                {
                    var active = activeCustomer.FirstOrDefault(m => m.service.Id == item.service.Id);

                    ReportItem repItem = new ReportItem
                    {
                        Active             = active != null ? active.count : 0,
                        NotActive          = item.count - (active != null ? active.count : 0),
                        Total              = item.count,
                        ActiveCustomers    = active != null ? active.customers : null,
                        NotActiveCustomers = item.customers.ToList().Except(active != null ? active.customers.ToList() : null),
                        NewspaperName      = item.service.NewsPaperName,
                    };
                    repItems.Add(repItem);
                }

                ReportItem repItemTotal = new ReportItem
                {
                    NewspaperName = "जम्मा",
                    Active        = repItems.Sum(m => m.Active),
                    NotActive     = repItems.Sum(m => m.NotActive),
                    Total         = repItems.Sum(m => m.Total)
                };

                repItems.Add(repItemTotal);
                rep.ReportItems = repItems;

                return(View(rep));
            }
            return(View(rep));
        }
Exemplo n.º 33
0
 public SharedStepsCardRow(ReportItem workItem)
 {
     WorkItem = workItem;
 }
Exemplo n.º 34
0
        public async Task UpdateReportItem(ReportItem reportItem)
        {
            UpdateDefinition <ReportItemMongo> updateDefinition = Builders <ReportItemMongo> .Update.Set(x => x.ReportLayout, reportItem.ReportLayout);

            await mongoCollection.UpdateOneAsync(x => x.ReportName == reportItem.Id, updateDefinition);
        }
 public static string GetResultLabel(ReportItem item)
 {
     return string.Format("[{0}] in {1}ms", item.Result.ToString(), (item.EndTime - item.StartTime).Milliseconds);
 }
Exemplo n.º 36
0
        public async Task <string> CreateReportItem(ReportItem reportItem)
        {
            await mongoCollection.InsertOneAsync(ReportItemMongo.CreateFromReportItem(reportItem));

            return(reportItem.Id);
        }
Exemplo n.º 37
0
 private void StoreContext(ReportItem rItem)
 {
     if (rItem == null) return;
     Current.Context.ReportItem = rItem;
     Current.Context.Report = null;
     UpdateInterface(null);
 }
Exemplo n.º 38
0
 public UnknownCardRow(ReportItem workItem)
 {
     WorkItem = workItem;
 }