Exemple #1
0
        public static MsCrmResult CreateUserGiftRequest(UserGiftRequest userGiftRequest, IOrganizationService service)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                Entity ent = userGiftRequest.ToCrmEntity();

                returnValue.CrmId   = service.Create(ent);
                returnValue.Success = true;
                returnValue.Result  = userGiftRequest.Point.ToString() + " puana sahip hediye talebiniz alınmıştır.";
            }
            catch (Exception ex)
            {
                returnValue.Result = ex.Message;
            }

            return(returnValue);
        }
Exemple #2
0
        public static MsCrmResult UpdateGiftRequest(UserGiftRequest userGiftRequest, IOrganizationService service)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                Entity ent = userGiftRequest.ToCrmEntity();

                service.Update(ent);
                returnValue.Success = true;
                returnValue.Result  = "Hediye talebi güncellendi";
            }
            catch (Exception ex)
            {
                returnValue.Result = ex.Message;
            }

            return(returnValue);
        }
Exemple #3
0
        public static MsCrmResult CreateUserGiftRequest(UserGiftRequest userGiftRequest, IOrganizationService service)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                Entity ent = userGiftRequest.ToCrmEntity();

                returnValue.CrmId = service.Create(ent);
                returnValue.Success = true;
                returnValue.Result = userGiftRequest.Point.ToString() + " puana sahip hediye talebiniz alınmıştır.";
            }
            catch (Exception ex)
            {
                returnValue.Result = ex.Message;
            }

            return returnValue;
        }
Exemple #4
0
        public GiftServiceResult Post(GiftUpdateInfo val)
        {
            GiftServiceResult returnValue = new GiftServiceResult();

            if (string.IsNullOrWhiteSpace(val.api_key) || string.IsNullOrWhiteSpace(val.id))
            {
                returnValue.message = "Failure";

                return(returnValue);
            }

            if (val.api_key != "6r9ZTok8zp4yZxKq")
            {
                returnValue.message = "Not authorized";

                return(returnValue);
            }

            try
            {
                IOrganizationService service = MSCRM.GetOrgService(true);

                UserGiftRequest request = new UserGiftRequest();
                request.Id = new Guid(val.id);

                request.ShippingCompany = val.shipping_company;
                request.ShippingNo      = val.shipping_no;
                request.Note            = val.note;
                request.ServiceStatus   = val.status;

                GiftHelper.UpdateGiftRequest(request, service);

                returnValue.message = "Success";
            }
            catch (Exception ex)
            {
                returnValue.message = "Failure | Ex:" + ex.Message;
            }

            return(returnValue);
        }
