Ejemplo n.º 1
0
 internal bool Add(ProjectEntity project)
 {
     bool isAdded = false;
     db.Projects.Add(project);
     db.SaveChanges();
     return isAdded;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 添加按钮
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btn_OK_Click(object sender, EventArgs e)
 {
     /*初始化工程,并设置属性*/
     ProjectEntity pe = new ProjectEntity();
     pe.ProjectName = tb_ProjectName.Text;
     if (pe.ProjectName == "")
     {
         SmallScript.MessageBox(Page, "请输入工程名!");
         return;
     }
     if (ProjectOperation.CheckProjectNameExist(pe.ProjectName, -1) == true)
     {
         SmallScript.MessageBox(Page, "已存在该名称的工程。请使用其他名称。");
         return;
     }
     pe.Tid = int.Parse(ddl_Type.SelectedValue);
     pe.Uid = int.Parse(Session["uid"].ToString());
     pe.UpTime = DateTime.Now;
     pe.Description = Server.HtmlEncode(tb_Description.Text);
     /*添加工程,并返回是否成功*/
     if (pe.ProjectName == "")
     {
         SmallScript.goRedirect(Response, Session, "工程信息请填写完整!", "/admin/addproject.aspx");
         return;
     }
     if (ProjectOperation.AddProject(pe) == true)
     {
         SmallScript.goRedirect(Response, Session, "工程已成功添加!", "/admin/projectlist.aspx");
     }
     else
     {
         SmallScript.MessageBox(Page, "添加工程失败!");
     };
 }
Ejemplo n.º 3
0
        public void UnSubscribe(ProjectEntity entity, Guid recipientID)
        {
            var recipient = RecipientProvider.GetRecipient(recipientID.ToString());

            if (recipient == null) return;

            SubscriptionProvider.UnSubscribe(NotifyAction, entity.NotifyId, recipient);
        }
        public bool IsSubscribed(ProjectEntity entity, Guid recipientID)
        {
            var recipient = RecipientProvider.GetRecipient(recipientID.ToString());

            var objects = new List<String>(SubscriptionProvider.GetSubscriptions(NotifyAction, recipient));

            return !String.IsNullOrEmpty(objects.Find(item => String.Compare(item, entity.NotifyId, StringComparison.OrdinalIgnoreCase) == 0));
        }
Ejemplo n.º 5
0
 internal bool Update(ProjectEntity project)
 {
     ProjectEntity entity = Get(project.Id);
     entity.ProjectName = project.ProjectName;
     entity.Description = project.Description;
     db.SaveChanges();
     //TODO: Updating image
     return true;
 }
Ejemplo n.º 6
0
 public static ProjectModel ProjectEntityToProjectModel(ProjectEntity entity)
 {
     return new ProjectModel
     {
         Id = entity.Id,
         Description = entity.Description,
         ProjectImageContent = entity.ProjectImage,
         ProjectName = entity.ProjectName,
     };
 }
Ejemplo n.º 7
0
 public static bool AddProject(ProjectEntity pe)
 {
     /*增加一个工程*/
     DataBase db = new DataBase();
     try
     {
         string sql =string.Format( "INSERT INTO tb_project ( projectName, description, upTime, tid, uid)VALUES  ( '{0}', '{1}','{2}', {3}, {4})",pe.ProjectName,pe.Description,pe.UpTime,pe.Tid,pe.Uid);
         db.ExCommandNoBack(sql);
         return true;
     }
     catch
     {
         return false;
     }
 }
Ejemplo n.º 8
0
        public async Task <DomainProjectProcessedVideo> GetAsync(DomainProjectProcessedVideo entity)
        {
            ProjectEntity project = await _projectRepository.SingleOrDefaultAsync(p => p.Id == entity.ProjectId);

            if (project == null)
            {
                throw new NotFoundException(string.Format("Project {0} was not found", entity.ProjectId));
            }

            ProjectEntity.EncodedVideo video = project.EncodedVideos.Single(s => s.FileId == entity.FileId);


            // building result
            return(BuildDomainObject(project, video));
        }
Ejemplo n.º 9
0
        public void DetachFile(ProjectEntity entity, object fileId)
        {
            if (!ProjectSecurity.CanReadFiles(entity.Project))
            {
                return;
            }

            using (var dao = FilesIntegration.GetTagDao())
            {
                dao.RemoveTags(new Tag(entity.GetType().Name + entity.ID, TagType.System, Guid.Empty)
                {
                    EntryType = FileEntryType.File, EntryId = fileId
                });
            }
        }
        public ImportImportantPartRejesterWindowViewModel(ChildWindow aChildWindow, Dictionary <String, ProjectEntity> aProjectEntityDictionary, ProductDomainContext aProductDomainContext, Dictionary <int, UserEntity> aDictionaryUser, ProjectEntity aProjectEntity)
        {
            childWindow             = aChildWindow;
            ProjectEntityDictionary = aProjectEntityDictionary;
            ProductContext          = aProductDomainContext;
            DictionaryUser          = aDictionaryUser;
            ProjectEntity           = aProjectEntity;

            ImportantPartRejesterEntityList = new ObservableCollection <ImportantPartRejesterEntity>();

            OnImport       = new DelegateCommand(OnImportCommand);
            OnDownloadTemp = new DelegateCommand(OnDownloadTempCommand);
            OnCancel       = new DelegateCommand(OnCancelCommand);
            OnOK           = new DelegateCommand(OnOKCommand);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// While using a target file as storage, determines the fingerprint for the given
 /// <see cref="ProjectEntity"/>.
 /// </summary>
 /// <param name="entity">The <see cref="ProjectEntity"/> to generate a hashcode for.</param>
 /// <param name="filePath">The filepath to use as temporary storage.</param>
 /// <returns>The binary hashcode for <paramref name="entity"/>.</returns>
 /// <exception cref="ArgumentNullException">Thrown when <paramref name="entity"/> is <c>null</c>.</exception>
 /// <exception cref="QuotaExceededException">Thrown when <paramref name="entity"/>
 /// contains more than <see cref="int.MaxValue"/> unique object instances.</exception>
 /// <exception cref="UnauthorizedAccessException">The caller does not have the
 /// required permissions or <paramref name="filePath"/> is read-only.</exception>
 /// <exception cref="IOException">An I/O exception occurred while creating the file
 /// at <paramref name="filePath"/>.</exception>
 private static byte[] ComputeHash(ProjectEntity entity, string filePath)
 {
     using (HashAlgorithm hashingAlgorithm = MD5.Create())
         using (FileStream stream = File.Create(filePath))
             using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateBinaryWriter(stream))
             {
                 var serializer = new DataContractSerializer(entity.GetType(),
                                                             Enumerable.Empty <Type>(),
                                                             int.MaxValue, false, true, null);
                 serializer.WriteObject(writer, entity);
                 writer.Flush();
                 stream.Seek(0, SeekOrigin.Begin);
                 return(hashingAlgorithm.ComputeHash(stream));
             }
 }
Ejemplo n.º 12
0
        public async Task <Response> UpdateTask(TaskRequest request, int taskId)
        {
            try
            {
                TaskEntity task = await _context.Tasks.FindAsync(taskId);

                if (task == null)
                {
                    return(new Response
                    {
                        IsSuccess = false,
                        Message = "Task does not exist."
                    });
                }

                ProjectEntity project = await _context.Projects
                                        .FirstOrDefaultAsync(p => p.Tasks.FirstOrDefault(d => d.Id == task.Id) != null);

                task.IdProject     = project.Id;
                task.Name          = request.Name;
                task.Description   = request.Description;
                task.ExecutionDate = request.ExecutionDate;
                _context.Update(task);
                await _context.SaveChangesAsync();

                return(new Response
                {
                    IsSuccess = true,
                    Message = "Task Updated successfully",
                    Result = new TaskResponse
                    {
                        TaskId = task.Id,
                        Name = task.Name,
                        Description = task.Description,
                        ExecutionDate = task.ExecutionDate,
                        ProjectId = task.IdProject
                    }
                });
            }
            catch (Exception ex)
            {
                return(new Response
                {
                    IsSuccess = false,
                    Message = ex.Message
                });
            }
        }
Ejemplo n.º 13
0
        public void GivenProjectEntity_WhenComparingFingerprintsBeforeAndAfterChange_ThenHashDifferent()
        {
            // Given
            RiskeerProject project = RiskeerProjectTestHelper.GetFullTestProject();
            ProjectEntity  entity  = project.Create(new PersistenceRegistry());

            // When
            byte[] hash1 = FingerprintHelper.Get(entity);
            entity.AssessmentSectionEntities.First().Name = "Something completely different";
            byte[] hash2 = FingerprintHelper.Get(entity);

            // Then
            Assert.IsNotNull(hash1);
            CollectionAssert.IsNotEmpty(hash1);
            CollectionAssert.AreNotEqual(hash1, hash2);
        }
Ejemplo n.º 14
0
 public Project MapToProject(ProjectEntity model)
 {
     return(new Project()
     {
         Title = model.Data.Title,
         BodyHtml = model.Data.BodyHtml,
         ExternalUrl = model.Data.ExternalUrl,
         ImageHeaderUrl = ResolveAssetURL(model.Data.ImageHeader.First()),
         ImageThumbnailUrl = ResolveAssetURL(model.Data.ImageThumbnail.First()),
         Subtitle = model.Data.Subtitle,
         Id = model.Id,
         CreatedDate = model.Created.Date,
         MetaDescription = model.Data.MetaDescription,
         Tags = model.Data.Tags
     });
 }
Ejemplo n.º 15
0
    /// <summary>
    /// 添加工程
    /// </summary>
    /// <param name="pe">工程的实例</param>
    /// <returns>成功返回true 失败返回false</returns>
    public static bool AddProject(ProjectEntity pe)
    {
        /*增加一个工程*/
        DataBase db = new DataBase();

        try
        {
            string sql = string.Format("INSERT INTO tb_project ( projectName, description, upTime, tid, uid)VALUES  ( '{0}', '{1}','{2}', {3}, {4})", pe.ProjectName, pe.Description, pe.UpTime, pe.Tid, pe.Uid);
            db.ExCommandNoBack(sql);
            return(true);
        }
        catch
        {
            return(false);
        }
    }
Ejemplo n.º 16
0
        public void TestMethod1()
        {
            ProjectsController   pCon        = new ProjectsController();
            JArray               projArray   = pCon.GetProjects();
            List <ProjectEntity> objProjects = new List <ProjectEntity>();

            foreach (var project in db.Projects)
            {
                ProjectEntity objProject = new ProjectEntity();
                objProject = RetProjectEntity(project);
                objProjects.Add(objProject);
            }
            var json = JsonConvert.SerializeObject(objProjects);

            Assert.AreEqual(json, projArray);
        }
Ejemplo n.º 17
0
 public int Submit(ProjectEntity entity)
 {
     try
     {
         entity.D_Submit = DateTime.Now;
         FlowKinkEntity flowKinkEntity = DataHelper.GetDataItem <FlowKinkEntity>("Usp_Flow_Template", new { Id = entity.I_FlowType });
         FlowHelper.Commit(entity, flowKinkEntity, entity.I_Creater, true);
         WriteLog("流程提交", entity);
         DataHelper.ExecuteNonQuery("Usp_Project_Insert", entity);
         return(1);
     }
     catch (Exception ex)
     {
         return(-1);
     }
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Creates a <see cref="ProjectEntity"/> based on the information of the <see cref="RiskeerProject"/>.
        /// </summary>
        /// <param name="project">The project to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <returns>A new <see cref="ProjectEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="registry"/> is <c>null</c>.</exception>
        internal static ProjectEntity Create(this RiskeerProject project, PersistenceRegistry registry)
        {
            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            var entity = new ProjectEntity
            {
                Description = project.Description.DeepClone()
            };

            entity.AssessmentSectionEntities.Add(project.AssessmentSection.Create(registry));

            return(entity);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Fetches project details by id
        /// </summary>
        /// <param name="projectId"></param>
        /// <returns>Single Project Entity</returns>
        public ProjectEntity GetProjectById(string projectId)
        {
            AspNetProject rp = _unitOfWork.ProjectRepository.GetByID(projectId);
            ProjectEntity ep = new ProjectEntity();

            //AspNetProject to EntityProject mapping
            ep.Id           = rp.Id;
            ep.Title        = rp.Title;
            ep.Topic        = rp.Topic;
            ep.DateCreated  = rp.DateCreated;
            ep.DateModified = rp.DateModified;
            ep.AuthorId     = rp.AuthorId;
            ep.FullText     = rp.FullText;

            return(ep);
        }
Ejemplo n.º 20
0
        public async Task <DomainProject> GetAsync(DomainProject entity)
        {
            ProjectEntity project = await _projectRepository.GetAsync(entity.Id);

            if (project == null)
            {
                throw new NotFoundException(string.Format("Project with id '{0}' was not found.", entity.Id));
            }

            if (project.UserId != entity.UserId)
            {
                throw new ForbiddenException();
            }

            return(_mapper.Map <ProjectEntity, DomainProject>(project));
        }
Ejemplo n.º 21
0
        void loadOperationProject_Completed(object sender, EventArgs e)
        {
            ProjectList.Clear();
            LoadOperation loadOperation = sender as LoadOperation;

            foreach (ProductManager.Web.Model.project project in loadOperation.Entities)
            {
                ProjectEntity projectEntity = new ProjectEntity();
                projectEntity.Project = project;
                projectEntity.Update();
                ProjectList.Add(projectEntity);
            }

            UpdateChanged("ProjectList");
            IsBusy = false;
        }
Ejemplo n.º 22
0
        public void Build(ProjectEntity project)
        {
            this.project      = project;
            this.workloadList = TFS.WorkItem.Workload.GetAll(project.Name, TFS.Utility.GetBestIteration(project.Name));
            BuildTitle();
            BuildSubTitle();
            BuildDescription();
            BuildSummaryTable();

            BuildDevelopmentTitle();
            BuildDevelopmentDescription();

            int startRow = BuildDevelopmentTable();
            int dataRow  = startRow - 3;

            List <Tuple <string, double, double> > workloads = new List <Tuple <string, double, double> >();

            for (int i = 14; i <= dataRow; i++)
            {
                string textb = this.sheet.Cells[i, "B"].Text;
                string textf = this.sheet.Cells[i, "F"].Text;
                string texti = this.sheet.Cells[i, "I"].Text;

                if (texti.StartsWith("#"))
                {
                    texti = "0%";
                }

                if (String.IsNullOrEmpty(textb))
                {
                    continue;
                }

                workloads.Add(Tuple.Create <string, double, double>(this.sheet.Cells[i, "B"].Text, Convert.ToDouble(textf.Replace("%", "")) / 100.00d, Convert.ToDouble(texti.Replace("%", "")) / 100.00d));
            }

            startRow = Build120Analysis(startRow, workloads);
            startRow = Build100Analysis(startRow, workloads);
            startRow = Build60Analysis(startRow, workloads);
            startRow = BUild10Analysis(startRow, dataRow);

            ExcelInterop.Range colb = sheet.Cells[1, "B"];
            Utility.AddNativieResource(colb);
            colb.ColumnWidth = 10;

            sheet.Cells[1, "A"] = "";
        }
Ejemplo n.º 23
0
        private metaDataTemplate FindFieldTemplate(string name, Entity owner)
        {
            IEnumerable <metaDataTemplate> possibleTemplates =
                templateRepository.FieldTemplates.Where(t => t.name.Equals(name, StringComparison.OrdinalIgnoreCase) &&
                                                        FirmwareVersionIsSupported(t.supportedFirmwareVersions));
            metaDataTemplate fieldTemplate = NewestTemplate(possibleTemplates);

            return(fieldTemplate);

            bool FirmwareVersionIsSupported(string supportedFirmwareVersion)
            {
                if (supportedFirmwareVersion == null)
                {
                    return(true);
                }
                ProjectEntity project   = ProjectEntity.Decorate(owner.IsRoot() ? owner : owner.Root);
                Version       minTarget = project.Targets.Min(t => TargetEntity.Decorate(t).Version);

                if (minTarget == null)
                {
                    return(true);
                }

                NuGetVersion targetVersion = new NuGetVersion(minTarget);

                if (VersionRange.TryParse(supportedFirmwareVersion, out VersionRange supportedVersion))
                {
                    return(supportedVersion.Satisfies(targetVersion));
                }

                return(true);
            }

            metaDataTemplate NewestTemplate(IEnumerable <metaDataTemplate> templates)
            {
                IEnumerable <metaDataTemplate> templatesWithVersion = templates.Where(t => t.supportedFirmwareVersions != null);

                if (!templatesWithVersion.Any())
                {
                    return(templates.FirstOrDefault());
                }

                return(templatesWithVersion.Where(template => template.supportedFirmwareVersions.Equals(
                                                      templatesWithVersion.Max(t => t.supportedFirmwareVersions), StringComparison.OrdinalIgnoreCase))
                       .FirstOrDefault());
            }
        }
Ejemplo n.º 24
0
 void projectDeleteHelper(ProjectEntity project)
 {
     if (project.parent != null)
     {
         project.parent.ProjectList.Remove(project.name);
     }
     else
     {
         Homepage.ProjectList.Remove(project.name);
     }
     foreach (KeyValuePair <string, TagEntity> tag in project.TagList)
     {
         TagEntity t = tag.Value;
         t.ProjectList.Remove(project.name);
     }
     Homepage.ProjectMasterList.Remove(project.name);
 }
Ejemplo n.º 25
0
        public void Create_StringPropertiesDoNotShareReference()
        {
            // Setup
            const string testdescription = "original description";
            var          project         = new RiskeerProject(new AssessmentSection(AssessmentSectionComposition.Dike))
            {
                Description = testdescription
            };
            var registry = new PersistenceRegistry();

            // Call
            ProjectEntity entity = project.Create(registry);

            // Assert
            Assert.AreNotSame(testdescription, entity.Description);
            Assert.AreEqual(testdescription, entity.Description);
        }
Ejemplo n.º 26
0
        public ActionResult GetFormJson(string keyValue)
        {
            var entity = new ProjectEntity();

            try
            {
                entity = projectApp.FindList(c => c.projectGuid == keyValue).FirstOrDefault();
                WirteOperationRecord("Project", "SELECT", "查询", "Info:获取项目资料(单个)");
            }
            catch (Exception ex)
            {
                log.logType  = "ERROR";
                log.logLevel = "ERROR";
                WirteOperationRecord("Project", "", "", "Info:" + ex.Message.ToString());
            }
            return(Content(entity.ToJson()));
        }
Ejemplo n.º 27
0
 private void LoadOperationProjectCompleted(LoadOperation <ProductManager.Web.Model.project> aLoadOperation)
 {
     ProjectList.Clear();
     foreach (ProductManager.Web.Model.project project in aLoadOperation.Entities)
     {
         ProjectEntity projectEntity = new ProjectEntity();
         projectEntity.Project = project;
         projectEntity.Update();
         ProjectList.Add(projectEntity);
     }
     if (aLoadOperation.TotalEntityCount != -1)
     {
         this.projectView.SetTotalItemCount(aLoadOperation.TotalEntityCount);
     }
     UpdateChanged("ProjectList");
     this.IsBusy = false;
 }
Ejemplo n.º 28
0
        public async Task <IActionResult> Create([Bind("Name,Order")] ProjectEntity project)
        {
            if (ModelState.IsValid)
            {
                project.CreateTime     = DateTime.Now;
                project.LastModifyTime = DateTime.Now;
                UserEntity usere = _context.Set <UserEntity>().SingleOrDefault(t => t.Account == HttpContext.User.Identity.Name);
                project.CreatorUserId    = usere.Id;
                project.LastModifyUserId = project.CreatorUserId;
                project.Id = Guid.NewGuid().ToString("N");
                _context.Add(project);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(project));
        }
Ejemplo n.º 29
0
        public async Task <DetailedProjectDto> UpdateProjectAsync(DetailedProjectDto project)
        {
            await ValidateProject(new ProjectDto()
            {
                CommunicationPlatform = project.CommunicationPlatform
            });

            var mappedEntity = _mapper.Map <ProjectEntity>(project);

            await RecomputeProjectCollaboratorSuggestions(_mapper.Map <ProjectDto>(project));

            ProjectEntity updatedProject = await _projectStorage.UpdateAsync(mappedEntity);

            DetailedProjectDto detailedProjectDto = _mapper.Map <DetailedProjectDto>(updatedProject);

            return(detailedProjectDto);
        }
Ejemplo n.º 30
0
        public static void Seeder(IDbSet <ProjectEntity> projects, IDbSet <CompanyEntity> companies)
        {
            var companyOne = companies.Find(1);
            var companyTwo = companies.Find(2);

            if (companyOne == null)
            {
                throw new Exception("Company One not found");
            }
            if (companyTwo == null)
            {
                throw new Exception("Company Two not found");
            }


            var projectOne = new ProjectEntity()
            {
                Name        = "Project One",
                Description = "This is the first test project",
                Company     = companyOne
            };
            var projectTwo = new ProjectEntity()
            {
                Name        = "Project two",
                Description = "This is the second test project",
                Company     = companyOne
            };
            var projectThree = new ProjectEntity()
            {
                Name        = "Project three",
                Description = "This is the third test project",
                Company     = companyOne
            };
            var projectFour = new ProjectEntity()
            {
                Name        = "Project four",
                Description = "This is the fourth test project",
                Company     = companyTwo
            };

            projects.AddOrUpdate(x => x.Name,
                                 projectOne,
                                 projectTwo,
                                 projectThree,
                                 projectFour);
        }
        public List <ProjectEntity> GetProject(string connectionString)
        {
            List <ProjectEntity> listProject = new List <ProjectEntity>();

            using (var context = new MISAEntity(connectionString))
            {
                var deparrtment = context.Departments.ToList();
                var categories  = context.Projects.ToList().OrderBy(x => x.Grade);
                foreach (var result in categories)
                {
                    var project = new ProjectEntity();
                    project.ProjectId           = result.ProjectID.ToString();
                    project.ProjectCode         = result.ProjectCode;
                    project.ProjectNumber       = result.ProjectNumber;
                    project.ProjectName         = result.ProjectName;
                    project.ProjectEnglishName  = result.ProjectEnglishName;
                    project.BUCACodeID          = result.MISACodeID;
                    project.StartDate           = result.StartDate;
                    project.FinishDate          = result.FinishDate;
                    project.ExecutionUnit       = result.ExecutionUnit;
                    project.DepartmentID        = result.Department == null? null: result.Department.DepartmentID.ToString();
                    project.TotalAmountApproved = result.TotalAmountApproved;
                    project.ParentID            = result.ParentID.ToString();
                    project.Grade    = result.Grade;
                    project.IsParent = result.IsParent;
                    project.IsDetailbyActivityAndExpense = result.IsDetailbyActivityAndExpense;
                    project.IsSystem          = result.IsSystem;
                    project.IsActive          = result.Inactive != true;
                    project.ObjectType        = result.ObjectType;
                    project.ContractorID      = result.ContractorID.ToString();
                    project.ContractorName    = result.ContractorName;
                    project.ContractorAddress = result.ContractorAddress;
                    project.Description       = result.Description;
                    project.ProjectSize       = result.ProjectSize;
                    project.BuildLocation     = result.BuildLocation;
                    project.InvestmentClass   = result.InvestmentClass;
                    project.CDCActivityType   = result.CDCActivityType;
                    project.Investment        = "";


                    listProject.Add(project);
                }
            }

            return(listProject);
        }
Ejemplo n.º 32
0
        private async Task <DomainProjectForAdmin> GetProjectDataAsync(ProjectEntity project)
        {
            UserEntity user = await _userRepository.GetAsync(project.UserId);

            return(new DomainProjectForAdmin
            {
                ProjectId = project.Id,
                Name = project.Name,
                Description = project.Description,
                Created = project.Created,
                Modified = project.Modified,
                UserId = project.UserId,
                UserName = user != null ? user.Name : null,
                ProductType = (ProductType)project.ProductId,
                Product = _productWriterForAdmin.WriteProduct(project.ProductId)
            });
        }
Ejemplo n.º 33
0
        public void SendNewComment(ProjectEntity entity, Comment comment)
        {
            INotifyAction action;

            if (entity.GetType() == typeof(Issue))
            {
                action = NotifyConstants.Event_NewCommentForIssue;
            }
            else if (entity.GetType() == typeof(Message))
            {
                action = NotifyConstants.Event_NewCommentForMessage;
            }
            else if (entity.GetType() == typeof(Milestone))
            {
                action = NotifyConstants.Event_NewCommentForMilestone;
            }
            else if (entity.GetType() == typeof(Task))
            {
                action = NotifyConstants.Event_NewCommentForTask;
            }
            else
            {
                return;
            }

            var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));

            try
            {
                client.AddInterceptor(interceptor);
                client.SendNoticeAsync(
                    action,
                    entity.NotifyId,
                    null,
                    new TagValue(NotifyConstants.Tag_ProjectID, entity.Project.ID),
                    new TagValue(NotifyConstants.Tag_ProjectTitle, entity.Project.Title),
                    new TagValue(NotifyConstants.Tag_EntityTitle, entity.Title),
                    new TagValue(NotifyConstants.Tag_EntityID, entity.ID),
                    new TagValue(NotifyConstants.Tag_AdditionalData, comment.Content),
                    GetReplyToEntityTag(entity, comment));
            }
            finally
            {
                client.RemoveInterceptor(interceptor.Name);
            }
        }
Ejemplo n.º 34
0
        public void GivenProjectEntity_WhenGeneratingFingerprintEqualData_ThenHashRemainsEqual()
        {
            // Setup
            RiskeerProject project1 = RiskeerProjectTestHelper.GetFullTestProject();
            RiskeerProject project2 = RiskeerProjectTestHelper.GetFullTestProject();
            ProjectEntity  entity1  = project1.Create(new PersistenceRegistry());
            ProjectEntity  entity2  = project2.Create(new PersistenceRegistry());

            // Call
            byte[] hash1 = FingerprintHelper.Get(entity1);
            byte[] hash2 = FingerprintHelper.Get(entity2);

            // Assert
            Assert.IsNotNull(hash1);
            CollectionAssert.IsNotEmpty(hash1);
            CollectionAssert.AreEqual(hash1, hash2);
        }
Ejemplo n.º 35
0
 /// <summary>
 /// Creates a Project
 /// </summary>
 /// <param name="projectEntity"></param>
 /// <returns></returns>
 public int CreateProject(ProjectEntity projectEntity)
 {
     using (var scope = new TransactionScope())
     {
         var project = new Project
         {
             ProjectName = projectEntity.ProjectName,
             Start_Date  = projectEntity.Start_Date,
             End_Date    = projectEntity.End_Date,
             Priority    = projectEntity.Priority
         };
         _unitOfWork.ProjectRepository.Insert(project);
         _unitOfWork.Save();
         scope.Complete();
         return(project.Project_ID);
     }
 }
Ejemplo n.º 36
0
        public void Save()
        {
            ProjectEntity entity = ((BindingView)this.DataContext).Project;

            entity.Settings.Action = (bool)rbMethodCall.IsChecked ? ProfilMode.CallCount : ProfilMode.TimeSpent;

            entity.Settings.LogLevel = (ProfilerLogLevel)this.sliderLogLevel.Value;

            if (this.cbTransportMode.SelectedIndex == 0)
            {
                entity.Settings.TransportMode = Transport.Http;
            }
            else
            {
                entity.Settings.TransportMode = Transport.Tcp;
            }
        }
Ejemplo n.º 37
0
        public List <File> GetEntityFiles(ProjectEntity entity)
        {
            if (entity == null)
            {
                return(new List <File>());
            }

            using (var tagdao = FilesIntegration.GetTagDao())
                using (var filedao = FilesIntegration.GetFileDao())
                {
                    var ids   = tagdao.GetTags(entity.GetType().Name + entity.ID, TagType.System).Where(t => t.EntryType == FileEntryType.File).Select(t => t.EntryId).ToArray();
                    var files = 0 < ids.Length ? filedao.GetFiles(ids) : new List <File>();
                    files.ForEach(r => r.Access = GetFileShare(r, entity.Project.ID));
                    SetThumbUrls(files);
                    return(files);
                }
        }
Ejemplo n.º 38
0
 protected void btn_OK_Click(object sender, EventArgs e)
 {
     /*初始化工程,并设置属性*/
     ProjectEntity pe = new ProjectEntity();
     pe.ProjectName = tb_ProjectName.Text;
     pe.Tid =int.Parse( ddl_Type.SelectedValue);
     pe.Uid =int.Parse( Session["uid"].ToString());
     pe.UpTime = DateTime.Now;
     pe.Description = tb_Description.Text;
     /*添加工程,并返回是否成功*/
     if (ProjectOperation.AddProject(pe) == true)
     {
         SmallScript.goRedirect(Response,Session,"工程已成功添加!","/admin/projectlist.aspx");
     }
     else{
         SmallScript.MessageBox(Page,"添加工程失败!");
     };
 }
Ejemplo n.º 39
0
 public static ProjectEntity GetProject(int projectId)
 {
     /*获取工程信息*/
     DataBase db = new DataBase();
     DataSet rs = db.RunProcReturn("select * from tb_project where id=" + projectId, "tb_project");
     if (rs.Tables[0].Rows.Count > 0)
     {
         ProjectEntity pe = new ProjectEntity();
         pe.ProjectName = rs.Tables[0].Rows[0]["projectName"].ToString();
         pe.Uid = int.Parse(rs.Tables[0].Rows[0]["uid"].ToString());
         pe.Tid = int.Parse(rs.Tables[0].Rows[0]["tid"].ToString());
         pe.UpTime = DateTime.Parse(rs.Tables[0].Rows[0]["uptime"].ToString());
         pe.Id = int.Parse(rs.Tables[0].Rows[0]["id"].ToString());
         pe.Description = rs.Tables[0].Rows[0]["description"].ToString();
         return pe;
     }
     return null;
 }
Ejemplo n.º 40
0
 internal void DeleteEntity(ProjectEntity entity, bool directory)
 {
     if (directory) {
         Helpers.RemoveObject(ref p_Directories, entity);
     }
     else {
         Helpers.RemoveObject(ref p_Files, entity);
     }
 }
Ejemplo n.º 41
0
 public void Follow(ProjectEntity entity)
 {
     Follow(entity, SecurityContext.CurrentAccount.ID);
 }
Ejemplo n.º 42
0
        public void SendNewFile(List<IRecipient> recipients, ProjectEntity entity, string fileTitle)
        {
            INotifyAction action;
            if (entity.GetType() == typeof(Message)) action = NotifyConstants.Event_NewFileForDiscussion;
            else if (entity.GetType() == typeof(Task)) action = NotifyConstants.Event_NewFileForTask;
            else return;

            var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
            try
            {
                client.AddInterceptor(interceptor);
                client.SendNoticeToAsync(
                    action,
                    entity.NotifyId,
                    recipients.ToArray(), 
                    true,
                    new TagValue(NotifyConstants.Tag_ProjectID, entity.Project.ID),
                    new TagValue(NotifyConstants.Tag_ProjectTitle, entity.Project.Title),
                    new TagValue(NotifyConstants.Tag_EntityTitle, entity.Title),
                    new TagValue(NotifyConstants.Tag_EntityID, entity.ID),
                    new TagValue(NotifyConstants.Tag_AdditionalData, fileTitle));
            }
            finally
            {
                client.RemoveInterceptor(interceptor.Name);
            }
        }
Ejemplo n.º 43
0
 internal void RegisterEntity(ProjectEntity entity, bool directory)
 {
     if (directory) {
         Array.Resize(ref p_Directories, p_Directories.Length + 1);
         p_Directories[p_Directories.Length - 1] = entity;
     }
     else {
         Array.Resize(ref p_Files, p_Files.Length + 1);
         p_Files[p_Files.Length - 1] = entity;
     }
 }
Ejemplo n.º 44
0
        public IEnumerable<File> GetFiles(ProjectEntity entity)
        {
            if (entity == null) return new List<File>();

            if (!ProjectSecurity.CanReadFiles(entity.Project)) return new List<File>();

            using (var tagdao = FilesIntegration.GetTagDao())
            using (var filedao = FilesIntegration.GetFileDao())
            {
                var ids = tagdao.GetTags(entity.GetType().Name + entity.ID, TagType.System).Where(t => t.EntryType == FileEntryType.File).Select(t => t.EntryId).ToArray();
                var files = 0 < ids.Length ? filedao.GetFiles(ids) : new List<File>();

                var rootId = FileEngine.GetRoot(entity.Project.ID);

                //delete tags when file moved from project folder
                files.Where(file => !file.RootFolderId.Equals(rootId)).ToList()
                    .ForEach(file =>
                    {
                        DetachFile(entity, file.ID);
                        files.Remove(file);
                    });

                files.ForEach(r => r.Access = FileEngine.GetFileShare(r, entity.Project.ID));
                return files;
            }
        }
Ejemplo n.º 45
0
        public void SendNewComment(ProjectEntity entity, Comment comment)
        {
            INotifyAction action;
            if (entity.GetType() == typeof(Issue)) action = NotifyConstants.Event_NewCommentForIssue;
            else if (entity.GetType() == typeof(Message)) action = NotifyConstants.Event_NewCommentForMessage;
            else if (entity.GetType() == typeof(Milestone)) action = NotifyConstants.Event_NewCommentForMilestone;
            else if (entity.GetType() == typeof(Task)) action = NotifyConstants.Event_NewCommentForTask;
            else return;

            var interceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), ""));
            try
            {
                client.AddInterceptor(interceptor);
                client.SendNoticeAsync(
                    action,
                    entity.NotifyId,
                    null,
                    new TagValue(NotifyConstants.Tag_ProjectID, entity.Project.ID),
                    new TagValue(NotifyConstants.Tag_ProjectTitle, entity.Project.Title),
                    new TagValue(NotifyConstants.Tag_EntityTitle, entity.Title),
                    new TagValue(NotifyConstants.Tag_EntityID, entity.ID),
                    new TagValue(NotifyConstants.Tag_AdditionalData, comment.Content),
                    GetReplyToEntityTag(entity, comment));
            }
            finally
            {
                client.RemoveInterceptor(interceptor.Name);
            }
        }
