Esempio n. 1
0
 public static void LoadData(string start, string end)
 {
     _roles       = new List <Roles>(Roles.ListRoles());
     _patients    = new List <Patient>(Patient.ListPatients());
     _users       = new List <Users>(Users.ListUsers());
     _events      = new List <Events>(Events.ListEvents());
     _clinics     = new List <Clinics>(Clinics.ListClinic());
     _branch      = new List <Branch>(Branch.ListBranch());
     _queues      = new List <Queue>(Queue.ListQueue());
     _admit       = new List <Admission>(Admission.ListAdmission());
     _wards       = new List <Wards>(Wards.ListWards());
     _departments = new List <Departments>(Departments.ListDepartment());
     _procedures  = new List <Procedures>(Procedures.ListProcedures());
     _operations  = new List <Operations>(Operations.ListOperations());
     _specimens   = new List <Specimens>(Specimens.ListSpecimens());
     _tests       = new List <Tests>(Tests.ListTests());
     _disciplines = new List <Discipline>(Discipline.ListDiscipline());
     _beds        = new List <Beds>(Beds.ListBeds());
     _categories  = new List <Category>(Category.ListCategory());
     _cds         = new List <Cd10>(Cd10.ListCd10());
     _items       = new List <Item>(Item.ListItem());
     _stocks      = new List <Stock>(Stock.ListStock());
     _dosages     = new List <Dosage>(Dosage.ListDosage());
     _transactors = new List <Transactor>(Transactor.ListTransactors());
     //  _services = new List<Services>(Services.ListServices());
     // _diagnosis = new List<Diagnosis>(Diagnosis.ListDiagnosis());
     _rooms = new List <Room>(Room.ListRoom());
     // _vitals = new List<Vitals>(Vitals.ListVitals());
     _org = new List <Organisation>(Organisation.ListOrganisation());
 }
