コード例 #1
0
        public ActionResult Export(int?storeId)
        {
            var path = Path.Combine(HttpRuntime.AppDomainAppPath, EnvironmentHelper.TemplatePath(this.RouteData));

            GridRequest request = new GridRequest(Request);
            Expression <Func <Returned, bool> > predicate = FilterHelper.GetExpression <Returned>(request.FilterGroup);
            //根据店铺权限筛选
            var enabledStores = _storeContract.FilterStoreId(AuthorityHelper.OperatorId, _administratorContract, storeId);
            var query         = _returnedContract.Returneds.Where(r => enabledStores.Contains(r.StoreId.Value)).Where(predicate);
            var list          = query.Select(m => new
            {
                StoreName      = m.Store.StoreName,
                MemberName     = m.Member.RealName,
                ReturnedNumber = m.ReturnedNumber,
                RetailNumber   = m.RetailNumber,
                EraseMoney     = m.EraseMoney,
                Status         = m.Status + "",
                Cash           = m.Cash,
                Card           = m.SwipCard,
                ConsumeScore   = m.ConsumeScore,
                AchieveScore   = m.AchieveScore,
                Balance        = m.Balance,
                Coupon         = m.Coupon,
                UpdatedTime    = m.UpdatedTime,
                OperatorName   = m.Operator.Member.MemberName,
            }).ToList();

            var group = new StringTemplateGroup("all", path, typeof(TemplateLexer));
            var st    = group.GetInstanceOf("Exporter");

            st.SetAttribute("list", list);
            return(FileExcel(st, "退货记录查询"));
        }
コード例 #2
0
        public ActionResult ExportPurchaseOrder(string purchaseNumber)
        {
            if (string.IsNullOrEmpty(purchaseNumber))
            {
                return(Json(OperationResult.Error("参数错误")));
            }

            Purchase purchaseEntity = _purchaseContract.Purchases.Where(c => c.PurchaseNumber == purchaseNumber && !c.IsDeleted && c.IsEnabled).FirstOrDefault();

            if (purchaseEntity == null)
            {
                return(Json(OperationResult.Error("为找到采购单信息")));
            }
            var li = purchaseEntity.PurchaseItems.Select(c => new Product_Model()
            {
                ProductNumber    = c.Product.ProductNumber,
                ProductName      = c.Product.ProductName ?? c.Product.ProductOriginNumber.ProductName,
                Brand            = c.Product.ProductOriginNumber.Brand.BrandName,
                Size             = c.Product.Size.SizeName,
                Season           = c.Product.ProductOriginNumber.Season.SeasonName,
                Color            = c.Product.Color.ColorName,
                TagPrice         = c.Product.ProductOriginNumber.TagPrice,
                PurchaseQuantity = c.Quantity
            }).ToList();
            var tempFilePath = Path.Combine(HttpRuntime.AppDomainAppPath, EnvironmentHelper.TemplatePath(this.RouteData));
            var group        = new StringTemplateGroup("all", tempFilePath, typeof(TemplateLexer));
            var st           = group.GetInstanceOf("ExportPurchaseOrder");

            st.SetAttribute("list", li);
            var str    = st.ToString();
            var buffer = Encoding.UTF8.GetBytes(str);
            var stream = new MemoryStream(buffer);

            return(File(stream, "application/ms-excel", $"采购单[{purchaseEntity.PurchaseNumber}]详情.xls"));
        }
コード例 #3
0
        public ActionResult Export()
        {
            var         path    = Path.Combine(HttpRuntime.AppDomainAppPath, EnvironmentHelper.TemplatePath(this.RouteData));
            GridRequest request = new GridRequest(Request);
            Expression <Func <OrderFood, bool> > predicate = FilterHelper.GetExpression <OrderFood>(request.FilterGroup);
            var query = _OrderFoodContract.Entities.Where(predicate);
            var list  = (from s in query
                         let depa = s.Admins.Where(w => w.IsEnabled && !w.IsDeleted)
                                    select new
            {
                s.UpdatedTime,
                OperatorName = s.Operator.Member.RealName,
                WL = depa.Count(c => c.DepartmentId == 7),            //网络部
                CC = depa.Count(c => c.DepartmentId == 8),            //仓储部
                YY = depa.Count(c => c.DepartmentId == 9),            //运营部
                HG = depa.Count(c => c.DepartmentId == 10),           //合规部
                RS = depa.Count(c => c.DepartmentId == 11),           //人事部
                CW = depa.Count(c => c.DepartmentId == 12),           //财务部
                BJ = depa.Count(c => c.DepartmentId == 13),           //编辑部
                CP = depa.Count(c => c.DepartmentId == 1016),         //产品部
                SC = depa.Count(c => c.DepartmentId == 1025),         //市场部
                XZ = depa.Count(c => c.DepartmentId == 1027),         //行政部
            }).ToList();
            var group = new StringTemplateGroup("all", path, typeof(TemplateLexer));
            var st    = group.GetInstanceOf("Exporter");

            st.SetAttribute("list", list);
            return(FileExcel(st, "订餐预约管理"));
        }
コード例 #4
0
        private void createContent(String varName, Object objectToPass, StringReader reader, String outputFileName)
        {
            Dictionary <String, Object> map = new Dictionary <String, Object>();

            map.Add(varName, objectToPass);

            String outputContent      = null;
            StringTemplateGroup group = new StringTemplateGroup(reader);
            var contentTemplate       = group.GetInstanceOf("Content");

            contentTemplate.Attributes = map;
            outputContent = contentTemplate.ToString();
            //StringBuilder sb = new StringBuilder(outputContent);
            StringWriter writer = new StringWriter(new StringBuilder(outputContent));

            writer.Flush();
            StreamWriter fileWriter = null;

            try
            {
                fileWriter = new StreamWriter(outputFileName + "/report.html.data");
                fileWriter.Write(writer.ToString());
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }

            writer.Close();
            fileWriter.Close();
        }
コード例 #5
0
        private void WriteHeaderFileContent(TextWriter writer, string suitePath)
        {
            Stream stream =
                Assembly.GetExecutingAssembly().GetManifestResourceStream(
                    NewTestSuiteTemplateResourcePath);

            StringTemplateGroup templateGroup = new StringTemplateGroup(
                new StreamReader(stream), typeof(AngleBracketTemplateLexer));

            templateGroup.RegisterAttributeRenderer(typeof(string),
                                                    new NewTestSuiteStringRenderer(suitePath));

            StringTemplate template =
                templateGroup.GetInstanceOf("newSuiteFile");

            // Initialize the options that will be passed into the template.

            Hashtable options = new Hashtable();

            options["suiteName"]       = suiteName;
            options["superclass"]      = superclass;
            options["headerUnderTest"] = headerUnderTest.CanonicalName;
            options["createSetUp"]     = createSetUp;
            options["createTearDown"]  = createTearDown;

            template.SetAttribute("options", options);
            template.SetAttribute("testCases", new List <string>(stubNames));

            template.Write(new AutoIndentWriter(writer));
        }
コード例 #6
0
ファイル: ScriptFile.cs プロジェクト: sharpsteve/papyrus-lang
        public string GetScriptAssembly()
        {
            if (CompilerType == null)
            {
                return(null);
            }

            var papyrusGen = new PapyrusGen(new CommonTreeNodeStream(CompilerType.GetAst())
            {
                TokenStream = CompilerType.GetTokenStream()
            });

            using (var manifestResourceStream = papyrusGen.GetType().Assembly.GetManifestResourceStream("PCompiler.PapyrusAssembly.stg"))
            {
                var templateGroup = new StringTemplateGroup(new StreamReader(manifestResourceStream));
#if SKYRIM
                papyrusGen.TemplateLib = templateGroup;
#else
                papyrusGen.TemplateGroup = templateGroup;
#endif

                papyrusGen.AsDynamic().KnownUserFlags = _program.FlagsFile.NativeFlagsDict;
                var template = papyrusGen.script(_filePath, CompilerType).Template;
                return(template.ToString());
            }
        }
コード例 #7
0
    private static void WriteSkinnedMeshJson(SkinnedMeshRenderer skinnedRenderer, WebGLBone[] bones, Stream outStream, Dictionary <Material, WebGLModel> materialModels)
    {
        Mesh mesh = skinnedRenderer.sharedMesh;
        int  i;

        // Map the bones used by each sub-mesh
        foreach (WebGLModel model in materialModels.Values)
        {
            for (i = 0; i < model.meshes.Count; ++i)
            {
                WebGLMesh subMesh = model.meshes[i];

                // Eventually this will have to change, but for now let's just keep things simple:
                subMesh.boneOffset = 0;
                subMesh.boneCount  = bones.Length;

                model.meshes[i] = subMesh;
            }
        }

        StringTemplateGroup templateGroup = new StringTemplateGroup("MG", templatePath, typeof(DefaultTemplateLexer));
        StringTemplate      modelTemplate = templateGroup.GetInstanceOf("WebGLModel");

        modelTemplate.SetAttribute("name", mesh.name);
        modelTemplate.SetAttribute("models", materialModels.Values);
        modelTemplate.SetAttribute("bones", bones);

        string content = modelTemplate.ToString();

        Byte[] bytes = new UTF8Encoding(true).GetBytes(CleanJSON(content));
        outStream.Write(bytes, 0, bytes.Length);
    }
コード例 #8
0
        public ActionResult Export()
        {
            var path = Path.Combine(HttpRuntime.AppDomainAppPath, EnvironmentHelper.TemplatePath(this.RouteData));

            GridRequest request = new GridRequest(Request);
            Expression <Func <MemberConsume, bool> > predicate = FilterHelper.GetExpression <MemberConsume>(request.FilterGroup);
            var dataList = _memberconsumeContract.MemberConsumes.OrderByDescending(c => c.CreatedTime).Where(predicate).ToList();
            var list     = dataList.Select(m => new
            {
                OrderType      = m.OrderType.HasValue ? m.OrderType.ToString() : string.Empty,
                ConsumeContext = m.ConsumeContext.HasValue ? m.ConsumeContext.ToString() : string.Empty,
                m.MemberId,
                m.Member.RealName,
                m.Member.MobilePhone,
                m.StoreId,
                m.Store.StoreName,
                m.BalanceConsume,
                m.ScoreConsume,
                m.RelatedOrderNumber,
                ConsumeType = m.ConsumeType.ToDescription(),
                m.UpdatedTime,
                m.Operator.Member.MemberName,
            }).ToList();

            var group = new StringTemplateGroup("all", path, typeof(TemplateLexer));
            var st    = group.GetInstanceOf("Exporter");

            st.SetAttribute("list", list);
            return(FileExcel(st, "消费记录管理"));
        }
コード例 #9
0
        public ActionResult Export(int?storeId)
        {
            var path = Path.Combine(HttpRuntime.AppDomainAppPath, EnvironmentHelper.TemplatePath(this.RouteData));

            //根据店铺权限筛选
            var enabledStores = _storeContract.FilterStoreId(AuthorityHelper.OperatorId, _administratorContract, storeId);
            var gr            = new GridRequest(Request);
            Expression <Func <Retail, bool> > predict = FilterHelper.GetExpression <Retail>(gr.FilterGroup);
            var query = _retailContract.Retails.Where(w => w.StoreId.HasValue).Where(r => enabledStores.Contains(r.StoreId.Value)).Where(predict);

            var listdata = (from s in query
                            let item = s.RetailItems.Where(w => w.IsEnabled && !w.IsDeleted)
                                       select new
            {
                s.RetailNumber,
                StoreName = s.Store.StoreName,
                ConsumerName = s.Consumer.RealName ?? string.Empty,
                RetailCount = item.Sum(t => t.RetailCount),
                s.ConsumeCount,
                s.OutStorageDatetime,
                IsStoreActivityDiscount = s.StoreActivityDiscount > 0 ? "是" : "否",
                IsCouponConsume = s.CouponConsume > 0 ? "是" : "否",
                RetailState = s.RetailState + "",
                OperatorName = s.Operator.Member.MemberName,
            }).ToList();

            var group = new StringTemplateGroup("all", path, typeof(TemplateLexer));
            var st    = group.GetInstanceOf("Exporter");

            st.SetAttribute("list", listdata);
            return(FileExcel(st, "零售记录查询"));
            //return JsonLarge(new { version = EnvironmentHelper.ExcelVersion(), html = st.ToString() }, JsonRequestBehavior.AllowGet);
        }
コード例 #10
0
        public ActionResult Export()
        {
            var         path    = Path.Combine(HttpRuntime.AppDomainAppPath, EnvironmentHelper.TemplatePath(this.RouteData));
            GridRequest request = new GridRequest(Request);
            Expression <Func <PosLocation, bool> > predicate = FilterHelper.GetExpression <PosLocation>(request.FilterGroup);
            var querystore = _StoreContract.Stores.Where(w => w.IsEnabled && !w.IsDeleted);
            var query      = _PosLocationContract.Entities.Where(predicate);
            var list       = (from s in query
                              let storeName = querystore.Where(w => w.IMEI == s.IMEI).Select(ss => ss.StoreName).FirstOrDefault()
                                              select new
            {
                s.UpdatedTime,
                OperatorName = s.Operator.Member.RealName,
                s.IMEI,
                s.Longitude,
                s.Latitude,
                s.PrevLongitude,
                s.PrevLatitude,
                s.PrevUpdatedTime,
                s.Address,
                s.PrevAddress,
                StoreName = storeName,
            }).ToList();
            var group = new StringTemplateGroup("all", path, typeof(TemplateLexer));
            var st    = group.GetInstanceOf("Exporter");

            st.SetAttribute("list", list);
            return(FileExcel(st, "POS机定位"));
        }
コード例 #11
0
        static void Main(string[] args)
        {
            const string fileName = "Template";

            List <Person> _list = new List <Person>();

            _list.Add(new Person("idCustomer", "integer"));
            _list.Add(new Person("Name", "Alphanumeric"));

            StringTemplateGroup grp = new StringTemplateGroup(Environment.CurrentDirectory);
            StringTemplate      tmp = grp.GetInstanceOf(fileName);


            tmp.SetAttribute("ProcessorType", "validationFile.Processor.standardProcessor");
            tmp.SetAttribute("ProcessorPath", ".");

            tmp.SetAttribute("HandlerType", "ValidationInputFileDataFlowSSIS.pipellineBufferHandler");
            tmp.SetAttribute("HandlerPath", @"C:\Proyects\petSSISCustomTask\ValidationInputFileDataFlowSSIS\bin\Debug\ValidationInputFileDataFlowSSIS.dll");

            tmp.SetAttribute("MessageType", "ValidationInputFileDataFlowSSIS.KOMessageProvider");
            tmp.SetAttribute("MessagePath", @"C:\Proyects\petSSISCustomTask\ValidationInputFileDataFlowSSIS\bin\Debug\ValidationInputFileDataFlowSSIS.dll");

            tmp.SetAttribute("Fields", _list);

            Console.Write(tmp);
            StreamWriter sw = new StreamWriter("output.xml");

            sw.Write(tmp.ToString());
            sw.Close();
            Console.ReadKey();
        }
コード例 #12
0
 public ActionResult Export(int[] Id)
 {
     var path = Path.Combine(HttpRuntime.AppDomainAppPath, EnvironmentHelper.TemplatePath(this.RouteData));
     var list = _subjectContract.Subjects.Where(m => Id.Contains(m.Id)).OrderByDescending(m => m.Id).ToList();
     var group = new StringTemplateGroup("all", path, typeof(TemplateLexer));
     var st = group.GetInstanceOf("Exporter");
     st.SetAttribute("list", list);
     return Json(new { version = EnvironmentHelper.ExcelVersion(), html = st.ToString() }, JsonRequestBehavior.AllowGet);
 }
 public FuncProtoToShimParser(string templatefile, ITokenStream input)
     : this(input, new RecognizerSharedState())
 {
     using (TextReader tr = new StreamReader(templatefile))
     {
         TemplateGroup = new StringTemplateGroup(tr);
         tr.Close();
     }
 }
コード例 #14
0
        /** <summary>
         *  Return a list of all template names missing from group that are defined
         *  in this interface.  Return null if all is well.
         *  </summary>
         */
        public virtual IList <string> GetMissingTemplates(StringTemplateGroup group)
        {
            string[] missing =
                _templates.Values
                .Where(template => !template.optional && !group.IsDefined(template.name))
                .Select(template => template.name)
                .ToArray();

            return((missing.Length == 0) ? null : missing);
        }
