public static string get_application_icon_url(Guid?applicationId, bool highQuality = false, bool networkAddress = false) { FolderNames folderName = highQuality ? FolderNames.HighQualityApplicationIcon : FolderNames.ApplicationIcons; if (!applicationId.HasValue || applicationId == Guid.Empty) { string addr = RaaiVanSettings.LogoMiniURL; return(highQuality ? string.Empty : (networkAddress ? addr.Replace("../..", RaaiVanSettings.RaaiVanURL(applicationId)) : addr)); } DocFileInfo fi = new DocFileInfo() { FileID = applicationId, OwnerID = applicationId, Extension = "jpg", FolderName = folderName }; string retUrl = fi.exists(applicationId) ? fi.url(applicationId) : string.Empty; if (string.IsNullOrEmpty(retUrl) && !highQuality) { retUrl = RaaiVanSettings.LogoMiniURL; } return(networkAddress ? retUrl.Replace("../..", RaaiVanSettings.RaaiVanURL(applicationId)) : retUrl); }
public static string get_personal_image_address(Guid?applicationId, Guid?userId, bool networkAddress = false, bool highQuality = false) { if (RaaiVanSettings.SAASBasedMultiTenancy) { applicationId = null; } if (!userId.HasValue || userId == Guid.Empty) { string addr = PublicConsts.DefaultProfileImageURL; return(highQuality ? string.Empty : (networkAddress ? addr.Replace("../..", RaaiVanSettings.RaaiVanURL(applicationId)) : addr)); } FolderNames folderName = highQuality ? FolderNames.HighQualityProfileImage : FolderNames.ProfileImages; DocFileInfo fi = new DocFileInfo() { FileID = userId, Extension = "jpg", FolderName = folderName }; string address = !fi.exists(applicationId) ? (highQuality ? string.Empty : PublicConsts.DefaultProfileImageURL) : fi.url(applicationId); return(networkAddress ? address.Replace("../..", RaaiVanSettings.RaaiVanURL(applicationId)) : address); }
public void ExchangeDataWithServer(I2_InfoDisplay d, I6_WhatsAppProcess p) { string url = p.Debug_AmendUrl(FolderNames.GetUrl(this.urlToUse), toASP.GetCounters().Total_ResultsString()); toASP = new Data_Net_Tray2ASP(); fromASP = new Data_Net_ASP2Tray(); }
public static bool create_icon(Guid?applicationId, Guid iconId, IconType iconType, byte[] fileContent, ref string errorMessage, ref IconMeta meta) { int width = 100, height = 100, highQualityWidth = 600, highQualityHeight = 600; FolderNames imageFolder = FolderNames.ProfileImages, highQualityImageFolder = FolderNames.HighQualityProfileImage; bool isValid = DocumentUtilities.get_icon_parameters(applicationId, iconType, ref width, ref height, ref highQualityWidth, ref highQualityHeight, ref imageFolder, ref highQualityImageFolder); if (!isValid) { return(false); } DocFileInfo highQualityFile = new DocFileInfo() { FileID = iconId, Extension = "jpg", FolderName = highQualityImageFolder }; DocFileInfo file = new DocFileInfo() { FileID = iconId, Extension = "jpg", FolderName = imageFolder }; byte[] hqContent = new byte[0]; bool succeed = RVGraphics.make_thumbnail(applicationId, fileContent, highQualityFile, ref hqContent, highQualityWidth, highQualityHeight, width, height, ref errorMessage, highQualityFile.Extension, dontStore: false); return(succeed && hqContent != null && hqContent.Length > 0 && RVGraphics.extract_thumbnail(applicationId, highQualityFile, hqContent, file, -1, -1, -1, -1, width, height, ref errorMessage, ref meta)); }
public static string get_cover_photo_url(Guid?applicationId, Guid?ownerId, bool networkAddress = false, bool highQuality = false) { if (RaaiVanSettings.SAASBasedMultiTenancy) { applicationId = null; } if (!ownerId.HasValue || ownerId == Guid.Empty) { string addr = PublicConsts.DefaultCoverPhotoURL; return(highQuality ? string.Empty : (networkAddress ? addr.Replace("../..", RaaiVanSettings.RaaiVanURL(applicationId)) : addr)); } FolderNames folderName = highQuality ? FolderNames.HighQualityCoverPhoto : FolderNames.CoverPhoto; DocFileInfo fi = new DocFileInfo() { FileID = ownerId, OwnerID = ownerId, Extension = "jpg", FolderName = folderName }; string retUrl = fi.exists(applicationId) ? fi.url(applicationId) : string.Empty; return(networkAddress ? retUrl.Replace("../..", RaaiVanSettings.RaaiVanURL(applicationId)) : retUrl); }
public static void Load(Page page, Which which) { try { XmlDocument xD = new XmlDocument(); xD.Load(FolderNames.GetFolder(NiceSystemInfo.DEFAULT, MyFolders.ASP_ServerStateFolder) + "\\KeyWords\\KeyWords.xml"); XmlNode allkeyNode = xD["KeyWords"]; XmlNode keyNode = null; switch (which) { case Which.Default: keyNode = allkeyNode["Default"]; break; case Which.HowItWorks: keyNode = allkeyNode["HowItWorks"]; break; case Which.HowToUse: keyNode = allkeyNode["HowToUse"]; break; case Which.Login: keyNode = allkeyNode["Login"]; break; case Which.Register: keyNode = allkeyNode["Register"]; break; case Which.Price: keyNode = allkeyNode["Price"]; break; } page.MetaKeywords = keyNode["KeyWords"].InnerText; page.MetaDescription = keyNode["Description"].InnerText; page.Title = keyNode["Title"].InnerText; } catch { } }
protected void Page_Load(object sender, EventArgs e) { // This come from an anonymous browser try { if (!IsPostBack) { if (!FolderNames.IsDevMachine()) { if (Request["SCRIPT_NAME"] != "/default.aspx") { Response.Redirect("~/ItemX.aspx?id=Home"); } } Page.MetaKeywords = "API, Online, Send Whatsapp message, Free"; Page.MetaDescription = "Let your application send you WhatsApp messages. Sign up for free today."; NiceASP.KeywordLoader.Load(this, KeywordLoader.Which.Default); ExOut.InnerHtml = APIActualSending.fakeRequest("<Your unique X-APIId>", "<Mobile number>", "What a great day"); ExRes.InnerHtml = APIActualSending.fakeResponse("queued"); } } catch (DataUnavailableException) { DSSwitch.OnDataUnavailableException(this); } }
public Data_Net__02ScreenshotRequest ReadOne(NiceSystemInfo niceSystem, string fileName, IMyLog log) { try { WithAndWithoutUnderline ww = new WithAndWithoutUnderline( FolderNames.GetFolder(niceSystem, MyFolders.ASP_QueuedMessages_), fileName); Data_Net__02ScreenshotRequest o = null; Stream stream = OpenFile.ForRead(ww.Existing, false, false, log); if (stream == null) { return(null); } using (BinaryReader br = new BinaryReader(stream)) { ASPTrayBase ox = ASPTrayBase.ReadOne(br); if (ox.GetEnumType() == ASPTrayBase.eASPtrayType.ScreenShotRequest) { o = (Data_Net__02ScreenshotRequest)ox; } } return(o); } catch (SystemException se) { log.Error("*** SystemException ***"); log.Error(se.Message); } return(null); }
public static void Load() { try { List3Digit.Clear(); List2Digit.Clear(); XmlDocument xD = new XmlDocument(); xD.Load(FolderNames.GetFolder(NiceSystemInfo.DEFAULT, MyFolders.ASP_ServerStateFolder) + "\\CountryList.xml"); XmlNode listNode = xD["CountryList"]; foreach (XmlNode e1 in listNode) { if (e1.Name.StartsWith("CC")) { if (e1.Name.Length == 5) { // 3 digit code List3Digit.Add(Int32.Parse(e1.Name.Substring(2)), e1.InnerText); } if (e1.Name.Length == 4) { // 2 digit code List2Digit.Add(Int32.Parse(e1.Name.Substring(2)), e1.InnerText); } } } } catch { } }
public Data_Net__00NormalMessage ReadOne(NiceSystemInfo niceSystem, string fileName, Data_Net__00NormalMessage.eLocation location, IMyLog log) { try { WithAndWithoutUnderline ww = new WithAndWithoutUnderline( FolderNames.GetFolder(niceSystem, eLocationToMyFolder(location)), fileName); Data_Net__00NormalMessage o = null; Stream stream = OpenFile.ForRead(ww.Existing, false, false, log); if (stream == null) { return(null); } using (BinaryReader br = new BinaryReader(stream)) { ASPTrayBase ox = ASPTrayBase.ReadOne(br); if (ox.GetEnumType() == ASPTrayBase.eASPtrayType.NormalMessage) { o = (Data_Net__00NormalMessage)ox; } } return(o); } catch (SystemException se) { log.Error("*** SystemException ***"); log.Error(se.Message); } return(null); }
public static bool get_icon_parameters(Guid?applicationId, IconType iconType, ref FolderNames folder, ref FolderNames highQualityFolder, ref string defaultIconUrl) { int width = 0, height = 0, highQualityWidth = 0, highQualityHeight = 0; return(get_icon_parameters(applicationId, iconType, ref width, ref height, ref highQualityWidth, ref highQualityHeight, ref folder, ref highQualityFolder, ref defaultIconUrl)); }
private static string getWalletFullPath(string email) { string filePath = FolderNames.GetFolder(NiceSystemInfo.DEFAULT, MyFolders.ASP_UserWalletFolder_) + Path.DirectorySeparatorChar + "Wallet_" + Data_AppUserFile.EmailSaveChars(email) + ".txt"; return(filePath); }
private static bool has_sub_folder(FolderNames folderName) { return(!(new[] { FolderNames.EmailTemplates, FolderNames.Index, FolderNames.TemporaryFiles, FolderNames.Themes, FolderNames.EmailTemplates }).Any(f => folderName == f)); }
public bool HasAccount(string email, IMyLog log) { string folder = FolderNames.GetFolder(NiceSystemInfo.DEFAULT, MyFolders.ASP_UserAccountFolder_); string file = folder + Path.DirectorySeparatorChar + Data_AppUserFile.EmailSaveChars(email) + ".txt"; if (File.Exists(file)) { return(true); } return(false); }
public void ExchangeDataWithServer(I2_InfoDisplay d, I6_WhatsAppProcess p) { d.AddLine("exchangeDataWithASP"); d.FileLog_Debug("exchangeDataWithASP"); toASP.TrayType = ConfigurationManager.AppSettings["_3GetData.Server.TrayType"]; d.AddLine2(new DetailedData_TypeAndAndroidEP() { TrayType = toASP.TrayType }); d.AddLine2(new DetailedData_TypeAndAndroidEP() { LocalIPAddress = Extensions.GetLocalIPAddress() }); if (String.IsNullOrEmpty(toASP.TrayType)) { throw new ConfigurationException("_3GetData.Server.TrayType is missing!"); } ASPTray_ObjectList.Counters toASPCount = toASP.GetCounters(); if (toASPCount.Total_Results() > 0) { d.FileLog_Info(toASPCount.Total_ResultsString() + " up msg"); } d.AddLine2(toASPCount.AddLineIFace_Send()); string url = p.Debug_AmendUrl(FolderNames.GetUrl(this.urlToUse), toASP.GetCounters().Total_ResultsString()); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.ReadWriteTimeout = FolderNames.GetValue(MyValues.Tray_TcpTimeoutSec) * 1000; request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; Stream requestStream = request.GetRequestStream(); BinBase64StreamHelper.Tray2ASP_ToB64Stream(ref toASP, requestStream); requestStream.Close(); // GET RESPONSE **************************************************** HttpWebResponse response = (HttpWebResponse)request.GetResponse(); d.AddLine("GetResponse done"); toASP = new Data_Net_Tray2ASP(); fromASP = new Data_Net_ASP2Tray(); Stream stream = response.GetResponseStream(); BinBase64StreamHelper.ASP2Tray_FromB64Stream(ref fromASP, stream); response.Close(); ASPTray_ObjectList.Counters fromASPCount = fromASP.GetCounters(); if (fromASPCount.Total_Requests() > 0) { d.FileLog_Info(fromASPCount.Total_RequestsString() + " down msg"); } d.AddLine2(fromASPCount.AddLineIFace_Receive()); }
private void responseWriteHomeLink() { if (FolderNames.IsDevMachine()) { Response.Write("<a href=\"./\">Home</a><br />"); } else { Response.Write("<a href=\"/\">Home</a><br />"); } }
public void RetrieveAll(d1_Data_AppUserWallet d, IMyLog log) { foreach (string f1 in Directory.GetFiles(FolderNames.GetFolder(NiceSystemInfo.DEFAULT, MyFolders.ASP_UserWalletFolder_))) { string email = Data_AppUserWalletHandling_File.GetEmailFromFileName(Path.GetFileName(f1)); Data_AppUserWallet w1 = RetrieveOne(email, log); if (w1 != null) { d(w1); } } }
public void Build(string outputName) { RegenFolderRecords(); if (File.Exists(outputName)) { File.Delete(outputName); } using (var fs = File.OpenWrite(outputName)) using (var wtr = new BinaryWriter(fs)) { wtr.Write(_fileId); wtr.Write(_version); wtr.Write(_offset); wtr.Write(_archiveFlags); var folders = FolderNames.ToList(); wtr.Write((uint)folders.Count); wtr.Write((uint)_files.Count); wtr.Write((uint)_folders.Select(f => f._nameBytes.Count() - 1).Sum()); // totalFolderNameLength var s = _files.Select(f => f._pathBytes.Count()).Sum(); _totalFileNameLength = (uint)_files.Select(f => f._nameBytes.Count()).Sum(); wtr.Write(_totalFileNameLength); // totalFileNameLength wtr.Write(_fileFlags); foreach (var folder in _folders) { folder.WriteFolderRecord(wtr); } foreach (var folder in _folders) { if (HasFolderNames) { wtr.Write(folder._nameBytes); } foreach (var file in folder._files) { file.WriteFileRecord(wtr); } } foreach (var file in _files) { wtr.Write(file._nameBytes); } foreach (var file in _files) { file.WriteData(wtr); } } }
public void Delete(NiceSystemInfo niceSystem, string fileName, IMyLog log) { try { WithAndWithoutUnderline ww = new WithAndWithoutUnderline( FolderNames.GetFolder(niceSystem, MyFolders.ASP_QueuedMessages_), fileName); File.Delete(ww.Existing); } catch (SystemException se) { log.Error("*** SystemException ***"); log.Error(se.Message); } }
public void Delete(NiceSystemInfo niceSystem, string fileName, Data_Net__00NormalMessage.eLocation location, IMyLog log) { try { WithAndWithoutUnderline ww = new WithAndWithoutUnderline( FolderNames.GetFolder(niceSystem, eLocationToMyFolder(location)), fileName); File.Delete(ww.Existing); } catch (SystemException se) { log.Error("*** SystemException ***"); log.Error(se.Message); } }
/// <summary> /// Create new file under local folder /// </summary> /// <param name="fileName">File Name</param> /// <param name="folderName">Folder Name (where the file will be created)</param> /// <param name="collision">Creation Collision Option</param> /// <returns>StorageFile</returns> async static public Task <StorageFile> CreateFileAsync(string fileName, FolderNames folderName, CreationCollisionOption collision = CreationCollisionOption.GenerateUniqueName) { try { var storage = Windows.Storage.ApplicationData.Current.LocalFolder; var folder = await storage.CreateFolderAsync(folderName.ToString(), Windows.Storage.CreationCollisionOption.OpenIfExists); return(await folder.CreateFileAsync(fileName, collision)); } catch { Helpers.ShowErrorMessageAsync("Create File", "Can't create new file under the specific folder because the file is used by the application."); return(null); } }
public bool move(Guid?applicationId, FolderNames source, FolderNames destination, Guid?newGuidName = null) { try { if (!FileID.HasValue) { return(false); } FolderName = source; string sourceAddress = get_real_address(applicationId); if (newGuidName.HasValue && newGuidName.Value != Guid.Empty) { FileID = newGuidName; } FolderName = destination; if (string.IsNullOrEmpty(sourceAddress)) { return(!string.IsNullOrEmpty(get_real_address(applicationId))); } if (CephMode) { bool isPublic = false; string newAddress = get_address(applicationId, ref isPublic, encrypted: is_encrypted(applicationId)); return(CephStorage.rename_file(sourceAddress, newAddress, isPublic)); } else { string destFolder = get_folder_address(applicationId); string destinationAddress = get_address(applicationId, encrypted: is_encrypted(applicationId)); if (!Directory.Exists(destFolder)) { Directory.CreateDirectory(destFolder); } File.Move(sourceAddress, destinationAddress); return(true); } } catch { return(false); } }
private static bool get_icon_parameters(Guid?applicationId, IconType iconType, ref int width, ref int height, ref int highQualityWidth, ref int highQualityHeight, ref FolderNames folder, ref FolderNames highQualityFolder, ref string defaultIconUrl) { switch (iconType) { case IconType.ProfileImage: width = height = 100; highQualityWidth = highQualityHeight = 600; folder = FolderNames.ProfileImages; highQualityFolder = FolderNames.HighQualityProfileImage; defaultIconUrl = get_personal_image_address(applicationId, null); break; case IconType.CoverPhoto: width = 900; height = 220; highQualityWidth = 1800; highQualityHeight = 600; folder = FolderNames.CoverPhoto; highQualityFolder = FolderNames.HighQualityCoverPhoto; defaultIconUrl = get_cover_photo_url(applicationId, null); break; case IconType.Icon: width = height = 100; highQualityWidth = highQualityHeight = 600; folder = FolderNames.Icons; highQualityFolder = FolderNames.HighQualityIcon; defaultIconUrl = get_icon_url(applicationId, DefaultIconTypes.Node); break; case IconType.ApplicationIcon: width = height = 100; highQualityWidth = highQualityHeight = 600; folder = FolderNames.ApplicationIcons; highQualityFolder = FolderNames.HighQualityApplicationIcon; defaultIconUrl = get_application_icon_url(null); break; default: return(false); } return(true); }
protected void Page_Init(object sender, EventArgs e) { // check for https if (!FolderNames.IsDevMachine()) { if ((Request.ServerVariables["HTTPS"] == "off") && (Request.ServerVariables["SERVER_PORT"] == "80")) { Response.Redirect("https://" + Request.ServerVariables["HTTP_HOST"] + Request.ServerVariables["UNENCODED_URL"]); } if (Request.ServerVariables["HTTP_HOST"].ToUpper().StartsWith("WWW")) { Response.Redirect("https://niceapi.net" + Request.ServerVariables["URL"]); } } // The code below helps to protect against XSRF attacks var requestCookie = Request.Cookies[AntiXsrfTokenKey]; Guid requestCookieGuidValue; if (requestCookie != null && Guid.TryParse(requestCookie.Value, out requestCookieGuidValue)) { // Use the Anti-XSRF token from the cookie _antiXsrfTokenValue = requestCookie.Value; Page.ViewStateUserKey = _antiXsrfTokenValue; } else { // Generate a new Anti-XSRF token and save to the cookie _antiXsrfTokenValue = Guid.NewGuid().ToString("N"); Page.ViewStateUserKey = _antiXsrfTokenValue; var responseCookie = new HttpCookie(AntiXsrfTokenKey) { HttpOnly = true, Value = _antiXsrfTokenValue }; if (FormsAuthentication.RequireSSL && Request.IsSecureConnection) { responseCookie.Secure = true; } Response.Cookies.Set(responseCookie); } Page.PreLoad += master_Page_PreLoad; }
public Data_AppUserFile RetrieveOne(string email, IMyLog log) { string folder = FolderNames.GetFolder(NiceSystemInfo.DEFAULT, MyFolders.ASP_UserAccountFolder_); string filePath = folder + Path.DirectorySeparatorChar + Data_AppUserFile.EmailSaveChars(email) + ".txt"; Data_AppUserFile o = Data_AppUserFile.CreateBlank(); Stream stream = OpenFile.ForRead(filePath, false, false, log); if (stream == null) { return(null); } using (BinaryReader br = new BinaryReader(stream)) { o.ReadFromStream(br); } return(o); }
public void RetrieveAll(Data_AppUserFile.SortType sort, d1_Data_AppUserFile d, IMyLog log) { List <Data_AppUserFile> allUsers = new List <Data_AppUserFile>(); foreach (string s1 in Directory.GetFiles(FolderNames.GetFolder(NiceSystemInfo.DEFAULT, MyFolders.ASP_UserAccountFolder_))) { string file = Path.GetFileNameWithoutExtension(s1); Data_AppUserFile u1 = this.RetrieveOne(file, log); allUsers.Add(u1); } Sort(allUsers, sort); foreach (Data_AppUserFile u1 in allUsers) { if (d != null) { d(u1); } } }
internal bool CreateEventFolder(WatcherFolderOption watcherFolderOption, FolderNames folder) { string folderName = watcherFolderOption.TrashFolder + "\\" + folder.ToString(); if (!Directory.Exists(folderName)) { try { Directory.CreateDirectory(folderName); slLogger.WriteLogLine("Directory " + folderName + " created at " + DateTime.Today.ToShortDateString()); return(true); } catch (Exception ex) { slLogger.WriteLogLine(ex, "SetupTrashFolderError CreateEventFolderError"); return(false); } } return(false); }
/// <summary> /// Delete file from specific folder /// </summary> /// <param name="Filename">File name to delete</param> /// <param name="folderType">Folder name where the file is located</param> /// <returns></returns> public async static Task DeleteFileAsync(string Filename, FolderNames folderType) { try { var storage = Windows.Storage.ApplicationData.Current.LocalFolder; var folder = await storage.CreateFolderAsync(folderType.ToString(), Windows.Storage.CreationCollisionOption.OpenIfExists); var file = await folder.GetFileAsync(Filename); if (file == null) { return; } await file.DeleteAsync(); } catch { Helpers.ShowErrorMessageAsync("Delete File", "Can't delete file because the file is used by the application."); } }
private static void Append(string wholeLine) { string path = FolderNames.GetMachineRoot() + s_FileName /*"MyLog.txt"*/; System.Threading.Monitor.Enter(MyLock); try { using (StreamWriter sw = File.AppendText(path)) { sw.WriteLine(wholeLine); } } catch (Exception ex) { throw new Exception($"MyLogToMyFile.Append(wholeLine:'{wholeLine}', path:'{path}')", ex); } finally { System.Threading.Monitor.Exit(MyLock); } }
public void Update_General(string email, d_On_User_Action action, Object args, d_On_User_PostAction postAction, IMyLog log) { string filePath = FolderNames.GetFolder(NiceSystemInfo.DEFAULT, MyFolders.ASP_UserAccountFolder_) + Path.DirectorySeparatorChar + Data_AppUserFile.EmailSaveChars(email) + ".txt"; using (Stream stream = OpenFile.ForRead(filePath, true, true, log)) { Data_AppUserFile r = null; if (stream != null) { r = Data_AppUserFile.CreateBlank(); //1) read it in BinaryReader br = new BinaryReader(stream); r.ReadFromStream(br); } //2) update values if (action != null) { action(r, args); } //3) write it back if (r != null) { stream.Seek(0, SeekOrigin.Begin); BinaryWriter bw = new BinaryWriter(stream); r.WriteToStream(bw); stream.SetLength(stream.Position); stream.Close(); } } if (postAction != null) { postAction(args); } }
public URL(PageNames pageName, FolderNames folderName) : this(string.Format("/{0}/{1}", folderName, pageName)) { }