コード例 #1
0
 /// <summary>
 /// 将DataSet导出为excel,一个Table对应一个sheet
 /// </summary>
 /// <param name="ds"></param>
 public static void DataSetToExcel(System.Data.DataSet ds, string fileName)
 {
     ExcelHandler eh = new ExcelHandler();
     SheetExcelForm frm = new SheetExcelForm();
     eh.ProcessHandler = frm.AddProcess;
     eh.ProcessErrorHandler = new Action<string>((msg) =>
     {
         MessageBox.Show(msg);
     });
     try
     {
         frm.Show();
         Delay(20);
         eh.DataSet2Excel(ds, null, fileName);
         ds.Dispose();
     }
     catch (Exception ex)
     {
         MessageBox.Show("导出Excel错误:" + ex.Message);
     }
     finally
     {
         Delay(20);
         frm.Close();
     }
 }
コード例 #2
0
ファイル: Timer.cs プロジェクト: garymatthias/bentbot
 private void RemoveAndDisposeTimer(System.Timers.Timer t)
 {
     bool value;
     activeTimers.TryRemove(t, out value);
     t.Enabled = false;
     t.Dispose();
 }
コード例 #3
0
 /// <summary>
 /// this function modifies a window shape
 /// </summary>
 /// <param name="bmp">
 /// the bitmap that has the shape of the window. <see cref="System.Drawing.Bitmap"/>
 /// </param>
 /// <param name="window">
 /// the window to apply the shape change <see cref="Gtk.Window"/>
 /// </param>
 /// <returns>
 /// true if it succeded, either return false <see cref="System.Boolean"/>
 /// </returns>
 public static bool ModifyWindowShape( System.Drawing.Bitmap bmp, Gtk.Window window )
 {
     bool ret = false;
     try
     {
         //save bitmap to stream
         System.IO.MemoryStream stream = new System.IO.MemoryStream();
         bmp.Save( stream, System.Drawing.Imaging.ImageFormat.Png );
         //verry important: put stream on position 0
         stream.Position     = 0;
         //get the pixmap mask
         Gdk.Pixbuf buf      = new Gdk.Pixbuf( stream, bmp.Width, bmp.Height );
         Gdk.Pixmap map1, map2;
         buf.RenderPixmapAndMask( out map1, out map2, 255 );
         //shape combine window
         window.ShapeCombineMask( map2, 0, 0 );
         //dispose
         buf.Dispose();
         map1.Dispose();
         map2.Dispose();
         bmp.Dispose();
         //if evrything is ok return true;
         ret = true;
     }
     catch(Exception ex)
     {
         Console.WriteLine( ex.Message + "\r\n" + ex.StackTrace );
     }
     return ret;
 }
コード例 #4
0
ファイル: GridDomainNode.cs プロジェクト: csuffyy/GridDomain
        public async Task Stop()
        {
            if (_stopping)
            {
                return;
            }

            _log.Debug("GridDomain node {Id} is stopping", Id);
            _stopping = true;
            Container?.Dispose();

            try
            {
                _quartzScheduler?.Shutdown(false);
            }
            catch (Exception ex)
            {
                _log.Warn($"Got error on quartz scheduler shutdown: {ex}");
            }

            if (System != null)
            {
                await System.Terminate();

                System.Dispose();
            }

            _log.Debug("GridDomain node {Id} stopped", Id);
        }
コード例 #5
0
		protected override Task CloseStreamAsync(System.IO.Stream stream)
		{
			stream.Dispose();
			m_socket.Dispose();
			m_socket = null;
			return Task.FromResult(true);
		}
コード例 #6
0
        public void TestFixtureTearDown()
        {
            OnFixtureTearDown();

            if (Database != null)
            {
                Database.Close();
                Database.Dispose();
            }

            if (System != null)
            {
                System.Dispose();
            }

            DeleteFiles();

            GC.Collect(0, GCCollectionMode.Optimized);
            GC.Collect(1, GCCollectionMode.Forced);
            GC.Collect(2, GCCollectionMode.Forced);
            GC.Collect();
            GC.WaitForPendingFinalizers();
            var status = GC.WaitForFullGCComplete(-1);

            if (status == GCNotificationStatus.Timeout)
            {
                Console.Error.WriteLine("GC timed-out");
            }
        }
コード例 #7
0
ファイル: MapStorage.cs プロジェクト: SNSB/DiversityMobile
        public IObservable<Unit> addMap(Map map, System.IO.Stream mapContent)
        {
            Func<Task> impl = async () =>
            {
                try
                {
                    using (var iso = IsolatedStorageFile.GetUserStoreForApplication())
                    {
                        var filename = fileNameForMap(map);
                        if (iso.FileExists(filename))
                            iso.DeleteFile(filename);

                        using (var file = iso.CreateFile(filename))
                        {
                            await mapContent.CopyToAsync(file, 4 * 1024 * 1024);
                        }
                    }
                }
                catch (IsolatedStorageException)
                {
                    mapContent.Dispose();
                }

                using (var ctx = getContext())
                {
                    ctx.Maps.InsertOnSubmit(map);
                    ctx.SubmitChanges();
                }
            };

            return impl().ToObservable();
        }
コード例 #8
0
ファイル: Expander.cs プロジェクト: Algorithmix/Papyrus
        /// <summary>
        /// Expands the given image to with a transparent boarder of size determined in this class
        /// </summary>
        /// <param name="shred">the image to expand</param>
        /// <returns>an expanded image</returns>
        public static System.Drawing.Bitmap Expand(System.Drawing.Bitmap shred)
        {
            //read all images into memory
            System.Drawing.Bitmap finalImage = null;

            try
            {

                //create a bitmap to hold the stretched image (20px on each border
                finalImage = new System.Drawing.Bitmap(shred.Width + 2 * border, shred.Height + 2 * border);

                //get a graphics object from the image so we can draw on it
                using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(finalImage))
                {
                    //set background color, make it clear
                    g.Clear(System.Drawing.Color.Transparent);

                    g.DrawImage(shred, new System.Drawing.Rectangle(border, border, shred.Width, shred.Height));
                }

                return finalImage;
            }
            catch (Exception ex)
            {
                if (finalImage != null)
                    finalImage.Dispose();

                throw ex;
            }
            finally
            {
                //clean up memory
                shred.Dispose();
            }
        }
コード例 #9
0
ファイル: Switch.cs プロジェクト: pinguicodes/Ryujinx
 protected virtual void Dispose(bool Disposing)
 {
     if (Disposing)
     {
         System.Dispose();
     }
 }
コード例 #10
0
        internal void ActivateSalesView(ITable table)
        {
            var currentSaleId = table.CurrentSaleOnTable.Id;

            System.Dispose();
            this.TasksManager.StartTask(typeof(ProcessSaleTask), new object[] { CurrentEmployee.Id, table.Id, table.Area.Id, currentSaleId });
        }
コード例 #11
0
ファイル: ChatCommands.cs プロジェクト: DaimOwns/ProRP
 public static bool FinishSendHome(Session Session, System.Timers.Timer Timer)
 {
     Timer.Dispose();
             Timer.Stop();
             Session.CharacterInfo.UpdateSentHome(0);
             return true;
 }
コード例 #12
0
ファイル: Utilities.cs プロジェクト: chaitu005/NSDL
        public byte[] BmpToBytes(System.Drawing.Image bmp)
        {
            MemoryStream ms = null;
            byte[] bmpBytes = null;
            try
            {
                ms = new MemoryStream();
                // Save to memory using the Jpeg format
                bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

                // read to end
                bmpBytes = ms.GetBuffer();
            }
            catch
            {
                return null;
            }
            finally
            {
                bmp.Dispose();
                if (ms != null)
                {
                    ms.Close();
                }
            }
            return bmpBytes;
        }
コード例 #13
0
ファイル: Switch.cs プロジェクト: zpoo32/Ryujinx
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         System.Dispose();
         VsyncEvent.Dispose();
     }
 }
コード例 #14
0
 public void closeService(System.Data.SqlClient.SqlConnection _conn)
 {
     if (_conn != null && _conn.State != System.Data.ConnectionState.Closed)
     {
         _conn.Dispose();
         _conn.Close();
     }
 }
コード例 #15
0
ファイル: Switch.cs プロジェクト: adrianjosh/Ryujinx
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         System.Dispose();
         AudioOut.Dispose();
     }
 }
コード例 #16
0
ファイル: SupportClass.cs プロジェクト: eric-seekas/QR.NET
	/// <summary>
	/// Recieves a form and an integer value representing the operation to perform when the closing 
	/// event is fired.
	/// </summary>
	/// <param name="form">The form that fire the event.</param>
	/// <param name="operation">The operation to do while the form is closing.</param>
	public static void CloseOperation(System.Windows.Forms.Form form, int operation)
	{
		switch (operation)
		{
			case 0:
				break;
			case 1:
				form.Hide();
				break;
			case 2:
				form.Dispose();
				break;
			case 3:
				form.Dispose();
				System.Windows.Forms.Application.Exit();
				break;
		}
	}
コード例 #17
0
ファイル: Switch.cs プロジェクト: WilliamWsyHK/Ryujinx
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         System.Dispose();
         AudioDeviceDriver.Dispose();
         FileSystem.Dispose();
         Memory.Dispose();
     }
 }
コード例 #18
0
        public System.IO.Stream Process(string virtualPath, string rootPath, System.IO.Stream source, Dictionary<string, string> settings)
        {
            var min = new JSMin.JavaScriptMinifier();
            var src = new StreamReader(source).ReadToEnd();
            source.Dispose();

            var output = min.Minify(src);

            return new MemoryStream(Encoding.UTF8.GetBytes(output));
        }
コード例 #19
0
ファイル: Cache.cs プロジェクト: stophun/fdotoolbox
 /// <summary>
 /// Inserts an image into the HttpCache and returns the cache identifier.
 /// </summary>
 /// <remarks>
 /// Image can after insertion into the cache be requested by calling getmap.aspx?ID=[identifier]<br/>
 /// This requires you to add the following to web.config:
 /// <code escaped="true">
 /// <httpHandlers>
 ///	   <add verb="*" path="GetMap.aspx" type="SharpMap.Web.HttpHandler,SharpMap"/>
 /// </httpHandlers>
 /// </code>
 /// <example>
 /// Inserting the map into the cache and setting the ImageUrl:
 /// <code>
 /// string imgID = SharpMap.Web.Caching.CacheMap(5, myMap.GetMap(), Session.SessionID, Context);
 /// imgMap.ImageUrl = "getmap.aspx?ID=" + HttpUtility.UrlEncode(imgID);
 /// </code>
 /// </example>
 /// </remarks>
 /// <param name="minutes">Number of minutes to cache the map</param>
 /// <param name="map">Map reference</param>
 /// <returns>Image identifier</returns>
 public static string InsertIntoCache(int minutes, System.Drawing.Image map)
 {
     string guid = System.Guid.NewGuid().ToString().Replace("-","");
     System.IO.MemoryStream MS = new System.IO.MemoryStream();
     map.Save(MS, System.Drawing.Imaging.ImageFormat.Png);
     byte[] buffer = MS.ToArray();
     System.Web.HttpContext.Current.Cache.Insert(guid, buffer, null, System.Web.Caching.Cache.NoAbsoluteExpiration, TimeSpan.FromMinutes(minutes));
     map.Dispose();
     return guid;
 }
コード例 #20
0
        public DataRow retornaFila()
        {
            Formas.fCatalogo f = new SOPORTEC.Formas.fCatalogo(dt,"Nombre del Catalogo",2, );
                f.ShowDialog();
                rw = f.fila;
                f.Close();
                f.Dispose();

            return rw;
        }
コード例 #21
0
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         System.Dispose();
         Host1x.Dispose();
         AudioOut.Dispose();
         FileSystem.Unload();
         Memory.Dispose();
     }
 }
コード例 #22
0
        //TODO: kamrul have to fix this on the next version ie24
        public bool FinaliseSale(decimal change)
        {
            var canFinalise = CurrentSale.CanFinalisePayment();

            if (canFinalise)
            {
                System.SaveChanges();
                System.Dispose();
                TasksManager.StartTask(typeof(TableViewTask), new object[] { CurrentEmployee.Id });
            }
            return(canFinalise);
        }
コード例 #23
0
 public void CancelCovers()
 {
     if (CurrentSale != null)
     {
         System.Dispose();
         this.TasksManager.StartTask(typeof(ProcessSaleTask), new object[] { CurrentEmployee.Id, CurrentTable.Id, currentTableAreaId, CurrentSale.Id });
     }
     else if (CurrentSale == null)
     {
         System.Dispose();
         this.TasksManager.StartTask(typeof(TableViewTask), new object[] { CurrentEmployee.Id, CurrentTable.Id, currentTableAreaId });
     }
 }
コード例 #24
0
ファイル: Switch.cs プロジェクト: zyh1234/Ryujinx
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                ConfigurationState.Instance.Hid.InputConfig.Event -= Hid.RefreshInputConfigEvent;

                System.Dispose();
                Host1x.Dispose();
                AudioDeviceDriver.Dispose();
                FileSystem.Unload();
                Memory.Dispose();
            }
        }
コード例 #25
0
ファイル: ChatCommands.cs プロジェクト: DaimOwns/ProRP
 public static bool ExecuteTaxi(Session Session, RoomActor Actor, uint RoomID, System.Timers.Timer Timer)
 {
     Timer.Dispose();
             Timer.Stop();
             if (Session.CharacterInfo.Dead != 1 && Session.CharacterInfo.Jailed != 1)
             {
                 using (SqlDatabaseClient MySqlClient = SqlDatabaseManager.GetClient())
                 {
                     Session.CharacterInfo.SetHomeRoom(MySqlClient, RoomID);
                     RoomHandler.PrepareRoom(Session, RoomID, null, true);
                 }
             }
             return true;
 }
コード例 #26
0
 public string UploadFile(string filePath, int maxSize, string[] fileType, System.Web.UI.HtmlControls.HtmlInputFile TargetFile)
 {
     string Result = "UnDefine";
     bool typeFlag = false;
     string FilePath = filePath;
     int MaxSize = maxSize;
     string strFileName, strNewName, strFilePath;
     if (TargetFile.PostedFile.FileName == "")
     {
         return "FILE_ERR";
     }
     strFileName = TargetFile.PostedFile.FileName;
     TargetFile.Accept = "*/*";
     strFilePath = FilePath;
     if (Directory.Exists(strFilePath) == false)
     {
         Directory.CreateDirectory(strFilePath);
     }
     FileInfo myInfo = new FileInfo(strFileName);
     string strOldName = myInfo.Name;
     strNewName = strOldName.Substring(strOldName.LastIndexOf("."));
     strNewName = strNewName.ToLower();
     if (TargetFile.PostedFile.ContentLength <= MaxSize)
     {
         for (int i = 0; i <= fileType.GetUpperBound(0); i++)
         {
             if (strNewName.ToLower() == fileType[i].ToString()) { typeFlag = true; break; }
         }
         if (typeFlag)
         {
             string strFileNameTemp = GetUploadFileName();
             string strFilePathTemp = strFilePath;
             float strFileSize = TargetFile.PostedFile.ContentLength;
             strOldName = strFileNameTemp + strNewName;
             strFilePath = strFilePath + "\\" + strOldName;
             TargetFile.PostedFile.SaveAs(strFilePath);
             Result = strOldName + "|" + strFileSize;
             TargetFile.Dispose();
         }
         else
         {
             return "TYPE_ERR";
         }
     }
     else
     {
         return "SIZE_ERR";
     }
     return (Result);
 }
コード例 #27
0
        public void TestFixtureTearDown()
        {
            OnFixtureTearDown();

            if (Database != null)
            {
                Database.Dispose();
            }

            if (System != null)
            {
                System.Dispose();
            }
        }
コード例 #28
0
 /// <summary>
 /// ����һ���µ�Connection����,��������
 /// </summary>
 /// <returns>System.Data.SqlClient.SqlConnection</returns>
 public void connDispose(System.Data.SqlClient.SqlConnection sqlConn)
 {
     try
     {
         if(sqlConn.State == System.Data.ConnectionState.Open)
         {
             sqlConn.Close();
         }
         sqlConn.Dispose();
     }
     catch //(Exception exp)
     {
         //System.Windows.Forms.MessageBox.Show(exp.Message);
     }
 }
コード例 #29
0
        public void DefineCovers(int numberOfCovers)
        {
            if (CurrentSale == null)
            {
                CurrentSale = System.CreateNewSale(Company.Id, CurrentEmployee.Id, Store.Id,
                                                   CurrentTable.Area.Id, CurrentTable.Id, Terminal.Id, TerminalArea.Id, numberOfCovers);
            }
            else
            {
                System.ChangeCovers(Company.Id, Store.Id, TerminalArea.Id, Terminal.Id,
                                    CurrentTable.CurrentSaleOnTable.Id, numberOfCovers, CurrentEmployee.Id);
            }

            System.Dispose();
            this.TasksManager.StartTask(typeof(ProcessSaleTask), new object[] { CurrentEmployee.Id, CurrentTable.Id, currentTableAreaId, CurrentSale.Id });
        }
コード例 #30
0
        public System.IO.Stream Process(string virtualPath, string rootPath, System.IO.Stream source, Dictionary<string, string> settings)
        {
            var engine = new dotless.Core.LessEngine();
            if (settings != null)
            {
                bool compress = false;
                if (bool.TryParse(settings["compress"], out compress))
                    engine.Compress = compress;
            }

            var src = new StreamReader(source).ReadToEnd();
            source.Dispose();
            string output = engine.TransformToCss(src, Path.Combine(rootPath, virtualPath.TrimStart('\\')));

            MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(output));
            return ms;
        }
コード例 #31
0
 private void SendMailInSeperateThread(System.Net.Mail.MailMessage mailMessage)
 {
     
     try
     {
         using (SmtpClient mailClient = new SmtpClient())
         {
             mailClient.Send(mailMessage);
             mailMessage.Dispose();
             mailClient.Dispose();
         }
     }
     catch (Exception e)
     {
         // This is very necessary to catch errors since we are in
         // a different context & thread
         Elmah.ErrorLog.GetDefault(null).Log(new Error(e));
     }
 }
コード例 #32
0
ファイル: ODataRawInputContext.cs プロジェクト: nickchal/pash
 private ODataRawInputContext(ODataFormat format, System.IO.Stream messageStream, Encoding encoding, ODataMessageReaderSettings messageReaderSettings, ODataVersion version, bool readingResponse, bool synchronous, IEdmModel model, IODataUrlResolver urlResolver, ODataPayloadKind readerPayloadKind) : base(format, messageReaderSettings, version, readingResponse, synchronous, model, urlResolver)
 {
     ExceptionUtils.CheckArgumentNotNull<ODataFormat>(format, "format");
     ExceptionUtils.CheckArgumentNotNull<ODataMessageReaderSettings>(messageReaderSettings, "messageReaderSettings");
     try
     {
         this.stream = messageStream;
         this.encoding = encoding;
         this.readerPayloadKind = readerPayloadKind;
     }
     catch (Exception exception)
     {
         if (ExceptionUtils.IsCatchableExceptionType(exception) && (messageStream != null))
         {
             messageStream.Dispose();
         }
         throw;
     }
 }
コード例 #33
0
        public async Task Stop()
        {
            if (_stopping)
            {
                return;
            }

            Log.Information("GridDomain node {Id} is stopping", Id);
            _stopping = true;

            if (System != null)
            {
                await System.Terminate();

                System.Dispose();
            }
            System = null;
            Container?.Dispose();
            Log.Information("GridDomain node {Id} stopped", Id);
        }
コード例 #34
0
        public void ResizeXLargeDoImage(System.Drawing.Image image)
        {
            double rat = (370.0 / Convert.ToDouble(image.Width)) * image.Height;
            int newHeight = Convert.ToInt32(370.0 / Convert.ToDouble(image.Width));
            var newWidth = 370;

            var thumbnailBitmap = new Bitmap(newWidth, newHeight);

            var thumbnailGraph = Graphics.FromImage(thumbnailBitmap);
            thumbnailGraph.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
            thumbnailGraph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            thumbnailGraph.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

            var imageRectangle = new Rectangle(0, 0, newWidth, newHeight);

            thumbnailGraph.DrawImage(image, imageRectangle);

            thumbnailBitmap.Save(fle_id_do.Value.Replace(".jpg", "_tmp.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);

            File.Copy(fle_id_do.Value.Replace(".jpg", "_tmp.jpg"), fle_id_do.Value, true);
            File.Delete(fle_id_do.Value.Replace(".jpg", "_tmp.jpg"));

            thumbnailGraph.Dispose();
            thumbnailBitmap.Dispose();
            image.Dispose();

            /*System.Drawing.Bitmap bmpImage = new System.Drawing.Bitmap(new_img);
            double rat = (370.0 / Convert.ToDouble(new_img.Width)) * new_img.Height;
            int new_height = Convert.ToInt32(370.0 / Convert.ToDouble(new_img.Width));

            System.Drawing.Image thumbnailImage = new_img.GetThumbnailImage(370, new_height, new System.Drawing.Image.GetThumbnailImageAbort(ThumbNailCallBack), IntPtr.Zero);

            System.Drawing.Bitmap bm = new System.Drawing.Bitmap(thumbnailImage);
            bm.Save(fle_id_do.Value.Replace(".jpg", "_tmp.jpg"), System.Drawing.Imaging.ImageFormat.Jpeg);

            new_img.Dispose();
            File.Copy(fle_id_do.Value.Replace(".jpg", "_tmp.jpg"), fle_id_do.Value, true);
            File.Delete(fle_id_do.Value.Replace(".jpg", "_tmp.jpg"));*/
        }
コード例 #35
0
        private void DisposeContext()
        {
            if (Query != null)
            {
                Query.Dispose();
            }

            if (Database != null)
            {
                Database.Dispose();
            }

            if (System != null)
            {
                System.Dispose();
            }

            Query    = null;
            Database = null;
            Database = null;
            System   = null;
        }
コード例 #36
0
        public static void WriteStreamToFile(System.IO.Stream stream, String filename)
        {
            Microsoft.Xna.Framework.Media.MediaLibrary library = new Microsoft.Xna.Framework.Media.MediaLibrary();

            // write to "Saved Pictures"
            if (SaveToAlbum)
            {
                stream.Position = 0;
                library.SavePicture(filename, stream);
                Console.WriteLine("Saved Image: " + filename + " to 'Saved Pictures' album");
            }

            // write to "Camera Roll"
            if (SaveToCameraRoll)
            {
                stream.Position = 0;
                library.SavePictureToCameraRoll(filename, stream);
                Console.WriteLine("Saved Image: " + filename + " to Camera Roll");
            }

            stream.Dispose();
        }
コード例 #37
0
        public static void TryWaitOnHandleAndDispose(ref System.Threading.WaitHandle handle)
        {
            if (handle == null) return;

            try
            {
                handle.WaitOne();
            }
            catch (System.ObjectDisposedException)
            {
                return;
            }
            catch (System.Exception ex)
            {
                Media.Common.Extensions.Exception.ExceptionExtensions.TryRaiseTaggedException(handle, "An exception occured while waiting.", ex);
            }
            finally
            {
                if (handle != null) handle.Dispose();
            }

            handle = null;
        }
コード例 #38
0
ファイル: Program.cs プロジェクト: alekseysukharev/proxy
        static void Main(string[] args)
        {
            // read ip-address
            IPAddress address;
            int port = 0;
            bool parseResult = true;
            do
            {
                System.Console.Write("Proxy IP address: ");
                string ipAddressString = System.Console.ReadLine();
                parseResult = IPAddress.TryParse(ipAddressString, out address);
                if (!parseResult)
                {
                    System.Console.WriteLine("Incorrect IP!");
                }
            } while (!parseResult);

           
            do
            {
                System.Console.Write("Port: ");
                string portString = System.Console.ReadLine();
                parseResult = int.TryParse(portString, out port);
                if (!parseResult)
                {
                    System.Console.WriteLine("Incorrect IP!");
                }
            } while (!parseResult);

            var proxy = new HttpProxyHandler(address, port, HttpParser.Instance,
                new HttpRequestSender(HttpWebRequestFactory.Instance), new SHA1HashProvider(), new CacheSlot<string, byte[]>(new MemoryCache<string, byte[]>(), new IsolatedStorageCache<string, byte[]>(s => s, b => b, b => b)), new RequestLogger);
            proxy.Start();
            System.Console.WriteLine("Press any key to exit...");
            System.Console.ReadKey(true);
            proxy.Dispose();
        }
コード例 #39
0
ファイル: ExcelHelper.cs プロジェクト: aliarascc/HeatProjects
        public void ExportDataTable2TemplateSheetExpress(System.Data.DataTable dt, string SheetName, int StartingRowCount, bool column)
        {
            System.Globalization.CultureInfo oldCI = System.Threading.Thread.CurrentThread.CurrentCulture;
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");

            Worksheet targetSheet = GetSheet(SheetName);



            object[,] rawData = new object[dt.Rows.Count + 1, dt.Columns.Count];
            object[,] newData = new object[1, dt.Columns.Count];

            if (column)
            {
                for (int col = 0; col < dt.Columns.Count; col++)
                {
                    rawData[0, col] = dt.Columns[col].ColumnName;
                }
            }

            for (int col = 0; col < dt.Columns.Count; col++)
            {
                for (int row = 0; row < dt.Rows.Count; row++)
                {
                    rawData[row + 1, col] = dt.Rows[row].ItemArray[col];
                }
            }

            string finalColLetter = string.Empty;
            string colCharset = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
            int colCharsetLen = colCharset.Length;

            if (dt.Columns.Count > colCharsetLen)
            {
                finalColLetter = colCharset.Substring(
                    (dt.Columns.Count - 1) / colCharsetLen - 1, 1);
            }

            finalColLetter += colCharset.Substring(
                    (dt.Columns.Count - 1) % colCharsetLen, 1);


            ((Range)targetSheet.Rows[1, Type.Missing]).Font.Bold = true;

            string excelRange;
            int i;

            for (i = 0; i < dt.Rows.Count / EXCELSHEET_MAX_RANGE_LENGTH; i++)
            {
                newData = new object[EXCELSHEET_MAX_RANGE_LENGTH + 1, dt.Columns.Count];

                Int64 sourceIndex = i * EXCELSHEET_MAX_RANGE_LENGTH;
                Array.Copy(rawData, sourceIndex * dt.Columns.Count, newData, 0, EXCELSHEET_MAX_RANGE_LENGTH * dt.Columns.Count);

                excelRange = string.Format(
                    "A" + ((i * EXCELSHEET_MAX_RANGE_LENGTH) + StartingRowCount).ToString() + ":{0}{1}"
                    , finalColLetter
                    , (EXCELSHEET_MAX_RANGE_LENGTH * (i + 1)));

                targetSheet.get_Range(excelRange, Type.Missing).set_Value(Microsoft.Office.Interop.Excel.XlRangeValueDataType.xlRangeValueDefault
                                    , newData);

                Array.Clear(newData, 0, EXCELSHEET_MAX_RANGE_LENGTH * dt.Columns.Count);
            }

            if (dt.Rows.Count > i * EXCELSHEET_MAX_RANGE_LENGTH)
            {
                newData = new object[dt.Rows.Count - (i * EXCELSHEET_MAX_RANGE_LENGTH) + 1, dt.Columns.Count];

                Int64 sourceIndex = i * EXCELSHEET_MAX_RANGE_LENGTH;
                Array.Copy(rawData, sourceIndex * dt.Columns.Count, newData, 0, ((dt.Rows.Count - (i * EXCELSHEET_MAX_RANGE_LENGTH)) + 1) * dt.Columns.Count);

                excelRange = string.Format(
                    "A" + ((i * EXCELSHEET_MAX_RANGE_LENGTH) + StartingRowCount).ToString() + ":{0}{1}"
                    , finalColLetter
                    , (i * EXCELSHEET_MAX_RANGE_LENGTH) + (dt.Rows.Count - (i * EXCELSHEET_MAX_RANGE_LENGTH)) + StartingRowCount);

                targetSheet.get_Range(
                    excelRange
                    , Type.Missing).set_Value(
                                    Microsoft.Office.Interop.Excel.XlRangeValueDataType.xlRangeValueDefault
                                    , newData);

                Array.Clear(newData, 0, (dt.Rows.Count - (i * EXCELSHEET_MAX_RANGE_LENGTH) + 1) * dt.Columns.Count);
            }

            dt.Dispose();
            rawData = null;
        }
コード例 #40
0
 private void killTimer(System.Timers.Timer time)
 {
     time.Stop();
     time.Dispose();
 }
コード例 #41
0
 public void BackToCoversView()
 {
     System.Dispose();
     this.TasksManager.StartTask(typeof(DefineCoversTask), new object[] { CurrentEmployee.Id, CurrentTable.Id, currentTableAreaId, CurrentSale.Id });
 }
コード例 #42
0
 public void ActivatePaymentView()
 {
     System.Dispose();
     this.TasksManager.StartTask(typeof(PaymentTask), new object[] { CurrentEmployee.Id, CurrentTable.Id, currentTableAreaId, CurrentSale.Id });
 }
コード例 #43
0
ファイル: Text.cs プロジェクト: ChrisMoreton/Test3
			/// <summary>
			/// Disposes the specified brush.
			/// </summary>
			public void DisposeBrush(System.Drawing.Brush brush)
			{
				if ((_format & Styles.Color) == 0)
					return;

				brush.Dispose();
			}
コード例 #44
0
        public System.Drawing.Image ResizeImage(System.Drawing.Image imageToResize, Size size)
        {
            int sourceWidth = imageToResize.Width;
            int sourceHeight = imageToResize.Height;

            float percent = 0;
            float percentW = 0;
            float percentH = 0;

            percentW = (float)size.Width / (float)sourceWidth;
            percentH = (float)size.Height / (float)sourceHeight;

            if(percentH < percentW)
            {
                percent = percentW;
            }
            else
            {
                percent = percentH;
            }

            int destWidth = (int)(sourceWidth * percent);
            int destHeight = (int)(sourceHeight * percent);

            System.Drawing.Image image = new Bitmap(size.Width, size.Height);
            RectangleF destinationRect;

            if(imageToResize.Width > imageToResize.Height)
            {
                destinationRect = new RectangleF(-destWidth / 4, 0, destWidth, destHeight);
            }
            else
            {
                destinationRect = new RectangleF(0, 0, destWidth, destHeight);
            }

            Graphics graphics = Graphics.FromImage(image);
            // graphics.DrawImage(image, 0, 0);

            graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;

            graphics.DrawImage(imageToResize, destinationRect);
            // graphics.DrawImage(imageToResize, 0, 0, destWidth, destHeight);
            imageToResize.Dispose();
            graphics.Dispose();

            return image;
        }
コード例 #45
0
 public void ActivateLoginView()
 {
     System.Dispose();
     TasksManager.StartTask(typeof(LoginTask));
 }
コード例 #46
0
ファイル: AppFixture.cs プロジェクト: jmaragon/JasperSamples
 public void Dispose()
 {
     System?.Dispose();
 }
コード例 #47
0
 public void BackToTableView(bool moveTable)
 {
     System.Dispose();
     this.TasksManager.StartTask(typeof(TableViewTask), new object[] { CurrentEmployee.Id, CurrentTable.Id, currentTableAreaId, CurrentSale.Id, moveTable });
 }
コード例 #48
0
        /// <summary>
        /// 上传文件
        /// </summary>
        /// <param name="filePath">保存文件地址</param>
        /// <param name="maxSize">文件最大大小</param>
        /// <param name="fileType">文件后缀类型</param>
        /// <param name="TargetFile">控件名</param>
        /// <param name="saveFileName">保存后的文件名和地址</param>
        /// <param name="fileSize">文件大小</param>
        /// <returns></returns>
        public string UploadFile(string filePath, int maxSize, string[] fileType, System.Web.UI.HtmlControls.HtmlInputFile TargetFile, out string saveFileName, out int fileSize)
        {
            saveFileName = "";
            fileSize = 0;

            string Result = "";
            bool typeFlag = false;
            string FilePath = filePath;
            int MaxSize = maxSize;
            string strFileName, strNewName, strFilePath;
            if (TargetFile.PostedFile.FileName == "")
            {
                return "请选择上传的文件";
            }
            strFileName = TargetFile.PostedFile.FileName;
            TargetFile.Accept = "*/*";
            strFilePath = FilePath;
            if (Directory.Exists(strFilePath) == false)
            {
                Directory.CreateDirectory(strFilePath);
            }
            FileInfo myInfo = new FileInfo(strFileName);
            string strOldName = myInfo.Name;
            strNewName = strOldName.Substring(strOldName.LastIndexOf("."));
            strNewName = strNewName.ToLower();
            if (TargetFile.PostedFile.ContentLength <= MaxSize)
            {
                string strFileNameTemp = GetUploadFileName();
                string strFilePathTemp = strFilePath;
                strOldName = strFileNameTemp + strNewName;
                strFilePath = strFilePath + "\\" + strOldName;

                fileSize = TargetFile.PostedFile.ContentLength / 1024;
                saveFileName = strFilePath.Substring(strFilePath.IndexOf("FileUpload\\"));
                TargetFile.PostedFile.SaveAs(strFilePath);
                TargetFile.Dispose();
            }
            else
            {
                return "上传文件超出指定的大小";
            }
            return (Result);
        }
コード例 #49
0
 public void BackToLoginView()
 {
     System.Dispose();
     this.TasksManager.StartTask(typeof(LoginTask));
 }
コード例 #50
0
 internal void ActivateLoginView()
 {
     System.Dispose();
     this.TasksManager.StartTask(typeof(LoginTask));
 }
コード例 #51
0
ファイル: Utils.cs プロジェクト: youthjoy/cshelper
        /// <summary>
        /// 将数据表转换成JSON类型串
        /// </summary>
        /// <param name="dt">要转换的数据表</param>
        /// <param name="dispose">数据表转换结束后是否dispose掉</param>
        /// <returns></returns>
        public static StringBuilder DataTableToJson(System.Data.DataTable dt, bool dt_dispose)
        {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.Append("[\r\n");

            //数据表字段名和类型数组
            string[] dt_field = new string[dt.Columns.Count];
            int i = 0;
            string formatStr = "{{";
            string fieldtype = "";
            foreach (System.Data.DataColumn dc in dt.Columns)
            {
                dt_field[i] = dc.Caption.ToLower().Trim();
                formatStr += "'" + dc.Caption.ToLower().Trim() + "':";
                fieldtype = dc.DataType.ToString().Trim().ToLower();
                if (fieldtype.IndexOf("int") > 0 || fieldtype.IndexOf("deci") > 0 ||
                    fieldtype.IndexOf("floa") > 0 || fieldtype.IndexOf("doub") > 0 ||
                    fieldtype.IndexOf("bool") > 0)
                {
                    formatStr += "{" + i + "}";
                }
                else
                {
                    formatStr += "'{" + i + "}'";
                }
                formatStr += ",";
                i++;
            }

            if (formatStr.EndsWith(","))
                formatStr = formatStr.Substring(0, formatStr.Length - 1);//去掉尾部","号

            formatStr += "}},";

            i = 0;
            object[] objectArray = new object[dt_field.Length];
            foreach (System.Data.DataRow dr in dt.Rows)
            {

                foreach (string fieldname in dt_field)
                {   //对 \ , ' 符号进行转换
                    objectArray[i] = dr[dt_field[i]].ToString().Trim().Replace("\\", "\\\\").Replace("'", "\\'");
                    switch (objectArray[i].ToString())
                    {
                        case "True":
                            {
                                objectArray[i] = "true"; break;
                            }
                        case "False":
                            {
                                objectArray[i] = "false"; break;
                            }
                        default: break;
                    }
                    i++;
                }
                i = 0;
                stringBuilder.Append(string.Format(formatStr, objectArray));
            }
            if (stringBuilder.ToString().EndsWith(","))
                stringBuilder.Remove(stringBuilder.Length - 1, 1);//去掉尾部","号

            if (dt_dispose)
                dt.Dispose();

            return stringBuilder.Append("\r\n];");
        }
コード例 #52
0
        private void SendMessage(Action<string> messageFunc, string message, System.Timers.Timer timer, params object[] formatParams)
        {
            try
            {
                if(timer != null)
                {
                    timer.Dispose();
                }

                message = (formatParams != null && formatParams.Any() ? String.Format(message, formatParams) : message);
                messageFunc(message);
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error occurred when sending message.  Message: \"{0}\" \nException: {1} ", message, ex.ToString()));
            }
        }
コード例 #53
0
 internal void ActivateCoversView(ITable table)
 {
     System.Dispose();
     this.TasksManager.StartTask(typeof(DefineCoversTask), new object[] { CurrentEmployee.Id, table.Id, table.Area.Id });
 }