Exemple #5
0
        private MsCrmResult SendToServiceBirIleri(UserGiftRequest request)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                string cityCode = string.Empty;

                MsCrmResultObject resultGetGiftInfo = GiftHelper.GetGiftInfo(request.GiftId.Id, _sda);
                MsCrmResultObject resultUserInfo    = PortalUserHelper.GetPortalUserDetail(request.PortalId.Id, request.UserId.Id, _sda);

                if (!resultGetGiftInfo.Success)
                {
                    returnValue.Result = resultGetGiftInfo.Result;

                    return(returnValue);
                }

                if (!resultUserInfo.Success)
                {
                    returnValue.Result = resultUserInfo.Result;

                    return(returnValue);
                }

                Gift       gift     = resultGetGiftInfo.GetReturnObject <Gift>();
                PortalUser userInfo = resultUserInfo.GetReturnObject <PortalUser>();

                StringBuilder sb          = new StringBuilder();
                bool          checkFailed = false;

                if (userInfo.ContactInfo.CityId == null)
                {
                    sb.AppendLine("İl bilgisi eksik");
                    checkFailed = true;
                }

                if (userInfo.ContactInfo.TownId == null)
                {
                    sb.AppendLine("İlçe bilgisi eksik");
                    checkFailed = true;
                }

                if (string.IsNullOrWhiteSpace(userInfo.ContactInfo.MobilePhone))
                {
                    sb.AppendLine("Cep telefonu bilgisi eksik.");
                    checkFailed = true;
                }

                TelephoneNumber telNo = ValidationHelper.CheckTelephoneNumber(userInfo.ContactInfo.MobilePhone);

                if (!telNo.isFormatOK)
                {
                    sb.AppendLine("Telefon numarası formatı hatalı.");
                    checkFailed = true;
                }


                if (checkFailed)
                {
                    returnValue.Result = sb.ToString();

                    return(returnValue);
                }

                NameValueCollection formData = new NameValueCollection();

                GiftServiceInfo giftServiceInfo = new GiftServiceInfo();
                giftServiceInfo.api_key = "6r9ZTok8zp4yZxKq";
                formData["api_key"]     = "6r9ZTok8zp4yZxKq";

                giftServiceInfo.id = request.Id.ToString();
                formData["id"]     = request.Id.ToString();

                giftServiceInfo.created_at = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                formData["created_at"]     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                giftServiceInfo.name = userInfo.ContactInfo.FirstName;
                formData["name"]     = userInfo.ContactInfo.FirstName;

                giftServiceInfo.surname = userInfo.ContactInfo.LastName;
                formData["surname"]     = userInfo.ContactInfo.LastName;

                giftServiceInfo.address = userInfo.ContactInfo.AddressDetail;
                formData["address"]     = userInfo.ContactInfo.AddressDetail;

                giftServiceInfo.city = userInfo.ContactInfo.CityId.Name;
                formData["city"]     = userInfo.ContactInfo.CityId.Name;

                giftServiceInfo.district = userInfo.ContactInfo.TownId.Name;
                formData["district"]     = userInfo.ContactInfo.TownId.Name;

                giftServiceInfo.tc = userInfo.ContactInfo.IdentityNumber;
                formData["tc"]     = userInfo.ContactInfo.IdentityNumber;

                giftServiceInfo.product_category = gift.CategoryId.Name;
                formData["product_category"]     = gift.CategoryId.Name;

                giftServiceInfo.product_name = gift.Name;
                formData["product_name"]     = gift.Name;

                giftServiceInfo.product_quantity = "1";
                formData["product_quantity"]     = "1";

                giftServiceInfo.tel = userInfo.ContactInfo.MobilePhone;
                formData["tel"]     = userInfo.ContactInfo.MobilePhone;

                giftServiceInfo.status = "Servise Gönderildi";
                formData["status"]     = "Servise Gönderildi";

                //var js = new JavaScriptSerializer();
                //string json = js.Serialize(giftServiceInfo);

                string formDataStr = SerializePostData(formData);

                ISendGiftRequestService giftReqService = new SendGiftRequestService();

                GiftServiceResult serviceResult = giftReqService.SendGiftRequest(formDataStr);

                FileLogHelper.LogFunction(this.GetType().Name, "Result:" + serviceResult.message + ",Id:" + request.Id.ToString(), @Globals.FileLogPath);

                string errorText = string.Empty;

                if (serviceResult.message.ToLower() == "success")
                {
                    returnValue.Result  = serviceResult.message;
                    returnValue.Success = true;
                }
                else
                {
                    returnValue.Result = serviceResult.message;
                }
            }
            catch (Exception ex)
            {
                returnValue.Result = ex.StackTrace;
            }

            return(returnValue);
        }
Exemple #6
0
        private MsCrmResult SendToService(UserGiftRequest request)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                string cityCode = string.Empty;

                MsCrmResultObject resultGetGiftInfo = GiftHelper.GetGiftInfo(request.GiftId.Id, _sda);
                MsCrmResultObject resultUserInfo    = PortalUserHelper.GetPortalUserDetail(request.PortalId.Id, request.UserId.Id, _sda);

                if (!resultGetGiftInfo.Success)
                {
                    returnValue.Result = resultGetGiftInfo.Result;

                    return(returnValue);
                }

                if (!resultUserInfo.Success)
                {
                    returnValue.Result = resultUserInfo.Result;

                    return(returnValue);
                }

                Gift       gift     = resultGetGiftInfo.GetReturnObject <Gift>();
                PortalUser userInfo = resultUserInfo.GetReturnObject <PortalUser>();

                StringBuilder sb          = new StringBuilder();
                bool          checkFailed = false;

                if (userInfo.ContactInfo.CityId == null)
                {
                    sb.AppendLine("İl bilgisi eksik");
                    checkFailed = true;
                }

                if (userInfo.ContactInfo.TownId == null)
                {
                    sb.AppendLine("İlçe bilgisi eksik");
                    checkFailed = true;
                }

                if (string.IsNullOrWhiteSpace(userInfo.ContactInfo.MobilePhone))
                {
                    sb.AppendLine("Cep telefonu bilgisi eksik.");
                    checkFailed = true;
                }

                TelephoneNumber telNo = ValidationHelper.CheckTelephoneNumber(userInfo.ContactInfo.MobilePhone);

                if (!telNo.isFormatOK)
                {
                    sb.AppendLine("Telefon numarası formatı hatalı.");
                    checkFailed = true;
                }


                if (checkFailed)
                {
                    returnValue.Result = sb.ToString();

                    return(returnValue);
                }

                cityCode = ContactHelper.GetCityCode(userInfo.ContactInfo.CityId.Id, _sda);

                interlinkService.OperactiveOrder oo = new interlinkService.OperactiveOrder();

                string result = oo.OrderAdd("Interlink-Service2q2k", Globals.InterlinkPartnerId, DateTime.Now.ToLongDateString()
                                            , gift.GiftCode, 1, userInfo.ContactInfo.AddressDetail, userInfo.ContactInfo.CityId.Name, userInfo.ContactInfo.TownId.Name, cityCode
                                            , userInfo.ContactInfo.FirstName, userInfo.ContactInfo.LastName, string.Empty, string.Empty
                                            , telNo.phoneCode, telNo.phoneNo, userInfo.ContactInfo.Title, request.Id.ToString(), "Portal PUAN KULLANIMI"
                                            , Globals.InterlinkCatalogId, userInfo.PortalUserId.ToString());

                //result = "0001";

                FileLogHelper.LogFunction(this.GetType().Name, "Result:" + result + ",Id:" + request.Id.ToString(), @Globals.FileLogPath);

                string errorText = string.Empty;

                bool hasError = GiftHelper.InterlinkOrderErrorCodes.TryGetValue(result, out errorText);

                if (string.IsNullOrWhiteSpace(errorText))
                {
                    returnValue.Result  = result;
                    returnValue.Success = true;
                }
                else
                {
                    returnValue.Result = errorText;
                }
            }
            catch (Exception ex)
            {
                returnValue.Result = ex.StackTrace;
            }

            return(returnValue);
        }
