Beispiel #1
0
        public ActionResult Filter(string filter)
        {
            if (!string.IsNullOrEmpty(filter) && filter.EndsWith("or "))
            {
                filter = " and " + ReplaceLastOccurrence(filter, "or", "");
            }

            if (!string.IsNullOrEmpty(filter) && filter.EndsWith("and "))
            {
                filter = " and " + ReplaceLastOccurrence(filter, "and", "");
            }
            SProject sproject     = new SProject();
            int      pagenumber   = 1;                                                                                            //int.Parse( Request.QueryString.Get("pagenumber"));
            int      itemsperpage = 50;                                                                                           // int.Parse(Request.QueryString.Get("itemsperpage"));

            string    conditions = " where iduser='******' " + filter + "; "; //Request.QueryString.Get("conditions");
            string    order      = Request.QueryString.Get("order");
            SCategory scat       = new SCategory();

            List <Persistence.Entities.Project> lista = sproject.GetListPaged(pagenumber, itemsperpage, conditions, order);
            List <Models.Project> listprojects        = lista.Select(e => new Models.Project().InjectFrom(e)).Cast <Models.Project>().ToList();

            if (((RegisterBindingModel)SessionBag.Current.User).Freelance)
            {
                return(PartialView("PartialFilterOffer", listprojects));
            }
            else
            {
                return(PartialView("PartialFilterOffer", listprojects));
            }
        }
        private TreeNode FindNodeByValue(string fname, TreeNodeCollection nodes = null)
        {
            if (string.IsNullOrEmpty(fname))
            {
                return(null);
            }

            if (null == nodes)
            {
                nodes = Form.ProjectsTree.Nodes;
            }
            foreach (TreeNode node in nodes)
            {
                SProject project = node.Tag as SProject;
                if (null != project && 0 == string.Compare(fname, project.name, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(node);
                }

                if (node.Nodes.Count > 0)
                {
                    TreeNode res = FindNodeByValue(fname, node.Nodes);
                    if (null != res)
                    {
                        return(res);
                    }
                }
            }

            return(null);
        }
Beispiel #3
0
        public List <OfferUser> GetSetProjetToUser(int Id)
        {
            //Guid userInfoId = new Guid(IdUser.ToString());
            SUser    suser     = new SUser();
            SProject sproject  = new SProject();
            SOffer   soffer    = new SOffer();
            var      offeruser = soffer.GetOfferUserById(Id);

            var user   = suser.GetUserById(new Guid(offeruser.IdUser));
            var offere = soffer.GetOffer(offeruser.IdOffer);

            Persistence.Entities.Project     project     = new Persistence.Entities.Project();
            Persistence.Entities.ProjectUser projectuser = new Persistence.Entities.ProjectUser();
            projectuser.IdUser = offeruser.IdUser;

            project.IdCategory = offere.Category.Id;
            project.IdOffer    = offere.Id;

            //project.Inicio = soffer.GetPhaseInitial(idoffer).InitPhase;
            //project.Fin= soffer.GetPhaseFinal(idoffer).FinishPhase;
            //project.Phases = new List<OfferPhase>();
            //project.Phases = soffer.GetOfferPhases(idoffer).Select(e=>new OfferPhase().InjectFrom(e)).Cast<OfferPhase>().ToList();
            project.Postulantes = soffer.GetOfferUser(offeruser.IdOffer).OfferUsers.Count();
            project.Status      = Persistence.Entities.StatusProject.EnCurso;

            sproject.Insert(project, projectuser);

            return(GetOfferUsers(offeruser.IdOffer));
        }
        internal bool CheckIfProjectnameIsUnique(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(false);
            }

            SProject par = Form.SelectedProject;

            if (null == par)
            {
                return(false);
            }

            List <SProject> projects = GetChildProjectsOf(par);

            if (null == projects || projects.Count <= 0)
            {
                return(true);
            }

            foreach (SProject proj in projects)
            {
                if (0 == string.Compare(proj.name, name, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(false);
                }
            }

            return(true);
        }
        internal string AddProject(SProject parent, string projectName, string projectDesc, string ifcFormat)
        {
            if (null == parent || string.IsNullOrEmpty(projectName))
            {
                return(null);
            }

            if (null == projectDesc)
            {
                projectDesc = string.Empty;
            }
            if (string.IsNullOrEmpty(ifcFormat))
            {
                ifcFormat = "ifc2x3tc1";
            }

            SProject res;

            if (parent.oid < 0)
            {
                res = Form.Cmd.ServerInterface.AddRootProject(Form.Data, projectName, projectDesc, ifcFormat);
            }
            else
            {
                res = Form.Cmd.ServerInterface.AddProjectTo(Form.Data, projectName, projectDesc, parent, ifcFormat);
            }
            List <SProject> projects = Form.Cmd.ServerInterface.GetAllProjects(Form.Data);

            FillTree(projects);

            //Form.ProjectsTree.FocusedNode = Form.ProjectsTree.FindNodeByID(res.oid);
            return(Form.SelectedProjectName);
        }
Beispiel #6
0
        public void GetCalificationAverageUserTest()
        {
            SProject spro  = new SProject();
            var      calif = spro.GetCalificationAverageUser("2bb615d9-0183-4f91-acf6-c06738a2ad53");

            Assert.Fail();
        }
        private string GetProjectHierarchyName(SProject project, List <SProject> projects)
        {
            if (null == project)
            {
                return(string.Empty);
            }

            string res = project.name;
            int    id  = project.parentId;

            while (id > 0)
            {
                int             id1   = id;
                List <SProject> items = projects.Where(p => p.oid == id1).ToList();
                if (items.Count <= 0)
                {
                    break;
                }

                SProject par = items[0];
                if (null == par)
                {
                    break;
                }

                res = $"{par.name}.{res}";
                id  = par.parentId;
            }

            return(res);
        }
Beispiel #8
0
        // GET: Project/Edit/5
        public ActionResult Edit(int id)
        {
            SProject SProject = new SProject();

            Persistence.Entities.Project Project = SProject.Get(id);
            return(View(Project));
        }
Beispiel #9
0
        private string GetSelectionHierarchy(TreeNode sel)
        {
            if (null == sel)
            {
                return(string.Empty);
            }

            List <string> selection = new List <string>();
            SProject      data      = sel.Tag as SProject;

            if (null != data)
            {
                selection.Add(data.name);
            }

            sel = sel.Parent;
            while (null != sel)
            {
                data = sel.Tag as SProject;
                if (null != data && data.oid >= 0)
                {
                    selection.Insert(0, data.name);
                }
                sel = sel.Parent;
            }

            if (selection.Count <= 0)
            {
                return(string.Empty);
            }

            return(string.Join(".", selection));
        }
Beispiel #10
0
        private void OpenProjectEvent()
        {
            SProject project = Cmd.ServerInterface.GetProject(Data, Data.ProjectName);

            if (null == project)
            {
                return;
            }
            int    poid = project.oid;
            string tag  = $"apps/bimviews/?page=Project&poid={poid}";
            string url  = $"{Data.Url}:{Data.Port}/{tag}";

            Process.Start(url);
        }
Beispiel #11
0
        private void TreeView_MouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            TreeView tree = sender as TreeView;

            if (null == tree)
            {
                return;
            }
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            if (ProjectsTree == tree)
            {
                TreeNode node = tree.GetNodeAt(e.X, e.Y);
                if (null == node)
                {
                    return;
                }

                SProject project = node.Tag as SProject;
                if (null == project)
                {
                    return;
                }

                int poid = project.oid;
                contextMenuStrip1.Items.Clear();

                ToolStripMenuItem item = new ToolStripMenuItem("Go to Bimviews");
                item.Click += MenuItem_Click;
                item.Tag    = string.Format($"apps/bimviews/?page=Project&poid={poid}");
                contextMenuStrip1.Items.Add(item);

                foreach (string name in BimServerApps)
                {
                    ToolStripMenuItem mi = new ToolStripMenuItem(name);
                    mi.Click += MenuItem_Click;
                    mi.Tag    = string.Format($"apps/{name}/?page=Project&poid={poid}");
                    contextMenuStrip1.Items.Add(item);
                }
                contextMenuStrip1.Show(tree, e.Location);

                return;
            }

            throw new IcnException($"TreeView '{tree.Name}' activated that has no code", 20, "BimServerExchangeForm");
        }
Beispiel #12
0
 public ActionResult Edit(int id, FormCollection collection, Models.Project Project)
 {
     try
     {
         SProject SProject = new SProject();
         Persistence.Entities.Project project = new Persistence.Entities.Project();
         project.InjectFrom(Project);
         Persistence.Entities.Project updaoofer = SProject.Update(project);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Beispiel #13
0
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here
                SProject SProject = new SProject();

                SProject.Delete(id);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #14
0
        public ActionResult Create(FormCollection collection, Models.Project Project)
        {
            try
            {
                // TODO: Add insert logic here
                SProject SProject = new SProject();

                Persistence.Entities.Project projectp = new Persistence.Entities.Project();
                projectp.InjectFrom(Project);
                SProject.Insert(projectp);
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        private List <SProject> GetChildProjectsOf(SProject par)
        {
            if (null == par)
            {
                return(null);
            }

            List <SProject> res = new List <SProject>();
            // get the full list, including the deleted ones (Form.Projects only contains the active projects so it can't be used here)
            List <SProject> projects = Form.Cmd.ServerInterface.GetAllProjects(Form.Data, true);

            foreach (SProject proj in projects)
            {
                if (proj.parentId != par.oid)
                {
                    continue;
                }

                res.Add(proj);
            }

            return(res);
        }
 void saveProject(SProject[] projects)
 {
     XmlSerializer serializer = new XmlSerializer (projets.GetType ());
     FileStream stream = new FileStream (this.filename, FileMode.Create);
     serializer.Serialize (stream, projects);
 }
Beispiel #17
0
        private void TreeView_Select(object sender, TreeViewEventArgs e)
        {
            TreeView tree = sender as TreeView;

            if (null == tree)
            {
                return;
            }

            if (ProjectsTree == tree)
            {
                // if the treelist selection changed it may be that the name becomes (in)eligible for adding
                string name = ProjectNameEdt.Text;
                ProjectAddBtn.Enabled = !string.IsNullOrEmpty(name) && Cmd.BimServerExchange.CheckIfProjectnameIsUnique(name);

                name = SelectedProjectName;
                bool enable = !string.IsNullOrEmpty(name) && 0 != string.Compare(name, "BIMserver Projects", StringComparison.InvariantCultureIgnoreCase);
                UploadBtn.Enabled = enable;
                if (enable)
                {
                    SProject         project = Cmd.ServerInterface.GetProject(Data, name);
                    List <SRevision> list    = null;

                    try
                    {
                        list = Cmd.ServerInterface.GetAllFilesOfProject(Data, project);
                    }
                    catch (IcnException iex)
                    {
                        Cmd.BimServerExchange.ShowResultInForm(iex.ToString());
                    }
                    catch (Exception ex)
                    {
                        Cmd.BimServerExchange.ShowResultInForm($"Generic Error in selecting a project ({ex.Message})");
                    }
                    finally
                    {
                        if (null == list)
                        {
                            list = new List <SRevision>();
                        }
                    }

                    Cmd.BimServerExchange.FillRevisionTree(list);
                    if (RevisionsTree.Items.Count > 0)
                    {
                        RevisionsTree.Items[0].Selected = true;
                        RevisionsTree.Items[0].Checked  = true;
                    }
                    DownloadBtn.Enabled = true;
                }
                else
                {
                    Cmd.BimServerExchange.FillRevisionTree(null);
                    DownloadBtn.Enabled = false;
                }

                RevisionsGrp.Text = $@"Revisions in project {SelectedProjectLeaf}";
                Cmd.BimServerExchange.HighlightSelectedProject(tree.SelectedNode);

                return;
            }

            throw new IcnException($"TreeView '{tree.Name}' activated that has no code", 20, "BimServerExchangeForm");
        }
        internal void DoUpload()
        {
            // see if there is a project up and running
            try
            {
                string   projectName = Form.SelectedProjectName;
                SProject proj        = Form.Cmd.ServerInterface.GetProject(Form.Data, projectName);
                if (null == proj)
                {
                    throw new IcnException("No project selected", 10, "Upload");
                }

                string schema = proj.schema;
                if (string.IsNullOrEmpty(schema))
                {
                    schema = "Ifc2x3tc1";
                }
                SDeserializer deserialiser = Form.Cmd.ServerInterface.GetDeserialiser(Form.Data, proj.oid, schema);
                if (null == deserialiser)
                {
                    throw new IcnException($"Serializer '{schema}' not found in project '{projectName}'", 10, "Upload");
                }

                string path = Form.IfcEdt.Text;
                if (string.IsNullOrEmpty(path) || !File.Exists(path))
                {
                    path = Form.Cmd.BimServerExchange.AskForIfcUploadPath();
                }
                if (string.IsNullOrEmpty(path) || !File.Exists(path))
                {
                    throw new IcnException($"IFC file '{path ?? string.Empty}' not found", 10, "Upload");
                }
                // this checks if the file and project name are the same and asks the user to confirm if they are not
                if (!Form.Cmd.BimServerExchange.ValidateAndAcceptFilename(projectName, path))
                {
                    return;
                }

                // we may have linked files. And we likely will need additional controls (e.g. for the Project to upload to) and additional data to go with this
                string tag = Form.Cmd.BimServerExchange.GetFileTag(path);
                string result;
                Form.Cmd.BimServerExchange.ActivateButtons(false);
                int fileId = Form.Cmd.ServerInterface.CheckinFile(Form.Data, path, tag ?? string.Empty, proj.oid, deserialiser.oid, true, out result);
                if (fileId > 0)
                {
                    Form.CancelUploadBtn.Enabled = false;
                    fileId = Form.Cmd.ServerInterface.MonitorProcessingState(Form.Data, fileId, out result);
                }

                Form.Cmd.ShowResult($"Copy IFC file '{path}' to the BIMserver\nResult: '{result}'");

                List <SRevision> revisions = Form.Cmd.ServerInterface.GetAllFilesOfProject(Form.Data, proj);
                Form.Cmd.BimServerExchange.FillRevisionTree(revisions);
            }
            catch (IcnException iex)
            {
                iex.Display(@"Exception in Upload IFC file");
                Form.Cmd.ShowResult(iex.ToString());
            }
            catch (Exception ex)
            {
                Form.Cmd.ShowResult($"Select/add project failed ({ex.Message})");
                Form.Cmd.ShowResult(ex.Message);
            }
            finally
            {
                Form.Cmd.BimServerExchange.ActivateButtons(true);
            }
        }
        internal void QuickCheckinFile(string path, string comment)
        {
            if (string.IsNullOrEmpty(path) || !File.Exists(path))
            {
                throw new IcnException("No IFC file selected to export", 10, "QuickExport");
            }

            if (string.IsNullOrEmpty(comment))
            {
                comment = Path.GetFileName(path);
            }

            // get the projectId (from the project stored in Properties.Settings.Default.BimServerProject!)
            SProject project = Form.Cmd.ServerInterface.GetProject(Form.Data, Form.Data.ProjectName);

            if (null == project)
            {
                throw new IcnException($"Project '{Form.Data.ProjectName}' is not found on the BIMserver", 10, "QuickExport");
            }

            // get the deserializerId (from the setting of the project)
            string fileIfcFormat    = GetIFCFormatOfFile(path);   // this may contain the " (streaming)" suffix as it is meant to look up the deserializer
            string projectIfcFormat = project.schema;             // this is the actual IFC schema used in this project
            string fname            = Path.GetFileNameWithoutExtension(path);

            if (string.IsNullOrEmpty(fname))
            {
                fname = path;
            }
            if (!IfcFormatsMatch(fileIfcFormat, projectIfcFormat))
            {
                throw new IcnException($"Could not copy '{fname}' to the BIMserver. The IFC format '{fileIfcFormat}' differs from the project format '{projectIfcFormat}'", 10, "QuickExport");
            }

            SDeserializer deserialiser = Form.Cmd.ServerInterface.GetDeserialiser(Form.Data, project.oid, projectIfcFormat);

            if (null == deserialiser)
            {
                throw new IcnException($"Serializer '{projectIfcFormat}' is unknown in project '{Form.Data.ProjectName}'", 10, "QuickExport");
            }

            // do the actual export
            string result;
            int    topicId = Form.Cmd.ServerInterface.CheckinFile(Form.Data, path, comment, project.oid, deserialiser.oid, true, out result);

            if (topicId < 0)
            {
                // result is either cancelled or failed
                if (result.IndexOf("failed", StringComparison.InvariantCultureIgnoreCase) > 0)
                {
                    throw new IcnException($"Project '{fname}' is not copied to the BIMserver", 10, "QuickExport");
                }

                ShowResultInForm(result);
                return;
            }

            // What we really want to do here is start a new modeless form and have that report progress while we close this form
            // when the modeless form completes it can close and show this form again. This will probably mess up the commanders that
            // are running. And we also need to create keyboard shortcuts for the exporter as we will have to trigger the command (not just the form)
            // The better option is to run the exporter in a modeless dialog, then we can keep it up and running (but will need to guard many of its
            // commander methods against it being destroyed) and use it for output just as we do now

            // we can't cancel the processing by the BIMserver so disable that option
            ActivateCancelButton(false);

            // then run the actual monitoring process. This will make the form (and revit) block for potentially a very long time
            topicId = Form.Cmd.ServerInterface.MonitorProcessingState(Form.Data, topicId, out result);

            if (Form.Cancelling)
            {
                return;
            }

            if (0 != string.Compare(result, "OK", StringComparison.InvariantCultureIgnoreCase) &&
                0 != string.Compare(result, "Project is uploaded to the BIMserver", StringComparison.InvariantCultureIgnoreCase))
            {
                throw new IcnException($"Project '{fname}' is not copied to the BIMserver ({result})", 10, "QuickExport");
            }

            // normally we have the (final) result here stating that the upload was successful
            ShowResultInForm(result);
        }
Beispiel #20
0
        // GET: Project

        public ActionResult Index(string id)
        {
            int statusProject = 0;

            if (Request.QueryString["statusProject"] != null)
            {
                statusProject = int.Parse(Request.QueryString["statusProject"]);
            }


            ViewBag.Status = statusProject;

            SOffer soffer       = new SOffer();
            int    pagenumber   = 1;  //int.Parse( Request.QueryString.Get("pagenumber"));
            int    itemsperpage = 50; // int.Parse(Request.QueryString.Get("itemsperpage"));
            string conditions   = "";

            ZonaFl.Persistence.Entities.AspNetUsers useru = null;
            ZonaFl.Business.SubSystems.SUser        usern = new Business.SubSystems.SUser();
            useru = usern.GetUserById(new Guid(id));
            if (SessionBag.Current.User == null)
            {
                SessionBag.Current.User = useru;
            }
            //if (statusProject == 2 && !useru.Freelance)
            //    statusProject = 1;

            //    Publicada = 0,
            //EnCurso = 1,
            //Finalizada = 2,
            //Eliminada = 3
            if (statusProject == 0)
            {
                if (!useru.Freelance)
                {
                    //conditions = " where O.Id NOT IN(SELECT Project.idoffer  from project) and O.iduser='******' and (OP.StatusPhase=" + statusProject + " "; //Request.QueryString.Get("conditions");
                    conditions = " where O.Id NOT IN(SELECT Project.idoffer  from project) and (O.iduser='******' and O.Status=0"; //and (OP.StatusPhase=" + statusProject + " "; //Request.QueryString.Get("conditions");
                }
                else
                {
                    conditions = " where O.Id NOT IN(SELECT Project.idoffer  from project) and (OU.iduser='******' and O.Status=0";// and (OP.StatusPhase=" + statusProject + " "; //Request.QueryString.Get("conditions");
                }
            }
            else if (statusProject >= 1)
            {
                if (!useru.Freelance)
                {
                    conditions = " where O.IdUser = '******' and (project.Status = " + statusProject + " OR O.Status=" + statusProject;
                    //conditions = " where O.Id IN(SELECT Project.idoffer  from project) and (O.iduser='******' and project.Status="+ statusProject;
                }
                else
                {
                    //conditions = " where O.IdUser = '******' and project.Status = " + statusProject;
                    conditions = " where O.Id IN(SELECT Project.idoffer  from project where  project.Status=" + statusProject + ") and (OU.iduser='******'"; //Request.QueryString.Get("conditions");
                }
            }
            ///user session bag
            ZonaFl.Business.SubSystems.SProject userp = new Business.SubSystems.SProject();
            var projects = userp.GetProjectsEndedByUser(id);
            List <Models.Project> projetsm = new List <Models.Project>();

            projetsm = projects.Select(e => new Models.Project().InjectFrom(e)).Cast <Models.Project>().ToList();
            projetsm.Select(e => new Models.Project().InjectFrom(usern.GetUserByOffer(e.IdOffer, 1))).Cast <Models.Project>().ToList();

            ViewBag.Commentaries = projetsm;
            int calif = userp.GetCalificationAverageUser(id);

            //calif = 3;
            ViewBag.Calification = calif;



            RegisterBindingModel regbm = new RegisterBindingModel();

            regbm.InjectFrom(useru);
            regbm.Skills            = useru.Skills.Select(e => new ZonaFl.Models.Skill().InjectFrom(e)).Cast <ZonaFl.Models.Skill>().ToList();
            SessionBag.Current.User = regbm;
            ViewBag.IdUser          = id;
            ViewBag.NameUser        = regbm.UserName;
            ViewBag.User            = useru.UserName;
            ViewBag.ImageUser       = useru.Image;
            ViewBag.EmailUserBuyer  = regbm.Email;
            ViewBag.EmailConfirmed  = (useru.EmailConfirmed)? @"verified": @"";
            ViewBag.PagosConfirmed  = (useru.PagosConfirmed) ? @"verified" : @"";
            // ViewBag.MobileConfirmed=
            /////

            string    order = Request.QueryString.Get("order");
            SCategory scat  = new SCategory();
            List <ZonaFl.Persistence.Entities.Category> listcat = scat.FindAll();

            ViewBag.Categories = listcat;
            List <Persistence.Entities.Offer> lista = new List <Persistence.Entities.Offer>();

            if (!regbm.Freelance)
            {
                //if (statusProject == 0)
                //{
                //    conditions += " or OP.StatusPhase =" + 1+")";
                //}
                //else
                //{
                conditions += " )";
                //}
                lista = soffer.GetListPaged(pagenumber, itemsperpage, conditions + ";", order, statusProject);
            }
            else
            {
                conditions += " )";
                lista       = soffer.GetAppliedOfferByUserListPaged(pagenumber, itemsperpage, conditions, order);
            }



            List <Models.Offer> listoffers = lista.Select(e => new Models.Offer().InjectFrom(e)).Cast <Models.Offer>().ToList();
            SProject            spro       = new SProject();

            listoffers.ForEach(e => e.Comments      = spro.GetByOffer(e.Id) != null ? spro.GetByOffer(e.Id).Comments : "");
            listoffers.ForEach(e => e.Qualification = spro.GetByOffer(e.Id) != null ? spro.GetByOffer(e.Id).Qualification : 0);
            if (statusProject == 1)
            {
                listoffers.ForEach(e => e.IsForFinally = spro.IsProjectForFinally(e.Id));
            }


            List <Persistence.Entities.Category> listcategories = lista.Select(e => e.Category).ToList();

            foreach (var offer in lista)
            {
                var offerget = soffer.GetById(offer.Id);
                if (offerget != null)
                {
                    offer.OfferPhases = offerget.OfferPhases.Select(e => new Persistence.Entities.OfferPhases().InjectFrom(e)).Cast <Persistence.Entities.OfferPhases>().ToList();
                }

                listoffers.FirstOrDefault(e => e.Id == offer.Id).OfferPhases = offer.OfferPhases.Where(e => e.IdOffer == offer.Id).ToList().Select(t => new OfferPhase().InjectFrom(t)).Cast <OfferPhase>().ToList();   //new OfferPhase().InjectFrom(e)).Cast<OfferPhase>().ToList();
                //foreach(var of in offer.OfferPhases.Where(e => e.IdOffer == offer.Id).ToList())
                // {
                //     Models.OfferPhase newof = new Models.OfferPhase();
                //     newof.InjectFrom(of);

                //     listoffers.FirstOrDefault(e => e.Id == offer.Id).OfferPhases.Add(newof);
                // }

                if (listoffers.FirstOrDefault(e => e.Id == offer.Id) != null)
                {
                    listoffers.FirstOrDefault(e => e.Id == offer.Id).Category = new Models.Category();//.InjectFrom(offer.Category);
                }
                listoffers.FirstOrDefault(e => e.Id == offer.Id).Category.InjectFrom(offer.Category);
                listoffers.FirstOrDefault(e => e.Id == offer.Id).ContractorCity    = ((RegisterBindingModel)SessionBag.Current.User).City;
                listoffers.FirstOrDefault(e => e.Id == offer.Id).ContractorCountry = ((RegisterBindingModel)SessionBag.Current.User).Country;
                listoffers.FirstOrDefault(e => e.Id == offer.Id).NameContractor    = ((RegisterBindingModel)SessionBag.Current.User).FirstMiddleName;
                listoffers.FirstOrDefault(e => e.Id == offer.Id).NoPostulados      = soffer.GetNoPostuladosByOffer(offer.Id);



                var dateoferfase1 = soffer.GetPhaseInitial(offer.Id);
                if (dateoferfase1 == null)
                {
                    listoffers.FirstOrDefault(e => e.Id == offer.Id).DateIniPhase1 = DateTime.Parse("01/01/1900");
                }
                else
                {
                    ViewBag.InicioEst = dateoferfase1.InitPhase;
                    if (offer.OfferPhases.Count > 0)
                    {
                        var finest = offer.OfferPhases.LastOrDefault(e => e.FinishPhase != null).FinishPhase;
                        ViewBag.FinEst = finest;
                        listoffers.FirstOrDefault(e => e.Id == offer.Id).FinEst = finest;
                    }
                    else
                    {
                        ViewBag.FinEst = dateoferfase1.FinishPhase;
                        listoffers.FirstOrDefault(e => e.Id == offer.Id).FinEst = dateoferfase1.FinishPhase;
                    }
                    listoffers.FirstOrDefault(e => e.Id == offer.Id).DateIniPhase1 = dateoferfase1.InitPhase;
                    listoffers.FirstOrDefault(e => e.Id == offer.Id).InicioEst     = dateoferfase1.InitPhase;
                }
            }


            if (!regbm.Freelance)
            {
                return(View("DetailsForEmployer", listoffers));
            }
            else
            {
                return(View("DetailsForFreelance", listoffers));
            }
        }
Beispiel #21
0
        private void SimpleButton_Click(object sender, EventArgs e)
        {
            Button btn = sender as Button;

            if (null == btn)
            {
                return;
            }

            if (CancelBtn == btn)
            {
                // if we are still connected disconnect now
                if (Connected)
                {
                    Cmd.ServerInterface.Logout(Data);
                    Connected = false;
                }
                // then close the dialog normally
                DialogResult = DialogResult.OK;
                Close();
                return;
            }

            if (LoginBtn == btn)
            {
                if (Connected)
                {
                    Cmd.ServerInterface.Logout(Data);
                    Connected         = false;
                    UploadBtn.Enabled = false;
                }

                BimServerLoginForm form = new BimServerLoginForm(UIDoc, Data, false);
                if (DialogResult.OK != form.ShowDialog())
                {
                    return;
                }

                Data.CopyFrom(form.Data);
                Cmd.ShowResult(Data.Token);
                Data.SaveToProperties(false);     // save the settings in the properties so the next call will default with them
                UploadBtn.Enabled = true;         // if we have a connection we can enable the action buttons (upload)
                Connected         = true;         // mark as connected
                return;
            }

            if (SaveBtn == btn)
            {
                string name = SelectedProjectName;
                if (string.IsNullOrEmpty(name))
                {
                    return;
                }

                Data.ProjectName = name;
                Cmd.BimServerExchange.SaveBimServerLink(name);

                // report to the user
                Cmd.BimServerExchange.ShowResultInForm($"This revit document is now linked to BIMserver project '{name}'");
                return;
            }

            if (SaveIfcBtn == btn)
            {
                string path = Cmd.BimServerExchange.GetCurrentProjectPath();
                if (string.IsNullOrEmpty(path) || !File.Exists(path))
                {
                    return;
                }

                path = Cmd.BimServerExchange.AskForIfcSavePath(path);
                if (string.IsNullOrEmpty(path))
                {
                    return;
                }

                Cmd.ShowResult(path);
                try
                {
                    Cmd.BimServerExchange.ActivateButtons(false);
                    Cmd.BimServerExchange.ExportProjectToIFC(path);
                    IfcEdt.Text = path;
                    Cmd.BimServerExchange.DoUpload();
                }
                catch (IcnException iex)
                {
                    iex.Display("Exception in Export to IFC");
                }
                catch (Exception ex)
                {
                    Cmd.ShowResult($"Export to IFC failed ({ex.Message})");
                    Cmd.ShowResult(ex.Message);
                }
                finally
                {
                    Cmd.BimServerExchange.ActivateButtons(true);
                }
                return;
            }

            if (LoadIfcBtn == btn)
            {
                string path = Cmd.BimServerExchange.AskForIfcUploadPath();
                if (string.IsNullOrEmpty(path) || !File.Exists(path))
                {
                    return;
                }

                IfcEdt.Text = path;
                Cmd.BimServerExchange.DoUpload();
                return;
            }

            if (CopyProjectNameBtn == btn)
            {
                string name = UIDoc.Document.PathName;
                if (string.IsNullOrEmpty(name))
                {
                    return;
                }

                string fname = Path.GetFileNameWithoutExtension(name);
                if (string.IsNullOrEmpty(fname))
                {
                    return;
                }

                ProjectNameEdt.Text = fname;
                Cmd.BimServerExchange.SelectProjectInTree(fname);
                return;
            }

            if (ProjectAddBtn == btn)
            {
                if (string.IsNullOrEmpty(ProjectNameEdt.Text))
                {
                    Cmd.ShowResult("The revit project does not have a name (it must be saved before running this tool)");
                    return;
                }

                string ifcFormat = NewProjectData.IfcFormat;
                if (ifcFormat.StartsWith("ifc2x3", StringComparison.InvariantCultureIgnoreCase))
                {
                    ifcFormat = "ifc2x3tc1";
                }
                else
                {
                    ifcFormat = "ifc4";
                }
                string fullname = Cmd.BimServerExchange.AddProject(SelectedProject, ProjectNameEdt.Text, ProjectDescEdt.Text, ifcFormat);
                if (string.IsNullOrEmpty(fullname))
                {
                    Cmd.ShowResult("Could not add a new project");
                    return;
                }

                UploadBtn.Enabled = true;
                // reset the projects list
                Projects.Clear();
                Projects.AddRange(Cmd.ServerInterface.GetAllProjects(Data));
                return;
            }

            if (UploadBtn == btn)
            {
                Cmd.BimServerExchange.DoUpload();
                return;
            }

            if (CancelUploadBtn == btn)
            {
                Cmd.BimServerExchange.ActivateButtons(true);
                Cmd.ServerInterface.CancelDownload();
                return;
            }

            // the exact structure of the IFC download request/response is currently undetermined,
            // we can't get the filename
            if (DownloadBtn == btn)
            {
                // see if there is a project up and running
                try
                {
                    SProject proj = SelectedProject;
                    if (null == proj)
                    {
                        throw new IcnException("No project selected", 10, "Download");
                    }

                    SRevision file = SelectedRevision;
                    if (null == file)
                    {
                        throw new IcnException("No IFC file selected", 10, "Download");
                    }

                    string scheme = proj.schema;
                    if (string.IsNullOrEmpty(scheme) || !scheme.StartsWith("Ifc", StringComparison.InvariantCultureIgnoreCase))
                    {
                        Cmd.ShowResult($"Unknown IFC scheme '{scheme ?? string.Empty}'. Attemping to download with 'Ifc2x3tc1 (Streaming)'");
                        scheme = "Ifc2x3tc1 (Streaming)";
                    }
                    SSerializer serialiser = Cmd.ServerInterface.GetSerialiser(Data, proj, scheme);
                    //SSerializer serialiser = Cmd.ServerInterface.GetSerialiser(Data, proj, "json");
                    if (null == serialiser)
                    {
                        throw new IcnException($"Serializer '{scheme}' not found in project '{SelectedProjectName}'", 10, "Download");
                    }

                    // construct a default pathname out of the current revit project location and the BIMserver project name
                    string path = UIDoc.Document.PathName;
                    if (!string.IsNullOrEmpty(path))
                    {
                        path = Path.GetDirectoryName(path);
                    }

                    path = Cmd.BimServerExchange.AskForIfcDownloadFilename(path, proj.name + ".ifc");
                    if (string.IsNullOrEmpty(path))
                    {
                        throw new IcnException($"No path supplied to download to", 10, "Download");
                    }

                    if (File.Exists(path))
                    {
                        string backup = Path.ChangeExtension(path, "bak");
                        if (File.Exists(backup))
                        {
                            File.Delete(backup);
                        }
                        File.Move(path, backup);
                    }

                    // we may have linked files. And we likely will need additional controls (e.g. for the Project to upload to) and additional data to go with this
                    Cmd.ServerInterface.DownloadFile(Data, path, file.oid, serialiser.oid);
                    Cmd.ShowResult($"IFC file '{path}' is copied form the BIMsrver");
                }
                catch (IcnException iex)
                {
                    iex.Display(@"Exception in Download IFC file");
                    Cmd.ShowResult(iex.ToString());
                }
                catch (Exception ex)
                {
                    Cmd.ShowResult($"Download IFC file failed ({ex.Message})");
                    Cmd.ShowResult(ex.Message);
                }

                return;
            }

            throw new IcnException($"SimpleButton '{btn.Name}' activated that has no code", 20, "BimServerExchangeForm");
        }