//public virtual ContainerProperty ContainerProperty { get; set; } //public virtual ICollection<PropIns> PropInstruments { get; set; } //public virtual ICollection<TempBinBatch> TempBinBatches { get; set; } #region Properties //public string prc_ProcescellId //{ // get { return _prc_ProcCellId; } // set { SetProperty(ref _prc_ProcCellId, value); } //} #endregion #region Override public override void DeleteTreeViewObject() { BinService service = new BinService(); service.DeleteBin(this); service.RemoveRelationShips(this); }
public ActionResult NewDoc(int id, DocumentCreateForm collection) { try { if (ModelState.IsValid) { DocumentService d = new DocumentService(); BinService b = new BinService(); byte[] buffer = new byte[collection.FileBinary.ContentLength]; collection.FileBinary.InputStream.Read(buffer, 0, collection.FileBinary.ContentLength); Bin fileBin = new Bin() { Binaries = buffer, UploadName = collection.FileBinary.FileName }; fileBin = b.Insert(fileBin); Document doc = new Document(collection.Name, collection.Description, collection.ModifiedDate, collection.Size, collection.Extention, UserSession.CurrentUser.Id, fileBin.Id, null); doc = d.Insert(doc); if (!d.InsertToTask(doc, id)) { /*-----------If don't have receiver, don't saved in DB------------*/ //b.Delete(fileBin.Id); //d.Delete(doc.Id); } } return(RedirectToAction("Details", new { id = id })); } catch { return(RedirectToAction("Details", new { id = id })); } }
private void CreateBin() { BinService service = new BinService(); //check if parameters are correct bool ParametersCorrect = service.CheckParameters(NumberOfBins, StartingNumber); if (!ParametersCorrect) { _view.ShowMessage("one or more parameters are incorrect. Creation has been cancelled."); return; } //exclude the same bins List <Bin> binList = service.GetAddAbleBinList(Prefix, NumberOfBins, StartingNumber, BinType); //create bin foreach (var B in binList) { service.CreateNewBin(B); } _view.ShowMessage("New bins have been created"); //reset the screen (or make it close later) Prefix = ""; NumberOfBins = ""; StartingNumber = ""; BinType = _Bintypes.First(); }
public CreateBinViewModel(ICreateBinView view) : base(view) { this._view = view; InitializeCommand(); BinService service = new BinService(); _Bintypes = new ObservableCollection <string>(service.GetAllBinTypes()); _BinType = _Bintypes.First(); }
//***************************************** DOWNLOAD ***************************************************************///// // post: Document/Download /* public ActionResult Download(int id) * { * * DocumentService repoDoc = new DocumentService(); * Document doc= repoDoc.Get(id); * if (doc.FileBinId != 0) * { * string path = Path.GetDirectoryName(Environment.GetFolderPath(Environment.SpecialFolder.Personal)); * path = Path.Combine(path, "Downloads"); * BinaryWriter binW = new BinaryWriter(new FileStream(Path.Combine(path,doc.Name + "." + doc.Extention), FileMode.Create)); * BinService repoBin = new BinService(); * Bin file = repoBin.Get(doc.FileBinId); * //binW.Write(file.Binaries); * binW.Close(); * return File(file.Binaries,); * } * * * return RedirectToAction("index"); * * }*/ public FileResult Download(int id) { DocumentService repoDoc = new DocumentService(); Document doc = repoDoc.Get(id); string path = Path.GetDirectoryName(Environment.GetFolderPath(Environment.SpecialFolder.Personal)); path = Path.Combine(path, "Downloads"); BinService repoBin = new BinService(); Bin file = repoBin.Get(doc.FileBinId); return(File(file.Binaries, System.Net.Mime.MediaTypeNames.Application.Octet, doc.Name + "." + doc.Extention)); }
public static void Main(string[] args) { var random = new Random(); for (int i = 0; i < 10; i++) { var angle = random.Next(0, 90); var level = random.Next(0, 100); var binService = new BinService(angle, level); binService.Validate(); } Console.ReadKey(); }
public ActionResult Create(DocumentCreateForm collection) { try { // TODO: Add insert logic here if (ModelState.IsValid) { DocumentService d = new DocumentService(); BinService b = new BinService(); byte[] buffer = new byte[collection.FileBinary.ContentLength]; collection.FileBinary.InputStream.Read(buffer, 0, collection.FileBinary.ContentLength); Bin fileBin = new Bin() { Binaries = buffer, UploadName = collection.FileBinary.FileName }; fileBin = b.Insert(fileBin); Document doc = new Document(collection.Name, collection.Description, collection.ModifiedDate, collection.Size, collection.Extention, UserSession.CurrentUser.Id, fileBin.Id, null); doc = d.Insert(doc); switch (collection.Kind) { case "Task": //procedure task d.InsertToTask(doc, collection.ReceiverId); break; case "Project": //procedure project d.InsertToProject(doc, collection.ReceiverId); break; case "Team": //procedure team d.InsertToTeam(doc, collection.ReceiverId); break; case "Department": //procedure department d.InsertToDepartment(doc, collection.ReceiverId); break; case "Event": //procedure Event d.InsertToEvent(doc, collection.ReceiverId); break; default: /*-----------If don't have receiver, don't saved in DB------------*/ //b.Delete(fileBin.Id); //d.Delete(doc.Id); return(View(collection)); } return(RedirectToAction("Details", new { id = doc.Id })); } return(View(collection)); } catch { return(View(collection)); } }