public TypeOrg GetTypeOrg(OrganizationModel model)
        {
            if (RecordType.RU_Hospital.ToString() == model.RecordType)
            {
                return(TypeOrg.ЛПУ);
            }
            if (((RecordType.RU_Department.ToString() == model.RecordType) && (model.MainSpec == "Pharmaciuticals")) || (RecordType.RU_Pharmacy.ToString() == model.RecordType))
            {
                return(TypeOrg.Аптека);
            }
            if (RecordType.RU_Department.ToString() == model.RecordType)
            {
                return(TypeOrg.Отделение);
            }
            if (RecordType.RU_Institution_Buying.ToString() == model.RecordType)
            {
                return(TypeOrg.Дистрибьютор);
            }
            if (model.ClientType == ExportOrganization.clientType[0])
            {
                return(TypeOrg.Отдел);
            }
            if (model.ClientType == ExportOrganization.clientType[1])
            {
                return(TypeOrg.Административное_Учреждение);
            }
            if (model.ClientType == ExportOrganization.clientType[2])
            {
                return(TypeOrg.Дистрибьютор);
            }
            if (model.ClientType == ExportOrganization.clientType[3])
            {
                return(TypeOrg.Ветеренарная_клиника);
            }
            if (model.ClientType == ExportOrganization.clientType[4])
            {
                return(TypeOrg.Стоматология);
            }

            throw new NullReferenceException("Failed recognize Organization type");
        }
        public TypeOrg GetTypeOrg(OrganizationModel model)
        {
            if (RecordType.RU_Hospital.ToString() == model.RecordType)
                return TypeOrg.ЛПУ;
            if (((RecordType.RU_Department.ToString() == model.RecordType) && (model.MainSpec == "Pharmaciuticals")) || (RecordType.RU_Pharmacy.ToString() == model.RecordType))
                return TypeOrg.Аптека;
            if (RecordType.RU_Department.ToString() == model.RecordType)
                return TypeOrg.Отделение;
            if (RecordType.RU_Institution_Buying.ToString() == model.RecordType)
                return TypeOrg.Дистрибьютор;
            if (model.ClientType == ExportOrganization.clientType[0])
                return TypeOrg.Отдел;
            if (model.ClientType == ExportOrganization.clientType[1])
                return TypeOrg.Административное_Учреждение;
            if (model.ClientType == ExportOrganization.clientType[2])
                return TypeOrg.Дистрибьютор;
            if (model.ClientType == ExportOrganization.clientType[3])
                return TypeOrg.Ветеренарная_клиника;
            if (model.ClientType == ExportOrganization.clientType[4])
                return TypeOrg.Стоматология;

            throw new NullReferenceException("Failed recognize Organization type");
        }
        private void Update(OrganizationModel model)
        {
            Organization organization = GetOrganization(model);
            if (organization == null)
                return;

            organization.NumberSF = model.NumberSF;
            organization.CrmID = model.CrmID;

            if (model.ParentNumberSF != string.Empty)
            {
                organization.ParentOrganization = organizationList.GetItem(model.ParentNumberSF) ?? organization.ParentOrganization;
            }

            organization.Name = model.Name;
            organization.ShortName = model.ShortName;
            organization.Email = model.Email;
            organization.Website = model.Website;
            organization.Phone = model.Phone;
            organization.Pharmacy = model.Pharmacy;
            organization.Deleted = model.Deleted;

            organization.INN = model.INN;
            organization.KPP = model.KPP;
            organization.RealRegion = GetItem(realRegionList, model.RealRegion, "Region", model.NumberSF) as RealRegion;
            organization.City = model.City;
            organization.PostIndex = model.PostIndex;
            organization.Street = model.Street;

            if (organization is LPU)
            {
                LPU lpu = organization as LPU;
                lpu.AdmLevel = GetItem(admLevelList, model.AdmLevel, "AdminLevel", model.NumberSF) as AdmLevel;
                lpu.TypeFin = GetItem(typeFinList, model.TypeFin, "TypeFin", model.NumberSF) as TypeFin;
                lpu.MainSpec = GetItem(mainSpecList, model.MainSpec, "MainSpec", model.NumberSF) as MainSpec;
                lpu.SubRegion = model.SubRegion;
                lpu.BedsTotal = model.BedsTotal;
                lpu.BedsIC = model.BedsIC;
                lpu.BedsSurgical = model.BedsSurgical;
                lpu.Operating = model.Operating;

                lpu.TypeLPU = GetItem(typeLPUList, model.TypeLPU, "Hospital type", model.NumberSF) as TypeLPU;
                lpu.Ownership = GetItem(ownershipList, model.Ownership, "Ownership", model.NumberSF) as Ownership;
            }
            if (organization is IAvitum)
            {
                IAvitum avitum = organization as IAvitum;
                avitum.MachineGD = model.MachineGD;
                avitum.MachineGDF = model.MachineGDF;
                avitum.MachineCRRT = model.MachineCRRT;
                avitum.Shift = model.Shifts;
                avitum.PatientGD = model.PatientGD;
                avitum.PatientPD = model.PatientPD;
                avitum.PatientCRRT = model.PatientCRRT;
            }

            organization.Save();
        }
        private Organization GetOrganization(OrganizationModel model)
        {
            Organization organization = organizationList.GetItem(model.NumberSF);

            if (organization == null)
            {
                try
                {
                    TypeOrg typeOrg = GetTypeOrg(model);
                    organization = new Organization(typeOrg);
                }
                catch (NullReferenceException)
                {
                    if (model.RecordType == "RU_Other")
                        LogManager.WriteNotFound(model.ClientType, "Organization subtype", model.NumberSF);
                    else
                        LogManager.WriteNotFound(model.RecordType, "Organization type", model.NumberSF);
                }
            }

            return organization;
        }
Example #5
0
        public TypeOrg ImportOrganization(RecordType recordType, string clientType, string mainSpec)
        {
            OrganizationModel organizationModel = new OrganizationModel { RecordType = recordType.ToString(), ClientType = clientType, MainSpec = mainSpec };

            return new ReadFileOrganization().GetTypeOrg(organizationModel);
        }
        private void Update(OrganizationModel model)
        {
            Organization organization = GetOrganization(model);

            if (organization == null)
            {
                return;
            }

            organization.NumberSF = model.NumberSF;
            organization.CrmID    = model.CrmID;

            if (model.ParentNumberSF != string.Empty)
            {
                organization.ParentOrganization = organizationList.GetItem(model.ParentNumberSF) ?? organization.ParentOrganization;
            }

            organization.Name      = model.Name;
            organization.ShortName = model.ShortName;
            organization.Email     = model.Email;
            organization.Website   = model.Website;
            organization.Phone     = model.Phone;
            organization.Pharmacy  = model.Pharmacy;
            organization.Deleted   = model.Deleted;

            organization.INN        = model.INN;
            organization.KPP        = model.KPP;
            organization.RealRegion = GetItem(realRegionList, model.RealRegion, "Region", model.NumberSF) as RealRegion;
            organization.City       = model.City;
            organization.PostIndex  = model.PostIndex;
            organization.Street     = model.Street;

            if (organization is LPU)
            {
                LPU lpu = organization as LPU;
                lpu.AdmLevel     = GetItem(admLevelList, model.AdmLevel, "AdminLevel", model.NumberSF) as AdmLevel;
                lpu.TypeFin      = GetItem(typeFinList, model.TypeFin, "TypeFin", model.NumberSF) as TypeFin;
                lpu.MainSpec     = GetItem(mainSpecList, model.MainSpec, "MainSpec", model.NumberSF) as MainSpec;
                lpu.SubRegion    = model.SubRegion;
                lpu.BedsTotal    = model.BedsTotal;
                lpu.BedsIC       = model.BedsIC;
                lpu.BedsSurgical = model.BedsSurgical;
                lpu.Operating    = model.Operating;

                lpu.TypeLPU   = GetItem(typeLPUList, model.TypeLPU, "Hospital type", model.NumberSF) as TypeLPU;
                lpu.Ownership = GetItem(ownershipList, model.Ownership, "Ownership", model.NumberSF) as Ownership;
            }
            if (organization is IAvitum)
            {
                IAvitum avitum = organization as IAvitum;
                avitum.MachineGD   = model.MachineGD;
                avitum.MachineGDF  = model.MachineGDF;
                avitum.MachineCRRT = model.MachineCRRT;
                avitum.Shift       = model.Shifts;
                avitum.PatientGD   = model.PatientGD;
                avitum.PatientPD   = model.PatientPD;
                avitum.PatientCRRT = model.PatientCRRT;
            }

            organization.Save();
        }