public long AddLink(long userId, long movieId, string name, string description, string url) { if (!UserDao.Exists(userId)) { throw new InstanceNotFoundException <UserProfileDetails>("userId", userId); } if (LinkDao.ExistsForMovieAndName(movieId, name)) { throw new DuplicateInstanceException <LinkDetails>("movieId", movieId, "name", name); } if (LinkDao.ExistsForMovieAndUrl(movieId, url)) { throw new DuplicateInstanceException <LinkDetails>("movieId", movieId, "url", url); } Link link = Link.CreateLink(-1, movieId, userId, name, description, url, DateTime.Now); link.reportRead = false; try { LinkDao.Create(link); } catch (DuplicateInstanceException <Link> ex) { throw new DuplicateInstanceException <LinkDetails>(ex.Properties); } return(link.linkId); }
public long AddToFavorites(long userId, long linkId, string name, string description) { if (!UserProfileDao.Exists(userId)) { throw new InstanceNotFoundException <UserProfileDetails>("userId", userId); } if (!LinkDao.Exists(linkId)) { throw new InstanceNotFoundException <LinkDetails>("linkId", linkId); } if (FavoriteDao.ExistsForUserAndLink(userId, linkId)) { throw new DuplicateInstanceException <FavoriteDetails>("userId", userId, "linkId", linkId); } Favorite favorite = Favorite.CreateFavorite(-1, userId, linkId, name, description, DateTime.Now); try { FavoriteDao.Create(favorite); } catch (DuplicateInstanceException <Favorite> ex) { throw new InternalErrorException(ex); } return(favorite.favoriteId); }
public LinkDetails GetLink(long linkId) { Link link; try { link = LinkDao.Find(linkId); } catch (InstanceNotFoundException <Link> ex) { throw new InstanceNotFoundException <LinkDetails>(ex); } UserProfile user; try { user = UserDao.Find(link.userId); } catch (InstanceNotFoundException <UserProfile> ex) { throw new InternalErrorException(ex); } int rating = RatingDao.CalculateValueForLink(link.linkId); return(new LinkDetails(link.linkId, link.userId, user.userLogin, link.movieId, link.name, link.description, link.url, rating, link.reportRead.GetValueOrDefault(), link.date)); }
public DictionaryBlock <string, long> GetLabelsForLink(long linkId, int startIndex, int count) { if (!LinkDao.Exists(linkId)) { throw new InstanceNotFoundException <LinkDetails>("linkId", linkId); } ListBlock <Label> labels; try { labels = LabelDao.ListForLinkRated(linkId, startIndex, count); } catch (InstanceNotFoundException <Label> ) { return(new DictionaryBlock <string, long>(startIndex, false)); } catch (NoMoreItemsException <Label> ) { return(new DictionaryBlock <string, long>(startIndex, false)); } DictionaryBlock <string, long> details = new DictionaryBlock <string, long>(labels.Index, labels.HasMore); foreach (Label label in labels) { int rating = RatingDao.CalculateValueForLabel(label.text); details.Add(label.text, rating); } return(details); }
/// <summary> /// 删除该流程 /// </summary> public void Remove() { ISqlMapper mapper = MapperHelper.GetMapper(); WorkflowDao wfdao = new WorkflowDao(mapper); ActivityDao activitydao = new ActivityDao(mapper); LinkDao linkDao = new LinkDao(mapper); ActivityAuthDao authdao = new ActivityAuthDao(mapper); ApprovalDao approvalDao = new ApprovalDao(mapper); TaskDao taskdao = new TaskDao(mapper); string id = this.value.ID; var activities = activitydao.Query(new ActivityQueryForm { WorkflowID = id }); taskdao.Delete(new TaskQueryForm { WorkflowID = id }); wfdao.Delete(new WorkflowQueryForm { ID = id }); activitydao.Delete(new ActivityQueryForm { WorkflowID = id }); linkDao.Delete(new LinkQueryForm { WorkflowID = id }); approvalDao.Delete(new ApprovalQueryForm { WorkflowID = id }); authdao.Delete(new ActivityAuthQueryForm { WorkflowID = id }); }
public void RemoveLink(long userId, long linkId) { if (!UserDao.Exists(userId)) { throw new InstanceNotFoundException <UserProfileDetails>("userId", userId); } Link link; try { link = LinkDao.Find(linkId); } catch (InstanceNotFoundException <Link> ex) { throw new InstanceNotFoundException <LinkDetails>(ex.Properties); } if (link.UserProfile.userId != userId) { throw new UserNotAuthorizedException <LinkDetails>(userId, "linkId", linkId); } try { LinkDao.Remove(linkId); } catch (InstanceNotFoundException <Link> ex) { throw new InternalErrorException(ex); } }
public void SetReportedLinkAsRead(long userId, long linkId) { if (!UserDao.Exists(userId)) { throw new InstanceNotFoundException <UserProfileDetails>("userId", userId); } Link link; try { link = LinkDao.Find(linkId); } catch (InstanceNotFoundException <Link> ex) { throw new InstanceNotFoundException <LinkDetails>(ex.Properties); } if (userId != link.UserProfile.userId) { throw new UserNotAuthorizedException <LinkDetails>(userId, "linkId", linkId);; } link.reportRead = true; try { LinkDao.Update(link); } catch (InstanceNotFoundException <Link> ex) { throw new InternalErrorException(ex); } }
public void RunJob(DistributedTask _, CancellationToken cancellationToken) { try { CancellationToken = cancellationToken; CoreContext.TenantManager.SetCurrentTenant(CurrentTenant); Thread.CurrentPrincipal = principal; Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(culture); Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(culture); FolderDao = Global.DaoFactory.GetFolderDao(); FileDao = Global.DaoFactory.GetFileDao(); TagDao = Global.DaoFactory.GetTagDao(); ProviderDao = Global.DaoFactory.GetProviderDao(); FilesSecurity = new FileSecurity(Global.DaoFactory); LinkDao = Global.GetLinkDao(); Logger = Global.Logger; Total = InitTotalProgressSteps(); Do(); } catch (AuthorizingException authError) { Error = FilesCommonResource.ErrorMassage_SecurityException; Logger.Error(Error, new SecurityException(Error, authError)); } catch (AggregateException ae) { ae.Flatten().Handle(e => e is TaskCanceledException || e is OperationCanceledException); } catch (Exception error) { Error = error is TaskCanceledException || error is OperationCanceledException ? FilesCommonResource.ErrorMassage_OperationCanceledException : error.Message; Logger.Error(error, error); } finally { try { TaskInfo.SetProperty(FINISHED, true); PublishTaskInfo(); FolderDao.Dispose(); FileDao.Dispose(); TagDao.Dispose(); LinkDao.Dispose(); if (ProviderDao != null) { ProviderDao.Dispose(); } } catch { /* ignore */ } } }
public int GetRating(long userId, long linkId) { if (!UserProfileDao.Exists(userId)) { throw new InstanceNotFoundException <UserProfileDetails>("userId", userId); } if (!LinkDao.Exists(linkId)) { throw new InstanceNotFoundException <LinkDetails>("linkId", linkId); } try { return(RatingDao.FindForUserAndLink(userId, linkId).value); } catch (InstanceNotFoundException <Rating> ) { return(0); } catch (DuplicateInstanceException <Rating> ex) { throw new InternalErrorException(ex); } }
public FavoriteDetails GetFavorite(long userId, long linkId) { if (!UserProfileDao.Exists(userId)) { throw new InstanceNotFoundException <UserProfileDetails>("userId", userId); } if (!LinkDao.Exists(linkId)) { throw new InstanceNotFoundException <LinkDetails>("linkId", linkId); } Favorite favorite; try { favorite = FavoriteDao.FindForUserAndLink(userId, linkId); } catch (InstanceNotFoundException <Favorite> ex) { throw new InstanceNotFoundException <FavoriteDetails>(ex.Properties); } catch (DuplicateInstanceException <Favorite> ex) { throw new InternalErrorException(ex); } return(new FavoriteDetails(favorite.favoriteId, favorite.linkId, favorite.name, favorite.description, favorite.date)); }
public int CountCommentsForLink(long linkId) { if (!LinkDao.Exists(linkId)) { throw new InstanceNotFoundException <LinkDetails>("linkId", linkId); } return(CommentDao.CountForLink(linkId)); }
public int CountReportedLinksForUser(long userId, int threshold) { if (!UserDao.Exists(userId)) { throw new InstanceNotFoundException <UserProfileDetails>("userId", userId); } return(LinkDao.CountForUserReported(userId, threshold)); }
/// <summary> /// 从数据库读取流程信息 /// </summary> /// <param name="workflowids"></param> /// <returns></returns> public static List <WorkflowModel> Load(WorkflowQueryForm form) { List <WorkflowModel> models = new List <WorkflowModel>(); if (form == null) { return(models); } #region query data ISqlMapper mapper = MapperHelper.GetMapper(); WorkflowDao wfdao = new WorkflowDao(mapper); ActivityDao activitydao = new ActivityDao(mapper); LinkDao linkDao = new LinkDao(mapper); ActivityAuthDao authdao = new ActivityAuthDao(mapper); ApprovalDao approvalDao = new ApprovalDao(mapper); TaskDao taskdao = new TaskDao(mapper); List <Activity> activityList = new List <Activity>(); List <Link> linkList = new List <Link>(); List <ActivityAuth> authList = new List <ActivityAuth>(); List <Approval> approvalList = new List <Approval>(); List <Task> taskList = new List <Task>(); List <Workflow> workflows = new List <Workflow>(); //先从缓存取值 //var item = cache.GetItem(id); //if (item != null) //{ // model = item.Value as WorkflowModel; // return model; //} workflows = wfdao.Query(form); var workflowids = (from wf in workflows select wf.ID).ToList(); activityList = activitydao.Query(new ActivityQueryForm { WorkflowIDs = workflowids }); linkList = linkDao.Query(new LinkQueryForm { WorkflowIDs = workflowids }); approvalList = approvalDao.Query(new ApprovalQueryForm { WorkflowIDs = workflowids }); authList = authdao.Query(new ActivityAuthQueryForm { WorkflowIDs = workflowids }); taskList = taskdao.Query(new TaskQueryForm { WorkflowIDs = workflowids }); #endregion foreach (var workflow in workflows) { var model = BuildWorkflow(workflow, activityList, linkList, authList, approvalList, taskList); models.Add(model); } return(models); }
private void DeleteFiles(IEnumerable <object> fileIds) { foreach (var fileId in fileIds) { CancellationToken.ThrowIfCancellationRequested(); var file = FileDao.GetFile(fileId); string tmpError; if (file == null) { Error = FilesCommonResource.ErrorMassage_FileNotFound; } else if (!_ignoreException && WithError(new[] { file }, false, out tmpError)) { Error = tmpError; } else { FileMarker.RemoveMarkAsNewForAll(file); if (!_immediately && FileDao.UseTrashForRemove(file)) { FileDao.MoveFile(file.ID, _trashId); FilesMessageService.Send(file, _headers, MessageAction.FileMovedToTrash, file.Title); if (file.ThumbnailStatus == Thumbnail.Waiting) { file.ThumbnailStatus = Thumbnail.NotRequired; FileDao.SaveThumbnail(file, null); } } else { try { FileDao.DeleteFile(file.ID); FilesMessageService.Send(file, _headers, MessageAction.FileDeleted, file.Title); } catch (Exception ex) { Error = ex.Message; Logger.Error(Error, ex); } LinkDao.DeleteAllLink(file.ID); } ProcessedFile(fileId); } ProgressStep(fileId: FolderDao.CanCalculateSubitems(fileId) ? null : fileId); } }
/// <summary> /// 把流程实体新增到数据库 /// </summary> /// <returns></returns> public bool Create() { ISqlMapper mapper = MapperHelper.GetMapper(); WorkflowDao workflowdao = new WorkflowDao(mapper); ActivityDao activitydao = new ActivityDao(mapper); LinkDao linkdao = new LinkDao(mapper); ActivityAuthDao authdao = new ActivityAuthDao(mapper); workflowdao.Add(this.Value); var activities = this.Root.GetList(); List <Link> linkList = new List <Link>(); //保存节点 foreach (var activity in activities) { activitydao.Add(activity.Value); var activityinstance = activity as ActivityModel; //保存连接 if (activityinstance.PreLinks != null) { foreach (var link in activityinstance.PreLinks) { if (!linkList.Contains(link.Value)) { linkList.Add(link.Value); } } } if (activityinstance.NextLinks != null) { foreach (var link in activityinstance.NextLinks) { if (!linkList.Contains(link.Value)) { linkList.Add(link.Value); } } } //保存权限 foreach (var auth in activityinstance.Auth) { authdao.Add(auth); } } foreach (var link in linkList) { linkdao.Add(link); } return(true); }
public bool HasInFavorites(long userId, long linkId) { if (!UserProfileDao.Exists(userId)) { throw new InstanceNotFoundException <UserProfileDetails>("userId", userId); } if (!LinkDao.Exists(linkId)) { throw new InstanceNotFoundException <LinkDetails>("linkId", linkId); } return(FavoriteDao.ExistsForUserAndLink(userId, linkId)); }
private Link CreateTestLink(UserProfile user, long movieId, string linkName, string linkDescription, string linkUrl, DateTime time) { Link link = Link.CreateLink( TestData.nonExistentLinkId, movieId, user.userId, linkName, linkDescription, linkUrl, Trunk(time)); LinkDao.Create(link); return(link); }
public ListBlock <LinkDetails> GetReportedLinksForUser(long userId, int threshold, int startIndex, int count) { if (!UserDao.Exists(userId)) { throw new InstanceNotFoundException <UserProfileDetails>("userId", userId); } ListBlock <Link> links; try { links = LinkDao.ListForUserReported(userId, threshold, startIndex, count); } catch (InstanceNotFoundException <Link> ) { return(new ListBlock <LinkDetails>(startIndex, false)); } catch (NoMoreItemsException <Link> ) { return(new ListBlock <LinkDetails>(startIndex, false)); } List <LinkDetails> details = new List <LinkDetails>(); foreach (Link link in links) { UserProfile user; try { user = UserDao.Find(link.userId); } catch (InstanceNotFoundException <UserProfile> ex) { throw new InternalErrorException(ex); } int rating = RatingDao.CalculateValueForLink(link.linkId); details.Add(new LinkDetails(link.linkId, link.userId, user.userLogin, link.movieId, link.name, link.description, link.url, rating, link.reportRead.GetValueOrDefault(), link.date)); } return(new ListBlock <LinkDetails>(details, links.Index, links.HasMore)); }
public ListBlock <CommentDetails> GetCommentsForLink(long linkId, int startIndex, int count) { if (!LinkDao.Exists(linkId)) { throw new InstanceNotFoundException <LinkDetails>("linkId", linkId); } ListBlock <Comment> comments; try { comments = CommentDao.ListForLink(linkId, startIndex, count); } catch (InstanceNotFoundException <Comment> ) { return(new ListBlock <CommentDetails>(startIndex, false)); } catch (NoMoreItemsException <Comment> ) { return(new ListBlock <CommentDetails>(startIndex, false)); } List <CommentDetails> details = new List <CommentDetails>(); foreach (Comment comment in comments) { UserProfile user; try { user = UserDao.Find(comment.userId); } catch (InstanceNotFoundException <UserProfile> ex) { throw new InternalErrorException(ex); } details.Add(new CommentDetails(comment.commentId, comment.text, comment.userId, user.userLogin, comment.linkId, comment.date)); } return(new ListBlock <CommentDetails>(details, comments.Index, comments.HasMore)); }
public void UpdateLink(long userId, long linkId, string name, string description) { if (!UserDao.Exists(userId)) { throw new InstanceNotFoundException <UserProfileDetails>("userId", userId); } Link link; try { link = LinkDao.Find(linkId); } catch (InstanceNotFoundException <Link> ex) { throw new InstanceNotFoundException <LinkDetails>(ex.Properties); } if ((link.name != name) && (LinkDao.ExistsForMovieAndName(link.movieId, name))) { throw new DuplicateInstanceException <LinkDetails>("movieId", link.movieId, "name", name); } if (userId != link.UserProfile.userId) { throw new UserNotAuthorizedException <LinkDetails>(userId, "linkId", linkId);; } link.name = name; link.description = description; try { LinkDao.Update(link); } catch (InstanceNotFoundException <Link> ex) { throw new InternalErrorException(ex); } }
private static LinkDetector CreateInstance(int driverID, string direction) { // リンクテーブルを作成 #region Driver毎に、特定のセマンティックリンクidのリストの作成 List <int> semanticLinkIdList = new List <int>(); switch (driverID) { // 運転者やルート追加ごとにこれらの更新が必要になる。 // TODO: ここをハードコードにしない case 1: if (direction == "outward") { for (int id = 187; id <= 201; id++) { semanticLinkIdList.Add(id); } } else if (direction == "homeward") { for (int id = 202; id <= 218; id++) { semanticLinkIdList.Add(id); } } break; } int[] semanticLinkIdArray = semanticLinkIdList.ToArray(); #endregion return(new LinkDetector { DriverID = driverID, Direction = direction, _linkTable = LinkDao.GetLinkTableforMM(semanticLinkIdArray) }); }
public void UpdateFavorite(long userId, long linkId, string name, string description) { if (!UserProfileDao.Exists(userId)) { throw new InstanceNotFoundException <UserProfileDetails>("userId", userId); } if (!LinkDao.Exists(linkId)) { throw new InstanceNotFoundException <LinkDetails>("linkId", linkId); } Favorite favorite; try { favorite = FavoriteDao.FindForUserAndLink(userId, linkId); } catch (InstanceNotFoundException <Favorite> ex) { throw new InstanceNotFoundException <FavoriteDetails>(ex.Properties); } catch (DuplicateInstanceException <Favorite> ex) { throw new InternalErrorException(ex); } favorite.name = name; favorite.description = description; try { FavoriteDao.Update(favorite); } catch (InstanceNotFoundException <Favorite> ex) { throw new InternalErrorException(ex); } }
// GPSデータ点と、driver_idから最近傍リンクとセマンティックリンクを求める // driver_idで読み込むセマンティックリンクを限定する public static Tuple <string, int> detectLink(int driverId, string direction, double lat, double lng) { string linkId = "RB000000000x"; int semanticLinkId = -1; #region Driver毎に、特定のセマンティックリンクidのリストの作成 List <int> semanticLinkIdList = new List <int>(); switch (driverId) { // 運転者やルート追加ごとにこれらの更新が必要になる。 case 1: if (direction == "outward") { for (int id = 187; id <= 201; id++) { semanticLinkIdList.Add(id); } } else if (direction == "homeward") { for (int id = 202; id <= 218; id++) { semanticLinkIdList.Add(id); } } break; } int[] semanticLinkIdArray = semanticLinkIdList.ToArray(); #endregion // 運転者ごとのリンクが得られる // TODO 何度も同じテーブルを得ることになるので、上手くキャッシュする仕組みが必要。 DataTable linkTable = LinkDao.GetLinkTableforMM(semanticLinkIdArray); return(new Tuple <string, int>(linkId, semanticLinkId)); }
public long AddComment(long userId, long linkId, string text) { if (!UserDao.Exists(userId)) { throw new InstanceNotFoundException <UserProfileDetails>("userId", userId); } if (!LinkDao.Exists(linkId)) { throw new InstanceNotFoundException <LinkDetails>("linkId", linkId); } Comment comment = Comment.CreateComment(-1, userId, linkId, text, DateTime.Now); try { CommentDao.Create(comment); } catch (DuplicateInstanceException <Comment> ex) { throw new InternalErrorException(ex); } return(comment.commentId); }
public void RemoveFromFavorites(long userId, long linkId) { if (!UserProfileDao.Exists(userId)) { throw new InstanceNotFoundException <UserProfileDetails>("userId", userId); } if (!LinkDao.Exists(linkId)) { throw new InstanceNotFoundException <LinkDetails>("linkId", linkId); } Favorite favorite; try { favorite = FavoriteDao.FindForUserAndLink(userId, linkId); } catch (InstanceNotFoundException <Favorite> ex) { throw new InstanceNotFoundException <FavoriteDetails>(ex.Properties); } catch (DuplicateInstanceException <Favorite> ex) { throw new InternalErrorException(ex); } try { FavoriteDao.Remove(favorite.favoriteId); } catch (InstanceNotFoundException <Favorite> ex) { throw new InternalErrorException(ex); } }
public int CountLinksForLabel(string label) { return(LinkDao.CountForLabel(label)); }
/// <summary> /// 把流程实体新增到数据库 /// </summary> /// <returns></returns> public bool Create() { ISqlMapper mapper = MapperHelper.GetMapper(); WorkflowDao workflowdao = new WorkflowDao(mapper); ActivityDao activitydao = new ActivityDao(mapper); LinkDao linkdao = new LinkDao(mapper); ActivityAuthDao authdao = new ActivityAuthDao(mapper); workflowdao.Add(this.Value); var activities = this.Root.GetList(); List<Link> linkList = new List<Link>(); //保存节点 foreach (var activity in activities) { activitydao.Add(activity.Value); var activityinstance = activity as ActivityModel; //保存连接 if (activityinstance.PreLinks != null) { foreach (var link in activityinstance.PreLinks) { if (!linkList.Contains(link.Value)) { linkList.Add(link.Value); } } } if (activityinstance.NextLinks != null) { foreach (var link in activityinstance.NextLinks) { if (!linkList.Contains(link.Value)) { linkList.Add(link.Value); } } } //保存权限 foreach (var auth in activityinstance.Auth) { authdao.Add(auth); } } foreach (var link in linkList) { linkdao.Add(link); } return true; }
/// <summary> /// 删除该流程 /// </summary> public void Remove() { ISqlMapper mapper = MapperHelper.GetMapper(); WorkflowDao wfdao = new WorkflowDao(mapper); ActivityDao activitydao = new ActivityDao(mapper); LinkDao linkDao = new LinkDao(mapper); ActivityAuthDao authdao = new ActivityAuthDao(mapper); ApprovalDao approvalDao = new ApprovalDao(mapper); TaskDao taskdao = new TaskDao(mapper); string id = this.value.ID; var activities = activitydao.Query(new ActivityQueryForm { WorkflowID = id }); taskdao.Delete(new TaskQueryForm { WorkflowID = id }); wfdao.Delete(new WorkflowQueryForm { ID = id }); activitydao.Delete(new ActivityQueryForm { WorkflowID = id }); linkDao.Delete(new LinkQueryForm { WorkflowID = id }); approvalDao.Delete(new ApprovalQueryForm { WorkflowID = id }); authdao.Delete(new ActivityAuthQueryForm { WorkflowID = id }); }
/// <summary> /// 从数据库读取流程信息 /// </summary> /// <param name="workflowids"></param> /// <returns></returns> public static List<WorkflowModel> Load(WorkflowQueryForm form) { List<WorkflowModel> models = new List<WorkflowModel>(); if (form == null) return models; #region query data ISqlMapper mapper = MapperHelper.GetMapper(); WorkflowDao wfdao = new WorkflowDao(mapper); ActivityDao activitydao = new ActivityDao(mapper); LinkDao linkDao = new LinkDao(mapper); ActivityAuthDao authdao = new ActivityAuthDao(mapper); ApprovalDao approvalDao = new ApprovalDao(mapper); TaskDao taskdao = new TaskDao(mapper); List<Activity> activityList = new List<Activity>(); List<Link> linkList = new List<Link>(); List<ActivityAuth> authList = new List<ActivityAuth>(); List<Approval> approvalList = new List<Approval>(); List<Task> taskList = new List<Task>(); List<Workflow> workflows = new List<Workflow>(); //先从缓存取值 //var item = cache.GetItem(id); //if (item != null) //{ // model = item.Value as WorkflowModel; // return model; //} workflows = wfdao.Query(form); var workflowids = (from wf in workflows select wf.ID).ToList(); activityList = activitydao.Query(new ActivityQueryForm { WorkflowIDs = workflowids }); linkList = linkDao.Query(new LinkQueryForm { WorkflowIDs = workflowids }); approvalList = approvalDao.Query(new ApprovalQueryForm { WorkflowIDs = workflowids }); authList = authdao.Query(new ActivityAuthQueryForm { WorkflowIDs = workflowids }); taskList = taskdao.Query(new TaskQueryForm { WorkflowIDs = workflowids }); #endregion foreach (var workflow in workflows) { var model = BuildWorkflow(workflow, activityList, linkList, authList, approvalList, taskList); models.Add(model); } return models; }
public int CountLinksForMovie(long movieId) { return(LinkDao.CountForMovie(movieId)); }
public static DataTable getResultMapMatchingDoppler(DataTable gpsRawTable, InsertDatum datum) { if (gpsRawTable.Rows.Count == 0) { return(new DataTable()); } List <DataTable> dt = new List <DataTable>(); if (datum.DriverId == 1)//被験者1用のマップマッチング道路リンクを取得 { int[] id = new int[] { 220 }; DataTable tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "復路,代官山下ルート"; dt.Add(tempTable); dt[0].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 224 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "復路,代官山上ルート"; dt.Add(tempTable); dt[1].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 221 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "往路,小学校上ルート"; dt.Add(tempTable); dt[2].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 225 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "往路,小学校下ルート"; dt.Add(tempTable); dt[3].DefaultView.Sort = "START_LAT, " + "" + "" + "" + "" + "" + "" + "" + "" + "START_LONG"; } else if (datum.DriverId == 17)//マップマッチング道路リンクを取得 { int[] id = new int[] { 328 }; DataTable tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者17復路ルート1"; dt.Add(tempTable); dt[0].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 329 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者17往路ルート1"; dt.Add(tempTable); dt[1].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 330 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者17往路ルート2"; dt.Add(tempTable); dt[2].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 331 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者17往路ルート2"; dt.Add(tempTable); dt[2].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 340 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者17往路ルート3"; dt.Add(tempTable); dt[2].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 341 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者17復路ルート3"; dt.Add(tempTable); dt[2].DefaultView.Sort = "START_LAT, START_LONG"; } else if (datum.DriverId == 28) { int[] id = new int[] { 365 }; DataTable tempTable = LinkDao.GetLinkTableforMM(id); tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者28 往路ルート1"; dt.Add(tempTable); dt[0].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 366 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者28 復路ルート1"; dt.Add(tempTable); dt[1].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 369 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者28 往路ルート2"; dt.Add(tempTable); dt[2].DefaultView.Sort = "START_LAT, START_LONG"; id = new int[] { 370 }; tempTable = LinkDao.GetLinkTableforMM(id); tempTable.TableName = "被験者28 復路ルート2"; dt.Add(tempTable); dt[3].DefaultView.Sort = "START_LAT, START_LONG"; } //TODO マップマッチング処理 double[] sumDist = new double[dt.Count]; //GPS点をマッチングさせるのに移動させた距離の総和 double[] maxDist = new double[dt.Count]; //GPS点をマッチングさせるのに移動させた距離の最大値 DataTable[] mapMatchedGpsTable = DataTableUtil.GetAndroidGpsRawDopplerTableArray(dt.Count); for (int i = 0; i < gpsRawTable.Rows.Count; i++) { for (int n = 0; n < dt.Count; n++) { double tempDist = searchNearestLinkDoppler(dt[n], gpsRawTable.Rows[i], ref mapMatchedGpsTable[n]); sumDist[n] += tempDist; if (tempDist > maxDist[n]) { maxDist[n] = tempDist; } } } int element = getMinElement(sumDist); if (sumDist.Length == 0) { SlackUtil.noMapMatching(datum, gpsRawTable.Rows[0]); return(new DataTable()); } if (sumDist[element] > 0.5 || maxDist[element] > 0.003) { SlackUtil.noMapMatching(datum, gpsRawTable.Rows[0]); return(new DataTable()); } return(mapMatchedGpsTable[element]); }
public List <InitApprovalResultForm> Query(List <string> projectids, List <string> taskids, string currentuserid) { #region init dao List <InitApprovalResultForm> result = new List <InitApprovalResultForm>(); if (projectids == null || projectids.Count == 0) { return(new List <InitApprovalResultForm>()); } ISqlMapper mapper = Common.GetMapperFromSession(); ProjectDao dao = new ProjectDao(mapper); Customer_ProjectDao cpdao = new Customer_ProjectDao(mapper); Customer_AssetDao cadao = new Customer_AssetDao(mapper); Asset_ProjectDao apdao = new Asset_ProjectDao(mapper); WorkflowDao workflowdao = new WorkflowDao(mapper); ActivityDao activitydao = new ActivityDao(mapper); ApprovalDao appvoraldao = new ApprovalDao(mapper); TaskDao taskdao = new TaskDao(mapper); UserInfoDao uidao = new UserInfoDao(mapper); User_RoleDao urdao = new User_RoleDao(mapper); TrackingChangeOwnerDao tcodao = new TrackingChangeOwnerDao(mapper); TrackingMortgageDao tmdao = new TrackingMortgageDao(mapper); LinkDao linkdao = new LinkDao(mapper); Role_Module_ActionDao rmadao = new Role_Module_ActionDao(mapper); ReturnBackConfirmDao rbcdao = new ReturnBackConfirmDao(mapper); CreditReceiverInfoDao cridao = new CreditReceiverInfoDao(mapper); #endregion #region 查询数据 List <Customer_Project> cps = new List <Customer_Project>(); List <Customer_Asset> cas = new List <Customer_Asset>(); List <Asset_Project> aps = new List <Asset_Project>(); List <Activity> activities = new List <Activity>(); List <Approval> approvals = new List <Approval>(); List <Task> tasks = new List <Task>(); List <TrackingChangeOwner> tco = new List <TrackingChangeOwner>(); List <TrackingMortgage> tm = new List <TrackingMortgage>(); List <string> projectidlist = new List <string>(); List <string> workflowids = new List <string>(); List <CreditReceiverInfo> criList = new List <CreditReceiverInfo>(); List <Link> links = new List <Link>(); List <ReturnBackConfirm> returnBackMoneyInfo = new List <ReturnBackConfirm>(); List <Workflow> workflows = null; List <Project> list = null; var rma = rmadao.Query(new Role_Module_ActionQueryForm { }); if (taskids != null && taskids.Count > 0) { tasks = taskdao.Query(new TaskQueryForm { IDs = taskids }); workflowids = (from t in tasks select t.WorkflowID).Distinct().ToList(); workflows = workflowdao.Query(new WorkflowQueryForm { IDs = workflowids }); activities = activitydao.Query(new ActivityQueryForm { WorkflowIDs = workflowids }); approvals = appvoraldao.Query(new ApprovalQueryForm { WorkflowIDs = workflowids }); projectidlist = (from w in workflows select w.ProcessID).ToList(); list = dao.Query(new ProjectQueryForm { IDs = projectidlist }); } else if (projectids != null && projectids.Count > 0) { list = dao.Query(new ProjectQueryForm { IDs = projectids }); projectidlist = (from p in list select p.ID).ToList(); workflows = workflowdao.Query(new WorkflowQueryForm { ProcessIDs = projectidlist }); workflowids = (from w in workflows select w.ID).ToList(); if (workflowids.Count > 0) { activities = activitydao.Query(new ActivityQueryForm { WorkflowIDs = workflowids }); approvals = appvoraldao.Query(new ApprovalQueryForm { WorkflowIDs = workflowids }); tasks = taskdao.Query(new TaskQueryForm { WorkflowIDs = workflowids }); } } else { return(result); } if (projectidlist.Count > 0) { cps = cpdao.Query(new Customer_ProjectQueryForm { ProjectIDs = projectidlist }); cas = cadao.Query(new Customer_AssetQueryForm { ProjectIDs = projectidlist }); aps = apdao.Query(new Asset_ProjectQueryForm { ProjectIDs = projectidlist }); } var users = uidao.Query(new UserInfoQueryForm { }); var userroles = urdao.Query(new User_RoleQueryForm { }); criList = cridao.Query(new CreditReceiverInfoQueryForm { ProjectIDs = projectids }); tco = tcodao.Query(new TrackingChangeOwnerQueryForm { ProjectIDs = projectidlist }); tm = tmdao.Query(new TrackingMortgageQueryForm { ProjectIDs = projectidlist }); returnBackMoneyInfo = rbcdao.Query(new ReturnBackConfirmQueryForm { ProjectIDs = projectidlist }); //从缓存中取得 var customers = TableCacheHelper.GetDataFromCache <Customer>(typeof(CustomerDao)); var assets = TableCacheHelper.GetDataFromCache <Asset>(typeof(AssetDao)); #endregion #region 处理废单权限 //处理废单权限 var hasDisplayDiscard = (from ur in userroles join r in rma on ur.RoleID equals r.RoleID where r.ModuleID == "4" && r.ActionID == "4" && ur.UserID == currentuserid select r).FirstOrDefault(); #endregion foreach (Project project in list) { var data = QueryDetail(project, customers, assets, cps, cas, aps, workflows, activities, approvals, tasks, users, userroles, tco, tm, returnBackMoneyInfo, criList, currentuserid); if (hasDisplayDiscard != null) { data.DisplayDiscard = true; } result.Add(data); } return(result); }
public WorkflowModel StartNew(string creator, string processid, IWorkflowAuthority iauth) { var mapper = MapperHelper.GetMapper(); WorkflowDao workflowdao = new WorkflowDao(mapper); ActivityDao activitydao = new ActivityDao(mapper); LinkDao linkdao = new LinkDao(mapper); ActivityAuthDao aadd = new ActivityAuthDao(mapper); TaskDao taskdao = new TaskDao(mapper); WorkflowModel model = null; Workflow wf = this.value.ConvertTo <Workflow>(); wf.ID = null; wf.Creator = creator; wf.Status = (int)WorkflowProcessStatus.Started; wf.WorkflowDefinitionID = this.value.ID; wf.ProcessID = processid; workflowdao.Add(wf); var activites = this.ActivityDefinitionList; var links = this.LinkDefinitionList; List <Activity> activityEntities = new List <Activity>(); foreach (var a in activites) { Activity activity = a.Value.ConvertTo <Activity>(); activity.Creator = creator; activity.ID = null; activity.WorkflowID = wf.ID; activity.ActivityDefinitionID = a.Value.ID; activity.Title = a.Value.Title; activity.Status = (int)ActivityProcessStatus.Started; List <ActivityAuth> authList = new List <ActivityAuth>(); //如果是开始节点,就设置为已处理 if (this.Root.Equals(a)) { activity.Status = (int)ActivityProcessStatus.Processed; activity.ProcessTime = DateTime.Now; } if (this.Root.Children.Count > 0 && this.Root.Children[0].Equals(a)) { activity.Status = (int)ActivityProcessStatus.Processing; } activitydao.Add(activity); activityEntities.Add(activity); //权限处理 foreach (var ad in a.AuthDefinition) { ActivityAuth auth = ad.ConvertTo <ActivityAuth>(); auth.Creator = creator; auth.WorkflowID = wf.ID; auth.ActivityID = activity.ID; auth.ID = null; auth.ActivityAuthDefinitionID = ad.ID; aadd.Add(auth); authList.Add(auth); } //如果是第二节点,就设置成正在处理 if (this.Root.Children.Count > 0 && this.Root.Children[0].Equals(a)) { ActivityModel activitymodel = new ActivityModel { Value = activity, }; var idlist = iauth.GetUserIDList(authList); var tasklist = activitymodel.GetTask(creator, idlist); foreach (var task in tasklist) { taskdao.Add(task); } } } foreach (var l in links) { Link link = l.Value.ConvertTo <Link>(); link.Creator = creator; link.WorkflowID = wf.ID; link.ID = null; link.LinkDefinitionID = l.Value.ID; var fromactivity = activityEntities.Find(t => t.ActivityDefinitionID == l.Value.FromActivityDefinitionID); var totactivity = activityEntities.Find(t => t.ActivityDefinitionID == l.Value.ToActivityDefinitionID); if (fromactivity != null) { link.FromActivityID = fromactivity.ID; } if (totactivity != null) { link.ToAcivityID = totactivity.ID; } linkdao.Add(link); } model = WorkflowModel.Load(wf.ID); return(model); }
public WorkflowModel StartNew(string creator, string processid, IWorkflowAuthority iauth) { var mapper = MapperHelper.GetMapper(); WorkflowDao workflowdao = new WorkflowDao(mapper); ActivityDao activitydao = new ActivityDao(mapper); LinkDao linkdao = new LinkDao(mapper); ActivityAuthDao aadd = new ActivityAuthDao(mapper); TaskDao taskdao = new TaskDao(mapper); WorkflowModel model = null; Workflow wf = this.value.ConvertTo<Workflow>(); wf.ID = null; wf.Creator = creator; wf.Status = (int)WorkflowProcessStatus.Started; wf.WorkflowDefinitionID = this.value.ID; wf.ProcessID = processid; workflowdao.Add(wf); var activites = this.ActivityDefinitionList; var links = this.LinkDefinitionList; List<Activity> activityEntities = new List<Activity>(); foreach (var a in activites) { Activity activity = a.Value.ConvertTo<Activity>(); activity.Creator = creator; activity.ID = null; activity.WorkflowID = wf.ID; activity.ActivityDefinitionID = a.Value.ID; activity.Title = a.Value.Title; activity.Status = (int)ActivityProcessStatus.Started; List<ActivityAuth> authList = new List<ActivityAuth>(); //如果是开始节点,就设置为已处理 if (this.Root.Equals(a)) { activity.Status = (int)ActivityProcessStatus.Processed; activity.ProcessTime = DateTime.Now; } if (this.Root.Children.Count > 0 && this.Root.Children[0].Equals(a)) { activity.Status = (int)ActivityProcessStatus.Processing; } activitydao.Add(activity); activityEntities.Add(activity); //权限处理 foreach (var ad in a.AuthDefinition) { ActivityAuth auth = ad.ConvertTo<ActivityAuth>(); auth.Creator = creator; auth.WorkflowID = wf.ID; auth.ActivityID = activity.ID; auth.ID = null; auth.ActivityAuthDefinitionID = ad.ID; aadd.Add(auth); authList.Add(auth); } //如果是第二节点,就设置成正在处理 if (this.Root.Children.Count > 0 && this.Root.Children[0].Equals(a)) { ActivityModel activitymodel = new ActivityModel { Value = activity, }; var idlist = iauth.GetUserIDList(authList); var tasklist = activitymodel.GetTask(creator, idlist); foreach (var task in tasklist) { taskdao.Add(task); } } } foreach (var l in links) { Link link = l.Value.ConvertTo<Link>(); link.Creator = creator; link.WorkflowID = wf.ID; link.ID = null; link.LinkDefinitionID = l.Value.ID; var fromactivity = activityEntities.Find(t => t.ActivityDefinitionID == l.Value.FromActivityDefinitionID); var totactivity = activityEntities.Find(t => t.ActivityDefinitionID == l.Value.ToActivityDefinitionID); if (fromactivity != null) { link.FromActivityID = fromactivity.ID; } if (totactivity != null) { link.ToAcivityID = totactivity.ID; } linkdao.Add(link); } model = WorkflowModel.Load(wf.ID); return model; }