Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XLSToCSVConverter"/> class.
        /// </summary>
        /// <param name="sourceFile">
        /// The path to the xls(b/x) being converted
        /// </param>
        /// <param name="importheader">
        /// Option to import the header row or not.
        /// </param>
        /// <param name="saveAs">
        /// The option to save the xls(x/b) as one csv file or a csv file per worksheet.
        /// </param>
        /// <param name="delimeter">
        /// The CSV file delimeter requried.
        /// </param>
        /// <param name="qualifier">
        /// The CSV file qualifier required.
        /// </param>
        public ExcelData(string sourceFile, ImportHeader importheader, SaveAs saveAs, char delimeter, char qualifier)
        {
            if (!File.Exists(sourceFile))
            {
                throw new FileNotFoundException(
                String.Format("The source file: {0} can not be found.", sourceFile));
            }

            this.IsSaveAs = saveAs;
            this.SourceFile = sourceFile;
            this.IsImportHeader = importheader;
            this.Delimeter = delimeter.ToString();
            this.Qualifier = qualifier.ToString();
            this.workSheets = new Dictionary<string, DataTable>();
        }
Пример #2
0
        public ActionResult _ImportMessages(int id)
        {
            ImportMessageViewModel temp          = new ImportMessageViewModel();
            List <ImportMessage>   ImportMessage = (from H in db.ImportMessage where H.ImportHeaderId == id && H.IsActive == true && H.ValueType == "Error" select H).ToList();

            ImportHeader Header = _ImportHeaderservice.Find(id);

            temp.ImportHeaderId = id;
            temp.ImportMessage  = ImportMessage;
            ViewBag.Name        = Header.ImportName;

            if (temp == null)
            {
                return(HttpNotFound());
            }
            return(PartialView("_ImportMessages", temp));
        }
Пример #3
0
        public ActionResult Import(int MenuId, int id)//id == DocTypeId
        {
            Menu              menu   = new MenuService(_unitOfWork).Find(MenuId);
            ImportHeader      header = _ImportHeaderservice.GetImportHeaderByName(menu.MenuName);
            List <ImportLine> lines  = _ImportLineService.GetImportLineList(header.ImportHeaderId).ToList();

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

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


            ImportMasterViewModel vm = new ImportMasterViewModel();

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

            vm.ImportHeader   = header;
            vm.ImportLine     = lines;
            vm.ImportHeaderId = header.ImportHeaderId;
            vm.DocTypeId      = id;

            int ImportMessageCnt = (from H in db.ImportMessage where H.ImportHeaderId == header.ImportHeaderId && H.IsActive == true && H.ValueType == "Error" select H).Count();

            ViewBag.ImportMessageCnt = ImportMessageCnt;

            return(View(vm));
        }
