public async Task <BuildingRequestBussines> GetAsync(string _connectionString, Guid guid)
        {
            var list = new BuildingRequestBussines();

            try
            {
                using (var cn = new SqlConnection(_connectionString))
                {
                    var cmd = new SqlCommand("sp_BuildingRequest_Get", cn)
                    {
                        CommandType = CommandType.StoredProcedure
                    };
                    cmd.Parameters.AddWithValue("@guid", guid);
                    await cn.OpenAsync();

                    var dr = await cmd.ExecuteReaderAsync();

                    if (dr.Read())
                    {
                        list = LoadData(dr, true);
                    }
                    cn.Close();
                }
            }
            catch (Exception exception)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(exception);
            }

            return(list);
        }
Beispiel #2
0
        private static string Text(BuildingRequestBussines bu)
        {
            var res = "";

            try
            {
                res = Settings.Classes.Payamak.SayerText;

                if (res.Contains(Replacor.Request.DateSabt))
                {
                    res = res.Replace(Replacor.Request.DateSabt, bu.DateSh);
                }
                if (res.Contains(Replacor.Request.Name))
                {
                    var owner = PeoplesBussines.Get(bu.AskerGuid);
                    res = res.Replace(Replacor.Request.Name, owner?.Name);
                }
                if (res.Contains(Replacor.Request.UserName))
                {
                    var user = UserBussines.Get(bu.UserGuid);
                    res = res.Replace(Replacor.Request.UserName, user?.Name);
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }

            return(res);
        }
 public frmRequestMain()
 {
     InitializeComponent();
     cls                 = new BuildingRequestBussines();
     ucHeader.Text       = "افزودن تقاضای جدید";
     ucHeader.IsModified = cls.IsModified;
     WindowState         = FormWindowState.Maximized;
 }
Beispiel #4
0
        private async Task RefreshLables()
        {
            try
            {
                var allBuilding = await BuildingBussines.DbCount(Guid.Empty, 0);

                var myBuilding = await BuildingBussines.DbCount(UserBussines.CurrentUser.Guid, 0);

                var rahn = await BuildingBussines.DbCount(Guid.Empty, 1);

                var foroush = await BuildingBussines.DbCount(Guid.Empty, 2);

                var allReq = await BuildingRequestBussines.DbCount(Guid.Empty);

                var myReq = await BuildingRequestBussines.DbCount(UserBussines.CurrentUser.Guid);

                var myCon = await ContractBussines.DbCount(UserBussines.CurrentUser.Guid);

                var disCharge = await ContractBussines.DischargeDbCount();

                BirthdayList = await PeoplesBussines.GetAllBirthDayAsync(Calendar.MiladiToShamsi(DateTime.Now));

                var minDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
                var maxDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);

                allNote = await NoteBussines.GetAllAsync();

                allNote = allNote.Where(q =>
                                        q.DateSarresid != null && q.DateSarresid >= minDate &&
                                        q.DateSarresid <= maxDate)
                          .ToList();

                Invoke(new MethodInvoker(() =>
                {
                    lblAllBiulding.Text = allBuilding.ToString();
                    lblMyBuilding.Text  = myBuilding.ToString();
                    lblAllRahn.Text     = rahn.ToString();
                    lblAllForoush.Text  = foroush.ToString();
                    lblAllRequest.Text  = allReq.ToString();
                    lblMyRequest.Text   = myReq.ToString();
                    lblMyContract.Text  = myCon.ToString();
                    lblBirthday.Text    = BirthdayList.Count.ToString();
                    lblNotes.Text       = allNote.Count.ToString();
                    //lblReceptionCheck.Text = receptionCheck.ToString();
                    //lblPardakhtCheck.Text = pardakhtCheck.ToString();
                    lblSarresidEjare.Text    = disCharge.ToString();
                    btnBirthday.Enabled      = BirthdayList.Count != 0;
                    btnReminderNotes.Enabled = allNote.Count != 0;
                    //btnReceptionCheck.Enabled = receptionCheck != 0;
                    //btnPardakhtCheck.Enabled = pardakhtCheck != 0;
                    btnDischarge.Enabled = disCharge != 0;
                }));
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Beispiel #5
0
        private void mnuShowBuilding_Click(object sender, EventArgs e)
        {
            try
            {
                if (DGrid.RowCount <= 0)
                {
                    return;
                }
                if (DGrid.CurrentRow == null)
                {
                    return;
                }
                var guid = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                var req  = BuildingRequestBussines.Get(guid);
                if (req == null)
                {
                    return;
                }

                var     type = EnRequestType.Rahn;
                decimal fPrice1 = 0, sPrice1 = 0, fPrice2 = 0, sPrice2 = 0;

                if (req.SellPrice1 > 0)
                {
                    type = EnRequestType.Forush;
                }
                if (req.RahnPrice1 > 0)
                {
                    type = EnRequestType.Rahn;
                }

                if (type == EnRequestType.Forush)
                {
                    fPrice1 = req.SellPrice1;
                    fPrice2 = req.SellPrice2;
                }
                else
                {
                    fPrice1 = req.RahnPrice1;
                    fPrice2 = req.RahnPrice2;
                    sPrice1 = req.EjarePrice1;
                    sPrice2 = req.EjarePrice2;
                }

                var frm = new frmFilterForm(type, req.BuildingTypeGuid, req.BuildingAccountTypeGuid, req.RoomCount,
                                            req.Masahat1, req.Masahat2, fPrice1, sPrice1, fPrice2, sPrice2,
                                            req.RegionList.Select(q => q.RegionGuid).ToList());
                frm.ShowDialog(this);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Beispiel #6
0
        public static async Task <List <BuildingRequestViewModel> > GetAllMatchesItemsAsync(List <BuildingBussines> allBuilding, CancellationToken token)
        {
            var list = new List <BuildingRequestViewModel>();

            try
            {
                foreach (var item in allBuilding)
                {
                    decimal       price1, price2;
                    EnRequestType type;
                    if (item.SellPrice > 0)
                    {
                        price1 = item.SellPrice;
                        price2 = 0;
                        type   = EnRequestType.Forush;
                    }
                    else
                    {
                        price1 = item.RahnPrice1;
                        price2 = item.EjarePrice1;
                        type   = EnRequestType.Rahn;
                    }
                    var reqList = await BuildingRequestBussines.GetAllAsync(type, token, price1, price2, item.Masahat,
                                                                            item.RoomCount, item.BuildingAccountTypeGuid, item.BuildingConditionGuid, item.RegionGuid);

                    if (reqList == null || reqList.Count <= 0)
                    {
                        continue;
                    }
                    var a = new BuildingRequestViewModel()
                    {
                        SellPrice               = item.SellPrice,
                        BuildingGuid            = item.Guid,
                        BuildingTypeName        = item.BuildingTypeName,
                        BuildingAccountTypeName = item.BuildingAccountTypeName,
                        OwnerName               = item.OwnerName,
                        EjarePrice              = item.EjarePrice1,
                        RahnPrice               = item.RahnPrice1,
                        BuildingCode            = item.Code,
                        RequestCount            = reqList.Count,
                        RequestList             = reqList
                    };
                    list.Add(a);
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }

            return(list);
        }
 public frmRequestMain(Guid guid, bool isShowMode)
 {
     InitializeComponent();
     cls                           = BuildingRequestBussines.Get(guid);
     asker                         = PeoplesBussines.Get(cls.AskerGuid);
     ucHeader.Text                 = !isShowMode ? $"ویرایش تقاضای {cls.AskerName}" : $"مشاهده تقاضای {cls.AskerGuid}";
     ucHeader.IsModified           = cls.IsModified;
     superTabControlPanel1.Enabled = !isShowMode;
     superTabControlPanel2.Enabled = !isShowMode;
     superTabControlPanel3.Enabled = !isShowMode;
     btnFinish.Enabled             = !isShowMode;
     superTabControl1.SelectedTab  = superTabItem1;
     WindowState                   = FormWindowState.Maximized;
 }
        public async Task <ReturnedSaveFuncInfo> SaveAsync(BuildingRequestBussines item, SqlTransaction tr)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var cmd = new SqlCommand("sp_BuildingRequest_Save", tr.Connection, tr)
                {
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.AddWithValue("@guid", item.Guid);
                cmd.Parameters.AddWithValue("@st", item.Status);
                cmd.Parameters.AddWithValue("@createDtae", item.CreateDate);
                cmd.Parameters.AddWithValue("@modif", item.Modified);
                cmd.Parameters.AddWithValue("@askerGuid", item.AskerGuid);
                cmd.Parameters.AddWithValue("@userGuid", item.UserGuid);
                cmd.Parameters.AddWithValue("@sellPrice1", item.SellPrice1);
                cmd.Parameters.AddWithValue("@sellPrice2", item.SellPrice2);
                cmd.Parameters.AddWithValue("@hasVam", item.HasVam);
                cmd.Parameters.AddWithValue("@rahn1", item.RahnPrice1);
                cmd.Parameters.AddWithValue("@rahn2", item.RahnPrice2);
                cmd.Parameters.AddWithValue("@ejare1", item.EjarePrice1);
                cmd.Parameters.AddWithValue("@ejare2", item.EjarePrice2);
                cmd.Parameters.AddWithValue("@peopleCount", item.PeopleCount);
                cmd.Parameters.AddWithValue("@hasOwner", item.HasOwner);
                cmd.Parameters.AddWithValue("@shortDate", item.ShortDate);
                cmd.Parameters.AddWithValue("@rentalGuid", item.RentalAutorityGuid);
                cmd.Parameters.AddWithValue("@cityGuid", item.CityGuid);
                cmd.Parameters.AddWithValue("@typeGuid", item.BuildingTypeGuid);
                cmd.Parameters.AddWithValue("@masahat1", item.Masahat1);
                cmd.Parameters.AddWithValue("@masahat2", item.Masahat2);
                cmd.Parameters.AddWithValue("@roomCount", item.RoomCount);
                cmd.Parameters.AddWithValue("@accTypeGuid", item.BuildingAccountTypeGuid);
                cmd.Parameters.AddWithValue("@conditionGuid", item.BuildingConditionGuid);
                cmd.Parameters.AddWithValue("@shortDesc", item.ShortDesc ?? "");
                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);
        }
        public static async Task <ReturnedSaveFuncInfo> SaveAsync(BuildingRequestBussines cls)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var obj = new WebBuildingRequest()
                {
                    Guid                    = cls.Guid,
                    Modified                = cls.Modified,
                    Status                  = cls.Status,
                    EjarePrice1             = cls.EjarePrice1,
                    RahnPrice1              = cls.RahnPrice1,
                    RoomCount               = cls.RoomCount,
                    BuildingAccountTypeGuid = cls.BuildingAccountTypeGuid,
                    UserGuid                = cls.UserGuid,
                    BuildingTypeGuid        = cls.BuildingTypeGuid,
                    EjarePrice2             = cls.EjarePrice2,
                    RentalAutorityGuid      = cls.RentalAutorityGuid,
                    ShortDesc               = cls.ShortDesc,
                    CityGuid                = cls.CityGuid,
                    CreateDate              = cls.CreateDate,
                    RahnPrice2              = cls.RahnPrice2,
                    SellPrice2              = cls.SellPrice2,
                    BuildingConditionGuid   = cls.BuildingConditionGuid,
                    AskerGuid               = cls.AskerGuid,
                    SellPrice1              = cls.SellPrice1,
                    Masahat1                = cls.Masahat1,
                    Masahat2                = cls.Masahat2,
                    PeopleCount             = cls.PeopleCount,
                    ShortDate               = cls.ShortDate,
                    HasVam                  = cls.HasVam,
                    HasOwner                = cls.HasOwner,
                    HardSerial              = cls.HardSerial,
                    RegionList              = cls.RegionList,
                    ServerStatus            = cls.ServerStatus,
                    ServerDeliveryDate      = cls.ServerDeliveryDate
                };
                await obj.SaveAsync();
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }
Beispiel #10
0
        private async Task LoadDataAsync(string search = "")
        {
            try
            {
                _token?.Cancel();
                _token = new CancellationTokenSource();
                _list  = await BuildingRequestBussines.GetAllAsync(search, _token.Token);

                Invoke(new MethodInvoker(() => reqBindingSource.DataSource =
                                             _list.Where(q => q.Status == _st).OrderByDescending(q => q.CreateDate).ToSortableBindingList()));
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
Beispiel #11
0
        private async Task SetDataAsync()
        {
            try
            {
                var bu = await BuildingBussines.DbCount(Guid.Empty, 0);

                var req = await BuildingRequestBussines.DbCount(Guid.Empty);

                lblBuildingCount.Text = bu.ToString();
                lblRequestCount.Text  = req.ToString();
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }
        private BuildingRequestBussines LoadData(SqlDataReader dr, bool isLoadDet)
        {
            var res = new BuildingRequestBussines();

            try
            {
                res.Guid                    = (Guid)dr["Guid"];
                res.Modified                = (DateTime)dr["Modified"];
                res.Status                  = (bool)dr["Status"];
                res.AskerGuid               = (Guid)dr["AskerGuid"];
                res.CreateDate              = (DateTime)dr["CreateDate"];
                res.UserGuid                = (Guid)dr["UserGuid"];
                res.SellPrice1              = (decimal)dr["SellPrice1"];
                res.SellPrice2              = (decimal)dr["SellPrice2"];
                res.HasVam                  = (bool?)dr["HasVam"];
                res.RahnPrice1              = (decimal)dr["RahnPrice1"];
                res.RahnPrice2              = (decimal)dr["RahnPrice2"];
                res.EjarePrice1             = (decimal)dr["EjarePrice1"];
                res.EjarePrice2             = (decimal)dr["EjarePrice2"];
                res.PeopleCount             = (short?)dr["PeopleCount"];
                res.HasOwner                = (bool?)dr["HasOwner"];
                res.ShortDate               = (bool?)dr["ShortDate"];
                res.RentalAutorityGuid      = (Guid?)dr["RentalAutorityGuid"];
                res.CityGuid                = (Guid)dr["CityGuid"];
                res.BuildingTypeGuid        = (Guid)dr["BuildingTypeGuid"];
                res.Masahat1                = (int)dr["Masahat1"];
                res.Masahat2                = (int)dr["Masahat2"];
                res.RoomCount               = (int)dr["RoomCount"];
                res.BuildingAccountTypeGuid = (Guid)dr["BuildingAccountTypeGuid"];
                res.BuildingConditionGuid   = (Guid)dr["BuildingConditionGuid"];
                res.ShortDesc               = dr["ShortDesc"].ToString();
                res.UserName                = dr["UserName"].ToString();
                res.ServerDeliveryDate      = (DateTime)dr["ServerDeliveryDate"];
                res.ServerStatus            = (ServerStatus)dr["ServerStatus"];
                res.IsModified              = true;
                if (isLoadDet)
                {
                    res.RegionList = AsyncContext.Run(() => BuildingRequestRegionBussines.GetAllAsync(res.Guid));
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }

            return(res);
        }
        public async Task <ReturnedSaveFuncInfo> ChangeStatusAsync(BuildingRequestBussines item, bool status, SqlTransaction tr)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var cmd = new SqlCommand("sp_BuildingRequest_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);
        }
Beispiel #14
0
        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);
            }
        }
        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;
                }));
            }
        }
Beispiel #16
0
        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 BuildingRequestBussines.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 BuildingRequestBussines.GetAsync(guid);

                    res.AddReturnedValue(await prd.ChangeStatusAsync(true));
                }

                await LoadDataAsync(txtSearch.Text);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (res.HasError)
                {
                    var frm = new FrmShowErrorMessage(res, "خطا در تغییر وضعیت تقاضا");
                    frm.ShowDialog(this);
                    frm.Dispose();
                }
            }
        }
Beispiel #17
0
        public static async Task <ReturnedSaveFuncInfo> SendAsync(BuildingRequestBussines bu)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                res.AddReturnedValue(await Utilities.PingHostAsync());
                if (res.HasError)
                {
                    return(res);
                }


                var text = Text(bu);
                if (string.IsNullOrEmpty(text))
                {
                    res.AddReturnedValue(ReturnedState.Error, "متن پیش فرض خالی می باشد");
                    return(res);
                }

                if (string.IsNullOrEmpty(Settings.Classes.Payamak.DefaultPanelGuid))
                {
                    res.AddReturnedValue(ReturnedState.Error, "پنل پبش فرض تعریف نشده است");
                    return(res);
                }

                var panel = SmsPanelsBussines.Get(Guid.Parse(Settings.Classes.Payamak.DefaultPanelGuid));
                if (panel == null)
                {
                    res.AddReturnedValue(ReturnedState.Error, "پنل پیش فرض معتبر نمی باشد");
                    return(res);
                }

                var sApi = new Sms.Api(panel.API.Trim());

                var list = new List <string>();
                var pe   = await PhoneBookBussines.GetAllAsync(bu.AskerGuid, true);

                foreach (var item in pe)
                {
                    list.Add(item.Tell);
                }

                var res_ = sApi.Send(panel.Sender, list, text);
                if (res_.Count <= 0)
                {
                    res.AddReturnedValue(ReturnedState.Error, "ارتباط با پنل با شکست مواجه شد");
                    return(res);
                }

                foreach (var result in res_)
                {
                    var smsLog = new SmsLogBussines()
                    {
                        Guid       = Guid.NewGuid(),
                        UserGuid   = UserBussines.CurrentUser.Guid,
                        Cost       = result.Cost,
                        Message    = result.Message,
                        MessageId  = result.Messageid,
                        Reciver    = result.Receptor,
                        Sender     = result.Sender,
                        StatusText = result.StatusText
                    };

                    await smsLog.SaveAsync();
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }