Beispiel #1
0
        //TODO(adam): simplify access to constructing file paths

        internal FilePaths(StyleConfigData config)
        {
            this.config = config;
        }
Beispiel #2
0
        private string ConstructStylePathPart(OrderData order)
        {
            //NOTE(adam): operating on copy to preserve original data
            OrderData tempOrder = order;

            //TODO(adam): this feels really messy. can I access other configs in a better way?
            if (config.GetStyleLookupType(tempOrder.itemCode) != config.styleType)
            {
                if (config.pathTypes[config.paths[tempOrder.itemCode].type] == "cut-sew_files")
                {
                    StyleConfigData cutConfig = Lettering.configs[ReportType.Cut];
                    return(cutConfig.pathBuilders["!style"](tempOrder) + @"\SEW FILES\");
                }

                if (config.pathTypes[config.paths[tempOrder.itemCode].type] == "cut-specific")
                {
                    StyleConfigData cutConfig = Lettering.configs[ReportType.Cut];
                    return(cutConfig.filePaths.ConstructStylePathPart(tempOrder) + @"SEW FILES\");
                }

                ErrorHandler.HandleError(ErrorType.Alert, "Mismatched style and config with no match found.");
            }

            //NOTE(adam): replace item code if mirror style
            if (config.pathTypes[config.paths[tempOrder.itemCode].type] == "mirror")
            {
                tempOrder.itemCode = config.paths[tempOrder.itemCode].mirrorStyle;
            }

            string startPath = "";
            //NOTE(adam): test for exceptions
            List <ExceptionData> possibleExceptions;

            if (config.exceptions.TryGetValue(tempOrder.itemCode, out possibleExceptions))
            {
                bool noException = true;
                foreach (ExceptionData ex in possibleExceptions)
                {
                    if (config.exceptionChecks[ex.tag.ToLower()](tempOrder, ex))
                    {
                        startPath   = ex.path;
                        noException = false;
                        break;
                    }
                }
                //NOTE(adam): fallthrough if no exception match
                if (noException)
                {
                    startPath = config.pathTypes[config.paths[tempOrder.itemCode].type];
                }
            }
            else
            {
                startPath = config.pathTypes[config.paths[tempOrder.itemCode].type];
            }

            string[] tokens    = startPath.Split('\\');
            string   finalPath = "";

            foreach (string token in tokens)
            {
                if (token.StartsWith("!") && config.pathBuilders.ContainsKey(token))
                {
                    finalPath += config.pathBuilders[token](tempOrder) + '\\';
                }
                else
                {
                    finalPath += token + '\\';
                }
            }

            return(finalPath);
        }