public IEnumerable <BuildingListViewModel> GetLastList(EnRequestType type)
        {
            var list = new List <BuildingListViewModel>();

            try
            {
                var headers = Request.Headers?.ToList();
                if (headers == null || headers.Count <= 0)
                {
                    return(null);
                }
                var guid = Request.Headers.GetValues("cusGuid").FirstOrDefault();
                if (string.IsNullOrEmpty(guid))
                {
                    return(list);
                }
                var cusGuid = Guid.Parse(guid);
                if (!Assistence.CheckCustomer(cusGuid))
                {
                    return(list);
                }
                list = BuildingBussines.GetAllBuildingListViewModel(cusGuid, type);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }

            return(list);
        }
        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 async Task <BuildingBussines> GetAsync(string _connectionString, Guid guid)
        {
            var list = new BuildingBussines();

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

                    var dr = await cmd.ExecuteReaderAsync();

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

            return(list);
        }
 public Divar_OfficeStoreRent(BuildingBussines building, int imgCount, bool giveChat, string ersalKonnade)
 {
     bu           = building;
     fixValue     = new Divar_SetFixValue(building, imgCount);
     isGiveChat   = giveChat;
     agahiDahande = ersalKonnade;
 }
 public Divar_ResidentialApartmentSell(BuildingBussines building, int imgCount, bool giveChat, string ersalKonnade)
 {
     bu           = building;
     fixValue     = new Divar_SetFixValue(building, imgCount);
     isGiveChat   = giveChat;
     agahiDahande = ersalKonnade;
 }
Esempio n. 6
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);
            }
        }
 public frmBuildingMainFast()
 {
     InitializeComponent();
     WindowState                  = FormWindowState.Maximized;
     cls                          = new BuildingBussines();
     ucHeader.Text                = "افزودن ملک جدید";
     ucHeader.IsModified          = cls.IsModified;
     superTabControl1.SelectedTab = superTabItem1;
     superTabControl2.SelectedTab = superTabItem8;
 }
 private async Task NextCodeAsync()
 {
     try
     {
         txtCode.Text = await BuildingBussines.NextCodeAsync() ?? "";
     }
     catch (Exception ex)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(ex);
     }
 }
Esempio n. 9
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);
            }
        }
Esempio n. 10
0
        public static async Task <ReturnedSaveFuncInfo> FixBuildingImage()
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                res.AddReturnedValue(await BuildingBussines.FixImageAsync());
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }
Esempio n. 11
0
 private void btnBuildingSearch_Click(object sender, EventArgs e)
 {
     try
     {
         var frm = new frmShowBuildings(true, null, true, fSide?.Guid ?? Guid.Empty);
         if (frm.ShowDialog(this) != DialogResult.OK)
         {
             return;
         }
         building = BuildingBussines.Get(frm.SelectedGuid);
         LoadBuilding();
     }
     catch (Exception ex)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(ex);
     }
 }
        private async Task <string> SetDivarCityAsync(BuildingBussines bu)
        {
            var city = "";

            try
            {
                var c = await CitiesBussines.GetAsync(bu.CityGuid);

                city = c?.Name ?? "";
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }

            return(city);
        }
Esempio n. 13
0
 public frmContractMain(Guid guid, bool isShowMode)
 {
     InitializeComponent();
     WindowState = FormWindowState.Maximized;
     cls         = ContractBussines.Get(guid);
     fSide       = PeoplesBussines.Get(cls.FirstSideGuid);
     sSide       = PeoplesBussines.Get(cls.SecondSideGuid);
     building    = BuildingBussines.Get(cls.BuildingGuid);
     superTabControl1.SelectedTab   = superTabItem5;
     superTabControl2.SelectedTab   = superTabItem8;
     superTabControlPanel1.Enabled  = !isShowMode;
     superTabControlPanel2.Enabled  = !isShowMode;
     superTabControlPanel3.Enabled  = !isShowMode;
     superTabControlPanel4.Enabled  = !isShowMode;
     superTabControlPanel5.Enabled  = !isShowMode;
     superTabControlPanel6.Enabled  = !isShowMode;
     superTabControlPanel7.Enabled  = !isShowMode;
     superTabControlPanel10.Enabled = !isShowMode;
     superTabControlPanel8.Enabled  = !isShowMode;
     superTabControlPanel11.Enabled = !isShowMode;
     btnFinish.Enabled = !isShowMode;
 }
Esempio n. 14
0
        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);
        }
        private async Task <string> SetDivarStateAsync(BuildingBussines bu)
        {
            var state = "";

            try
            {
                var c = await CitiesBussines.GetAsync(bu.CityGuid);

                if (c == null || c.StateGuid == Guid.Empty)
                {
                    return(state);
                }
                var st = await StatesBussines.GetAsync(c.StateGuid);

                state = st?.Name ?? "";
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }

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

            try
            {
                var cmd = new SqlCommand("sp_Building_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);
        }
        private BuildingBussines LoadData(SqlDataReader dr)
        {
            var res = new BuildingBussines();

            try
            {
                res.Guid         = (Guid)dr["Guid"];
                res.OwnerGuid    = (Guid)dr["OwnerGuid"];
                res.SellPrice    = (decimal)dr["SellPrice"];
                res.Modified     = (DateTime)dr["Modified"];
                res.Status       = (bool)dr["Status"];
                res.Code         = dr["Code"].ToString();
                res.VamPrice     = (decimal)dr["VamPrice"];
                res.QestPrice    = (decimal)dr["QestPrice"];
                res.Dang         = (int)dr["Dang"];
                res.DocumentType = (Guid)dr["DocumentType"];
                var tr = dr["Tarakom"].ToString().ParseToShort();
                res.Tarakom     = (EnTarakom?)tr;
                res.RahnPrice1  = (decimal)dr["RahnPrice1"];
                res.RahnPrice2  = (decimal)dr["RahnPrice2"];
                res.EjarePrice1 = (decimal)dr["EjarePrice1"];
                res.EjarePrice2 = (decimal)dr["EjarePrice2"];
                if (dr["RentalAutorityGuid"] != DBNull.Value)
                {
                    res.RentalAutorityGuid = (Guid?)dr["RentalAutorityGuid"];
                }
                res.IsShortTime    = (bool)dr["IsShortTime"];
                res.IsOwnerHere    = (bool)dr["IsOwnerHere"];
                res.PishTotalPrice = (decimal)dr["PishTotalPrice"];
                res.PishPrice      = (decimal)dr["PishPrice"];
                if (dr["DeliveryDate"] != DBNull.Value)
                {
                    res.DeliveryDate = (DateTime?)dr["DeliveryDate"];
                }
                res.PishDesc              = dr["PishDesc"].ToString();
                res.MoavezeDesc           = dr["MoavezeDesc"].ToString();
                res.MosharekatDesc        = dr["MosharekatDesc"].ToString();
                res.UserGuid              = (Guid)dr["UserGuid"];
                res.Masahat               = (int)dr["Masahat"];
                res.ZirBana               = (int)dr["ZirBana"];
                res.CityGuid              = (Guid)dr["CityGuid"];
                res.RegionGuid            = (Guid)dr["RegionGuid"];
                res.Address               = dr["Address"].ToString();
                res.BuildingConditionGuid = (Guid)dr["BuildingConditionGuid"];
                res.Side                    = (EnBuildingSide)dr["Side"];
                res.BuildingTypeGuid        = (Guid)dr["BuildingTypeGuid"];
                res.ShortDesc               = dr["ShortDesc"].ToString();
                res.BuildingAccountTypeGuid = (Guid)dr["BuildingAccountTypeGuid"];
                res.MetrazhTejari           = (float)dr["MetrazhTejari"];
                res.BuildingViewGuid        = (Guid)dr["BuildingViewGuid"];
                res.FloorCoverGuid          = (Guid)dr["FloorCoverGuid"];
                res.KitchenServiceGuid      = (Guid)dr["KitchenServiceGuid"];
                res.Water                   = (EnKhadamati)dr["Water"];
                res.Barq                    = (EnKhadamati)dr["Barq"];
                res.Gas                     = (EnKhadamati)dr["Gas"];
                res.Tell                    = (EnKhadamati)dr["Tell"];
                res.TedadTabaqe             = (int)dr["TedadTabaqe"];
                res.TabaqeNo                = (int)dr["TabaqeNo"];
                res.VahedPerTabaqe          = (int)dr["VahedPerTabaqe"];
                res.MetrazhKouche           = (float)dr["MetrazhKouche"];
                res.ErtefaSaqf              = (float)dr["ErtefaSaqf"];
                res.Hashie                  = (float)dr["Hashie"];
                res.SaleSakht               = dr["SaleSakht"].ToString();
                res.DateParvane             = dr["DateParvane"].ToString();
                res.ParvaneSerial           = dr["ParvaneSerial"].ToString();
                res.BonBast                 = (bool)dr["BonBast"];
                res.MamarJoda               = (bool)dr["MamarJoda"];
                res.RoomCount               = (int)dr["RoomCount"];
                res.CreateDate              = (DateTime)dr["CreateDate"];
                res.Image                   = dr["Image"].ToString();
                res.Priority                = (EnBuildingPriority)dr["Priority"];
                res.IsArchive               = (bool)dr["IsArchive"];
                res.GalleryList             = AsyncContext.Run(() => BuildingGalleryBussines.GetAllAsync(res.Guid));
                res.OptionList              = BuildingRelatedOptionsBussines.GetAll(res.Guid);
                res.ServerDeliveryDate      = (DateTime)dr["ServerDeliveryDate"];
                res.ServerStatus            = (ServerStatus)dr["ServerStatus"];
                res.OwnerName               = dr["OwnerName"].ToString();
                res.BuildingTypeName        = dr["BuildingTypeName"].ToString();
                res.UserName                = dr["UserName"].ToString();
                res.RegionName              = dr["RegionName"].ToString();
                res.RentalAuthorityName     = dr["RentalAuthorityName"].ToString();
                res.DocumentTypeName        = dr["DocumentTypeName"].ToString();
                res.BuildingConditionName   = dr["BuildingConditionName"].ToString();
                res.BuildingViewName        = dr["BuildingViewName"].ToString();
                res.FloorCoverName          = dr["FloorCoverName"].ToString();
                res.KitchenServiceName      = dr["KitchenServiceName"].ToString();
                res.BuildingAccountTypeName = dr["BuildingAccountTypeName"].ToString();
                res.IsModified              = true;
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }

            return(res);
        }
        private List <string> GetNextImages(BuildingBussines bu, int imgCount)
        {
            var resultImages = new List <string>();

            try
            {
                //گرفتن تمام عکسهای پوشه و فیلتر کردن عکسهای درست
                var advFullPath  = bu.GalleryList.Select(q => q.ImageName);
                var allImages    = new List <string>();
                var imageAddress = Path.Combine(Application.StartupPath, "Images");
                foreach (var imgName in advFullPath)
                {
                    string fullPath;
                    if (!imgName.EndsWith(".jpg") && !imgName.EndsWith(".png"))
                    {
                        fullPath = Path.Combine(imageAddress, imgName + ".jpg");
                    }
                    else
                    {
                        fullPath = Path.Combine(imageAddress, imgName);
                    }
                    if (!File.Exists(fullPath))
                    {
                        continue;
                    }
                    allImages.Add(fullPath);
                }
                var selectedImages = new List <string>();
                //حذف عکسهای زیر پیکسل 600*600
                foreach (var imgItem in allImages)
                {
                    var img = Image.FromFile(imgItem);
                    if (img.Width < 600 || img.Height < 600)
                    {
                        try
                        {
                            img.Dispose();
                            File.Delete(imgItem);
                        }
                        catch
                        {
                            /**/
                        }
                    }
                    img.Dispose();
                }

                if (allImages.Count <= imgCount)
                {
                    selectedImages = allImages;
                }
                else
                {
                    var indexes = new List <int>();
                    var rnd     = new Random();
                    while (indexes.Count < imgCount)
                    {
                        var index = rnd.Next(allImages.Count);
                        if (!indexes.Contains(index))
                        {
                            indexes.Add(index);
                        }
                    }

                    selectedImages.AddRange(indexes.Select(index => allImages[index]));
                }


                //ویرایش عکسها
                foreach (var img in selectedImages)
                {
                    resultImages.Add(ImageManager.ModifyImage(img));
                }

                return(resultImages);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                return(resultImages);
            }
        }
 public Divar_SetFixValue(BuildingBussines _bu, int imgCount)
 {
     bu         = _bu;
     imageCount = imgCount;
 }
Esempio n. 20
0
        //private static async Task<ReturnedSaveFuncInfo> SendChat_(long number, Guid visitorGuid)
        //{
        //    var res = new ReturnedSaveFuncInfo();
        //    try
        //    {
        //        AdvDepartmentBusiness dep;
        //        if (visitorGuid == Guid.Empty)
        //            dep = await AdvDepartmentBusiness.GetAsync("نوین پرداز");
        //        else
        //        {
        //            var visitor = await VisitorBusiness.GetAsync(visitorGuid);
        //            dep = await AdvDepartmentBusiness.GetAsync(visitor?.DepartmentGuid ?? Guid.Empty);
        //        }

        //        if (dep == null)
        //        {
        //            res.AddReturnedValue(ReturnedState.Error, "Department is Null");
        //            return res;
        //        }

        //        if (!dep.IsSendChat)
        //        {
        //            res.AddReturnedValue(ReturnedState.Error, "Dont Permition Send Chat");
        //            return res;
        //        }
        //        var list = new List<string>();
        //        if (!string.IsNullOrEmpty(dep.ChatList.Desc1)) list.Add(dep.ChatList.Desc1);
        //        if (!string.IsNullOrEmpty(dep.ChatList.Desc2)) list.Add(dep.ChatList.Desc2);
        //        if (!string.IsNullOrEmpty(dep.ChatList.Desc3)) list.Add(dep.ChatList.Desc3);
        //        if (!string.IsNullOrEmpty(dep.ChatList.Desc4)) list.Add(dep.ChatList.Desc4);
        //        if (!string.IsNullOrEmpty(dep.ChatList.Desc5)) list.Add(dep.ChatList.Desc5);
        //        if (!string.IsNullOrEmpty(dep.ChatList.Desc6)) list.Add(dep.ChatList.Desc6);
        //        if (!string.IsNullOrEmpty(dep.ChatList.Desc7)) list.Add(dep.ChatList.Desc7);
        //        if (!string.IsNullOrEmpty(dep.ChatList.Desc8)) list.Add(dep.ChatList.Desc8);
        //        if (!string.IsNullOrEmpty(dep.ChatList.Desc9)) list.Add(dep.ChatList.Desc9);
        //        if (!string.IsNullOrEmpty(dep.ChatList.Desc10)) list.Add(dep.ChatList.Desc10);

        //        var cityList = new List<string>();
        //        if (!string.IsNullOrEmpty(dep.ChatCity.City1)) cityList.Add(dep.ChatCity.City1);
        //        if (!string.IsNullOrEmpty(dep.ChatCity.City2)) cityList.Add(dep.ChatCity.City2);
        //        if (!string.IsNullOrEmpty(dep.ChatCity.City3)) cityList.Add(dep.ChatCity.City3);
        //        if (!string.IsNullOrEmpty(dep.ChatCity.City4)) cityList.Add(dep.ChatCity.City4);
        //        if (!string.IsNullOrEmpty(dep.ChatCity.City5)) cityList.Add(dep.ChatCity.City5);
        //        if (!string.IsNullOrEmpty(dep.ChatCity.City6)) cityList.Add(dep.ChatCity.City6);
        //        if (!string.IsNullOrEmpty(dep.ChatCity.City7)) cityList.Add(dep.ChatCity.City7);
        //        if (!string.IsNullOrEmpty(dep.ChatCity.City8)) cityList.Add(dep.ChatCity.City8);
        //        if (!string.IsNullOrEmpty(dep.ChatCity.City9)) cityList.Add(dep.ChatCity.City9);
        //        if (!string.IsNullOrEmpty(dep.ChatCity.City10)) cityList.Add(dep.ChatCity.City10);
        //        var rand = new Random().Next(0, cityList.Count);
        //        var catList = await DepartmentCategoryBusiness.GetAllAsync(dep.Guid);
        //        var rnd = new Random().Next(0, catList.ToList().Count);
        //        var d = DivarAdv.GetInstance();
        //        await d.SendChat(number, list, dep.ChatCount, cityList[rand], catList[rnd].FirstLevel,
        //            catList[rnd].SecondLevel,
        //            catList[rnd].ThirdLevel, false);
        //    }
        //    catch (Exception ex)
        //    {
        //        WebErrorLog.ErrorLogInstance.StartLog(ex);
        //        res.AddReturnedValue(ex);
        //    }

        //    return res;
        //}
        #endregion


        private static async Task <ReturnedSaveFuncInfo> SendDivarAdv(BuildingBussines bu, long simCardNumber, bool isGiveChat, string sender, int imageCount)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var accType = await BuildingAccountTypeBussines.GetAsync(bu.BuildingAccountTypeGuid);

                if (accType == null)
                {
                    res.AddError("کاربری ملک معتبر نمی باشد");
                    return(res);
                }

                if (bu.RahnPrice1 > 0 || bu.RahnPrice2 > 0 || bu.EjarePrice1 > 0 || bu.EjarePrice2 > 0)
                {
                    if (accType.Name.Contains("مسکونی") && !accType.Name.Contains("زمین"))
                    {
                        var type = await BuildingTypeBussines.GetAsync(bu.BuildingTypeGuid);

                        if (type == null)
                        {
                            res.AddError("نوع ملک معتبر نمی باشد");
                            return(res);
                        }
                        if (type.Name.Contains("پارتمان"))
                        {
                            var ret = new Divar_ResidentialApartmentRent(bu, imageCount, isGiveChat, sender);
                            res.AddReturnedValue(await ret.SendAsync(simCardNumber));
                            return(res);
                        }
                        if (type.Name.Contains("خانه") || accType.Name.Contains("ویلا"))
                        {
                            var ret = new Divar_ResidentialVillaRent(bu, imageCount, isGiveChat, sender);
                            res.AddReturnedValue(await ret.SendAsync(simCardNumber));
                            return(res);
                        }
                    }
                    if (accType.Name.Contains("دفتر") || accType.Name.Contains("اداری") || accType.Name.Contains("مطب"))
                    {
                        var ret = new Divar_OfficeOfficeRent(bu, imageCount, isGiveChat, sender);
                        res.AddReturnedValue(await ret.SendAsync(simCardNumber));
                        return(res);
                    }
                    if (accType.Name.Contains("صنعتی") || accType.Name.Contains("کشاورزی") ||
                        accType.Name.Contains("دامداری") || accType.Name.Contains("مرغداری") ||
                        accType.Name.Contains("زراعی"))
                    {
                        var ret = new Divar_OfficeKeshavarziRent(bu, imageCount, isGiveChat, sender);
                        res.AddReturnedValue(await ret.SendAsync(simCardNumber));
                        return(res);
                    }
                    if (accType.Name.Contains("مغازه") || accType.Name.Contains("غرفه") || accType.Name.Contains("تجاری"))
                    {
                        var ret = new Divar_OfficeStoreRent(bu, imageCount, isGiveChat, sender);
                        res.AddReturnedValue(await ret.SendAsync(simCardNumber));
                        return(res);
                    }
                }

                else if (bu.SellPrice > 0)
                {
                    if (accType.Name.Contains("مسکونی"))
                    {
                        var type = await BuildingTypeBussines.GetAsync(bu.BuildingTypeGuid);

                        if (type == null)
                        {
                            res.AddError("نوع ملک معتبر نمی باشد");
                            return(res);
                        }
                        if (type.Name.Contains("پارتمان"))
                        {
                            var ret = new Divar_ResidentialApartmentSell(bu, imageCount, isGiveChat, sender);
                            res.AddReturnedValue(await ret.SendAsync(simCardNumber));
                            return(res);
                        }
                        if (type.Name.Contains("خانه") || accType.Name.Contains("ویلا"))
                        {
                            var ret = new Divar_ResidentialVillaSell(bu, imageCount, isGiveChat, sender);
                            res.AddReturnedValue(await ret.SendAsync(simCardNumber));
                            return(res);
                        }
                        if (type.Name.Contains("زمین") || type.Name.Contains("کلنگی"))
                        {
                            var ret = new Divar_ResidentialZaminSell(bu, imageCount, isGiveChat, sender);
                            res.AddReturnedValue(await ret.SendAsync(simCardNumber));
                            return(res);
                        }
                    }
                    if (accType.Name.Contains("زمین") || accType.Name.Contains("کلنگی"))
                    {
                        var ret = new Divar_ResidentialZaminSell(bu, imageCount, isGiveChat, sender);
                        res.AddReturnedValue(await ret.SendAsync(simCardNumber));
                        return(res);
                    }
                    if (accType.Name.Contains("دفتر") || accType.Name.Contains("اداری") || accType.Name.Contains("مطب"))
                    {
                        var ret = new Divar_OfficeOfficeSell(bu, imageCount, isGiveChat, sender);
                        res.AddReturnedValue(await ret.SendAsync(simCardNumber));
                        return(res);
                    }
                    if (accType.Name.Contains("صنعتی") || accType.Name.Contains("کشاورزی") ||
                        accType.Name.Contains("دامداری") || accType.Name.Contains("مرغداری") ||
                        accType.Name.Contains("زراعی"))
                    {
                        var ret = new Divar_OfficeKeshavarziSell(bu, imageCount, isGiveChat, sender);
                        res.AddReturnedValue(await ret.SendAsync(simCardNumber));
                        return(res);
                    }
                    if (accType.Name.Contains("مغازه") || accType.Name.Contains("غرفه") || accType.Name.Contains("تجاری"))
                    {
                        var ret = new Divar_OfficeStoreSell(bu, imageCount, isGiveChat, sender);
                        res.AddReturnedValue(await ret.SendAsync(simCardNumber));
                        return(res);
                    }
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }
Esempio n. 21
0
 public static async Task <List <BuildingRequestViewModel> > GetAllMatchesItemsAsync(BuildingBussines building, CancellationToken token)
 {
     try
     {
         var list = new List <BuildingBussines> {
             building
         };
         return(await GetAllMatchesItemsAsync(list, token));
     }
     catch (Exception ex)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(ex);
         return(null);
     }
 }
Esempio n. 22
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);
            }
        }
Esempio n. 23
0
        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;
                }));
            }
        }
Esempio n. 24
0
        public static async Task <ReturnedSaveFuncInfo> SendAsync(BuildingBussines 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.OwnerGuid, 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);
        }
        public async Task <ReturnedSaveFuncInfo> SaveAsync(BuildingBussines item, SqlTransaction tr)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var cmd = new SqlCommand("sp_Building_Save", tr.Connection, tr)
                {
                    CommandType = CommandType.StoredProcedure
                };
                cmd.Parameters.AddWithValue("@guid", item.Guid);
                cmd.Parameters.AddWithValue("@st", item.Status);
                cmd.Parameters.AddWithValue("@ownerGuid", item.OwnerGuid);
                cmd.Parameters.AddWithValue("@modif", item.Modified);
                cmd.Parameters.AddWithValue("@sellPrice", item.SellPrice);
                cmd.Parameters.AddWithValue("@vamPrice", item.VamPrice);
                cmd.Parameters.AddWithValue("@qestPrice", item.QestPrice);
                cmd.Parameters.AddWithValue("@dong", item.Dang);
                cmd.Parameters.AddWithValue("@docTypeGuid", item.DocumentType);
                cmd.Parameters.AddWithValue("@tarakom", item.Tarakom);
                cmd.Parameters.AddWithValue("@rahnPrice1", item.RahnPrice1);
                cmd.Parameters.AddWithValue("@rahnPrice2", item.RahnPrice2);
                cmd.Parameters.AddWithValue("@ejarePrice1", item.EjarePrice1);
                cmd.Parameters.AddWithValue("@ejarePrice2", item.EjarePrice2);
                cmd.Parameters.AddWithValue("@rentalGuid", item.RentalAutorityGuid);
                cmd.Parameters.AddWithValue("@isShortTime", item.IsShortTime);
                cmd.Parameters.AddWithValue("@isOwnerHere", item.IsOwnerHere);
                cmd.Parameters.AddWithValue("@pishTotalPrice", item.PishTotalPrice);
                cmd.Parameters.AddWithValue("@pishPrice", item.PishPrice);
                cmd.Parameters.AddWithValue("@deliveryDate", item.DeliveryDate);
                cmd.Parameters.AddWithValue("@pishDesc", item.PishDesc ?? "");
                cmd.Parameters.AddWithValue("@moavezeDesc", item.MoavezeDesc ?? "");
                cmd.Parameters.AddWithValue("@mosharekatDesc", item.MosharekatDesc ?? "");
                cmd.Parameters.AddWithValue("@masahat", item.Masahat);
                cmd.Parameters.AddWithValue("@zirbana", item.ZirBana);
                cmd.Parameters.AddWithValue("@cityGuid", item.CityGuid);
                cmd.Parameters.AddWithValue("@regionGuid", item.RegionGuid);
                cmd.Parameters.AddWithValue("@address", item.Address ?? "");
                cmd.Parameters.AddWithValue("@conditionGuid", item.BuildingConditionGuid);
                cmd.Parameters.AddWithValue("@side", (int)item.Side);
                cmd.Parameters.AddWithValue("@typeGuid", item.BuildingTypeGuid);
                cmd.Parameters.AddWithValue("@shortDesc", item.ShortDesc ?? "");
                cmd.Parameters.AddWithValue("@accountTypeGuid", item.BuildingAccountTypeGuid);
                cmd.Parameters.AddWithValue("@metrazhTejari", item.MetrazhTejari);
                cmd.Parameters.AddWithValue("@viewGuid", item.BuildingViewGuid);
                cmd.Parameters.AddWithValue("@floorCoverGuid", item.FloorCoverGuid);
                cmd.Parameters.AddWithValue("@kitchenServiceGuid", item.KitchenServiceGuid);
                cmd.Parameters.AddWithValue("@water", (short)item.Water);
                cmd.Parameters.AddWithValue("@barq", (short)item.Barq);
                cmd.Parameters.AddWithValue("@gas", (short)item.Gas);
                cmd.Parameters.AddWithValue("@tell", (short)item.Tell);
                cmd.Parameters.AddWithValue("@tedadTabaqe", item.TedadTabaqe);
                cmd.Parameters.AddWithValue("@tabaqeNo", item.TabaqeNo);
                cmd.Parameters.AddWithValue("@vahedPerTabaqe", item.VahedPerTabaqe);
                cmd.Parameters.AddWithValue("@metrazheKouche", item.MetrazhKouche);
                cmd.Parameters.AddWithValue("@ertefaSaqf", item.ErtefaSaqf);
                cmd.Parameters.AddWithValue("@hashie", item.Hashie);
                cmd.Parameters.AddWithValue("@saleSakht", item.SaleSakht ?? "");
                cmd.Parameters.AddWithValue("@dateParvane", item.DateParvane ?? "");
                cmd.Parameters.AddWithValue("@parvaneSerial", item.ParvaneSerial ?? "");
                cmd.Parameters.AddWithValue("@bonBast", item.BonBast);
                cmd.Parameters.AddWithValue("@mamarJoda", item.MamarJoda);
                cmd.Parameters.AddWithValue("@roomCount", item.RoomCount);
                cmd.Parameters.AddWithValue("@code", item.Code ?? "");
                cmd.Parameters.AddWithValue("@userGuid", item.UserGuid);
                cmd.Parameters.AddWithValue("@createDate", item.CreateDate);
                cmd.Parameters.AddWithValue("@image", item.Image ?? "");
                cmd.Parameters.AddWithValue("@priority", (short)item.Priority);
                cmd.Parameters.AddWithValue("@isArchive", item.IsArchive);
                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);
        }
