public LoginResultModel(LibVisLib.Profile p) { Result = 0; ResultComplement = ""; LastLoginDate = DateTime.Now; NumberOfTentatives = 0; Token = ""; Account = new AccountModel(p, true, p.user.GetProfileForInternalSystem(RacLib.InternalSystem.LibVisId) >= RacLib.BaseUser.InternalSystemProfile.InternalStaff); }
/// <summary> /// Retorna o usuário /// </summary> /// <param name="userid"></param> /// <returns></returns> static public AccountModel GetUser(string userid, bool own, bool full) { LibVisLib.Profile p = LibVisLib.Profile.LoadProfile(userid); if (p != null) { AccountModel m = new AccountModel(p, own, full); return(m); } else { return(new AccountModel()); } }
public UserNameId(LibVisLib.Profile p) { Name = p.user.name; Email = p.user.email; Id = p.user.id; }
public AccountModel(LibVisLib.Profile p, bool isOwn, bool isInternal) { Id = p.user.id; Email = p.user.email; Name = p.user.name; Profile = (int)p.user.GetProfileForInternalSystem(RacLib.InternalSystem.LibVisId); RacLib.RacMsg msgs = RacLib.RacMsg.cache.GetMessage(p.user.defaultLanguage); if (isOwn || isInternal) { Bitcoin = p.bitcoin; } else { Bitcoin = ""; } ProfileName = msgs.Get(RacLib.RacMsg.Id.Anonymous); if (p.user.GetProfileForInternalSystem(RacLib.InternalSystem.LibVisId) >= RacLib.BaseUser.InternalSystemProfile.Public) { ProfileName = ProfileName = msgs.Get(RacLib.RacMsg.Id.User); } if (p.user.GetProfileForInternalSystem(RacLib.InternalSystem.LibVisId) >= RacLib.BaseUser.InternalSystemProfile.InternalStaff) { ProfileName = ProfileName = msgs.Get(RacLib.RacMsg.Id.Internal); } if (p.user.GetProfileForInternalSystem(RacLib.InternalSystem.LibVisId) >= RacLib.BaseUser.InternalSystemProfile.Administrator) { ProfileName = ProfileName = msgs.Get(RacLib.RacMsg.Id.Administrator); } if (isOwn || isInternal) { NewsLetter = p.newsLetter; p.CheckMedals(); Xp = (int)p.xp; NextXp = (int)p.nextXp; Ap = (int)p.ap; NextAp = (int)p.nextAp; Rp = (int)p.rp; NextRp = (int)p.nextRp; Op = (int)p.op; NextOp = (int)p.nextOp; Qp = (int)p.qp; NextQp = (int)p.nextQp; Tp = (int)p.tp; NextTp = (int)p.nextTp; Up = (int)p.up; NextUp = (int)p.nextUp; Sp = (int)p.sp; NextSp = (int)p.nextSp; Ep = (int)p.ep; NextEp = (int)p.nextEp; } else { Xp = 0; NextXp = 0; Ap = 0; NextAp = 0; Rp = 0; NextRp = 0; Op = 0; NextOp = 0; Qp = 0; NextQp = 0; Tp = 0; NextTp = 0; Up = 0; NextUp = 0; Sp = 0; NextSp = 0; Ep = 0; NextEp = 0; } Medals = new List <MedalsModel>(); for (int i = 0; i < p.medals.Count; i++) { MedalsModel m = new MedalsModel(msgs, p.medals[i].medals); Medals.Add(m); } Payments = new List <PaymentModel>(); if (isOwn || isInternal) { for (int i = 0; i < p.payments.Count; i++) { PaymentModel pa = new PaymentModel(p.payments[i]); Payments.Add(pa); } } Videos = new List <ValuesPerVideoPerUser>(); Value = 0; if (isOwn || isInternal) { int year = DateTime.Now.Year; int month = DateTime.Now.Month; DateTime start = new DateTime(year, month, 1); DateTime end = new DateTime(year, month, DateTime.DaysInMonth(year, month), 23, 59, 59); List <LibVisLib.Article> articles = LibVisLib.Article.ListPublishedArticlesForInterval(Id, start, end); double val = 0; for (int i = 0; i < articles.Count; i++) { Article art = articles[i]; ArticleAction a0 = art.GetActionForType(ArticleAction.ActionType.Created); if (a0 != null && a0.userId == Id) { ValuesPerVideoPerUser a = new ValuesPerVideoPerUser(msgs, a0); Videos.Add(a); val += a.Total; } ArticleAction a1 = art.GetActionForType(ArticleAction.ActionType.Revised); if (a1 != null && a1.userId == Id) { ValuesPerVideoPerUser a = new ValuesPerVideoPerUser(msgs, a1); Videos.Add(a); val += a.Total; } ArticleAction a2 = art.GetActionForType(ArticleAction.ActionType.IncludedNaration, art.finalNarratorId); if (a2 != null && a2.userId == Id) { ValuesPerVideoPerUser a = new ValuesPerVideoPerUser(msgs, a2); Videos.Add(a); val += a.Total; } ArticleAction a3 = art.GetActionForType(ArticleAction.ActionType.Produced); if (a3 != null && a3.userId == Id) { ValuesPerVideoPerUser a = new ValuesPerVideoPerUser(msgs, a3); Videos.Add(a); val += a.Total; } } Value = val; } TotalQualification = p.GetTotalQualification(msgs); EditorQualification = p.GetEditorQualification(msgs); ReporterQualification = p.GetReporterQualification(msgs); if (EditorQualification != "" && ReporterQualification != "") { GeneralQualification = EditorQualification + ", " + ReporterQualification; } else { GeneralQualification = EditorQualification + ReporterQualification; } if (Profile >= 9) { GeneralQualification += ((GeneralQualification != "") ? " " : "") + "(Admin)"; Staff = 1; Admin = 1; } else if (Profile >= 7) { GeneralQualification += ((GeneralQualification != "") ? " " : "") + "(Staff)"; Staff = 1; } else { Staff = p.staff ? 1 : 0; } Lang = p.user.defaultLanguageId; RoleTranslatorEn = p.translatorEnglish ? 1 : 0; RoleTranslatorPt = p.translatorPortuguese ? 1 : 0; RoleTranslatorEs = p.translatorSpanish ? 1 : 0; RoleRevisorEn = p.revisorEnglish ? 1 : 0; RoleRevisorPt = p.revisorPortuguese ? 1 : 0; RoleRevisorEs = p.revisorSpanish ? 1 : 0; RoleNarratorEn = p.narratorEnglish ? 1 : 0; RoleNarratorPt = p.narratorPortuguese ? 1 : 0; RoleNarratorEs = p.narratorSpanish ? 1 : 0; RoleProducerEn = p.producerEnglish ? 1 : 0; RoleProducerPt = p.producerPortuguese ? 1 : 0; RoleProducerEs = p.producerSpanish ? 1 : 0; Sponsor = p.sponsor ? 1 : 0; Blocked = p.user.isBlocked || p.user.isDisabled ? 1 : 0; NotConfirmed = p.user.isConfirmed ? 0 : 1; if (p.user.defaultLanguage == RacLib.RacMsg.Language.Portugues) { Translator = p.translatorPortuguese ? 1 : 0; Revisor = p.revisorPortuguese ? 1 : 0; Narrator = p.narratorPortuguese ? 1 : 0; Producer = p.producerPortuguese ? 1 : 0; } else if (p.user.defaultLanguage == RacLib.RacMsg.Language.Espanol) { Translator = p.translatorSpanish ? 1 : 0; Revisor = p.revisorSpanish ? 1 : 0; Narrator = p.narratorSpanish ? 1 : 0; Producer = p.producerSpanish ? 1 : 0; } else { Translator = p.translatorEnglish ? 1 : 0; Revisor = p.revisorEnglish ? 1 : 0; Narrator = p.narratorEnglish ? 1 : 0; Producer = p.producerEnglish ? 1 : 0; } }
public GenericStatusModel RegisterGrant(string token, [FromBody] RegisterGrant grant) { GenericStatusModel gsm = new GenericStatusModel(); gsm.Result = 0; gsm.ResultComplement = ""; // Verifica o token de autenticação string machine = HttpContext.Features.Get <IHttpConnectionFeature>()?.RemoteIpAddress.ToString(); string userId = SessionCode.ValidateSessionCode(token, machine); if (userId == null) { gsm.Result = (int)RacMsg.Id.InvalidTokenInExpression; gsm.ResultComplement = "Token inválido"; } LibVisLib.Profile prf = LibVisLib.Profile.LoadProfile(userId); if (prf == null) { gsm.Result = (int)RacMsg.Id.InvalidTokenInExpression; gsm.ResultComplement = "Usuário não encontrado"; } if (!prf.user.isInternal) { gsm.Result = (int)RacMsg.Id.UserHasNoRightToThisItem; gsm.ResultComplement = "Usuário não tem direitos para essa ação"; } if (gsm.Result == 0) { try { if (!LibVisLib.Verify.AcceptGuidOrNull(grant.ActionId)) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Caracteres inválidos no id da ação; "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errActionId: Invalid chars"); } if (!LibVisLib.Verify.AcceptGuidOrNull(grant.AwardId)) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Caracteres inválidos no id do premio; "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errActionId: Invalid chars"); } if (grant.Add < 0 || grant.Add > 1) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Ação inválida; "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errAdd: Invalid value"); } if (gsm.Result == 0) { string actionId = LibVisLib.Verify.VerifyGuid(grant.ActionId); string awardId = LibVisLib.Verify.VerifyGuid(grant.AwardId); LibVisLib.TargetAction trga = LibVisLib.TargetAction.LoadTargetAction(actionId); if (trga == null) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Ação inválida; "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errTargetId: Invalid target"); } else { if (grant.Add == 0) { trga.RemoveGrant(grant.AwardId); } else { trga.AddGrant(grant.AwardId, userId); } trga.Save(); } } } catch (Exception ex) { if (!ex.Message.StartsWith("Thread was being aborted")) { gsm.Result = (int)RacLib.RacMsg.Id.InternalError; gsm.ResultComplement += ex.Message; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.InternalError, "Exception in form"); RacLib.BaseLog.log.Log(ex); } } } return(gsm); }
public GenericIdModel Change(string token, [FromBody] ChangeVideoModel video) { GenericIdModel gsm = new GenericIdModel(); gsm.Result = 0; gsm.ResultComplement = ""; gsm.Id = ""; int lang = video.Lang; if (lang < 3 || lang > 4) { lang = 2; } RacLib.RacMsg msgs = RacLib.RacMsg.cache.GetMessage((RacLib.RacMsg.Language)lang); // Verifica o token de autenticação string machine = HttpContext.Features.Get <IHttpConnectionFeature>()?.RemoteIpAddress.ToString(); string userId = SessionCode.ValidateSessionCode(token, machine); if (userId == null) { gsm.Result = (int)RacMsg.Id.InvalidToken; gsm.ResultComplement = msgs.Get(RacMsg.Id.InvalidToken); } LibVisLib.Profile prf = LibVisLib.Profile.LoadProfile(userId); if (prf == null) { gsm.Result = (int)RacMsg.Id.UserNotFound; gsm.ResultComplement = msgs.Get(RacMsg.Id.UserNotFound); } if (gsm.Result == 0) { if (prf.user.profile < BaseUser.InternalSystemProfile.InternalStaff) { gsm.Result = (int)RacMsg.Id.Number; gsm.ResultComplement = "Você não tem direitos para cadastrar vídeos; "; } try { if (!LibVisLib.Verify.AcceptGuid(video.Id)) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Caracteres inválidos no Id do vídeo; "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errId: Invalid chars"); } if (!LibVisLib.Verify.AcceptInteger(video.Categ)) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Caracteres inválidos nas categorias; "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errCateg: Invalid chars"); } string r0 = ""; if (!LibVisLib.Verify.AcceptFreeText(video.Title, ref r0)) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Caracteres inválidos no título (" + r0 + "); "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errTitle: Invalid chars"); } string r1 = ""; if (!LibVisLib.Verify.AcceptMultilineFreeText(video.Description, ref r1)) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Caracteres inválidos na descrição (" + r1 + "); "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errDescription: Invalid chars (" + r1 + "); "); } string r2 = ""; if (!LibVisLib.Verify.AcceptFreeText(video.Tags, ref r2)) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Caracteres inválidos na tag (" + r2 + "); "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errTags: Invalid chars"); } r1 = ""; if (!LibVisLib.Verify.AcceptFreeText(video.Image, ref r1)) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Caracteres inválidos nos dados da imagem (" + r1 + "); "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errImage: Invalid chars (imagem base64) (" + r1 + "); "); } if (!LibVisLib.Verify.AcceptUrl(video.YoutubeLink)) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Caracteres inválidos no link do youtube; "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errYoutubeLink: Invalid chars"); } if (!LibVisLib.Verify.AcceptUrl(video.BitchuteLink)) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Caracteres inválidos no link do bitchute; "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errBitchuteLink: Invalid chars"); } r1 = ""; if (!LibVisLib.Verify.AcceptMultilineFreeText(video.Script, ref r1)) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Caracteres inválidos na descrição (" + r1 + "); "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errDescription: Invalid chars (" + r1 + "); "); } string imagem = video.Image; string[] imagempart = imagem.Split(','); if (imagempart.Length > 0) { imagem = imagempart[imagempart.Length - 1]; } string videoId = LibVisLib.Verify.VerifyGuid(video.Id); string title = LibVisLib.Verify.VerifyFreeText(video.Title); string tags = LibVisLib.Verify.VerifyFreeText(video.Tags); string description = LibVisLib.Verify.VerifyMultilineFreeText(video.Description); string categ = LibVisLib.Verify.VerifyInteger(video.Categ); string youtubelink = LibVisLib.Verify.VerifyUrl(video.YoutubeLink); string bitchutelink = LibVisLib.Verify.VerifyUrl(video.BitchuteLink); string script = LibVisLib.Verify.VerifyMultilineFreeText(video.Script); if (videoId == null || videoId.Length < 36) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Id do vídeo inválido; "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errId: Id inválido"); } if (title.Length < 10) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Titulo muito pequeno (mínimo 10 caracteres); "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errTitle: required at least 10 chars"); } if (title.Length > 150) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Titulo muito grande (máximo 150 caracteres); "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errTitle: Content too big"); } if (description.Length < 10) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Texto muito pequeno (mínimo 10 caracteres); "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errTexto: required at least 10 chars"); } if (description.Length > 5000) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Descrição muito grande (máximo 5k caracteres); "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errDescription: Content too big"); } if (script.Length > 100000) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Script muito grande (máximo 100k caracteres); "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errScript: Content too big"); } if (imagem.Length > 5000000) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += "Imagem muito grande (máximo 500k caracteres); "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errImage: Content too big"); } if (gsm.Result == 0) { LibVisLib.Video vid = Video.LoadVideo(videoId); vid.title = title; vid.description = description; vid.released = DateTime.Now; vid.script = script; vid.linkBitchute = bitchutelink; vid.linkYoutube = youtubelink; vid.tags = tags; vid.language = (RacMsg.Language)lang; vid.categories = new List <string>(); int ic = 0; for (int i = 0; i < LibVisLib.Category.categories.Count; i++) { if (!LibVisLib.Category.categories[i].main) { if (ic < categ.Length && categ[ic++] == '1') { vid.categories.Add(Category.categories[i].label); } } } vid.NormalizeMain(); vid.Save(); byte[] str = Convert.FromBase64String(imagem); MemoryStream ms = new MemoryStream(str, 0, str.Length); ms.Write(str, 0, str.Length); System.Drawing.Image img = System.Drawing.Image.FromStream(ms, true); string path = Base.conf.tempImageFilePath + "\\v-" + vid.id + ".jpg"; img.Save(path, System.Drawing.Imaging.ImageFormat.Jpeg); VideoAction act = new VideoAction(vid); act.date = vid.released; act.type = VideoAction.ActionType.Created; act.userId = userId; act.show = true; act.observation = ""; act.Save(); gsm.Id = vid.id; } } catch (Exception ex) { if (!ex.Message.StartsWith("Thread was being aborted")) { gsm.Result = (int)RacLib.RacMsg.Id.InternalError; gsm.ResultComplement += ex.Message; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.InternalError, "Exception in form"); RacLib.BaseLog.log.Log(ex); } } } return(gsm); }
public GenericIdModel Register(string token, [FromBody] NewVideoModel video) { GenericIdModel gsm = new GenericIdModel(); gsm.Result = 0; gsm.ResultComplement = ""; gsm.Id = ""; int lang = LibVisLib.Verify.ValidLanguage(video.Lang); RacMsg msgs = RacMsg.cache.GetMessage((RacMsg.Language)lang); // Verifica o token de autenticação string machine = HttpContext.Features.Get <IHttpConnectionFeature>()?.RemoteIpAddress.ToString(); string userId = SessionCode.ValidateSessionCode(token, machine); if (userId == null) { gsm.Result = (int)RacMsg.Id.InvalidToken; gsm.ResultComplement = msgs.Get(RacMsg.Id.InvalidToken); } LibVisLib.Profile prf = LibVisLib.Profile.LoadProfile(userId); if (prf == null) { gsm.Result = (int)RacMsg.Id.UserNotFound; gsm.ResultComplement = msgs.Get(RacMsg.Id.UserNotFound); } if (gsm.Result == 0) { if (prf.user.profile < BaseUser.InternalSystemProfile.InternalStaff) { gsm.Result = (int)RacMsg.Id.UserHasNoRightToThisItem; gsm.ResultComplement = msgs.Get(RacMsg.Id.UserHasNoRightToThisItem); } try { if (!LibVisLib.Verify.AcceptInteger(video.Categ)) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += msgs.Get(RacMsg.Id.InvalidCharsInCategories) + "; "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errCateg: Invalid chars"); } string r0 = ""; if (!LibVisLib.Verify.AcceptFreeText(video.Title, ref r0)) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += msgs.Get(RacMsg.Id.InvalidCharactersInTitle) + " (" + r0 + "); "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errTitle: Invalid chars"); } string r1 = ""; if (!LibVisLib.Verify.AcceptMultilineFreeText(video.Description, ref r1)) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += msgs.Get(RacMsg.Id.InvalidCharactersInText) + " (" + r1 + "); "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errDescription: Invalid chars (" + r1 + "); "); } string r2 = ""; if (!LibVisLib.Verify.AcceptFreeText(video.Tags, ref r2)) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += msgs.Get(RacMsg.Id.InvalidCharactersInTags) + " (" + r2 + "); "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errTags: Invalid chars"); } r1 = ""; if (!LibVisLib.Verify.AcceptFreeText(video.Image, ref r1)) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += msgs.Get(RacMsg.Id.InvalidCharactersInImageData) + " (" + r1 + "); "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errImage: Invalid chars (imagem base64) (" + r1 + "); "); } if (!LibVisLib.Verify.AcceptUrl(video.YoutubeLink)) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += msgs.Get(RacMsg.Id.InvalidCharactersInYoutubeUrl) + "; "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errYoutubeLink: Invalid chars"); } if (!LibVisLib.Verify.AcceptUrl(video.BitchuteLink)) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += msgs.Get(RacMsg.Id.InvalidCharactersInBitchuteUrl) + "; "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errBitchuteLink: Invalid chars"); } r1 = ""; if (!LibVisLib.Verify.AcceptMultilineFreeText(video.Script, ref r1)) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += msgs.Get(RacMsg.Id.InvalidCharactersInTheVideoScript) + "; "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errDescription: Invalid chars (" + r1 + "); "); } string imagem = video.Image; string[] imagempart = imagem.Split(','); if (imagempart.Length > 0) { imagem = imagempart[imagempart.Length - 1]; } string title = LibVisLib.Verify.VerifyFreeText(video.Title); string description = LibVisLib.Verify.VerifyMultilineFreeText(video.Description); string tags = LibVisLib.Verify.VerifyFreeText(video.Tags); string categ = LibVisLib.Verify.VerifyInteger(video.Categ); string youtubelink = LibVisLib.Verify.VerifyUrl(video.YoutubeLink); string bitchutelink = LibVisLib.Verify.VerifyUrl(video.BitchuteLink); string script = LibVisLib.Verify.VerifyMultilineFreeText(video.Script); if (title.Length < 10) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += msgs.Get(RacMsg.Id.TitleTooShort) + "; "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errTitle: required at least 10 chars"); } if (title.Length > 150) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += msgs.Get(RacMsg.Id.TitleTooLong) + "; "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errTitle: Content too big"); } if (description.Length < 10) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += msgs.Get(RacMsg.Id.TextTooShort) + "; "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errTexto: required at least 10 chars"); } if (description.Length > 5000) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += msgs.Get(RacMsg.Id.TextTooLong) + "; "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errDescription: Content too big"); } if (script.Length > 100000) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += msgs.Get(RacMsg.Id.ScriptTooLong) + "; "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errScript: Content too big"); } if (imagem.Length > 5000000) { gsm.Result = (int)RacLib.RacMsg.Id.Error; gsm.ResultComplement += msgs.Get(RacMsg.Id.ImageTooLarge) + "; "; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.Error, "errImage: Content too big"); } if (gsm.Result == 0) { LibVisLib.Video vid = new Video(); vid.title = title; vid.description = description; vid.released = DateTime.Now; vid.script = script; vid.linkBitchute = bitchutelink; vid.linkYoutube = youtubelink; vid.tags = tags; vid.language = (RacMsg.Language)lang; vid.categories = new List <string>(); int ic = 0; for (int i = 0; i < LibVisLib.Category.categories.Count; i++) { if (!LibVisLib.Category.categories[i].main) { if (ic < categ.Length && categ[ic++] == '1') { vid.categories.Add(Category.categories[i].label); } } } vid.NormalizeMain(); vid.Save(); byte[] str = Convert.FromBase64String(imagem); MemoryStream ms = new MemoryStream(str, 0, str.Length); ms.Write(str, 0, str.Length); System.Drawing.Image img = System.Drawing.Image.FromStream(ms, true); string path = Base.conf.tempImageFilePath + "\\v-" + vid.id + ".jpg"; img.Save(path, System.Drawing.Imaging.ImageFormat.Jpeg); VideoAction act = new VideoAction(vid); act.date = vid.released; act.type = VideoAction.ActionType.Created; act.userId = userId; act.show = true; act.observation = ""; act.Save(); //prf.RegisterAction(Profile.ProfileAction.Reg); gsm.Id = vid.id; } } catch (Exception ex) { if (!ex.Message.StartsWith("Thread was being aborted")) { gsm.Result = (int)RacLib.RacMsg.Id.InternalError; gsm.ResultComplement += ex.Message; RacLib.BaseLog.log.Log(RacLib.BaseLog.LogType.InternalError, "Exception in form"); RacLib.BaseLog.log.Log(ex); } } } return(gsm); }
/// <summary> /// Cria novo /// </summary> public ProfileMedals(Profile p) { profInt = p; awardedInt = RacMsg.NullDateTime; medalsInt = ""; }