예제 #1
0
        public ActionResult SetSelectedFarm(string root, string selectedId)
        {
            long key     = long.Parse(root);
            long rootKey = (long)((IObject)ModelStorage.GetRoot(Session.SessionID, key, null)).Key;
            var  vetCase = ModelStorage.Get(Session.SessionID, rootKey, null) as VetCase;

            using (DbManagerProxy manager = DbManagerFactory.Factory.Create(EidssUserContext.Instance))
            {
                var  cloneVetCase = (VetCase)vetCase.CloneWithSetup(manager, true);
                long idfFarm      = string.IsNullOrEmpty(selectedId) ? 0 : long.Parse(selectedId);
                if (idfFarm == 0)
                {
                    var accessor = FarmPanel.Accessor.Instance(null);
                    vetCase.Farm = accessor.CreateByCase(manager, vetCase, vetCase);
                }
                else
                {
                    vetCase.Farm.idfRootFarm = idfFarm;
                }
                CompareModel data = vetCase.Compare(cloneVetCase);
                return(new JsonResult {
                    JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = data
                });
            }
        }
예제 #2
0
        public ActionResult SectionTemplateTableNodeRender(string idfsSection, long key, string ffpresenterId)
        {
            var ff       = ModelStorage.Get(Session.SessionID, key, ffpresenterId) as FFPresenterModel;
            var flexNode = ff != null?ff.TemplateFlexNode.FindChildNodeSection(Convert.ToInt64(idfsSection)) : null;

            return(PartialView("SectionTemplateTableRender", flexNode));
        }
예제 #3
0
        public ActionResult Notification(long id, bool getFromSession = true)
        {
            HumanCase.Accessor humanCaseAccessor = HumanCase.Accessor.Instance(null);
            ViewBag.CanUpdate = humanCaseAccessor.CanUpdate;
            if (getFromSession)
            {
                var humanCase = (HumanCase)ModelStorage.Get(Session.SessionID, id, null);
                Session["IdfCase"] = humanCase.idfCase;
                return(View(humanCase));
            }

            using (DbManagerProxy manager = DbManagerFactory.Factory.Create(EidssUserContext.Instance))
            {
                var acc       = HumanCase.Accessor.Instance(null);
                var humanCase = id.Equals(0) ? acc.CreateNewT(manager, null) : acc.SelectByKey(manager, id); //TODO extender helper для проверки
                if (id.Equals(0))
                {
                    humanCase.datNotificationDate         = humanCase.datEnteredDate;
                    humanCase.RegistrationAddress.Country = null;
                }
                ModelStorage.Put(Session.SessionID, humanCase.idfCase, humanCase.idfCase, null, humanCase);
                ModelStorage.Put(Session.SessionID, humanCase.idfCase, humanCase.Patient.idfHuman, null, humanCase.Patient);
                Session["IdfCase"] = humanCase.idfCase;

                return(View(humanCase));
            }
        }
예제 #4
0
        public ActionResult ContactDetails(long rootKey, long contactedCasePersonId, bool getFromSession = true)
        {
            HumanCase.Accessor humanCaseAccessor = HumanCase.Accessor.Instance(null);
            ViewBag.CanUpdate = humanCaseAccessor.CanUpdate;

            ViewBag.RootKey = rootKey;

            if (getFromSession)
            {
                var contactedCasePerson =
                    (ContactedCasePerson)ModelStorage.Get(Session.SessionID, contactedCasePersonId, null);
                return(View(contactedCasePerson));
            }

            var humanCase = (HumanCase)ModelStorage.GetRoot(Session.SessionID, rootKey, null);
            EditableList <ContactedCasePerson> list = humanCase.ContactedPerson;
            var root = (long)((HumanCase)ModelStorage.GetRoot(Session.SessionID, rootKey, null)).Key;
            ContactedCasePerson item;

            if (contactedCasePersonId == 0)
            {
                using (DbManagerProxy manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
                {
                    var accessor = ContactedCasePerson.Accessor.Instance(null);
                    item           = accessor.Create(manager, humanCase, rootKey);
                    item.NewObject = true;
                    ModelStorage.Put(Session.SessionID, root, item.idfContactedCasePerson, null, item);
                    return(View(item));
                }
            }

            item = list.SingleOrDefault(c => c.idfContactedCasePerson == contactedCasePersonId);
            ModelStorage.Put(Session.SessionID, root, item.idfContactedCasePerson, null, item);
            return(View(item));
        }
예제 #5
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
            });
        }
예제 #6
0
        public ActionResult Investigation(long id)
        {
            HumanCase.Accessor humanCaseAccessor = HumanCase.Accessor.Instance(null);
            ViewBag.CanUpdate = humanCaseAccessor.CanUpdate;
            var humanCase = (HumanCase)ModelStorage.Get(Session.SessionID, id, null);

            Session["IdfCase"] = humanCase.idfCase;
            return(View(humanCase));
        }
예제 #7
0
        public ActionResult Details(FormCollection form)
        {
            string errorMessage;

            form.AllKeys.ToList().ForEach(k => form[k] = EidssWebHelper.UnescapeHtml(form[k]));
            bool isDatesValid = DateTimeHelper.TryParseCustomDates(form, out errorMessage) && DateTimeHelper.TryParseMobileSafariDates(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 key       = long.Parse(Session["IdfCase"].ToString());
            var  humanCase = (HumanCase)ModelStorage.Get(Session.SessionID, key, null);

            var cloneHumanCase = (HumanCase)humanCase.Clone();

            m_Validation          = null;
            humanCase.Validation += hc_ValidationDetails;
            humanCase.ParseFormCollection(form);
            if (m_Validation != null)
            {
                humanCase.Validation -= hc_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))
            {
                HumanCase.Accessor acc = HumanCase.Accessor.Instance(null);
                acc.Validate(manager, humanCase, true, true, true);
                if (m_Validation == null)
                {
                    acc.Post(manager, humanCase);
                }
            }
            humanCase.Validation -= hc_ValidationDetails;
            if (m_Validation != null)
            {
                errorMessage = Translator.GetErrorMessage(m_Validation);
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
            }
            else
            {
                data = humanCase.Compare(cloneHumanCase);
            }
            return(new JsonResult {
                Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
예제 #8
0
        public ActionResult SelectPostCode(long idfGeoLocation, long idfsSettlement)
        {
            var address = (Address)ModelStorage.Get(Session.SessionID, idfGeoLocation, null);

            address.Settlement = address.SettlementLookup.Where(x => x.idfsSettlement == idfsSettlement).FirstOrDefault();
            return(new JsonResult {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new SelectList(address.PostCodeLookup, "strPostCode", "strPostCode")
            });
        }
예제 #9
0
        public ActionResult SelectRayon(long idfGeoLocation, long idfsRegion)
        {
            var address = (Address)ModelStorage.Get(Session.SessionID, idfGeoLocation, null);

            address.Region = address.RegionLookup.Where(x => x.idfsRegion == idfsRegion).FirstOrDefault();
            return(new JsonResult {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new SelectList(address.RayonLookup, "idfsRayon", "strRayonName")
            });
        }
예제 #10
0
        public ActionResult SelectSettlement(long idfGeoLocation, long idfsRayon)
        {
            var geoLocation = (GeoLocation)ModelStorage.Get(Session.SessionID, idfGeoLocation, null);

            geoLocation.Rayon = geoLocation.RayonLookup.Where(x => x.idfsRayon == idfsRayon).FirstOrDefault();
            return(new JsonResult {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = new SelectList(geoLocation.SettlementLookup, "idfsSettlement", "strSettlementName")
            });
        }
예제 #11
0
        public ActionResult ContactList(long id)
        {
            HumanCase.Accessor humanCaseAccessor = HumanCase.Accessor.Instance(null);
            ViewBag.CanUpdate = humanCaseAccessor.CanUpdate;
            var humanCase = (HumanCase)ModelStorage.Get(Session.SessionID, id, null);

            ViewBag.IsHiddenPersonalData = humanCase.IsHiddenPersonalData("ContactedPersonList");
            Session["IdfCase"]           = humanCase.idfCase;
            return(View(humanCase));
        }
예제 #12
0
        public ActionResult FarmDetails(long id)
        {
            VetCase.Accessor vetCaseAccessor = VetCase.Accessor.Instance(null);
            ViewBag.CanUpdate = vetCaseAccessor.CanUpdate;
            var vetCase = (VetCase)ModelStorage.Get(Session.SessionID, id, null);

            AddTitleData(vetCase._HACode);
            Session["IdfCase"] = vetCase.idfCase;
            return(View(vetCase));
        }
예제 #13
0
        public ActionResult CopyTableRow(string idfsSection, long idfRow, long key, string ffpresenterId)
        {
            var ff = ModelStorage.Get(Session.SessionID, key, ffpresenterId) as FFPresenterModel;

            if ((ff != null) && (idfsSection.Length > 0))
            {
                ff.CopyRow(Convert.ToInt64(idfsSection), idfRow);
            }
            return(new JsonResult {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
예제 #14
0
        public ActionResult PatientsList(long rootKey, long contactedCasePersonId)
        {
            ViewBag.IdfCase = rootKey;
            ViewBag.ContactedCasePersonId = contactedCasePersonId;
            var contactedPerson             = (ContactedCasePerson)ModelStorage.Get(Session.SessionID, contactedCasePersonId, null);
            List <PatientListItem> patients = GetPatientsList(contactedPerson.Person);

            ViewBag.ItemsCount = patients == null ? 0 : patients.Count;
            List <PatientListItem> resultList = patients == null ? patients : patients.Take(100).ToList();

            return(View(resultList));
        }
예제 #15
0
        public ActionResult RemoveTableRow(string idfsSection, long idfRow, long key, string ffpresenterId)
        {
            var ff = ModelStorage.Get(Session.SessionID, key, ffpresenterId) as FFPresenterModel;

            if (ff != null)
            {
                ff.RemoveRow(idfRow);
            }
            return(new JsonResult {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
예제 #16
0
        public ActionResult FarmsList(long rootKey, long farmId)
        {
            ViewBag.IdfCase = rootKey;
            ViewBag.FarmId  = farmId;
            var farmPanel             = (FarmPanel)ModelStorage.Get(Session.SessionID, farmId, null);
            List <FarmListItem> farms = GetFarmsList(farmPanel);

            ViewBag.ItemsCount = farms == null ? 0 : farms.Count;
            List <FarmListItem> resultList = farms == null ? farms : farms.Take(100).ToList();

            return(View(resultList));
        }
예제 #17
0
        public ActionResult LocationDetails(long rootKey)
        {
            HumanCase.Accessor humanCaseAccessor = HumanCase.Accessor.Instance(null);
            ViewBag.CanUpdate = humanCaseAccessor.CanUpdate;
            ViewBag.RootKey   = rootKey;
            var         humanCase        = (HumanCase)ModelStorage.Get(Session.SessionID, rootKey, null);
            GeoLocation cloneGeoLocation = GetCloneOfOriginalGeoLocation(humanCase);

            cloneGeoLocation.idfGeoLocation = cloneGeoLocation.idfGeoLocation + 1;
            ModelStorage.Put(Session.SessionID, rootKey, cloneGeoLocation.idfGeoLocation, null, cloneGeoLocation);
            return(PartialView(cloneGeoLocation));
        }
예제 #18
0
        private void SetOrganizationInRootObject(long organizationId)
        {
            var    rootId = (Int64)Session["RootId"];
            var    root   = (IObject)ModelStorage.Get(Session.SessionID, rootId, null);
            string idfsOrganizationPropertyName = Session["IdfsOrganizationPropertyName"].ToString();

            root.SetValue(idfsOrganizationPropertyName, organizationId.ToString());
            string strOrganizationPropertyName        = Session["StrOrganizationPropertyName"].ToString();
            List <OrganizationListItem> organizations = GetOrganizationsList();
            string organizationName = organizations.Where(x => x.idfInstitution == organizationId).FirstOrDefault().name;

            root.SetValue(strOrganizationPropertyName, organizationName);
        }
예제 #19
0
        public ActionResult RemoveSpecies(long rootKey, long speciesId)
        {
            var         vetCase = (VetCase)ModelStorage.Get(Session.SessionID, rootKey, null);
            VetFarmTree item    = vetCase.Farm.FarmTree.Where(x => x.idfParty == speciesId).SingleOrDefault();

            if (item != null)
            {
                vetCase.Farm.FarmTree.Remove(item);
            }
            return(new JsonResult {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = null
            });
        }
예제 #20
0
        public ActionResult ShowFlexibleForm(long root, long key, long ffpresenterId, bool canUpdate = true)
        {
            var ff = ModelStorage.Get(Session.SessionID, key, ffpresenterId.ToString()) as FFPresenterModel;

            if ((ff != null) && (ff.CurrentTemplate != null))
            {
                ViewBag.FFKey         = key;
                ViewBag.FFpresenterId = ffpresenterId;
                ViewBag.CanUpdate     = canUpdate;
                return(PartialView("ShowFlexibleForm", ff));
            }
            return(PartialView("Empty"));
        }
예제 #21
0
        public ActionResult EditTableRow(string idfsSection, bool isNew, long idfRow, long key, string ffpresenterId)
        {
            FlexNode sectionNode = null;
            var      ff          = ModelStorage.Get(Session.SessionID, key, ffpresenterId) as FFPresenterModel;

            if ((ff != null) && (ff.CurrentTemplate != null) && (idfsSection.Length > 0) &&
                (ff.CurrentObservation.HasValue))
            {
                //проходим по всем столбцам-параметрами создаём фейковые ячейки данных
                //(пустые, удалятся при сохранении, если не будут введены данные)
                //отыскиваем нод для табличной секции
                sectionNode = ff.TemplateFlexNode.FindChildNodeSection(Convert.ToInt64(idfsSection));

                if (isNew)
                {
                    var idParameters = sectionNode.GetIDParametersForSection();
                    var numRow       = sectionNode.GetNumForNewRow(ff.ActivityParameters);

                    using (var manager = DbManagerFactory.Factory.Create(ModelUserContext.Instance))
                    {
                        var idfRowNew = (new GetNewIDExtender <ActivityParameter>()).GetScalar(manager, null);
                        foreach (var parameter in ff.CurrentTemplate.ParameterTemplatesLookup)
                        {
                            if (!idParameters.Contains(parameter.idfsParameter))
                            {
                                continue;
                            }
                            ff.ActivityParameters.SetActivityParameterValue(
                                ff.CurrentTemplate
                                , ff.CurrentObservation.Value
                                , parameter.idfsParameter
                                , idfRowNew
                                , numRow
                                , DBNull.Value
                                , String.Empty);
                        }
                        sectionNode.idfRow = ViewBag.IdfRow = idfRowNew;
                    }
                }
                else
                {
                    sectionNode.idfRow = ViewBag.IdfRow = idfRow;
                }
            }
            ViewBag.IsNew         = isNew ? 1 : 0;
            ViewBag.IdfsSection   = idfsSection;
            ViewBag.FFKey         = key;
            ViewBag.FFPresenterId = ffpresenterId;
            ViewBag.UrlForReturn  = Session["ReturnUrl"];
            return(View("SectionTemplateTableEditRender", sectionNode));
        }
예제 #22
0
        public ActionResult EpidemiologicalInformation(long root)
        {
            var vc = ModelStorage.Get(Session.SessionID, root, null) as VetCase;

            if (vc.Farm.idfsFormTemplate.HasValue && vc.Farm.FFPresenterEpi != null)
            {
                vc.Farm.FFPresenterEpi.ReadOnly = vc.ReadOnly || vc.IsClosed;
            }
            VetCase.Accessor vetCaseAccessor = VetCase.Accessor.Instance(null);
            ViewBag.CanUpdate    = vetCaseAccessor.CanUpdate;
            ViewBag.RootKey      = vc.idfCase;
            Session["ReturnUrl"] = Url.Action("EpidemiologicalInformation", "Farm", new { root = vc.idfCase });
            return(PartialView(vc.Farm));
        }
예제 #23
0
        public ActionResult ClinicalSigns(long id)
        {
            HumanCase.Accessor humanCaseAccessor = HumanCase.Accessor.Instance(null);
            ViewBag.CanUpdate = humanCaseAccessor.CanUpdate;
            var humanCase = (HumanCase)ModelStorage.Get(Session.SessionID, id, null);

            Session["IdfCase"]   = humanCase.idfCase;
            Session["ReturnUrl"] = Url.Action("ClinicalSigns", "HumanCase", new { id = humanCase.idfCase.ToString() });
            if (humanCase.FFPresenterCs.CurrentObservation.HasValue)
            {
                humanCase.FFPresenterCs.ReadOnly = humanCaseAccessor.IsReadOnlyForEdit;
                ModelStorage.Put(Session.SessionID, humanCase.idfCase, humanCase.idfCase,
                                 humanCase.FFPresenterCs.CurrentObservation.Value.ToString(), humanCase.FFPresenterCs);
            }
            return(View(humanCase));
        }
예제 #24
0
        public ActionResult StoreCase(FormCollection form)
        {
            var key = Int64.Parse(Session["IdfCase"].ToString());

            form.AllKeys.ToList().ForEach(k => form[k] = EidssWebHelper.UnescapeHtml(form[k]));
            var    vetCase = (VetCase)ModelStorage.Get(Session.SessionID, key, null);
            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
                });
            }

            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
                });
            }

            return(new JsonResult {
                Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
예제 #25
0
        private List <VetFarmTree> PrepareSpeciesForCase(long caseId)
        {
            var vetCase = (VetCase)ModelStorage.Get(Session.SessionID, caseId, null);

            EditableList <VetFarmTree> farmTree = ModelStorage.Get(Session.SessionID, caseId, m_FarmTreeSessionKey) as EditableList <VetFarmTree>;

            if (farmTree == null && vetCase.Farm.FarmTree != null)
            {
                ModelStorage.Put(Session.SessionID, caseId, caseId, m_FarmTreeSessionKey, vetCase.Farm.FarmTree);
                farmTree = vetCase.Farm.FarmTree;
            }

            AddTitleData(vetCase._HACode);
            Session["IdfCase"] = vetCase.idfCase;
            List <VetFarmTree> species = GetSpeciesForFarmTree(farmTree);

            return(species);
        }
예제 #26
0
        private void SetButtonsReadOnlyInViewBag(long objectId, string idfsOrganizationPropertyName, string strOrganizationPropertyName)
        {
            var rootObject = (IObject)ModelStorage.Get(Session.SessionID, objectId, null);

            IObjectPermissions permission = rootObject.GetPermissions();
            bool isRootReadOnly           = permission == null ? false : permission.IsReadOnlyForEdit;
            bool isControlReadOnly        = rootObject.IsReadOnly(idfsOrganizationPropertyName) ||
                                            rootObject.IsHiddenPersonalData(strOrganizationPropertyName) || isRootReadOnly;

            ViewBag.IsSearchButtonReadOnly = isControlReadOnly;

            object organization   = rootObject.GetValue(idfsOrganizationPropertyName);
            Int64  organizationId = 0;

            if (organization != null)
            {
                Int64.TryParse(organization.ToString(), out organizationId);
            }
            ViewBag.IsClianButtonReadOnly = isControlReadOnly || organizationId == 0;
        }
예제 #27
0
        public ActionResult StoreContactDetails(FormCollection form)
        {
            var    key = Int64.Parse(form["idfContactedCasePerson"]);
            var    contactedCasePerson = (ContactedCasePerson)ModelStorage.Get(Session.SessionID, key, null);
            string errorMessage;
            bool   isDatesValid = DateTimeHelper.TryParseCustomDates(form, out errorMessage);
            var    data         = new CompareModel();

            if (!isDatesValid)
            {
                data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
            }
            else
            {
                contactedCasePerson.ParseFormCollection(form);
            }
            return(new JsonResult {
                Data = data, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
예제 #28
0
        public ActionResult ClianOrganizationPicker(string objectId, string idfsOrganizationPropertyName, string strOrganizationPropertyName)
        {
            long         key        = long.Parse(objectId);
            var          rootObject = (IObject)ModelStorage.Get(Session.SessionID, key, null);
            CompareModel data;

            using (DbManagerProxy manager = DbManagerFactory.Factory.Create(EidssUserContext.Instance))
            {
                using (IObject cloneObject = rootObject.CloneWithSetup(manager, true))
                {
                    rootObject.SetValue(idfsOrganizationPropertyName, null);
                    string organizationName = string.Empty;
                    rootObject.SetValue(strOrganizationPropertyName, organizationName);
                    data = rootObject.Compare(cloneObject);
                }
            }
            return(new JsonResult {
                Data = data ?? new CompareModel(), JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
예제 #29
0
        public ActionResult SetValue(string key, string value)
        {
            CompareModel data = null;

            string[] keyparts = key.Split('_');
            if (keyparts.Length == 3)
            {
                IObject obj = ModelStorage.Get(Session.SessionID, long.Parse(keyparts[1]), null) as IObject;
                if (obj != null)
                {
                    string name = keyparts[2];
                    value = value == "null" ? null : value;
                    object oldvalue    = obj.GetValue(name);
                    string stroldvalue = oldvalue == null ? null : oldvalue.ToString();
                    if (stroldvalue != value)
                    {
                        ICloneable cloneable = obj as ICloneable;
                        IObject    clone     = cloneable.Clone() as IObject;
                        obj.Validation += obj_Validation;
                        obj.SetValue(name, value);
                        obj.Validation -= obj_Validation;
                        data            = obj.Compare(clone);
                        if (m_validation != null)
                        {
                            object val    = obj.GetValue(name);
                            string type   = obj.GetType(name);
                            string valstr = val == null ? "" : val.ToString();
                            data.Add(name, key, type, valstr, obj.IsReadOnly(name), obj.IsInvisible(name), obj.IsRequired(name));
                            data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage",
                                     string.Format(Translator.GetMessageString(m_validation.MessageId), m_validation.PropertyName),
                                     false, false, false);
                        }
                    }
                }
            }
            var json = new JsonResult {
                Data = data ?? new CompareModel(), JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            return(json);
        }
예제 #30
0
        public ActionResult SetSelectedPatient(string root, string selectedId)
        {
            long idfHumanActual = long.Parse(selectedId);
            long key            = long.Parse(root);
            long rootKey        = (long)((IObject)ModelStorage.GetRoot(Session.SessionID, key, null)).Key;
            var  rootHumanCase  = ModelStorage.Get(Session.SessionID, rootKey, null) as HumanCase;
            var  data           = new CompareModel();

            using (DbManagerProxy manager = DbManagerFactory.Factory.Create(EidssUserContext.Instance))
            {
                var                 patientAccessor         = Patient.Accessor.Instance(null);
                Patient             patient                 = patientAccessor.SelectByKey(manager, idfHumanActual);
                var                 contactedPersonAccessor = ContactedCasePerson.Accessor.Instance(null);
                ContactedCasePerson contactedPerson         = contactedPersonAccessor.Create(manager, rootHumanCase, rootKey);
                contactedPerson.Person = contactedPerson.Person.CopyFrom(manager, patient);
                long idfPatientRootHuman  = patient.idfRootHuman.HasValue ? patient.idfRootHuman.Value : patient.idfHuman;
                int  contactedPersonCount = rootHumanCase.ContactedPerson.Where(x => x.Person.idfRootHuman.Value == idfPatientRootHuman).Count();
                if (contactedPersonCount > 0)
                {
                    string errorMessage = EidssMessages.Get("errContactedPersonDuplicates");
                    data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
                }
                else if (rootHumanCase.Patient.idfRootHuman == idfPatientRootHuman)
                {
                    string errorMessage = EidssMessages.Get("errContactedPersonDuplicateRootHuman");
                    data.Add("ErrorMessage", "ErrorMessage", "ErrorMessage", errorMessage, false, false, false);
                }
                else
                {
                    //rootHumanCase.ContactedPerson.Add(contactedPerson);
                    //TODO: remove previous contact
                    contactedPerson.NewObject = true;
                    ModelStorage.Put(Session.SessionID, key, contactedPerson.idfContactedCasePerson, null, contactedPerson);
                    data.Add("idfContactedCasePerson", "", "", contactedPerson.idfContactedCasePerson.ToString(), false, false, false);
                }
            }
            return(new JsonResult {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet, Data = data
            });
        }