Exemple #7
0
        public static MsCrmResult UpdateGiftRequest(UserGiftRequest userGiftRequest, IOrganizationService service)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                Entity ent = userGiftRequest.ToCrmEntity();

                service.Update(ent);
                returnValue.Success = true;
                returnValue.Result = "Hediye talebi güncellendi";
            }
            catch (Exception ex)
            {
                returnValue.Result = ex.Message;
            }

            return returnValue;
        }
Exemple #8
0
        public MsCrmResult CreateUserGiftRequest(string token, string giftId)
        {
            MsCrmResult returnValue = new MsCrmResult();
            LoginSession ls = new LoginSession();

            try
            {
                if (!string.IsNullOrEmpty(token))
                {
                    #region | CHECK SESSION |
                    MsCrmResultObject sessionResult = GetUserSession(token);

                    if (!sessionResult.Success)
                    {
                        returnValue.Result = sessionResult.Result;
                        return returnValue;
                    }
                    else
                    {
                        ls = (LoginSession)sessionResult.ReturnObject;
                    }

                    #endregion

                    IOrganizationService service = MSCRM.GetOrgService(true);

                    sda = new SqlDataAccess();
                    sda.openConnection(Globals.ConnectionString);

                    MsCrmResultObject resultGetGiftInfo = GiftHelper.GetGiftInfo(new Guid(giftId), sda);

                    MsCrmResultObject resultUserInfo = PortalUserHelper.GetPortalUserDetail(ls.PortalId, ls.PortalUserId, sda);

                    int userPoint = ScoreHelper.GetUserScore(ls.PortalId, ls.PortalUserId, sda);

                    if (resultGetGiftInfo.Success)
                    {
                        Gift gift = resultGetGiftInfo.GetReturnObject<Gift>();

                        PortalUser userInfo = resultUserInfo.GetReturnObject<PortalUser>();

                        TelephoneNumber telNo = ValidationHelper.CheckTelephoneNumber(userInfo.ContactInfo.MobilePhone);

                        if (!telNo.isFormatOK)
                        {
                            returnValue.Success = false;
                            returnValue.Result = "Cep telefonu bilginiz eksik veya formatı hatalıdır. Profilim bölümünden Cep telefpnu bilginizi güncelleyebilirsiniz.";

                            return returnValue;
                        }

                        #region | POINT CONTROL |
                        if (userPoint < gift.Point)
                        {
                            returnValue.Success = false;
                            returnValue.Result = "Mevcut puanınız: " + userPoint.ToString() + ", hediye talebi için yeterli değildir.";

                            return returnValue;
                        }
                        #endregion

                        #region | ADDRESS CONTROL |
                        if (userInfo.ContactInfo.CityId == null || userInfo.ContactInfo.TownId == null || string.IsNullOrEmpty(userInfo.ContactInfo.AddressDetail))
                        {
                            returnValue.Success = false;
                            returnValue.Result = "Adres bilgilerinizin tam olması gerekmektedir. Lütfen Profilim sayfasından Adres Bilgilerinizi güncelleyiniz";

                            return returnValue;
                        }
                        #endregion

                        UserGiftRequest req = new UserGiftRequest();
                        req.Name = gift.Name + "-" + DateTime.Now.ToString("dd.MM.yyyy");
                        req.PortalId = new EntityReferenceWrapper() { Id = ls.PortalId, LogicalName = "new_portal" };
                        req.UserId = new EntityReferenceWrapper() { Id = ls.PortalUserId, LogicalName = "new_user" };
                        req.GiftId = new EntityReferenceWrapper() { Id = gift.Id, Name = gift.Name, LogicalName = "new_gift" };
                        req.Point = gift.Point;

                        returnValue = GiftHelper.CreateUserGiftRequest(req, service);

                        if (returnValue.Success)
                        {
                            Score sc = new Score()
                            {
                                Point = gift.Point * -1,
                                Portal = req.PortalId.ToCrmEntityReference(),
                                User = req.UserId.ToCrmEntityReference(),
                                ScoreType = ScoreType.UsePoint
                            };

                            MsCrmResult scoreRes = ScoreHelper.CreateScore(sc, service);
                        }

                    }
                    else
                    {
                        returnValue.Result = resultGetGiftInfo.Result;
                    }
                }
                else
                {
                    returnValue.Success = false;
                    returnValue.Result = "M003"; //"Eksik parametre!-CreateForumSubject";

                }

            }
            catch (Exception ex)
            {
                returnValue.Result = ex.Message;
            }

            return returnValue;
        }
        private MsCrmResult SendToService(UserGiftRequest request)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                string cityCode = string.Empty;

                MsCrmResultObject resultGetGiftInfo = GiftHelper.GetGiftInfo(request.GiftId.Id, _sda);
                MsCrmResultObject resultUserInfo = PortalUserHelper.GetPortalUserDetail(request.PortalId.Id, request.UserId.Id, _sda);

                if (!resultGetGiftInfo.Success)
                {
                    returnValue.Result = resultGetGiftInfo.Result;

                    return returnValue;
                }

                if (!resultUserInfo.Success)
                {
                    returnValue.Result = resultUserInfo.Result;

                    return returnValue;
                }

                Gift gift = resultGetGiftInfo.GetReturnObject<Gift>();
                PortalUser userInfo = resultUserInfo.GetReturnObject<PortalUser>();

                StringBuilder sb = new StringBuilder();
                bool checkFailed = false;

                if (userInfo.ContactInfo.CityId == null)
                {
                    sb.AppendLine("İl bilgisi eksik");
                    checkFailed = true;
                }

                if (userInfo.ContactInfo.TownId == null)
                {
                    sb.AppendLine("İlçe bilgisi eksik");
                    checkFailed = true;
                }

                if (string.IsNullOrWhiteSpace(userInfo.ContactInfo.MobilePhone))
                {
                    sb.AppendLine("Cep telefonu bilgisi eksik.");
                    checkFailed = true;
                }

                TelephoneNumber telNo = ValidationHelper.CheckTelephoneNumber(userInfo.ContactInfo.MobilePhone);

                if (!telNo.isFormatOK)
                {
                    sb.AppendLine("Telefon numarası formatı hatalı.");
                    checkFailed = true;
                }

                if (checkFailed)
                {
                    returnValue.Result = sb.ToString();

                    return returnValue;
                }

                cityCode = ContactHelper.GetCityCode(userInfo.ContactInfo.CityId.Id, _sda);

                interlinkService.OperactiveOrder oo = new interlinkService.OperactiveOrder();

                string result = oo.OrderAdd("Interlink-Service2q2k", Globals.InterlinkPartnerId, DateTime.Now.ToLongDateString()
                    , gift.GiftCode, 1, userInfo.ContactInfo.AddressDetail, userInfo.ContactInfo.CityId.Name, userInfo.ContactInfo.TownId.Name, cityCode
                    , userInfo.ContactInfo.FirstName, userInfo.ContactInfo.LastName, string.Empty, string.Empty
                    , telNo.phoneCode, telNo.phoneNo, userInfo.ContactInfo.Title, request.Id.ToString(), "Portal PUAN KULLANIMI"
                    , Globals.InterlinkCatalogId, userInfo.PortalUserId.ToString());

                //result = "0001";

                FileLogHelper.LogFunction(this.GetType().Name, "Result:" + result + ",Id:" + request.Id.ToString(), @Globals.FileLogPath);

                string errorText = string.Empty;

                bool hasError = GiftHelper.InterlinkOrderErrorCodes.TryGetValue(result, out errorText);

                if (string.IsNullOrWhiteSpace(errorText))
                {
                    returnValue.Result = result;
                    returnValue.Success = true;
                }
                else
                {
                    returnValue.Result = errorText;
                }
            }
            catch (Exception ex)
            {
                returnValue.Result = ex.StackTrace;
            }

            return returnValue;
        }