Exemplo n.º 1
0
        public string AddComponent(string editorID, long viewStamp, int x, int y)
        {
            try
            {
                AllowAccess();
                SchemeDTO dto = new SchemeDTO();

                if (CheckArguments(editorID, viewStamp, dto))
                {
                    switch (Editor.PointerMode)
                    {
                    case Editor.PointerModes.Create:
                        dto.Success = Editor.CreateComponent(x, y);
                        break;

                    case Editor.PointerModes.Paste:
                        dto.Success = Editor.PasteFromClipboard(x, y);
                        break;
                    }
                }

                return(JsSerializer.Serialize(dto));
            }
            catch (Exception ex)
            {
                AppData.Log.WriteException(ex, Localization.UseRussian ?
                                           "Ошибка при добавлении компонента на схему" :
                                           "Error adding component to the scheme");
                return(JsSerializer.GetErrorJson(ex));
            }
        }
Exemplo n.º 2
0
        public string GetLoadErrors(int viewID, long viewStamp)
        {
            try
            {
                UserRights userRights;
                AppData.CheckLoggedOn(out userRights);

                SchemeView schemeView = GetSchemeView(viewID, userRights);
                SchemeDTO  dto        = new SchemeDTO();
                dto.ViewStamp = schemeView.Stamp;

                if (SchemeUtils.ViewStampsMatched(viewStamp, schemeView.Stamp))
                {
                    dto.Data = schemeView.LoadErrors.ToArray();
                }

                return(JsSerializer.Serialize(dto));
            }
            catch (Exception ex)
            {
                AppData.Log.WriteException(ex, Localization.UseRussian ?
                                           "Ошибка при получении ошибок при загрузке схемы с ид.={0}" :
                                           "Error getting loading errors of the scheme with ID={0}", viewID);
                return(GetErrorDtoJs(ex));
            }
        }
Exemplo n.º 3
0
        public string GetLoadErrors(string editorID, long viewStamp)
        {
            try
            {
                AllowAccess();
                SchemeDTO dto = new SchemeDTO();

                if (CheckArguments(editorID, viewStamp, dto))
                {
                    lock (Editor.SchemeView.SyncRoot)
                    {
                        dto.Data = Editor.SchemeView.LoadErrors.ToArray();
                    }
                }

                return(JsSerializer.Serialize(dto));
            }
            catch (Exception ex)
            {
                AppData.Log.WriteException(ex, Localization.UseRussian ?
                                           "Ошибка при получении ошибок при загрузке схемы" :
                                           "Error getting loading errors of the scheme");
                return(JsSerializer.GetErrorJson(ex));
            }
        }
Exemplo n.º 4
0
        public ActionResult EditScheme(int schemeId)
        {
            SchemeDTO dto = QuestionnaireAdminBusinessManager.Instance.LoadScheme(schemeId);

            if (dto != null)
            {
                return(View(dto));
            }
            else
            {
                throw new HttpException("Could not load scheme id " + schemeId.ToString());
            }
        }
Exemplo n.º 5
0
        public string MoveResize(string editorID, long viewStamp, int dx, int dy, int w, int h)
        {
            try
            {
                AllowAccess();
                SchemeDTO dto = new SchemeDTO();

                if (CheckArguments(editorID, viewStamp, dto))
                {
                    Editor.MoveResizeSelected(dx, dy, w, h, false);
                }

                return(JsSerializer.Serialize(dto));
            }
            catch (Exception ex)
            {
                AppData.Log.WriteException(ex, Localization.UseRussian ?
                                           "Ошибка при перемещении и изменении размера выбранных компонентов схемы" :
                                           "Error moving and resizing selected scheme components");
                return(JsSerializer.GetErrorJson(ex));
            }
        }
Exemplo n.º 6
0
 public ActionResult EditScheme(SchemeDTO dto, int schemeId)
 {
     if (ModelState.IsValid)
     {
         SchemeDTO existingSchemeDTO = QuestionnaireAdminBusinessManager.Instance.LoadScheme(dto.Code);
         if (existingSchemeDTO != null && existingSchemeDTO.SchemeID != dto.SchemeID)
         {
             //duplicate scheme code
             ModelState.AddModelError("Code", "Code already in use, please enter a different code");
             return(View(dto));
         }
         else
         {
             QuestionnaireAdminBusinessManager.Instance.SaveScheme(dto);
             return(RedirectToAction("Scheme", new { schemeId = schemeId }));
         }
     }
     else
     {
         return(View(dto));
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Проверить аргументы метода сервиса
        /// </summary>
        private bool CheckArguments(string editorID, long viewStamp, SchemeDTO dto)
        {
            if (editorID == Editor.EditorID)
            {
                SchemeView schemeView = Editor.SchemeView;

                if (schemeView != null)
                {
                    dto.ViewStamp = schemeView.Stamp;

                    if (SchemeUtils.ViewStampsMatched(viewStamp, schemeView.Stamp))
                    {
                        return(true);
                    }
                }
            }
            else
            {
                dto.EditorUnknown = true;
            }

            return(false);
        }
Exemplo n.º 8
0
        public string FormAction(string editorID, long viewStamp, string action)
        {
            try
            {
                AllowAccess();
                SchemeDTO dto = new SchemeDTO();

                if (CheckArguments(editorID, viewStamp, dto) &&
                    Enum.TryParse(action, true, out FormAction formAction))
                {
                    AppData.MainForm.PerformAction(formAction);
                }

                return(JsSerializer.Serialize(dto));
            }
            catch (Exception ex)
            {
                AppData.Log.WriteException(ex, Localization.UseRussian ?
                                           "Ошибка при выполнении действия главной формы" :
                                           "Error performing action of the main form");
                return(JsSerializer.GetErrorJson(ex));
            }
        }
Exemplo n.º 9
0
        public string ChangeSelection(string editorID, long viewStamp, string action, int componentID)
        {
            try
            {
                AllowAccess();
                SchemeDTO dto = new SchemeDTO();

                if (CheckArguments(editorID, viewStamp, dto) &&
                    Enum.TryParse(action, true, out SelectAction selectAction))
                {
                    Editor.PerformSelectAction(selectAction, componentID);
                }

                return(JsSerializer.Serialize(dto));
            }
            catch (Exception ex)
            {
                AppData.Log.WriteException(ex, Localization.UseRussian ?
                                           "Ошибка при изменении выбора компонентов схемы" :
                                           "Error changing scheme component selection");
                return(JsSerializer.GetErrorJson(ex));
            }
        }
Exemplo n.º 10
0
 public ActionResult DeleteScheme(int schemeId, SchemeDTO dto)
 {
     QuestionnaireAdminBusinessManager.Instance.DeleteScheme(schemeId);
     return(RedirectToAction("SchemeDeleted"));
 }
Exemplo n.º 11
0
 public SchemeDTO SaveScheme(SchemeDTO dto)
 {
     return(QuestionnaireAdminDataManager.Instance.SaveScheme(dto));
 }