Esempio n. 26
0
        public static async Task <ReturnedSaveFuncInfo> SaveAsync(BuildingBussines cls, string path)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var obj = new WebBuilding()
                {
                    Guid                    = cls.Guid,
                    Modified                = cls.Modified,
                    Status                  = cls.Status,
                    Masahat                 = cls.Masahat,
                    RegionGuid              = cls.RegionGuid,
                    Code                    = cls.Code,
                    EjarePrice1             = cls.EjarePrice1,
                    RahnPrice1              = cls.RahnPrice1,
                    SellPrice               = cls.SellPrice,
                    RoomCount               = cls.RoomCount,
                    Priority                = cls.Priority,
                    IsArchive               = cls.IsArchive,
                    GalleryList             = cls.GalleryList,
                    ZirBana                 = cls.ZirBana,
                    BuildingAccountTypeGuid = cls.BuildingAccountTypeGuid,
                    OptionList              = cls.OptionList,
                    UserGuid                = cls.UserGuid,
                    Address                 = cls.Address,
                    BuildingTypeGuid        = cls.BuildingTypeGuid,
                    SaleSakht               = cls.SaleSakht,
                    OwnerGuid               = cls.OwnerGuid,
                    EjarePrice2             = cls.EjarePrice2,
                    RentalAutorityGuid      = cls.RentalAutorityGuid,
                    Tell                    = cls.Tell,
                    TedadTabaqe             = cls.TedadTabaqe,
                    CityGuid                = cls.CityGuid,
                    TabaqeNo                = cls.TabaqeNo,
                    ShortDesc               = cls.ShortDesc,
                    CreateDate              = cls.CreateDate,
                    RahnPrice2              = cls.RahnPrice2,
                    VahedPerTabaqe          = cls.VahedPerTabaqe,
                    DocumentType            = cls.DocumentType,
                    Dang                    = cls.Dang,
                    FloorCoverGuid          = cls.FloorCoverGuid,
                    KitchenServiceGuid      = cls.KitchenServiceGuid,
                    PishTotalPrice          = cls.PishTotalPrice,
                    PishPrice               = cls.PishPrice,
                    Water                   = cls.Water,
                    MosharekatDesc          = cls.MosharekatDesc,
                    ParvaneSerial           = cls.ParvaneSerial,
                    MoavezeDesc             = cls.MoavezeDesc,
                    MamarJoda               = cls.MamarJoda,
                    QestPrice               = cls.QestPrice,
                    PishDesc                = cls.PishDesc,
                    IsOwnerHere             = cls.IsOwnerHere,
                    DeliveryDate            = cls.DeliveryDate,
                    BuildingConditionGuid   = cls.BuildingConditionGuid,
                    Side                    = cls.Side,
                    Hashie                  = cls.Hashie,
                    VamPrice                = cls.VamPrice,
                    ErtefaSaqf              = cls.ErtefaSaqf,
                    MetrazhKouche           = cls.MetrazhKouche,
                    BonBast                 = cls.BonBast,
                    MetrazhTejari           = cls.MetrazhTejari,
                    IsShortTime             = cls.IsShortTime,
                    Tarakom                 = cls.Tarakom,
                    BuildingViewGuid        = cls.BuildingViewGuid,
                    Barq                    = cls.Barq,
                    Gas                = cls.Gas,
                    DateParvane        = cls.DateParvane,
                    HardSerial         = cls.HardSerial,
                    Image              = cls.Image,
                    ServerStatus       = cls.ServerStatus,
                    ServerDeliveryDate = cls.ServerDeliveryDate
                };
                await obj.SaveAsync(path);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }

            return(res);
        }
Esempio n. 27
0
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var isSendSms = false;
                if (cls.Guid == Guid.Empty)
                {
                    cls.Guid  = Guid.NewGuid();
                    isSendSms = true;
                }

                cls.AskerGuid = asker?.Guid ?? Guid.Empty;
                cls.UserGuid  = (Guid)cmbUser.SelectedValue;
                cls.Modified  = DateTime.Now;

                cls.SellPrice1  = txtSellPrice1.TextDecimal;
                cls.SellPrice2  = txtSellPrice2.TextDecimal;
                cls.RahnPrice1  = txtRahn1.TextDecimal;
                cls.RahnPrice2  = txtRahn2.TextDecimal;
                cls.EjarePrice1 = txtEjare1.TextDecimal;
                cls.EjarePrice2 = txtEjare2.TextDecimal;

                cls.HasVam                  = chbHasVam.Checked;
                cls.PeopleCount             = txtPeopleCount.Text.ParseToShort();
                cls.HasOwner                = chbHasOwner.Checked;
                cls.ShortDate               = chbShortDate.Checked;
                cls.RentalAutorityGuid      = (Guid?)cmbRentalAuthority.SelectedValue ?? Guid.Empty;
                cls.CityGuid                = (Guid)cmbCity.SelectedValue;
                cls.BuildingTypeGuid        = (Guid)cmbBuildingType.SelectedValue;
                cls.Masahat1                = txtMasahat1.Text.ParseToInt();
                cls.Masahat2                = txtMasahat2.Text.ParseToInt();
                cls.RoomCount               = txtRoomCount.Text.ParseToInt();
                cls.BuildingAccountTypeGuid = (Guid)cmbBuildingAccountType.SelectedValue;
                cls.BuildingConditionGuid   = (Guid)cmbBuildingCondition.SelectedValue;
                cls.ShortDesc               = txtDesc.Text;

                await SetRegionsAsync(cls.Guid);

                res.AddReturnedValue(await cls.SaveAsync());

                if (res.HasError)
                {
                    return;
                }

                if (Settings.Classes.Payamak.IsSendToSayer.ParseToBoolean() && isSendSms)
                {
                    _ = Task.Run(() => Payamak.FixSms.RequestSend.SendAsync(cls));
                }

                if (MessageBox.Show("آیا مایلید املاک مطابق با این تقاضا را مشاهده نمایید؟", "تطبیق املاک با تقاضا",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                {
                    return;
                }

                var list = new List <BuildingViewModel>();

                decimal       fPrice1, fPrice2, sPrice1, sPrice2;
                EnRequestType type;

                if (cls.SellPrice1 > 0 || cls.SellPrice2 > 0)
                {
                    type    = EnRequestType.Forush;
                    fPrice1 = cls.SellPrice1;
                    fPrice2 = cls.SellPrice2;
                    sPrice1 = sPrice2 = 0;
                }
                else
                {
                    type    = EnRequestType.Rahn;
                    fPrice1 = cls.RahnPrice1;
                    fPrice2 = cls.RahnPrice2;
                    sPrice1 = cls.EjarePrice1;
                    sPrice2 = cls.EjarePrice2;
                }

                _token?.Cancel();
                _token = new CancellationTokenSource();
                list.AddRange(await BuildingBussines.GetAllAsync(null, _token.Token, Guid.Empty,
                                                                 cls.BuildingAccountTypeGuid, cls.Masahat1,
                                                                 cls.Masahat2, cls.RoomCount, fPrice1,
                                                                 sPrice1, fPrice2,
                                                                 sPrice2, type, cls.RegionList?.Select(q => q.RegionGuid).ToList()));

                if (list.Count <= 0)
                {
                    MessageBox.Show("متاسفانه در حال حاضر، ملکی مطابق با این تقاضا وجود ندارد");
                    return;
                }

                var frm = new frmBuildingAdvanceSearch(list);
                frm.ShowDialog(this);
            }
            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
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
        }
