Exemplo n.º 1
0
        public bool EcoEvalsChangeStatus(long evalId, Eco.EvalStatus status)
        {
            Eco.Domain.EconomicEvaluation eval = Manager.Get <Eco.Domain.EconomicEvaluation>(evalId);

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

            eval.UpdateMetaInfo(GetCurrentPerson(), UC.IpAddress, UC.ProxyIpAddress);
            eval.Status = status;

            if (!Manager.IsInTransaction())
            {
                Manager.BeginTransaction();
            }

            try
            {
                Manager.SaveOrUpdate <Eco.Domain.EconomicEvaluation>(eval);
                Manager.Commit();
            }
            catch (Exception ex)
            {
                Manager.RollBack();
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        public bool EcoEvalsAssignCurrent(long evalId)
        {
            Eco.Domain.EconomicEvaluation eval = Manager.Get <Eco.Domain.EconomicEvaluation>(evalId);

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



            lm.Comol.Modules.CallForPapers.Advanced.Domain.AdvMember Member = null;
            try
            {
                Member = eval.Commission.Members.FirstOrDefault(mem => mem.Member.Id == UC.CurrentUserID);
            } catch
            {
            }

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

            eval.UpdateMetaInfo(GetCurrentPerson(), UC.IpAddress, UC.ProxyIpAddress);
            eval.Status        = Eco.EvalStatus.take;
            eval.CurrentMember = Member;

            if (!Manager.IsInTransaction())
            {
                Manager.BeginTransaction();
            }

            try
            {
                Manager.SaveOrUpdate <Eco.Domain.EconomicEvaluation>(eval);
                Manager.Commit();
            }
            catch (Exception ex)
            {
                Manager.RollBack();
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        //public Workbook EcoTablesGetFromEval(long evalId)
        //{
        //    Eco.Domain.EconomicEvaluation eval = Manager.Get<Eco.Domain.EconomicEvaluation>(evalId);

        //    return Eco.Helpers.EconomicExportRadSpreadsheet.EcoExportGetWorkbookPerUser(eval);

        //}

        //EcoEvalTableExportStream(Eco.Domain.EconomicEvaluation Eval, Stream documentStream, SpreadDocumentFormat DocFormat = SpreadDocumentFormat.Xlsx)

        /// <summary>
        /// Esporta via stream le tabelle economiche relative ad una valutazione
        /// </summary>
        /// <param name="evalId">Id valutazione</param>
        /// <param name="stream">stream</param>
        /// <param name="DocFormat">Formato documento (non in uso)</param>
        public void EcoTablesExportStream(
            long evalId,
            System.IO.Stream stream,
            Telerik.Documents.SpreadsheetStreaming.SpreadDocumentFormat DocFormat = Telerik.Documents.SpreadsheetStreaming.SpreadDocumentFormat.Xlsx)
        {
            if (evalId == 0)
            {
                return;
            }

            Eco.Domain.EconomicEvaluation eval = Manager.Get <Eco.Domain.EconomicEvaluation>(evalId);
            if (eval == null)
            {
                return;
            }

            Eco.Helpers.EconomicExportRadSpreadsheet.EcoEvalTableExportStream(eval, stream, DocFormat);
        }
Exemplo n.º 4
0
        public bool EcoCreateEvaluation(long CommissionId)
        {
            if (!EcoEvalClear(CommissionId))
            {
                return(false);
            }


            Adv.Domain.AdvCommission comm = Manager.Get <Adv.Domain.AdvCommission>(CommissionId);

            if (
                comm.Step == null || comm.Step.Type != Adv.StepType.economics ||
                comm.Call == null)
            {
                return(false);
            }

            var stepsQuery = (from Adv.Domain.AdvStep step in Manager.GetIQ <Adv.Domain.AdvStep>()
                              where step.Type != Adv.StepType.economics &&
                              step.Call != null && step.Call.Id == comm.Call.Id
                              select step);

            Adv.Domain.AdvStep prevStep = stepsQuery.Where(s => s.Type == Adv.StepType.custom).OrderByDescending(s => s.Order).Skip(0).Take(1).FirstOrDefault();

            if (prevStep == null)
            {
                prevStep = stepsQuery.Where(s => s.Type == Adv.StepType.validation).Skip(0).Take(1).FirstOrDefault();
            }

            if (prevStep == null || prevStep.Status != Adv.StepStatus.Closed)
            {
                return(false);
            }

            IList <Adv.Domain.AdvSubmissionToStep> subStep = Manager.GetAll <Adv.Domain.AdvSubmissionToStep>(
                s => s.Step != null &&
                s.Step.Id == prevStep.Id &&
                s.Commission == null &&
                s.Admitted).OrderBy(s => s.Rank).ToList();

            IList <CpDomain.UserSubmission> AdmitSubmission = (from Adv.Domain.AdvSubmissionToStep sts in subStep
                                                               select sts.Submission).Distinct().ToList();

            IList <EcoD.EconomicEvaluation> ecEvaluations = Manager.GetAll <EcoD.EconomicEvaluation>(
                ecev => ecev.Call != null && ecev.Call.Id == comm.Call.Id &&
                ecev.Step != null && ecev.Step.Id == comm.Step.Id &&
                ecev.Commission != null && ecev.Commission.Id == comm.Id);

            if (ecEvaluations == null)
            {
                ecEvaluations = new List <EcoD.EconomicEvaluation>();
            }

            foreach (CpDomain.UserSubmission sub in AdmitSubmission)
            {
                EcoD.EconomicEvaluation ecEval = ecEvaluations.FirstOrDefault(ev => ev.Submission != null && ev.Submission.Id == sub.Id);
                bool isNew = false;
                if (ecEval == null)
                {
                    ecEval = new EcoD.EconomicEvaluation();
                    ecEval.CreateMetaInfo(GetCurrentPerson(), UC.IpAddress, UC.ProxyIpAddress);

                    ecEval.CurrentMember = null;
                    ecEval.Call          = comm.Call;
                    ecEval.Commission    = comm;
                    ecEval.Step          = comm.Step;
                    ecEval.Submission    = sub;
                    ecEval.CreateMetaInfo(GetCurrentPerson(), UC.IpAddress, UC.ProxyIpAddress);
                    isNew = true;
                }
                else
                {
                    ecEval.UpdateMetaInfo(GetCurrentPerson(), UC.IpAddress, UC.ProxyIpAddress);
                }

                ecEval.Status = AdvEconomic.EvalStatus.draft;


                ecEval.Tables = EcoTableFromSubmission(sub, ref ecEval);

                try
                {
                    ecEval.Rank          = subStep.FirstOrDefault(st => st.Submission != null && st.Submission.Id == sub.Id).Rank;
                    ecEval.AverageRating = Math.Round(subStep.FirstOrDefault(st => st.Submission != null && st.Submission.Id == sub.Id).AverageRating, 2);
                    ecEval.SumRating     = subStep.FirstOrDefault(st => st.Submission != null && st.Submission.Id == sub.Id).SumRating;
                } catch (Exception ex)
                {
                }


                if (isNew)
                {
                    ecEvaluations.Add(ecEval);
                }
            }

            if (!Manager.IsInTransaction())
            {
                Manager.BeginTransaction();
            }


            try
            {
                Manager.SaveOrUpdateList <EcoD.EconomicEvaluation>(ecEvaluations);
                Manager.Commit();
            } catch (Exception ex)
            {
                Manager.RollBack();
                return(false);
            }

            return(true);
        }
Exemplo n.º 5
0
        private IList <EcoD.EconomicTable> EcoTableFromSubmission(CpDomain.UserSubmission submission, ref EcoD.EconomicEvaluation eval)
        {
            List <EcoD.EconomicTable> tables = new List <EcoD.EconomicTable>();


            long idSubmitterType = (submission.Type != null) ? submission.Type.Id : 0;
            long revId           = (submission.Revisions != null && submission.Revisions.Any()) ?  submission.Revisions.FirstOrDefault().Id : 0;

            List <CpDomain.dtoCallSection <CpDomain.dtoSubmissionValueField> > sections = GetSubmissionFields(submission.Call, idSubmitterType, submission.Id, revId);

            IList <CpDomain.FieldDefinition> fielddefinitions = Manager.GetAll <CpDomain.FieldDefinition>(fd =>
                                                                                                          fd.Call != null && fd.Call.Id == submission.Call.Id &&
                                                                                                          fd.Type == CpDomain.FieldType.TableReport &&
                                                                                                          fd.Deleted == BaseStatusDeleted.None);

            //sf.Fields.FirstOrDefault().Value
            //sf.Fields.FirstOrDefault().Field.Type == CpDomain.FieldType.TableReport

            foreach (var sect in sections)
            {
                foreach (var field in sect.Fields)
                {
                    if (field.Field != null && field.Field.Type == CpDomain.FieldType.TableReport)
                    {
                        //bool isFirst = true;
                        //string Table = field.Value.Text;

                        EcoD.EconomicTable table = new EcoD.EconomicTable();
                        table.CreateMetaInfo(GetCurrentPerson(), UC.IpAddress, UC.ProxyIpAddress);
                        table.Items = new List <EcoD.EconomicItem>();

                        CpDomain.FieldDefinition fDef = fielddefinitions.FirstOrDefault(f => f.Id == field.IdField);
                        //String[] Cold = fDef.TableCols.Split('|');
                        table.FieldDefinition = fDef;

                        table.HeaderValue = fDef.TableCols;
                        table.AdmitMax    = field.Field.TableFieldSetting.MaxTotal;

                        int AddcolNum = table.HeaderValues.Count();


                        string contentXml = String.Format("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>{0}{1}",
                                                          System.Environment.NewLine, field.Value.Text);

                        XmlDocument doc = new XmlDocument();
                        doc.LoadXml(contentXml);

                        foreach (XmlNode trXml in doc.GetElementsByTagName("tr"))
                        {
                            EcoD.EconomicItem itm = new EcoD.EconomicItem();
                            itm.CreateMetaInfo(GetCurrentPerson(), UC.IpAddress, UC.ProxyIpAddress);


                            double unitycost = 0;
                            double quantity  = 0;
                            double total     = 0;
                            int    curCol    = 0;

                            bool hasValue = false;
                            foreach (XmlNode tdXml in trXml.ChildNodes)
                            {
                                curCol++;

                                string cssclass = "";

                                try
                                {
                                    cssclass = tdXml.Attributes["class"].Value;
                                }
                                catch (Exception ex)
                                {
                                }
                                if (!String.IsNullOrEmpty(cssclass) && cssclass == "quantity")
                                {
                                    Double.TryParse(tdXml.InnerText.ToString(), out quantity);

                                    if (quantity > 0)
                                    {
                                        hasValue = true;
                                    }
                                }
                                else if (!String.IsNullOrEmpty(cssclass) && cssclass == "unitycost")
                                {
                                    Double.TryParse(tdXml.InnerText.ToString(), out unitycost);
                                    if (unitycost > 0)
                                    {
                                        hasValue = true;
                                    }
                                }
                                else if (!String.IsNullOrEmpty(cssclass) && cssclass == "total")
                                {
                                    Double.TryParse(tdXml.InnerText.ToString(), out total);
                                    if (total > 0)
                                    {
                                        hasValue = true;
                                    }
                                }
                                else
                                {
                                    bool infoHasvalue = CheckInfoValues(tdXml.InnerText.ToString());
                                    if (infoHasvalue)
                                    {
                                        hasValue = true;
                                    }

                                    if (String.IsNullOrEmpty(itm.InfoValue))
                                    {
                                        itm.InfoValue = String.IsNullOrEmpty(tdXml.InnerText.ToString())? "&nbsp;" : tdXml.InnerText.ToString();
                                    }
                                    else
                                    {
                                        itm.InfoValue = string.Format("{0}|{1}",
                                                                      itm.InfoValue,
                                                                      tdXml.InnerText.ToString());
                                    }
                                }
                            }

                            itm.IsAdmit          = false;
                            itm.RequestQuantity  = quantity;
                            itm.RequestUnitPrice = unitycost;

                            itm.Table   = table;
                            itm.IsEmpty = !hasValue;
                            //if(hasValue)
                            table.Items.Add(itm);
                        }
                        table.EcoEvaluation = eval;

                        tables.Add(table);
                    }
                }
            }
            return(tables);
        }