コード例 #15
0
ファイル: SlnFileRenderer.cs プロジェクト: jpk6789/SlimJim
        static SlnFileRenderer()
        {
            var stream = typeof(SlnFileRenderer).Assembly.GetManifestResourceStream("SlimJim.Templates.SolutionTemplate.st");

            templateGroup = new StringTemplateGroup("SlnTemplates");
            using (stream)
            {
                templateGroup.DefineTemplate("SolutionTemplate", new StreamReader(stream).ReadToEnd());
            }
        }
コード例 #16
0
        public ActionResult ExportQuantity(string CheckGuid, CheckerItemFlag Flag)
        {
            var path  = Path.Combine(HttpRuntime.AppDomainAppPath, EnvironmentHelper.TemplatePath(this.RouteData));
            var list  = _checkerItemContract.CheckerItems.Where(w => w.IsEnabled && !w.IsDeleted).Where(w => w.CheckGuid == CheckGuid && w.CheckerItemType == (int)Flag).ToList();
            var group = new StringTemplateGroup("all", path, typeof(TemplateLexer));
            var st    = group.GetInstanceOf("ExporterQuantity");

            st.SetAttribute("list", list);
            return(FileExcel(st, "盘点详情列表"));
        }
コード例 #17
0
        public ActionResult Print(int[] Id)
        {
            var path  = Path.Combine(HttpRuntime.AppDomainAppPath, EnvironmentHelper.TemplatePath(this.RouteData));
            var list  = _memberfavouriteContract.MemberFavourites.Where(m => Id.Contains(m.Id)).OrderByDescending(m => m.Id).ToList();
            var group = new StringTemplateGroup("all", path, typeof(TemplateLexer));
            var st    = group.GetInstanceOf("Printer");

            st.SetAttribute("list", list);
            return(Json(new { html = st.ToString() }, JsonRequestBehavior.AllowGet));
        }
コード例 #18
0
        public ActionResult ExportInventory(int?recordId, string Ids)
        {
            try
            {
                var inventoryIds = new List <int>();
                if (recordId.HasValue && recordId != -1)
                {
                    //导出记录下所有库存数据
                    inventoryIds.AddRange(CacheAccess.GetInventoryRecords(_inventoryRecordContract, _storeContract)
                                          .Where(r => r.Id == recordId.Value)
                                          .SelectMany(r => r.Inventories)
                                          .Where(i => !i.IsDeleted && i.IsEnabled)
                                          .Select(i => i.Id).ToList());
                }
                else
                {
                    //导出选中的数据
                    inventoryIds.AddRange(Ids.Split(',').Select(id => int.Parse(id)));
                }

                var path = Path.Combine(HttpRuntime.AppDomainAppPath, EnvironmentHelper.TemplatePath(this.RouteData));


                var list = CacheAccess.GetAccessibleInventorys(_inventoryContract, _storeContract)
                           .Where(i => inventoryIds.Contains(i.Id))
                           .OrderByDescending(c => c.CreatedTime)
                           .Select(c => new
                {
                    c.Id,
                    c.Store.StoreName,
                    c.Product.ProductOriginNumber.Brand.BrandName,
                    c.Product.ProductOriginNumber.Category.CategoryName,
                    c.Product.ProductOriginNumber.Season.SeasonName,
                    c.Product.Size.SizeName,
                    c.Product.Color.ColorName,
                    c.Product.Color.IconPath,
                    c.Storage.StorageName,
                    c.Product.ThumbnailPath,
                    c.ProductBarcode,
                    c.CreatedTime,
                    c.Operator.Member.MemberName
                }).ToList();
                var group = new StringTemplateGroup("all", path, typeof(TemplateLexer));
                var st    = group.GetInstanceOf("ExporterInventory");
                st.SetAttribute("list", list);
                var str    = st.ToString();
                var buffer = Encoding.UTF8.GetBytes(str);
                var stream = new MemoryStream(buffer);
                return(File(stream, "application/ms-excel", "入库记录明细.xls"));
            }
            catch (Exception e)
            {
                return(Json(new OperationResult(OperationResultType.Error, e.Message), JsonRequestBehavior.AllowGet));
            }
        }
コード例 #19
0
        public static void Main(string[] args)
        {
            // Use a try/catch block for parser exceptions
            try
            {
                string inputFileName;
                string templateFileName;

                if ((args.Length == 1) || (args.Length == 2))
                {
                    if (args.Length == 1)
                    {
                        templateFileName = "Java.stg";
                        inputFileName    = args[0];
                    }
                    else
                    {
                        templateFileName = args[0];
                        inputFileName    = args[1];
                    }

                    // Ensure full pathnames
                    if (!Path.IsPathRooted(templateFileName))
                    {
                        //templateFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, templateFileName);
                        templateFileName = Path.Combine(Environment.CurrentDirectory, templateFileName);
                    }
                    if (!Path.IsPathRooted(inputFileName))
                    {
                        inputFileName = Path.Combine(Environment.CurrentDirectory, inputFileName);
                    }

                    templates = new StringTemplateGroup(new StreamReader(templateFileName),
                                                        typeof(AngleBracketTemplateLexer));

                    ICharStream       input  = new ANTLRFileStream(inputFileName);
                    CMinusLexer       lexer  = new CMinusLexer(input);
                    CommonTokenStream tokens = new CommonTokenStream(lexer);
                    CMinusParser      parser = new CMinusParser(tokens);
                    parser.TemplateLib = templates;
                    RuleReturnScope r = parser.program();
                    Console.Out.WriteLine(r.Template.ToString());
                }
                else
                {
                    Console.Error.WriteLine("Usage: cminus [<output-template-file>] <input-file>");
                }
            }
            catch (System.Exception e)
            {
                Console.Error.WriteLine("exception: " + e);
                Console.Error.WriteLine(e.StackTrace);                 // so we can get stack trace
            }
        }
コード例 #20
0
 public GénérateurRapportMail()
 {
     _stg = new StringTemplateGroup(
         new StreamReader(
             Assembly.GetExecutingAssembly()
             .GetManifestResourceStream("CabOnline.Operators.RapportMail.StViews.RapportMailView.stg"), Encoding.UTF8),
         typeof(TemplateLexer))
     {
         FileCharEncoding = Encoding.UTF8
     };
     _stg.RegisterRenderer(typeof(DateTime), new DateRenderer());
 }
コード例 #21
0
    private static void WriteMeshJson(Mesh mesh, Stream outStream, Dictionary <Material, WebGLModel> materialModels)
    {
        StringTemplateGroup templateGroup = new StringTemplateGroup("MG", templatePath, typeof(DefaultTemplateLexer));
        StringTemplate      modelTemplate = templateGroup.GetInstanceOf("WebGLModel");

        modelTemplate.SetAttribute("name", mesh.name);
        modelTemplate.SetAttribute("models", materialModels.Values);

        string content = modelTemplate.ToString();

        Byte[] bytes = new UTF8Encoding(true).GetBytes(CleanJSON(content));
        outStream.Write(bytes, 0, bytes.Length);
    }
コード例 #22
0
        public override void ReportError(RecognitionException e)
        {
            StringTemplateGroup group = self.Group;

            if (group == StringTemplate.defaultGroup)
            {
                self.Error("action parse error; template context is " + self.GetEnclosingInstanceStackString(), e);
            }
            else
            {
                self.Error("action parse error in group " + self.Group.Name + " line " + self.GroupFileLine + "; template context is " + self.GetEnclosingInstanceStackString(), e);
            }
        }
コード例 #23
0
    public StringTemplate LoadTemplate(string name)
    {
        if (_templateGroup == null)
        {
            _templateGroup = new StringTemplateGroup("MG", GLexConfig.TemplatePath, typeof(DefaultTemplateLexer));
            _templateGroup.RegisterAttributeRenderer(typeof(bool), TemplateRenderers.BoolRenderer.Instance);
            _templateGroup.RegisterAttributeRenderer(typeof(Color), TemplateRenderers.ColorRenderer.Instance);
            _templateGroup.RegisterAttributeRenderer(typeof(DateTime), TemplateRenderers.DateTimeRenderer.Instance);
            _templateGroup.RegisterAttributeRenderer(typeof(Vector3), TemplateRenderers.VectorRenderer.Instance);
            _templateGroup.RegisterAttributeRenderer(typeof(Vector2), TemplateRenderers.VectorRenderer.Instance);
            _templateGroup.RegisterAttributeRenderer(typeof(Matrix4x4), TemplateRenderers.MatrixRenderer.Instance);
        }

        Debug.Log(name);
        return(_templateGroup.GetInstanceOf(GLexConfig.GetTemplate(name)));
    }
コード例 #24
0
        public FileResult Export(int DepartmentId, DateTime StartDate, DateTime EndDate, int AdminId = 0)
        {
            var path = Path.Combine(HttpRuntime.AppDomainAppPath, EnvironmentHelper.TemplatePath(this.RouteData));
            //var list = _attendanceContract.Attendances.ToList();
            var list  = GetAttens(DepartmentId, StartDate, EndDate, AdminId);
            var group = new StringTemplateGroup("all", path, typeof(TemplateLexer));
            var st    = group.GetInstanceOf("Exporter");

            st.SetAttribute("list", list);
            string str1 = st.ToString();

            byte[] fileContents = Encoding.UTF8.GetBytes(str1);
            var    fileStream   = new MemoryStream(fileContents);

            return(File(fileStream, "application/ms-excel", "考勤记录.xls"));
        }
コード例 #25
0
        /**
         * Instantiates an instance of the CxxTestDriverGenerator for the
         * specified project and test suite collection.
         *
         * @param project the ICProject associated with this generator
         * @param path the path of the source file to be generated
         * @param suites the collection of test suites to be generated
         *
         * @throws IOException if an I/O error occurs during generation
         */
        public TestRunnerGenerator(string path, TestSuiteCollection suites,
                                   Dictionary <string, bool> testsToRun)
        {
            this.suites     = suites;
            this.runnerPath = path;

            // Create a proxy object to manage the tests to run. Any tests
            // not in this map are assumed to be true (so that if tests
            // have been added, but not refreshed in the tool window, they
            // will be run until they are explicitly disabled).

            this.testsToRunProxy = new TestsToRunProxy(testsToRun);

            // Load the template from the embedded assembly resources.

            Stream stream =
                Assembly.GetExecutingAssembly().GetManifestResourceStream(
                    RunnerTemplateResourcePath);

            StringTemplateGroup templateGroup = new StringTemplateGroup(
                new StreamReader(stream), typeof(AngleBracketTemplateLexer));

            templateGroup.RegisterAttributeRenderer(typeof(string),
                                                    new TestRunnerStringRenderer(path));

            template = templateGroup.GetInstanceOf("runAllTestsFile");

            // Initialize the options that will be passed into the template.

            options = new Hashtable();
            options["platformIsMSVC"]      = true;
            options["trapSignals"]         = true;
            options["traceStack"]          = true;
            options["noStaticInit"]        = true;
            options["root"]                = true;
            options["part"]                = false;
            options["abortOnFail"]         = true;
            options["longLongType"]        = null;
            options["mainProvided"]        = suites.MainFunctionExists;
            options["runner"]              = "XmlStdioPrinter";
            options["xmlOutput"]           = true;
            options["testResultsFilename"] = Constants.TestResultsFilename;
            options["testsToRun"]          = testsToRunProxy;

            writer = File.CreateText(path);
        }
コード例 #26
0
        /** <summary>
         *  Load a group with a specified superGroup.  Groups with
         *  region definitions must know their supergroup to find templates
         *  during parsing.
         *  </summary>
         */
        public virtual StringTemplateGroup LoadGroup(string groupName,
                                                     Type templateLexer,
                                                     StringTemplateGroup superGroup)
        {
            StringTemplateGroup group = null;
            TextReader          br    = null;
            // group file format defaults to <...>
            Type lexer = typeof(AngleBracketTemplateLexer);

            if (templateLexer != null)
            {
                lexer = templateLexer;
            }
            try
            {
                br = Locate(groupName + ".stg");
                if (br == null)
                {
                    Error("no such group file " + groupName + ".stg");
                    return(null);
                }
                group = new StringTemplateGroup(br, lexer, _errors, superGroup);
                br.Close();
                br = null;
            }
            catch (IOException ioe)
            {
                Error("can't load group " + groupName, ioe);
            }
            finally
            {
                if (br != null)
                {
                    try
                    {
                        br.Close();
                    }
                    catch (IOException ioe2)
                    {
                        Error("Cannot close template group file: " + groupName + ".stg", ioe2);
                    }
                }
            }
            return(group);
        }
コード例 #27
0
    static void WriteLevel(WebGLLevel level, Stream outStream)
    {
        if (EditorUtility.DisplayCancelableProgressBar("Exporting Level", "Writing JSON", 1.0f))
        {
            throw new Exception("User canceled export");
        }

        // Write out JSON
        StringTemplateGroup templateGroup = new StringTemplateGroup("MG", templatePath, typeof(DefaultTemplateLexer));
        StringTemplate      animTemplate  = templateGroup.GetInstanceOf("WebGLLevel");

        animTemplate.SetAttribute("level", level);

        string content = animTemplate.ToString();

        Byte[] bytes = new UTF8Encoding(true).GetBytes(CleanJSON(content));
        outStream.Write(bytes, 0, bytes.Length);
    }
コード例 #28
0
        public ActionResult Export(string Ids)
        {
            try
            {
                var arr = Ids.Split(',');

                List <int> data = new List <int>();
                for (int i = 0; i < arr.Length; i++)
                {
                    data.Add(int.Parse(arr[i]));
                }
                var Id   = data.ToArray();
                var path = Path.Combine(HttpRuntime.AppDomainAppPath, EnvironmentHelper.TemplatePath(this.RouteData));
                var list = _inventoryRecordContract.InventoryRecords
                           .Where(m => Id.Contains(m.Id)).OrderByDescending(m => m.Id)
                           .Select(i => new
                {
                    i.Id,
                    i.RecordOrderNumber,
                    i.IdentifyId,
                    i.Store.StoreName,
                    i.Storage.StorageName,
                    i.TagPrice,
                    i.Quantity,
                    i.Operator.Member.MemberName,
                    i.CreatedTime,
                    i.IsDeleted,
                    i.IsEnabled,
                    TotalBrandCount = i.Inventories.Count() > 0 ? i.Inventories.Select(j => j.Product.ProductOriginNumber.Brand.BrandName).Distinct().Count() : 0
                })
                           .ToList();
                var group = new StringTemplateGroup("all", path, typeof(TemplateLexer));
                var st    = group.GetInstanceOf("Exporter");
                st.SetAttribute("list", list);
                var str    = st.ToString();
                var buffer = Encoding.UTF8.GetBytes(str);
                var stream = new MemoryStream(buffer);
                return(File(stream, "application/ms-excel", "入库记录.xls"));
            }
            catch (Exception e)
            {
                return(Json(new OperationResult(OperationResultType.Error, e.Message), JsonRequestBehavior.AllowGet));
            }
        }
コード例 #29
0
        public void Generate(string path)
        {
            StringTemplateGroup group        = new StringTemplateGroup("myGroup", @".\Templet");
            StringTemplate      st           = group.GetInstanceOf("Home");
            int           ID                 = 1;
            List <String> allMethodSigniture = new List <string>();

            foreach (var testSummary in AllTestSummary)
            {
                string methodSignature = testSummary.GetMethodSignature();
                st.SetAttribute("IDNum", ID++);
                st.SetAttribute("MethodSignature", methodSignature);
                var method       = testSummary.Method;
                var methodString = GetEntireMethodString(method);
                st.SetAttribute("SourceCode", methodString);
                bool bStartTests = false;
                if (testSummary.SwumSummary.StartsWith("test"))
                {
                    bStartTests = true;
                }
                st.SetAttribute("NotStartTests", !bStartTests);
                st.SetAttribute("SwumDesc", testSummary.SwumSummary.ToLower());

                st.SetAttribute("MethodBodyDesc", testSummary.GetBodyDescriptions());
                allMethodSigniture.Add(methodSignature);
            }
            allMethodSigniture.Sort();
            //hyper index
            foreach (var ms in allMethodSigniture)
            {
                st.SetAttribute("MethodLinkID", ms);
            }


            //st.SetAttribute("Message", "hello ");
            String result = st.ToString(); // yields "int x = 0;"
            //Console.WriteLine(result);

            StreamWriter writetext = new StreamWriter(path);

            writetext.WriteLine(result);
            writetext.Close();
        }
コード例 #30
0
        /** <summary>
         *  Return a list of all template sigs that are present in the group, but
         *  that have wrong formal argument lists.  Return null if all is well.
         *  </summary>
         */
        public virtual IList <string> GetMismatchedTemplates(StringTemplateGroup group)
        {
            List <string> mismatched = new List <string>();

            foreach (TemplateDefinition d in _templates.Values)
            {
                if (group.IsDefined(d.name))
                {
                    StringTemplate defST      = group.GetTemplateDefinition(d.name);
                    var            formalArgs = defST.FormalArguments;
                    bool           ack        = false;
                    if ((d.formalArgs != null && formalArgs == null) ||
                        (d.formalArgs == null && formalArgs != null) ||
                        d.formalArgs.Count != formalArgs.Count)
                    {
                        ack = true;
                    }
                    if (!ack)
                    {
                        foreach (var arg in formalArgs)
                        {
                            FormalArgument arg2;
                            if (!d.formalArgs.TryGetValue(arg.name, out arg2) || arg2 == null)
                            {
                                ack = true;
                                break;
                            }
                        }
                    }
                    if (ack)
                    {
                        //System.out.println(d.formalArgs+"!="+formalArgs);
                        mismatched.Add(GetTemplateSignature(d));
                    }
                }
            }
            if (mismatched.Count == 0)
            {
                mismatched = null;
            }
            return(mismatched);
        }
コード例 #31
0
        //throws RecognitionException, TokenStreamException
        public void group(
		StringTemplateGroup g
	)
        {
            IToken  name = null;

            try {      // for error handling
            match(LITERAL_group);
            name = LT(1);
            match(ID);
            g.setName(name.getText());
            match(SEMI);
            { // ( ... )+
                int _cnt3=0;
                for (;;)
                {
                    if ((LA(1)==ID) && (LA(2)==LPAREN||LA(2)==DEFINED_TO_BE) && (LA(3)==ID||LA(3)==RPAREN))
                    {
                        template(g);
                    }
                    else if ((LA(1)==ID) && (LA(2)==DEFINED_TO_BE) && (LA(3)==LBRACK)) {
                        mapdef(g);
                    }
                    else
                    {
                        if (_cnt3 >= 1) { goto _loop3_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; }
                    }

                    _cnt3++;
                }
            _loop3_breakloop:				;
            }    // ( ... )+
            }
            catch (RecognitionException ex)
            {
            reportError(ex);
            recover(ex,tokenSet_0_);
            }
        }
コード例 #32
0
        //throws RecognitionException, TokenStreamException
        public void group(
            StringTemplateGroup g
            )
        {
            IToken  name = null;
            IToken  s = null;
            IToken  i = null;
            IToken  i2 = null;

            this._group = g;

            try {      // for error handling
            match(LITERAL_group);
            name = LT(1);
            match(ID);
            g.Name = name.getText();
            {
                switch ( LA(1) )
                {
                case COLON:
                {
                    match(COLON);
                    s = LT(1);
                    match(ID);
                    g.SetSuperGroup(s.getText());
                    break;
                }
                case LITERAL_implements:
                case SEMI:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            {
                switch ( LA(1) )
                {
                case LITERAL_implements:
                {
                    match(LITERAL_implements);
                    i = LT(1);
                    match(ID);
                    g.ImplementInterface(i.getText());
                    {    // ( ... )*
                        for (;;)
                        {
                            if ((LA(1)==COMMA))
                            {
                                match(COMMA);
                                i2 = LT(1);
                                match(ID);
                                g.ImplementInterface(i2.getText());
                            }
                            else
                            {
                                goto _loop5_breakloop;
                            }

                        }
            _loop5_breakloop:						;
                    }    // ( ... )*
                    break;
                }
                case SEMI:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            match(SEMI);
            { // ( ... )+
                int _cnt7=0;
                for (;;)
                {
                    if ((LA(1)==ID||LA(1)==AT) && (LA(2)==ID||LA(2)==LPAREN||LA(2)==DEFINED_TO_BE) && (LA(3)==ID||LA(3)==DOT||LA(3)==RPAREN))
                    {
                        template(g);
                    }
                    else if ((LA(1)==ID) && (LA(2)==DEFINED_TO_BE) && (LA(3)==LBRACK)) {
                        mapdef(g);
                    }
                    else
                    {
                        if (_cnt7 >= 1) { goto _loop7_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; }
                    }

                    _cnt7++;
                }
            _loop7_breakloop:				;
            }    // ( ... )+
            }
            catch (RecognitionException ex)
            {
            reportError(ex);
            recover(ex,tokenSet_0_);
            }
        }
コード例 #33
0
        //throws RecognitionException, TokenStreamException
        public void mapdef(
            StringTemplateGroup g
            )
        {
            IToken  name = null;

            IDictionary m=null;

            try {      // for error handling
            name = LT(1);
            match(ID);
            match(DEFINED_TO_BE);
            m=map();

                    if ( g.GetMap(name.getText())!=null ) {
                        g.Error("redefinition of map: "+name.getText());
                    }
                    else if ( g.IsDefinedInThisGroup(name.getText()) ) {
                        g.Error("redefinition of template as map: "+name.getText());
                    }
                    else {
                        g.DefineMap(name.getText(), m);
                    }

            }
            catch (RecognitionException ex)
            {
            reportError(ex);
            recover(ex,tokenSet_1_);
            }
        }
コード例 #34
0
        //throws RecognitionException, TokenStreamException
        public void template(
            StringTemplateGroup g
            )
        {
            IToken  scope = null;
            IToken  region = null;
            IToken  name = null;
            IToken  t = null;
            IToken  bt = null;
            IToken  alias = null;
            IToken  target = null;

            StringTemplate st = null;
            string templateName=null;
            int line = LT(1).getLine();

            try {      // for error handling
            if ((LA(1)==ID||LA(1)==AT) && (LA(2)==ID||LA(2)==LPAREN))
            {
                {
                    switch ( LA(1) )
                    {
                    case AT:
                    {
                        match(AT);
                        scope = LT(1);
                        match(ID);
                        match(DOT);
                        region = LT(1);
                        match(ID);

                                    templateName=g.GetMangledRegionName(scope.getText(),region.getText());
                                    if ( g.IsDefinedInThisGroup(templateName) ) {
                                        g.Error("group "+g.Name+" line "+line+": redefinition of template region: @"+
                                            scope.getText()+"."+region.getText());
                                        st = new StringTemplate(); // create bogus template to fill in
                                    }
                                    else {
                                        bool err = false;
                                        // @template.region() ::= "..."
                                        StringTemplate scopeST = g.LookupTemplate(scope.getText());
                                        if ( scopeST==null ) {
                                            g.Error("group "+g.Name+" line "+line+": reference to region within undefined template: "+
                                                scope.getText());
                                            err=true;
                                        }
                                        if ( !scopeST.ContainsRegionName(region.getText()) ) {
                                            g.Error("group "+g.Name+" line "+line+": template "+scope.getText()+" has no region called "+
                                                region.getText());
                                            err=true;
                                        }
                                        if ( err ) {
                                            st = new StringTemplate();
                                        }
                                        else {
                                            st = g.DefineRegionTemplate(scope.getText(),
                                                                        region.getText(),
                                                                        null,
                                                                        StringTemplate.REGION_EXPLICIT);
                                        }
                                    }

                        break;
                    }
                    case ID:
                    {
                        name = LT(1);
                        match(ID);
                        templateName = name.getText();

                                if ( g.IsDefinedInThisGroup(templateName) ) {
                                    g.Error("redefinition of template: "+templateName);
                                    st = new StringTemplate(); // create bogus template to fill in
                                }
                                else {
                                    st = g.DefineTemplate(templateName, null);
                                }

                        break;
                    }
                    default:
                    {
                        throw new NoViableAltException(LT(1), getFilename());
                    }
                     }
                }
                if ( st!=null ) {st.GroupFileLine = line;}
                match(LPAREN);
                {
                    switch ( LA(1) )
                    {
                    case ID:
                    {
                        args(st);
                        break;
                    }
                    case RPAREN:
                    {
                        st.DefineEmptyFormalArgumentList();
                        break;
                    }
                    default:
                    {
                        throw new NoViableAltException(LT(1), getFilename());
                    }
                     }
                }
                match(RPAREN);
                match(DEFINED_TO_BE);
                {
                    switch ( LA(1) )
                    {
                    case STRING:
                    {
                        t = LT(1);
                        match(STRING);
                        st.Template = t.getText();
                        break;
                    }
                    case BIGSTRING:
                    {
                        bt = LT(1);
                        match(BIGSTRING);
                        st.Template = bt.getText();
                        break;
                    }
                    default:
                    {
                        throw new NoViableAltException(LT(1), getFilename());
                    }
                     }
                }
            }
            else if ((LA(1)==ID) && (LA(2)==DEFINED_TO_BE)) {
                alias = LT(1);
                match(ID);
                match(DEFINED_TO_BE);
                target = LT(1);
                match(ID);
                g.DefineTemplateAlias(alias.getText(), target.getText());
            }
            else
            {
                throw new NoViableAltException(LT(1), getFilename());
            }

            }
            catch (RecognitionException ex)
            {
            reportError(ex);
            recover(ex,tokenSet_1_);
            }
        }
コード例 #35
0
        //throws RecognitionException, TokenStreamException
        public void group(
		StringTemplateGroup g
	)
        {
            IToken  name = null;

            try {      // for error handling
            match(LITERAL_group);
            name = LT(1);
            match(ID);
            g.setName(name.getText());
            match(SEMI);
            {    // ( ... )*
                for (;;)
                {
                    if ((LA(1)==ID))
                    {
                        template(g);
                    }
                    else
                    {
                        goto _loop3_breakloop;
                    }

                }
            _loop3_breakloop:				;
            }    // ( ... )*
            }
            catch (RecognitionException ex)
            {
            reportError(ex);
            recover(ex,tokenSet_0_);
            }
        }
コード例 #36
0
        //throws RecognitionException, TokenStreamException
        public void template(
		StringTemplateGroup g
	)
        {
            IToken  name = null;
            IToken  t = null;
            IToken  alias = null;
            IToken  target = null;

            IDictionary formalArgs = null;
            StringTemplate st = null;
            bool ignore = false;

            try {      // for error handling
            if ((LA(1)==ID) && (LA(2)==LPAREN))
            {
                name = LT(1);
                match(ID);

                        if ( g.isDefinedInThisGroup(name.getText()) ) {
                            g.error("redefinition of template: "+name.getText());
                            st = new StringTemplate(); // create bogus template to fill in
                        }
                        else {
                            st = g.defineTemplate(name.getText(), null);
                        }

                match(LPAREN);
                {
                    switch ( LA(1) )
                    {
                    case ID:
                    {
                        args(st);
                        break;
                    }
                    case RPAREN:
                    {
                        st.defineEmptyFormalArgumentList();
                        break;
                    }
                    default:
                    {
                        throw new NoViableAltException(LT(1), getFilename());
                    }
                     }
                }
                match(RPAREN);
                match(DEFINED_TO_BE);
                t = LT(1);
                match(TEMPLATE);
                st.setTemplate(t.getText());
            }
            else if ((LA(1)==ID) && (LA(2)==DEFINED_TO_BE)) {
                alias = LT(1);
                match(ID);
                match(DEFINED_TO_BE);
                target = LT(1);
                match(ID);
                g.defineTemplateAlias(alias.getText(), target.getText());
            }
            else
            {
                throw new NoViableAltException(LT(1), getFilename());
            }

            }
            catch (RecognitionException ex)
            {
            reportError(ex);
            recover(ex,tokenSet_1_);
            }
        }