当前位置: 首页>>代码示例>>C#>>正文


C# Connector.Query_Execute_Parameters方法代码示例

本文整理汇总了C#中Connector.Query_Execute_Parameters方法的典型用法代码示例。如果您正苦于以下问题:C# Connector.Query_Execute_Parameters方法的具体用法?C# Connector.Query_Execute_Parameters怎么用?C# Connector.Query_Execute_Parameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Connector的用法示例。


在下文中一共展示了Connector.Query_Execute_Parameters方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: pageProfile_Upload

 public static void pageProfile_Upload(string pluginid, ref ResultRow profileData, Connector conn, ref Misc.PageElements pageElements, HttpRequest request, HttpResponse response)
 {
     string error = null;
     HttpPostedFile image = request.Files["profile_picture"];
     if(image != null)
     {
         int maxSize = Core.settings[SETTINGS_KEY].getInt(SETTINGS_KEY_PICTURE_MAX_SIZE);
         if (image.ContentLength > maxSize)
             error = "Picture cannot exceed " + maxSize + " bytes (" + Misc.Plugins.getBytesString(maxSize) + ") !";
         else if (image.ContentType != "image/gif" && image.ContentType != "image/jpeg" && image.ContentType != "image/png" && image.ContentType != "image/jpg")
             error = "Invalid file format!";
         else
         {
             // Compress the image
             double maxWidth = Core.settings[SETTINGS_KEY].getDouble(SETTINGS_KEY_PICTURE_MAX_WIDTH);
             double maxHeight = Core.settings[SETTINGS_KEY].getDouble(SETTINGS_KEY_PICTURE_MAX_HEIGHT);
             Stream bStream = image.InputStream;
             Image pp = Image.FromStream(bStream);
             // Work-out the size of the new image
             int width;
             int height;
             if (pp.Width > maxWidth)
             {
                 width = (int)maxWidth;
                 height = (int)((maxWidth / (double)pp.Width) * pp.Height);
             }
             else
             {
                 height = (int)maxHeight;
                 width = (int)((maxHeight / (double)pp.Height) * pp.Width);
             }
             Bitmap compressedImage = new Bitmap(width, height);
             // Draw the uploaded image
             Graphics g = Graphics.FromImage(compressedImage);
             g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
             g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
             g.DrawImage(pp, 0, 0, width, height);
             g.Dispose();
             // Save the image as a byte-array
             MemoryStream ms = new MemoryStream();
             compressedImage.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
             byte[] data = ms.ToArray();
             ms.Dispose();
             ms = null;
             // Dispose image
             compressedImage.Dispose();
             compressedImage = null;
             pp.Dispose();
             pp = null;
             bStream.Dispose();
             bStream = null;
             // Save the byte-array to the database
             Dictionary<string, object> queryParams = new Dictionary<string, object>();
             queryParams.Add("profile_picture", data);
             queryParams.Add("profileid", profileData["profileid"]);
             // Save the byte-array to the database
             conn.Query_Execute_Parameters("UPDATE bsa_profiles SET [email protected]_picture WHERE [email protected]", queryParams);
             // Redirect to profile
             conn.Disconnect();
             response.Redirect(pageElements["URL"] + "/profile?userid=" + profileData["userid"], true);
         }
     }
     pageElements["PROFILE_CONTENT"] = Core.templates["bsa_profiles"]["profile_upload"]
         .Replace("<USERID>", HttpUtility.HtmlEncode(profileData["userid"]))
         .Replace("<ERROR>", error != null ? Core.templates[pageElements["TEMPLATE"]]["error"].Replace("<ERROR>", HttpUtility.HtmlEncode(error)) : string.Empty);
     pageElements.setFlag("PROFILE_UPLOAD");
 }
开发者ID:kassemshehady,项目名称:Uber-CMS,代码行数:67,代码来源:Base.cs

示例2: cmsStart

 public static string cmsStart(string pluginid, Connector conn)
 {
     // The directory where all of our files will be stored
     downloadsPath = Core.basePath + "/_downloads";
     // Check the local directory exists for downloads
     if (!Directory.Exists(downloadsPath))
         Directory.CreateDirectory(downloadsPath);
     else
         // Begin indexing pre-existing files for changes
         indexMainFolder();
     // Initialize file-watcher
     watcherEnable();
     // Check all the icons in the cache exist physically - else delete the db version
     List<string> iconsFound = new List<string>();
     StringBuilder deleteBuffer = new StringBuilder("DELETE FROM downloads_ext_icons WHERE ");
     int dbLength = deleteBuffer.Length;
     foreach (ResultRow icon in conn.Query_Read("SELECT extension FROM downloads_ext_icons"))
     {
         if (!File.Exists(Core.basePath + "\\Content\\Images\\downloads\\icons"))
             deleteBuffer.Append("extension='" + Utils.Escape(icon["extension"]) + "' OR ");
         else
             iconsFound.Add(icon["extension"]);
     }
     if (deleteBuffer.Length != dbLength)
         conn.Query_Execute(deleteBuffer.Remove(deleteBuffer.Length - 4, 4).Append(";").ToString());
     // Add any new physical icons to the database
     string ext;
     Dictionary<string, object> attribs;
     foreach (string file in Directory.GetFiles(Core.basePath + "\\Content\\Images\\downloads\\icons", "*.png", SearchOption.AllDirectories))
         try
         {
             if (!iconsFound.Contains((ext = Path.GetFileNameWithoutExtension(file))))
             {
                 attribs = new Dictionary<string, object>();
                 attribs.Add("extension", ext);
                 attribs.Add("icon", File.ReadAllBytes(file));
                 conn.Query_Execute_Parameters("INSERT INTO downloads_ext_icons (extension, icon) VALUES(@extension, @icon)", attribs);
             }
         }
         catch { }
     return null;
 }
开发者ID:kassemshehady,项目名称:Uber-CMS,代码行数:42,代码来源:Downloads.cs


注:本文中的Connector.Query_Execute_Parameters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。