コード例 #1
0
        public IHttpActionResult Generate([FromUri]string format)
        {
            IGenerate generator = null;
            byte[] content;

            switch (format)
            {
                case "pdf":
                    {
                        generator = new GeneratePDF();
                        break;
                    }
                default:
                    return ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Invalid format"));

            }

            List<food> foods = _db.food.ToList();
            content = generator.Generate(foods);

            string pdfName = "Foods";

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.ContentType = "application/" + format;
            HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + pdfName + "." + format);
            HttpContext.Current.Response.ContentType = "application/" + format;
            HttpContext.Current.Response.Buffer = true;
            HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            HttpContext.Current.Response.BinaryWrite(content);
            HttpContext.Current.Response.End();
            HttpContext.Current.Response.Close();

            return Ok();
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: Strelchonok/Compare
 public HomeController(CompareContext _db, ICsvWriter _csv, IHostingEnvironment _env, IGenerate _gen)
 {
     this.db        = _db;
     this.CsvWriter = _csv;
     this.env       = _env;
     this.gen       = _gen;
 }
コード例 #3
0
        public InterfaceManager(IGenerate Generate, Texts text, string[] inputValue)
        {
            this.inputValue = inputValue;
            this.text       = text;

            _IGenerate = Generate;
        }
コード例 #4
0
 public HistogramController(IHistogramRepository repository, IUserEventRepository userEventRepository, IGenerate<Histogram> generateHistogram, IFeatureRepository featureRepository, IBackgroundJobClient backgroundJobClient)
 {
     this.repository = repository;
     this.userEventRepository = userEventRepository;
     this.generateHistogram = generateHistogram;
     this.featureRepository = featureRepository;
     this.backgroundJobClient = backgroundJobClient;
 }
コード例 #5
0
 public TimeSeriesController(ApiDataContext context, ITimeSeriesRepository timeSeriesRepository, IUserEventRepository userEventRepository, IGenerate<TimeSeries> generateTimeSeries, IFeatureRepository featureRepository, IBackgroundJobClient backgroundJobClient)
 {
     this.context = context;
     this.timeSeriesRepository = timeSeriesRepository;
     this.userEventRepository = userEventRepository;
     this.generateTimeSeries = generateTimeSeries;
     this.featureRepository = featureRepository;
     this.backgroundJobClient = backgroundJobClient;
 }
コード例 #6
0
 private IGenerate check(IGenerate exp)
 {
     if (exp == null)
     {
         return(null);
     }
     if (!match(";"))
     {
         LogWriter.WriteLexText(lineNo, "expect \";\"");
         return(null);
     }
     return(exp);
 }
コード例 #7
0
ファイル: BaseNpa.cs プロジェクト: wenzqbaby/CommonTools
        public BaseNpa(IDataAccess iDataAccess)
        {
            mType        = typeof(T);
            TAG          = this.GetType().ToString();
            mIDataAccess = iDataAccess;
            mIDataAccess.setLog(this.GetType());
            MemberInfo memberInfo = mType;

            try
            {
                Table entity = (Attribute.GetCustomAttribute(memberInfo, typeof(Table)) as Table);
                entity.setType(mType);
                mTable  = entity.Name;
                mScheme = entity.Scheme;
            }
            catch (Exception ex)
            {
                throw new Exception(TAG + "获取映射表名异常:" + memberInfo.Name + " " + ex.Message);
            }

            PropertyInfo[] propertyInfos = mType.GetProperties();
            columnsDic = new Dictionary <String, IColumn>(propertyInfos.Length);
            foreach (PropertyInfo pi in propertyInfos)
            {
                try
                {
                    Attribute attr = Attribute.GetCustomAttribute(pi, typeof(BaseColumn));
                    if (attr != null)
                    {
                        IColumn column = attr as IColumn;
                        column.setPropertyInfo(pi);
                        columnsDic[pi.Name] = column;
                        if (column.isIdColumn())
                        {
                            idList.Add(column);
                        }
                    }
                }
                catch (Exception e)
                {
                    throw new Exception(String.Format("{0} 获取类 {1} 的属性 {2} 注解异常:{3}", TAG, mType.Name, pi.Name, e.Message));
                }
            }
            mISave     = new Insert <T>(mScheme, mTable, columnsDic, idList, TAG);
            mIUpdate   = new Update <T>(mScheme, mTable, columnsDic, idList, TAG);
            mIDelete   = new Delete <T>(mScheme, mTable, columnsDic, idList, TAG);
            mISelect   = new Select <T>(mScheme, mTable, columnsDic, TAG);
            mICount    = new Count <T>(mScheme, mTable, columnsDic, idList, TAG);
            mIGenerate = new Generate <T>(columnsDic, TAG);
            mICreate   = new Creator();
        }
コード例 #8
0
        static private void WriteFile(IGenerate generator, List <NodeFeature> features, string outputDirectory, string extension, string consoleMessage)
        {
            List <string[]> listOfContents = generator.Generate(GetLanguageConfig(), features);

            for (int i = 0; i < listOfContents.Count; i++)
            {
                string file = string.Format("{0}{1}{2}", outputDirectory, features[i].Name, extension);
                Console.WriteLine(string.Format("{0}: {1}", consoleMessage, file));
                File.WriteAllLines(file, listOfContents[i]);
                if (!_singleFile)
                {
                    AddFilesToCppProject(file, FEATURE_DIR, CPP_PROJ);
                }
            }
        }
コード例 #9
0
        private Exp_Block match_expressions()
        {
            if (index == code.Length)
            {
                return(null);
            }
            IGenerate        exp     = match_stat();
            List <IGenerate> expList = new List <IGenerate>();

            while (exp != null)
            {
                expList.Add(exp);
                exp = match_stat();
            }
            return(new Exp_Block(expList));
        }
コード例 #10
0
        private IGenerate match_stat()
        {
            if (match("at"))
            {
                index -= 2;
                return(null);
            }
            else if (match("#"))
            {
                index--;
                return(null);
            }

            IGenerate exp = match_function_expression();

            if (exp != null)
            {
                return(exp);
            }
            exp = match_expression();
            return(check(exp));
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: SCRUMdifferent/specflowC
 private static void WriteFile(IGenerate generator, List<NodeFeature> features, string outputDirectory, string extension, string consoleMessage)
 {
     List<string[]> listOfContents = generator.Generate(GetLanguageConfig(), features);
     for (int i = 0; i < listOfContents.Count; i++)
     {
         string file = string.Format("{0}{1}{2}", outputDirectory, features[i].Name, extension);
         Console.WriteLine(string.Format("{0}: {1}", consoleMessage, file));
         File.WriteAllLines(file, listOfContents[i]);
         if (!_singleFile)
         {
             AddFilesToCppProject(file, FEATURE_DIR, CPP_PROJ);
         }
     }
 }
コード例 #12
0
 //brige
 public void generate(IGenerate generate, string nameSpace)
 {
     generate.Generate(this, nameSpace);
 }
コード例 #13
0
 public GenerateTests(Generate generate)
 {
     _generate = generate;
 }
コード例 #14
0
 public FachadaModel(IGenerate model)
 {
     _model = model;
 }