Exemplo n.º 1
0
 public WebServicesTools()
 {
     dbManager    = new dbManager();
     payvastWS    = new AccountingServiceSoapClient();
     NezamSenfiWS = new AccountingWebServiceSoapClient();
     fiscalPeriod = (int)dbManager.GetFiscalPeriod();
 }
Exemplo n.º 2
0
        //public static bool RemoveFullPortage(Guid id, web_db.sardweb_Context db)
        //{
        //    var portage = db.TblPortages.Find(id);


        //    var contypeclone = db.TblContractTypes.Single(a => a.Id == portage.FkContracttype);


        //    #region rem PortageRows


        //    foreach (var item in db.TblPortageRows.Where(a => a.FkPortage == portage.Id))
        //    {
        //        db.TblPortageRowInjuries.RemoveRange(db.TblPortageRowInjuries.Where(a => a.FkPortageRow == item.Id));
        //        db.TblPortageRows.Remove(item);

        //    }


        //    #endregion


        //    #region rem images

        //    db.TblDocuments.RemoveRange(db.TblDocuments.Where(a => a.FkPortage == portage.Id));
        //    db.TblPortages.Remove(portage);
        //    #endregion
        //    db.SaveChanges();

        //    if (contypeclone.KindCotractType == web_db._Weighing.TblContractType.KindCotractTypeEnum.ASardKhane)
        //    {
        //        var x = db.TblPortageRows.Where(a => a.FkPortage == portage.Id);
        //        foreach (var item in x.Select(a => a.FkContract).Distinct())
        //        {
        //            Models.cl.refTblStoreLogcontractSardKhane(item.Value, db);
        //        }
        //    }

        //    else if (contypeclone.KindCotractType == web_db._Weighing.TblContractType.KindCotractTypeEnum.ASabad)

        //    {
        //        Models.cl.refTblStoreLogcontractTypeSabad(contypeclone.Id , db);

        //    }


        //    return true;
        //}
        //public static bool RemoveFullContract(Guid id, web_db.sardweb_Context db)
        //{
        //    try
        //    {
        //        db.TblContractPackings.RemoveRange(db.TblContractPackings.Where(a => a.FkContract == id));
        //        db.TblContractProducts.RemoveRange(db.TblContractProducts.Where(a => a.FkContract == id));
        //        db.TblContracts.Remove(db.TblContracts.Find(id));
        //        db.SaveChanges();
        //        return true;
        //    }
        //    catch
        //    {
        //        return false;
        //    }


        //}

        public static async Task <Guid?> AddPayvastCustomerAsync(web_db.sardweb_Context db, string CellPhone, int sal)
        {
            var Mali_KindOT = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Mali_KindOT) ?? new web_db.TblConf()).Value;
            var Mali_UrlOT  = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Mali_UrlOT) ?? new web_db.TblConf()).Value;
            var Mali_UserOT = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Mali_UserOT) ?? new web_db.TblConf()).Value;
            var Mali_PassOT = (Models.cl._conf.SingleOrDefault(a => a.Key == web_db.TblConf.KeyEnum.Mali_PassOT) ?? new web_db.TblConf()).Value;


            ApiPaivast.AccountingServiceSoapClient vv = new AccountingServiceSoapClient(AccountingServiceSoapClient.EndpointConfiguration.AccountingServiceSoap, Mali_UrlOT);
            var c = await vv.GetCustomerIdByCellPhoneAsync(CellPhone : CellPhone);

            var idc = c;

            var cid = await vv.GetCustomerInfoAsync(idc, Mali_UserOT, Mali_PassOT);

            if (cid != null)
            {
                string txt = "ثبت موفق";
                var    row = db.TblCustomers.FirstOrDefault(a => a.FkSalmali == sal && a.IdOtherSystem == cid.Id.ToString());
                if (row == null)
                {
                    row = new web_db.TblCustomer
                    {
                        Id            = Guid.NewGuid(),
                        FkSalmali     = sal,
                        IdOtherSystem = cid.Id.ToString(),
                        IsEnable      = true,
                        Code          = (db.TblCustomers.Where(a => a.FkSalmali == sal).Max(a => (int?)a.Code) ?? 0) + 1,
                    };
                    db.TblCustomers.Add(row);
                    txt = "بروزرسانی موفق";
                }
                row.IsEnable     = true;
                row.Addras       = "";
                row.Mob          = CellPhone;
                row.NationalCode = cid.NationalCode;
                row.Title        = cid.Name.ToPersianChars();
                db.SaveChanges();
                return(row.Id);
            }
            return(null);
        }