Пример #1
0
        public HttpResponseMessage Install(string uid, byte?type, string pluginVersion, string domain)
        {
            Logger.Debug(String.Format("PLUGIN INSTALL MSG::uid = {0}::type = {1}::domain {2}", uid, type, domain));

            if (type == null || String.IsNullOrEmpty(uid))
            {
                return(new HttpResponseMessage(HttpStatusCode.BadRequest));
            }

            var pluginType = Utils.ParseEnum <PluginEnums.ePluginType>(type.ToString());

            var token = new PluginInstallationDTO
            {
                Uid    = uid,
                Type   = pluginType,
                Domain = domain
            };
            string error;
            var    result = WidgetEndpointServices.SavePluginInstallaltion(token, out error);

            if (result)
            {
                SaveUserEvent(CommonEnums.eUserEvents.PLUGIN_INSTALLATION, Utils.GetEnumDescription(pluginType) + " plugin installed::" + uid, uid);
            }
            Logger.Debug(String.Format("PLUGIN INSTALL MSG::installed{3}::uid = {0}::type = {1}::domain {2}", uid, type, domain, result));

            return(new HttpResponseMessage(result ? HttpStatusCode.OK : HttpStatusCode.InternalServerError));
        }
Пример #2
0
        public ActionResult ConnectApp()
        {
            ViewBag.IsTabAdded = false;

            var query = Request.QueryString.ToString().ToLower();

            if (!query.Contains("tabs_added"))
            {
                return(View());
            }

            ViewBag.IsTabAdded = true;

            var firstIndex   = query.IndexOf("tabs_added%5b", StringComparison.Ordinal) + 13;
            var lastIndex    = query.IndexOf("%5d=", firstIndex, StringComparison.Ordinal);
            var pageID       = query.Substring(firstIndex, lastIndex - firstIndex);
            var facebookPage = "https://facebook.com/" + pageID;

            ViewBag.PageUrl = facebookPage;

            #region save plugin
            var token = new PluginInstallationDTO
            {
                Uid  = pageID,
                Type = PluginEnums.ePluginType.FB
            };
            string error;
            if (_widgetEndpointServices.SavePluginInstallaltion(token, out error))
            {
                SaveUserEvent(CommonEnums.eUserEvents.PLUGIN_INSTALLATION, "Facebook plugin installed::" + pageID, pageID);
            }
            #endregion

            return(Redirect(facebookPage));
        }
Пример #3
0
 public static APP_PluginInstallations Token2PluginInstallationEntity(this PluginInstallationDTO token)
 {
     return(new APP_PluginInstallations
     {
         AddOn = token.AddOn ?? DateTime.Now,
         UId = token.Uid,
         TypeId = (byte)token.Type,
         Domain = token.Domain,
         UserId = token.UserId,
         IsActive = token.IsActive,
         CreatedBy = DtoExtensions.CurrentUserId
                     //Version = pluginVersion,
     });
 }
Пример #4
0
        public bool SavePluginInstallaltion(PluginInstallationDTO token, out string error)
        {
            error = string.Empty;

            var entity = PluginInstallationsRepository.Get(x => x.UId == token.Uid && x.IsActive);

            if (entity != null)
            {
                return(true);
            }

            entity          = token.Token2PluginInstallationEntity();
            entity.IsActive = true;

            PluginInstallationsRepository.Add(entity);

            return(PluginInstallationsRepository.UnitOfWork.CommitAndRefreshChanges(out error));
        }
