public void QueueDownloadForGraffiti (Graffiti graffiti) {
		if (!graffiti.IsDownloaded) {
			IEnumerator coroutine = DownloadGraffiti(graffiti);
			this.downloadCoroutines.Add(coroutine);
			StartCoroutine(coroutine);
		} else {
			Debug.LogWarning("This graffiti is already downloaded. I ain't not doin' nothin'.");
		}
	}
示例#2
0
        public static MsCrmResult SaveOrUpdateGraffiti(Graffiti graffiti, IOrganizationService service)
        {
            MsCrmResult returnValue = new MsCrmResult();

            try
            {
                Entity ent = new Entity("new_graffiti");

                ent["new_name"] = graffiti.PortalUser.Name + "-" + DateTime.Now.ToString("dd.MM.yyyy HH:mm");

                ent["new_hasmedia"] = graffiti.HasMedia;

                if (graffiti.PortalUser != null)
                {
                    ent["new_userid"] = graffiti.PortalUser;
                }

                if (graffiti.Portal != null)
                {
                    ent["new_portalid"] = graffiti.Portal;
                }

                if (!string.IsNullOrEmpty(graffiti.Description))
                {
                    ent["new_content"] = graffiti.Description;
                }

                if (!string.IsNullOrEmpty(graffiti.ImagePath))
                {
                    ent["new_imageurl"] = graffiti.ImagePath;
                }

                if (graffiti.GraffitiId != Guid.Empty)
                {
                    ent["new_graffitiid"] = graffiti.GraffitiId;

                    service.Update(ent);
                    returnValue.Success = true;
                    returnValue.Result  = "M014"; //"Duvar yazısı güncellendi.";
                }
                else
                {
                    returnValue.CrmId   = service.Create(ent);
                    returnValue.Success = true;
                    returnValue.Result  = "M015"; //"Duvar yazısı oluşturuldu.";
                }
            }
            catch (Exception ex)
            {
                returnValue.Result  = ex.Message;
                returnValue.Success = false;
            }
            return(returnValue);
        }
示例#3
0
 public void AddGraffiti(string content, int userid)
 {
     try
     {
         Graffiti graffiti = new Graffiti()
         {
             Content = content, Posted = DateTime.Now, UserId = userid
         };
         _bbsDataContext.Graffiti.Add(graffiti);
         _bbsDataContext.SaveChanges();
     }
     catch (Exception e)
     {
         LoggingAPI.LogEntry("Exception in DataInterface.AddGraffiti: " + e.ToString());
     }
 }
示例#4
0
        private static void GenerateList()
        {
            string saveDirectoryPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); // scripts/Graffiti Mod

            List <Graffiti>          GraffitiArtList        = new List <Graffiti>();
            List <TextureDictionary> TextureDictionaryList  = new List <TextureDictionary>();
            List <string>            textureDicNamePathList = Directory.GetDirectories(saveDirectoryPath + "\\Decals").ToList();

            int textureDictCount = textureDicNamePathList.Count;
            int artCount         = 0;

            foreach (string path in textureDicNamePathList)
            {
                string folderName = path.Remove(0, path.LastIndexOf('\\') + 1);

                string[] filesWithPaths = Directory.GetFiles(@path, "*.png");
                foreach (string imageFilePath in filesWithPaths)
                {
                    Graffiti graf = new Graffiti();
                    graf.TextureDictionary = folderName;
                    graf.TextureName       = Path.GetFileNameWithoutExtension(imageFilePath);

                    // https://stackoverflow.com/a/13073341
                    var buff = new byte[32];
                    using (var d = File.OpenRead(imageFilePath))
                    {
                        d.Read(buff, 0, 32);
                    }
                    const int wOff = 16;
                    const int hOff = 20;
                    graf.TextureWidth  = BitConverter.ToInt32(new[] { buff[wOff + 3], buff[wOff + 2], buff[wOff + 1], buff[wOff + 0], }, 0);
                    graf.TextureHeight = BitConverter.ToInt32(new[] { buff[hOff + 3], buff[hOff + 2], buff[hOff + 1], buff[hOff + 0], }, 0);

                    GraffitiArtList.Add(graf);

                    artCount++;
                }
            }

            XMLHelper.SaveObjectToXML(GraffitiArtList, saveDirectoryPath + "\\" + "GraffitiTextureList.xml");

            Console.WriteLine("List saved to:" + "\n" + saveDirectoryPath);
            Console.WriteLine("\nYou have a total of " + artCount + " graffiti art spread across " + textureDictCount + " texture pack(s).");
            Console.WriteLine("\n" + "Now you can use your newly added graffiti in-game. Enjoy!");
            Console.WriteLine("\nPress any key to exit.");
        }
示例#5
0
 public void AddGraffiti(string graffiti, int userid)
 {
     try
     {
         BBSDataDataContext bbs = GetDataContext();
         Graffiti           g   = new Graffiti()
         {
             Content = graffiti, Posted = DateTime.Now, UserId = userid
         };
         bbs.Graffitis.InsertOnSubmit(g);
         bbs.SubmitChanges();
     }
     catch (Exception e)
     {
         LoggingAPI.LogEntry("Exception in DataInterface.AddGraffiti: " + e.ToString());
     }
 }
示例#6
0
	public void ShowGraffiti (Graffiti graffiti) {
		StartCoroutine(this.FadeOutGraffiti(() => {
			// Put this in an expression in case the graffiti isn't done downloading so we can attach it to its download event.
			EventHandler<EventArgs> finishShowingHandler = (object sender, EventArgs e) => {
				Graffiti senderGraffiti = sender as Graffiti;
				this.graffitiImage.sprite = senderGraffiti.Image;
				//TODO: hide the downloading spiral.
				StartCoroutine(this.FadeInGraffiti());
			};
			
			if (graffiti.IsDownloaded) {
				finishShowingHandler(graffiti, new EventArgs());
			} else {
				//TODO: show a spiral or something to show it's still downloading
				graffiti.DownloadFinishedEvent += finishShowingHandler;
			}
		}));
	}
	private IEnumerator DownloadGraffiti (Graffiti graffiti) {
		if (currentDownload != null) {
			while (!currentDownload.isDone) {
				yield return new WaitForEndOfFrame();
			}
		}
		Events.RaiseDownloadStartedEvent(new EventArgs());
		this.currentDownload = new WWW(graffiti.ImageUrl);
		while (!this.currentDownload.isDone) {
			yield return new WaitForEndOfFrame();
		}

		if (string.IsNullOrEmpty(currentDownload.error)) {
			Rect rect = new Rect(0, 0, this.currentDownload.texture.width, this.currentDownload.texture.height);
			graffiti.Image = Sprite.Create(this.currentDownload.texture, rect, new Vector2(0.5f, 0.5f));
			Events.RaiseDownloadFinishedEvent(new DownloadEventArgs(this.currentDownload));
		} else {
			graffiti.Image = null;
			Events.RaiseDownloadFinishedEvent(new DownloadEventArgs(this.currentDownload));
		}

		downloadCoroutines.RemoveAt(0);
		if (downloadCoroutines.Count == 0) currentDownload = null;
	}
示例#8
0
	public void AddLikeToGraffiti (Graffiti graffiti, string fromUser, Action<bool> callback = null) {
		StartCoroutine(this.AddLikeToGraffitiCoroutine(graffiti, fromUser, callback));
	}
 private async Task DeliverGraffitiToUser(long userTelegramId, Graffiti graffiti)
 {
     await _bot.Client.SendPhotoAsync(userTelegramId, new InputOnlineFile(graffiti.Photo586));
 }
