Пример #1
0
    private string GetAttachmentImageDirectoryCommandHandler() {
      string position = GetCommandParameter("position", true);
      string folderName = GetCommandParameter("name", false, String.Empty);

      int currentPosition = int.Parse(GetCommandParameter("currentPosition", true));

      int recordingId = int.Parse(GetCommandParameter("recordingId", false, "0"));

      Recording recording = Recording.Parse(recordingId);
      if (currentPosition == -1) {
        currentPosition = 0;
      }
      RecordingAttachmentFolder folder = recording.GetAttachementFolder(folderName);

      if (!EmpiriaString.IsInteger(position)) {
        switch (position) {
          case "first":
            return folder.GetImageURL(0);
          case "previous":
            return folder.GetImageURL(Math.Max(currentPosition - 1, 0));
          case "next":
            return folder.GetImageURL(Math.Min(currentPosition + 1, folder.FilesCount - 1));
          case "last":
            return folder.GetImageURL(folder.FilesCount - 1);
          case "refresh":
            return folder.GetImageURL(currentPosition);
          default:
            return folder.GetImageURL(currentPosition);
        }
      } else {
        return folder.GetImageURL(int.Parse(position));
      }
    }
 private void MoveToRecording() {
   string position = GetCommandParameter("goto");
   Recording newRecording = null;
   switch (position) {
     case "First":
       newRecording = recordingBook.GetFirstRecording();
       break;
     case "Previous":
       newRecording = recordingBook.GetPreviousRecording(this.recording);
       break;
     case "Next":
       newRecording = recordingBook.GetNextRecording(this.recording);
       break;
     case "Last":
       newRecording = recordingBook.GetLastRecording();
       break;
     default:
       if (EmpiriaString.IsInteger(position)) {
         newRecording = recordingBook.GetRecording(int.Parse(position));
       }
       break;
   }
   if (newRecording != null) {
     this.recording = newRecording;
   }
 }
Пример #3
0
 private ProjectItem ParseActivityWithUID(string activityUID)
 {
     if (EmpiriaString.IsInteger(activityUID))
     {
         return(ProjectItem.Parse(int.Parse(activityUID)));
     }
     else
     {
         return(ProjectItem.Parse(activityUID));
     }
 }
Пример #4
0
        private StepDataHolder MapToStepDataHolder(StepType stepType,
                                                   ProjectItem projectItem,
                                                   ActivityModel formerModel)
        {
            var data = new StepDataHolder();

            data.Accessibility = "Private";
            data.DrivenMode    = "Manual";

            data.EstimatedDuration = ConvertEstimatedDuration(formerModel);

            data.ExecutionContext = ConvertExecutionContext(projectItem);

            data.ExtensionData = ConvertExtensionData(formerModel);

            data.IsOptional = !formerModel.IsMandatory;

            data.Notes = projectItem.Notes;

            data.OldProjectObjectId = projectItem.Id;

            if (formerModel.DueOnControllerId > 0 && EmpiriaString.IsInteger(formerModel.DueOnTerm))
            {
                StepRelation relation = CreateDependencyAsStepRelation(projectItem, formerModel);

                var dueOn = Activity.Parse(formerModel.DueOnControllerId);
                data.DataModels = $"{formerModel.DueOnTerm} {formerModel.DueOnTermUnit} {formerModel.DueOnCondition} " +
                                  $"{dueOn.Name} ({dueOn.Template.ActivityType}) [{formerModel.DueOnControllerId}]";
            }

            if (formerModel.IsPeriodic)
            {
                data.PeriodicityRule = formerModel.PeriodicRule.ToJson();
            }

            data.ProcedureEntityId = formerModel.EntityId;
            data.ProcedureId       = formerModel.ProcedureId;

            data.StepKind = formerModel.ActivityType;

            data.StepName     = projectItem.Name.Trim();
            data.StepPosition = 0;
            data.StepType     = stepType;

            data.Tags   = projectItem.Tag;
            data.Themes = projectItem.Theme;

            return(data);
        }
Пример #5
0
 protected string GetMultiselectListItems(System.Web.UI.HtmlControls.HtmlSelect control, string controlName) {
   const string row = "<tr><td><input id='{CONTROL.ID}' name='{CONTROL.NAME}' type='checkbox' value='{ITEM.VALUE}' /></td>" +
                      "<td id='{ITEM.NAME.ID}' style='white-space:normal;width:98%'>{ITEM.NAME}</td></tr>";
   string html = String.Empty;
   foreach (ListItem item in control.Items) {
     if (EmpiriaString.IsInteger(item.Value) && (int.Parse(item.Value) > 0)) {
       string temp = row.Replace("{ITEM.VALUE}", item.Value);
       temp = temp.Replace("{ITEM.NAME}", item.Text);
       temp = temp.Replace("{ITEM.NAME.ID}", controlName + "_text_" + item.Value);
       temp = temp.Replace("{CONTROL.ID}", controlName + "_" + item.Value);
       temp = temp.Replace("{CONTROL.NAME}", controlName);
       html += temp;
     }
   }
   return html;
 }
Пример #6
0
        private Duration ConvertEstimatedDuration(ActivityModel formerModel)
        {
            if (formerModel.Duration.Length != 0 && EmpiriaString.IsInteger(formerModel.Duration) &&
                EmpiriaString.ToInteger(formerModel.Duration) > 0 &&
                formerModel.DurationUnit.Length != 0)
            {
                string unit = formerModel.DurationUnit == "Undefined" || formerModel.DurationUnit == "NA" ?
                              "BusinessDays" : formerModel.DurationUnit;

                return(Duration.Parse($"{formerModel.Duration} {unit}"));
            }
            else
            {
                return(Duration.Empty);
            }
        }
Пример #7
0
    private string GetDirectoryImageUrlCommandHandler() {
      bool attachment = bool.Parse(GetCommandParameter("attachment", false, "false"));

      if (attachment) {
        return GetAttachmentImageDirectoryCommandHandler();
      }

      string position = GetCommandParameter("position", true);
      int currentPosition = int.Parse(GetCommandParameter("currentPosition", true));

      int recordingId = int.Parse(GetCommandParameter("recordingId", false, "0"));
      RecordBookDirectory directory = null;

      if (recordingId == 0) {
        int directoryId = int.Parse(GetCommandParameter("directoryId", true));
        directory = RecordBookDirectory.Parse(directoryId);
      } else {
        Recording recording = Recording.Parse(recordingId);
        if (currentPosition == -1) {
          currentPosition = recording.StartImageIndex - 1;
        }
        directory = recording.RecordingBook.ImagingFilesFolder;
      }

      if (!EmpiriaString.IsInteger(position)) {
        switch (position) {
          case "first":
            return directory.GetImageURL(0);
          case "previous":
            return directory.GetImageURL(Math.Max(currentPosition - 1, 0));
          case "next":
            return directory.GetImageURL(Math.Min(currentPosition + 1, directory.FilesCount - 1));
          case "last":
            return directory.GetImageURL(directory.FilesCount - 1);
          case "refresh":
            return directory.GetImageURL(currentPosition);
          default:
            return directory.GetImageURL(currentPosition);
        }
      } else {
        return directory.GetImageURL(int.Parse(position));
      }
    }
Пример #8
0
        public CollectionModel GetTasks(string activityUID)
        {
            try {
                ProjectItem activity = ParseActivityWithUID(activityUID);

                if (EmpiriaString.IsInteger(activityUID))
                {
                    activity = ProjectItem.Parse(int.Parse(activityUID));
                }
                else
                {
                    activity = ProjectItem.Parse(activityUID);
                }

                return(new CollectionModel(this.Request, activity.Tasks.ToResponse(),
                                           typeof(Task).FullName));
            } catch (Exception e) {
                throw base.CreateHttpException(e);
            }
        }
Пример #9
0
        public SingleObjectModel GetProjectActivity(string activityUIDOrId)
        {
            try {
                Activity projectItem;

                if (EmpiriaString.IsInteger(activityUIDOrId))
                {
                    projectItem = Activity.Parse(int.Parse(activityUIDOrId));
                }
                else
                {
                    projectItem = Activity.Parse(activityUIDOrId);
                }

                return(new SingleObjectModel(this.Request, projectItem.ToResponse(),
                                             typeof(ProjectItem).FullName));
            } catch (Exception e) {
                throw base.CreateHttpException(e);
            }
        }