Example #1
0
		public User(string username, string password, UserAuthorization authorization, UserStatus status) {
			this._mongoServer = MyMongoDB.GetServer();

			this._username = username;
			this._password = password;
			this._authorization = authorization;
			this._status = status;
		}
Example #2
0
        private async Task PublishImage(UserAuthorization user)
        {
            var imageUrl  = "https://c3labsdevstorage.blob.core.windows.net/7e46a98d-a143-4a4d-8e05-b3f95493cce4/e21b6488-8d6e-43e6-8c88-4ac4438ff8cb/images/e0858668-005b-4f6c-a0b5-b0695661be6b.png";
            var imageData = await ImageUtils.PrepareImageFromUrl(imageUrl, 10485760);

            var postId = await this.api.Media.PostAsync(user, new Common.MediaUploadData()
            {
                Data = imageData
            });
        }
Example #3
0
        private async Task GetVideo(UserAuthorization user)
        {
            var videoId = "urn:li:digitalmediaAsset:C4E05AQHDEiyF00wWkQ"; // video post on Horvath janos zrt
            var postId  = "urn:li:ugcPost:6650705316675665920";           // video post on Horvath janos zrt.
            var video   = await this.api.UGCPost.GetUGCVideoAsync(user, postId);

            var mediaElements = video.SpecificContent.ComLinkedinUgcVideoContent.UGCMedia[0].mediaData.Elements;

            var videoUrl = mediaElements.FirstOrDefault().Identifiers[0].Identifier;
        }
Example #4
0
        private async Task <string> UploadVideo(UserAuthorization user)
        {
            var videoUrl  = "https://diricostorage.blob.core.windows.net/48131979-e14a-47c4-bf19-e02bb7226732/cb07d670-6fc8-410f-b21e-3456a284f523/4cf54e39-afdb-47b1-bf7d-020464985554/8b896ee0-d73d-48bc-bc92-60ce09407028/data";
            var videoData = await ImageUtils.PrepareImageFromUrl(videoUrl, 10485760);

            var ownerUrn       = "urn:li:organization:18568129";
            var videoUploadUrn = await VideoUpload.UploadVideoAsync(api, user, ownerUrn, videoData);

            return(videoUploadUrn);
        }
        /// <summary>
        /// 授权
        /// </summary>
        /// <param name="AuthData"></param>
        /// <returns></returns>
        public ActionResult SponsorOAuth(string AuthData, string AppId)
        {
            //会自动解码,所以再次进行编码
            AuthData = HttpUtility.UrlEncode(AuthData, System.Text.Encoding.UTF8);
            bool   AuthState = false;
            string ErrMsg    = string.Empty;
            //缓存的键值
            string MarkKey = StringTool.GetMD5(AuthData).ToUpper();
            //获取授权的地址
            string RedirectUrl = Request.Url.Scheme + "://" + Request.Url.Authority + "/WeChatAuthorization/OAuthCallBack?MarkKey=" + MarkKey;
            //进行解密
            var AuthDataModel = new
            {
                SessionKey    = "",         //授权完毕保存到session的键名
                AuthDataParam = "AuthData", //授权信息传递的参数名称
                AppId         = "",
                IsBase        = true,       //是否是基础信息true表示只获取openid(隐士授权) false表示显示授权,可以获取用户的信息
                RedirectUrl   = ""
            };

            try
            {
                AuthDataModel = Newtonsoft.Json.JsonConvert.DeserializeAnonymousType(Tools.DESEncryptTool.Decode(AuthData, Tools.StringTool.GetMD5(AppId).ToUpper()), AuthDataModel);
                if (AppId == AuthDataModel.AppId && !string.IsNullOrEmpty(AuthDataModel.RedirectUrl) && !string.IsNullOrEmpty(AuthDataModel.AppId))
                {
                    //将授权的信息保存在缓存中2分钟
                    HttpContext.Cache.Insert(MarkKey, AuthDataModel, null, DateTime.UtcNow.AddMinutes(2), TimeSpan.Zero);
                    string AuthUrl = string.Empty;
                    if (AuthDataModel.IsBase)
                    {
                        //只获取openid
                        AuthUrl = new UserAuthorization().GetOpenIDAuthorizeUrl(AuthDataModel.AppId, RedirectUrl, MarkKey);
                    }
                    else
                    {
                        AuthUrl = new UserAuthorization().GetUserInfoAuthorizeUrl(AuthDataModel.AppId, RedirectUrl, MarkKey);
                    }
                    AuthState = true;
                    return(new RedirectResult(AuthUrl));
                }
                else
                {
                    //授权信息错误!
                    ErrMsg = "授权信息错误";
                }
            }
            catch (Exception ex)
            {
                //授权信息错误
                ErrMsg = "授权信息错误:" + ex.Message;
            }
            ViewBag.AuthState = AuthState;
            ViewBag.ErrMsg    = ErrMsg;
            return(View());
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        UserAuthorizationModel userInfo = UserAuthorization.userLogin(this.Page);

        if (userInfo.openId == null || userInfo.openId == "")
        {
            member = userInfo.mobile;
        }
        else
        {
            member = userInfo.openId;
        }
        ticketId = (string.IsNullOrEmpty(Request.QueryString["ticketId"]) ? 0 : int.Parse(Request.QueryString["ticketId"]));
        //预定数量
        reserverCount = (string.IsNullOrEmpty(Request.QueryString["reserverCount"]) ? 0 : int.Parse(Request.QueryString["reserverCount"]));
        if (!IsPostBack)
        {
            var bll = new LVWEIBA.DAL.ProviderSpot();
            ViewState["ticketId"] = ticketId;
            if (ticketId == 0 || reserverCount == 0)
            {
                Jscript.AlertAndRedirect("请选择合适的票数", "ticket.aspx");
            }
            else
            {
                LVWEIBA.Model.ProviderSpot providerSpot = bll.GetModel(ticketId);
                ticketTitle        = providerSpot.SpotName;
                ticketId           = providerSpot.ID;
                startDate          = Convert.ToDateTime(providerSpot.BeginTime).ToString("yyyy年MM月dd号");
                endDate            = Convert.ToDateTime(providerSpot.EndTime).ToString("yyyy年MM月dd号");
                orderPriceLbl.Text = "¥" + providerSpot.ZkPrice;
                string priceDetailStr = reserverCount + "张";
                int    maketPrice     = (int)providerSpot.TicketPrice * reserverCount;
                int    zkPrice        = (int)providerSpot.ZkPrice * reserverCount;
                string str            = string.Format(@"<p>市场价:¥{0}({1})</p>
                       <p>优惠价:¥{2}({3})</p>", maketPrice, priceDetailStr, zkPrice, priceDetailStr);
                this.priceDetailLbl.Text = str;
                this.hid_count.Value     = reserverCount.ToString();
                this.hid_price_sc.Value  = maketPrice.ToString();
                this.hid_price_yh.Value  = zkPrice.ToString();
                this.hid_ticket_id.Value = ticketId.ToString();
                this.hid_price_jj.Value  = providerSpot.SellPrice.ToString();
                HiddenFieldBZ.Value      = str.Replace("<p>", "").Replace("</p>", "");

                LVWEIBA.BLL.MemberHotel          bllhotel = new LVWEIBA.BLL.MemberHotel();
                List <LVWEIBA.Model.MemberHotel> lsthotel = bllhotel.GetModelList(" member='" + userInfo.mobile + "' or member='" + userInfo.openId + "'");
                string strhotel = "";
                foreach (MemberHotel item in lsthotel)
                {
                    strhotel += string.Format(" <input id='Checkbox1' name='hotel' class='hotel' type='checkbox' value='{0}' />{1}", item.Id, item.Name);
                }
                contactPersonsLiteral.Text = strhotel;
            }
        }
    }
Example #7
0
        private async Task GetProfile(UserAuthorization user)
        {
            try
            {
                // var profile = await this.api.Profiles.GetProfileAsync(user, "LWq7hpOmwk");
                var profile = await this.api.Profiles.GetProfileAsync(user, "1ky82GzXRL");

                var profiles = await this.api.Profiles.GetProfilesByIdsAsync(user, "(id:qhwvZ0K4cr),(id:LWq7hpOmwk),(id:1ky82GzXRL)");
            }
            catch { }
        }
Example #8
0
 public bool MeetsRequiredAuthorization(UserAuthorization userAuthorization)
 {
     if (userAuthorization == this.RequiredAuthorization)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #9
0
 public IObservable <bool> RequestPermission(UserAuthorization userAuthorization)
 {
     if (this.HasPermission(userAuthorization))
     {
         return(Observable.Return(true));
     }
     using (var activity = GetActivity())
         using (var compat = new AndroidJavaClass(JAVA_CLASS_NAME_ACTIVITY_COMPAT)) {
             compat.CallStatic(JAVA_METHOD_NAME_REQUEST_PERMISSIONS, activity, new [] { PERMISSION_NAME_MAP[userAuthorization] }, 0);
         }
     return(this.CreateRuntimePermissionDialogResultObservable(userAuthorization));
 }
Example #10
0
        public async Task <User> Register(User user, string password)
        {
            //Infrastracture.Infsture.CreatePasswordHash(UserForRegisterDto.Username,out byte[]passwordHash,out byte[]passwordSalt);
            UserAuthorization.CreatePasswordHash(password, out var passwordSalt, out var passwordHash);
            user.PasswordSalt = passwordSalt;
            user.PasswordHash = passwordHash;
            await _context.Users.AddAsync(user);

            await _context.SaveChangesAsync();

            return(user);
        }
        private async Task GetComemntByUrn(UserAuthorization user, string commentUrn)
        {
            try
            {
                var comment = await api.SocialActions.GetCommentsByUrnAsync(user, commentUrn);

                await ReplyComment(user, comment.Elements.First());
            }
            catch (Exception)
            {
            }
        }
Example #12
0
        public ActionResult Authorize(UserAuthorization UserAuth)
        {
            if ((Request.IsAuthenticated))
            {
                Roles rol = RBL.Details(UserAuth.RoleID);

                Users UserEdit = UBL.Details(UserAuth.UserID, rol.ApplicationID);

                UserEdit.RoleID     = UserAuth.RoleID;
                UserEdit.ActionType = "AUTH";
                UserAuth.ActionType = "AUTH";

                string InsertUser = User.Identity.GetUserName();

                var r = UBL.UpdateUser(UserEdit, InsertUser, rol.ApplicationID);

                if (!r)
                {
                    ViewBag.Mensaje = "Ha ocurrido un error inesperado";
                    return(View("~/Views/Shared/Error.cshtml"));
                }
                else
                {
                    var Roles = from rl in RBL.List(rol.ApplicationID)
                                where rl.ActiveFlag == true
                                select rl;

                    UserAuth.RolesList = Roles.ToList();

                    Emails Email = new Emails();

                    Email.FromEmail    = "*****@*****.**";
                    Email.ToEmail      = UserEdit.Email;
                    Email.SubjectEmail = "Ministerio de Artes Oasis Alajuela - Usuario Autorizado";
                    Email.BodyEmail    = "Hola " + UserEdit.FullName + "!!! Su cuenta ha sido autorizada y puede ingresar desde este momento a https://mdaigleoa.azurewebsites.net/. Bendiciones...";

                    MailMessage mm = new MailMessage(Email.FromEmail, Email.ToEmail);
                    mm.Subject    = Email.SubjectEmail;
                    mm.Body       = Email.BodyEmail;
                    mm.IsBodyHtml = false;

                    SmtpClient smtp = new SmtpClient();
                    smtp.Send(mm);

                    return(View(UserAuth));
                }
            }
            else
            {
                return(this.RedirectToAction("Login", "Account"));
            }
        }
        public async Task <string> UploadImage(UserAuthorization user, byte[] imageData, string ownerUrn)
        {
            try
            {
                var asset = new Asset.RegisterUploadRequest()
                {
                    RegisterUploadRequestData = new Asset.RegisterUploadRequestData()
                    {
                        Owner   = ownerUrn,
                        Recipes = new List <string>()
                        {
                            "urn:li:digitalmediaRecipe:feedshare-image"
                        },
                        ServiceRelationships = new List <Asset.ServiceRelationship>()
                        {
                            new ServiceRelationship()
                            {
                                Identifier       = "urn:li:userGeneratedContent",
                                RelationshipType = "OWNER"
                            }
                        }
                    }
                };
                var requestAsset = await api.Asset.RegisterUploadAsync(user, asset);

                var imageUrn = requestAsset.Value.Asset;

                var postAsset = await api.Asset.UploadImageAssetAsync(user,
                                                                      requestAsset.Value.UploadMechanism.ComLinkedinDigitalmediaUploadingMediaUploadHttpRequest.UploadUrl,
                                                                      new Asset.UploadAssetRequest()
                {
                    RequestHeaders = new Asset.ComLinkedinDigitalmediaUploadingMediaUploadHttpRequest()
                    {
                        Headers   = requestAsset.Value.UploadMechanism.ComLinkedinDigitalmediaUploadingMediaUploadHttpRequest.Headers,
                        UploadUrl = requestAsset.Value.UploadMechanism.ComLinkedinDigitalmediaUploadingMediaUploadHttpRequest.UploadUrl,
                    },
                    Data = imageData
                });

                return(imageUrn);
            }
            catch (LinkedInApiException ex)
            {
                errors.Add(ex.ToString());
                return(null);
            }
            catch (Exception ex)
            {
                errors.Add(ex.ToString());
                return(null);
            }
        }
Example #14
0
 public SubscriptionStopCommandFromApi(
     StoppedSubscriptionParametersDto parameters,
     SubscriptionStopResponseBuilder responseBuilder,
     SubscriptionsModifyOperations subscriptions,
     SubscriptionDataCorrectnessCriteria correctnessCriteria,
     UserAuthorization userAuthorization)
 {
     _parameters          = parameters;
     _responseBuilder     = responseBuilder;
     _subscriptions       = subscriptions;
     _correctnessCriteria = correctnessCriteria;
     _userAuthorization   = userAuthorization;
 }
Example #15
0
        protected void Application_PostAuthenticateRequest(Object sender, EventArgs e)
        {
            HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName];

            if (authCookie != null)
            {
                try
                {
                    FormsAuthenticationTicket     authTicket     = FormsAuthentication.Decrypt(authCookie.Value);
                    JavaScriptSerializer          serializer     = new JavaScriptSerializer();
                    CustomPrincipalSerializeModel serializeModel =
                        serializer.Deserialize <CustomPrincipalSerializeModel>(authTicket.UserData);
                    if (serializeModel != null)
                    {
                        CustomPrincipal newUser = new CustomPrincipal(authTicket.Name);
                        newUser.CurrentUserId   = serializeModel.CurrentUserId;
                        newUser.LoginID         = serializeModel.LoginId;
                        newUser.ProfilePhotoUrl = serializeModel.ProfilePhotoUrl;
                        newUser.CompanyID       = serializeModel.CompanyID;
                        newUser.CompanyName     = serializeModel.CompanyName;
                        newUser.CompanyLogo     = serializeModel.CompanyLogo;
                        newUser.CurrentUserName = serializeModel.CurrentUserName;
                        //newUser.PlatformId = serializeModel.PlatformId;
                        HttpContext.Current.User = newUser;
                    }
                }
                catch (Exception ex)
                {
                    UserAuthorization.RemoveActivities();
                    FormsAuthentication.SignOut();

                    var dataKey = "__ControllerTempData";

                    if (HttpContext.Current != null && HttpContext.Current.Session != null && HttpContext.Current.Session[dataKey] != null)
                    {
                        var dataDict = HttpContext.Current.Session[dataKey] as IDictionary <string, object>;
                        if (dataDict == null)
                        {
                            /* what do you want to do? add a new IDict<> and put in session? */
                        }
                        else
                        {
                            dataDict["LoginError"] = "Successfully logout from System : " + ex.Message;
                            HttpContext.Current.Session[dataKey] = dataDict;
                        }
                    }
                    var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);
                    Response.Redirect(urlHelper.Action("Index", "Login", new { Area = "Admin" }));
                }
            }
        }
