public DetailPageVM()
            : this(null, "", 0)
        {
            if (IsInDesignMode)
            {
                currentResource = new Forum() { title = "Design Forum" };
                Topic t1 = new Topic() { Forum = currentResource as Forum, PosterFirstname = "John", PosterLastname = "Doe", title = "Design Topic 1", Views = 15 };
                Topic t2 = new Topic() { Forum = currentResource as Forum, PosterFirstname = "Jane", PosterLastname = "Doe", title = "Design Topic 2", Views = 15 };

                (currentResource as Forum).Topics.AddRange(new Topic[] { t1, t2 });
                
                t1.Posts.Add(new Post()
                {
                    PosterFirstname = "John",
                    PosterLastname = "Doe",
                    Topic = t1,
                    Text = "Design Text 1 Design Text 1 Design Text 1 "
                         + "Design Text 1 Design Text 1 Design Text 1 "
                         + "Design Text 1 Design Text 1 Design Text 1 "
                         + "Design Text 1 Design Text 1 Design Text 1 "
                         + "Design Text 1 Design Text 1 Design Text 1 "
                });
                t1.Posts.Add(new Post()
                {
                    PosterFirstname = "John",
                    PosterLastname = "Doe",
                    Topic = t1,
                    Text = "Design Text 2 Design Text 2 Design Text 2 "
                         + "Design Text 2 Design Text 2 Design Text 2 "
                         + "Design Text 2 Design Text 2 Design Text 2 "
                         + "Design Text 2 Design Text 2 Design Text 2 "
                         + "Design Text 2 Design Text 2 Design Text 2 "
                });

                t1.Posts.Add(new Post()
                {
                    PosterFirstname = "Jane",
                    PosterLastname = "Doe",
                    Topic = t1,
                    Text = "Design Text 3 Design Text 3 Design Text 3 "
                         + "Design Text 3 Design Text 3 Design Text 3 "
                         + "Design Text 3 Design Text 3 Design Text 3 "
                         + "Design Text 3 Design Text 3 Design Text 3 "
                         + "Design Text 3 Design Text 3 Design Text 3 "
                });

                t2.Posts.Add(new Post()
                {
                    PosterFirstname = "Jane",
                    PosterLastname = "Doe",
                    Topic = t1,
                    Text = "Design Text 1 Design Text 1 Design Text 1 "
                         + "Design Text 1 Design Text 1 Design Text 1 "
                         + "Design Text 1 Design Text 1 Design Text 1 "
                         + "Design Text 1 Design Text 1 Design Text 1 "
                         + "Design Text 1 Design Text 1 Design Text 1 "
                });
            }
        }
예제 #2
0
        public override void UpdateFrom(ResourceModel newRes)
        {
            base.UpdateFrom(newRes);

            if (newRes is Description)
            {
                category = (newRes as Description).category;
            }
        }
예제 #3
0
        public async Task <ResourceModel> GetByIdAsync(Guid id)
        {
            ResourceModel resource = new ResourceModel();

            if (Guid.Empty != id)
            {
                resource = await resourceRepository.GetByIdAsync(id);
            }

            return(resource);
        }
예제 #4
0
 public bool UpdateResource(ResourceModel model)
 {
     try
     {
         return(resourceDAO.UpdateResource(model));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
예제 #5
0
 public bool AddModalityType(ResourceModel model)
 {
     try
     {
         return(resourceDAO.AddModalityType(model));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
        private async void DeleteResourceCommandHandler(ResourceModel resource)
        {
            SetCommandEnableStatus(ExecutionTypes.Delete);
            if (resource != null)
            {
                await _accountService.RemoveResourceAsync(resource.ID);
                await InitializeAsync();

                FirstNavCommandHandler();
            }
        }
예제 #7
0
        // GET: Resource/Create
        public ActionResult Create()
        {
            ResourceModel rm = new ResourceModel();

            rm.Profiles = rs.GetMany().Select(c => new SelectListItem
            {
                Text  = c.Name,
                Value = c.ProfileT.ToString(),
            });
            return(View(rm));
        }
예제 #8
0
        public IEnumerable <object> Get([FromQuery] Models.ResourceModel.Resource[] resources)
        {
            using (var session = _store.OpenSession())
            {
                var query = session.Advanced.DocumentQuery <ResourceModel.Resource, ResourceModel.ResourceIndex>();

                query = ResourceModel.QueryByExample(query, resources);

                return(query.ToQueryable().ProjectInto <ResourceModel.Resource>().Take(100).ToList());
            }
        }
        public void Ctor_ClassName_SetsFromPath(string path, string expected)
        {
            // Arrange
            _source.Path.Returns(path);

            // Act
            var result = new ResourceModel(_source);

            // Assert
            result.ClassName.Should().Be(expected);
        }
예제 #10
0
 private void SeacrhResource_Click(object sender, RoutedEventArgs e)
 {
     DGR.ItemsSource = null;
     using (var db = new ResourceModel())
     {
         DGR.ItemsSource = db.SearchResource(TB_Title.Text,
                                             Convert.ToDateTime(DT_DateStart.SelectedDate),
                                             Convert.ToDateTime(DT_DateEnd.SelectedDate),
                                             db.ConvertorObjectInInt(CB_People.SelectedValue));
     }
 }
예제 #11
0
        public void Namespace_IsSettable(string @namespace)
        {
            // Act
            var result = new ResourceModel(_source)
            {
                Namespace = @namespace
            };

            // Assert
            result.Namespace.Should().Be(@namespace);
        }
예제 #12
0
 private void AddResource_Click(object sender, RoutedEventArgs e)
 {
     using (var db = new ResourceModel())
     {
         MessageBox.Show(db.AddResource(TB_Title.Text,
                                        Convert.ToDateTime(DT_DateStart.SelectedDate),
                                        Convert.ToDateTime(DT_DateEnd.SelectedDate),
                                        db.ConvertorObjectInInt(CB_People.SelectedValue)));
     }
     Update();
 }
        /// <summary>
        /// 添加或者修改业务系统
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ActionResult AddOrEditResource(long id = 0)
        {
            ResourceModel model = new ResourceModel();

            if (id > 0)
            {
                //添加业务系统
                model = ResourceBll.GetResourceById(id);
            }
            return(View(model));
        }
예제 #14
0
 public CompilerContext Push(ResourceModel resourceModel)
 {
     if (_recursionDefender.Any(m => m.ResourceType == resourceModel.ResourceType))
     {
         throw new InvalidOperationException(
                   $"Detected recursion, already processing {resourceModel.ResourceType?.Name}: {String.Join("->", _recursionDefender.Select(m => m.ResourceType?.Name).Where(n => n != null))}");
     }
     return(new CompilerContext(MetaModel, resourceModel)
     {
         _recursionDefender = _recursionDefender.Concat(new[] { resourceModel }).ToList()
     });
 }
예제 #15
0
 public void Update()
 {
     DGR.ItemsSource             = null;
     CB_People.ItemsSource       = null;
     CB_ReportPeople.ItemsSource = null;
     using (var db = new ResourceModel())
     {
         DGR.ItemsSource             = db.GetResource();
         CB_People.ItemsSource       = db.GetPeople();
         CB_ReportPeople.ItemsSource = db.GetPeople();
     }
 }
예제 #16
0
        // GET: Project/Delete/5
        public ActionResult Delete2(int id)
        {
            Ressource     p   = rs.GetById(id);
            ResourceModel rs1 = new ResourceModel();

            rs1.Name            = p.Name;
            rs1.Rating          = p.Rating;
            rs1.CurriculumVitae = p.CurriculumVitae;


            return(View(rs1));
        }
예제 #17
0
 public IActionResult deleteRes(ResourceModel obj)
 {
     try
     {
         _commRes.deleteResource(obj);
         return(Ok());
     }
     catch
     {
         return(BadRequest());
     }
 }
예제 #18
0
        public async virtual Task <IActionResult> UpdateAsync(ResourceModel <TResource> resourceModel)
        {
            if (!User.IsAuthorized(ResourceType))
            {
                return(Unauthorized());
            }

            var updateResourceEvent = new UpdateResource <TResource>(resourceModel);
            var context             = await _mediator.Send(updateResourceEvent);

            if (context != null)
            {
                resourceModel = context;
            }

            if (resourceModel.Errors.Any())
            {
                foreach (var error in resourceModel.Errors)
                {
                    ModelState.AddModelError(error.Key, error.Value);
                }
            }

            if (!ModelState.IsValid)
            {
                return(PartialView("_Editor", resourceModel));
            }

            var update = await _repository.UpdateAsync(resourceModel.Resource, UserID);

            if (update <= 0)
            {
                return(BadRequest());
            }

            _logger.LogResourceUpdated(ResourceType, resourceModel.ID);

            var updatedResource = await _repository.ReadAsync(resourceModel.ID);

            var resourceUpdatedEvent = new ResourceUpdated <TResource>(updatedResource);
            await _mediator.Publish(resourceUpdatedEvent);

            var resourcePersistedEvent = new ResourcePersisted <TResource>();
            await _mediator.Publish(resourcePersistedEvent);

            var result = new ResourceModel <TResource>()
            {
                ID       = resourceModel.ID,
                Resource = updatedResource
            };

            return(PartialView("_Editor", result));
        }
예제 #19
0
 public IActionResult setResourceActive(ResourceModel obj)
 {
     try
     {
         _commRes.setResourceActive(obj.Id, obj.enabled_flg);
         return(Ok());
     }
     catch
     {
         return(BadRequest());
     }
 }
예제 #20
0
        private void SearchPeople_Click(object sender, RoutedEventArgs e)
        {
            DGR.ItemsSource = null;

            using (var db = new ResourceModel())
            {
                DGR.ItemsSource = db.SeacrhPeople(TB_FirstName.Text, TB_LastName.Text, TB_MiddleName.Text, TB_PhoneVoIP.Text,
                                                  db.ConvertorObjectInInt(CB_Department.SelectedValue),
                                                  db.ConvertorObjectInInt(CB_Organization.SelectedValue),
                                                  db.ConvertorObjectInInt(CB_Position.SelectedValue));
            }
        }
예제 #21
0
파일: Mapper.cs 프로젝트: Ivokin/Brewery
 public ResourceViewModel ResourceToResourceViewModel(ResourceModel resource)
 {
     return(new ResourceViewModel()
     {
         Link = resource.Link,
         Unit = resource.Unit.ToLower(),
         ShowAlert = false,
         Id = resource.ResourceId,
         Name = resource.Name,
         AmountInStock = resource.AmountInStock,
     });
 }
예제 #22
0
 public void GivenNewResourceWithTitleContentAuthorAndTags(string title, string content, string author, string tags)
 {
     var resourceModel = new ResourceModel
                          {
                              Tags = tags,
                              Title = title,
                              Author = author,
                              Content = content,
                              SubmitUser = SubmitUser
                          };
     CurrentScenario[SUBMITTED_RESOURCE_MODEL_KEY] = resourceModel;
 }
        private Common.Models.Resource.Resource GetDomainResourceFor(Resource resource)
        {
            string schemaProperCaseNameOrDefault =
                ExtensionsConventions.GetProperCaseNameForLogicalName(resource.logicalSchema ?? EdFiConventions.ProperCaseName);

            bool IsSchemaMatch(ResourceClassBase r) => r.SchemaProperCaseName.EqualsIgnoreCase(schemaProperCaseNameOrDefault);
            bool IsNameMatch(ResourceClassBase r) => r.Name.EqualsIgnoreCase(resource.name);
            bool IsFullNameMatch(ResourceClassBase r) => IsSchemaMatch(r) && IsNameMatch(r);

            return(ResourceModel.GetAllResources()
                   .FirstOrDefault(IsFullNameMatch));
        }
        public async Task <int> UpdateResource(ResourceModel model)
        {
            var storedProcedure = "dbo.Resource_Update";

            return(await _dataGateway.Execute(storedProcedure,
                                              new
            {
                Id = model.Id,
                name = model.Name
            },
                                              _connectionString.SqlConnectionString));
        }
예제 #25
0
 private void SeacrhComputer_Click(object sender, RoutedEventArgs e)
 {
     DGR.ItemsSource = null;
     using (var db = new ResourceModel())
     {
         DGR.ItemsSource = db.SeacrhComputer(TB_Indificator.Text,
                                             TB_IP.Text, TB_Name.Text,
                                             TB_Domen.Text,
                                             db.ConvertorObjectInInt(CB_WorkingGroup.SelectedValue),
                                             db.ConvertorObjectInInt(CB_People.SelectedValue));
     }
 }
예제 #26
0
        private async void ListenerEventWorker()
        {
            var EventID = RandomInstance.Next();

            ListenerEventID = EventID;

            await Task.Delay(500);

            if (EventID != ListenerEventID)
            {
                return;                                         // Another event called
            }
            string zItemsPath = ResourceCachePath;

            var res = new ResourceModel
            {
                Date = DateTime.Now,

                Fuel    = CurrentFuel,
                Ammo    = CurrentAmmo,
                Steel   = CurrentSteel,
                Bauxite = CurrentBauxite,

                RepairBucket        = CurrentRepairBucket,
                DevelopmentMaterial = CurrentDevelopmentMaterial,
                InstantConstruction = CurrentInstantConstruction,
                ImprovementMaterial = CurrentImprovementMaterial
            };

            CriticalSection("ResourceChartWrite", () =>
            {
                int tries = 5;

                while (tries > 0)
                {
                    try
                    {
                        using (FileStream fs = new FileStream(zItemsPath, FileMode.Append))
                        {
                            CSV.Write(fs,
                                      res.Date.ToString("yyyy-MM-dd HH:mm:ss"),
                                      res.Fuel, res.Ammo, res.Steel, res.Bauxite,
                                      res.RepairBucket, res.DevelopmentMaterial,
                                      res.InstantConstruction, res.ImprovementMaterial
                                      );
                        }
                        break;
                    }
                    catch (IOException) { tries--; }
                    catch (Exception) { break; }
                }
            });
        }
예제 #27
0
        public ActionResult NewResource(string FacilityId)
        {
            var model = new ResourceModel();

            model.FacilityId = int.Parse(FacilityId);
            return(Json(new
            {
                LocationModal = RenderRazorViewToString("PartialViews/Resource_Management/_newResourceModal", model)
            },
                        JsonRequestBehavior.AllowGet
                        ));
        }
        public void ResourceModel_Constructor_IsWorkflowSaved()
        {
            //------------Setup for test--------------------------
            Setup();
            var environmentModel = CreateMockEnvironment(new Mock <IEventPublisher>().Object);

            //------------Execute Test---------------------------
            var resourceModel = new ResourceModel(environmentModel.Object);

            //------------Assert Results-------------------------
            Assert.IsTrue(resourceModel.IsWorkflowSaved);
        }
예제 #29
0
 public void Update()
 {
     DGR.ItemsSource             = null;
     CB_WorkingGroup.ItemsSource = null;
     CB_People.ItemsSource       = null;
     using (var db = new ResourceModel())
     {
         DGR.ItemsSource             = db.GetComputer();
         CB_WorkingGroup.ItemsSource = db.GetWorking_Group();
         CB_People.ItemsSource       = db.GetPeople();
     }
 }
예제 #30
0
        public override void Go(ResourceModel resourceModel)
        {
            foreach (AnimationTemplateInstance instance in Instances)
            {
                string fileName = instance.TypeName + "Animation" + ".cs";
                string path     = "src\\" + instance.ModuleName + "\\System\\Windows\\Media\\Animation\\Generated";

                string fullPath = Path.Combine(resourceModel.OutputDirectory, path);

                string moduleReference      = "";
                string extraInterpolateArgs = "";
                string checkNotNull;
                string propertyTypeName;  // the actual type for the animation (e.g. Double? for DoubleAnimation)
                string nullableAccessor;  // .Value for accessing value types, nothing for reference types


                // AnimatedTypeHelpers.Interpolate has an extra parameter
                // for the Quaternion type
                if (instance.TypeName == "Quaternion")
                {
                    extraInterpolateArgs = ", UseShortestPath";
                }

                // Duplicate AnimatedTypeHelpers class across Core/Framework causes name conflicts,
                // requiring that they be split across two namespaces.
                switch (instance.ModuleName)
                {
                case @"Core\CSharp":
                    moduleReference = "using MS.Internal.PresentationCore;";
                    break;

                case "Framework":
                    moduleReference = "using MS.Internal.PresentationFramework;";
                    break;
                }

                if (instance.IsValueType)
                {
                    checkNotNull     = ".HasValue";
                    propertyTypeName = instance.TypeName + "?";
                    nullableAccessor = ".Value";
                }
                else
                {
                    checkNotNull     = " != null";
                    propertyTypeName = instance.TypeName;
                    nullableAccessor = "";
                }

                using (FileCodeSink csFile = new FileCodeSink(fullPath, fileName, true /* Create dir if necessary */))
                {
                    csFile.WriteBlock(
        public void ResourceModel_Commit_FixedErrorsNotRestored()
        {
            //Setup();
            var eventPublisher   = new EventPublisher();
            var environmentModel = CreateMockEnvironment(eventPublisher);

            var instanceID = Guid.NewGuid();
            var model      = new ResourceModel(environmentModel.Object)
            {
                ID = instanceID
            };

            var hitCount = 0;

            model.OnDesignValidationReceived += (sender, memo) =>
            {
                switch (hitCount++)
                {
                case 0:
                    Assert.AreEqual(2, model.Errors.Count);
                    Assert.AreEqual(0, model.FixedErrors.Count);
                    break;

                case 1:
                    Assert.AreEqual(1, model.Errors.Count);
                    Assert.AreEqual(1, model.FixedErrors.Count);

                    model.Commit();

                    Assert.AreEqual(1, model.Errors.Count);
                    Assert.AreEqual(0, model.FixedErrors.Count);
                    break;
                }
            };

            // Publish 2 errors
            var pubMemo = new DesignValidationMemo {
                InstanceID = instanceID
            };

            pubMemo.Errors.Add(new ErrorInfo {
                ErrorType = ErrorType.Critical, Message = "Critical error.", InstanceID = instanceID
            });
            pubMemo.Errors.Add(new ErrorInfo {
                ErrorType = ErrorType.Warning, Message = "Warning error.", InstanceID = instanceID
            });
            eventPublisher.Publish(pubMemo);

            // Fix 1 error and publish
            pubMemo.Errors.RemoveAt(1);
            eventPublisher.Publish(pubMemo);
        }
예제 #32
0
        public static int Update(ResourceModel resModel, ResourceGaugeModel resGaugeModel, ResourcePriceModel resPriceModel)
        {
            SqlConnection connection = new SqlConnection(SqlHelper.ConnectionString);

            connection.Open();
            SqlTransaction trans   = connection.BeginTransaction();
            int            num     = 0;
            StringBuilder  builder = new StringBuilder();

            try
            {
                builder.Append("begin update EPM_Res_Resource set ");
                builder.Append("VersionCode=@VersionCode,CategoryCode=@CategoryCode");
                builder.Append(",ResourceName=@ResourceName,Specification=@Specification,ResourceStyle=@ResourceStyle");
                builder.Append(",ResourceType=@ResourceType,IsValid=@IsValid,Owner=@Owner,VersionTime=@VersionTime,imgurl=@imgurl ");
                builder.Append(" where ResourceCode=@ResourceCode ");
                builder.Append(" update EPM_Res_Gauge set ");
                builder.Append(" VersionCode=@VersionCode,UnitID=@UnitID,Quotiety=@Quotiety,IsDefault=@IsDefault,IsValid=@IsValid,Owner=@Owner,VersionTime=@VersionTime ");
                builder.Append(" where ResourceCode=@ResourceCode ");
                builder.Append(" update EPM_Res_PriceRelations set ");
                builder.Append(" VersionCode=@VersionCode,PriceItemID=@PriceItemID,Price=@Price,Owner=@Owner,VersionTime=@VersionTime ");
                builder.Append(" where ResourceCode=@ResourceCode end ");
                SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@VersionCode", SqlDbType.UniqueIdentifier, 0x10), new SqlParameter("@ResourceCode", SqlDbType.VarChar, 50), new SqlParameter("@CategoryCode", SqlDbType.VarChar, 50), new SqlParameter("@ResourceName", SqlDbType.VarChar, 200), new SqlParameter("@Specification", SqlDbType.VarChar, 200), new SqlParameter("@ResourceStyle", SqlDbType.Int, 4), new SqlParameter("@ResourceType", SqlDbType.Int, 4), new SqlParameter("@IsValid", SqlDbType.Bit, 1), new SqlParameter("@Owner", SqlDbType.VarChar, 10), new SqlParameter("@VersionTime", SqlDbType.DateTime), new SqlParameter("@UnitID", SqlDbType.Int, 4), new SqlParameter("@Quotiety", SqlDbType.Decimal, 9), new SqlParameter("@IsDefault", SqlDbType.Bit, 1), new SqlParameter("@PriceItemID", SqlDbType.Int, 4), new SqlParameter("@Price", SqlDbType.Decimal, 9), new SqlParameter("@imgurl", SqlDbType.VarChar, 0xd7) };
                commandParameters[0].Value  = new Guid(resModel.VersionCode);
                commandParameters[1].Value  = resModel.ResourceCode;
                commandParameters[2].Value  = resModel.CategoryCode;
                commandParameters[3].Value  = resModel.ResourceName;
                commandParameters[4].Value  = resModel.Specification;
                commandParameters[5].Value  = int.Parse(resModel.ResourceStyle);
                commandParameters[6].Value  = int.Parse(resModel.ResourceType);
                commandParameters[7].Value  = Convert.ToBoolean(int.Parse(resModel.IsValid));
                commandParameters[8].Value  = resModel.Owner;
                commandParameters[9].Value  = resModel.VersionTime;
                commandParameters[10].Value = int.Parse(resGaugeModel.UnitId);
                commandParameters[11].Value = decimal.Parse(resGaugeModel.Quantity);
                commandParameters[12].Value = Convert.ToBoolean(int.Parse(resGaugeModel.IsDefault));
                commandParameters[13].Value = int.Parse(resPriceModel.PriceItem);
                commandParameters[14].Value = decimal.Parse(resPriceModel.Price);
                commandParameters[15].Value = resModel.ResourceImageUrl;
                num = SqlHelper.ExecuteNonQuery(trans, CommandType.Text, builder.ToString(), commandParameters);
                trans.Commit();
            }
            catch
            {
                trans.Rollback();
                connection.Close();
                connection.Dispose();
            }
            connection.Close();
            connection.Dispose();
            return(num);
        }
예제 #33
0
        public string GetResourceUrl(int resourceId)
        {
            ResourceModel res = CacheManager.Current.GetResource(resourceId);

            string schedulerUrl = ConfigurationManager.AppSettings["SchedulerUrl"];

            if (string.IsNullOrEmpty(schedulerUrl))
            {
                throw new InvalidOperationException("Missing appSetting: SchedulerUrl");
            }

            return(string.Format("{0}ResourceDayWeek.aspx?path={1}:{2}:{3}:{4}", schedulerUrl, res.BuildingID, res.LabID, res.ProcessTechID, res.ResourceID));
        }
예제 #34
0
        public void GivenNewResourceWithTitleAndContentAndAuthorAndTagsAndReferenceUrl(string title, string content, string author, string tags, string referenceurl)
        {
            var resourceModel = new ResourceModel
                            {
                                Tags = tags,
                                Title = title,
                                Author = author,
                                Content = content,
                                ReferenceUrl = referenceurl,
                            };

            CurrentScenario[PENDING_SUBMITTED_RESOURCE_MODEL_KEY] = resourceModel;
        }
예제 #35
0
        public ActionResult Create(ResourceModel model)
        {
            var resource = ResourceService.AddResource(new Resource
                {
                    Title = model.Title,
                    Content = model.Content,
                    Author = model.Author,
                    SubmitUser = SessionStateRepository.CurrentUser.UserName,
                    Tags = model.Tags.ToTagList(),
                    ReferenceUrl = model.ReferenceUrl
                });

            return RedirectToAction("Details", new { id = resource.Id.Substring(10) });
        }
예제 #36
0
        public PlanningHeadModel()
        {
            _repo = new WorkEntryRepo();
            _repoUcd = new UserCodeRepo();
            _repoRes = new ResourceRepo();

            LevSimulates = new List<LevellerSimulateModel>();
            Class = new ClassMasterModel();
            CoilBacks = new List<CoilBackModel>();
            CoilBackRoles = new List<CoilBackRuleModel>();
            CuttingDesign = new List<CutDesignModel>();
            Materials = new List<MaterialModel>();
            OrderTypeList = new List<UserCodeModel>();
            Possessions = new List<UserCodeModel>();
            ProcessLine = new ResourceModel();
            Resources = new List<ResourceModel>();
        }
예제 #37
0
        public ActionResult Edit(string id, ResourceModel model)
        {
            ResourceService.UpdateResource(id, new Resource
            {
                Title = model.Title,
                Content = model.Content,
                Author = model.Author,
                SubmitUser = SessionStateRepository.CurrentUser.UserName,
                ReferenceUrl = model.ReferenceUrl,
                Tags = model.Tags.ToTagList()
            });

            return RedirectToAction("Details", new { id });
        }
예제 #38
0
 private Action<bool> Complete(Dispatcher dispatcher, ResourceModel model)
 {
     return result =>
     {
         dispatcher.Handle(async () =>
         {
             model.Complete(result);
             await this.Persist();
         });
     };
 }
예제 #39
0
 private Action<long, long> SetProgress(Dispatcher dispatcher, ResourceModel model)
 {
     return (received, total) =>
     {
         dispatcher.Handle(() => model.SetProgress(received, total));
     };
 }
예제 #40
0
        public DetailPageVM(ISettings settings, string resid, int listid)
            : base(settings)
        {
            if(!IsInDesignMode)
            {
                ClarolineDB.Dispose();
                ClarolineDB = null;

                currentResource = (from r
                                   in ClarolineDB.Resources_Table
                                   where r.resourceId.Equals(resid)
                                   && r.ResourceList.Id == listid
                                   select r).FirstOrDefault();

                IsNotified = currentResource.isNotified;

                currentResource.seenDate = DateTime.Now;
                SaveChangesToDB(); 
            }
        }
예제 #41
0
        public override void DeleteResource(ResourceModel resForDelete)
        {
            switch (resForDelete.DiscKey)
            {
                case SupportedModules.CLDOC:
                    RaisePropertyChanged("Content");
                    break;
                case SupportedModules.CLDSC:
                    RaisePropertyChanged("descriptions");
                    break;
                case SupportedModules.CLFRM:
                    RaisePropertyChanged("forums");
                    break;
                case SupportedModules.CLCAL:
                    RaisePropertyChanged("events");
                    break;
                default:
                    break;
            }

            base.DeleteResource(resForDelete);
        }
예제 #42
0
 private Action<TimeSpan> SetEstimation(Dispatcher dispatcher, ResourceModel model)
 {
     return estimation =>
     {
         dispatcher.Handle(() => model.SetEstimation(estimation));
     };
 }
예제 #43
0
 public void OnGenericItemSelected(ResourceModel item)
 {
     if (item != null)
     {
         item.seenDate = DateTime.Now;
         SaveChangesToDB();
     }
 }
예제 #44
0
        public override void UpdateFrom(ResourceModel newRes)
        {
            base.UpdateFrom(newRes);

            if (newRes is Document)
            {
                size = (newRes as Document).size;
                isFolder = (newRes as Document).isFolder;
                description = (newRes as Document).description;
                extension = (newRes as Document).extension;
            }
        }
예제 #45
0
        public virtual void DeleteResource(ResourceModel resForDelete)
        {
            foreach (var subres in resForDelete.GetSubRes())
            {
                DeleteResource(subres);
            }

            ClarolineDB.Resources_Table.DeleteOnSubmit(resForDelete);
            SaveChangesToDB();
        }
예제 #46
0
 public void OnItemWithDetailsSelected(ResourceModel item)
 {
     NavigationTarget = new Uri(String.Format("/View/DetailPage.xaml?resource={0}&list={1}", item.resourceId, item.ResourceList.Id), UriKind.Relative);
 }
예제 #47
0
        public virtual void AddResource(ResourceModel newRes, int containerId)
        {
            ClarolineDataContext cdc = ClarolineDB;
            //using (ClarolineDataContext cdc = new ClarolineDataContext(ClarolineDataContext.DBConnectionString))
            //{
                var q = cdc.Resources_Table.Where(r => r.DiscKey == newRes.DiscKey
                                                    && r.ResourceList.Id == containerId
                                                    && r.resourceId == newRes.resourceId
                                                 );

                newRes.updated = true;
                newRes.loaded = DateTime.Now;
                bool alreadyInDb = false;

                if (!q.Any())
                {
                    cdc.ResourceList_Table.Single(r => r.Id == containerId).Resources.Add(newRes);

                    cdc.Resources_Table.InsertOnSubmit(newRes);
                    cdc.SubmitChanges();
                    cdc.Refresh(RefreshMode.OverwriteCurrentValues, newRes);
                }
                else
                {
                    q.Single().UpdateFrom(newRes);
                    cdc.SubmitChanges();
                    newRes.Id = q.Single().Id;

                    alreadyInDb = true;
                }

                if (!(newRes is Document) || !(newRes as Document).isFolder)
                {
                    AddNotification(Notification.CreateNotification(alreadyInDb), newRes);
                }
            //}
        }
예제 #48
0
        public virtual void AddNotification(Notification newNot, ResourceModel attachedResource)
        {
            using (ClarolineDataContext cdc = new ClarolineDataContext(ClarolineDataContext.DBConnectionString))
            {

                Notification lastNotificationFromDB = cdc.Notifications_Table.OrderByDescending(n => n.date)
                                                                                     .FirstOrDefault(n => n.resource == newNot.resource);

                if (lastNotificationFromDB != null)
                {
                    if (lastNotificationFromDB.date.CompareTo(newNot.date) >= 0)
                    {
                        return;
                    }
                }

                newNot.resource = cdc.Resources_Table.Single(r => r.Id == attachedResource.Id);
                cdc.Notifications_Table.InsertOnSubmit(newNot);
                cdc.SubmitChanges();
            }
        }
예제 #49
0
        public override void AddNotification(Notification newNot, ResourceModel attachedResource)
        {
            base.AddNotification(newNot, attachedResource);

            RaisePropertyChanged("topNotifications");
        }
예제 #50
0
        public ActionResult Create()
        {
            var viewModel = new ResourceModel();

            return View(viewModel);
        }
예제 #51
0
        public override void UpdateFrom(ResourceModel newRes)
        {
            base.UpdateFrom(newRes);

            if (newRes is Event)
            {
                speakers = (newRes as Event).speakers;
                location = (newRes as Event).location;
                lasting = (newRes as Event).lasting;
            }
        }
예제 #52
0
        public override async Task RefreshAsync(bool force = false)
        {
            if (IsNotified)
            {
                await GetSingleResourceAsync(currentResource.ResourceList, currentResource.GetResourceString());

                currentResource = (from r
                                   in ClarolineDB.Resources_Table
                                   where r.Id == currentResource.Id
                                   select r).FirstOrDefault();
                currentResource.seenDate = DateTime.Now;
                SaveChangesToDB();

                IsNotified = false;
            }
            else
            {
                await base.RefreshAsync(force);
            }
        }
예제 #53
0
 private Action<long> SetSpeed(Dispatcher dispatcher, ResourceModel model)
 {
     return speed =>
     {
         dispatcher.Handle(() => model.SetSpeed(speed));
     };
 }
예제 #54
0
 private Action<string> SetStatus(Dispatcher dispatcher, ResourceModel model)
 {
     return status =>
     {
         dispatcher.Handle(() => model.SetStatus(status));
     };
 }
예제 #55
0
        public override void AddResource(ResourceModel newRes, int containerId)
        {
            base.AddResource(newRes, containerId);

            switch (newRes.DiscKey)
            {
                case SupportedModules.CLDOC:
                    RaisePropertyChanged("Content");
                    break;
                case SupportedModules.CLDSC:
                    RaisePropertyChanged("descriptions");
                    break;
                case SupportedModules.CLFRM:
                    RaisePropertyChanged("forums");
                    break;
                case SupportedModules.CLCAL:
                    RaisePropertyChanged("events");
                    break;
                default:
                    break;
            }
        }