示例#10
0
	public void ShowFirstGraffitiForArtwork (Artwork artwork) {
		//TODO: Get this to check for the total amount of art, since this exists now.
		//TODO: Start out with everything transparent/off.

		canShowNextArt = false;
		this.HideChevron(Direction.Left);
		this.HideChevron(Direction.Right);

		// First, we check if there is already graffiti downloaded locally to show.
		if (this.graffitiManager.HasGraffitiDownloadedForArtwork(this.trackedArtwork)) {
			this.downloadedGraffitiForTrackedArtwork = this.graffitiManager.DownloadedGraffiti[trackedArtwork];

			if (this.downloadedGraffitiForTrackedArtwork.Count == 1) {
				this.canShowNextArt = false;
				this.HideChevron(Direction.Right);
			} else {
				this.canShowNextArt = true;
				this.ShowChevron(Direction.Right);
			}

			Graffiti graffiti = this.downloadedGraffitiForTrackedArtwork[0];
			this.shownGraffiti = graffiti;
			this.titleText.text = graffiti.Title;
			this.posterText.text = "- " + graffiti.Poster;
			this.likeButton.transform.Find("Text").GetComponent<Text>().text = graffiti.Likes.Length.ToString();

			CrossFadeCanvasGroup(graffitiInfoUI, 1, 0.5f);
			this.augmentVC.ShowGraffiti(graffiti);
		} 
		// If there isn't, we ask the graffiti manager if there is more online.
		else {
			this.graffitiManager.GetMoreGraffitiForArtwork(this.trackedArtwork, 0, (bool succeeded, bool wasMore) => {
				if (succeeded) {
					// If there was more, change the UI stuff and tell the augmented view controller to change its image.
					if (wasMore) {
						this.downloadedGraffitiForTrackedArtwork = this.graffitiManager.DownloadedGraffiti[trackedArtwork];

						if (this.downloadedGraffitiForTrackedArtwork.Count == 1) {
							this.canShowNextArt = false;
							this.HideChevron(Direction.Right);
						} else {
							this.canShowNextArt = true;
							this.ShowChevron(Direction.Right);
						}

						Graffiti graffiti = this.downloadedGraffitiForTrackedArtwork[0];
						this.shownGraffiti = graffiti;
						this.titleText.text = graffiti.Title;
						this.posterText.text = graffiti.Poster;
						this.likeButton.transform.Find("Text").GetComponent<Text>().text = graffiti.Likes.Length.ToString();

						CrossFadeCanvasGroup(graffitiInfoUI, 1, 0.5f);
						this.augmentVC.ShowGraffiti(graffiti);
					} 
					// If there wasn't, change the UI to let the user know.
					else {
						CrossFadeCanvasGroup(graffitiInfoUI, 0, 0);
						this.augmentVC.ShowNoGraffitiText();
					}
				} else {
					this.augmentVC.ShowNetworkErrorText();
				}
			});
		}
	}
示例#11
0
	public void ShowPreviousGraffiti () {
		if (indexInGraffitiList == 0) return;

		this.indexInGraffitiList--;
		this.canShowNextArt = true;
		this.ShowChevron(Direction.Right);

		// If we are back to the first graffiti in the list, hide the left chevron.
		if (this.indexInGraffitiList == 0) {
			this.HideChevron(Direction.Left);
		}

		Graffiti graffiti = downloadedGraffitiForTrackedArtwork[this.indexInGraffitiList];
		this.shownGraffiti = graffiti;
		this.titleText.text = graffiti.Title;
		this.posterText.text = graffiti.Poster;
		this.likeButton.transform.Find("Text").GetComponent<Text>().text = graffiti.Likes.Length.ToString();
		this.augmentVC.ShowGraffiti(graffiti);
	}
示例#12
0
	public void ShowNextGraffiti () {
		this.indexInGraffitiList++;
		this.ShowChevron(Direction.Left);

		// If we're on the last graffiti downloaded, ask graffiti manager for more.
		if (this.indexInGraffitiList == this.downloadedGraffitiForTrackedArtwork.Count-1) {
			this.canShowNextArt = false;
			this.HideChevron(Direction.Right);
			this.graffitiManager.GetMoreGraffitiForArtwork(this.trackedArtwork, this.graffitiManager.DownloadedGraffiti[this.trackedArtwork].Count, (bool succeeded, bool wasMore) => {
				if (succeeded) {
					if (wasMore) {
						this.downloadedGraffitiForTrackedArtwork = this.graffitiManager.DownloadedGraffiti[this.trackedArtwork];
						this.canShowNextArt = true;
						this.ShowChevron(Direction.Right);
					}
				}
			});
		}
		Graffiti graffiti = downloadedGraffitiForTrackedArtwork[this.indexInGraffitiList];
		this.shownGraffiti = graffiti;
		this.titleText.text = graffiti.Title;
		this.posterText.text = graffiti.Poster;
		this.likeButton.transform.Find("Text").GetComponent<Text>().text = graffiti.Likes.Length.ToString();
		this.augmentVC.ShowGraffiti(graffiti);
	}
