public bool setRecover(string url) { IRemoteOperations worker = (IRemoteOperations)Activator.GetObject(typeof(IRemoteOperations), url); worker.Recover(); return(wm.recover(url)); }
public AutoStartService(ISharedSettings sharedSettings, ILogger <AutoStartService> logger, ILiveApis liveApis, IRemoteOperations remoteOperations) { _remoteSettings = sharedSettings.RemoteSettings; _logger = logger; _liveApis = liveApis; _remoteOperations = remoteOperations; }
public bool setFreeze(string url) { IRemoteOperations worker = (IRemoteOperations)Activator.GetObject(typeof(IRemoteOperations), url); worker.Freeze(); return(wm.freeze(url)); }
public Object Get(AllStorageNodes dummy) { IRemoteOperations remoteOperation = RemotingManager.GetRemoteObject(); if (string.IsNullOrEmpty(base.Request.QueryString["node"]) || base.Request.QueryString["node"] == "root" || base.Request.QueryString["node"] == "NaN" || base.Request.QueryString["node"] == "0") { List <P2PBackup.Common.StorageGroup> baseGroups = RemotingManager.GetRemoteObject().GetStorageGroups(); var groups = new List <P2PBackup.Common.Node>(); foreach (StorageGroup g in baseGroups) { Console.WriteLine("Get(GetAllStorageNodes dummy) : adding 1 storagegroups as node to SG list"); groups.Add(new P2PBackup.Common.Node { Id = (uint)g.Id, Name = g.Name, Group = -1, // trick to distinguish groups from leafs Description = g.Description }); Console.WriteLine("Get(GetAllStorageNodes dummy) : ADDED 1 storagegroups as node to SG list"); } return(groups); } else { return(RemotingManager.GetRemoteObject().GetStorageNodes(int.Parse(base.Request.QueryString["node"]))); } }
private string ApproveNodes(string nodesList, string approve) { IRemoteOperations rOp = RemotingManager.GetRemoteObject(); string outMsg = String.Empty; bool doApprove = false; try{ doApprove = bool.Parse(approve); } catch (Exception boolE) { outMsg += "Could not parse parameter as bool type :" + boolE.Message; //Console.WriteLine("ApproveNodes : invalid status : "+boolE.Message); return(outMsg); } foreach (string nid in nodesList.Split(',')) { try{ if (nid != null && nid != String.Empty) { rOp.ApproveNode(int.Parse(nid), doApprove); } } catch (Exception e) { outMsg += "" + e.Message + "---" + e.StackTrace + ","; } } return(outMsg); }
public override bool TryAuthenticate(IServiceBase authService, string userLogin, string password) { Logger.Append(Severity.DEBUG, "User '" + userLogin + "' is trying to authenticate from " + authService.RequestContext.IpAddress); IRemoteOperations remoteOperation = RemotingManager.GetRemoteObject(); //User authUser = remoteOperation.BeginSession(login.Text, password.Text); remoteOperation.Login(userLogin, password); User p = remoteOperation.GetCurrentUser(); if (p == null) { return(false); } var s = (UserSession)authService.GetSession(); s.UserId = p.Id; //s.UserAuthId = p.Id.ToString(); s.UserName = p.Login; s.Culture = p.Culture; s.CreatedAt = DateTime.UtcNow; //s.DisplayName = p.FirstName+" "+p.MiddleName+" "+p.LastName; //s.Email = p.MailOffice; s.Roles = new List <string>(); s.Roles.Add("GlobalAdmin"); s.IsAuthenticated = true; return(true); }
protected void Page_Load(object sender, EventArgs args) { StreamReader reader = new StreamReader(Request.InputStream); string rawPostData = reader.ReadLine(); Console.WriteLine(rawPostData); // for debug only if (Request.QueryString["w"] == "AddBackupSet") { Response.Write(ParseAndAddBS(rawPostData)); } else if (Request.QueryString["w"] == "ConfigureNodes") { if (Request.QueryString["nodeId"] != null) { Response.Write(ParseAndProcessConf(int.Parse(Request.QueryString["nodeId"]), rawPostData)); } } else if (Request.QueryString["w"] == "ApproveNodes") { string approve = Request.QueryString["approve"]; Response.Write(ApproveNodes(rawPostData, approve)); } else if (Request.QueryString["w"] == "ChangeTasks") { string action = Request.QueryString["action"]; //Console.WriteLine ("action="+action); IRemoteOperations rOp = RemotingManager.GetRemoteObject(); Response.Write(rOp.ChangeTasks(rawPostData.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(n => long.Parse(n)).ToList <long>(), (TaskAction)Enum.Parse(typeof(TaskAction), action))); } }
public ListenerService(ISharedSettings sharedSettings, ILogger <ListenerService> logger, IMessageQueue messageQueue, IRemoteOperations remoteOperations, IMemoryCache memoryCache, IHostApplicationLifetime applicationLifetime) { _sharedSettings = sharedSettings; _remoteSettings = _sharedSettings.RemoteSettings; _messageQueue = messageQueue; _remoteOperations = remoteOperations; _logger = logger; _memoryCache = memoryCache; _applicationLifetime = applicationLifetime; }
internal static IRemoteOperations GetRemoteObject() { if (binding == null) { new RemotingManager(); } var address = new EndpointAddress("net.tcp://" + serverIP + ":" + serverPort); cf = new ChannelFactory <IRemoteOperations> (binding, address); cf.Faulted += OnChannelFault; remote = cf.CreateChannel(); return(remote); }
internal static IRemoteOperations GetRemoteObject() { string hubIP = ConfigurationManager.AppSettings["Hub.IP"]; string hubPort = ConfigurationManager.AppSettings["Hub.Port"]; if (binding == null) { new RemotingManager(); } var address = new EndpointAddress("net.tcp://" + hubIP + ":" + hubPort); cf = new ChannelFactory <IRemoteOperations> (binding, address); cf.Faulted += OnChannelFault; remote = cf.CreateChannel(); return(remote); }
private string ParseAndProcessConf(int nodeId, string rawPostData) { try{ /*string logLevel = Request.Params["Logger.Level"]; * string logFile = Request.Params["Logger.LogFile"]; * bool syslog = bool.Parse(Request.Params["Logger.Syslog"]); * string backupTempFolder = Request.Params["Backup.TempFolder"]; * string backupIndexFolder = Request.Params["Storage.IndexFolder"]; * * bool isStorageNode = bool.Parse(Request.Params["istorageNode"]); * int storageGroup = int.Parse(Request.Params["Storage.StorageGroup"]); * IPAddress listenIP = IPAddress.Parse(Request.Params["Storage.ListenIP"]); * int listenPort = int.Parse(Request.Params["Storage.ListenPort"]); * string storageDir = Request.Params["Storage.Directory"]; * */ Hashtable nodeConfig = new Hashtable(); foreach (string key in Request.Params) { nodeConfig.Add(key, Request.Params[key]); Console.WriteLine(key + "=" + Request.Params[key]); } IRemoteOperations rOp = RemotingManager.GetRemoteObject(); //rOp.SetNodeConfig(nodeId, null, logLevel, syslog, logFile, listenIP.ToString(), listenPort, backupTempFolder, backupIndexFolder, shareSize); // We don't do params validation at this stage. On hub side, the method savenodeconfig will ignore every key that doesn't exist in nodes config template (db id=0) rOp.SetNodeConfig(nodeId, nodeConfig); long?storageSize = long.Parse(Request.Params["shareSize"]); long?quota = long.Parse(Request.Params["quota"]); int? storageGroup = int.Parse(Request.Params["storageGroup"]); int? nodeGroup = int.Parse(Request.Params["nodeGroup"]); rOp.UpdateNodeGeneralConf(nodeId, storageSize, quota, storageGroup, nodeGroup); return("OK"); } catch (Exception e) { Response.StatusCode = 500; return(e.Message + ":" + e.TargetSite); } return("ok"); }
public LogWS() { remoteOperation = remoteOperation = RemotingManager.GetRemoteObject(); }
public HouseController(IRemoteOperations remoteOperations, IBarkOperations barkOperations) { _remoteOperations = remoteOperations; _barkOperations = barkOperations; }
private string ParseAndAddBS(string rawData) { ArrayList clientIds; ArrayList paths; if (rawData.Substring(0, 2) == "[]") { return("You must select at least 1 node which will process this backup set"); } int endOfClients = rawData.IndexOf("]],"); clientIds = GetClientIds(rawData.Substring(2, endOfClients - 2)); if (clientIds.Count == 0) { return("You must select at least one client to backup"); } if (rawData.Substring(endOfClients, 3) == "[]") { return("You must select at least one path to backup"); } int endOfPaths = rawData.IndexOf('{'); paths = GetPaths(rawData.Substring(endOfClients, endOfPaths - endOfClients)); int endOfFilesSelection = rawData.IndexOf('}'); string jGroupBk = rawData.Substring(endOfPaths + 1, endOfFilesSelection - endOfPaths - 1); string rootPath = GetValueFromJson("basePath", jGroupBk); if (paths.Count == 0 || rootPath == null) { return("You must select at least one path to backup"); } string includePolicy = GetValueFromJson("includePolicy", jGroupBk); string excludePolicy = GetValueFromJson("excludePolicy", jGroupBk); bool compress = (GetValueFromJson("compress", jGroupBk) == "on")?true:false; bool encrypt = (GetValueFromJson("encrypt", jGroupBk) == "on")?true:false; int endOfOps = rawData.IndexOf('}', endOfFilesSelection - endOfPaths); string jGroupOps = rawData.Substring(endOfFilesSelection - endOfPaths, endOfOps); string preops = GetValueFromJson("preops", jGroupOps); string postops = GetValueFromJson("postops", jGroupOps); Console.WriteLine("rootPath=" + rootPath + ",includepolicy=" + includePolicy + "excludepolicy=" + excludePolicy + ",compress=" + compress); // getting per-day backup scheduling string rawSchedulingInfo = rawData.Substring(endOfOps); List <ScheduleTime> bTimes = new List <ScheduleTime>(); List <BasePath> bPaths = new List <BasePath>(); for (int i = 0; i < 7; i++) { string day = ((DayOfWeek)i).ToString(); if (GetValueFromJson(day + "Do", rawSchedulingInfo) == "on") { if (GetValueFromJson(day + "Hour", rawSchedulingInfo).Split(':').Length == 2 && GetValueFromJson(day + "Type", rawSchedulingInfo) != null) { BackupLevel bType = (BackupLevel)Enum.Parse(typeof(BackupLevel), GetValueFromJson(day + "Type", rawSchedulingInfo)); ScheduleTime bt = new ScheduleTime(bType, (DayOfWeek)i, GetValueFromJson(day + "Hour", rawSchedulingInfo), string.Empty); bTimes.Add(bt); } } } if (rootPath != null) { BasePath bp = new BasePath(); bp.Path = rootPath; bp.IncludePolicy.Add(includePolicy); bp.ExcludePolicy.Add(excludePolicy); bPaths.Add(bp); } foreach (string thePath in paths) { BasePath bp = new BasePath(); bp.Path = thePath; bp.IncludePolicy.Add(includePolicy); bp.ExcludePolicy.Add(excludePolicy); bPaths.Add(bp); } IRemoteOperations rOp = RemotingManager.GetRemoteObject(); string createResult = null; foreach (int client in clientIds) { BackupSet newBs = new BackupSet(); newBs.NodeId = client; newBs.ScheduleTimes = bTimes; newBs.BasePaths = bPaths; //newBs.Compress = compress; //newBs.Encrypt = encrypt; newBs.Preop = preops; newBs.Postop = postops; createResult += "," + rOp.CreateBackupSet(newBs); } if (createResult == null) { return("New BackupSet successfully created on Hub."); } else { return(createResult); } }
private void Page_Load(object sender, EventArgs args) { //remoteOperation = Utilities.GetRemoteObject(); remoteOperation = RemotingManager.GetRemoteObject(); // (IRemoteOperations)Session["remote"]; if (Request.QueryString["w"] == "Clients") { //ArrayList onLineUsers = (ArrayList)remoteOperation.GetOnlineClients(); //ArrayList users = (ArrayList)remoteOperation.GetClients(); bool showOnlineOnly = false; if (Request.QueryString["online"] != null && Request.QueryString["online"].ToLower() == "true") { showOnlineOnly = true; } Response.Write(BuildClients(showOnlineOnly)); } /*else if(Request.QueryString["w"] == "Clients2"){ * Response.Write(BuildClients2(true)); * }*/ else if (Request.QueryString["w"] == "StorageNodes") { List <P2PBackup.Common.Node> users = remoteOperation.GetStorageNodes(); Dictionary <int, NodeStatus> onLineUsers = remoteOperation.GetOnlineClients(); bool groupsOnly = false; if (Request["groupsOnly"] != null && Request["groupsOnly"].ToLower() == "true") { groupsOnly = true; } Response.Write(BuildStorages(users, onLineUsers, groupsOnly)); } else if (Request.QueryString["w"] == "BackupPlan") { List <P2PBackup.Common.Node> users = remoteOperation.GetNodes(); Dictionary <int, NodeStatus> onLineUsers = remoteOperation.GetOnlineClients(); List <P2PBackup.Common.BackupSet> bPlans = remoteOperation.GetBackupPlan((Request["interval"] == null)?12:int.Parse(Request["interval"])); Response.Write(BuildBP(bPlans, users, onLineUsers)); } else if (Request.QueryString["w"] == "Backupsets") { Console.WriteLine("requested backupsets for node " + Request["nodeId"]); if (Request["nodeId"] != null) { Response.Write(BuildBackupSet(int.Parse(Request["nodeId"]))); } } else if (Request.QueryString["w"] == "Tasks") { Response.Write(BuildTasks()); } else if (Request.QueryString["w"] == "TaskLogEntries") { if (Request["trackingId"] != null) { Response.Write(BuildTaskLog(int.Parse(Request["trackingId"]))); } } else if (Request.QueryString["w"] == "Browse") { int nodeId = int.Parse(Request["curNode"]); string path = Request.QueryString["path"]; if (path == null || path == String.Empty) { path = HttpUtility.UrlDecode(Request.QueryString["node"]); } Response.ClearHeaders(); Response.ContentEncoding = Encoding.UTF8; Response.ContentType = "text/xml;charset=utf-8"; Response.Write(remoteOperation.Browse(nodeId, path)); } else if (Request.QueryString["w"] == "SpecialObjects") { int nodeId = int.Parse(Request["nodeId"]); Response.ClearHeaders(); Response.ContentEncoding = Encoding.UTF8; Response.ContentType = "text/xml;charset=utf-8"; Response.Write(remoteOperation.GetSpecialObjects(nodeId)); } else if (Request.QueryString["w"] == "Drives") { int nodeId = int.Parse(Request["nodeId"]); Response.ClearHeaders(); Response.ContentEncoding = Encoding.UTF8; Response.ContentType = "text/xml;charset=utf-8"; Response.Write(remoteOperation.GetDrives(nodeId)); } else if (Request.QueryString["w"] == "VM") { int nodeId = int.Parse(Request["nodeId"]); Response.Write(remoteOperation.GetVMs(nodeId)); } else if (Request.QueryString["w"] == "HubLogs") { LogEntry[] log = remoteOperation.GetLogBuffer(); int start = 0; int limit = 20; if (Request["start"] != null) { start = int.Parse(Request["start"]); } if (Request["limit"] != null) { limit = int.Parse(Request["limit"]); } Response.Write(BuildLog(log, start, limit)); } else if (Request.QueryString["w"] == "NodeConf") { int nodeId = int.Parse(Request["nodeId"]); Response.Write(BuildNodeConf(nodeId)); } else if (Request.QueryString["w"] == "BackupHistory") { if (Request["bsId"] != null && Request["bsId"] != String.Empty && Request["startDate"] != null && Request["endDate"] != null) { int bsId = int.Parse(Request["bsId"]); int limit = 50; int offset = 0; DateTime start = DateTime.ParseExact(Request["startDate"], "yyyy-mm-dd", CultureInfo.InvariantCulture); DateTime end = DateTime.ParseExact(Request["endDate"], "yyyy-mm-dd", CultureInfo.InvariantCulture); Response.Write(BuildBackupHistory(bsId, start, end)); } } else if (Request.QueryString["w"] == "Users") { Response.Write(BuildUsers()); } else if (Request.QueryString["w"] == "NodeGroups") { Response.Write(BuildNodeGroups()); } else if (Request.QueryString["w"] == "Cultures") { Response.Write(BuildCultures()); } }