public int WriteFile(String filename, Byte[] buffer, ref uint writtenBytes, long offset, DokanFileInfo info) { RamFile fs = null; String userName = GetProcessOwner((int)info.ProcessId); try { if (!userFSList.ContainsKey(userName)) { fs = new OpenedFile(root_ + filename); UserFS ufs = new UserFS(); ufs.userName = userName; ufs.files = new System.Collections.Generic.LinkedList<RamFile>(); ufs.files.AddLast(fs); lock (userFSLock) { userFSList.Add(userName, ufs); } } else { fs = GetUserFSFile(userName, filename); if (fs == null) { lock (userFSLock) { fs = GetUserFSFile(userName, filename); if (fs == null) { fs = AddUserFSFile(userName, filename); } } } } fs.Seek(offset, SeekOrigin.Begin); fs.Write(buffer, 0, buffer.Length); writtenBytes = (uint)buffer.Length; return 0; } catch (Exception e) { logger.WriteLine("WriteFile error: " + e.Message + " " + e.StackTrace, Logger.MessagePriority.None); return -1; } }
public int CreateFile(String filename, FileAccess access, FileShare share, FileMode mode, FileOptions options, DokanFileInfo info) { String userName = GetProcessOwner((int)info.ProcessId); string path = GetPath(filename); info.Context = count_++; logger.WriteLine("CreateFile: " + path + " //// " + mode.ToString(), Logger.MessagePriority.Debug); if (!(Directory.Exists(path)) && (mode == FileMode.Create || mode == FileMode.CreateNew || mode == FileMode.OpenOrCreate)) { if (File.Exists(path)) { return 0; } RamFile fs = null; logger.WriteLine("Creating " + path, Logger.MessagePriority.Debug); if (!userFSList.ContainsKey(userName)) { //fs = new OpenedRamFile(root_ + filename); UserFS ufs = new UserFS(); ufs.userName = userName; ufs.files = new System.Collections.Generic.LinkedList<RamFile>(); //ufs.files.AddLast(fs); lock (userFSLock) { userFSList.Add(userName, ufs); } AddUserFSRamFile(userName, filename); } else { fs = GetUserFSFile(userName, filename); if (fs == null) { lock (userFSLock) { fs = GetUserFSFile(userName, filename); if (fs == null) { fs = AddUserFSRamFile(userName, filename); } } } } return 0; } else if (File.Exists(path)) { return 0; } else if (Directory.Exists(path)) { info.IsDirectory = true; return 0; } else { UserFS ufs; if (userFSList.TryGetValue(userName, out ufs)) { foreach (RamFile f in ufs.files) { if (f.Name.ToLower().Equals(path.ToLower())) { return 0; } } } return -DokanNet.ERROR_FILE_NOT_FOUND; } }
private async void Button_Clicked(object sender, EventArgs e) { Cator.IsVisible = true; Loginbtn.IsVisible = false; var xn = User.Text; var xpass = Pass.Text; UserDb = new UserDb(); var users = UserDb.GetMembers(); var uCount = users.Count(); int RowCount = 0; if (string.IsNullOrWhiteSpace(xn)) { User.Focus(); } else if (string.IsNullOrWhiteSpace(xpass)) { Pass.Focus(); } else { RowCount = Convert.ToInt32(uCount); if (RowCount > 0) { Cator.IsVisible = false; await DisplayAlert("Ya tenemos datos ! ", "YA EXISTE USUSARIO ", "Ok"); Application.Current.MainPage = new MainPage(); } else { Errormsn.IsVisible = false; var uri = "http://192.168.90.165:55751/Account/LoginAPP"; HttpClient client = new HttpClient(); var value_check = new Dictionary <string, string> { { "username", xn }, { "passw", xpass } }; try { var content = new FormUrlEncodedContent(value_check); var response = await client.PostAsync(uri, content); switch (response.StatusCode) { case (System.Net.HttpStatusCode.OK): try { HttpContent resp_content = response.Content; var json = await resp_content.ReadAsStringAsync(); var userResult = JsonConvert.DeserializeObject <List <UserFS> >(json); if (userResult[0].Mensaje == "Error al Iniciar Sesión") { User.Focus(); Pass.Focus(); Errormsn.IsVisible = true; Errormsn.Text = "Usuario o contraseña invalidos"; } else { var userFS = new UserFS(); userFS.Nombre = xn; userFS.Email = userResult[0].Email; userFS.Id = userResult[0].Id; userFS.Sucursal = userResult[0].Sucursal; UserDb.AddMember(userFS); Application.Current.MainPage = new MainPage(); } } catch (Exception ex) { await DisplayAlert("", "" + ex.ToString(), "ok"); var x = ex.ToString(); } break; } } catch (Exception ex) { await DisplayAlert("Error", "Intente en otro momento _ error: " + ex.ToString() + " _ ", "ok"); Cator.IsVisible = false; Pass.Focus(); Errormsn.IsVisible = true; Errormsn.Text = "Ha habido un error"; return; } Cator.IsVisible = false; Loginbtn.IsVisible = true; } } }