Пример #4
0
        public static IEnumerable <ImportInfo> GetImportInfos(string libPath)
        {
            using FileStream libStream   = new FileStream(libPath, FileMode.Open, FileAccess.Read);
            using BinaryReader libReader = new BinaryReader(libStream);

            byte[] libHeader = libReader.ReadBytes(expectedLibHeader.Length);
            if (!libHeader.SequenceEqual(expectedLibHeader))
            {
                throw new InvalidOperationException($"{libPath} is not a valid .lib.");
            }

            long nextArchPos = libStream.Position;

            while (libStream.Position != libStream.Length)
            {
                libStream.Position = nextArchPos;

                // Make sure it starts on an even boundary
                if ((libStream.Position % 2) == 1)
                {
                    libStream.Position += 1;
                }

                byte[]        headerBytes = libReader.ReadBytes(Marshal.SizeOf(typeof(ArchiveHeader)));
                ArchiveHeader header      = GetStructFromBytes <ArchiveHeader>(headerBytes);
                if (!header.IsValid)
                {
                    yield break;
                }

                nextArchPos = libStream.Position + header.ArchiveSize;

                string name = header.Name;

                // We don't need these archives
                if (name == "/" || name == "//")
                {
                    continue;
                }

                if (header.ArchiveSize < Marshal.SizeOf(typeof(ImportHeader)))
                {
                    continue;
                }

                byte[]       importHeaderBytes = libReader.ReadBytes(Marshal.SizeOf(typeof(ImportHeader)));
                ImportHeader importHeader      = GetStructFromBytes <ImportHeader>(importHeaderBytes);

                // Is this really an import header?
                if (importHeader.sig1 != 0 || importHeader.sig2 != 0xFFFF)
                {
                    continue;
                }

                // Make sure it's a code import
                if (importHeader.ImportType != ImportType.Code)
                {
                    continue;
                }

                string symbolName = ReadNullTermString(libReader);
                string dllName    = ReadNullTermString(libReader);
                string procName   = symbolName;

                // If it's x86, try to undecorate it
                if (importHeader.MachineType == MachineType.X86)
                {
                    if (procName.StartsWith('_'))
                    {
                        procName = procName.Substring(1);

                        int atIndex = procName.IndexOf('@');
                        if (atIndex != -1)
                        {
                            procName = procName.Substring(0, atIndex);
                        }
                    }
                }

                yield return(new ImportInfo(dllName, procName));
            }
        }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="XLSToCSVConverter"/> class.
 /// </summary>
 /// <param name="sourceFile">
 /// The path to the xls(b/x) being converted
 /// </param>
 /// <param name="importheader">
 /// Option to import the header row or not.
 /// </param>
 /// <param name="saveAs">
 /// The option to save the xls(x/b) as one csv file or a csv file per worksheet.
 /// </param>
 /// <param name="aceVersion">
 /// The ACE DB Override version. (Default 12.0).
 /// </param>
 /// <param name="excelVersion">
 /// The Excel Override version. (Default 12.0).
 /// </param>
 /// /// <param name="delimeter">
 /// The CSV file delimeter requried.
 /// </param>
 /// <param name="qualifier">
 /// The CSV file qualifier required.
 /// </param>
 public ExcelData(string sourceFile, ImportHeader importheader, SaveAs saveAs, string aceVersion, string excelVersion, char delimeter, char qualifier)
     : this(sourceFile, importheader, saveAs, delimeter, qualifier)
 {
     this.ACEDbVersionOverride = aceVersion;
     this.ExcelVersionOverride = excelVersion;
 }
        private void ValidateContext(SLangGrammarParser.ThisHeaderContext thisHeader, ITerminalNode id, SLangGrammarParser.ImportHeadContext importHead, ITerminalNode accessModifier, ITerminalNode abstractToken, ITerminalNode overrideToken, SLangGrammarParser.RoutineArgListContext routineArgList, SLangGrammarParser.TypeNameContext typeName, SLangGrammarParser.StatementSeqContext statementSeq)
        {
            var isMethod = thisHeader != null;
            var symbol   = id.Symbol;

            string nameOfThis = string.Empty;

            if (isMethod)
            {
                nameOfThis = thisHeader.Id().GetText();
                ThrowIfReservedWord(nameOfThis, ModuleData.File, thisHeader.Id().Symbol);
                if (importHead != null)
                {
                    ThrowImportHeaderMethodsException(ModuleData.File, id);
                }
            }
            var name = id.GetText();

            ThrowIfReservedWord(name, ModuleData.File, symbol);
            var          args   = Visit(routineArgList) as List <RoutineArgNameTableItem>;
            ImportHeader header = null;

            if (importHead != null)
            {
                header = Visit(importHead) as ImportHeader;
            }

            SlangType returnType = typeName != null?Visit(typeName) as SlangType : null;

            var modifier = GetModifierByName(accessModifier.GetText());

            var isAbstract = abstractToken != null;
            var isOverride = overrideToken != null;

            if (!isMethod && (isAbstract || isOverride))
            {
                ThrowRoutinesAbstractOverrideException(ModuleData.File, abstractToken ?? overrideToken);
            }

            if (header != null && statementSeq.statement().Length != 0)
            {
                ThrowImportHeaderException(ModuleData.File, id);
            }

            if (isMethod)
            {
                if (Visit(thisHeader) is SlangCustomType methodTypeIdent && methodTypeIdent.ModuleName != ModuleData.Name)
                {
                    ThrowModuleFromOtherClassModuleException(id, ModuleData.File);
                }
                if (isAbstract)
                {
                    ThrowIfAbstractMethodPrivate(modifier, ModuleData.File, id);
                }
                if ((args ?? throw new InvalidOperationException(nameof(args))).Any(a => a.Name == nameOfThis))
                {
                    ThrowConfictsThisException(thisHeader.Id(), ModuleData.File);
                }
                var classData  = Visit(thisHeader) as SlangCustomType;
                var foundClass = Table.FindClass(classData);

                if (foundClass.Methods.ContainsKey(name))
                {
                    ThrowMethodSignatureExistsException(classData, id, ModuleData.File);
                }

                if (isAbstract && statementSeq.statement().Length != 0)
                {
                    ThrowAbstractEmptyException(id, ModuleData.File);
                }

                var method = new MethodNameTableItem
                {
                    AccessModifier = modifier,
                    Column         = symbol.Column,
                    Header         = header,
                    IsAbstract     = isAbstract,
                    IsOverride     = isOverride,
                    Line           = symbol.Line,
                    Name           = name,
                    NameOfThis     = nameOfThis,
                    Params         = args,
                    ReturnType     = returnType
                };
                if (modifier == AccessModifier.Public)
                {
                    CheckLevelAccessForMethods(method, id, classData);
                }

                foundClass.CheckRoutineConflicts(moduleItem.ModuleData, method);
                foundClass.Methods.Add(method.Name, method);
            }
            else
            {
                if (moduleItem.Routines.ContainsKey(name))
                {
                    ThrowRoutineExistsException(id, ModuleData.File);
                }

                var routine = new RoutineNameTableItem
                {
                    AccessModifier = modifier,
                    Column         = symbol.Column,
                    Line           = symbol.Line,
                    Header         = header,
                    Name           = name,
                    Params         = args,
                    ReturnType     = returnType
                };

                if (modifier == AccessModifier.Public)
                {
                    CheckLevelAccessForRoutines(routine, id, name);
                }

                moduleItem.CheckCommonNamesConflicts(routine.Name, routine.Line, routine.Column);
                moduleItem.Routines.Add(routine.Name, routine);
            }
        }
Пример #7
0
 public void Update(ImportHeader pt)
 {
     pt.ObjectState = ObjectState.Modified;
     _unitOfWork.Repository <ImportHeader>().Update(pt);
 }
Пример #8
0
 public void Delete(ImportHeader pt)
 {
     _unitOfWork.Repository <ImportHeader>().Delete(pt);
 }
Пример #9
0
 public ImportHeader Create(ImportHeader pt)
 {
     pt.ObjectState = ObjectState.Added;
     _unitOfWork.Repository <ImportHeader>().Insert(pt);
     return(pt);
 }
Пример #10
0
 public ImportHeader Add(ImportHeader pt)
 {
     _unitOfWork.Repository <ImportHeader>().Insert(pt);
     return(pt);
 }