Example #16
0
 public UserAuthorization Add(UserAuthorization auth)
 {
     if (auth != null)
     {
         using (DataContext db = new SqlserverContext())
         {
             Table <UserAuthorization> AuthTable = db.GetTable <UserAuthorization>();
             AuthTable.InsertOnSubmit(auth);
             db.SubmitChanges();
             return(auth);
         }
     }
     return(null);
 }
        private async Task <TargetingFacets> GetTargetingFacetsAsync(UserAuthorization user)
        {
            try
            {
                var targetingFacets = await api.Targeting.GetTargetingFacetsAsync(user);

                return(targetingFacets);
            }
            catch (Exception ex)
            {
                errors.Add(ex.ToString());
                return(null);
            }
        }
        private async Task <Seniorities> GetSenioritiesAsync(UserAuthorization user, string language, string country)
        {
            try
            {
                var seniorities = await api.Targeting.GetSenioritiesAsync(user, language, country);

                return(seniorities);
            }
            catch (Exception ex)
            {
                errors.Add(ex.ToString());
                return(null);
            }
        }
Example #19
0
        public ActionResult UserShare(CompanyShareModel model)
        {
            var item = JsonConvert.DeserializeObject <Sparkle.LinkedInNET.Common.PostShare>(model.Json);

            this.ViewBag.Share = item;

            var token  = this.data.GetAccessToken();
            var user   = new UserAuthorization(token);
            var result = this.api.Social.Post(user, item);

            this.ViewBag.Result = result;

            return(this.View(model));
        }
        /// <summary>
        /// 将给定的用户权限实体数据添加至数据库中。
        /// </summary>
        /// <param name="entity">要添加的用户权限实体数据。</param>
        /// <exception cref="ArgumentNullException"/>
        /// <exception cref="InvalidOperationException"/>
        /// <remarks>
        /// 若给定的实体数据已经存在于数据库中,抛出 InvalidOperationException 异常。
        /// 若要更新给定的实体数据,请使用 UpdateUserAuthorizationEntity 方法。
        /// </remarks>
        public void AddUserAuthorizationEntity(UserAuthorizationEntity entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }
            if (QueryUserAuthorizationEntity(entity.Username) != null)
            {
                throw new InvalidOperationException("给定的实体数据已经存在于数据库中。");
            }

            UserAuthorization.Add(entity);
            SaveChanges();
        }
        private async Task <PersonList> GetProfilesByIdsAsync(UserAuthorization user, string profileIds)
        {
            try
            {
                var profiles = await api.Profiles.GetProfilesByIdsAsync(user, profileIds);

                return(profiles);
            }
            catch (Exception ex)
            {
                errors.Add(ex.ToString());
                return(null);
            }
        }
        public ActionResult Delete()
        {
            if (!UserAuthorization.CheckAccessRights(UserGroup.Administrators, UserSession.GetUserGroup(Session)))
            {
                return(new ContentResult());
            }
            if (Request.QueryString["id"] == null)
            {
                return(new ContentResult());
            }

            ProblemArchieveManager.Default.RemoveProblem(Request.QueryString["id"]);
            return(new ContentResult());
        }
        private async Task <UGCPostItems> GetUgcPostsAsync(UserAuthorization user, string companyUrn)
        {
            try
            {
                var posts = await api.UGCPost.GetUGCPostsAsync(user, companyUrn);

                return(posts);
            }
            catch (Exception ex)
            {
                errors.Add(ex.ToString());
                return(null);
            }
        }
        private async Task <DegreeSize> GetFirstDegreeConnectionsAsync(UserAuthorization user, string profileId)
        {
            try
            {
                var degreeSize = await api.Profiles.GetFirstDegreeConnectionsAsync(user, profileId);

                return(degreeSize);
            }
            catch (Exception ex)
            {
                errors.Add(ex.ToString());
                return(null);
            }
        }
        private async Task <PostStatistic> GetSharePostStatisticsAsync(UserAuthorization user, string companyId, string shareUrn)
        {
            try
            {
                var sharePostStatistics = await api.Shares.GetSharePostStatisticsAsync(user, companyId, shareUrn);

                return(sharePostStatistics);
            }
            catch (Exception ex)
            {
                errors.Add(ex.ToString());
                return(null);
            }
        }
        private async Task <PostShares> GetSharePostsAsync(UserAuthorization user, string companyUrn)
        {
            try
            {
                var posts = await api.Shares.GetSharesAsync(user, companyUrn);

                return(posts);
            }
            catch (Exception ex)
            {
                errors.Add(ex.ToString());
                return(null);
            }
        }
        private async Task <VideoAnalytics> GetVideoStatisticsAsync(UserAuthorization user, string videoPostId, string type, string agregation)
        {
            try
            {
                var videoStatistics = await api.Videos.GetVideoStatisticsAsync(user, videoPostId, type, agregation);

                return(videoStatistics);
            }
            catch (Exception ex)
            {
                errors.Add(ex.ToString());
                return(null);
            }
        }
        private async Task <JobFunctions> GetJobFunctionsAsync(UserAuthorization user, string locale)
        {
            try
            {
                var functions = await api.Targeting.GetJobFunctionsAsync(user, locale);

                return(functions);
            }
            catch (Exception ex)
            {
                errors.Add(ex.ToString());
                return(null);
            }
        }
        private async Task <Countries> GetCountriesAsync(UserAuthorization user, string language, string country, string countryGroupUrn)
        {
            try
            {
                var countries = await api.Targeting.GetCountriesAsync(user, language, country, "countryGroup", countryGroupUrn);

                return(countries);
            }
            catch (Exception ex)
            {
                errors.Add(ex.ToString());
                return(null);
            }
        }
        private async Task <AudienceCounts> GetAudienceCountsAsync(UserAuthorization user, string targetingCriteria)
        {
            try
            {
                var audienceCounts = await api.Targeting.GetAudienceCountsAsync(user, targetingCriteria);

                return(audienceCounts);
            }
            catch (Exception ex)
            {
                errors.Add(ex.ToString());
                return(null);
            }
        }
        private async Task <Regions> GetRegionsAsync(UserAuthorization user, string language, string country, string stateUrn)
        {
            try
            {
                var regions = await api.Targeting.GetRegionsAsync(user, language, country, "states", stateUrn);

                return(regions);
            }
            catch (Exception ex)
            {
                errors.Add(ex.ToString());
                return(null);
            }
        }
        public async Task<ActionResult> Company(int id, string culture = "en-US", int start = 0, int count = 10, string eventType = null)
        {
            var token = this.data.GetAccessToken();
            this.ViewBag.Token = token;
            var user = new UserAuthorization(token);
            var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", };

            Company company;
            {
                var fields = FieldSelector.For<Company>()
                    .WithAllFields();
                company = await this.api.Companies.GetByIdAsync(user, id.ToString(), fields);
            }

            {
                var fields = FieldSelector.For<CompanyUpdates>();
                var shares = this.api.Companies.GetShares(user, id, start, count, eventType);
                this.ViewBag.Shares = shares;
            }
            
            return this.View(company);
        }