Esempio n. 2
0
        private void saveBtn_Click(object sender, EventArgs e)
        {
            if (nameTxt.Text == "")
            {
                nameTxt.BackColor = Color.Red;
                return;
            }

            string id = Guid.NewGuid().ToString();

            _ward = new Wards(id, nameTxt.Text, codeTxt.Text, capacityTxt.Text, costTxt.Text, depositTxt.Text, wingTxt.Text, periodTxt.Text, DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"), Helper.orgID);

            if (DBConnect.Insert(_ward) != "")
            {
                Global._wards.Add(_ward);
                nameTxt.Text     = "";
                codeTxt.Text     = "";
                capacityTxt.Text = "";
                MessageBox.Show("Information Saved");
                LoadData();
            }
            else
            {
                return;
            }
        }
Esempio n. 3
0
        public Wards GetByID(int _wardId)
        {
            WardsDAC    _wardsComponent = new WardsDAC();
            IDataReader reader          = _wardsComponent.GetByIDWards(_wardId);
            Wards       _wards          = null;

            while (reader.Read())
            {
                _wards = new Wards();
                if (reader["WardId"] != DBNull.Value)
                {
                    _wards.WardId = Convert.ToInt32(reader["WardId"]);
                }
                if (reader["WardCode"] != DBNull.Value)
                {
                    _wards.WardCode = Convert.ToString(reader["WardCode"]);
                }
                if (reader["WardDescription"] != DBNull.Value)
                {
                    _wards.WardDescription = Convert.ToString(reader["WardDescription"]);
                }
                if (reader["WardTypeId"] != DBNull.Value)
                {
                    _wards.WardTypeId = Convert.ToInt32(reader["WardTypeId"]);
                }
                if (reader["WardForId"] != DBNull.Value)
                {
                    _wards.WardForId = Convert.ToInt32(reader["WardForId"]);
                }
                if (reader["BedsNumber"] != DBNull.Value)
                {
                    _wards.BedsNumber = Convert.ToInt32(reader["BedsNumber"]);
                }
                if (reader["WardCapacity"] != DBNull.Value)
                {
                    _wards.WardCapacity = Convert.ToInt32(reader["WardCapacity"]);
                }
                if (reader["RoomsNumber"] != DBNull.Value)
                {
                    _wards.RoomsNumber = Convert.ToInt32(reader["RoomsNumber"]);
                }
                if (reader["WardPhone"] != DBNull.Value)
                {
                    _wards.WardPhone = Convert.ToString(reader["WardPhone"]);
                }
                if (reader["WardColor"] != DBNull.Value)
                {
                    _wards.WardColor = Convert.ToString(reader["WardColor"]);
                }
                if (reader["WardOrder"] != DBNull.Value)
                {
                    _wards.WardOrder = Convert.ToInt32(reader["WardOrder"]);
                }
                _wards.NewRecord = false;
            }
            reader.Close();
            return(_wards);
        }
Esempio n. 4
0
        private void dtGrid_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            updateID = dtGrid.Rows[e.RowIndex].Cells[2].Value.ToString();
            _ward    = new Wards(dtGrid.Rows[e.RowIndex].Cells[2].Value.ToString(), dtGrid.Rows[e.RowIndex].Cells[4].Value.ToString(), dtGrid.Rows[e.RowIndex].Cells[5].Value.ToString(), dtGrid.Rows[e.RowIndex].Cells[6].Value.ToString(), dtGrid.Rows[e.RowIndex].Cells[7].Value.ToString(), dtGrid.Rows[e.RowIndex].Cells[8].Value.ToString(), dtGrid.Rows[e.RowIndex].Cells[9].Value.ToString(), dtGrid.Rows[e.RowIndex].Cells[10].Value.ToString(), DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"), Helper.orgID);

            DBConnect.Update(_ward, updateID);
            Global._wards.RemoveAll(x => x.Id == updateID);
            Global._wards.Add(_ward);
        }
Esempio n. 5
0
 public HospitalViewModel(DataStoreItem item)
     : base(item)
 {
     foreach (Ward w in ((Hospital)Item).Wards)
     {
         Wards.Add(new DataStoreItemViewModel(w));
     }
     AddNewWardCommand = new RelayCommand(AddWard);
 }
        private void LoadWardsData()
        {
            Wards oWards = new Wards();

            cboWard.DataBindings.Clear();
            m_oDS = oWards.GetData();
            cboWard.DataSource    = m_oDS.Tables["Wards"];
            cboWard.DisplayMember = "Name";
            cboWard.ValueMember   = "Name";
        }
Esempio n. 7
0
 public override void Start()
 {
     base.Start();
     try
     {
         SelectedCounty    = Counties.FirstOrDefault(x => x.Id == 0);
         SelectedSubCounty = SubCounties.FirstOrDefault(x => x.Id == 0);
         SelectedWard      = Wards.FirstOrDefault(x => x.Id == 0);
     }
     catch { }
 }
Esempio n. 8
0
        public bool Insert(Wards wards)
        {
            int      autonumber       = 0;
            WardsDAC wardsComponent   = new WardsDAC();
            bool     endedSuccessfuly = wardsComponent.InsertNewWards(ref autonumber, wards.WardCode, wards.WardDescription, wards.WardTypeId, wards.WardForId, wards.BedsNumber, wards.WardCapacity, wards.RoomsNumber, wards.WardPhone, wards.WardColor, wards.WardOrder);

            if (endedSuccessfuly)
            {
                wards.WardId = autonumber;
            }
            return(endedSuccessfuly);
        }
Esempio n. 9
0
        public ShadowShaman(Unit9 owner, MultiSleeper abilitySleeper, Sleeper orbwalkSleeper, ControllableUnitMenu menu)
            : base(owner, abilitySleeper, orbwalkSleeper, menu)
        {
            this.ComboAbilities = new Dictionary <AbilityId, Func <ActiveAbility, UsableAbility> >
            {
                { AbilityId.shadow_shaman_ether_shock, x => this.shock = new NukeAbility(x) },
                { AbilityId.shadow_shaman_voodoo, x => this.hex = new DisableAbility(x) },
                { AbilityId.shadow_shaman_shackles, x => this.shackles = new DisableAbility(x) },
                { AbilityId.shadow_shaman_mass_serpent_ward, x => this.wards = new Wards(x) },

                { AbilityId.item_force_staff, x => this.force = new ForceStaff(x) },
                { AbilityId.item_blink, x => this.blink = new BlinkAbility(x) },
                { AbilityId.item_cyclone, x => this.euls = new EulsScepterOfDivinity(x) },
            };

            this.MoveComboAbilities.Add(AbilityId.shadow_shaman_voodoo, _ => this.hex);
        }
Esempio n. 10
0
        internal static void OnLoad(EventArgs args)
        {
            Config    = new Menu(Menuname, Menuname, true);
            Orbwalker = new Orbwalking.Orbwalker(Menu.root);
            ActivatorMenu.LoadActivator();
            DamagesMenu.LoadDamagesMenu();
            EnviormentMenu.LoadEnviormentMenu();
            JungleMenu.LoadJungleMenu();
            DrawingsMenu.DrawingsMenus();
            SummonersMenu.LoadSummonersMenu();
            AutoLevelMenu.OnLoad();
            Config.Item("useautolevel").SetValue(false);
            Config.AddToMainMenu();

            // Activator
            Defensive.OnLoad();
            Offensive.OnLoad();
            Consumables.OnLoad();

            // Summoners
            Ignite.OnLoad();
            Heal.OnLoad();
            Cleanse.OnLoad();
            Barrier.OnLoad();

            //Drawings //todo DtoP
            EnemyRanges.OnLoad();
            AllyRanges.OnLoad();
            Wards.OnLoad();
            TrackerSpell.OnLoad();
            //DtoT.OnLoad();s
            //  DtoP.OnLoad();

            //Jungle (yes smite contains everything in jungle) //todo Jungle timers
            Smite.OnLoad();

            //Enviormenet //todo Ult Manager, Inhibs, Turn Around, Turrets
            AntiRengar.OnLoad();
            Auto_Level_Manager.AutoLevel.OnLoad();
            //UltManager.OnLoad();
            //Inhibitors.OnLoad();
            //TurnAround.OnLoad();
            //Turrets.OnLoad();
        }
Esempio n. 11
0
        public JsonResult LoadWard(int id)
        {
            var          ward      = db.Wards.Where(s => s.DistrictID == id).ToList();
            List <Wards> listWards = new List <Wards>();
            Wards        tmp       = null;

            foreach (var item in ward)
            {
                tmp      = new Wards();
                tmp.Id   = item.Id;
                tmp.Name = item.Name;
                tmp.Type = item.Type;
                listWards.Add(tmp);
            }
            return(Json(new
            {
                data = listWards,
                status = true
            }));
        }
Esempio n. 12
0
        private static void Drawing_OnDraw(EventArgs args)
        {
            if (!menu.CheckBoxValue("enable"))
            {
                return;
            }

            foreach (var ward in Detectedwards)
            {
                Circle.Draw(Wards.color(ward), 125, ward.Position);

                var endtime = (int)(ward.EndTime - Game.Time);
                Extensions.text.TextValue = endtime.ToString(CultureInfo.InvariantCulture);
                Extensions.text.Position  = ward.Position.WorldToScreen();
                if (ward.EndTime > 0)
                {
                    Extensions.text.Draw();
                }
            }
        }
        public override void LoadFromStore(VMStore modelStore)
        {
            try
            {
                ContactAddress = JsonConvert.DeserializeObject <ClientContactAddressDTO>(modelStore.Store);
                PersonId       = ContactAddress.PersonId;
                Downloaded     = ContactAddress.Downloaded;
                Telephone      = ContactAddress.Phone;
                Landmark       = ContactAddress.Landmark;
                ContactId      = ContactAddress.ContactId;
                AddressId      = ContactAddress.AddressId;

                SelectedCounty    = Counties.FirstOrDefault(x => x.Id == 0);
                SelectedSubCounty = SubCounties.FirstOrDefault(x => x.Id == 0);
                SelectedWard      = Wards.FirstOrDefault(x => x.Id == 0);

                if (ContactAddress.CountyId.HasValue && ContactAddress.CountyId.Value > 0)
                {
                    SelectedCounty = Counties.FirstOrDefault(x => x.Id == ContactAddress.CountyId);
                    GetSubCounties();
                }

                if (ContactAddress.SubCountyId.HasValue && ContactAddress.SubCountyId.Value > 0)
                {
                    SelectedSubCounty = SubCounties.FirstOrDefault(x => x.Id == ContactAddress.SubCountyId);
                    GetWards();
                }

                if (ContactAddress.WardId.HasValue && ContactAddress.WardId.Value > 0)
                {
                    SelectedWard = Wards.FirstOrDefault(x => x.Id == ContactAddress.WardId);
                }
            }
            catch (Exception e)
            {
                Mvx.Error(e.Message);
            }
        }
Esempio n. 14
0
        private void updateBtn_Click(object sender, EventArgs e)
        {
            if (updateID == "")
            {
                return;
            }
            if (MessageBox.Show("YES or No?", "Are you sure you want to update this information? ", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                _ward = new Wards(updateID, nameTxt.Text, codeTxt.Text, capacityTxt.Text, costTxt.Text, depositTxt.Text, wingTxt.Text, periodTxt.Text, DateTime.Now.ToString("dd-MM-yyyy H:mm:ss"), Helper.orgID);

                DBConnect.Update(_ward, updateID);
                Global._wards.RemoveAll(x => x.Id == updateID);
                Global._wards.Add(_ward);
                // DBConnect.Execute(SQL);
                MessageBox.Show("Information updated");
                saveBtn.Visible   = true;
                updateBtn.Visible = false;
                updateID          = "";
                nameTxt.Text      = "";
                codeTxt.Text      = "";
                capacityTxt.Text  = "";
                LoadData();
            }
        }
Esempio n. 15
0
        public bool Update(Wards wards, int old_wardId)
        {
            WardsDAC wardsComponent = new WardsDAC();

            return(wardsComponent.UpdateWards(wards.WardCode, wards.WardDescription, wards.WardTypeId, wards.WardForId, wards.BedsNumber, wards.WardCapacity, wards.RoomsNumber, wards.WardPhone, wards.WardColor, wards.WardOrder, old_wardId));
        }
Esempio n. 16
0
        public double CalcCorrectionFactor()
        {
            var totalPopulation = Wards.Sum(w => w.Population);

            return(totalPopulation / Convert.ToDouble(Scenario.NumberOfAgents));
        }
Esempio n. 17
0
 public Parishioner(string _firstName, string _lastName, Wards _ward)
 {
     this.firstName = !string.IsNullOrEmpty(_firstName) ? _firstName : "FIRSTNAME";
     this.lastName  = !string.IsNullOrEmpty(_lastName) ? _lastName : "LASTNAME";
     this.ward      = _ward;
 }
        public override async Task ExecuteAsync(CancellationToken token)
        {
            Target = this.TargetSelector.Active.GetTargets().FirstOrDefault(x => !x.IsInvulnerable());

            var silenced = UnitExtensions.IsSilenced(this.Owner);

            var sliderValue = this.Config.UseBlinkPrediction.Item.GetValue <Slider>().Value;

            var isChanneling = UnitExtensions.IsChanneling(this.Owner);

            if (!silenced)
            {
                try
                {
                    if ((this.BlinkDagger != null) &&
                        (this.BlinkDagger.Item.IsValid) &&
                        Target != null && Owner.Distance2D(Target) <= 1200 + sliderValue &&
                        !(Owner.Distance2D(Target) <= sliderValue) &&
                        this.BlinkDagger.Item.CanBeCasted() &&
                        this.Config.ItemToggler.Value.IsEnabled(this.BlinkDagger.Item.Name) && !isChanneling)
                    {
                        var l        = (this.Owner.Distance2D(Target) - sliderValue) / sliderValue;
                        var posA     = this.Owner.Position;
                        var posB     = Target.Position;
                        var x        = (posA.X + (l * posB.X)) / (1 + l);
                        var y        = (posA.Y + (l * posB.Y)) / (1 + l);
                        var position = new Vector3((int)x, (int)y, posA.Z);

                        Log.Debug("Using BlinkDagger");
                        this.BlinkDagger.UseAbility(position);
                        await Await.Delay(this.GetItemDelay(position), token);
                    }

                    if ((this.Euls != null) && this.Euls.Item.IsValid && Target != null &&
                        this.Owner.Distance2D(Target) <= this.Euls.CastRange && this.Euls.Item.CanBeCasted(Target) &&
                        this.Config.ItemToggler.Value.IsEnabled(this.Euls.Item.Name))
                    {
                        Log.Debug($"Using Eul");
                        this.Euls.UseAbility(this.Target);
                        await Await.Delay(this.GetItemDelay(Target), token);
                    }

                    if (Hex != null && Hex.IsValid && Hex.CanBeCasted(Target) &&
                        !isChanneling &&
                        this.Config.AbilityToggler.Value.IsEnabled(this.Hex.Name))
                    {
                        Log.Debug($"Using Hex");
                        Hex.UseAbility(Target);
                        await Await.Delay(GetAbilityDelay(this.Owner, Hex), token);
                    }

                    if (Ethershock != null && Ethershock.IsValid && Ethershock.CanBeCasted(Target) &&
                        !isChanneling &&
                        this.Config.AbilityToggler.Value.IsEnabled(this.Ethershock.Name))
                    {
                        Log.Debug($"Using Ethershock!");
                        Ethershock.UseAbility(Target);
                        await Await.Delay(GetAbilityDelay(this.Owner, Ethershock), token);
                    }
                }
                catch (TaskCanceledException)
                {
                    // ignore
                }
                catch (Exception e)
                {
                    Log.Error($"{e}");
                }
            }

            if (!silenced)
            {
                try
                {
                    var invulTargetsToo = this.TargetSelector.Active.GetTargets().FirstOrDefault();
                    if (Wards != null && Wards.IsValid && Wards.CanBeCasted() &&
                        !isChanneling && invulTargetsToo != null && invulTargetsToo.IsValid &&
                        this.Config.AbilityToggler.Value.IsEnabled(this.Wards.Name))
                    {
                        var delay          = Wards.GetCastPoint();
                        var wardsCastRange = Wards.CastRange;

                        var input = new PredictionInput(this.Owner, invulTargetsToo, delay, float.MaxValue,
                                                        wardsCastRange, 30,
                                                        PredictionSkillshotType.SkillshotCircle)
                        {
                            CollisionTypes = CollisionTypes.None
                        };

                        output = Prediction.GetPrediction(input);

                        if (output.HitChance >= HitChance.Medium)
                        {
                            Log.Debug($"Casting Wards");
                            this.Wards.UseAbility(output.CastPosition);
                            if (this.Config.FailSwitch.Value.Equals(true) && (Target.IsRotating() && Target.MovementSpeed >= 300 || Ensage.SDK.Extensions.EntityExtensions.Distance2D(Target, output.CastPosition) >= 200))
                            {
                                Log.Error($"stopping");
                                this.Owner.Stop();
                                await Await.Delay(100, token);
                            }
                            await Await.Delay(GetAbilityDelay(output.CastPosition, this.Wards), token);
                        }
                    }
                }
                catch (TaskCanceledException)
                {
                    // ignored
                }
                catch (Exception e)
                {
                    Log.Error($"{e}");
                }
            }

            if (this.BloodThorn != null &&
                this.BloodThorn.Item.IsValid &&
                Target != null && !isChanneling &&
                this.BloodThorn.Item.CanBeCasted(Target) &&
                this.Config.ItemToggler.Value.IsEnabled(this.BloodThorn.Item.Name))
            {
                Log.Debug("Using Bloodthorn");
                this.BloodThorn.UseAbility(Target);
                await Await.Delay(this.GetItemDelay(Target), token);
            }

            if ((this.SheepStick != null) &&
                (this.SheepStick.Item.IsValid) &&
                Target != null && !isChanneling &&
                this.SheepStick.Item.CanBeCasted(Target) &&
                this.Config.ItemToggler.Value.IsEnabled("item_sheepstick"))
            {
                Log.Debug("Using Sheepstick");
                this.SheepStick.UseAbility(Target);
                await Await.Delay(this.GetItemDelay(Target), token);
            }

            if (this.Dagon != null &&
                this.Dagon.Item.IsValid &&
                Target != null && !isChanneling &&
                this.Dagon.Item.CanBeCasted(Target) &&
                this.Config.ItemToggler.Value.IsEnabled(Dagon5.Item.Name))
            {
                Log.Debug("Using Dagon");
                this.Dagon.UseAbility(Target);
                await Await.Delay(this.GetItemDelay(Target), token);
            }

            if (this.Orchid != null &&
                this.Orchid.Item.IsValid &&
                Target != null && !isChanneling &&
                this.Orchid.Item.CanBeCasted(Target) &&
                this.Config.ItemToggler.Value.IsEnabled("item_orchid"))
            {
                Log.Debug("Using Orchid");
                this.Orchid.UseAbility(Target);
                await Await.Delay(this.GetItemDelay(Target), token);
            }

            if (this.RodofAtos != null &&
                this.RodofAtos.Item.IsValid &&
                Target != null && !isChanneling &&
                this.RodofAtos.Item.CanBeCasted(Target) &&
                this.Config.ItemToggler.Value.IsEnabled("item_rod_of_atos"))
            {
                Log.Debug("Using RodofAtos");
                this.RodofAtos.UseAbility(Target);
                await Await.Delay(this.GetItemDelay(Target), token);
            }

            if (this.VeilofDiscord != null &&
                this.VeilofDiscord.Item.IsValid &&
                Target != null && !isChanneling &&
                this.VeilofDiscord.Item.CanBeCasted() &&
                this.Config.ItemToggler.Value.IsEnabled("item_veil_of_discord"))
            {
                Log.Debug("Using VeilofDiscord");
                this.VeilofDiscord.UseAbility(Target.Position);
                await Await.Delay(this.GetItemDelay(Target), token);
            }

            if (this.HurricanePike != null &&
                this.HurricanePike.Item.IsValid &&
                Target != null && !isChanneling &&
                this.HurricanePike.Item.CanBeCasted() &&
                this.Config.ItemToggler.Value.IsEnabled("item_hurricane_pike"))
            {
                Log.Debug("Using HurricanePike");
                this.HurricanePike.UseAbility(Target);
                await Await.Delay(this.GetItemDelay(Target), token);
            }

            if (this.ShivasGuard != null &&
                this.ShivasGuard.Item.IsValid &&
                Target != null && !isChanneling &&
                this.ShivasGuard.Item.CanBeCasted() &&
                Owner.Distance2D(Target) <= 900 &&
                this.Config.ItemToggler.Value.IsEnabled("item_shivas_guard"))
            {
                Log.Debug("Using Shiva's Guard");
                this.ShivasGuard.UseAbility();
                await Await.Delay((int)Game.Ping, token);
            }

            if (this.Mjollnir != null &&
                this.Mjollnir.Item.IsValid &&
                Target != null && !isChanneling &&
                this.Mjollnir.Item.CanBeCasted() &&
                this.Config.ItemToggler.Value.IsEnabled("item_mjollnir"))
            {
                Log.Debug("Using Mjollnir");
                this.Mjollnir.UseAbility(Owner);
                await Await.Delay(this.GetItemDelay(Target), token);
            }
            try
            {
                if (Shackles != null && Shackles.IsValid && Shackles.CanBeCasted(Target) &&
                    !isChanneling &&
                    (Wards == null || !Wards.IsValid || !Wards.CanBeCasted() ||
                     !this.Config.AbilityToggler.Value.IsEnabled(this.Wards.Name)) && HexSync() &&
                    this.Config.AbilityToggler.Value.IsEnabled(this.Shackles.Name))
                {
                    Log.Debug($"Using Shackles!");
                    Shackles.UseAbility(Target);
                    await Await.Delay(GetAbilityDelay(this.Target, Shackles) + 1000, token);
                }
            }
            catch (TaskCanceledException)
            {
                // ignore
            }
            catch (Exception e)
            {
                Log.Error(e);
            }

            /*if (Refresher != null && Refresher.Item.IsValid && Target != null &&
             *   !isChanneling && this.Refresher.Item.CanBeCasted() && !this.Wards.CanBeCasted() && !this.Shackles.CanBeCasted() &&
             *   this.Config.ItemToggler.Value.IsEnabled(Refresher.Item.Name))
             * {
             *   Log.Debug($"Using Refresher Orb");
             *   Refresher.UseAbility();
             *   await Await.Delay(100, token);
             * }*/

            if (Target != null && Owner.IsValidOrbwalkingTarget(Target) && !isChanneling)
            {
                this.Context.Orbwalker.Active.OrbwalkTo(Target);
                Log.Debug($"Orbwalking");
            }

            await Await.Delay(100, token);
        }
Esempio n. 19
0
        public void Run()
        {
            string        log            = String.Empty;
            ReplaceString replaceString  = new ReplaceString();
            DirectoryInfo dir            = Directory.GetParent(Environment.CurrentDirectory).Parent.Parent;
            string        dirPath        = dir.FullName;
            string        templateReport = System.IO.Path.Combine(dirPath, @"Json\Ward.json");

            using (StreamReader r = new StreamReader(templateReport))
            {
                string      json  = r.ReadToEnd();
                List <Ward> items = JsonConvert.DeserializeObject <List <Ward> >(json);
                using (var context = new quickbeedev1Context())
                {
                    var translator = context.Translators.Where(x => x.DataKey == "VTP.DISTRICT").ToList();
                    foreach (var i in translator)
                    {
                        int?   districtOriginId = Convert.ToInt32(i.OriginalValue);
                        string districtJsId     = i.TranslatedValue;

                        //List Ward
                        var wardJsList       = items.Where(x => x.DISTRICT_ID == districtJsId).ToList();
                        var wardOriginalList = (from d in context.Wards.Where(x => x.DistrictId == districtOriginId)
                                                select new
                        {
                            Id = d.Id,
                            Name = replaceString.Replace(d.Name, "WARD")
                        }).ToList();
                        foreach (var itemW in wardJsList)
                        {
                            var wardOriginalObj = wardOriginalList.Where(x => x.Name == replaceString.Replace(itemW.WARDS_NAME, "WARD")).FirstOrDefault();
                            if (wardOriginalObj != null)
                            {
                                var translators = new Translators()
                                {
                                    DataKey         = "VTP.WARD",
                                    OriginalValue   = Convert.ToString(wardOriginalObj.Id),
                                    TranslatedValue = Convert.ToString(itemW.WARDS_ID)
                                };

                                var wardExists = context.Translators.Where(x => x.DataKey == translators.DataKey &&
                                                                           x.TranslatedValue == translators.TranslatedValue);
                                if (wardExists.Count() == 0)
                                {
                                    context.Translators.Add(translators);
                                    context.SaveChanges();
                                    log += wardOriginalObj.Name + "-" + itemW.WARDS_NAME + "\n";
                                }
                            }
                            else
                            {
                                var wardNew = new Wards()
                                {
                                    Name       = replaceString.ConverToUpper(itemW.WARDS_NAME),
                                    DistrictId = districtOriginId ?? 0
                                };

                                context.Wards.Add(wardNew);
                                context.SaveChanges();
                                var translators = new Translators()
                                {
                                    DataKey         = "VTP.WARD",
                                    OriginalValue   = Convert.ToString(wardNew.Id),
                                    TranslatedValue = Convert.ToString(itemW.WARDS_ID)
                                };
                                context.Translators.Add(translators);
                                context.SaveChanges();
                                log += itemW.WARDS_NAME + "\n";
                            }
                        }
                    }
                }
            }

            Console.WriteLine(log);
        }
Esempio n. 20
0
        public List <Wards> GetAll()
        {
            WardsDAC     _wardsComponent = new WardsDAC();
            IDataReader  reader          = _wardsComponent.GetAllWards().CreateDataReader();
            List <Wards> _wardsList      = new List <Wards>();

            while (reader.Read())
            {
                if (_wardsList == null)
                {
                    _wardsList = new List <Wards>();
                }
                Wards _wards = new Wards();
                if (reader["WardId"] != DBNull.Value)
                {
                    _wards.WardId = Convert.ToInt32(reader["WardId"]);
                }
                if (reader["WardCode"] != DBNull.Value)
                {
                    _wards.WardCode = Convert.ToString(reader["WardCode"]);
                }
                if (reader["WardDescription"] != DBNull.Value)
                {
                    _wards.WardDescription = Convert.ToString(reader["WardDescription"]);
                }
                if (reader["WardTypeId"] != DBNull.Value)
                {
                    _wards.WardTypeId = Convert.ToInt32(reader["WardTypeId"]);
                }
                if (reader["WardForId"] != DBNull.Value)
                {
                    _wards.WardForId = Convert.ToInt32(reader["WardForId"]);
                }
                if (reader["BedsNumber"] != DBNull.Value)
                {
                    _wards.BedsNumber = Convert.ToInt32(reader["BedsNumber"]);
                }
                if (reader["WardCapacity"] != DBNull.Value)
                {
                    _wards.WardCapacity = Convert.ToInt32(reader["WardCapacity"]);
                }
                if (reader["RoomsNumber"] != DBNull.Value)
                {
                    _wards.RoomsNumber = Convert.ToInt32(reader["RoomsNumber"]);
                }
                if (reader["WardPhone"] != DBNull.Value)
                {
                    _wards.WardPhone = Convert.ToString(reader["WardPhone"]);
                }
                if (reader["WardColor"] != DBNull.Value)
                {
                    _wards.WardColor = Convert.ToString(reader["WardColor"]);
                }
                if (reader["WardOrder"] != DBNull.Value)
                {
                    _wards.WardOrder = Convert.ToInt32(reader["WardOrder"]);
                }
                _wards.NewRecord = false;
                _wardsList.Add(_wards);
            }
            reader.Close();
            return(_wardsList);
        }