public EstimationTaskColumnsMaster GetLastUsedBufferColoumnETCM(int projectid, string datatype, int?MasterTaskTypeID)
        {
            EstimationTaskColumnsMaster estcol = new EstimationTaskColumnsMaster();

            //using (var context = new Cubicle_EntityEntities())
            //{

            //    estcol = context.EstimationTaskColumnsMasters.Where(a => a.ProjectID == projectid && a.ProjectTaskListColumn.Contains(datatype) && a.MasterTaskTypeID == MasterTaskTypeID).OrderByDescending(x => x.EstimationTaskColumnID).FirstOrDefault();
            //}

            return(estcol);
        }
Example #2
0
        public void validateTaskEntry(int normId, bool isProjectLeader, string colValue, EstimationTaskColumnsMaster est, IEnumerable <NormDesDet> pEqVal, IEnumerable <NormDesDet> pEqValNorm,
                                      int UserID, int ProjectID, int ProjectTaskId, string DataMappingID, out OperationResult result, List <object> lstMilestoneReq)
        {
            try
            {
                //string message = "";
                result = new OperationResult();

                //if (est.PermanentNameInDb == "Norm" || est.PermanentNameInDb == "Dept")
                //{
                //    result.Message = "";
                //    result.MessageType = "S";
                //    return;
                //}
                ////No validation for norm dependent field if norm is not selected.
                //if (normId == 0 && est.DependonNorms == "Y")
                //{
                //    result.Message = "";
                //    result.MessageType = "S";
                //    return;
                //}

                //if (est.IsMandatory == "Y")
                //{
                //    if (est.PermanentNameInDb == "TaskProgressLevels")
                //    {
                //        if (lstMilestoneReq != null && lstMilestoneReq.Count() > 0)
                //        {
                //            foreach (var m in lstMilestoneReq)
                //            {

                //            }
                //        }
                //    }
                //    else if (colValue == null || colValue.Length <= 0)
                //    {
                //        message += est.DisplayColName + " is required.";
                //    }
                //}

                //if (est.DataType == "Number")
                //{
                //    if (est.IsMandatory == "Y" || Convert.ToString(colValue as object) != "")
                //    {
                //        decimal n;
                //        bool isNumeric = decimal.TryParse(colValue, out n);
                //        if (!isNumeric)
                //        {
                //            message += est.DisplayColName + " must be a numeric value.";
                //        }
                //    }
                //}

                //if (est.DataType == "DateTime")
                //{
                //    string[] formats = { "dd/MM/yyyy" };
                //    DateTime dateValue;
                //    if (est.IsMandatory == "Y" || Convert.ToString(colValue as object) != "")
                //    {
                //        if (est.PermanentNameInDb == "TaskProgressLevels")
                //        {
                //        }
                //        else if (!DateTime.TryParseExact(colValue, formats, new CultureInfo("en-Gb"), DateTimeStyles.None, out dateValue))
                //        {
                //            message += est.DisplayColName + " must be a DateTime value of dd/MM/yyyy format.";
                //        }


                //    }
                //}

                //if (Convert.ToString(est.DataType as object).ToLower().Contains("unique"))
                //{
                //    NewBLEstimationTaskListRepository blObj = new NewBLEstimationTaskListRepository();
                //    if (!blObj.checkUniqueness(Convert.ToInt32(ProjectID), est.ProjectTaskListColumn, colValue, Convert.ToInt32(ProjectTaskId)))
                //    {
                //        message += MessageConstants.Duplicate;
                //    }
                //}

                ////// 1==2 so that it will not get executed.As we have changed equation to javascript function.

                //if (1 == 2 && ((est.Equationvalidation != null && est.Equationvalidation.Length > 0) || (est.EquationID != null && est.EquationID.Length > 0)))
                //{
                //    string eqn = Convert.ToString(est.Equationvalidation as object).Length > 0 ? est.Equationvalidation : est.EquationID;
                //    string[] separators = { " ", "/", "*", "+", "-", "&", "|", ">", "<", "=" };
                //    string[] arr = eqn.Split(separators, StringSplitOptions.None);

                //    for (int i = 0; i < arr.Length; i++)
                //    {
                //        var vNormWord = pEqValNorm.Where(a => a.NameInDb == arr[i]);
                //        var vWord = pEqVal.Where(a => a.NameInDb == arr[i]);
                //        if (vNormWord.Count() > 0 || vWord.Count() > 0)
                //        {
                //            string nameInDb = vWord.Count() > 0 ? vWord.SingleOrDefault().NameInDb : (vNormWord.Count() > 0 ? vNormWord.SingleOrDefault().NameInDb : "");

                //            arr[i] = vWord.Count() > 0 ? vWord.SingleOrDefault().ColValue : (vNormWord.Count() > 0 ? vNormWord.SingleOrDefault().ColValue : "0");

                //            if (est.ValidationMessage != null && Convert.ToString(est.ValidationMessage) != "")
                //            {
                //                est.ValidationMessage = est.ValidationMessage.Replace("#" + nameInDb + "#", Convert.ToString(arr[i] as object));
                //                // est.ValidationMessage = Regex.Replace(est.ValidationMessage, nameInDb, Convert.ToString(arr[i] as object) != "" ? arr[i] : "0");

                //            }
                //            nameInDb = String.Format(@"\b{0}\b", nameInDb);
                //            eqn = Regex.Replace(eqn, nameInDb, Convert.ToString(arr[i] as object) != "" ? arr[i] : "0");
                //        }
                //        else if (est.PermanentNameInDb == "TOTALHRS")
                //        {
                //            eqn = eqn.Replace(arr[i], "0");
                //        }

                //    }

                //    if (Regex.Matches(eqn, @"[a-zA-Z]").Count <= 0)
                //    {
                //        string[] separatorValidation = { "&" };
                //        string[] arr1 = eqn.Split(separatorValidation, StringSplitOptions.None);
                //        if (arr1.Length > 1)
                //        {
                //            for (int i = 0; i < arr1.Length; i++)
                //            {
                //                if (Convert.ToString(arr1[i].Trim()) != "")
                //                {
                //                    if (!Convert.ToBoolean(new DataTable().Compute(Convert.ToString(arr1[i].Trim()), null)))
                //                    {
                //                        message += est.ValidationMessage + "";
                //                    }
                //                }
                //            }
                //        }
                //        else
                //        {
                //            if (est.DBColPkID > 0)
                //            {
                //                result.Message = Convert.ToString(new DataTable().Compute(eqn, null));
                //                result.MessageType = "S";
                //                return;
                //            }
                //            else if (est.PermanentNameInDb == "TOTALHRS")
                //            {
                //                result.Message = Convert.ToString(new DataTable().Compute(eqn, null));
                //                result.MessageType = "S";
                //                return;
                //            }
                //            else if (!Convert.ToBoolean(new DataTable().Compute(eqn, null)))
                //            {
                //                message += est.ValidationMessage + "";
                //            }
                //        }

                //    }
                //}

                //if (!isProjectLeader && est.PermanentNameInDb == "Dept")
                //{
                //    //BLUserRepository bluser = new BLUserRepository();
                //    //User user = bluser.GetuserByID(UserID);
                //    //if (user.DepartmentID != Convert.ToInt32(colValue))
                //    //{
                //    //    message += "You can not create task for other department.";
                //    //}
                //}

                //result.Message = message;
                //result.MessageType = "S";
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }