Esempio n. 1
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, "盘点详情列表"));
        }
Esempio n. 2
0
        public ActionResult Export(int[] Id)
        {
            var path  = Path.Combine(HttpRuntime.AppDomainAppPath, EnvironmentHelper.TemplatePath(this.RouteData));
            var list  = _expressContract.Expresss.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 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));
            }
        }
Esempio n. 4
0
        public string Generate(IEnumerable <OntologyClass> classes, Options opts)
        {
            StringTemplate template = stringTemplateGroup.GetInstanceOf("classes");

            template.SetAttribute("classes", classes);
            template.SetAttribute("handle", opts.OntologyPrefix);
            template.SetAttribute("uri", opts.OntologyNamespace);
            template.SetAttribute("opts", opts);
            template.SetAttribute("refs", opts.DotNetNamespaceReferences.Split(','));
            return(template.ToString());
        }
Esempio n. 5
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);
    }
        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"));
        }
    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)));
    }
Esempio n. 8
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);
        }
Esempio n. 9
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);
    }
        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));
            }
        }
Esempio n. 11
0
        public string RapportMail(IEnumerable <IInfosTraitementParution> infosParutions)
        {
            var cabsIndisponibles =
                from i in infosParutions
                where i.CabAbsent && i.EtatCabOnline == EtatCabOnline.Indisponible
                orderby i.DateDhl
                select new InfosParutionStAdapter(i);
            var cabsBloqués =
                from i in infosParutions
                where i.CabAbsent && i.EtatCabOnline == EtatCabOnline.Incompatible
                orderby i.DateDhl
                select new InfosParutionStAdapter(i);
            var cabsIncompatibles =
                from i in infosParutions
                where i.EtatCab == EtatCab.Incompatible
                orderby i.DateDhl
                select new InfosParutionStAdapter(i);
            var cabsAnormauxAvecAction =
                from i in infosParutions
                where i.EtatCab == EtatCab.ActionNécessaire
                orderby i.DateDhl
                select new InfosParutionStAdapter(i);
            var cabsAnormaux =
                from i in infosParutions
                where i.EtatCab == EtatCab.Anormal
                orderby i.DateDhl
                select new InfosParutionStAdapter(i);
            var cabsTéléchargés =
                from i in infosParutions
                where i.EtatCabOnline == EtatCabOnline.Téléchargé
                orderby i.DateDhl
                select new InfosParutionStAdapter(i);

            var bodyTemplate = _stg.GetInstanceOf("body");

            bodyTemplate.SetAttribute("date", DateTime.Now);
            bodyTemplate.SetAttribute("cabsIndisponibles", cabsIndisponibles);
            bodyTemplate.SetAttribute("cabsBloques", cabsBloqués);
            bodyTemplate.SetAttribute("cabsIncompatibles", cabsIncompatibles);
            bodyTemplate.SetAttribute("cabsAnormauxAvecAction", cabsAnormauxAvecAction);
            bodyTemplate.SetAttribute("cabsAnormaux", cabsAnormaux);
            bodyTemplate.SetAttribute("cabsTelecharges", cabsTéléchargés);
            return(bodyTemplate.ToString());
        }
Esempio n. 12
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();
        }
Esempio n. 13
0
        public ActionResult Export()
        {
            var path = Path.Combine(HttpRuntime.AppDomainAppPath, EnvironmentHelper.TemplatePath(this.RouteData));

            GridRequest request = new GridRequest(Request);
            Expression <Func <Appointment, bool> > predicate = FilterHelper.GetExpression <Appointment>(request.FilterGroup);
            var query = _appointmentContract.Entities.Where(predicate);

            var list = query.Select(s => new
            {
                s.Number,
                s.Store.StoreName,
                s.Member.RealName,
                s.Member.MobilePhone,
                State = s.State + "",
                s.StartTime,
                s.EndTime,
                s.UpdatedTime,
                ProductNumber         = s.ProductNumber,
                DislikeProductNumbers = s.DislikeProductNumbers,
                s.SelectedPlanId,
            }).ToList().Select(s => new
            {
                s.Number,
                s.StoreName,
                s.RealName,
                s.MobilePhone,
                s.State,
                StartTime = s.StartTime.HasValue ? s.StartTime.Value.ToString("MM-dd HH:mm") : null,
                EndTime   = s.EndTime.HasValue ? s.EndTime.Value.ToString("MM-dd HH:mm") : null,
                s.UpdatedTime,
                PlanCount    = s.SelectedPlanId.HasValue ? 1 : 0,
                LikeCount    = s.ProductNumber != null ? s.ProductNumber.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Count() : 0,
                DislikeCount = s.DislikeProductNumbers != null ? s.DislikeProductNumbers.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Count() : 0,
            }).ToList();

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

            st.SetAttribute("list", list);
            return(FileExcel(st, "预约管理"));
        }
        public ActionResult Export()
        {
            var         path    = Path.Combine(HttpRuntime.AppDomainAppPath, EnvironmentHelper.TemplatePath(this.RouteData));
            GridRequest request = new GridRequest(Request);
            Expression <Func <AppointmentGen, bool> > predicate = FilterHelper.GetExpression <AppointmentGen>(request.FilterGroup);
            var query = _AppointmentGenContract.Entities.Where(predicate);
            var list  = (from s in query
                         select new
            {
                s.UpdatedTime,
                OperatorName = s.Operator.Member.RealName,
                s.AllCount,
                s.SuccessCount,
            }).ToList();
            var group = new StringTemplateGroup("all", path, typeof(TemplateLexer));
            var st    = group.GetInstanceOf("Exporter");

            st.SetAttribute("list", list);
            return(FileExcel(st, "预约数据生成"));
        }
Esempio n. 15
0
        public ActionResult Export()
        {
            GridRequest request     = new GridRequest(Request);
            FilterRule  rule        = request.FilterGroup.Rules.FirstOrDefault(x => x.Field == "RealName");
            string      strRealName = string.Empty;

            if (rule != null)
            {
                strRealName = rule.Value.ToString();
                request.FilterGroup.Rules.Remove(rule);
            }
            Expression <Func <AdjustDeposit, bool> > predicate = FilterHelper.GetExpression <AdjustDeposit>(request.FilterGroup);
            IQueryable <AdjustDeposit> listAdjustDeposit       = _adjustDepositContract.AdjustDeposits;

            if (!string.IsNullOrEmpty(strRealName))
            {
                IQueryable <Administrator> listAdmin = _adminContract.Administrators.Where(x => x.Member.RealName.Contains(strRealName));
                listAdjustDeposit = listAdjustDeposit.Where(x => listAdmin.Where(k => k.Id == x.ApplicantId).Count() > 0);
            }
            var list = listAdjustDeposit.Where(predicate).Select(m => new
            {
                Applicant = m.ApplicantId == null ? string.Empty : m.Applicant.Member.RealName,
                Reviewers = m.ReviewersId == null ? string.Empty : m.Reviewers.Member.RealName,
                //m.Member.MemberName,
                m.Member.RealName,
                m.Member.MobilePhone,
                m.MemberId,
                Balance = m.Balance, // > 0 ? m.Balance * -1 : m.Balance,
                Score   = m.Score,   // > 0 ? m.Score * -1 : m.Score,
                m.UpdatedTime,
                m.VerifyType,
            }).ToList();

            var path  = Path.Combine(HttpRuntime.AppDomainAppPath, EnvironmentHelper.TemplatePath(this.RouteData));
            var group = new StringTemplateGroup("all", path, typeof(TemplateLexer));
            var st    = group.GetInstanceOf("Exporter");

            st.SetAttribute("list", list);
            return(FileExcel(st, "储值积分维护"));
        }
Esempio n. 16
0
        private string SetStringTemplate(List <ChangelogEntry> clEntries)
        {
            StringTemplate changeLog = new StringTemplate("$logEntry; separator=\"\\n\"$\r\nGenerated with Subversion Changelog Generator $currentVersion$\r\nCopyright © CharlieFirpo 2009 <*****@*****.**>");

            changeLog.SetAttribute("currentVersion", Program.AssemblyVersion);

            foreach (ChangelogEntry cle in clEntries)
            {
                if (cle.Msg.Count > 0)
                {
                    StringTemplate logEntry = m_ClGrp.GetInstanceOf("Templates/ChangeLog");
                    logEntry.SetAttribute("date", cle.Dates[0]);
                    logEntry.SetAttribute("version", cle.VersionString);
                    logEntry.SetAttribute("revisions", cle.Revisions);
                    logEntry.SetAttribute("msg", cle.Msg);
                    logEntry.SetAttribute("paths", cle.Paths);
                    logEntry.SetAttribute("authors", cle.Authors);
                    changeLog.SetAttribute("logEntry", logEntry);
                }
            }

            return(changeLog.ToString());
        }
        public ActionResult Export()
        {
            var path = Path.Combine(HttpRuntime.AppDomainAppPath, EnvironmentHelper.TemplatePath(this.RouteData));

            GridRequest request = new GridRequest(Request);
            Expression <Func <MemberDeposit, bool> > predicate = FilterHelper.GetExpression <MemberDeposit>(request.FilterGroup);

            var query = _memberdepositContract.MemberDeposits.Where(predicate);
            var list  = query.Select(m => new
            {
                OrderType = m.OrderType + "",
                m.RelatedOrderNumber,
                m.MemberId,
                m.Member.RealName,
                m.Member.MobilePhone,
                m.Quotiety,
                m.Price,
                m.Cash,
                m.Card,
                m.Coupon,
                m.Notes,
                m.Score,
                m.UpdatedTime,
                m.order_Uid,
                AdminName = m.Operator.Member.MemberName,
                m.Operator.Department.DepartmentName,
                StoreName      = m.Store.StoreName ?? string.Empty,
                DepositContext = m.DepositContext.HasValue ? m.DepositContext + "" : string.Empty
            }).ToList();

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

            st.SetAttribute("list", list);
            return(FileExcel(st, "充值记录管理"));
        }
Esempio n. 18
0
        public string GetPathDescriptions(int num)
        {
            StringTemplateGroup group = new StringTemplateGroup("myGroup", @".\Templet");
            StringTemplate      st    = group.GetInstanceOf("PathTemplate");

            st.SetAttribute("Number", num);
            int  i       = 0;
            bool isFirst = true;

            foreach (var vs in VariableStmts)
            {
                var    loc        = vs.Stmt.Locations.FirstOrDefault();
                string lineNumber = "";
                if (loc != null)
                {
                    if (vs.Variable.Location.SourceFileName == loc.SourceFileName)
                    {
                        lineNumber += loc.StartingLineNumber;
                    }
                }

                if (isFirst)
                {
                    if (vs.Variable.Name == "")
                    {
                        return("");
                    }
                    st.SetAttribute("rootVar", vs.Variable.Name);
                    isFirst = false;
                }
                st.SetAttribute("Variable", vs.Variable.Name + "(@line " + lineNumber + ")");
                //st.SetAttribute("Variable", System.Net.WebUtility.HtmlEncode(vs.Stmt.ToString().Replace(" . ", ".")) + "(@line " + lineNumber + ")" );
                i++;
            }
            return(("\n" + st.ToString()).Trim());
        }
Esempio n. 19
0
    private static void WriteAnimationJson(AnimationClip clip, Stream outStream)
    {
        AnimationClipCurveData[] curves = AnimationUtility.GetAllCurves(clip);

        int frameCount = (int)(clip.frameRate * clip.length);

        Dictionary <string, WebGLAnimatedBone> boneTable = new Dictionary <string, WebGLAnimatedBone>();

        int i;

        // Gather the transform information for all
        foreach (AnimationClipCurveData curveData in curves)
        {
            AnimationCurve curve    = curveData.curve;
            string         boneName = curveData.path;

            int pathSeparator = boneName.LastIndexOf('/');
            if (pathSeparator != -1)
            {
                boneName = boneName.Substring(pathSeparator + 1);
            }

            WebGLAnimatedBone animatedBone;

            if (!boneTable.TryGetValue(boneName, out animatedBone))
            {
                animatedBone           = new WebGLAnimatedBone();
                animatedBone.bone      = boneName;
                animatedBone.keyframes = new WebGLBoneKeyframe[frameCount];

                boneTable.Add(boneName, animatedBone);
            }

            for (i = 0; i < frameCount; ++i)
            {
                float frameTime = (float)i * (1.0f / (float)clip.frameRate);
                float frameVal  = curve.Evaluate(frameTime);
                switch (curveData.propertyName)
                {
                case "m_LocalRotation.x": animatedBone.keyframes[i].rot.x = frameVal; break;

                case "m_LocalRotation.y": animatedBone.keyframes[i].rot.y = frameVal; break;

                case "m_LocalRotation.z": animatedBone.keyframes[i].rot.z = frameVal; break;

                case "m_LocalRotation.w": animatedBone.keyframes[i].rot.w = frameVal; break;

                case "m_LocalPosition.x": animatedBone.keyframes[i].pos.x = frameVal; break;

                case "m_LocalPosition.y": animatedBone.keyframes[i].pos.y = frameVal; break;

                case "m_LocalPosition.z": animatedBone.keyframes[i].pos.z = frameVal; break;
                }
            }
        }

        List <WebGLKeyframe> keyframes = new List <WebGLKeyframe>();

        for (i = 0; i < frameCount; ++i)
        {
            WebGLKeyframe keyFrame = new WebGLKeyframe();
            keyFrame.id    = i;
            keyFrame.bones = new List <WebGLBoneKeyframe>();

            foreach (WebGLAnimatedBone animatedBone in boneTable.Values)
            {
                keyFrame.bones.Add(animatedBone.keyframes[i]);
            }

            keyframes.Add(keyFrame);
        }

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

        animTemplate.SetAttribute("clip", clip);
        animTemplate.SetAttribute("clipLength", (int)(clip.length * 1000.0)); // Why does this die if I try to pull it from clip directly in the template?
        animTemplate.SetAttribute("frameCount", frameCount);
        animTemplate.SetAttribute("bones", boneTable.Values);
        animTemplate.SetAttribute("keyframes", keyframes);
        //animTemplate.SetAttribute("curves", curves);

        string content = animTemplate.ToString();

        Byte[] bytes = new UTF8Encoding(true).GetBytes(CleanJSON(content));
        outStream.Write(bytes, 0, bytes.Length);
    }
        public string GetBodyDescriptions()
        {
            StringTemplateGroup group = new StringTemplateGroup("myGroup", @".\Templet");
            StringTemplate      st    = group.GetInstanceOf("MethodBody");



            HashSet <Statement> focalMethodSet = new HashSet <Statement>();



            int num = 1;
            Dictionary <Statement, List <Statement> > focalToAssert = new Dictionary <Statement, List <Statement> >();

            foreach (var assertInfo in ListAssertInfo)
            {
                if (assertInfo.focalStmt != null)
                {
                    var fMethod = assertInfo.focalStmt;
                    if (!focalToAssert.ContainsKey(fMethod))
                    {
                        focalToAssert[fMethod] = new List <Statement>();
                        focalToAssert[fMethod].Add(assertInfo.AssertStatment);
                    }
                    else
                    {
                        focalToAssert[fMethod].Add(assertInfo.AssertStatment);
                    }

                    focalMethodSet.Add(assertInfo.focalStmt);
                }
            }


            //Focal method part
            bool          first = true;
            StringBuilder sb    = new StringBuilder();

            foreach (KeyValuePair <Statement, List <Statement> > entry in focalToAssert)
            {
                var fMethod = entry.Key;
                if (first)
                {
                    sb.Append(
                        "<br><br><span class=\"glyphicon glyphicon-bell\"></span><b>This unit test case includes following focal methods: </b>");
                    first = false;
                }
                StringBuilder focalInfo = new StringBuilder();
                if (IsAssert(fMethod))
                {
                    focalInfo.Append("(" + num++ + ") " + "An assertion in line ");
                    var firstOrDefault = fMethod.Locations.FirstOrDefault();
                    int line           = 0;
                    if (firstOrDefault != null)
                    {
                        line = firstOrDefault.StartingLineNumber;
                    }
                    focalInfo.Append(line);
                    focalInfo.Append("  validating that ");
                    focalInfo.Append(AssertSTInfo.TranslateAssert(fMethod));
                    sb.Append("<br>" + focalInfo);
                }
                else
                {
                    var firstOrDefault = fMethod.Locations.FirstOrDefault();
                    if (firstOrDefault != null)
                    {
                        focalInfo.Append("(" + num++ + ") " + fMethod.ToString().Replace(" . ", ".") + "(@line " +
                                         firstOrDefault.StartingLineNumber + ")");
                    }
                    else
                    {
                        focalInfo.Append("(" + num++ + ") " + fMethod.ToString().Replace(" . ", "."));
                    }
                    var assertSet = entry.Value;
                    int i         = 0;
                    foreach (var assertStmt in assertSet)
                    {
                        if (i == 0)
                        {
                            focalInfo.Append("<br> This focal method is related with assertions at ");
                        }
                        else
                        {
                            focalInfo.Append(", ");
                        }
                        StringTemplate stFA = group.GetInstanceOf("FocalAssert");
                        stFA.SetAttribute("Statment", System.Net.WebUtility.HtmlEncode(assertStmt.ToString().Replace(" . ", ".")));
                        firstOrDefault = assertStmt.Locations.FirstOrDefault();
                        int line = 0;
                        if (firstOrDefault != null)
                        {
                            line = firstOrDefault.StartingLineNumber;
                        }
                        stFA.SetAttribute("LineNumber", line);
                        focalInfo.Append(stFA.ToString());
                        i++;
                    }
                    sb.Append("<br>" + focalInfo);
                }
            }
            st.SetAttribute("FocalMethodDesc", sb.ToString());


            //Assertion part
            int           ID = 1;
            StringBuilder TestCasesDescBuilder = new StringBuilder();

            foreach (var assertInfo in ListAssertInfo)
            {
                //avoid since the information is shown in focal method discription
                if (focalMethodSet.Contains(assertInfo.AssertStatment))
                {
                    continue;
                }
                //string methodSignature = testSummary.GetMethodSignature();
                string discAssertion = assertInfo.GetAssertionDescriptions(ID++);

                //for focal method
                //Statement focalStmt = assertInfo.FindThisFocalMethodStmt();
                //
                TestCasesDescBuilder.Append(discAssertion);
            }

            st.SetAttribute("TotalNumGZ", ID > 1);
            if (ID != 1)
            {
                st.SetAttribute("TestCasesDesc", TestCasesDescBuilder.ToString());
            }
            //st.SetAttribute("FocalMethodDesc", "Focal Method");


            return(st.ToString());
        }
Esempio n. 21
0
        /// <summary>
        /// Get description for the current assertion
        /// </summary>
        /// <param name="num"></param>
        /// <returns></returns>
        public string GetAssertionDescriptions(int num)
        {
            StringTemplateGroup group = new StringTemplateGroup("myGroup", @".\Templet");
            StringTemplate      st    = group.GetInstanceOf("AssertionTemplate");

            st.SetAttribute("Number", num);
            st.SetAttribute("Assertion", TranslateAssert(this.AssertStatment));
            //st.SetAttribute("Assertion", AssertStatment.ToString().Replace(" ", ""));


            //TODO: JavaCodeParserTests . BasicParentTest_Java  focal method is null. Handle at template
            //if (focalStmt != null) {
            //    var firstOrDefault = focalStmt.Locations.FirstOrDefault();
            //    if (firstOrDefault != null) {
            //        st.SetAttribute("FocalMethod",
            //            focalStmt.ToString().Replace(" . ", ".") + "(@line " + firstOrDefault.StartingLineNumber + ")");
            //    } else {
            //        st.SetAttribute("FocalMethod", focalStmt.ToString().Replace(" . ", "."));
            //    }
            //}

            StringBuilder       rootPathDesc = new StringBuilder();
            int                 PathID       = 1;
            VariableDeclaration LastVar      = null;
            bool                first        = true;
            int                 appendNum    = 0;
            bool                pathNotNull  = false;

            foreach (var path in ListPath)
            {
                var curFocalVar = path.VariableStmts.LastOrDefault().Variable;
                if (curFocalVar == null)
                {
                    continue;
                }
                else
                {
                    if (LastVar != curFocalVar)
                    {
                        if (!first)
                        {
                            if (rootPathDesc.ToString() != "")
                            {
                                pathNotNull = true;
                            }
                            st.SetAttribute("pathNotNull", pathNotNull);
                            st.SetAttribute("pathInfo", rootPathDesc.ToString());
                        }
                        st.SetAttribute("focalVariable", curFocalVar.Name);
                        first     = false;
                        LastVar   = curFocalVar;
                        appendNum = 0;
                    }
                }

                //string methodSignature = testSummary.GetMethodSignature();
                if (IsLocalPath(path))
                {
                    if (appendNum > 0)
                    {
                        rootPathDesc.Append("<br>&nbsp&nbsp&nbsp<i>" + (appendNum + 1) + ") </i>");
                    }
                    else
                    {
                        rootPathDesc.Append("<br>&nbsp&nbsp&nbsp<i>" + (appendNum + 1) + ")</i> ");
                    }
                    rootPathDesc.Append(path.GetPathDescriptions(PathID++));
                    appendNum++;
                }
            }
            if (rootPathDesc.ToString() != "")
            {
                pathNotNull = true;
            }
            st.SetAttribute("pathNotNull", pathNotNull);
            st.SetAttribute("pathInfo", rootPathDesc.ToString());
            return(st.ToString());
        }
Esempio n. 22
0
    public static StringTemplate LoadTemplate(string name)
    {
        StringTemplateGroup templateGroup = new StringTemplateGroup("MG", templatePath, typeof(DefaultTemplateLexer));

        return(templateGroup.GetInstanceOf(name));
    }
        public StringTemplate ToFunctionDict()
        {
            List <StringTemplate> templateFunctions = new List <StringTemplate>();

            foreach (FunctionSig sig in functions)
            {
                StringTemplate st = TemplateGroup.GetInstanceOf("functionsig",
                                                                new Dictionary <string, object>
                {
                    { "id", sig.FunctionName },
                    { "returntype", sig.ReturnType },
                    { "paramtypes", sig.ParamTypes },
                    { "paramnames", sig.ParamNames },
                    { "tableindex", sig.TableIndex }
                }
                                                                );

                templateFunctions.Add(st);
            }

            return(TemplateGroup.GetInstanceOf("functiondict", new Dictionary <string, object> {
                { "sigs", templateFunctions }
            }));
        }
Esempio n. 24
0
        public ActionResult Export(int[] Id)
        {
            var path = Path.Combine(HttpRuntime.AppDomainAppPath, EnvironmentHelper.TemplatePath(this.RouteData));

            GridRequest request = new GridRequest(Request);
            var         optId   = AuthorityHelper.OperatorId;

            if (!optId.HasValue)
            {
                throw new Exception("optId is null");
            }
            Expression <Func <Checker, bool> > predicate = FilterHelper.GetExpression <Checker>(request.FilterGroup);

            IQueryable <Checker> listChecker = _checkerContract.Checkers.OrderByDescending(c => c.CreatedTime)
                                               .Where(x => x.IsEnabled == true && x.IsDeleted == false);
            Dictionary <string, Checker> dic = new Dictionary <string, Checker>();

            foreach (Checker checker in listChecker)
            {
                int index = dic.Where(x => x.Value.StoreId == checker.StoreId && x.Value.StorageId == checker.StorageId).Count();
                if (index > 0)
                {
                    continue;
                }
                else
                {
                    if (!dic.ContainsKey(checker.CheckGuid))
                    {
                        dic.Add(checker.CheckGuid, new Checker()
                        {
                            StoreId = checker.StoreId, StorageId = checker.StorageId
                        });
                    }
                }
            }

            IQueryable <Brand>    listBrand    = _brandContract.Brands.Where(x => x.IsDeleted == false && x.IsEnabled == true);
            IQueryable <Category> listCategory = _categoryContract.Categorys.Where(x => x.IsDeleted == false && x.IsEnabled == true);
            var query = _checkerContract.Checkers;

            if (request.FilterGroup.Rules.Count(i => i.Field == "StorageId") <= 0)
            {
                var enableStoreIds = _storeContract.QueryManageStoreId(AuthorityHelper.OperatorId.Value);
                query = query.Where(c => enableStoreIds.Contains(c.StoreId));
            }
            var list = query.OrderByDescending(c => c.CreatedTime).Where(predicate).Select(m => new
            {
                Id                  = m.CheckGuid,
                ParentId            = "",
                StoreName           = m.Store.StoreName,
                StorageName         = m.Storage.StorageName,
                BrandName           = listBrand.FirstOrDefault(x => x.Id == m.BrandId) == null ? "全部" : listBrand.FirstOrDefault(x => x.Id == m.BrandId).BrandName,
                CategoryName        = listCategory.FirstOrDefault(x => x.Id == m.CategoryId) == null ? "全部" : listCategory.FirstOrDefault(x => x.Id == m.CategoryId).CategoryName,
                CheckerName         = m.CheckerName,
                BeforeCheckQuantity = m.BeforeCheckQuantity,
                CheckedQuantity     = m.CheckedQuantity,
                CheckedCount        = m.ValidQuantity + m.ResidueQuantity + m.MissingQuantity,
                ValidCount          = m.ValidQuantity,
                ResidueCount        = m.ResidueQuantity,
                MissingCount        = m.MissingQuantity,
                Notes               = m.Notes,
                CreatedTime         = m.UpdatedTime,
                CheckerState        = m.CheckerState,
                AdminName           = 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, "盘点管理"));
        }