Пример #5
0
        public ActionResult AppSettingsNew(string instance, string origCompId, string compId)
        {
            var user = this.CurrentUser();

            if (user == null)
            {
                return(RedirectToAction("Index", "Home", new { area = "WixEndPoint", instance = instance, compId = compId, origCompId = origCompId }));
            }


            var wixInstance = GetInstanceDto(instance);

            if (instance != null)
            {
                #region save plugin
                var token = new PluginInstallationDTO
                {
                    Uid  = wixInstance.instanceId.ToString(),
                    Type = PluginEnums.ePluginType.WIX
                };
                string error;
                if (WidgetEndpointServices.SavePluginInstallaltion(token, out error))
                {
                    SaveUserEvent(CommonEnums.eUserEvents.PLUGIN_INSTALLATION, Utils.GetEnumDescription(PluginEnums.ePluginType.WIX) + " plugin installed::" + wixInstance.instanceId, wixInstance.instanceId.ToString());
                }
                #endregion

                var wixUser = UserServices.FindUserDtoByWixInstanceId(wixInstance.instanceId);

                if (wixUser != null && user.UserId != wixUser.UserId)
                {
                    var returnUrl = Url.ToWixLoginHandlerUrl(wixInstance.instanceToken, compId, origCompId);
                    return(RedirectToAction("ForceWixUserSignIn", "Account", new { area = "", returnUrl, email = wixUser.Email, userProfileId = wixUser.UserProfileId, trackingId = wixInstance.instanceId.ToString() }));
                }

                #region update plugin owner
                WidgetEndpointServices.VerifyPluginOwner(wixInstance.instanceId.ToString(), out error);
                #endregion
            }


            var webStore = WidgetServices.GetWidgetStoreDto(wixInstance.instanceId.ToString()) ?? UserServices.GetAndUpdateZombieStore(wixInstance.instanceId, user.UserId);
            //check for zombie store (if user had store and clicked disconnect and than reconnected)


            var settingToken = new SettingsViewToken
            {
                Instance        = wixInstance,
                UserId          = user.UserId,
                StoreId         = webStore != null ? webStore.WebStoreID : (int?)null,
                UserCoursesList = CoursesServices.GetAuthorCoursesList(Constants.DEFAULT_CURRENCY_ID, user.UserId)
            };

            if (webStore == null)//create a new store
            {
                var jsonToken = new WixSettingsJsonToken
                {
                    cbIsShowBorder    = false,
                    cbIsShowTitleBar  = true,
                    cbIsTransparent   = false,
                    cpBackgroundColor = "#FFFFFF",
                    cpFontColor       = "#000000",
                    cpTabsFontColor   = "#006699",
                    InstanceId        = wixInstance.instanceId.ToString(),
                    StoreId           = null,
                    txtStoreName      = "",
                    UniqueId          = "",
                    WixSiteUrl        = ""
                };

                string error;
                WebstoreWixService.UpdateWixSettings(ref jsonToken, this.CurrentUser(), out error);

                settingToken.StoreName       = jsonToken.txtStoreName;
                settingToken.FontColor       = jsonToken.cpFontColor;
                settingToken.TabsFontColor   = jsonToken.cpTabsFontColor;
                settingToken.BackgroundColor = jsonToken.cpBackgroundColor;
                settingToken.IsTransparent   = jsonToken.cbIsTransparent;
                settingToken.IsShowBorder    = jsonToken.cbIsShowBorder;
                settingToken.IsShowTitleBar  = jsonToken.cbIsShowBorder;
                settingToken.StoreId         = jsonToken.StoreId;
                settingToken.UniqueId        = jsonToken.UniqueId;
            }
            else
            {
                settingToken.StoreName       = webStore.WebStoreName;
                settingToken.FontColor       = webStore.FontColor;
                settingToken.TabsFontColor   = webStore.TabsFontColor;
                settingToken.BackgroundColor = webStore.BackgroundColor;
                settingToken.IsTransparent   = webStore.IsTransParent;
                settingToken.IsShowBorder    = webStore.IsShowBorder;
                settingToken.IsShowTitleBar  = webStore.IsShowTitleBar;
                settingToken.StoreId         = webStore.WebStoreID;
                settingToken.UniqueId        = webStore.UniqueId;
                // settingToken.StoreCoursesIds = WidgetServices.GetAllStoreCourseIds(webStore.WebStoreID);
            }

            return(View(settingToken));
        }