示例#13
0
        protected static MetaWeblog.Post ConvertToPost(Graffiti.Core.Post wp)
        {
            MetaWeblog.Post p = new Post();

            if(wp.Category.ParentId > 0)
                p.categories = new string[] {new CategoryController().GetCachedCategory(wp.Category.ParentId,false).Name + " > " +  wp.Category.Name };
            else
                p.categories = new string[] {wp.Category.Name};
            p.dateCreated = wp.Published;//.ToUniversalTime();
            p.description = wp.PostBody;
            p.mt_text_more = wp.ExtendedBody;

            p.link = new Macros().FullUrl(wp.Url);
            p.permalink = p.link;
            p.postid = wp.Id;
            p.title = wp.Title;
            p.wp_slug = p.mt_basename = Util.UnCleanForUrl(wp.Name);
            p.mt_keywords = wp.TagList;
            p.mt_tags = wp.TagList;
            return p;
        }
示例#14
0
        public static MsCrmResultObject GetGraffities(Guid portalId, int commentCount, int startRow, int endRow, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();
            try
            {
                #region | SQL QUERY |
                string query = @"SELECT
                                    A.*
                                FROM
                                (
                                    SELECT
                                        PG.new_graffitiId GraffitiId
                                        ,PG.new_content [Description]
                                        ,PG.new_userId PortalUserId
                                        ,PG.new_userIdName PortalUserIdName
                                        ,PG.new_portalId BrandId
                                        ,PG.new_portalIdName BrandIdName
                                        ,PG.new_imageurl [Image]
                                        ,U.new_imageurl UserImage
                                        ,CAST({4}.dbo.fn_UTCToTzSpecificLocalTime(PG.CreatedOn, us.TimeZoneBias, us.TimeZoneDaylightBias,us.TimeZoneDaylightYear, us.TimeZoneDaylightMonth, us.TimeZoneDaylightDay, us.TimeZoneDaylightHour,us.TimeZoneDaylightMinute, us.TimeZoneDaylightSecond, 0, us.TimeZoneDaylightDayOfWeek,us.TimeZoneStandardBias, us.TimeZoneStandardYear, us.TimeZoneStandardMonth, us.TimeZoneStandardDay,us.TimeZoneStandardHour, us.TimeZoneStandardMinute, us.TimeZoneStandardSecond, 0,us.TimeZoneStandardDayOfWeek) as DATETIME) CreatedOn
                                        ,ROW_NUMBER() OVER(ORDER BY PG.CreatedOn DESC) AS RowNumber
                                        ,(
                                            SELECT
                                                COUNT(0)
                                            FROM
                                                new_comment AS c (NOLOCK)
                                            WHERE
                                                c.new_graffitiId=PG.new_graffitiId
                                        ) AS CommentCount
                                        ,(
                                            SELECT
                                                COUNT(0)
                                            FROM
                                                new_likerecord AS lr (NOLOCK)
                                            WHERE
                                                lr.new_graffitiId=PG.new_graffitiId
                                        ) AS LikeCount
                                    FROM
                                        new_graffiti PG (NoLock)
                                    INNER JOIN
                                        new_user U (NoLock)
                                        ON
                                        PG.new_portalId = '{0}'
                                        AND
                                        PG.statecode = 0
                                        AND
                                        U.new_userId = PG.new_userId
                                    INNER JOIN
                                        dbo.UserSettingsBase US (NoLock)
                                        ON
                                        US.SystemUserId ='{1}'
                                    WHERE
                                        PG.statecode=0
                                    AND
                                        PG.statuscode=1 --Active
                                )A
                                WHERE
                                    A.RowNumber BETWEEN {2} AND {3}
                                ORDER BY
                                    A.RowNumber ASC";
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, portalId, Globals.AdminId, startRow, endRow, Globals.DatabaseName));
                if (dt != null && dt.Rows.Count > 0)
                {
                    List<Graffiti> returnList = new List<Graffiti>();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Graffiti _graffiti = new Graffiti();
                        _graffiti.GraffitiId = (Guid)dt.Rows[i]["GraffitiId"];
                        _graffiti.Description = dt.Rows[i]["Description"] != DBNull.Value ? dt.Rows[i]["Description"].ToString() : string.Empty;
                        _graffiti.ImagePath = dt.Rows[i]["Image"] != DBNull.Value ? dt.Rows[i]["Image"].ToString() : string.Empty;
                        _graffiti.PortalUserImage = dt.Rows[i]["UserImage"] != DBNull.Value ? dt.Rows[i]["UserImage"].ToString() : "nouserprofile.jpg";
                        _graffiti.CreatedOnString = dt.Rows[i]["CreatedOn"] != DBNull.Value ? ((DateTime)dt.Rows[i]["CreatedOn"]).ToString("dd MMMM yyyy, HH:mm", new CultureInfo("tr-TR", false)) : string.Empty;
                        _graffiti.HasMedia = dt.Rows[i]["Image"] != DBNull.Value ? true : false;

                        _graffiti.LikeCount = (int)dt.Rows[i]["LikeCount"];
                        _graffiti.CommentCount = (int)dt.Rows[i]["CommentCount"];

                        if (dt.Rows[i]["CreatedOn"] != DBNull.Value)
                        {
                            _graffiti.CreatedOn = (DateTime)dt.Rows[i]["CreatedOn"];
                        }

                        if (dt.Rows[i]["PortalUserId"] != DBNull.Value)
                        {
                            EntityReference er = new EntityReference();
                            er.LogicalName = "new_user";
                            er.Id = (Guid)dt.Rows[i]["PortalUserId"];
                            if (dt.Rows[i]["PortalUserIdName"] != DBNull.Value) { er.Name = dt.Rows[i]["PortalUserIdName"].ToString(); }

                            _graffiti.PortalUser = er;
                        }

                        if (dt.Rows[i]["BrandId"] != DBNull.Value)
                        {
                            EntityReference er = new EntityReference();
                            er.LogicalName = "new_brand";
                            er.Id = (Guid)dt.Rows[i]["BrandId"];
                            if (dt.Rows[i]["BrandIdName"] != DBNull.Value) { er.Name = dt.Rows[i]["BrandIdName"].ToString(); }

                            _graffiti.Portal = er;
                        }

                        #region | GET COMMENTS |
                        MsCrmResultObject commentResult = CommentHelper.GetGraffitiComments(_graffiti.GraffitiId, 0, commentCount, sda);
                        //MsCrmResultObject commentResult = CommentHelper.GetGraffitiComments(_graffiti.GraffitiId, sda);
                        if (commentResult.Success)
                        {
                            _graffiti.CommentList = (List<Comment>)commentResult.ReturnObject;
                        }
                        #endregion

                        returnList.Add(_graffiti);
                    }

                    returnValue.Success = true;
                    returnValue.ReturnObject = returnList;
                }
                else
                {
                    returnValue.Success = true;
                    returnValue.Result = "M013"; //"Duvar yazısı bulunamadı!";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result = ex.Message;
            }
            return returnValue;
        }
示例#15
0
        public static MsCrmResultObject GetGraffities(Guid portalId, int commentCount, int startRow, int endRow, SqlDataAccess sda)
        {
            MsCrmResultObject returnValue = new MsCrmResultObject();

            try
            {
                #region | SQL QUERY |
                string query = @"SELECT
	                                A.*
                                FROM
                                (
	                                SELECT
		                                PG.new_graffitiId GraffitiId
		                                ,PG.new_content [Description]
		                                ,PG.new_userId PortalUserId
		                                ,PG.new_userIdName PortalUserIdName
		                                ,PG.new_portalId BrandId
		                                ,PG.new_portalIdName BrandIdName
		                                ,PG.new_imageurl [Image]
		                                ,U.new_imageurl UserImage
		                                ,CAST({4}.dbo.fn_UTCToTzSpecificLocalTime(PG.CreatedOn, us.TimeZoneBias, us.TimeZoneDaylightBias,us.TimeZoneDaylightYear, us.TimeZoneDaylightMonth, us.TimeZoneDaylightDay, us.TimeZoneDaylightHour,us.TimeZoneDaylightMinute, us.TimeZoneDaylightSecond, 0, us.TimeZoneDaylightDayOfWeek,us.TimeZoneStandardBias, us.TimeZoneStandardYear, us.TimeZoneStandardMonth, us.TimeZoneStandardDay,us.TimeZoneStandardHour, us.TimeZoneStandardMinute, us.TimeZoneStandardSecond, 0,us.TimeZoneStandardDayOfWeek) as DATETIME) CreatedOn
		                                ,ROW_NUMBER() OVER(ORDER BY PG.CreatedOn DESC) AS RowNumber
                                        ,(
			                                SELECT
				                                COUNT(0)
			                                FROM
				                                new_comment AS c (NOLOCK)
			                                WHERE
				                                c.new_graffitiId=PG.new_graffitiId
                                        ) AS CommentCount
                                        ,(
			                                SELECT
				                                COUNT(0)
			                                FROM
				                                new_likerecord AS lr (NOLOCK)
			                                WHERE
				                                lr.new_graffitiId=PG.new_graffitiId
                                        ) AS LikeCount
	                                FROM
		                                new_graffiti PG (NoLock)
	                                INNER JOIN
		                                new_user U (NoLock)
		                                ON
		                                PG.new_portalId = '{0}'
		                                AND
		                                PG.statecode = 0
		                                AND
		                                U.new_userId = PG.new_userId
	                                INNER JOIN 
		                                dbo.UserSettingsBase US (NoLock)
		                                ON 
		                                US.SystemUserId ='{1}'   
                                    WHERE
	                                    PG.statecode=0
                                    AND
	                                    PG.statuscode=1 --Active    
                                )A
                                WHERE
	                                A.RowNumber BETWEEN {2} AND {3}
                                ORDER BY 
                                    A.RowNumber ASC";
                #endregion

                DataTable dt = sda.getDataTable(string.Format(query, portalId, Globals.AdminId, startRow, endRow, Globals.DatabaseName));
                if (dt != null && dt.Rows.Count > 0)
                {
                    List <Graffiti> returnList = new List <Graffiti>();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        Graffiti _graffiti = new Graffiti();
                        _graffiti.GraffitiId      = (Guid)dt.Rows[i]["GraffitiId"];
                        _graffiti.Description     = dt.Rows[i]["Description"] != DBNull.Value ? dt.Rows[i]["Description"].ToString() : string.Empty;
                        _graffiti.ImagePath       = dt.Rows[i]["Image"] != DBNull.Value ? dt.Rows[i]["Image"].ToString() : string.Empty;
                        _graffiti.PortalUserImage = dt.Rows[i]["UserImage"] != DBNull.Value ? dt.Rows[i]["UserImage"].ToString() : "nouserprofile.jpg";
                        _graffiti.CreatedOnString = dt.Rows[i]["CreatedOn"] != DBNull.Value ? ((DateTime)dt.Rows[i]["CreatedOn"]).ToString("dd MMMM yyyy, HH:mm", new CultureInfo("tr-TR", false)) : string.Empty;
                        _graffiti.HasMedia        = dt.Rows[i]["Image"] != DBNull.Value ? true : false;

                        _graffiti.LikeCount    = (int)dt.Rows[i]["LikeCount"];
                        _graffiti.CommentCount = (int)dt.Rows[i]["CommentCount"];

                        if (dt.Rows[i]["CreatedOn"] != DBNull.Value)
                        {
                            _graffiti.CreatedOn = (DateTime)dt.Rows[i]["CreatedOn"];
                        }

                        if (dt.Rows[i]["PortalUserId"] != DBNull.Value)
                        {
                            EntityReference er = new EntityReference();
                            er.LogicalName = "new_user";
                            er.Id          = (Guid)dt.Rows[i]["PortalUserId"];
                            if (dt.Rows[i]["PortalUserIdName"] != DBNull.Value)
                            {
                                er.Name = dt.Rows[i]["PortalUserIdName"].ToString();
                            }

                            _graffiti.PortalUser = er;
                        }

                        if (dt.Rows[i]["BrandId"] != DBNull.Value)
                        {
                            EntityReference er = new EntityReference();
                            er.LogicalName = "new_brand";
                            er.Id          = (Guid)dt.Rows[i]["BrandId"];
                            if (dt.Rows[i]["BrandIdName"] != DBNull.Value)
                            {
                                er.Name = dt.Rows[i]["BrandIdName"].ToString();
                            }

                            _graffiti.Portal = er;
                        }

                        #region | GET COMMENTS |
                        MsCrmResultObject commentResult = CommentHelper.GetGraffitiComments(_graffiti.GraffitiId, 0, commentCount, sda);
                        //MsCrmResultObject commentResult = CommentHelper.GetGraffitiComments(_graffiti.GraffitiId, sda);
                        if (commentResult.Success)
                        {
                            _graffiti.CommentList = (List <Comment>)commentResult.ReturnObject;
                        }
                        #endregion

                        returnList.Add(_graffiti);
                    }

                    returnValue.Success      = true;
                    returnValue.ReturnObject = returnList;
                }
                else
                {
                    returnValue.Success = true;
                    returnValue.Result  = "M013"; //"Duvar yazısı bulunamadı!";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result  = ex.Message;
            }
            return(returnValue);
        }
