public ExtState Save(List <DownloadType> types) { ExtState state = ExtState.Failed; if (types == null) { return(state); } Helper.RunElevated(SPContext.Current.Site.ID, SPContext.Current.Site.RootWeb.ID, delegate(SPWeb elevatedWeb) { string fileTypes = string.Empty; string fileSizes = string.Empty; string actives = string.Empty; foreach (DownloadType type in types) { fileTypes += type.Extension + ";"; fileSizes += type.Size + ";"; actives += type.Active + ";"; } elevatedWeb.AllowUnsafeUpdates = true; elevatedWeb.Properties[Content.SPFileTypes] = fileTypes; elevatedWeb.Properties[Content.SPFileSizes] = fileSizes; elevatedWeb.Properties[Content.SPFileTypesActive] = actives; elevatedWeb.Properties.Update(); elevatedWeb.AllowUnsafeUpdates = false; state = ExtState.Success; }); return(state); }
private void SendState(IWire parentWire, ExtState state) { parentWire.Send(RdId, writer => { SendTrace?.Log($"{this} : {state}"); writer.Write((int)state); writer.Write(SerializationHash); }); }
private void SendState(IWire parentWire, ExtState state) { parentWire.Send(RdId, writer => { TraceMe(LogSend, state); writer.Write((int)state); writer.Write(SerializationHash); }); }
private void SendState(IWire parentWire, ExtState state) { using (base.Proto.Contexts.CreateSendWithoutContextsCookie()) parentWire.Send(RdId, writer => { SendTrace?.Log($"{this} : {state}"); writer.Write((int)state); writer.Write(SerializationHash); }); }
public ExtState Add(DownloadType type) { ExtState state = ExtState.Failed; if (!downloadTypes.Contains(type, new DownloadTypeEqualComparer())) { downloadTypes.Add(type); state = Save(downloadTypes); } else { state = ExtState.IsExists; } return(state); }
protected void btnAddDownload_Click(object sender, EventArgs e) { DownloadType type = new DownloadType(txtExtension.Text, Convert.ToInt32(txtSize.Text), chbActive.Checked); ExtState state = DownloadManager.Instance.Add(type); switch (state) { case ExtState.Failed: Helper.AddSPNotification(updSettings, hdnFailed.Value, false); break; case ExtState.Success: Helper.AddSPNotification(updSettings, hdnSuccess.Value, true); break; case ExtState.IsExists: Helper.AddSPNotification(updSettings, string.Format(hdnIsExists.Value, type.Extension), false); break; } }
protected void btnSaveSettings_Click(object sender, EventArgs e) { List <DownloadType> types = new List <DownloadType>(); foreach (GridViewRow row in spgvSettings.Rows) { bool flag = ((CheckBox)row.Cells[3].FindControl("chbDelete")).Checked; if (flag == false) { string ext = ((TextBox)row.Cells[0].FindControl("txtExtension")).Text; int size = Convert.ToInt32(((TextBox)row.Cells[1].FindControl("txtSize")).Text); bool active = ((CheckBox)row.Cells[2].FindControl("chbActive")).Checked; DownloadType file = new DownloadType(ext, size, active); if (!types.Contains(file)) { types.Add(file); } } } if (types != null) { ExtState state = DownloadManager.Instance.Save(types); switch (state) { case ExtState.Failed: Helper.AddSPNotification(updSettings, hdnFailed.Value, false); break; case ExtState.Success: Helper.AddSPNotification(updSettings, hdnSuccess.Value, false); Refresh(); break; } } Refresh(); }