private async Task SetDataAsync() { try { _token?.Cancel(); _token = new CancellationTokenSource(); var list = await RegionsBussines.GetAllAsync(_token.Token); if (list.Count <= 0) return; foreach (var item in list) for (var i = 0; i < DGrid.RowCount; i++) if (item.Guid == ((Guid?)DGrid[dgGuid.Index, i].Value ?? Guid.Empty)) { if (!(bool)DGrid[dgIsChecked.Index, i].Value) continue; _list.Add(new AdvertiseRelatedRegionBussines() { Guid = Guid.NewGuid(), LocalRegionGuid = item.Guid, OnlineRegionName = Region.Name.Trim() }); } } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }
private async Task <string> SetDivarRegionAsync(BuildingBussines bu) { var region = ""; try { var relatedRegion = await AdvertiseRelatedRegionBussines.GetByRegionGuidAsync(bu.RegionGuid); if (relatedRegion != null) { region = relatedRegion?.OnlineRegionName ?? ""; } else { var reg = await RegionsBussines.GetAsync(bu.RegionGuid); if (reg != null) { region = reg?.Name; if (region.StartsWith(" ")) { region = region.Remove(0, 1); } } } } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } return(region); }
public string Title() { try { var type = ""; var regionName = ""; if (bu.RahnPrice1 > 0 || bu.RahnPrice2 > 0) { type = "رهن و اجاره"; } else if (bu.SellPrice > 0) { type = "فروش"; } if (bu.RegionGuid != Guid.Empty) { regionName = RegionsBussines.Get(bu.RegionGuid)?.Name ?? ""; } return($"{type} ملک در {regionName}"); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); return(""); } }
private async Task LoadDataAsync(string search = "") { try { while (!IsHandleCreated) { await Task.Delay(100); } var list = new List <RegionsBussines>(); _token?.Cancel(); _token = new CancellationTokenSource(); if (rbtnMyRegion.Checked) { var cityGuid = Guid.Parse(clsEconomyUnit.EconomyCity); list = await RegionsBussines.GetAllAsync(search, cityGuid, _token.Token); } else if (rbtnAll.Checked) { list = await RegionsBussines.GetAllAsync(search, Guid.Empty, _token.Token); } Invoke(new MethodInvoker(() => RegionBindingSource.DataSource = list?.Where(q => q.Status == _st).OrderBy(q => q.Name).ToSortableBindingList())); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }
public async Task <ReturnedSaveFuncInfo> SaveAsync(RegionsBussines item, SqlTransaction tr) { var res = new ReturnedSaveFuncInfo(); try { var cmd = new SqlCommand("sp_Regions_Save", tr.Connection, tr) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@guid", item.Guid); cmd.Parameters.AddWithValue("@modif", item.Modified); cmd.Parameters.AddWithValue("@st", item.Status); cmd.Parameters.AddWithValue("@name", item.Name ?? ""); cmd.Parameters.AddWithValue("@cityGuid", item.CityGuid); cmd.Parameters.AddWithValue("@serverSt", (short)item.ServerStatus); cmd.Parameters.AddWithValue("@serverDate", item.ServerDeliveryDate); await cmd.ExecuteNonQueryAsync(); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); res.AddReturnedValue(ex); } return(res); }
private RegionsBussines LoadData(SqlDataReader dr) { var item = new RegionsBussines(); try { item.Guid = (Guid)dr["Guid"]; item.Modified = (DateTime)dr["Modified"]; item.Status = (bool)dr["Status"]; item.Name = dr["Name"].ToString(); item.CityGuid = (Guid)dr["CityGuid"]; item.CityName = dr["CityName"].ToString(); item.StateGuid = (Guid)dr["StateGuid"]; item.StateName = dr["StateName"].ToString(); item.ServerDeliveryDate = (DateTime)dr["ServerDeliveryDate"]; item.ServerStatus = (ServerStatus)dr["ServerStatus"]; item.IsModified = true; } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } return(item); }
public frmRegionMain() { InitializeComponent(); cls = new RegionsBussines(); ucHeader.Text = "افزودن منطقه جدید"; ucHeader.IsModified = cls.IsModified; }
public async Task <RegionsBussines> GetAsync(string _connectionString, string name) { var obj = new RegionsBussines(); try { using (var cn = new SqlConnection(_connectionString)) { var cmd = new SqlCommand("sp_Regions_GetByName", cn) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@name", name); await cn.OpenAsync(); var dr = await cmd.ExecuteReaderAsync(); if (dr.Read()) { obj = LoadData(dr); } cn.Close(); } } catch (Exception exception) { WebErrorLog.ErrorInstence.StartErrorLog(exception); } return(obj); }
public frmRegionMain(Guid guid, bool isShowMode) { InitializeComponent(); cls = RegionsBussines.Get(guid); ucHeader.Text = !isShowMode ? $"ویرایش منطقه {cls.Name}" : $"مشاهده منطقه {cls.Name}"; ucHeader.IsModified = cls.IsModified; grp.Enabled = !isShowMode; btnFinish.Enabled = !isShowMode; }
private void frmRegionMain_Load(object sender, EventArgs e) { try { AsyncContext.Run(SetDataAsync); var myCollection = new AutoCompleteStringCollection(); var list = AsyncContext.Run(() => RegionsBussines.GetAllAsync(new CancellationToken())); foreach (var item in list.ToList()) { myCollection.Add(item.Name); } txtRegion.AutoCompleteCustomSource = myCollection; } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }
private static RegionsBussines SetDef(string name, string cityGuid) { try { var reg = new RegionsBussines() { Name = name, Guid = Guid.NewGuid(), CityGuid = Guid.Parse(cityGuid) }; return(reg); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); return(null); } }
private async Task SetRegionsAsync(Guid requestGuid) { try { cls.RegionList = new List <BuildingRequestRegionBussines>(); if (requestGuid == Guid.Empty) { return; } _token?.Cancel(); _token = new CancellationTokenSource(); var list = await RegionsBussines.GetAllAsync(_token.Token); if (list.Count <= 0) { return; } foreach (var item in list) { for (var i = 0; i < DGrid.RowCount; i++) { if (item.Guid == ((Guid?)DGrid[dgGuid.Index, i].Value ?? Guid.Empty)) { if (!(bool)DGrid[dgChecked.Index, i].Value) { continue; } cls.RegionList.Add(new BuildingRequestRegionBussines() { Guid = Guid.NewGuid(), RegionGuid = item.Guid, Modified = DateTime.Now, RequestGuid = cls.Guid }); } } } } catch (Exception e) { WebErrorLog.ErrorInstence.StartErrorLog(e); } }
private async void cmbCity_SelectedIndexChanged(object sender, EventArgs e) { try { if (cmbCity.SelectedValue == null) { return; } _token?.Cancel(); _token = new CancellationTokenSource(); var list = await RegionsBussines.GetAllAsync((Guid)cmbCity.SelectedValue, _token.Token); RegionBindingSource.DataSource = list.Where(q => q.Status).OrderBy(q => q.Name).ToList(); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }
private static string Text(BuildingBussines bu) { var res = ""; try { res = Settings.Classes.Payamak.OwnerText; if (res.Contains(Replacor.Owner.Code)) { res = res.Replace(Replacor.Owner.Code, bu.Code); } if (res.Contains(Replacor.Owner.DateSabt)) { res = res.Replace(Replacor.Owner.DateSabt, bu.DateSh); } if (res.Contains(Replacor.Owner.OwnerName)) { var owner = PeoplesBussines.Get(bu.OwnerGuid); res = res.Replace(Replacor.Owner.OwnerName, owner?.Name); } if (res.Contains(Replacor.Owner.Region)) { var reg = RegionsBussines.Get(bu.RegionGuid); res = res.Replace(Replacor.Owner.Region, reg?.Name); } if (res.Contains(Replacor.Owner.UserName)) { var user = UserBussines.Get(bu.UserGuid); res = res.Replace(Replacor.Owner.UserName, user?.Name); } } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } return(res); }
public async Task <ReturnedSaveFuncInfo> ChangeStatusAsync(RegionsBussines item, bool status, SqlTransaction tr) { var res = new ReturnedSaveFuncInfo(); try { var cmd = new SqlCommand("sp_Regions_ChangeStatus", tr.Connection, tr) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@Guid", item.Guid); cmd.Parameters.AddWithValue("@st", status); await cmd.ExecuteNonQueryAsync(); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); res.AddReturnedValue(ex); } return(res); }
public string Content() { try { var content = new StringBuilder(); var reg = ""; if (bu.RegionGuid != Guid.Empty) { reg = RegionsBussines.Get(bu.RegionGuid)?.Name ?? ""; } content.AppendLine($"محدوده: {reg}"); content.AppendLine($"متراژ: {bu.Masahat}"); content.AppendLine($"سال ساخت: {bu.SaleSakht}"); return(content.ToString()); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); return(""); } }
private async Task LoadRegionsAsync() { try { _token?.Cancel(); _token = new CancellationTokenSource(); var list = await RegionsBussines.GetAllAsync((Guid.Parse(Settings.Classes.clsEconomyUnit.EconomyCity)), _token.Token); var allRelated = await AdvertiseRelatedRegionBussines.GetAllAsync(); var query = from c in list where !(from o in allRelated select o.LocalRegionGuid) .Contains(c.Guid) select c; regBingingSource.DataSource = query.OrderBy(q => q.Name).ToSortableBindingList(); await SetRelatedRegionsAsync(Region.Name.Trim()); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }
private async Task ResendDataToHost() { try { if (chbState.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebStates.SaveAsync(await StatesBussines.GetAllAsync(_token.Token)); } if (chbCity.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebCity.SaveAsync(await CitiesBussines.GetAllAsync(_token.Token)); } if (chbRegion.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebRegion.SaveAsync(await RegionsBussines.GetAllAsync(_token.Token)); } if (chbUsers.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebUser.SaveAsync(await UserBussines.GetAllAsync(_token.Token)); } if (chbPeopleGroup.Checked) { await WebPeopleGroup.SaveAsync(await PeopleGroupBussines.GetAllAsync()); } if (chbPeople.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebPeople.SaveAsync(await PeoplesBussines.GetAllAsync(_token.Token)); } if (chbAccountType.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebBuildingAccountType.SaveAsync(await BuildingAccountTypeBussines.GetAllAsync(_token.Token)); } if (chbCondition.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebBuildingCondition.SaveAsync(await BuildingConditionBussines.GetAllAsync(_token.Token)); } if (chbType.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebBuildingType.SaveAsync(await BuildingTypeBussines.GetAllAsync(_token.Token)); } if (chbView.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebBuildingView.SaveAsync(await BuildingViewBussines.GetAllAsync(_token.Token)); } if (chbDocType.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebDocumentType.SaveAsync(await DocumentTypeBussines.GetAllAsync(_token.Token)); } if (chbFloor.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebFloorCover.SaveAsync(await FloorCoverBussines.GetAllAsync(_token.Token)); } if (chbKitchen.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebKitchenService.SaveAsync(await KitchenServiceBussines.GetAllAsync(_token.Token)); } if (chbRental.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebRental.SaveAsync(await RentalAuthorityBussines.GetAllAsync(_token.Token)); } if (chbOptions.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebBuildingOptions.SaveAsync(await BuildingOptionsBussines.GetAllAsync(_token.Token)); } if (chbBuilding.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebBuilding.SaveAsync(await BuildingBussines.GetAllAsync(_token.Token), Application.StartupPath); } if (chbRequest.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebBuildingRequest.SaveAsync(await BuildingRequestBussines.GetAllAsync(_token.Token)); } if (chbContract.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebContract.SaveAsync(await ContractBussines.GetAllAsync(_token.Token)); } if (chbReception.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebReception.SaveAsync(await ReceptionBussines.GetAllAsync(_token.Token)); } if (chbPardakht.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebPardakht.SaveAsync(await PardakhtBussines.GetAllAsync(_token.Token)); } if (chbAdvisor.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebAdvisor.SaveAsync(await AdvisorBussines.GetAllAsync(_token.Token)); } if (chbBank.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebBank.SaveAsync(await BankBussines.GetAllAsync(_token.Token)); } if (chbKol.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebKol.SaveAsync(await KolBussines.GetAllAsync(_token.Token)); } if (chbMoein.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebMoein.SaveAsync(await MoeinBussines.GetAllAsync(_token.Token)); } if (chbTafsil.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebTafsil.SaveAsync(await TafsilBussines.GetAllAsync(_token.Token)); } if (chbSanad.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); await WebSanad.SaveAsync(await SanadBussines.GetAllAsync(_token.Token)); } Invoke(new MethodInvoker(() => MessageBox.Show("انتقال داده ها به سرور با موفقیت انجام شد"))); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } finally { Invoke(new MethodInvoker(() => { btnSend.Enabled = true; Cursor = Cursors.Default; })); } }
private async void btnSeach_Click(object sender, EventArgs e) { try { clsAdvertise.MaxFileCount = (int)txtMaxFile.Value; var list = new List <BuildingViewModel>(); decimal fPrice1 = 0, sPrice1 = 0, fPrice2 = 0, sPrice2 = 0; if (cmbRahn1.SelectedIndex == 0) { fPrice1 = txtFPrice1.Text.ParseToDecimal() * 10000; } if (cmbRahn1.SelectedIndex == 1) { fPrice1 = txtFPrice1.Text.ParseToDecimal() * 10000000; } if (cmbRahn1.SelectedIndex == 2) { fPrice1 = txtFPrice1.Text.ParseToDecimal() * 10000000000; } if (cmbRahn2.SelectedIndex == 0) { sPrice1 = txtFPrice2.Text.ParseToDecimal() * 10000; } if (cmbRahn2.SelectedIndex == 1) { sPrice1 = txtFPrice2.Text.ParseToDecimal() * 10000000; } if (cmbRahn2.SelectedIndex == 2) { sPrice1 = txtFPrice2.Text.ParseToDecimal() * 10000000000; } if (cmbEjare1.SelectedIndex == 0) { fPrice2 = txtSPrice1.Text.ParseToDecimal() * 10000; } if (cmbEjare1.SelectedIndex == 1) { fPrice2 = txtSPrice1.Text.ParseToDecimal() * 10000000; } if (cmbEjare1.SelectedIndex == 2) { fPrice2 = txtSPrice1.Text.ParseToDecimal() * 10000000000; } if (cmbEjare2.SelectedIndex == 0) { sPrice2 = txtSPrice2.Text.ParseToDecimal() * 10000; } if (cmbEjare2.SelectedIndex == 1) { sPrice2 = txtSPrice2.Text.ParseToDecimal() * 10000000; } if (cmbEjare2.SelectedIndex == 2) { sPrice2 = txtSPrice2.Text.ParseToDecimal() * 10000000000; } if (chbSystem.Checked) { _token?.Cancel(); _token = new CancellationTokenSource(); list.AddRange(await BuildingBussines.GetAllAsync(txtCode.Text, _token.Token, (Guid)cmbBuildingType.SelectedValue, (Guid)cmbBuildingAccountType.SelectedValue, txtFMasahat.Text.ParseToInt(), txtSMasahat.Text.ParseToInt(), txtRoomCount.Text.ParseToInt(), fPrice1, fPrice2, sPrice1, sPrice2, (EnRequestType)cmbReqType.SelectedIndex, RegionList)); } if (chbDivar.Checked) { var list_ = new List <string>(); foreach (var item in RegionList) { var related = await AdvertiseRelatedRegionBussines.GetByRegionGuidAsync(item); if (related != null) { list_.Add(related.OnlineRegionName); continue; } var region = await RegionsBussines.GetAsync(item); if (region != null) { list_.Add(region.Name); } } list_ = list_.GroupBy(q => q).Select(q => q.Key).ToList(); var divar = DivarAdv.GetInstance(); list.AddRange(await divar.GetBuildingAsync((EnRequestType)cmbReqType.SelectedIndex, fPrice1, sPrice1, fPrice2, sPrice2, txtFMasahat.Text.ParseToInt(), txtSMasahat.Text.ParseToInt(), (int)txtMaxFile.Value, list_)); } var frm = new frmBuildingAdvanceSearch(list); frm.ShowDialog(this); } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }
public static async Task InsertDefaultDataAsync() { var res = new ReturnedSaveFuncInfo(); SqlTransaction tr = null; SqlConnection cn = null; try { cn = new SqlConnection(Cache.ConnectionString); await cn.OpenAsync(); tr = cn.BeginTransaction(); #region Kol var allKol = await KolBussines.GetAllAsync(new CancellationToken()); if (allKol == null || allKol.Count <= 0) { var kol = DefaultKol.SetDef(); res.AddReturnedValue(await KolBussines.SaveRangeAsync(kol, tr)); if (res.HasError) { return; } } #endregion #region Moein var allMoein = await MoeinBussines.GetAllAsync(new CancellationToken()); if (allMoein == null || allMoein.Count <= 0) { var moein = DefaultMoein.SetDef(); res.AddReturnedValue(await MoeinBussines.SaveRangeAsync(moein, tr)); if (res.HasError) { return; } } #endregion #region Tafsil var allTafsil = await TafsilBussines.GetAllAsync(new CancellationToken()); if (allTafsil == null || allTafsil.Count <= 0) { var tafsil = DefaultTafsil.SetDef(); res.AddReturnedValue(await TafsilBussines.SaveRangeAsync(tafsil, tr)); if (res.HasError) { return; } } #endregion #region Bank var allBank = await BankBussines.GetAllAsync(new CancellationToken()); if (allBank == null || allBank.Count <= 0) { var user = new BankBussines() { Guid = ParentDefaults.TafsilCoding.CLSTafsil1010101, Name = "حساب بانکی مرکزی", Code = "1010101", }; res.AddReturnedValue(await user.SaveAsync(tr)); if (res.HasError) { return; } } #endregion #region Bank Segest var allbs = await BankSegestBussines.GetAllAsync(); if (allbs == null || allbs.Count <= 0) { var bs = DefaultBankSegest.SetDef(); res.AddReturnedValue(await BankSegestBussines.SaveRangeAsync(bs, tr)); if (res.HasError) { return; } } #endregion #region Users var allusers = await UserBussines.GetAllAsync(new CancellationToken()); var access = new AccessLevel(); if (allusers == null || allusers.Count <= 0) { var user = new UserBussines() { Guid = ParentDefaults.TafsilCoding.CLSTafsil1030401, Name = "کاربر پیش فرض", UserName = "******", SecurityQuestion = 0, Access = Json.ToStringJson(access) }; var ue = new UTF8Encoding(); var bytes = ue.GetBytes("2211"); var md5 = new MD5CryptoServiceProvider(); var hashBytes = md5.ComputeHash(bytes); user.Password = System.Text.RegularExpressions.Regex.Replace(BitConverter.ToString(hashBytes), "-", "") .ToLower(); res.AddReturnedValue(await user.SaveAsync(tr)); if (res.HasError) { return; } } #endregion #region States var allStates = await StatesBussines.GetAllAsync(new CancellationToken()); if (allStates == null || allStates.Count <= 0) { var states = DefaultStates.SetDef(); res.AddReturnedValue(await StatesBussines.SaveRangeAsync(states, tr)); if (res.HasError) { return; } } #endregion #region Cities var allCities = await CitiesBussines.GetAllAsync(new CancellationToken()); if (allCities == null || allCities.Count <= 0) { var city = DefaultCities.SetDef(); res.AddReturnedValue(await CitiesBussines.SaveRangeAsync(city, tr)); if (res.HasError) { return; } } #endregion #region Regions var allRegions = await RegionsBussines.GetAllAsync(new CancellationToken()); if (allRegions == null || allRegions.Count <= 0) { var reg = DefaultRegions.SetDef(); res.AddReturnedValue(await RegionsBussines.SaveRangeAsync(reg, tr)); if (res.HasError) { return; } } #endregion #region Naqz var allNaqz = await NaqzBussines.GetAllAsync(); if (allNaqz == null || allNaqz.Count <= 0) { var naqz = DefaultNaqz.SetDef(); res.AddReturnedValue(await NaqzBussines.SaveRangeAsync(naqz, tr)); if (res.HasError) { return; } } #endregion #region BuildingOption var allbo = await BuildingOptionsBussines.GetAllAsync(new CancellationToken()); if (allbo == null || allbo.Count <= 0) { var bo = DefaultBuildingOptions.SetDef(); res.AddReturnedValue(await BuildingOptionsBussines.SaveRangeAsync(bo, tr)); if (res.HasError) { return; } } #endregion #region BuildingAccountType var allbat = await BuildingAccountTypeBussines.GetAllAsync(new CancellationToken()); if (allbat == null || allbat.Count <= 0) { var bat = DefaultBuildingAccountType.SetDef(); res.AddReturnedValue(await BuildingAccountTypeBussines.SaveRangeAsync(bat, tr)); if (res.HasError) { return; } } #endregion #region FloorCover var allfc = await FloorCoverBussines.GetAllAsync(new CancellationToken()); if (allfc == null || allfc.Count <= 0) { var fc = DefaultFloorCover.SetDef(); res.AddReturnedValue(await FloorCoverBussines.SaveRangeAsync(fc, tr)); if (res.HasError) { return; } } #endregion #region KitchenService var allks = await KitchenServiceBussines.GetAllAsync(new CancellationToken()); if (allks == null || allks.Count <= 0) { var ks = DefaultKitchenService.SetDef(); res.AddReturnedValue(await KitchenServiceBussines.SaveRangeAsync(ks, tr)); if (res.HasError) { return; } } #endregion #region DocumentType var alldt = await DocumentTypeBussines.GetAllAsync(new CancellationToken()); if (alldt == null || alldt.Count <= 0) { var dt = DefaultDocumentType.SetDef(); res.AddReturnedValue(await DocumentTypeBussines.SaveRangeAsync(dt, tr)); if (res.HasError) { return; } } #endregion #region RentalAuthority var allra = await RentalAuthorityBussines.GetAllAsync(new CancellationToken()); if (allra == null || allra.Count <= 0) { var ra = DefaultRentalAuthority.SetDef(); res.AddReturnedValue(await RentalAuthorityBussines.SaveRangeAsync(ra, tr)); if (res.HasError) { return; } } #endregion #region BuildingView var allbv = await BuildingViewBussines.GetAllAsync(new CancellationToken()); if (allbv == null || allbv.Count <= 0) { var bv = DefaultBuildingView.SetDef(); res.AddReturnedValue(await BuildingViewBussines.SaveRangeAsync(bv, tr)); if (res.HasError) { return; } } #endregion #region BuildingCondition var allbc = await BuildingConditionBussines.GetAllAsync(new CancellationToken()); if (allbc == null || allbc.Count <= 0) { var bc = DefaultBuildingCondition.SetDef(); res.AddReturnedValue(await BuildingConditionBussines.SaveRangeAsync(bc, tr)); if (res.HasError) { return; } } #endregion #region BuildingType var allbt = await BuildingTypeBussines.GetAllAsync(new CancellationToken()); if (allbt == null || allbt.Count <= 0) { var bo = DefaultBuildingType.SetDef(); res.AddReturnedValue(await BuildingTypeBussines.SaveRangeAsync(bo, tr)); if (res.HasError) { return; } } #endregion #region PeopleGroup var allpg = await PeopleGroupBussines.GetAllAsync(); if (allpg == null || allpg.Count <= 0) { var reg = DefaultPeopleGroup.SetDef(); res.AddReturnedValue(await PeopleGroupBussines.SaveRangeAsync(reg, tr)); if (res.HasError) { return; } } #endregion #region Setting var allSetting = await SettingsBussines.GetAllAsync(); if (allSetting == null || allSetting.Count <= 0) { res.AddReturnedValue(SettingsBussines.Save("ArzeshAfzoude", "9", tr)); res.AddReturnedValue(SettingsBussines.Save("Tabdil", "2", tr)); if (res.HasError) { return; } } #endregion } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); res.AddReturnedValue(ex); } finally { res.AddReturnedValue(tr.TransactionDestiny(res.HasError)); res.AddReturnedValue(cn.CloseConnection()); } }
private async void mnuDelete_Click(object sender, EventArgs e) { var res = new ReturnedSaveFuncInfo(); try { if (DGrid.RowCount <= 0) { return; } if (DGrid.CurrentRow == null) { return; } var guid = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value; if (_st) { if (MessageBox.Show(this, $@"آیا از حذف {DGrid[dgName.Index, DGrid.CurrentRow.Index].Value} اطمینان دارید؟", "حذف", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } var prd = await RegionsBussines.GetAsync(guid); res.AddReturnedValue(await prd.ChangeStatusAsync(false)); } else { if (MessageBox.Show(this, $@"آیا از فعال کردن {DGrid[dgName.Index, DGrid.CurrentRow.Index].Value} اطمینان دارید؟", "حذف", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } var prd = await RegionsBussines.GetAsync(guid); res.AddReturnedValue(await prd.ChangeStatusAsync(true)); } } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); res.AddReturnedValue(ex); } finally { if (res.HasError) { var frm = new FrmShowErrorMessage(res, "خطا در تغییر وضعیت منطقه"); frm.ShowDialog(this); frm.Dispose(); } else { await LoadDataAsync(txtSearch.Text); } } }
private static async Task StartSendToServerAsync() { try { var list = await TempBussines.GetAllAsync(); while (true) { if (list == null || list.Count <= 0) { await Task.Delay(2000); continue; } foreach (var item in list) { switch (item.Type) { case EnTemp.States: var states = await StatesBussines.GetAsync(item.ObjectGuid); if (states != null) { await WebStates.SaveAsync(states); } break; case EnTemp.Cities: var city = await CitiesBussines.GetAsync(item.ObjectGuid); if (city != null) { await WebCity.SaveAsync(city); } break; case EnTemp.Region: var region = await RegionsBussines.GetAsync(item.ObjectGuid); if (region != null) { await WebRegion.SaveAsync(region); } break; case EnTemp.Users: var user = await UserBussines.GetAsync(item.ObjectGuid); if (user != null) { await WebUser.SaveAsync(user); } break; case EnTemp.PeopleGroups: var pg = await PeopleGroupBussines.GetAsync(item.ObjectGuid); if (pg != null) { await WebPeopleGroup.SaveAsync(pg); } break; case EnTemp.Peoples: var p = await PeoplesBussines.GetAsync(item.ObjectGuid); if (p != null) { await WebPeople.SaveAsync(p); } break; case EnTemp.BuildingAccountType: var acc = await BuildingAccountTypeBussines.GetAsync(item.ObjectGuid); if (acc != null) { await WebBuildingAccountType.SaveAsync(acc); } break; case EnTemp.BuildingCondition: var co = await BuildingConditionBussines.GetAsync(item.ObjectGuid); if (co != null) { await WebBuildingCondition.SaveAsync(co); } break; case EnTemp.BuildingType: var type = await BuildingTypeBussines.GetAsync(item.ObjectGuid); if (type != null) { await WebBuildingType.SaveAsync(type); } break; case EnTemp.BuildingView: var view = await BuildingViewBussines.GetAsync(item.ObjectGuid); if (view != null) { await WebBuildingView.SaveAsync(view); } break; case EnTemp.DocumentType: var doc = await DocumentTypeBussines.GetAsync(item.ObjectGuid); if (doc != null) { await WebDocumentType.SaveAsync(doc); } break; case EnTemp.FloorCover: var fc = await FloorCoverBussines.GetAsync(item.ObjectGuid); if (fc != null) { await WebFloorCover.SaveAsync(fc); } break; case EnTemp.KitchenService: var ks = await KitchenServiceBussines.GetAsync(item.ObjectGuid); if (ks != null) { await WebKitchenService.SaveAsync(ks); } break; case EnTemp.RentalAuthority: var ra = await RentalAuthorityBussines.GetAsync(item.ObjectGuid); if (ra != null) { await WebRental.SaveAsync(ra); } break; case EnTemp.BuildingOptions: var o = await BuildingOptionsBussines.GetAsync(item.ObjectGuid); if (o != null) { await WebBuildingOptions.SaveAsync(o); } break; case EnTemp.Building: var bu = await BuildingBussines.GetAsync(item.ObjectGuid); if (bu != null) { await WebBuilding.SaveAsync(bu, Application.StartupPath); } break; case EnTemp.Contract: var con = await ContractBussines.GetAsync(item.ObjectGuid); if (con != null) { await WebContract.SaveAsync(con); } break; case EnTemp.Requests: var req = await BuildingRequestBussines.GetAsync(item.ObjectGuid); if (req != null) { await WebBuildingRequest.SaveAsync(req); } break; case EnTemp.Reception: var rec = await ReceptionBussines.GetAsync(item.ObjectGuid); if (rec != null) { await WebReception.SaveAsync(rec); } break; case EnTemp.Pardakht: var pa = await PardakhtBussines.GetAsync(item.ObjectGuid); if (pa != null) { await WebPardakht.SaveAsync(pa); } break; case EnTemp.BuildingRelatedOptions: var re = await BuildingRelatedOptionsBussines.GetAsync(item.ObjectGuid); if (re != null) { await WebBuildingRelatedOptions.SaveAsync(re); } break; case EnTemp.RequestRegions: var rr = await BuildingRequestRegionBussines.GetAsync(item.ObjectGuid); if (rr != null) { await WebBuildingRequestRegion.SaveAsync(rr); } break; case EnTemp.PhoneBook: var ph = await PhoneBookBussines.GetAsync(item.ObjectGuid); if (ph != null) { await WebPhoneBook.SaveAsync(ph); } break; case EnTemp.Advisor: var ad = await AdvisorBussines.GetAsync(item.ObjectGuid); if (ad != null) { await WebAdvisor.SaveAsync(ad); } break; case EnTemp.Bank: var ba = await BankBussines.GetAsync(item.ObjectGuid); if (ba != null) { await WebBank.SaveAsync(ba); } break; case EnTemp.Kol: var kol = await KolBussines.GetAsync(item.ObjectGuid); if (kol != null) { await WebKol.SaveAsync(kol); } break; case EnTemp.Moein: var moein = await MoeinBussines.GetAsync(item.ObjectGuid); if (moein != null) { await WebMoein.SaveAsync(moein); } break; case EnTemp.Tafsil: var tafsil = await TafsilBussines.GetAsync(item.ObjectGuid); if (tafsil != null) { await WebTafsil.SaveAsync(tafsil); } break; case EnTemp.Sanad: var sa = await SanadBussines.GetAsync(item.ObjectGuid); if (sa != null) { await WebSanad.SaveAsync(sa); } break; case EnTemp.SanadDetail: var saD = await SanadDetailBussines.GetAsync(item.ObjectGuid); if (saD != null) { await WebSanadDetail.SaveAsync(saD); } break; } await item.RemoveAsync(); } await Task.Delay(2000); list = await TempBussines.GetAllAsync(); } } catch (Exception ex) { WebErrorLog.ErrorInstence.StartErrorLog(ex); } }