private void Init(string projectId, FolderID folderId) { IRestResponse response = CallApi(string.Format("data/v1/projects/{0}/folders/{1}", projectId, folderId.ID), Method.GET).Result; FolderResponse folderJsonData = JsonConvert.DeserializeObject <JsonapiResponse <FolderResponse> >(response.Content).data; this.Json = folderJsonData; }
/// <summary> /// Determines whether the specified <see cref="System.Object"/> is equal to this instance. /// </summary> /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param> /// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.</returns> public override bool Equals(object obj) { if (obj is Criteria2) { var c = (Criteria2)obj; if (!CreateDoc.Equals(c.CreateDoc)) { return(false); } if (!DocID.Equals(c.DocID)) { return(false); } if (!CreateFolder.Equals(c.CreateFolder)) { return(false); } if (!FolderID.Equals(c.FolderID)) { return(false); } if (!DocListFilteredCriteria.Equals(c.DocListFilteredCriteria)) { return(false); } return(true); } return(false); }
/// <summary> /// 特殊フォルダのアイコン画像を取得します。 /// </summary> /// <param name="handle">ウィンドウハンドルを指定します。</param> /// <param name="id">フォルダ ID を指定します。</param> /// <param name="isLarge">大きいアイコンを取得したい場合に true を指定します。</param> /// <returns>取得したアイコン画像を返します。</returns> public static BitmapSource GetSpecialIcon(IntPtr handle, FolderID id, bool isLarge = false) { BitmapSource icon = null; IntPtr hImg; //the handle to the system image list SHFILEINFO psf = new SHFILEINFO(); var startLocation = id; IntPtr pidlRoot = IntPtr.Zero; SHGetSpecialFolderLocation(handle, (int)startLocation, out pidlRoot); var uFlags = isLarge ? SHGFI_LARGEICON : SHGFI_SMALLICON; uFlags |= SHGFI_ICON | SHGFI_PIDL; hImg = SHGetFileInfo(pidlRoot, 0, ref psf, (uint)Marshal.SizeOf(psf), uFlags); //The icon is returned in the hIcon member of the shinfo struct //System.Drawing.Icon myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon); if (psf.hIcon != IntPtr.Zero) { icon = Imaging.CreateBitmapSourceFromHIcon(psf.hIcon, Int32Rect.Empty, null); } // pidlを解放する。 if (pidlRoot != IntPtr.Zero) { IMalloc malloc; int nret = SHGetMalloc(out malloc); malloc.Free(pidlRoot); } return(icon); }
public override int GetHashCode() { unchecked { var hashCode = AlertID; hashCode = (hashCode * 397) ^ Code; hashCode = (hashCode * 397) ^ (Source != null ? Source.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Title != null ? Title.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Severity != null ? Severity.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Created.GetHashCode(); hashCode = (hashCode * 397) ^ SnoozedEndDate.GetHashCode(); hashCode = (hashCode * 397) ^ (ThresholdValue1 != null ? ThresholdValue1.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ThresholdValue2 != null ? ThresholdValue2.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ThresholdValue3 != null ? ThresholdValue3.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ThresholdValue4 != null ? ThresholdValue4.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ThresholdValue5 != null ? ThresholdValue5.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DeviceGuid != null ? DeviceGuid.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AdditionalInfo != null ? AdditionalInfo.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AlertCategoryID != null ? AlertCategoryID.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Archived.GetHashCode(); hashCode = (hashCode * 397) ^ ArchivedDate.GetHashCode(); hashCode = (hashCode * 397) ^ TicketID.GetHashCode(); hashCode = (hashCode * 397) ^ (AlertMessage != null ? AlertMessage.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DeviceName != null ? DeviceName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ CustomerID; hashCode = (hashCode * 397) ^ (CustomerName != null ? CustomerName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (MessageTemplate != null ? MessageTemplate.GetHashCode() : 0); hashCode = (hashCode * 397) ^ FolderID.GetHashCode(); hashCode = (hashCode * 397) ^ PollingCyclesCount.GetHashCode(); return(hashCode); } }
/// <summary> /// Parse the RopLogonResponse_PublicFolders structure. /// </summary> /// <param name="s">An stream containing RopLogonResponse_PublicFolders structure.</param> public override void Parse(Stream s) { base.Parse(s); this.RopId = (RopIdType)ReadByte(); this.OutputHandleIndex = ReadByte(); HelpMethod help = new HelpMethod(); this.ReturnValue = help.FormatErrorCode(ReadUint()); if ((ErrorCodes)ReturnValue == ErrorCodes.Success) { this.LogonFlags = (LogonFlags)ReadByte(); this.FolderIds = new FolderID[13]; for (int i = 0; i < 13; i++) { FolderIds[i] = new FolderID(); FolderIds[i].Parse(s); } this.ReplId = ReadUshort(); this.ReplGuid = ReadGuid(); this.PerUserGuid = ReadGuid(); } else if ((AdditionalErrorCodes)ReturnValue == AdditionalErrorCodes.WrongServer) { this.LogonFlags = (LogonFlags)ReadByte(); this.ServerNameSize = ReadByte(); this.ServerName = new MAPIString(Encoding.ASCII); this.ServerName.Parse(s); } }
public override int GetHashCode() { unchecked { var hashCode = AgentID; hashCode = (hashCode * 397) ^ (MachineID != null ? MachineID.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DeviceGuid != null ? DeviceGuid.GetHashCode() : 0); hashCode = (hashCode * 397) ^ CustomerID; hashCode = (hashCode * 397) ^ (CustomerName != null ? CustomerName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ FolderID.GetHashCode(); hashCode = (hashCode * 397) ^ (AgentName != null ? AgentName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SystemName != null ? SystemName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (MachineName != null ? MachineName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (DomainName != null ? DomainName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (CurrentLoggedUsers != null ? CurrentLoggedUsers.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ComputerDescription != null ? ComputerDescription.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Monitored.GetHashCode(); hashCode = (hashCode * 397) ^ LastPatchManagementReceived.GetHashCode(); hashCode = (hashCode * 397) ^ (AgentVersion != null ? AgentVersion.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Favorite.GetHashCode(); hashCode = (hashCode * 397) ^ ThresholdID.GetHashCode(); hashCode = (hashCode * 397) ^ MonitoredAgentID.GetHashCode(); hashCode = (hashCode * 397) ^ Created.GetHashCode(); hashCode = (hashCode * 397) ^ Modified.GetHashCode(); hashCode = (hashCode * 397) ^ Online.GetHashCode(); hashCode = (hashCode * 397) ^ (ReportedFromIP != null ? ReportedFromIP.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (AppViewUrl != null ? AppViewUrl.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Motherboard != null ? Motherboard.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Processor != null ? Processor.GetHashCode() : 0); hashCode = (hashCode * 397) ^ Memory.GetHashCode(); hashCode = (hashCode * 397) ^ (Display != null ? Display.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Sound != null ? Sound.GetHashCode() : 0); hashCode = (hashCode * 397) ^ ProcessorCoresCount.GetHashCode(); hashCode = (hashCode * 397) ^ (SystemDrive != null ? SystemDrive.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ProcessorClock != null ? ProcessorClock.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Vendor != null ? Vendor.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (VendorSerialNumber != null ? VendorSerialNumber.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (VendorBrandModel != null ? VendorBrandModel.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (ProductName != null ? ProductName.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OS != null ? OS.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OSType != null ? OSType.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OSVersion != null ? OSVersion.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OSBuild != null ? OSBuild.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (WindowsSerialNumber != null ? WindowsSerialNumber.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Office != null ? Office.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OfficeSP != null ? OfficeSP.GetHashCode() : 0); hashCode = (hashCode * 397) ^ OfficeOEM.GetHashCode(); hashCode = (hashCode * 397) ^ (OfficeSerialNumber != null ? OfficeSerialNumber.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (OfficeFullVersion != null ? OfficeFullVersion.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (LastLoginUser != null ? LastLoginUser.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (HardwareDisks?.Sum(x => x.GetHashCode()) ?? 0); hashCode = (hashCode * 397) ^ (MacAddresses?.Sum(x => x.GetHashCode()) ?? 0); hashCode = (hashCode * 397) ^ (IpAddresses?.Sum(x => x.GetHashCode()) ?? 0); return(hashCode); } }
/// <summary> /// Parse the RopPublicFolderIsGhostedRequest structure. /// </summary> /// <param name="s">An stream containing RopPublicFolderIsGhostedRequest structure.</param> public override void Parse(Stream s) { base.Parse(s); this.RopId = (RopIdType)ReadByte(); this.LogonId = ReadByte(); this.InputHandleIndex = ReadByte(); this.FolderId = new FolderID(); this.FolderId.Parse(s); }
public void RetArcDiskFolder() { FolderID A = new FolderID(); A.Fdigit = 0; A.Sdigit = 40; A.Letter = "A"; //Еееееееее!!!! Assert.AreEqual("0A40", A.DiskFolder); }
public override int GetHashCode() { var hashCode = 438000814; hashCode = hashCode * -1521134295 + FolderID.GetHashCode(); hashCode = hashCode * -1521134295 + FileID.GetHashCode(); hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(FileName); return(hashCode); }
/// <summary> /// Parse the ServerEid structure. /// </summary> /// <param name="s">A stream containing the ServerEid structure</param> public override void Parse(Stream s) { base.Parse(s); this.Ours = ReadByte(); FolderID folderId = new FolderID(); this.FolderId = folderId; this.FolderId.Parse(s); this.MessageId = ReadUlong(); this.Instance = ReadINT32(); }
public void FullPath() { FolderID A = new FolderID(); A.Fdigit = 0; A.Sdigit = 40; A.Letter = "A"; A.Rome = "III"; A.MotherFolder = @"C:\storage\data"; Assert.AreEqual(@"C:\storage\data\A\0A\0A40\III", A.GetFullPath()); }
public FolderBrowser() { Description = "Please select a folder below:"; InitialDirectory = String.Empty; SelectedPath = String.Empty; NewStyle = true; IncludeFiles = false; ShowEditBox = false; ShowNewFolderButton = true; RootPIDL = IntPtr.Zero; RootFolderID = FolderID.Desktop; }
/// <summary> /// Parse the RopSetReceiveFolderRequest structure. /// </summary> /// <param name="s">An stream containing RopSetReceiveFolderRequest structure.</param> public override void Parse(Stream s) { base.Parse(s); this.RopId = (RopIdType)ReadByte(); this.LogonId = ReadByte(); this.InputHandleIndex = ReadByte(); this.FolderId = new FolderID(); this.FolderId.Parse(s); this.MessageClass = new MAPIString(Encoding.ASCII); this.MessageClass.Parse(s); }
public void IncLetterTest() { FolderID A = new FolderID(); A.Fdigit = 0; A.Sdigit = 40; A.Letter = "A"; A.Rome = "III"; A.IncLetter(); Assert.AreEqual("B", A.Letter); }
public void IncSdigitTest() { FolderID A = new FolderID(); A.Fdigit = 0; A.Sdigit = 40; A.Letter = "A"; A.Rome = "III"; A.IncSdigit(); Assert.AreEqual(41, A.Sdigit); }
static void Main(string[] args) { FolderID ID = new FolderID(@"C:\storage\", 0, "A", 40, "I"); var IDb = ID.GetIncFdigit(); var T = new WikiCard(); T.GetDataFromWiki(@"https://ru.wikipedia.org/wiki/Изображая_жертву"); Console.WriteLine(T.ToString()); Console.ReadLine(); }
/// <summary> /// Parse the OP_REPLY_and_OP_OOF_REPLY_ActionData_forStandard structure. /// </summary> /// <param name="s">A stream containing the OP_REPLY_and_OP_OOF_REPLY_ActionData_forStandard structure</param> public override void Parse(Stream s) { base.Parse(s); FolderID replyTemplateFID = new FolderID(); this.ReplyTemplateFID = replyTemplateFID; this.ReplyTemplateFID.Parse(s); MessageID replyTemplateMID = new MessageID(); this.ReplyTemplateMID = replyTemplateMID; this.ReplyTemplateMID.Parse(s); this.ReplyTemplateGUID = ReadGuid(); }
//List<FilmEntry> newData; public Form1() { InitializeComponent(); this.button6.Enabled = false; wCard = new WikiCard(); ID = new FolderID(@"D:\filmData", 0, "A", 43, "I"); //newData = readNew();// List<FilmEntry>(); var t = File.ReadAllText("resultFilm.json"); Newtonsoft.Json.Linq.JObject j = Newtonsoft.Json.Linq.JObject.Parse(t); oldData = (Newtonsoft.Json.Linq.JArray)j["data"]; updateFolderText(); }
/// <summary> /// Parse the RopGetReceiveFolderResponse structure. /// </summary> /// <param name="s">An stream containing RopGetReceiveFolderResponse structure.</param> public override void Parse(Stream s) { base.Parse(s); this.RopId = (RopIdType)ReadByte(); this.InputHandleIndex = ReadByte(); HelpMethod help = new HelpMethod(); this.ReturnValue = help.FormatErrorCode(ReadUint()); if ((ErrorCodes)ReturnValue == ErrorCodes.Success) { this.FolderId = new FolderID(); this.FolderId.Parse(s); this.ExplicitMessageClass = new MAPIString(Encoding.ASCII); this.ExplicitMessageClass.Parse(s); } }
/// <summary> /// Parse the RopRegisterNotificationRequest structure. /// </summary> /// <param name="s">An stream containing RopRegisterNotificationRequest structure.</param> public override void Parse(Stream s) { base.Parse(s); this.RopId = (RopIdType)ReadByte(); this.LogonId = ReadByte(); this.InputHandleIndex = ReadByte(); this.OutputHandleIndex = ReadByte(); this.NotificationTypes = (NotificationTypesEnum)ReadUshort(); if (this.NotificationTypes == NotificationTypesEnum.Extended) { this.Reserved = ReadByte(); } this.WantWholeStore = ReadBoolean(); if (!this.WantWholeStore) { this.FolderId = new FolderID(); this.FolderId.Parse(s); this.MessageId = new MessageID(); this.MessageId.Parse(s); } }
/// <summary> /// 特殊フォルダのアイコン画像をバイト配列として取得します。 /// </summary> /// <param name="handle">ウィンドウハンドルを指定します。</param> /// <param name="id">フォルダ ID を指定します。</param> /// <param name="isLarge">大きいアイコンを取得したい場合に true を指定します。</param> /// <returns>取得したアイコン画像を返します。</returns> public static byte[] GetSpecialIconByByteArray(IntPtr handle, FolderID id, bool isLarge = false) { var icon = GetSpecialIcon(handle, id, isLarge); return BitmapSourceToByteArray(icon); }
/// <summary> /// Returns a hash code for this instance. /// </summary> /// <returns>An hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns> public override int GetHashCode() { return(string.Concat("Criteria2", CreateDoc.ToString(), DocID.ToString(), CreateFolder.ToString(), FolderID.ToString(), DocListFilteredCriteria.ToString()).GetHashCode()); }
internal Folder(Project owner, FolderID folderId) : base(owner.Authorization) { Owner = owner; Init(owner.ID, folderId); }
/// <summary> /// 特殊フォルダのアイコン画像をバイト配列として取得します。 /// </summary> /// <param name="handle">ウィンドウハンドルを指定します。</param> /// <param name="id">フォルダ ID を指定します。</param> /// <param name="isLarge">大きいアイコンを取得したい場合に true を指定します。</param> /// <returns>取得したアイコン画像を返します。</returns> public static byte[] GetSpecialIconByByteArray(IntPtr handle, FolderID id, bool isLarge = false) { var icon = GetSpecialIcon(handle, id, isLarge); return(BitmapSourceToByteArray(icon)); }
internal Folder(string projectId, FolderID folderId, Authorization auth) : base(auth) { Init(projectId, folderId); }
/// <summary> /// Parse the NotificationData structure. /// </summary> /// <param name="s">An stream containing NotificationData structure.</param> public override void Parse(Stream s) { base.Parse(s); this.NotificationFlags = new NotificationFlags(); this.NotificationFlags.Parse(s); if (this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.TableModified) { this.TableEventType = (TableEventTypeEnum)ReadUshort(); } if (NotificationFlags.Value.NotificationType == NotificationTypesEnum.TableModified && (TableEventType == TableEventTypeEnum.TableRowAdded || TableEventType == TableEventTypeEnum.TableRowDeleted || TableEventType == TableEventTypeEnum.TableRowModified)) { this.TableRowFolderID = new FolderID(); this.TableRowFolderID.Parse(s); } if ((((int)NotificationFlags.Value.NotificationDataAvailability & 0x8000) != 0) && (TableEventType == TableEventTypeEnum.TableRowAdded || TableEventType == TableEventTypeEnum.TableRowDeleted || TableEventType == TableEventTypeEnum.TableRowModified)) { this.TableRowMessageID = new MessageID(); this.TableRowMessageID.Parse(s); } if ((((int)NotificationFlags.Value.NotificationDataAvailability & 0x8000) != 0) && (TableEventType == TableEventTypeEnum.TableRowAdded || TableEventType == TableEventTypeEnum.TableRowDeleted || TableEventType == TableEventTypeEnum.TableRowModified)) { this.TableRowInstance = ReadUint(); } if (NotificationFlags.Value.NotificationType == NotificationTypesEnum.TableModified && (TableEventType == TableEventTypeEnum.TableRowAdded || TableEventType == TableEventTypeEnum.TableRowModified)) { this.InsertAfterTableRowFolderID = new FolderID(); this.InsertAfterTableRowFolderID.Parse(s); } if (NotificationFlags.Value.NotificationType == NotificationTypesEnum.TableModified && (((int)NotificationFlags.Value.NotificationDataAvailability & 0x8000) != 0) && (TableEventType == TableEventTypeEnum.TableRowAdded || TableEventType == TableEventTypeEnum.TableRowModified)) { this.InsertAfterTableRowID = new MessageID(); this.InsertAfterTableRowID.Parse(s); } if (NotificationFlags.Value.NotificationType == NotificationTypesEnum.TableModified && (((int)NotificationFlags.Value.NotificationDataAvailability & 0x8000) != 0) && (TableEventType == TableEventTypeEnum.TableRowAdded || TableEventType == TableEventTypeEnum.TableRowModified)) { this.InsertAfterTableRowInstance = ReadUint(); } if (NotificationFlags.Value.NotificationType == NotificationTypesEnum.TableModified && (TableEventType == TableEventTypeEnum.TableRowAdded || TableEventType == TableEventTypeEnum.TableRowModified)) { this.TableRowDataSize = ReadUshort(); } if (NotificationFlags.Value.NotificationType == NotificationTypesEnum.TableModified && (TableEventType == TableEventTypeEnum.TableRowAdded || TableEventType == TableEventTypeEnum.TableRowModified)) { if (DecodingContext.PropertyTagsForNotify != null && DecodingContext.PropertyTagsForNotify.ContainsKey(this.NotificationHandle)) { propertiesBySetColum = DecodingContext.PropertyTagsForNotify[this.NotificationHandle]; } else { throw new MissingInformationException("Missing PropertyTags information for RopNotifyResponse", (ushort)RopIdType.RopNotify, new uint[] { 0, NotificationHandle }); } this.TableRowData = new PropertyRow(propertiesBySetColum); this.TableRowData.Parse(s); } if (NotificationFlags.Value.NotificationType != NotificationTypesEnum.TableModified && NotificationFlags.Value.NotificationType != NotificationTypesEnum.Extended) { this.FolderId = new FolderID(); this.FolderId.Parse(s); } if (NotificationFlags.Value.NotificationType != NotificationTypesEnum.TableModified && NotificationFlags.Value.NotificationType != NotificationTypesEnum.Extended && (((int)NotificationFlags.Value.NotificationDataAvailability & 0x8000) != 0)) { this.MessageId = new MessageID(); this.MessageId.Parse(s); } if ((NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectCreated || NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectDeleted || NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectMoved || NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectCopied) && ((((int)NotificationFlags.Value.NotificationDataAvailability) & 0xC000) == 0xC000 || (((int)NotificationFlags.Value.NotificationDataAvailability) & 0xC000) == 0)) { this.ParentFolderId = new FolderID(); this.ParentFolderId.Parse(s); } if (NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectMoved || NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectCopied) { this.OldFolderId = new FolderID(); this.OldFolderId.Parse(s); } if ((NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectMoved || NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectCopied) && (((int)NotificationFlags.Value.NotificationDataAvailability & 0x8000) != 0)) { this.OldMessageId = new MessageID(); this.OldMessageId.Parse(s); } if ((NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectMoved || NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectCopied) && (((int)NotificationFlags.Value.NotificationDataAvailability & 0x8000) == 0)) { this.OldParentFolderId = new MessageID(); this.OldParentFolderId.Parse(s); } if (NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectCreated || NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectModified) { this.TagCount = ReadUshort(); if (TagCount != 0x0000 && TagCount != 0xFFFF) { List <PropertyTag> listTags = new List <PropertyTag>(); for (int i = 0; i < this.TagCount; i++) { PropertyTag tempTag = new PropertyTag(); tempTag.Parse(s); listTags.Add(tempTag); } this.Tags = listTags.ToArray(); } } if (((int)NotificationFlags.Value.NotificationDataAvailability & 0x1000) != 0) { this.TotalMessageCount = ReadUint(); } if (((int)NotificationFlags.Value.NotificationDataAvailability & 0x2000) != 0) { this.UnreadMessageCount = ReadUint(); } if (NotificationFlags.Value.NotificationType == NotificationTypesEnum.NewMail) { this.MessageFlags = ReadUint(); this.UnicodeFlag = ReadByte(); this.MessageClass = new MAPIString(Encoding.ASCII); this.MessageClass.Parse(s); } }
/// <summary> /// 特殊フォルダのアイコン画像を取得します。 /// </summary> /// <param name="handle">ウィンドウハンドルを指定します。</param> /// <param name="id">フォルダ ID を指定します。</param> /// <param name="isLarge">大きいアイコンを取得したい場合に true を指定します。</param> /// <returns>取得したアイコン画像を返します。</returns> public static BitmapSource GetSpecialIcon(IntPtr handle, FolderID id, bool isLarge = false) { BitmapSource icon = null; IntPtr hImg; //the handle to the system image list SHFILEINFO psf = new SHFILEINFO(); var startLocation = id; IntPtr pidlRoot = IntPtr.Zero; SHGetSpecialFolderLocation(handle, (int)startLocation, out pidlRoot); var uFlags = isLarge ? SHGFI_LARGEICON : SHGFI_SMALLICON; uFlags |= SHGFI_ICON | SHGFI_PIDL; hImg = SHGetFileInfo(pidlRoot, 0, ref psf, (uint)Marshal.SizeOf(psf), uFlags); //The icon is returned in the hIcon member of the shinfo struct //System.Drawing.Icon myIcon = System.Drawing.Icon.FromHandle(shinfo.hIcon); if (psf.hIcon != IntPtr.Zero) icon = Imaging.CreateBitmapSourceFromHIcon(psf.hIcon, Int32Rect.Empty, null); // pidlを解放する。 if (pidlRoot != IntPtr.Zero) { IMalloc malloc; int nret = SHGetMalloc(out malloc); malloc.Free(pidlRoot); } return icon; }
public void Put(string remotename, System.IO.Stream stream) { if (stream.Length > BITS_FILE_SIZE_LIMIT) { // Get extra info for BITS var uid = UserID; var fid = FolderID.Split('.')[2]; // Create a session var url = string.Format("https://cid-{0}.users.storage.live.com/items/{1}/{2}?access_token={3}", uid, fid, Utility.Uri.UrlPathEncode(remotename), Library.Utility.Uri.UrlEncode(m_oauth.AccessToken)); var req = (HttpWebRequest)WebRequest.Create(url); req.UserAgent = USER_AGENT; req.Method = "POST"; req.ContentType = "application/json"; req.Headers.Add("X-Http-Method-Override", "BITS_POST"); req.Headers.Add("BITS-Packet-Type", "Create-Session"); req.Headers.Add("BITS-Supported-Protocols", "{7df0354d-249b-430f-820d-3d2a9bef4931}"); req.ContentLength = 0; var areq = new Utility.AsyncHttpRequest(req); string sessionid; using (var resp = (HttpWebResponse)areq.GetResponse()) { var packtype = resp.Headers["BITS-Packet-Type"]; if (!packtype.Equals("Ack", StringComparison.OrdinalIgnoreCase)) { throw new Exception(string.Format("Unable to create BITS transfer, got status: {0}", packtype)); } sessionid = resp.Headers["BITS-Session-Id"]; } if (string.IsNullOrEmpty(sessionid)) { throw new Exception("BITS session-id was missing"); } // Session is now created, start uploading chunks var offset = 0L; var retries = 0; while (offset < stream.Length) { try { var bytesInChunk = Math.Min(BITS_CHUNK_SIZE, stream.Length - offset); req = (HttpWebRequest)WebRequest.Create(url); req.UserAgent = USER_AGENT; req.Method = "POST"; req.Headers.Add("X-Http-Method-Override", "BITS_POST"); req.Headers.Add("BITS-Packet-Type", "Fragment"); req.Headers.Add("BITS-Session-Id", sessionid); req.Headers.Add("Content-Range", string.Format("bytes {0}-{1}/{2}", offset, offset + bytesInChunk - 1, stream.Length)); req.ContentLength = bytesInChunk; if (stream.Position != offset) { stream.Position = offset; } areq = new Utility.AsyncHttpRequest(req); var remaining = (int)bytesInChunk; using (var reqs = areq.GetRequestStream()) { int read; while ((read = stream.Read(m_copybuffer, 0, Math.Min(m_copybuffer.Length, remaining))) != 0) { reqs.Write(m_copybuffer, 0, read); remaining -= read; } } using (var resp = (HttpWebResponse)areq.GetResponse()) { if (resp.StatusCode != HttpStatusCode.OK) { throw new WebException("Invalid partial upload response", null, WebExceptionStatus.UnknownError, resp); } } offset += bytesInChunk; retries = 0; } catch (Exception ex) { var retry = false; // If we get a 5xx error, or some network issue, we retry if (ex is WebException && ((WebException)ex).Response is HttpWebResponse) { var code = (int)((HttpWebResponse)((WebException)ex).Response).StatusCode; retry = code >= 500 && code <= 599; } else if (ex is System.Net.Sockets.SocketException || ex is System.IO.IOException || ex.InnerException is System.Net.Sockets.SocketException || ex.InnerException is System.IO.IOException) { retry = true; } // Retry with exponential backoff if (retry && retries < 5) { System.Threading.Thread.Sleep(TimeSpan.FromSeconds(Math.Pow(2, retries))); retries++; } else { throw; } } } // Transfer completed, now commit the upload and close the session req = (HttpWebRequest)WebRequest.Create(url); req.UserAgent = USER_AGENT; req.Method = "POST"; req.Headers.Add("X-Http-Method-Override", "BITS_POST"); req.Headers.Add("BITS-Packet-Type", "Close-Session"); req.Headers.Add("BITS-Session-Id", sessionid); req.ContentLength = 0; areq = new Utility.AsyncHttpRequest(req); using (var resp = (HttpWebResponse)areq.GetResponse()) { if (resp.StatusCode != HttpStatusCode.OK) { throw new Exception("Invalid partial upload commit response"); } } } else { var url = string.Format("{0}/{1}/files/{2}?access_token={3}", WLID_SERVER, FolderID, Utility.Uri.UrlPathEncode(remotename), Library.Utility.Uri.UrlEncode(m_oauth.AccessToken)); var req = (HttpWebRequest)WebRequest.Create(url); req.UserAgent = USER_AGENT; req.Method = "PUT"; try { req.ContentLength = stream.Length; } catch { } // Docs says not to set this ? //req.ContentType = "application/octet-stream"; var areq = new Utility.AsyncHttpRequest(req); using (var reqs = areq.GetRequestStream()) Utility.Utility.CopyStream(stream, reqs, true, m_copybuffer); using (var resp = (HttpWebResponse)areq.GetResponse()) using (var rs = areq.GetResponseStream()) using (var tr = new System.IO.StreamReader(rs)) using (var jr = new Newtonsoft.Json.JsonTextReader(tr)) { var nf = new Newtonsoft.Json.JsonSerializer().Deserialize <WLID_FolderItem>(jr); m_fileidCache[remotename] = nf.id; } } }
/// <summary> /// Parse the NotificationData structure. /// </summary> /// <param name="s">A stream containing NotificationData structure.</param> public override void Parse(Stream s) { base.Parse(s); this.NotificationFlags = new NotificationFlags(); this.NotificationFlags.Parse(s); if (this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.TableModified) { this.TableEventType = (TableEventTypeEnum)this.ReadUshort(); } if (this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.TableModified && (this.TableEventType == TableEventTypeEnum.TableRowAdded || this.TableEventType == TableEventTypeEnum.TableRowDeleted || this.TableEventType == TableEventTypeEnum.TableRowModified)) { this.TableRowFolderID = new FolderID(); this.TableRowFolderID.Parse(s); } if ((((int)this.NotificationFlags.Value.NotificationDataAvailability & 0x8000) != 0) && (this.TableEventType == TableEventTypeEnum.TableRowAdded || this.TableEventType == TableEventTypeEnum.TableRowDeleted || this.TableEventType == TableEventTypeEnum.TableRowModified)) { this.TableRowMessageID = new MessageID(); this.TableRowMessageID.Parse(s); } if ((((int)this.NotificationFlags.Value.NotificationDataAvailability & 0x8000) != 0) && (this.TableEventType == TableEventTypeEnum.TableRowAdded || this.TableEventType == TableEventTypeEnum.TableRowDeleted || this.TableEventType == TableEventTypeEnum.TableRowModified)) { this.TableRowInstance = this.ReadUint(); } if (this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.TableModified && (this.TableEventType == TableEventTypeEnum.TableRowAdded || this.TableEventType == TableEventTypeEnum.TableRowModified)) { this.InsertAfterTableRowFolderID = new FolderID(); this.InsertAfterTableRowFolderID.Parse(s); } if (this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.TableModified && (((int)this.NotificationFlags.Value.NotificationDataAvailability & 0x8000) != 0) && (this.TableEventType == TableEventTypeEnum.TableRowAdded || this.TableEventType == TableEventTypeEnum.TableRowModified)) { this.InsertAfterTableRowID = new MessageID(); this.InsertAfterTableRowID.Parse(s); } if (this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.TableModified && (((int)this.NotificationFlags.Value.NotificationDataAvailability & 0x8000) != 0) && (this.TableEventType == TableEventTypeEnum.TableRowAdded || this.TableEventType == TableEventTypeEnum.TableRowModified)) { this.InsertAfterTableRowInstance = this.ReadUint(); } if (this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.TableModified && (this.TableEventType == TableEventTypeEnum.TableRowAdded || this.TableEventType == TableEventTypeEnum.TableRowModified)) { this.TableRowDataSize = this.ReadUshort(); } if (this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.TableModified && (this.TableEventType == TableEventTypeEnum.TableRowAdded || this.TableEventType == TableEventTypeEnum.TableRowModified)) { int parsingSessionID = MapiInspector.MAPIInspector.ParsingSession.id; if (!(DecodingContext.Notify_handlePropertyTags.Count > 0 && DecodingContext.Notify_handlePropertyTags.ContainsKey(this.notificationHandle) && DecodingContext.Notify_handlePropertyTags[this.notificationHandle].ContainsKey(parsingSessionID) && DecodingContext.Notify_handlePropertyTags[this.notificationHandle][parsingSessionID].Item1 == MapiInspector.MAPIInspector.ParsingSession.RequestHeaders.RequestPath && DecodingContext.Notify_handlePropertyTags[this.notificationHandle][parsingSessionID].Item2 == MapiInspector.MAPIInspector.ParsingSession.LocalProcess && DecodingContext.Notify_handlePropertyTags[this.notificationHandle][parsingSessionID].Item3 == MapiInspector.MAPIInspector.ParsingSession.RequestHeaders["X-ClientInfo"])) { throw new MissingInformationException("Missing PropertyTags information for RopNotifyResponse", (ushort)RopIdType.RopNotify, new uint[] { this.IsEmptyMessageID(this.TableRowMessageID) ? (uint)0 : (uint)1, this.notificationHandle }); } else { this.propertiesBySetColum = DecodingContext.Notify_handlePropertyTags[this.notificationHandle][parsingSessionID].Item4; } this.TableRowData = new PropertyRow(this.propertiesBySetColum); this.TableRowData.Parse(s); } if (this.NotificationFlags.Value.NotificationType != NotificationTypesEnum.TableModified && this.NotificationFlags.Value.NotificationType != NotificationTypesEnum.Extended) { this.FolderId = new FolderID(); this.FolderId.Parse(s); } if (this.NotificationFlags.Value.NotificationType != NotificationTypesEnum.TableModified && this.NotificationFlags.Value.NotificationType != NotificationTypesEnum.Extended && (((int)this.NotificationFlags.Value.NotificationDataAvailability & 0x8000) != 0)) { this.MessageId = new MessageID(); this.MessageId.Parse(s); } if ((this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectCreated || this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectDeleted || this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectMoved || this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectCopied) && ((((int)this.NotificationFlags.Value.NotificationDataAvailability) & 0xC000) == 0xC000 || (((int)this.NotificationFlags.Value.NotificationDataAvailability) & 0xC000) == 0)) { this.ParentFolderId = new FolderID(); this.ParentFolderId.Parse(s); } if (this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectMoved || this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectCopied) { this.OldFolderId = new FolderID(); this.OldFolderId.Parse(s); } if ((this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectMoved || this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectCopied) && (((int)this.NotificationFlags.Value.NotificationDataAvailability & 0x8000) != 0)) { this.OldMessageId = new MessageID(); this.OldMessageId.Parse(s); } if ((this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectMoved || this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectCopied) && (((int)this.NotificationFlags.Value.NotificationDataAvailability & 0x8000) == 0)) { this.OldParentFolderId = new MessageID(); this.OldParentFolderId.Parse(s); } if (this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectCreated || this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.ObjectModified) { this.TagCount = this.ReadUshort(); if (this.TagCount != 0x0000 && this.TagCount != 0xFFFF) { List <PropertyTag> listTags = new List <PropertyTag>(); for (int i = 0; i < this.TagCount; i++) { PropertyTag tempTag = new PropertyTag(); tempTag.Parse(s); listTags.Add(tempTag); } this.Tags = listTags.ToArray(); } } if (((int)this.NotificationFlags.Value.NotificationDataAvailability & 0x1000) != 0) { this.TotalMessageCount = this.ReadUint(); } if (((int)this.NotificationFlags.Value.NotificationDataAvailability & 0x2000) != 0) { this.UnreadMessageCount = this.ReadUint(); } if (this.NotificationFlags.Value.NotificationType == NotificationTypesEnum.NewMail) { this.MessageFlags = this.ReadUint(); this.UnicodeFlag = this.ReadByte(); this.MessageClass = new MAPIString(Encoding.ASCII); this.MessageClass.Parse(s); } }