Ejemplo n.º 46
0
        public void DetachFile(ProjectEntity entity, object fileId)
        {
            if (!ProjectSecurity.CanReadFiles(entity.Project)) return;

            using (var dao = FilesIntegration.GetTagDao())
            {
                dao.RemoveTags(new Tag(entity.GetType().Name + entity.ID, TagType.System, Guid.Empty) { EntryType = FileEntryType.File, EntryId = fileId });
            }
        }
Ejemplo n.º 47
0
        public void AttachFile(ProjectEntity entity, object fileId, bool notify)
        {
            if (!ProjectSecurity.CanReadFiles(entity.Project)) return;

            File file;

            using (var dao = FilesIntegration.GetTagDao())
            {
                dao.SaveTags(new Tag(entity.GetType().Name + entity.ID, TagType.System, Guid.Empty) { EntryType = FileEntryType.File, EntryId = fileId });
                file = FileEngine.GetFile(fileId, 0);
            }

            if (notify && !Factory.DisableNotifications)
            {
                var senders = GetSubscribers(entity);
                NotifyClient.Instance.SendNewFile(senders, entity, file.Title);
            }
        }
Ejemplo n.º 48
0
        public Comment SaveOrUpdateComment(ProjectEntity entity, Comment comment)
        {
            var isNew = comment.ID.Equals(Guid.Empty);

            Factory.GetCommentEngine().SaveOrUpdate(comment);

            NotifyNewComment(comment, entity, isNew);

            Subscribe(entity, SecurityContext.CurrentAccount.ID);

            return comment;
        }
Ejemplo n.º 49
0
        private void NotifyNewComment(Comment comment, ProjectEntity entity, bool isNew)
        {
            if (Factory.DisableNotifications) return;

            var senders = GetSubscribers(entity);

            NotifyClient.Instance.SendNewComment(senders, entity, comment, isNew);
        }
Ejemplo n.º 50
0
 public void UnSubscribe(ProjectEntity entity)
 {
     UnSubscribe(entity, SecurityContext.CurrentAccount.ID);
 }
Ejemplo n.º 51
0
 public bool IsSubscribed(ProjectEntity entity)
 {
     return IsSubscribed(entity, SecurityContext.CurrentAccount.ID);
 }
Ejemplo n.º 52
0
        public bool IsUnsubscribed(ProjectEntity entity, Guid recipientID)
        {
            var recipient = RecipientProvider.GetRecipient(recipientID.ToString());

            return recipient != null && SubscriptionProvider.IsUnsubscribe((IDirectRecipient)recipient, NotifyAction, entity.NotifyId);
        }
Ejemplo n.º 53
0
 private static TagValue GetReplyToEntityTag(ProjectEntity entity, Comment comment)
 {
     string type = string.Empty;
     if (entity is Task)
     {
         type = "project.task";
     }
     if (entity is Message)
     {
         type = "project.message";
     }
     if (entity is Milestone)
     {
         type = "project.milestone";
     }
     if (!string.IsNullOrEmpty(type))
     {
         return ReplyToTagProvider.Comment(type, entity.ID.ToString(), comment != null ? comment.ID.ToString() : null);
     }
     return null;
 }
Ejemplo n.º 54
0
        public void Follow(ProjectEntity entity, Guid recipientID)
        {
            var recipient = RecipientProvider.GetRecipient(recipientID.ToString());

            if (recipient == null) return;

            if (!IsSubscribed(entity, recipientID))
                SubscriptionProvider.Subscribe(NotifyAction, entity.NotifyId, recipient);
            else
                SubscriptionProvider.UnSubscribe(NotifyAction, entity.NotifyId, recipient);
        }
Ejemplo n.º 55
0
 public List<IRecipient> GetSubscribers(ProjectEntity entity)
 {
     return SubscriptionProvider.GetRecipients(NotifyAction, entity.NotifyId).ToList();
 }
Ejemplo n.º 56
0
        public List<File> GetEntityFiles(ProjectEntity entity)
        {
            if (entity == null) return new List<File>();

            using (var tagdao = FilesIntegration.GetTagDao())
            using (var filedao = FilesIntegration.GetFileDao())
            {
                var ids = tagdao.GetTags(entity.GetType().Name + entity.ID, TagType.System).Where(t => t.EntryType == FileEntryType.File).Select(t => t.EntryId).ToArray();
                var files = 0 < ids.Length ? filedao.GetFiles(ids) : new List<File>();
                files.ForEach(r => r.Access = GetFileShare(r, entity.Project.ID));
                SetThumbUrls(files);
                return files;
            }
        }