Example #33
0
        public ActionResult Company(int id, string culture = "en-US")
        {
            var token = this.data.GetAccessToken();
            this.ViewBag.Token = token;
            var user = new UserAuthorization(token);
            var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", };

            Company company;
            {
                var fields = FieldSelector.For<Company>()
                    .WithAllFields();
                company = this.api.Companies.GetById(user, id.ToString(), fields);
            }

            {
                var fields = FieldSelector.For<CompanyUpdates>();
                var shares = this.api.Companies.GetShares(user, id);
                this.ViewBag.Shares = shares;
            }

            return this.View(company);
        }
        public async Task<ActionResult> Index(string culture = "en-US")
        {
            var token = this.data.GetAccessToken();
            this.ViewBag.Token = token;
            var user = new UserAuthorization(token);
            var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", };

            {
                var fields = FieldSelector.For<Person>()
                    .WithPositions().WithId().WithPictureUrl()
                    .WithFirstName().WithLastName().WithHeadline();
                ////.WithConnections();
                this.ViewData["MyProfile"] = this.api.Profiles.GetMyProfile(user, acceptLanguages, fields);
                this.ViewBag.Profile = this.ViewData["MyProfile"];

                {
                    var pictures = await this.api.Profiles.GetOriginalProfilePictureAsync(user);
                    pictures = pictures ?? new PictureUrls() { PictureUrl = new List<string>(), };

                    {
                        var more = await this.api.Profiles.GetProfilePictureAsync(user, 120, 120);
                        if (more != null && more.PictureUrl != null)
                        {
                            pictures.PictureUrl.AddRange(more.PictureUrl);
                        }
                    }

                    this.ViewBag.Pictures = this.ViewData["ProfilePictures"] = pictures;
                }
            }

            ////{
            ////    var companies = this.api.Companies.GetList(user);
            ////    this.ViewBag.Companies = companies;
            ////}

            return this.View();
        }
Example #35
0
        /// <summary>
        /// retrieve a company by using the company ID
        /// </summary>
        public Companies.Company GetById(
              UserAuthorization user 
            , string companyId 
            , FieldSelector<Companies.Company> fields = null
        )
        {
            const string urlFormat = "/v1/companies/{CompanyId}{FieldSelector}";
            var url = FormatUrl(urlFormat, fields, "CompanyId", companyId);

            var context = new RequestContext();
            context.UserAuthorization = user;
            context.Method =  "GET";
            context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url;

            if (!this.ExecuteQuery(context))
                this.HandleJsonErrorResponse(context);

            var result = this.HandleJsonResponse<Companies.Company>(context);
            return result;
        }
Example #36
0
        /// <summary>
        /// This returns an array of companies that match to the specified email domain.
        /// </summary>
        public Companies.Company GetListByEmailDomain(
              UserAuthorization user 
            , string universalName 
            , FieldSelector<Companies.Company> fields = null
        )
        {
            const string urlFormat = "/v1/companies/universal-name={UniversalName}{FieldSelector}";
            var url = FormatUrl(urlFormat, fields, "UniversalName", universalName);

            var context = new RequestContext();
            context.UserAuthorization = user;
            context.Method =  "GET";
            context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url;

            if (!this.ExecuteQuery(context))
                this.HandleJsonErrorResponse(context);

            var result = this.HandleJsonResponse<Companies.Company>(context);
            return result;
        }
 public static bool HasUserAuthorization(UserAuthorization mode)
 {
     return UnityEngine.Application.HasUserAuthorization(mode);
 }
Example #38
0
        /// <summary>
        /// Share a new company update.
        /// </summary>
        /// <remarks>
        /// See https://developer.linkedin.com/creating-company-shares
        /// </remarks>
        public Common.PostShareResult Share(
              UserAuthorization user 
            , int companyId 
            , Common.PostShare postData
        )
        {
            const string urlFormat = "/v1/companies/{int companyId}/shares";
            var url = FormatUrl(urlFormat, default(FieldSelector), "int companyId", companyId);

            var context = new RequestContext();
            context.UserAuthorization = user;
            context.Method =  "POST";
            context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url;
            this.CreateJsonPostStream(context, postData);

            if (!this.ExecuteQuery(context))
                this.HandleJsonErrorResponse(context);

            var result = this.HandleJsonResponse<Common.PostShareResult>(context);
            result.Location = this.ReadHeader<string>(context, "Location");
            return result;
        }
Example #39
0
        /// <summary>
        /// returns the original picture posted by the user, fields selector are ignored
        /// </summary>
        public Profiles.PictureUrls GetOriginalProfilePicture(
              UserAuthorization user 
        )
        {
            var url = "/v1/people/~/picture-urls::(original)";

            var context = new RequestContext();
            context.UserAuthorization = user;
            context.Method =  "GET";
            context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url;

            if (!this.ExecuteQuery(context))
                this.HandleJsonErrorResponse(context);

            var result = this.HandleJsonResponse<Profiles.PictureUrls>(context);
            return result;
        }
Example #40
0
        /// <summary>
        /// the public profile of a user
        /// </summary>
        /// <remarks>
        /// See https://developer.linkedin.com/documents/profile-api
        /// </remarks>
        public Profiles.Person GetPublicProfile(
              UserAuthorization user 
            , string publicProfileUrl 
            , string[] acceptLanguages 
            , FieldSelector<Profiles.Person> fields = null
        )
        {
            const string urlFormat = "/v1/people/url={PublicProfileUrl}{FieldSelector}";
            var url = FormatUrl(urlFormat, fields, "PublicProfileUrl", publicProfileUrl);

            var context = new RequestContext();
            context.UserAuthorization = user;
            context.AcceptLanguages = acceptLanguages;
            context.Method =  "GET";
            context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url;

            if (!this.ExecuteQuery(context))
                this.HandleJsonErrorResponse(context);

            var result = this.HandleJsonResponse<Profiles.Person>(context);
            return result;
        }
Example #41
0
        public ActionResult SearchCompany(string keywords, int start = 0, int count = 20, string facet = null)
        {
            var token = this.data.GetAccessToken();
            var user = new UserAuthorization(token);
            var fields = FieldSelector.For<CompanySearch>()
                .WithFacets()
                .WithCompaniesDescription().WithCompaniesId()
                .WithCompaniesLogoUrl().WithCompaniesName()
                .WithCompaniesSquareLogoUrl().WithCompaniesStatus()
                .WithCompaniesWebsiteUrl()
                .WithCompaniesUniversalName();

            CompanySearch result;
            if (!string.IsNullOrEmpty(facet))
                result = this.api.Companies.FacetSearch(user, start, count, keywords, facet, fields);
            else
                result = this.api.Companies.Search(user, start, count, keywords, fields);

            this.ViewBag.keywords = keywords;
            this.ViewBag.start = start;
            this.ViewBag.count = count;
            this.ViewBag.facet = facet;

            return this.View(result);
        }
Example #42
0
        /// <summary>
        /// 
        /// </summary>
        public Companies.CompanySearch Search(
              UserAuthorization user 
            , int start 
            , int count 
            , string keywords 
            , FieldSelector<Companies.CompanySearch> fields = null
        )
        {
            const string urlFormat = "/v1/company-search{FieldSelector}?start={int start}&count={int count}&keywords={keywords}";
            var url = FormatUrl(urlFormat, fields, "int start", start, "int count", count, "keywords", keywords);

            var context = new RequestContext();
            context.UserAuthorization = user;
            context.Method =  "GET";
            context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url;

            if (!this.ExecuteQuery(context))
                this.HandleJsonErrorResponse(context);

            var result = this.HandleJsonResponse<Companies.CompanySearch>(context);
            return result;
        }
Example #43
0
        public ActionResult Person(string id, string culture = "en-US")
        {
            var token = this.data.GetAccessToken();
            this.ViewBag.Token = token;
            var user = new UserAuthorization(token);
            var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", };

            var fields = FieldSelector.For<Person>()
                .WithId()
                .WithPositions().WithPictureUrl()
                .WithFirstName().WithLastName().WithHeadline()
                .WithLanguageId().WithLanguageName().WithLanguageProficiency()
                .WithConnections();
            var profile = this.api.Profiles.GetProfileById(user, id, acceptLanguages, fields);

            {
                var pictures = this.api.Profiles.GetOriginalProfilePicture(user, profile.Id)
                     ?? new PictureUrls() { PictureUrl = new List<string>() };
                var more = this.api.Profiles.GetProfilePicture(user, profile.Id, 120, 120);
                if (more != null && more.PictureUrl != null)
                {
                    pictures.PictureUrl.AddRange(more.PictureUrl);
                }

                this.ViewBag.Pictures = this.ViewData["ProfilePictures"] = pictures;
            }

            return this.View(profile);
        }
        protected void Page_Load(object sender, EventArgs e)
        {

            if (Request.QueryString["code"] != null)
            {
                var accessCode = Request.QueryString["code"]; // save this code for each user in db and use this code for 
                // further accessing 
                var redirectUrl = "http://localhost:49965/WebForm1.aspx";

                // this section of code is using to access the web

                var config = LinkedInApiConfiguration.FromAppSettings("MyDemo.LinkedInConnect");

                var api = new LinkedInApi(config);

                var userToken = api.OAuth2.GetAccessToken(accessCode, redirectUrl);

                var user = new UserAuthorization(userToken.AccessToken);
                string culture = "en-US";
                var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", };
                var fields = FieldSelector.For<Person>()
                    .WithId()
                    .WithFirstName()
                    .WithLastName()
                    .WithFormattedName()
                    .WithEmailAddress()
                    .WithHeadline()

                    .WithLocationName()
                    .WithLocationCountryCode()

                    .WithPictureUrl()
                    .WithPublicProfileUrl()
                    .WithSummary()
                    .WithIndustry()

                    .WithPositions()
                    .WithPositionsSummary()
                    .WithThreeCurrentPositions()
                    .WithThreePastPositions()

                    .WithProposalComments()
                    .WithAssociations()
                    .WithInterests()
                    .WithLanguageId()
                    .WithLanguageName()
                    .WithLanguageProficiency()
                    .WithCertifications()
                    .WithEducations()
                    .WithFullVolunteer()
                    .WithPatents()
                    ////.WithRecommendationsReceived() // may not use that
                    .WithRecommendationsReceivedWithAdditionalRecommenderInfo()

                    .WithDateOfBirth()
                    .WithPhoneNumbers()
                    .WithImAccounts()
                    .WithPrimaryTwitterAccount()
                    .WithTwitterAccounts()
                    .WithSkills();

                var profile = api.Profiles.GetMyProfile(user, acceptLanguages, fields);

                var firstName = profile.Firstname;


                var lastName = profile.Lastname;


                var emailAddress = profile.EmailAddress;


                var headine = profile.Headline;


                var location = profile.Location.Name;


                var industry = profile.Industry;


                var dateOfDirth = profile.DateOfBirth;
            }

        }
Example #45
0
		public static extern bool HasUserAuthorization(UserAuthorization mode);
 public static AsyncOperation RequestUserAuthorization(UserAuthorization mode)
 {
     return UnityEngine.Application.RequestUserAuthorization(mode);
 }
Example #47
0
        /// <summary>
        /// retrieve the member's updates
        /// </summary>
        public Social.UserUpdates GetMyUpdates(
              UserAuthorization user 
            , int start = 0
            , int count = 50
            , DateTime? before = null
            , DateTime? after = null
            , bool showHiddenMembers = false
            , FieldSelector<Social.UserUpdates> fields = null
        )
        {
            const string urlFormat = "/v1/people/~/network/updates?scope=self&start={int start = 0}&count={int count = 50}&before={DateTime? before = null}&after={DateTime? after = null}&show-hidden-members={bool showHiddenMembers = false}";
            var url = FormatUrl(urlFormat, fields, "int start = 0", start, "int count = 50", count, "DateTime? before = null", before, "DateTime? after = null", after, "bool showHiddenMembers = false", showHiddenMembers);

            var context = new RequestContext();
            context.UserAuthorization = user;
            context.Method =  "GET";
            context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url;

            if (!this.ExecuteQuery(context))
                this.HandleJsonErrorResponse(context);

            var result = this.HandleJsonResponse<Social.UserUpdates>(context);
            return result;
        }
		public static bool HasUserAuthorization(UserAuthorization mode){}
Example #49
0
        /// <summary>
        /// returns a list of 1st degree connections for a user 
        /// </summary>
        public Profiles.Connections GetUpdatedConnectionsByPublicProfile(
              UserAuthorization user 
            , string publicProfileUrl 
            , int start 
            , int count 
            , long modifiedSince 
            , FieldSelector<Profiles.Connections> fields = null
        )
        {
            const string urlFormat = "/v1/people/url={PublicProfileUrl}/connections{FieldSelector}?start={int start}&count={int count}&modified=updated&modified-since={long modifiedSince}";
            var url = FormatUrl(urlFormat, fields, "PublicProfileUrl", publicProfileUrl, "int start", start, "int count", count, "long modifiedSince", modifiedSince);

            var context = new RequestContext();
            context.UserAuthorization = user;
            context.Method =  "GET";
            context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url;

            if (!this.ExecuteQuery(context))
                this.HandleJsonErrorResponse(context);

            var result = this.HandleJsonResponse<Profiles.Connections>(context);
            return result;
        }
		public static AsyncOperation RequestUserAuthorization(UserAuthorization mode){}
Example #51
0
        /// <summary>
        /// returns the original picture posted by the user, fields selector are ignored
        /// </summary>
        public Profiles.PictureUrls GetProfilePicture(
              UserAuthorization user 
            , string memberToken 
            , short width 
            , short height 
        )
        {
            const string urlFormat = "/v1/people/id={MemberToken}/picture-urls::({short width}x{short height})";
            var url = FormatUrl(urlFormat, default(FieldSelector), "MemberToken", memberToken, "short width", width, "short height", height);

            var context = new RequestContext();
            context.UserAuthorization = user;
            context.Method =  "GET";
            context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url;

            if (!this.ExecuteQuery(context))
                this.HandleJsonErrorResponse(context);

            var result = this.HandleJsonResponse<Profiles.PictureUrls>(context);
            return result;
        }
 public bool HasUserAuthorization(UserAuthorization mode)
 {
     return Application.HasUserAuthorization( mode );
 }
Example #53
0
        /// <summary>
        /// returns a list of 1st degree connections for a user 
        /// </summary>
        public Profiles.Connections GetMyConnections(
              UserAuthorization user 
            , int start 
            , int count 
            , FieldSelector<Profiles.Connections> fields = null
        )
        {
            const string urlFormat = "/v1/people/~/connections{FieldSelector}?start={int start}&count={int count}";
            var url = FormatUrl(urlFormat, fields, "int start", start, "int count", count);

            var context = new RequestContext();
            context.UserAuthorization = user;
            context.Method =  "GET";
            context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url;

            if (!this.ExecuteQuery(context))
                this.HandleJsonErrorResponse(context);

            var result = this.HandleJsonResponse<Profiles.Connections>(context);
            return result;
        }
 public AsyncOperation RequestUserAuthorization(UserAuthorization mode)
 {
     return Application.RequestUserAuthorization( mode );
 }
Example #55
0
        public ActionResult Connections(string id, string culture = "en-US", int start = 0, int count = 10, int? days = null)
        {
            var token = this.data.GetAccessToken();
            this.ViewBag.Token = token;
            var user = new UserAuthorization(token);
            var acceptLanguages = new string[] { culture ?? "en-US", "fr-FR", };

            {
                var fields = FieldSelector.For<Person>()
                    .WithFirstName().WithLastName().WithHeadline()
                    .WithPictureUrl();
                this.ViewBag.Profile = this.api.Profiles.GetMyProfile(user, acceptLanguages, fields);
            }

            Connections model;
            {
                var fields = FieldSelector.For<Connections>()
                    .WithDistance().WithPictureUrl()
                    .WithSummary().WithLocationName().WithLocationCountryCode()
                    .WithIndustry().WithId()
                    .WithPublicProfileUrl()
                    .WithFirstName().WithLastName().WithHeadline();

                if (days == null)
                {
                    model = this.api.Profiles.GetConnectionsByProfileId(user, id, start, count, fields);
                }
                else
                {
                    var date = DateTime.UtcNow.AddDays(-days.Value);
                    var modifiedSince = date.ToUnixTime();
                    model = this.api.Profiles.GetNewConnectionsByProfileId(user, id, start, count, modifiedSince, fields);
                }
            }

            this.ViewBag.id = id;
            this.ViewBag.start = start;
            this.ViewBag.days = days;
            this.ViewBag.count = count;
            this.ViewBag.days = days;

            return this.View(model);
        }
Example #56
0
        /// <summary>
        /// Retrieve the company's updates
        /// </summary>
        public async Task<Companies.CompanyUpdates> GetSharesAsync(
              UserAuthorization user 
            , int id 
            , int start 
            , int count 
            , string type 
            , FieldSelector<Companies.CompanyUpdates> fields = null
        )
        {
            const string urlFormat = "/v1/companies/{int id}/updates?start={int start}&count={int count}&event-type={type}";
            var url = FormatUrl(urlFormat, fields, "int id", id, "int start", start, "int count", count, "type", type);

            var context = new RequestContext();
            context.UserAuthorization = user;
            context.Method =  "GET";
            context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url;

            var exec = await this.ExecuteQueryAsync(context);
            if (!exec)
                this.HandleJsonErrorResponse(context);
            
            var result = this.HandleJsonResponse<Companies.CompanyUpdates>(context);
            return result;
        }
Example #57
0
        public ActionResult CompanyShare(CompanyShareModel model)
        {
            var item = JsonConvert.DeserializeObject<Sparkle.LinkedInNET.Common.PostShare>(model.Json);
            this.ViewBag.Share = item;

            var token = this.data.GetAccessToken();
            var user = new UserAuthorization(token);
            var result = this.api.Companies.Share(user, model.CompanyId, item);

            this.ViewBag.Result = result != null ? result.Location : null;

            return this.View(model);
        }
Example #58
0
        /// <summary>
        /// Retrieve the company's updates
        /// </summary>
        public Companies.CompanyUpdates GetShares(
              UserAuthorization user 
            , int id 
            , FieldSelector<Companies.CompanyUpdates> fields = null
        )
        {
            const string urlFormat = "/v1/companies/{int id}/updates";
            var url = FormatUrl(urlFormat, fields, "int id", id);

            var context = new RequestContext();
            context.UserAuthorization = user;
            context.Method =  "GET";
            context.UrlPath = this.LinkedInApi.Configuration.BaseApiUrl + url;

            if (!this.ExecuteQuery(context))
                this.HandleJsonErrorResponse(context);

            var result = this.HandleJsonResponse<Companies.CompanyUpdates>(context);
            return result;
        }
Example #59
0
		public static extern AsyncOperation RequestUserAuthorization(UserAuthorization mode);
Example #60
0
		private void SetUserByDbResult(UserEntity entity) {
			this._id = entity.Id.ToString();
			this._username = entity.Username;
			this._password = entity.Password;
			this._eMail = entity.eMail;
			this._eMailAliases = entity.eMailAliases;
			this._authorization = entity.Authorization;
			this._status = entity.Status;
		}