示例#16
0
	private IEnumerator PullGraffitiFromServerCoroutine (Artwork originalArt, int numberOfPosts, int startingFrom, Action<bool, Graffiti[]> callback) {
		var query = ParseObject.GetQuery("Graffiti")
			.WhereEqualTo("originalArtId", originalArt.Id)
			.Limit(numberOfPosts)
			.Skip(startingFrom)
			.OrderBy("createdAt");

		var queryTask = query.FindAsync();
		while (!queryTask.IsCompleted) {
			yield return new WaitForEndOfFrame();
		}

		if (!queryTask.IsFaulted) {
			Debug.Log("Parse call was successful!");
			IEnumerable<ParseObject> results = queryTask.Result;
			List<Graffiti> graffitiArray = new List<Graffiti>();
			
			foreach (ParseObject graffitiPacket in results) {
				string imageUrl = graffitiPacket.Get<ParseFile>("image").Url.AbsoluteUri;
				string poster = graffitiPacket.Get<string>("poster");
				string title = graffitiPacket.Get<string>("title");
				IList<object> likes = graffitiPacket.Get<IList<object>>("likes");
				string[] likesArray = new string[likes.Count];
				int index = 0;
				foreach (string like in likes) {
					likesArray[index] = like;
					index++;
				}
				
				Graffiti graffiti = new Graffiti(imageUrl, originalArt, title, poster, likesArray, graffitiPacket.ObjectId);
				downloadManager.QueueDownloadForGraffiti(graffiti);
				graffitiArray.Add(graffiti);
			}
			
			if (callback != null) {
				callback(true, graffitiArray.ToArray());
			}
		} else {
			Debug.LogError("Network error");
			if (callback != null) {
				callback(false, null);
			}
		}
	}
示例#17
0
        public MsCrmResult SaveGraffiti(string token, Graffiti graffiti)
        {
            MsCrmResult returnValue = new MsCrmResult();
            LoginSession ls = new LoginSession();

            try
            {
                if (graffiti.HasMedia == false && (string.IsNullOrWhiteSpace(graffiti.Description)))
                {
                    returnValue.Result = "Duvar yazısı paylaşmak için içerik veya resim içeriği eklemelisiniz.";

                    return returnValue;
                }

                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);
                    returnValue = GraffitiHelper.SaveOrUpdateGraffiti(graffiti, service);
                }
                else
                {
                    returnValue.Success = false;
                    returnValue.Result = "M003"; //"Eksik parametre!-SaveGraffiti";
                }
            }
            catch (Exception ex)
            {
                returnValue.Success = false;
                returnValue.Result = ex.Message + "-SaveGraffiti";
            }
            return returnValue;
        }
示例#18
0
	public void AddLikeToGraffiti (Graffiti graffiti) {
		this.parseManager.AddLikeToGraffiti(graffiti, PlayerPrefs.GetString("username"));
	}
示例#19
0
	private IEnumerator AddLikeToGraffitiCoroutine (Graffiti graffiti, string fromUser, Action<bool> callback) {
		ParseQuery<ParseObject> query = ParseObject.GetQuery("Graffiti");
		var queryTask = query.GetAsync(graffiti.ParseId);
		while (!queryTask.IsCompleted) {
			yield return new WaitForEndOfFrame();
		}

		ParseObject currentGraffiti = queryTask.Result;
		currentGraffiti.AddToList("likes", fromUser);

		var updateTask = currentGraffiti.SaveAsync();
		while (!updateTask.IsCompleted) {
			yield return new WaitForEndOfFrame();
		}

		if (!updateTask.IsFaulted) {
			if (callback != null) {
				callback(true);
			}
		} else {
			Debug.LogError("Network error");
			if (callback != null) {
				callback(false);
			}
		}
	}
示例#20
0
        public static MsCrmResult SaveOrUpdateGraffiti(Graffiti graffiti, IOrganizationService service)
        {
            MsCrmResult returnValue = new MsCrmResult();
            try
            {
                Entity ent = new Entity("new_graffiti");

                ent["new_name"] = graffiti.PortalUser.Name + "-" + DateTime.Now.ToString("dd.MM.yyyy HH:mm");

                ent["new_hasmedia"] = graffiti.HasMedia;

                if (graffiti.PortalUser != null)
                {
                    ent["new_userid"] = graffiti.PortalUser;
                }

                if (graffiti.Portal != null)
                {
                    ent["new_portalid"] = graffiti.Portal;
                }

                if (!string.IsNullOrEmpty(graffiti.Description))
                {
                    ent["new_content"] = graffiti.Description;
                }

                if (!string.IsNullOrEmpty(graffiti.ImagePath))
                {
                    ent["new_imageurl"] = graffiti.ImagePath;
                }

                if (graffiti.GraffitiId != Guid.Empty)
                {
                    ent["new_graffitiid"] = graffiti.GraffitiId;

                    service.Update(ent);
                    returnValue.Success = true;
                    returnValue.Result = "M014"; //"Duvar yazısı güncellendi.";
                }
                else
                {
                    returnValue.CrmId = service.Create(ent);
                    returnValue.Success = true;
                    returnValue.Result = "M015"; //"Duvar yazısı oluşturuldu.";
                }
            }
            catch (Exception ex)
            {
                returnValue.Result = ex.Message;
                returnValue.Success = false;
            }
            return returnValue;
        }
示例#21
0
	private IEnumerator PushNewGraffitiToServerCoroutine (Texture2D image, Artwork originalArt, string title, string poster, Action<bool, Graffiti> callback) {
		// Begin by encoding the image to PNG and saving that to the server.
		byte[] data = image.EncodeToPNG();
		var imageFile = new ParseFile("image.png", data);
		
		Task imageSaveTask = imageFile.SaveAsync();
		while (!imageSaveTask.IsCompleted) {
			yield return new WaitForEndOfFrame();
		}

		// Once that has saved, construct the Graffiti ParseObject and save that.
		if (!imageSaveTask.IsFaulted) {
			ParseObject graffitiPO = new ParseObject("Graffiti");
			graffitiPO["image"] = imageFile;
			graffitiPO["originalArtId"] = originalArt.Id;
			graffitiPO["poster"] = poster;
			graffitiPO["title"] = title;
			graffitiPO["likes"] = new string[0];
			
			Task graffitiSaveTask = graffitiPO.SaveAsync();
			while (!graffitiSaveTask.IsCompleted) {
				yield return new WaitForEndOfFrame();
			}

			if (!graffitiSaveTask.IsFaulted) {
				// Once that has saved, get the affiliated Artwork ParseObject.
				ParseQuery<ParseObject> query = ParseObject.GetQuery("Artwork")
					.WhereEqualTo("objectId", originalArt.Id);
				var queryTask = query.FirstAsync();
				while (!queryTask.IsCompleted) {
					yield return new WaitForEndOfFrame();
				}

				if (!queryTask.IsFaulted) {
					// Once that has been retrieved, update it.
					ParseObject artworkPO = queryTask.Result;
					artworkPO.Increment("NumberOfGraffiti");
					var graffitiRelation = artworkPO.GetRelation<ParseObject>("Graffiti");
					graffitiRelation.Add(graffitiPO);

					var artworkUpdateTask = artworkPO.SaveAsync();
					while (!artworkUpdateTask.IsCompleted) {
						yield return new WaitForEndOfFrame();
					}

					if (!artworkUpdateTask.IsFaulted) {
						// And finally, once the Artwork has been successfully updated, we can finish.
						Rect rect = new Rect(0, 0, image.width, image.height);
						Sprite imageSprite = Sprite.Create(image, rect, new Vector2(0.5f, 0.5f));
						Graffiti graffiti = new Graffiti(imageSprite, originalArt, title, poster, new string[0], graffitiPO.ObjectId);
					
						if (callback != null) {
							callback(true, graffiti);
						}
					} else {
						Debug.LogError("Network error");
						if (callback != null) {
							callback(false, null);
						}
					}
				}
			} else {
				Debug.LogError("Network error");
				if (callback != null) {
					callback(false, null);
				}
			}
		} else {
			Debug.LogError("Network error");
			if (callback != null) {
				callback(false, null);
			}
		}
	}