Esempio n. 28
0
        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);
            }
        }
Esempio n. 29
0
        private async void btnSelect_Click(object sender, EventArgs e)
        {
            try
            {
                btnSelect.Enabled = false;
                _token?.Cancel();
                _token = new CancellationTokenSource();
                var list = await BuildingRequestViewModel.GetAllMatchesItemsAsync(await BuildingBussines.GetAllAsync(_token.Token), _token.Token);

                if (list.Count <= 0)
                {
                    MessageBox.Show("فایل مطابقی جهت نمایش وجود ندارد");
                    return;
                }

                new frmShowRequestMatches(list).ShowDialog(this);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
            finally
            {
                btnSelect.Enabled = true;
            }
        }
Esempio n. 30
0
        private async void mnuShowStandard_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 contract = await ContractBussines.GetAsync(guid);

                if (contract == null)
                {
                    return;
                }
                var building = await BuildingBussines.GetAsync(contract.BuildingGuid);

                var buildingAccountType = await BuildingAccountTypeBussines.GetAsync(building.BuildingAccountTypeGuid);

                var fSide = await PeoplesBussines.GetAsync(contract.FirstSideGuid);

                var sSide = await PeoplesBussines.GetAsync(contract.SecondSideGuid);

                var unitCity = await CitiesBussines.GetAsync(Guid.Parse(Settings.Classes.clsEconomyUnit.EconomyCity));

                if (contract.Type == EnRequestType.Rahn)
                {
                    var view = new RahnViewModel
                    {
                        fName               = fSide?.Name,
                        fFatherName         = fSide?.FatherName,
                        fIdCode             = fSide?.IdCode,
                        fIssuedFrom         = fSide?.IssuedFrom,
                        fDateBirth          = fSide?.DateBirth,
                        fNationalCode       = fSide?.NationalCode,
                        fAddress            = fSide?.Address,
                        sName               = sSide?.Name,
                        sFatherName         = sSide?.FatherName,
                        sIdCode             = sSide?.IdCode,
                        sIssuedFrom         = sSide?.IssuedFrom,
                        sDateBirth          = sSide?.DateBirth,
                        sNationalCode       = sSide?.NationalCode,
                        sAddress            = sSide?.Address,
                        ContractDesc        = contract?.Description,
                        DongCount           = 6,
                        BuildingAddress     = building?.Address,
                        Masahat             = building?.Masahat ?? 0,
                        RoomCount           = building?.RoomCount ?? 0,
                        ContractTerm        = contract?.Term ?? 0,
                        ContractfDate       = Calendar.MiladiToShamsi(contract?.FromDate),
                        ContractsDate       = Calendar.MiladiToShamsi((contract?.FromDate ?? DateTime.Now).AddMonths((int)contract?.Term)),
                        UnitAddress         = Settings.Classes.clsEconomyUnit.ManagerAddress,
                        TotalEjare          = (contract?.MinorPrice * contract?.Term) ?? 0,
                        MinorEjare          = contract?.MinorPrice ?? 0,
                        Rahn                = contract?.TotalPrice ?? 0,
                        CheckNo             = contract?.CheckNo,
                        BankName            = contract?.BankName,
                        Shobe               = contract?.Shobe,
                        Sarresid            = contract?.SarResid,
                        UnitName            = Settings.Classes.clsEconomyUnit.EconomyName,
                        DischargeDate       = Calendar.MiladiToShamsi(contract?.DischargeDate),
                        BuildingAccountType = buildingAccountType?.Name,
                        Sarqofli            = contract?.SarQofli ?? 0,
                        Delay               = contract?.Delay ?? 0,
                        UnitCity            = unitCity?.Name,
                        Commition           = contract?.FirstTotalPrice ?? 0,
                        ContractDate        = contract?.DateSh,
                        ContractTime        = contract?.DateM.ToShortTimeString()
                    };
                    var lst = new List <object>()
                    {
                        view
                    };
                    var cls = new ReportGenerator(StiType.Contract_One, EnPrintType.Pdf_A4)
                    {
                        Lst = lst, SanadId = (int)contract?.Code
                    };
                    cls.PrintNew();
                }
                else if (contract.Type == EnRequestType.Forush)
                {
                    var view = new ForoshViewModel()
                    {
                        fName               = fSide?.Name,
                        fFatherName         = fSide?.FatherName,
                        fIdCode             = fSide?.IdCode,
                        fIssuedFrom         = fSide?.IssuedFrom,
                        fDateBirth          = fSide?.DateBirth,
                        fNationalCode       = fSide?.NationalCode,
                        fAddress            = fSide?.Address,
                        sName               = sSide?.Name,
                        sFatherName         = sSide?.FatherName,
                        sIdCode             = sSide?.IdCode,
                        sIssuedFrom         = sSide?.IssuedFrom,
                        sDateBirth          = sSide?.DateBirth,
                        sNationalCode       = sSide?.NationalCode,
                        sAddress            = sSide?.Address,
                        ContractDesc        = contract?.Description,
                        DongCount           = building?.Dang ?? 0,
                        BuildingAddress     = building?.Address,
                        Masahat             = building?.Masahat ?? 0,
                        UnitAddress         = Settings.Classes.clsEconomyUnit.ManagerAddress,
                        TotalPrice          = contract?.TotalPrice ?? 0,
                        MinorPrice          = (contract?.TotalPrice - contract?.MinorPrice) ?? 0,
                        Beyane              = contract?.MinorPrice ?? 0,
                        CheckNo             = contract?.CheckNo,
                        BankName            = contract?.BankName,
                        Shobe               = contract?.Shobe,
                        Sarresid            = contract?.SarResid,
                        UnitName            = Settings.Classes.clsEconomyUnit.EconomyName,
                        DischargeDate       = Calendar.MiladiToShamsi(contract?.DischargeDate),
                        BuildingAccountType = buildingAccountType?.Name,
                        Delay               = contract?.Delay ?? 0,
                        UnitCity            = unitCity?.Name,
                        Commition           = contract?.FirstTotalPrice ?? 0,
                        ContractDate        = contract?.DateSh,
                        ContractTime        = contract?.DateM.ToShortTimeString()
                    };
                    var lst = new List <object>()
                    {
                        view
                    };
                    var cls = new ReportGenerator(StiType.Contract_One, EnPrintType.Pdf_A5)
                    {
                        Lst = lst, SanadId = (int)contract?.Code
                    };
                    cls.PrintNew();
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }