Esempio n. 1
0
        public ActionResult SaveLocationOfExposure(FormCollection form)
        {
            long key       = long.Parse(Session["IdfCase"].ToString());
            var  humanCase = (HumanCase)ModelStorage.Get(Session.SessionID, key, null);

            Int64 originalIdfGeoLocation = humanCase.PointGeoLocation.idfGeoLocation;
            var   originalGeoLocation    = (GeoLocation)ModelStorage.Get(Session.SessionID, originalIdfGeoLocation, null);
            Int64 cloneIdfGeoLocation    = originalIdfGeoLocation + 1;
            var   cloneGeoLocation       = (GeoLocation)ModelStorage.Get(Session.SessionID, cloneIdfGeoLocation, null);

            var data = new CompareModel();

            ValidateGeoLocation(originalGeoLocation, cloneGeoLocation, form);

            if (m_Validation != null)
            {
                string errorMessage = Translator.GetErrorMessage(m_Validation);
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
            }
            else
            {
                using (GeoLocation tempGeoLocation = originalGeoLocation.CloneWithSetup())
                {
                    ModifyOriginalGeoLocation(originalGeoLocation, cloneGeoLocation, form);
                    ModelStorage.Remove(Session.SessionID, cloneIdfGeoLocation, null);
                    data = originalGeoLocation.Compare(tempGeoLocation);
                }
            }

            return(new JsonResult {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = data
            });
        }
Esempio n. 2
0
 private void Start()
 {
     if (isTemplate)
     {
         listener.Add <RailNode>(EventType.CREATED, rn => storage.Add(rn));
         listener.Add <RailNode>(EventType.DELETED, rn => storage.Remove(rn));
     }
 }
Esempio n. 3
0
 private void Start()
 {
     if (isTemplate)
     {
         listener.Add <Station>(EventType.CREATED, st => storage.Add(st));
         listener.Add <Station>(EventType.DELETED, st => storage.Remove(st));
     }
 }
Esempio n. 4
0
 private void Start()
 {
     if (isTemplate)
     {
         listener.Add <RailPart>(EventType.CREATED, rp => storage.Add(rp));
         listener.Add <RailPart>(EventType.DELETED, rp => storage.Remove(rp));
     }
     else
     {
         listener.Add <RailPart>(EventType.MODIFIED, this, (_) => SetTransform());
     }
 }
Esempio n. 5
0
 private void Start()
 {
     if (isTemplate)
     {
         listener.Add <RailEdge>(EventType.CREATED, re => storage.Add(re));
         listener.Add <RailEdge>(EventType.DELETED, re => storage.Remove(re));
     }
     else
     {
         listener.Add <RailEdge>(EventType.MODIFIED, this, (_) =>
         {
             listener.Fire(EventType.MODIFIED, ForwardPart);
             listener.Fire(EventType.MODIFIED, BackPart);
         });
     }
 }
Esempio n. 6
0
 public virtual void Remove()
 {
     storage.Remove(this);
     listener.Fire(EventType.DELETED, this);
 }
Esempio n. 7
0
        public ActionResult SaveContactedCasePerson(FormCollection form)
        {
            string errorMessage;
            bool   isDatesValid = DateTimeHelper.TryParseCustomDates(form, out errorMessage);
            var    data         = new CompareModel();

            if (!isDatesValid)
            {
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
                return(new JsonResult {
                    Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            long idfContactedCasePerson = long.Parse(form["idfContactedCasePerson"]);
            var  contactedPerson        = (ContactedCasePerson)ModelStorage.Get(Session.SessionID, idfContactedCasePerson, null);
            var  humanCase = (HumanCase)ModelStorage.Get(Session.SessionID, contactedPerson.idfHumanCase, null);

            m_Validation = null;
            if (contactedPerson.NewObject)
            {
                var tempPerson = contactedPerson.Person.CloneWithSetup();
                contactedPerson.Validation += obj_Validation;
                contactedPerson.ParseFormCollection(form);
                using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
                {
                    ContactedCasePerson.Accessor acc = ContactedCasePerson.Accessor.Instance(null);
                    acc.Validate(manager, contactedPerson, true, true, true);
                    contactedPerson.Validation -= obj_Validation;
                    if (m_Validation == null)
                    {
                        contactedPerson.NewObject = false;
                        contactedPerson.Person    = tempPerson.CopyFrom(manager, contactedPerson.Person);
                        humanCase.ContactedPerson.Add(contactedPerson);
                    }
                }
            }
            else
            {
                contactedPerson.Validation += obj_Validation;
                contactedPerson.ParseFormCollection(form);
                using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
                {
                    ContactedCasePerson.Accessor acc = ContactedCasePerson.Accessor.Instance(null);
                    acc.Validate(manager, contactedPerson, true, true, true);
                    contactedPerson.Validation -= obj_Validation;
                    if (m_Validation == null)
                    {
                        var originalContactedPerson = humanCase.ContactedPerson.Where(c => c.idfContactedCasePerson == idfContactedCasePerson).SingleOrDefault();
                        var tempPerson = contactedPerson.Person.CloneWithSetup();
                        originalContactedPerson.ParseFormCollection(form);
                        originalContactedPerson.Person = tempPerson.CopyFrom(manager, originalContactedPerson.Person);
                    }
                }
            }

            if (m_Validation != null)
            {
                errorMessage = Translator.GetErrorMessage(m_Validation);
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
            }
            else
            {
                ModelStorage.Remove(Session.SessionID, idfContactedCasePerson, null);
            }

            return(new JsonResult {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = data
            });
        }
Esempio n. 8
0
 public void Remove()
 {
     storage.Remove(this);
     listener.Fire <RailLine>(EventType.DELETED, this);
 }
Esempio n. 9
0
        public ActionResult Details(FormCollection form)
        {
            form.AllKeys.ToList().ForEach(k => form[k] = EidssWebHelper.UnescapeHtml(form[k]));
            string errorMessage;
            bool   isDatesValid = DateTimeHelper.TryParseCustomDates(form, out errorMessage);
            var    data         = new CompareModel();

            if (!isDatesValid)
            {
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
                return(new JsonResult {
                    Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }
            bool isNumericValid = NumericHelper.TryParseInteger(form, out errorMessage);

            if (!isNumericValid)
            {
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
                return(new JsonResult {
                    Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            long key     = long.Parse(Session["IdfCase"].ToString());
            var  vetCase = (VetCase)ModelStorage.Get(Session.SessionID, key, null);

            #region Обработка FF
            //TODO:
            #endregion

            m_validation        = null;
            vetCase.Validation += vc_ValidationDetails;
            vetCase.ParseFormCollection(form);
            if (m_validation != null)
            {
                vetCase.Validation -= vc_ValidationDetails;
                errorMessage        = Translator.GetErrorMessage(m_validation);
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
                return(new JsonResult {
                    Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
                });
            }

            using (DbManagerProxy manager = DbManagerFactory.Factory.Create(EidssUserContext.Instance))
            {
                VetCase.Accessor acc = VetCase.Accessor.Instance(null);
                acc.Validate(manager, vetCase, true, true, true);
                if (m_validation == null)
                {
                    acc.Post(manager, vetCase);
                }
            }
            vetCase.Validation -= vc_ValidationDetails;
            if (m_validation != null)
            {
                errorMessage = Translator.GetErrorMessage(m_validation);
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
            }
            else
            {
                ModelStorage.Remove(Session.SessionID, vetCase.idfCase, m_FarmTreeSessionKey);
            }

            return(new JsonResult {
                Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }