public void FileParserTest()
        {
            IFileParser fileParser   = new FileParser();
            IBaseFile   baseFileType = new LPFileType();
            var         output       = fileParser.ParseFile(string.Empty, baseFileType);

            Assert.IsNull(output);
        }
示例#2
0
        public LPFile(XmlNode LPFileNode, MasterTypes mType, int mNo, int iNo, bool imported)
        {
            string StrRoutineName = "LPFile";

            try
            {
                masterType = mType;
                masterNo   = mNo;
                IEDNo      = iNo;
                SetSupportedAttributes();
                if (LPFileNode.Attributes != null)
                {
                    try
                    {
                        LpFilenType = (LPFileType)Enum.Parse(typeof(LPFileType), LPFileNode.Name);
                    }
                    catch (System.ArgumentException)
                    {
                    }
                    if (masterType == MasterTypes.LoadProfile)
                    {
                        foreach (XmlAttribute item in LPFileNode.Attributes)
                        {
                            try
                            {
                                if (this.GetType().GetProperty(item.Name) != null)
                                {
                                    this.GetType().GetProperty(item.Name).SetValue(this, item.Value);
                                }
                            }
                            catch (System.NullReferenceException)
                            {
                            }
                        }
                    }
                }
                else if (LPFileNode.NodeType == XmlNodeType.Comment)
                {
                    isNodeComment = true;
                    comment       = LPFileNode.Value;
                }
                if (imported)
                {
                    //Ajay: 10/10/2018 Commented
                    //this.LPFileNo = (Globals.LPFileNo + 1).ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(StrRoutineName + ": " + "Error: " + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#3
0
        //Ajay: 10/10/2018 Commented
        //public static List<string> getParamCode(MasterTypes masterType)
        //{
        //    if (masterType == MasterTypes.LoadProfile)
        //        return Utils.getOpenProPlusHandle().getDataTypeValues("LoadProfile_LPFile_ParamCode");
        //    else
        //        return new List<string>();
        //}
        public LPFile(string LPFileName, List <KeyValuePair <string, string> > LpFileData, TreeNode tn, MasterTypes mType, int mNo, int iNo)
        {
            string strRoutineName = "DI";

            try
            {
                masterType = mType;
                masterNo   = mNo;
                IEDNo      = iNo;
                SetSupportedAttributes();
                try
                {
                    LpFilenType = (LPFileType)Enum.Parse(typeof(LPFileType), LPFileName);
                }
                catch (System.ArgumentException)
                {
                    Utils.WriteLine(VerboseLevel.WARNING, "Enum argument {0} not supported!!!", LPFileName);
                }
                if (LpFileData != null && LpFileData.Count > 0)
                {
                    foreach (KeyValuePair <string, string> lpfilekp in LpFileData)
                    {
                        Utils.Write(VerboseLevel.DEBUG, "{0} {1} ", lpfilekp.Key, lpfilekp.Value);
                        try
                        {
                            if (this.GetType().GetProperty(lpfilekp.Key) != null)
                            {
                                this.GetType().GetProperty(lpfilekp.Key).SetValue(this, lpfilekp.Value);
                            }
                        }
                        catch (System.NullReferenceException)
                        {
                            Utils.WriteLine(VerboseLevel.WARNING, "LPFile: Field doesn't exist. XML and class fields mismatch!!! key: {0} value: {1}", lpfilekp.Key, lpfilekp.Value);
                        }
                    }
                    Utils.Write(VerboseLevel.DEBUG, "\n");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(strRoutineName + ": " + "Error:" + ex.Message.ToString(), Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#4
0
        static void ProcessFile(FileTypes.Files fileType, string fileName)
        {
            try
            {
                IFileParser        fileParser        = new FileParser();
                IBaseFile          baseFileType      = null;
                IBaseFileProcessor basefileProcessor = null;
                switch (fileType)
                {
                case FileTypes.Files.LPF:
                    baseFileType      = new LPFileType();
                    basefileProcessor = new LPFFileProcessor();
                    break;

                case FileTypes.Files.TOU:
                    baseFileType      = new TOUFileType();
                    basefileProcessor = new TOUFileProcessor();
                    break;
                }
                if (!System.IO.File.Exists(fileName))
                {
                    Console.WriteLine("File does not exist");
                    return;
                }
                System.IO.FileInfo finfo = new System.IO.FileInfo(fileName);
                if (finfo.Extension != ".csv")
                {
                    Console.WriteLine("Invalid File");
                    return;
                }
                var data = fileParser.ParseFile(fileName, baseFileType);

                var         median   = basefileProcessor.CalcMedian(data.ToArray());
                var         outliers = basefileProcessor?.GetOutliers(data.ToArray(), 20, median);
                PublishData pub      = new PublishData();
                pub.DisplayData(outliers, finfo.Name, median);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }