/// <summary> /// バルーンを表示する /// </summary> public string ShowBalloon(StreamClass sc, int time) { NotifyIcon.BalloonTipTitle = sc.Title; NotifyIcon.BalloonTipText = sc.Owner; NotifyIcon.ShowBalloonTip(time); return(sc.Url); }
private static void PrintMail(string fileName) { var stream = new StreamClass(); stream.Open(); stream.LoadFromFile(fileName); stream.Flush(); var mail = new MessageClass(); mail.DataSource.OpenObject(stream, "_Stream"); mail.DataSource.Save(); Console.WriteLine("From: {0}", mail.From); Console.WriteLine("To: {0}", mail.To); Console.WriteLine("CC: {0}", mail.CC); Console.WriteLine("BCC: {0}", mail.BCC); Console.WriteLine("Subject: {0}", mail.Subject); Console.WriteLine("Body:"); Console.WriteLine(mail.TextBody); Console.WriteLine(); Console.WriteLine("Attachments:"); foreach (IBodyPart attachment in mail.Attachments) { Console.Write(attachment.FileName); Console.Write(" Open it? [y/N] "); var key = Console.ReadKey(); Console.WriteLine(); if (key.KeyChar != 'Y' && key.KeyChar != 'y') continue; var tempFile = Path.Combine(Path.GetTempPath(), attachment.FileName); var contentStream = attachment.GetDecodedContentStream(); contentStream.SaveToFile(tempFile, SaveOptionsEnum.adSaveCreateOverWrite); Process.Start(tempFile); } stream.Close(); }
public void StreamTest() { var stream = new MemoryStream(System.Text.Encoding.ASCII.GetBytes("StreamValue")); var expected = new StreamClass { Field = stream }; var actual = Roundtrip(expected); Assert.AreEqual(stream.Length, actual.Field.Length); }
public static RecordsetClass XmlToRecordset(string xml) { var stream = new StreamClass(); stream.Open(Missing.Value, ConnectModeEnum.adModeUnknown, StreamOpenOptionsEnum.adOpenStreamUnspecified, null, null); stream.WriteText(xml, 0); stream.Position = 0; var recordset = new RecordsetClass(); recordset.Open(stream, Missing.Value, CursorTypeEnum.adOpenUnspecified, LockTypeEnum.adLockUnspecified, 0); return(recordset); }
public override bool CompareTo(StreamClass Stream) { bool Result = false; if (Stream != null) { string Temp = "{" + FirstName.ToString() + "," + LastName.ToString() + "," + BirthDate.ToString() + "}" Result = Data.CompareTo(Temp); } } // bool CompareTo(...)
//bool flag = false; public SlideShow() { InitializeComponent(); timer = new DispatcherTimer(); device = new Device(); stream = new StreamClass(); pptLoader = new PPTFileLoader(); openFileDiag = new OpenFileDialog(); timer.Interval = new TimeSpan(0, 0, 1); openFileDiag.Filter = "Powerpoint file (*.ppt)|*.ppt|All files (*.*)|*.*"; stream.StreamName = Properties.Settings.Default.courseid; desktopStream = false; mn = new ChatBox.MainWindow(Properties.Settings.Default.courseid); }
public override bool RemoveFavorite(StreamClass target) { lock (lockobject_) { if (favoriteStreamClassList_.Exists(x => x == target)) { favoriteStreamClassList_.Remove(target); return(true); } else { return(false); } } }
public Toolbar() { InitializeComponent(); device = new Device(); stream = new StreamClass(); stream.StreamName = Properties.Settings.Default.courseid; desktopStream = false; this.Top = 768 - 100; this.Left = (1369 / 2) - 220; Loaded += Toolbar_Loaded; mn = new ChatBox.MainWindow(Properties.Settings.Default.courseid); mn.Hide(); }
public void OpenEml(string filepath) { try { var stream = new StreamClass(); stream.Open(); stream.LoadFromFile(filepath); stream.Flush(); var mail = new MessageClass(); mail.DataSource.OpenObject(stream, "_Stream"); mail.DataSource.Save(); fromBox.Text = mail.From; toBox.Text = mail.To; ccBox.Text = mail.CC; bccBox.Text = mail.BCC; subjectBox.Text = mail.Subject; bodyBox.Text = mail.TextBody; attachmentsPanel.Controls.Clear(); foreach (IBodyPart attachment in mail.Attachments) { var linkLabel = new LinkLabel { Text = attachment.FileName, AutoSize = true, }; linkLabel.Links.Add(0, linkLabel.Text.Length, attachment.GetDecodedContentStream()); linkLabel.LinkClicked += LinkLabelLinkClicked; linkLabel.Disposed += LinkLabelDisposed; attachmentsPanel.Controls.Add(linkLabel); } stream.Close(); } catch (Exception) { MessageBox.Show(this, "An error occured while opening the file", "Email could not be opened", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void SetRestore() { //display file(S) //prompt for file(s) // ... // ... List<int> gamearrayints = StreamClass.RestoreGameArray("C:/program files/returnchar/savelist.csv"); // restoring savelists foreach(int i in gamearrayints) { GameArray.Add(Book.GetBookID(i)); } GetGameModelOne(); break; // ... // ... }
public override bool AddFavorite(StreamClass newFavorite) { lock (lockobject_) { if (favoriteStreamClassList_.Exists(x => x.Start_Time == newFavorite.Start_Time && x.Owner == newFavorite.Owner)) { return(false); } else { favoriteStreamClassList_.Add(newFavorite); //最大サイズを超えていれば古い方から削除 while (favoriteStreamClassList_.Count > maxLogSize) { favoriteStreamClassList_.RemoveAt(0); } return(true); } } }
public static bool HighScorePath() { const string highscorefilepath = @"C:\program files\returnchar\highscores.csv"; try { if (File.Exists(highscorefilepath)) { StreamClass.SetHighScorePath(highscorefilepath); Console.WriteLine($"Path successfully set"); Console.ReadLine(); return(true); } else { return(false); } } catch (Exception secexc) { Console.WriteLine($"{secexc.Message}"); return(false); } }
public abstract bool CompareTo(StreamClass Stream);
/// <summary> /// Implementation of a Synchronous Event. This event will be triggered every time a /// mail message arrives at the mailbox where it is registered. It is synchronous because /// message will wait for the code here implemented to end execution before beeing available in mailbox. /// </summary> /// <param name="pEventInfo">A pointer to an IExStoreEventInfo interface that can be used to obtain further information related to the event.</param> /// <param name="bstrURLItem">A string containing the URL of the item on which the event is occurring.</param> /// <param name="lFlags">Bitwise AND flag gives further information about the save event.</param> public void OnSyncSave(IExStoreEventInfo pEventInfo, string bstrURLItem, int lFlags) { // Initialize local variables OWMailConfiguration configuration = null; EventLog log = null; Stream stream = null; Record recItem = null; try { // These values are checked to identify a saving event before beeing commited // Exchange Server SDK value and Exchange Server 2003 have presented different values // so both were included in this implementation. The enum is also checked here, just in case... if (lFlags == 33554440 || lFlags == 33554432 || lFlags == (int)EVT_SINK_FLAGS.EVT_SYNC_COMMITTED) { // These two must have the same value string sourceApplication = "OWMail"; //string logName = "OWMail"; // If Event Viewer entry does not exists (e.g., first time), then create it if (!EventLog.SourceExists(sourceApplication)) { EventLog.CreateEventSource(sourceApplication, sourceApplication); } log = new EventLog(sourceApplication); log.Log = sourceApplication; log.Source = sourceApplication; // Get settings from OWMail 2.0 XML configuration file configuration = new OWMailConfiguration(ConfigurationFilePath); // Get a ADO Record object from pEventInfo parameter IExStoreDispEventInfo pDispEventInfo = (IExStoreDispEventInfo)pEventInfo; recItem = (Record)pDispEventInfo.EventRecord; // Get a ADO Stream object from ADO Record stream = new StreamClass(); stream.Open(recItem, ConnectModeEnum.adModeRead, StreamOpenOptionsEnum.adOpenStreamFromRecord, string.Empty, string.Empty); // Creates a new Guid to use when saving message and attachments to TEMP directory. // TEMP directory path is stored in configuration file. string guid = Guid.NewGuid().ToString(); string filePath = configuration.TempDirectoryPath + @"\" + guid + ".eml"; // Saves the ADO Stream to TEMP directory stream.SaveToFile(filePath, SaveOptionsEnum.adSaveCreateNotExist); // Creates a CDO Message object Message message = new MessageClass(); // Gets message data loaded from ADO Record object message.DataSource.OpenObject(recItem, "_Record"); // Assigns local variables from loaded message fields string from = message.From; string to = message.To; string cc = message.CC; string subject = (string)message.Fields["urn:schemas:httpmail:normalizedsubject"].Value; DateTime mailDate = message.ReceivedTime; string body = (string)message.Fields["urn:schemas:httpmail:textdescription"].Value; // Use event source URL to extract mailbox name string[] urlElements = bstrURLItem.Split('/'); string mailboxName = urlElements[urlElements.Length - 3]; // Use mailbox name to extract its operation settings from configuration string userLogin = configuration.GetUserLoginByMailboxName(mailboxName, '@'); // OWApi Web Service accepts blank credentials string password = string.Empty; //string entityName = string.Empty; // This list will hold all message entities encapsulated in MailContact objects ArrayList list = new ArrayList(); // This object has functions to ease the extraction of message entity fields MailContactHelper mailContactHelper = new MailContactHelper(); // Get a list with all entities referred in FROM, TO, CC, BCC message fields list = mailContactHelper.GetMailContactsList(from, to, cc); // Directory name to be created in case Extract Attachments option is activated string directoryName = configuration.TempDirectoryPath + @"\" + guid; // OWApiHelper is a wrapper for OWApi Web Service InsertRegistry method. // If call is successfull, result will contain the ID of record created in tblEntities int result = OWApiHelper.InsertRegistry(userLogin, password, list, configuration, directoryName, guid, filePath, message.Attachments, subject, mailDate, body); //Not Register if (result == 0) { throw new Exception("Não é possivel inserir o registo."); } // Clean up temporary message file if (File.Exists(filePath)) { File.Delete(filePath); } // Clean up temporary attachments directory if (Directory.Exists(directoryName)) { Directory.Delete(directoryName, true); } } } catch (Exception ex) { Exception ex2 = null; log.WriteEntry(ex.Message + " " + ex.StackTrace, EventLogEntryType.Error); ex2 = ex.InnerException; while (ex2 != null) { log.WriteEntry(ex2.Message + " " + ex2.StackTrace, EventLogEntryType.Error); ex2 = ex.InnerException; } throw ex; } finally { // Always cleans up unmanaged resources if (stream != null) { stream.Close(); } if (recItem != null) { recItem.Close(); } } }
private void DoConnect() { //username = user; var user = DataOperations.formatString(username, 20); // password = pass; var pass = DataOperations.formatString(password, 20); if (user.Trim().Length == 0) { loginScreenPrint("You must enter both a username", "and a password - Please try again"); return; } if (reconnecting) { gameBoxPrint("Connection lost! Please wait...", "Attempting to re-establish"); } else { loginScreenPrint("Please wait...", "Connecting to server"); } streamClass = new StreamClass(makeSocket(Config.SERVER_IP, Config.SERVER_PORT), this); streamClass.maxPacketReadCount = maxPacketReadCount; long l = DataOperations.nameToHash(user); streamClass.createPacket(32); streamClass.addByte((int)(l >> 16 & 31L)); streamClass.addString("Shinigami");// TODO not used server-side streamClass.flush(); long sessionId = streamClass.readLong(); if (sessionId == 0L) { // loginScreenPrint("Login server offline.", "Please try again in a few mins"); // return; } Console.WriteLine("Verb: Session id: " + sessionId); int[] sessionKeys = new int[4]; sessionKeys[0] = (int)(Helper.Random.NextDouble() * 99999999D); sessionKeys[1] = (int)(Helper.Random.NextDouble() * 99999999D); sessionKeys[2] = (int)(sessionId >> 32); sessionKeys[3] = (int)sessionId; var dataEnc = new LoginDataEncryption(new byte[117]); dataEnc.addByte(reconnecting ? 1 : 0); dataEnc.addInt(Config.CLIENT_VERSION); dataEnc.addInt(sessionKeys[0]); dataEnc.addInt(sessionKeys[1]); dataEnc.addInt(sessionKeys[2]); dataEnc.addInt(sessionKeys[3]); dataEnc.addString(user); dataEnc.addString(pass); byte[] data = dataEnc.encrypt(dataEnc.packet); streamClass.createPacket(77); streamClass.addBytes(data, 0, data.Length); streamClass.flush(); int loginCode = streamClass.read(); Console.WriteLine("login response:" + loginCode); // streamClass.MakeAsync(); if (loginCode == 99) { reconnectTries = 0; initVars(); return; } if (loginCode == 0) { reconnectTries = 0; initVars(); return; } if (loginCode == 1) { reconnectTries = 0; return; } if (reconnecting) { user = ""; pass = ""; resetIntVars(); return; } if (loginCode == -1) { loginScreenPrint("Error unable to login.", "Server timed out"); return; } if (loginCode == 2) { loginScreenPrint("Invalid username or password.", "Try again, or create a new account"); return; } if (loginCode == 3) { loginScreenPrint("That username is already logged in.", "Wait 60 seconds then retry"); return; } if (loginCode == 4) { loginScreenPrint("The client has been updated.", "Please restart the client"); return; } if (loginCode == 5) { loginScreenPrint("Error unable to login.", "Please retry"); return; } if (loginCode == 6) { loginScreenPrint("Account banned.", "Appeal on the forums, ASAP."); return; } if (loginCode == 7) { loginScreenPrint("Error - failed to decode profile.", "Contact an admin!"); return; } if (loginCode == 8) { loginScreenPrint("Too many connections from your IP.", "Please try again later"); return; } if (loginCode == 9) { loginScreenPrint("Account already in use.", "You may only login to one character at a time"); return; } else { loginScreenPrint("Error unable to login.", "Unrecognised response code"); return; } if (reconnectTries > 0) { try { Thread.Sleep(2500); } catch (Exception _ex) { } reconnectTries--; connect(username, password, reconnecting); } if (reconnecting) { username = ""; password = ""; resetIntVars(); } else { loginScreenPrint("Sorry! Unable to connect.", "Check internet settings or try another world"); } }
/// <summary> /// 選択中のメニューに合わせてデータグリッドを更新 /// </summary> private void RefreshDataGrid() { SelectedData = null; DataGridCollection = GetSelectedGridData(SelectedLeftMenu, SelectedTopMenu); }