コード例 #1
0
        public async Task SaveNewResourceAsync(int currentUserId, Resource resource)
        {
            resource.PersonId = currentUserId;
            resource.EntryMade = DateTime.Now;

            await _dataService.AddResourceAsync(resource);
        }
コード例 #2
0
        public IResource CreateResource(ResourceType resourceType, int quantity)
        {
            var resource = new Resource(resourceType, quantity);

            return resource;
        }
コード例 #3
0
ファイル: AppsHelper.cs プロジェクト: kirannadell/ironfoundry
 private Resource[] CheckResources(Resource[] resourceAry)
 {
     /*
         Send in a resources manifest array to the system to have
         it check what is needed to actually send. Returns array
         indicating what is needed. This returned manifest should be
         sent in with the upload if resources were removed.
         E.g. [{:sha1 => xxx, :size => xxx, :fn => filename}]
      */
     var r = base.BuildVcapJsonRequest(Method.POST, Constants.RESOURCES_PATH);
     r.AddBody(resourceAry);
     IRestResponse response = r.Execute();
     return JsonConvert.DeserializeObject<Resource[]>(response.Content);
 }
コード例 #4
0
        public static void CreateDummyDataIfEmpty(ISession dataSession)
        {
            if (dataSession.CreateCriteria<Resource>().List<Resource>().Any()) return;
            using (var tx = dataSession.BeginTransaction())
            {
                //var tag1 = new Tag { Name = "Windows7" };
                //DataSession.Save(tag1);

                #region Resource Spam - Solutions Anyone?

                var resource = new Resource
                                   {
                                       Tags = (ProficiencyNovice + ProficiencyIntermediate
                                                + SmallOrgSize + MediumOrgSize + LargeOrgSize
                                                + Promoted
                                                + "Email,Spam").WrapCommas(),
                                       Title = "Spam - solutions anyone?",
                                       Uri = "http://www.ictknowledgebase.org.uk/spamsolutions",
                                       ShortDescription =
                                           "Spam (unsolicited bulk email) is now a real problem for many organisations. This article will help you choose a solution for your organisation.",
                                       LongDescription =
                                           "Spam (unsolicited bulk email) is now a real problem for many organisations. This article looks in more depth at how the various solutions on offer work and provides some guidance on issues to consider when choosing a solution for your organisation.",
                                       ResourceType = "ExternalLink"
                                   };
                dataSession.Save(resource);

                #endregion

                #region Resource Delete an email contact or an address book

                resource = new Resource
                               {
                                   Tags = (ProficiencyNovice +
                                            MediumOrgSize + LargeOrgSize +
                                            Promoted +
                                            "Email,Contact,AddressBook").WrapCommas(),
                                   Title = "Delete an email contact or an address book",
                                   Uri = "http://www.youtube.com/embed/juYn0TUrW90",
                                   ShortDescription =
                                       "This is a training video to help you delete a contact or addressbook in CTT Mail.",
                                   LongDescription =
                                       "This is a training video to help you delete a contact or addressbook in CTT Mail.",
                                   ResourceType = "YouTubeVideo"
                               };
                dataSession.Save(resource);

                #endregion

                #region Resource Font Colours

                resource = new Resource
                               {
                                   Tags = (ProficiencyNovice +
                                                SmallOrgSize + "Email,Font").WrapCommas(),
                                   Title = "Changing Font Colours in Email",
                                   Uri = "http://www.youtube.com/embed/ZQQloZ3rk5g",
                                   ShortDescription =
                                       "This is a training video to help you change the font colours used in CTT Mail.",
                                   LongDescription =
                                       "This is a training video to help you change the font colours used in CTT Mail.",
                                   ResourceType = "YouTubeVideo"
                               };
                dataSession.Save(resource);

                #endregion

                #region Resource PCI-DSS regulations – D day for charities

                resource = new Resource
                               {
                                   Tags = (ProficiencyExpert +
                                                LargeOrgSize +
                                                Promoted +
                                                "Payments,PCI-DSS").WrapCommas(),
                                   Title = "PCI-DSS regulations – D day for charities",
                                   Uri = "http://www.ctt.org/sites/default/files/PCI_Whitepaper.pdf",
                                   ShortDescription =
                                       "Payment Card Industry – Data Security Standards (PCI-DSS) were developed to address the increased threat of card fraud around the world.",
                                   LongDescription =
                                       "Payment Card Industry – Data Security Standards (PCI-DSS) were developed to address the increased threat of card fraud around the world.",
                                   ResourceType = "PDF"
                               };
                dataSession.Save(resource);

                #endregion

                #region Resource Paperless Direct Debit (PDD) User Guide

                resource = new Resource
                               {
                                   Tags = (ProficiencyIntermediate + ProficiencyExpert +
                                                MediumOrgSize + LargeOrgSize + "Payments,DirectDebit").WrapCommas(),
                                   Title = "Paperless Direct Debit (PDD) User Guide",
                                   Uri = "http://www.ctt.org/sites/default/files/pdd_userguide290711.pdf",
                                   ShortDescription =
                                       "A user guide for the Paperless Direct Debit (PDD) system.",
                                   LongDescription =
                                       "A user guide for the Paperless Direct Debit (PDD) system.",
                                   ResourceType = "PDF"
                               };
                dataSession.Save(resource);

                #endregion

                #region CTPayments Pricing

                resource = new Resource
                               {
                                   Tags = (ProficiencyIntermediate + ProficiencyExpert +
                                            MediumOrgSize + "Payments,Pricing").WrapCommas(),
                                   Title = "CTPayments Pricing",
                                   Uri = "http://www.ctt.org/ctpayments/pricing",
                                   ShortDescription =
                                       "A pricing list for the CTPayments Pricing system",
                                   LongDescription =
                                       "A pricing list for the CTPayments Pricing system",
                                   ResourceType = "InternalLink"
                               };
                dataSession.Save(resource);

                #endregion

                #region Sight Advice South Lakes - CTT case study

                resource = new Resource
                               {
                                   Tags = (ProficiencyNovice + ProficiencyIntermediate + ProficiencyExpert +
                                            SmallOrgSize + MediumOrgSize + LargeOrgSize +
                                            "CaseStudy,DonatedTechnology").WrapCommas(),
                                   Title = "Sight Advice South Lakes - CTT case study",
                                   Uri = "http://www.youtube.com/embed/rNnKJ6naWgQ",
                                   ShortDescription =
                                       "The Sight Advice South Lakes charity has set up a technology suite, using donated software from CTT and Microsoft, aimed at providing new opportunities for their clients.",
                                   LongDescription =
                                       "Sight Advice South Lakes are a small charity supporting blind, partially sighted and vision impaired people in South Lakeland, Cumbria. The charity has set up a technology suite, using donated software from CTT and Microsoft, aimed at providing new opportunities for their clients.",
                                   ResourceType = "YouTubeVideo"
                               };
                dataSession.Save(resource);

                #endregion

                #region Why Be Concerned About Managing IT

                resource = new Resource
                               {
                                   Tags = (ProficiencyNovice +
                                            SmallOrgSize + MediumOrgSize + LargeOrgSize +
                                            "GettingStarted,Strategy").WrapCommas(),
                                   Title = "Why Be Concerned About Managing IT",
                                   Uri = "http://www.ictknowledgebase.org.uk/whyworryaboutictmanagement",
                                   ShortDescription = "Managers increasingly face important decisions about IT. It is too important to be ignored, and this article tells you why.",
                                   LongDescription = "Managers increasingly face important decisions about IT. It is too important to be ignored, even by people who feel they don't know much about it. But why do we single out IT? Why not write about managing filing cabinets, or managing notice-boards? This article explains why IT needs your attention.",
                                   ResourceType = "ExternalLink"
                               };
                dataSession.Save(resource);

                #endregion

                #region Viruses, Spyware & Malware

                resource = new Resource
                               {
                                   Tags = (ProficiencyNovice +
                                            SmallOrgSize + MediumOrgSize + LargeOrgSize +
                                            "GettingStarted,Virus,Malware,Spyware").WrapCommas(),
                                   Title = "Viruses, Spyware & Malware",
                                   Uri = "http://www.ictknowledgebase.org.uk/virusesspywaremalware",
                                   ShortDescription = "A collection of articles telling you about keeping nasties off your organisation's network and computers.",
                                   LongDescription = "A collection of articles telling you about keeping nasties off your organisation's network and computers.",
                                   ResourceType = "ExternalLink"
                               };
                dataSession.Save(resource);

                #endregion

                #region Infection Control

                resource = new Resource
                               {
                                   Tags = (ProficiencyNovice + ProficiencyIntermediate +
                                            SmallOrgSize + MediumOrgSize + LargeOrgSize +
                                            Promoted +
                                            "Virus,Malware,Spyware").WrapCommas(),
                                   Title = "Infection Control",
                                   Uri = "http://www.ictknowledgebase.org.uk/infectioncontrol",
                                   ShortDescription = "Computer viruses plague millions around the world and email is a common way of spreading them. This article looks at the main issues.",
                                   LongDescription = "Computer viruses plague millions around the world and email is a common way of spreading them. Protecting your system effectively against email viruses depends on adopting a range of different measures. This article looks at the main issues.",
                                   ResourceType = "ExternalLink"
                               };
                dataSession.Save(resource);

                #endregion

                #region Virus Hoax Alert

                resource = new Resource
                               {
                                   Tags = (ProficiencyNovice + ProficiencyIntermediate + ProficiencyExpert +
                                            SmallOrgSize + MediumOrgSize + LargeOrgSize +
                                            "Virus,Malware,Spyware").WrapCommas(),
                                   Title = "Virus Hoax Alert",
                                   Uri = "http://www.ictknowledgebase.org.uk/virushoax",
                                   ShortDescription = "Virus hoaxes can cause mayhem and confusion. They often encourage recipients to delete important system files. This article gives examples of past hoaxes and tips on how to spot hoaxes so you can avoid spreading them.",
                                   LongDescription = "Virus hoaxes can cause mayhem and confusion. They often encourage recipients to delete important system files. This article gives examples of past hoaxes and tips on how to spot hoaxes so you can avoid spreading them.",
                                   ResourceType = "ExternalLink"
                               };
                dataSession.Save(resource);

                #endregion

                #region Choosing An Antivirus Solution For Your Organisation

                resource = new Resource
                               {
                                   Tags = (ProficiencyNovice +
                                            SmallOrgSize + MediumOrgSize + LargeOrgSize +
                                            Promoted +
                                            "GettingStarted,Virus,Malware,Spyware").WrapCommas(),
                                   Title = "Choosing An Antivirus Solution For Your Organisation",
                                   Uri = "http://www.ictknowledgebase.org.uk/choosingantivirus",
                                   ShortDescription = "Your organisation needs antivirus - that we can all agree. Don't rely on antivirus products that come with new computers. Coordinate a strategy across your organisation to benefit from time and money savings.",
                                   LongDescription = "Your organisation needs antivirus - that we can all agree. Don't rely on antivirus products that come with new computers. Coordinate a strategy across your organisation to benefit from time and money savings.",
                                   ResourceType = "ExternalLink"
                               };
                dataSession.Save(resource);

                #endregion

                #region A Day In The Life Of A PDA User

                resource = new Resource
                {
                    Tags = (ProficiencyIntermediate + ProficiencyExpert +
                             LargeOrgSize +
                             Promoted +
                             "Mobile,PDA").WrapCommas(),
                    Title = "A Day In The Life Of A PDA User",
                    Uri = "http://www.ictknowledgebase.org.uk/pdadiary",
                    ShortDescription = "Whilst not in itself a true story, all of these events show how a Personal Digital Assistants (PDA) could commonly be used by an Advice Worker. For this example we are going to use an Outreach Advice Worker working for a Housing charity.",
                    LongDescription = "Whilst not in itself a true story, all of these events show how a Personal Digital Assistants (PDA) could commonly be used by an Advice Worker. For this example we are going to use an Outreach Advice Worker working for a Housing charity.",
                    ResourceType = "ExternalLink"
                };
                dataSession.Save(resource);

                #endregion

                tx.Commit();
            }
        }
コード例 #5
0
        public Dap.RESULT Upload(Guid userId, string grade, string clas, string type, string form, string discipline)
        {
            if (string.IsNullOrEmpty(grade))
            {
                throw new ArgumentException("message", nameof(grade));
            }

            if (string.IsNullOrEmpty(clas))
            {
                throw new ArgumentException("message", nameof(clas));
            }

            if (string.IsNullOrEmpty(form))
            {
                throw new ArgumentException("message", nameof(form));
            }

            if (string.IsNullOrEmpty(discipline))
            {
                throw new ArgumentException("message", nameof(discipline));
            }

            Dap.RESULT result = new Dap.RESULT();
            try
            {
                HttpRequest        request = HttpContext.Current.Request;
                HttpFileCollection files   = request.Files;

                if (files.Count > 0)
                {
                    HttpPostedFile hpf = files[0];

                    //资源放入以上传者命名的文件夹
                    string folder = System.Web.HttpContext.Current.Server.MapPath(".\\" + userId.ToString()); //文件保存路径
                    string name, fileName, extname = Path.GetExtension(hpf.FileName);                         //分别为包括后缀名的文件名,不包括后缀名的文件名、后缀名

                    if (!Directory.Exists(folder))
                    {
                        Directory.CreateDirectory(folder);
                    }
                    name     = hpf.FileName.Substring(hpf.FileName.LastIndexOf("\\") + 1);
                    fileName = hpf.FileName.Substring(hpf.FileName.LastIndexOf("\\") + 1, (hpf.FileName.LastIndexOf(".") - hpf.FileName.LastIndexOf("\\") - 1));
                    //fileName = DateTime.Now.Ticks.ToString() +  extname;

                    hpf.SaveAs(folder + "\\" + name);
                    result.result = fileName;//上传成功返回文件名。
                    using (DataContext dc = new DataContext(Dap.common.conn))
                    {
                        var             tb        = dc.GetTable <Models.Resource>();
                        Models.Resource _resource = new Models.Resource();
                        _resource.Name         = fileName;
                        _resource.Size         = (int)Math.Ceiling((hpf.ContentLength) / 1024m);
                        _resource.UploadUserID = userId;
                        _resource.Grades       = grade;
                        _resource.Clas         = clas;
                        _resource.Type         = type;
                        _resource.Form         = form;
                        _resource.Suffix       = extname;//后缀名
                        _resource.ID           = Guid.NewGuid();
                        _resource.Discipline   = discipline;
                        _resource.CreateTime   = DateTime.Now.ToString("d");//时间以xx-x-x形式显示
                        tb.InsertOnSubmit(_resource);
                        dc.SubmitChanges();
                    }
                }
                else
                {
                    result.state = false;
                    result.msg   = "请先选择需要上传的文件。";
                }
            }
            catch (Exception e)
            {
                result.state = false;
                result.msg   = e.Message;
            }
            return(result);
        }
コード例 #6
0
ファイル: DataService.cs プロジェクト: mjmilan/crisischeckin
 public async Task AddResourceAsync(Resource newResource)
 {
     context.Resources.Add(newResource);
     await context.SaveChangesAsync();
 }