Ejemplo n.º 1
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtFileName.Text.Trim()))
            {
                MessageBox.Show("File name is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (!CaculatorHelper.CheckFileNameValid(txtFileName.Text))
            {
                MessageBox.Show("File name is invalid.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (CheckNameExist(txtFileName.Text))
            {
                MessageBox.Show("File name already existed in the system.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                var fileName = txtFileName.Text;
                this.Close();
                var id = _assessmentService.NewRecord(fileName);
                _frmMain.RefreshDataForGridFromAnotherForm();

                var frmPcst = new FrmPcstForm(id, _frmMain);
                frmPcst.ShowDialog();
            }
        }
Ejemplo n.º 2
0
        private static void AddMessageErrorMiscellaneousRequired(SectionTempleteVo parameter, List <MessageErrorVo> listMessageError, AssQuestionVo item, int row, int typeMess)
        {
            if (!string.IsNullOrEmpty(parameter.MessageErrorMiscellaneousName) ||
                !string.IsNullOrEmpty(parameter.MessageErrorMiscellaneousPerDay) ||
                !string.IsNullOrEmpty(parameter.MessageErrorMiscellaneousPerWeek))
            {
                var mess = string.Empty;
                if (!string.IsNullOrEmpty(parameter.MessageErrorMiscellaneousName) && typeMess == 1)
                {
                    mess = parameter.MessageErrorMiscellaneousName;
                }

                if (!string.IsNullOrEmpty(parameter.MessageErrorMiscellaneousPerDay) && typeMess == 2)
                {
                    mess = parameter.MessageErrorMiscellaneousPerDay;
                }

                if (!string.IsNullOrEmpty(parameter.MessageErrorMiscellaneousPerWeek) && typeMess == 3)
                {
                    mess = parameter.MessageErrorMiscellaneousPerWeek;
                }

                if (!string.IsNullOrEmpty(mess))
                {
                    var order = CaculatorHelper.GetNumberFromString(parameter.Name);
                    listMessageError.Add(new MessageErrorVo
                    {
                        Order        = order,
                        Id           = "Order" + item.Order + "-" + parameter.Name,
                        MessageError = string.Format(mess, item.Order, row)
                    });
                }
            }
        }
Ejemplo n.º 3
0
 private static void AddMessageErrorMaxValue(SectionTempleteVo parameter, List <MessageErrorVo> listMessageError, AssQuestionVo item, int maxValue)
 {
     if (!string.IsNullOrEmpty(parameter.MessageErrorMaxValue))
     {
         var order = CaculatorHelper.GetNumberFromString(parameter.Name);
         if (listMessageError.Any())
         {
             var checkOrderExist = listMessageError.FirstOrDefault(o => o.Order == order);
             if (checkOrderExist == null)
             {
                 listMessageError.Add(new MessageErrorVo
                 {
                     Order        = order,
                     Id           = "Order" + item.Order + "-" + parameter.Name,
                     MessageError = string.Format(parameter.MessageErrorMaxValue, item.Order, maxValue)
                 });
             }
         }
         else
         {
             listMessageError.Add(new MessageErrorVo
             {
                 Order        = order,
                 Id           = "Order" + item.Order + "-" + parameter.Name,
                 MessageError = string.Format(parameter.MessageErrorMaxValue, item.Order, maxValue)
             });
         }
     }
 }
Ejemplo n.º 4
0
        public WarningInfoVo GetWarningInfo(int requestId, int courierId)
        {
            var listRequestDatetimeNow = _requestRepository.GetListRequestByCourier(requestId, courierId);

            listRequestDatetimeNow = listRequestDatetimeNow.OrderBy(o => o.StartTime).ToList();
            var request = listRequestDatetimeNow.FirstOrDefault(o => o.Id == requestId);

            if (request != null && request.IsWarning.GetValueOrDefault())
            {
                Request preivousRequest = null;
                foreach (var item in listRequestDatetimeNow)
                {
                    if (listRequestDatetimeNow.Count == 1 || (preivousRequest == null && item.Id == requestId))
                    {
                        return(new WarningInfoVo
                        {
                            RequestNo = item.RequestNo,
                            FromAddress = CaculatorHelper.GetFullAddress(item.LocationFromObj.Address1, item.LocationFromObj.Address2, item.LocationFromObj.City, item.LocationFromObj.StateOrProvinceOrRegion, item.LocationFromObj.Zip),
                            ToAddress = CaculatorHelper.GetFullAddress(item.LocationToObj.Address1, item.LocationToObj.Address2, item.LocationToObj.City, item.LocationToObj.StateOrProvinceOrRegion, item.LocationToObj.Zip),
                            DistanceFromTo = item.EstimateDistance.GetValueOrDefault(),
                            TimeFromTo = item.EstimateTime.GetValueOrDefault(),
                            StartTime = item.StartTime,
                            EndTime = item.EndTime,
                            SendingTime = item.SendingTime.GetValueOrDefault()
                        });
                    }
                    if (item.Id == requestId && preivousRequest != null)
                    {
                        return(new WarningInfoVo
                        {
                            PreviousRequestNo = preivousRequest.RequestNo,
                            PreviousToAddress = CaculatorHelper.GetFullAddress(preivousRequest.LocationToObj.Address1, preivousRequest.LocationToObj.Address2, preivousRequest.LocationToObj.City, preivousRequest.LocationToObj.StateOrProvinceOrRegion, preivousRequest.LocationToObj.Zip),
                            PreviousFromAddress = CaculatorHelper.GetFullAddress(preivousRequest.LocationFromObj.Address1, preivousRequest.LocationFromObj.Address2, preivousRequest.LocationFromObj.City, preivousRequest.LocationFromObj.StateOrProvinceOrRegion, preivousRequest.LocationFromObj.Zip),
                            PreviousToAddressName = preivousRequest.LocationToObj.Name.Length > 25 ? preivousRequest.LocationToObj.Name.Remove(25).Insert(25, "...") :  preivousRequest.LocationToObj.Name,
                            PreviousFromAddressName = preivousRequest.LocationFromObj.Name.Length > 25 ? preivousRequest.LocationFromObj.Name.Remove(25).Insert(25, "...") : preivousRequest.LocationFromObj.Name,
                            PreviousSendingTime = preivousRequest.SendingTime,
                            PreviousStartTime = preivousRequest.StartTime,
                            PreviousEndTime = preivousRequest.EndTime,
                            RequestNo = item.RequestNo,
                            FromAddress = CaculatorHelper.GetFullAddress(item.LocationFromObj.Address1, item.LocationFromObj.Address2, item.LocationFromObj.City, item.LocationFromObj.StateOrProvinceOrRegion, item.LocationFromObj.Zip),
                            ToAddress = CaculatorHelper.GetFullAddress(item.LocationToObj.Address1, item.LocationToObj.Address2, item.LocationToObj.City, item.LocationToObj.StateOrProvinceOrRegion, item.LocationToObj.Zip),
                            FromAddressName = item.LocationFromObj.Name.Length > 25 ? item.LocationFromObj.Name.Remove(25).Insert(25, "...") : item.LocationFromObj.Name,
                            ToAddressName = item.LocationToObj.Name.Length > 25? item.LocationToObj.Name.Remove(25).Insert(25, "...") : item.LocationToObj.Name,
                            DistanceEndFrom = item.DistanceEndFrom.GetValueOrDefault(),
                            DistanceFromTo = item.EstimateDistance.GetValueOrDefault(),
                            TimeEndFrom = item.TimeEndFrom.GetValueOrDefault(),
                            TimeFromTo = item.EstimateTime.GetValueOrDefault(),
                            StartTime = item.StartTime,
                            EndTime = item.EndTime,
                            SendingTime = item.SendingTime.GetValueOrDefault()
                        });
                    }
                    preivousRequest = item;
                }
            }

            return(new WarningInfoVo());
        }
Ejemplo n.º 5
0
        public ActionResult GetLookup(LookupQuery queryInfo)
        {
            var selector = new Func <User, LookupItemVo>(o => new LookupItemVo
            {
                KeyId       = o.Id,
                DisplayName = CaculatorHelper.GetFullName(o.FirstName, o.MiddleName, o.LastName)
            });

            return(base.GetLookupForEntity(queryInfo, selector));
        }
Ejemplo n.º 6
0
        public JsonResult GetDescripttionPackage(int packageId)
        {
            //TODO: Issue Respone all error 403
            Response.Status     = "200 OK";
            Response.StatusCode = 200;
            //TODO: Issue Respone all error 403
            var descripttion = CaculatorHelper.GetDescriptionPackage(packageId);
            var clientsJson  = Json(descripttion, JsonRequestBehavior.AllowGet);

            return(clientsJson);
        }
Ejemplo n.º 7
0
        private static void AddMessageErrorImformalSupport(SectionTempleteVo parameter, List <MessageErrorVo> listMessageError,
                                                           AssQuestionVo item, int row, string fieldName)
        {
            var order = CaculatorHelper.GetNumberFromString(parameter.Name);

            listMessageError.Add(new MessageErrorVo
            {
                Order        = order,
                Id           = "Order" + item.Order + "-" + parameter.Name,
                MessageError = string.Format("Item " + item.Order + ": Row " + row + " - " + fieldName + " is required.")
            });
        }
Ejemplo n.º 8
0
        private static void AddMessageErrorMaxValueMiscellaneous(SectionTempleteVo parameter, List <MessageErrorVo> listMessageError, AssQuestionVo item, int maxValue, int row, int typeMess)
        {
            //var message = "Item {0}: Value input is greater than Max Value Allow";
            if (!string.IsNullOrEmpty(parameter.MessageErrorMaxValueMiscellaneousPerDay) ||
                !string.IsNullOrEmpty(parameter.MessageErrorMaxValueMiscellaneousPerWeek))
            {
                var mess = string.Empty;
                if (!string.IsNullOrEmpty(parameter.MessageErrorMaxValueMiscellaneousPerDay) && typeMess == 1)
                {
                    mess = parameter.MessageErrorMaxValueMiscellaneousPerDay;
                }

                if (!string.IsNullOrEmpty(parameter.MessageErrorMaxValueMiscellaneousPerWeek) && typeMess == 2)
                {
                    mess = parameter.MessageErrorMaxValueMiscellaneousPerWeek;
                }
                if (!string.IsNullOrEmpty(mess))
                {
                    var order = CaculatorHelper.GetNumberFromString(parameter.Name);
                    //if (listMessageError.Any())
                    //{
                    //    var checkOrderExist = listMessageError.FirstOrDefault(o => o.Order == order);
                    //    if (checkOrderExist == null)
                    //    {
                    //        listMessageError.Add(new MessageErrorVo
                    //        {
                    //            Order = order,
                    //            Id = "Order" + item.Order + "-" + parameter.Name,
                    //            MessageError = string.Format(mess, item.Order, row, maxValue)
                    //        });
                    //    }
                    //}
                    //else
                    //{
                    //    listMessageError.Add(new MessageErrorVo
                    //    {
                    //        Order = order,
                    //        Id = "Order" + item.Order + "-" + parameter.Name,
                    //        MessageError = string.Format(mess, item.Order, row, maxValue)
                    //    });
                    //}
                    listMessageError.Add(new MessageErrorVo
                    {
                        Order        = order,
                        Id           = "Order" + item.Order + "-" + parameter.Name,
                        MessageError = string.Format(mess, item.Order, row, maxValue)
                    });
                }
            }
        }
Ejemplo n.º 9
0
        public JsonResult GetLookupForReport(LookupQuery queryInfo)
        {
            var selector = new Func <Courier, LookupItemVo>(o => new LookupItemVo
            {
                KeyId       = o.Id,
                DisplayName = o.User != null ? CaculatorHelper.GetFullName(o.User.FirstName, o.User.MiddleName, o.User.LastName) : ""
            });

            var queryData = _courierService.GetLookupForReport(queryInfo, selector);

            queryData.Insert(0, new LookupItemVo()
            {
                DisplayName = "Select All", KeyId = 0
            });
            var clientsJson = Json(queryData.OrderBy(o => o.KeyId), JsonRequestBehavior.AllowGet);

            return(clientsJson);
        }
Ejemplo n.º 10
0
        public string GetFormula(int valConfigTime, int valConfigDay, int valConfigWeek, int valConfigDataTime, int valConfigDataDay, AssQuestionVo refer, List <AssQuestionVo> listRefer = null)
        {
            var result      = Formula;
            var configTime  = 0;
            var configTime2 = 0;

            #region calculator ConfigTime
            if (ConfigTime != null && ConfigTime.ValInOuts != null && ConfigTime.ValInOuts.Count > 0)
            {
                var valInOut = ConfigTime.ValInOuts.FirstOrDefault(o => o.ValIn == valConfigTime);
                if (valInOut != null)
                {
                    if (valInOut.ValOut != null)
                    {
                        result     = result.Replace("ConfigTime", valInOut.ValOut.ToString());
                        configTime = valInOut.ValOut.GetValueOrDefault();
                    }
                    else if (valInOut.ValOuts != null && valInOut.ValOuts.Count > 0 && ConfigRefers != null &&
                             ConfigRefers.Count > 0)
                    {
                        var res = "";
                        foreach (var configRefer in ConfigRefers.OrderByDescending(o => o.Order))
                        {
                            var obj = GetPropValue(refer, configRefer.Field);
                            if (obj != null && obj.ToString().ToLower().Equals(configRefer.Value))
                            {
                                if (string.IsNullOrEmpty(configRefer.ReferValue))
                                {
                                    var objRes   = GetPropValue(refer, configRefer.ReferField);
                                    var orderObj =
                                        valInOut.ValOuts.FirstOrDefault(o => o.ValIn == configRefer.Order);
                                    if (objRes != null && orderObj != null)
                                    {
                                        if (!string.IsNullOrEmpty(res))
                                        {
                                            res += configRefer.Operator;
                                        }

                                        res += "(" + objRes + "*" + orderObj.ValOut + ")";
                                    }
                                }
                                else
                                {
                                    res = "";
                                    break;
                                }
                            }
                        }
                        if (string.IsNullOrEmpty(res))
                        {
                            result = result.Replace("ConfigTime", "0");
                        }
                        else
                        {
                            result = result.Replace("ConfigTime", "(" + res + ")");
                        }
                    }
                    else
                    {
                        result = result.Replace("ConfigTime", "0");
                    }
                }
                else
                {
                    result = result.Replace("ConfigTime", "0");
                }
            }
            #endregion
            #region calculator ConfigDay
            if (ConfigDay != null && ConfigDay.ValInOuts != null && ConfigDay.ValInOuts.Count > 0)
            {
                var valOfAnyReferField = ConfigDay.ValInOuts.FirstOrDefault(o => o.ValIn == 0);
                if (valOfAnyReferField != null && !string.IsNullOrEmpty(valOfAnyReferField.ReferTo))
                {
                    var objRes = GetPropValue(refer, valOfAnyReferField.ReferTo);
                    if (objRes != null)
                    {
                        result = result.Replace("ConfigDay", objRes.ToString());
                    }
                    else
                    {
                        result = result.Replace("ConfigDay", "0");
                    }
                }
                else
                {
                    var valInOut = ConfigDay.ValInOuts.FirstOrDefault(o => o.ValIn == valConfigDay);
                    if (valInOut != null)
                    {
                        if (valInOut.ValOut != null)
                        {
                            result = result.Replace("ConfigDay", valInOut.ValOut.ToString());
                        }
                        else if (!string.IsNullOrEmpty(valInOut.ReferTo))
                        {
                            var objRes = GetPropValue(refer, valInOut.ReferTo);
                            if (objRes != null)
                            {
                                if (valInOut.MaxValue != null)
                                {
                                    var configDay = int.Parse(objRes.ToString());
                                    if (configTime * configDay > valInOut.MaxValue)
                                    {
                                        result = result.Replace(" ", "");
                                        result = result.Replace(configTime + "*ConfigDay", valInOut.MaxValue.ToString());
                                    }
                                    else
                                    {
                                        //result = result.Replace("ConfigDay", "0");
                                        result = result.Replace("ConfigDay", objRes.ToString());
                                    }
                                }
                                else
                                {
                                    if (valInOut.ValOuts != null && valInOut.ValOuts.Count > 0)
                                    {
                                        var valInOnList =
                                            valInOut.ValOuts.FirstOrDefault(o => o.ValIn == int.Parse(objRes.ToString()));
                                        result = result.Replace("ConfigDay",
                                                                valInOnList != null ? valInOnList.ValOut.ToString() : "0");
                                    }
                                    else
                                    {
                                        result = result.Replace("ConfigDay", objRes.ToString());
                                    }
                                }
                            }
                            else
                            {
                                result = result.Replace("ConfigDay", "0");
                            }
                        }
                    }
                    else
                    {
                        result = result.Replace("ConfigDay", "0");
                    }
                }
            }
            #endregion
            #region calculator ConfigWeek
            if (ConfigWeek != null && ConfigWeek.ValInOuts != null && ConfigWeek.ValInOuts.Count > 0)
            {
                var valOfAnyReferField = ConfigWeek.ValInOuts.FirstOrDefault(o => o.ValIn == 0);
                if (valOfAnyReferField != null && !string.IsNullOrEmpty(valOfAnyReferField.ReferTo))
                {
                    var objRes = GetPropValue(refer, valOfAnyReferField.ReferTo);
                    result = result.Replace("ConfigWeek", objRes.ToString());
                }
                else
                {
                    var valInOut = ConfigWeek.ValInOuts.FirstOrDefault(o => o.ValIn == valConfigWeek);
                    if (valInOut != null)
                    {
                        if (valInOut.ValOut != null)
                        {
                            result = result.Replace("ConfigWeek", valInOut.ValOut.ToString());
                        }
                        else if (!string.IsNullOrEmpty(valInOut.ReferTo))
                        {
                            var objRes = GetPropValue(refer, valInOut.ReferTo);
                            if (objRes != null)
                            {
                                if (valInOut.ValOuts != null && valInOut.ValOuts.Count > 0)
                                {
                                    var valInOnList =
                                        valInOut.ValOuts.FirstOrDefault(o => o.ValIn == int.Parse(objRes.ToString()));
                                    result = result.Replace("ConfigWeek",
                                                            valInOnList != null ? valInOnList.ValOut.ToString() : "0");
                                }
                                else
                                {
                                    result = result.Replace("ConfigWeek", objRes.ToString());
                                }
                            }
                            else
                            {
                                result = result.Replace("ConfigWeek", "0");
                            }
                        }
                    }
                    else
                    {
                        result = result.Replace("ConfigWeek", "0");
                    }
                }
            }
            #endregion

            #region calculator ConfigTime2
            if (ConfigDataTime != null && ConfigDataTime.ValInOuts != null && ConfigDataTime.ValInOuts.Count > 0)
            {
                var valInOut = ConfigDataTime.ValInOuts.FirstOrDefault(o => o.ValIn == valConfigDataTime);
                if (valInOut != null)
                {
                    if (valInOut.ValOut != null)
                    {
                        result = result.Replace("ConfigDataTime", valInOut.ValOut.ToString());
                    }
                    else
                    {
                        result = result.Replace("ConfigDataTime", "0");
                    }
                }
                else
                {
                    result = result.Replace("ConfigDataTime", "0");
                }
            }
            #endregion
            #region calculator ConfigDay2
            if (ConfigDataDay != null && ConfigDataDay.ValInOuts != null && ConfigDataDay.ValInOuts.Count > 0)
            {
                var valInOut = ConfigDay.ValInOuts.FirstOrDefault(o => o.ValIn == valConfigDataDay);
                if (valInOut != null)
                {
                    result = result.Replace("ConfigDataDay", valInOut.ValOut.ToString());
                }
                else
                {
                    result = result.Replace("ConfigDataDay", "0");
                }
            }
            #endregion
            #region calculator ConfigReferSums
            if (ConfigReferSums != null && ConfigReferSums.Count > 0)
            {
                var res   = string.Empty;
                var total = ConfigReferSums.Count;
                for (int i = 0; i < total; i++)
                {
                    var isCalculated = true;
                    if (ConfigReferSums[i].CheckReferFieldIsTrue != null)
                    {
                        var fieldCheck = GetPropValue(refer, ConfigReferSums[i].CheckReferFieldIsTrue) as string;
                        if (fieldCheck == null)
                        {
                            isCalculated = false;
                        }
                        else
                        {
                            bool valueOut;
                            if (!string.IsNullOrEmpty(fieldCheck) && bool.TryParse(fieldCheck, out valueOut))
                            {
                                if (!valueOut)
                                {
                                    isCalculated = false;
                                }
                            }
                        }
                    }

                    var obj = GetPropValue(refer, ConfigReferSums[i].Field);
                    if (obj != null && obj.ToString().ToLower().Equals(ConfigReferSums[i].Value) && isCalculated)
                    {
                        if (!string.IsNullOrEmpty(ConfigReferSums[i].ReferPerDayField) && !string.IsNullOrEmpty(ConfigReferSums[i].ReferPerWeekField))
                        {
                            var referPerDayFieldObj  = GetPropValue(refer, ConfigReferSums[i].ReferPerDayField);
                            var referPerWeekFieldObj = GetPropValue(refer, ConfigReferSums[i].ReferPerWeekField);
                            if (referPerDayFieldObj != null && referPerWeekFieldObj != null)
                            {
                                if (string.IsNullOrEmpty(res))
                                {
                                    res += "(" + ConfigReferSums[i].TimeAllow + "*" + referPerDayFieldObj + "*" +
                                           referPerWeekFieldObj + ") ";
                                }
                                else
                                {
                                    res += ConfigReferSums[i].Operator + "(" + ConfigReferSums[i].TimeAllow + "*" +
                                           referPerDayFieldObj + "*" + referPerWeekFieldObj + ") ";
                                }
                            }
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(ConfigReferSums[i].ReferFieldListType))
                            {
                                var jsonList = GetPropValue(refer, ConfigReferSums[i].ReferFieldListType);
                                var list     = JsonConvert.DeserializeObject <List <ReferListType> >(jsonList.ToString());
                                var sum      = 0;
                                foreach (var item in list)
                                {
                                    var valField02 = CaculatorHelper.TryParseIntFromStr(item.Field02);
                                    var valField03 = CaculatorHelper.TryParseIntFromStr(item.Field03);

                                    sum = sum + ConfigReferSums[i].TimeAllow * valField02 * valField03;
                                }
                                if (!string.IsNullOrEmpty(res))
                                {
                                    res += ConfigReferSums[i].Operator + sum;
                                }
                                else
                                {
                                    res += sum;
                                }
                            }
                        }
                    }
                }
                result = result.Replace("ConfigReferSums", string.IsNullOrEmpty(res) ? "0" : res);
            }
            #endregion
            #region calculator CalADLs
            if (CalADLs != null && listRefer != null)
            {
                var res = string.Empty;
                var obj = GetPropValue(refer, CalADLs.Field);
                if (obj != null && obj.ToString().ToLower().Equals(CalADLs.Value) && !string.IsNullOrEmpty(CalADLs.ForFieldCal) && CalADLs.OrderCals != null && CalADLs.OrderCals.Count > 0)
                {
                    foreach (var orderCal in CalADLs.OrderCals)
                    {
                        var calOrderObj = listRefer.FirstOrDefault(o => o.Order == orderCal);
                        if (calOrderObj != null)
                        {
                            var objCal = GetPropValue(calOrderObj, CalADLs.ForFieldCal);
                            if (string.IsNullOrEmpty(res))
                            {
                                res += objCal;
                            }
                            else
                            {
                                res += "+" + objCal;
                            }
                        }
                    }
                    if (CalADLs.ReferOrders != null && CalADLs.ReferOrders.Count > 0)
                    {
                        var flagNotDefault = false;
                        foreach (var source in CalADLs.ReferOrders.Where(o => o.Order != 0))
                        {
                            //With case 1.
                            var objRefer = listRefer.FirstOrDefault(o => o.Order == source.Order);
                            if (objRefer != null)
                            {
                                var objValue = GetPropValue(objRefer, source.Field);
                                if (objValue != null && objValue.ToString().ToLower().Equals(source.Value))
                                {
                                    result         = result.Replace("CalADLs", "(" + res + ")" + source.Operator + source.OperatorValue);
                                    flagNotDefault = true;
                                }
                            }
                        }
                        if (!flagNotDefault)
                        {
                            var objSource = CalADLs.ReferOrders.FirstOrDefault(o => o.Order == 0);
                            if (objSource != null)
                            {
                                result = result.Replace("CalADLs", "(" + res + ")" + objSource.Operator + objSource.OperatorValue);
                            }
                        }
                    }
                    else
                    {
                        result = result.Replace("CalADLs", "0");
                    }
                }
                else
                {
                    result = result.Replace("CalADLs", "0");
                }
            }
            #endregion
            #region calculator ConditionBinds

            if (ConditionBinds != null && ConditionBinds.Count > 0)
            {
                bool res = true;
                foreach (var conditionBind in ConditionBinds)
                {
                    var objCondition = GetPropValue(refer, conditionBind.Field);
                    switch (conditionBind.Operator)
                    {
                    case "=":
                        res &= objCondition != null && String.Compare(objCondition.ToString().ToLower(), conditionBind.Value, StringComparison.Ordinal) == 0;
                        break;

                    case ">":
                        res &= objCondition != null && String.Compare(objCondition.ToString().ToLower(), conditionBind.Value, StringComparison.Ordinal) > 0;
                        break;

                    case "<":
                        res &= objCondition != null && String.Compare(objCondition.ToString().ToLower(), conditionBind.Value, StringComparison.Ordinal) < 0;
                        break;
                    }
                }
                result = result.Replace("ConditionBinds", res ? "1" : "0");
            }

            #endregion

            #region calculator CalHourToileting
            if (CalToiletings != null && CalToiletings.Count > 0)
            {
                //Get max Day per week
                var maxPerWeek = 0;
                if (CalToiletingFieldGetMaxPerWeek != null && CalToiletingFieldGetMaxPerWeek.Any())
                {
                    foreach (var field in CalToiletingFieldGetMaxPerWeek)
                    {
                        var valueOfField = GetPropValue(refer, field);
                        if (valueOfField != null && !string.IsNullOrEmpty(valueOfField.ToString()))
                        {
                            if (valueOfField.ToString().ToLower().Equals("true"))
                            {
                                //Get day per with of Field was selected
                                foreach (var dayPerWeekField in CalToiletings)
                                {
                                    if (dayPerWeekField.Field == field)
                                    {
                                        var valueOfDayPerWeekField = GetPropValue(refer, dayPerWeekField.PerWeekField);
                                        if (valueOfDayPerWeekField != null && !string.IsNullOrEmpty(valueOfDayPerWeekField.ToString()))
                                        {
                                            int flagIntDayPerWeek;

                                            if (valueOfDayPerWeekField != null && int.TryParse(valueOfDayPerWeekField.ToString(), out flagIntDayPerWeek))
                                            {
                                                if (flagIntDayPerWeek > 0)
                                                {
                                                    dayPerWeekField.NumberDayPerWeek = flagIntDayPerWeek;
                                                }
                                                if (flagIntDayPerWeek > maxPerWeek)
                                                {
                                                    maxPerWeek = flagIntDayPerWeek;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                //Get Max minutes config
                var maxMinutes = CalToiletingMaxMinutes;

                //Loop to calculate for each day
                var sumPerDay = 0;

                if (maxPerWeek > 0)
                {
                    for (int i = 1; i <= maxPerWeek; i++)
                    {
                        var total = 0;
                        foreach (var itemCal in CalToiletings)
                        {
                            if (itemCal.NumberDayPerWeek >= i)
                            {
                                var valueOfPerDay = GetPropValue(refer, itemCal.PerDayField);
                                int flagIntPerDay;
                                if (valueOfPerDay != null && int.TryParse(valueOfPerDay.ToString(), out flagIntPerDay))
                                {
                                    total = total + itemCal.Minutes * flagIntPerDay;
                                }
                            }
                        }
                        sumPerDay = sumPerDay + (total <= maxMinutes ? total : maxMinutes);
                    }
                }

                result = result.Replace("CalToiletings", sumPerDay.ToString());
            }
            #endregion
            return(result);
        }
Ejemplo n.º 11
0
        public ActionResult Active(string keyCode, int packageId)
        {
            //TODO: Issue Respone all error 403
            Response.Status     = "200 OK";
            Response.StatusCode = 200;
            //TODO: Issue Respone all error 403

            var productKey         = ConfigurationManager.AppSettings["ProductKey"];
            var secretKey          = ConfigurationManager.AppSettings["SecretKey"];
            var url                = ConfigurationManager.AppSettings["Url"];
            var isRecurrence       = ConfigurationManager.AppSettings["IsRecurrence"];
            var recurrenceInterval = ConfigurationManager.AppSettings["RecurrenceInterval"];
            var passPhrase         = ConfigurationManager.AppSettings["PassPhrase"];
            var paymentUrl         = ConfigurationManager.AppSettings["PaymentUrl"];

            if (string.IsNullOrEmpty(productKey) || string.IsNullOrEmpty(secretKey) || string.IsNullOrEmpty(url) ||
                string.IsNullOrEmpty(isRecurrence) || string.IsNullOrEmpty(recurrenceInterval) || string.IsNullOrEmpty(passPhrase))
            {
                throw new Exception("Missing configuration ProductKey or SecretKey or Url or IsRecurrence or RecurrenceInterval or PassPhrase");
            }

            var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration();
            var objFranchiseeAndLicense = new FranchisseNameAndLicenseDto
            {
                FranchiseeName = franchiseeConfiguration != null ? franchiseeConfiguration.Name : "",
                LicenseKey     = franchiseeConfiguration != null ? franchiseeConfiguration.LicenseKey : ""
            };
            //TODO: franchiseeTenantPackageInfo.Active == false update franchiseeTenantPackageInfo.Active == true when deploy
            var franchiseeTenantPackageInfo = _webApiUserService.GetPackageCurrentId(objFranchiseeAndLicense);

            if (franchiseeTenantPackageInfo == null || franchiseeTenantPackageInfo.Active == true)
            {
                return(Redirect("/"));
            }

            var registerPaymentDto = new PaymentInfoDto();

            registerPaymentDto.AccountNumber      = franchiseeTenantPackageInfo.AccountNumber;
            registerPaymentDto.RequestId          = _webApiUserService.GetRequestCurrentId(objFranchiseeAndLicense);
            registerPaymentDto.ProductKey         = productKey;
            registerPaymentDto.SecretKey          = secretKey;
            registerPaymentDto.ReturnUrl          = url + "LicenceExtension/PaySuccess";
            registerPaymentDto.CancelUrl          = url + "LicenceExtension?keyCode=" + keyCode;
            registerPaymentDto.IsRecurrence       = int.Parse(isRecurrence);
            registerPaymentDto.RecurrenceInterval = int.Parse(recurrenceInterval);
            //0: new; 1: change package; 2: change paymentInfo
            registerPaymentDto.TransactionType = 1;
            registerPaymentDto.StartDate       = DateTime.UtcNow;

            if (franchiseeTenantPackageInfo.Amount.GetValueOrDefault() > CaculatorHelper.GetPricePackage(packageId))
            {
                var packageInfo    = _webApiUserService.GetPackageCurrentNoToken(objFranchiseeAndLicense);
                var packageHistory = new PackageHistoryDto();
                packageHistory.StartDate = DateTime.UtcNow;
                if (packageId % 2 == 0)
                {
                    packageHistory.EndDate = DateTime.UtcNow.AddMonths(1);
                }
                else
                {
                    packageHistory.EndDate = DateTime.UtcNow.AddMonths(12);
                }

                packageHistory.OldPackageId       = franchiseeTenantPackageInfo.PackageId;
                packageHistory.PackageId          = packageId;
                packageHistory.FranchiseeTenantId = franchiseeTenantPackageInfo.Id;
                packageHistory.RequestId          = 0;
                packageHistory.IsApply            = true;
                packageHistory.Amount             = franchiseeTenantPackageInfo.Amount.GetValueOrDefault() -
                                                    CaculatorHelper.GetPricePackage(packageId);
                packageHistory.NextBillingDate        = packageHistory.EndDate;
                packageHistory.PackageNextBillingDate = packageId;

                var  isSuccessAddPackage       = _webApiUserService.AddPackageHistoryNoToken(packageHistory);
                bool isSuccessUpdateFranchisee = _webApiUserService.UpdateFranchiseeTenantLicenceExtentsion(objFranchiseeAndLicense);
                if (isSuccessUpdateFranchisee && isSuccessAddPackage)
                {
                    return(RedirectToAction("Success", "LicenceExtension"));
                }

                return(RedirectToAction("Error", "LicenceExtension"));
            }

            registerPaymentDto.TrialAmount = CaculatorHelper.GetPricePackage(packageId) -
                                             franchiseeTenantPackageInfo.Amount.GetValueOrDefault();

            registerPaymentDto.Items = new List <RegisterProduct>
            {
                new RegisterProduct {
                    ItemId = 1, ItemName = CaculatorHelper.GetNamePackage(packageId), ItemQuantity = 1, ItemPrice = CaculatorHelper.GetPricePackage(packageId)
                }
            };

            var textdate = DateTime.Now.Year + "/" + DateTime.Now.Month + "/" + DateTime.Now.Day + "/ | " + DateTime.Now.Hour + "/" + DateTime.Now.Minute + "/" + DateTime.Now.Second;

            registerPaymentDto.AdditionInfo = JsonConvert.SerializeObject(new { PackageId = packageId, DateTimeSend = textdate });

            var user = _userService.FirstOrDefault(o => o.UserRoleId == 1);

            if (user != null)
            {
                registerPaymentDto.FirstName  = user.FirstName;
                registerPaymentDto.MiddleName = user.MiddleName;
                registerPaymentDto.LastName   = user.LastName;
            }

            if (franchiseeConfiguration != null)
            {
                registerPaymentDto.Email    = franchiseeConfiguration.PrimaryContactEmail;
                registerPaymentDto.Address1 = franchiseeConfiguration.Address1;
                registerPaymentDto.Address2 = franchiseeConfiguration.Address2;
                registerPaymentDto.Zip      = franchiseeConfiguration.Zip;
                registerPaymentDto.City     = franchiseeConfiguration.City;
                registerPaymentDto.State    = franchiseeConfiguration.State;
            }

            var data         = JsonConvert.SerializeObject(registerPaymentDto);
            var result       = EncryptHelper.Encrypt(data, passPhrase);
            var encodeUrl    = HttpUtility.UrlEncode(result);
            var encodeBase64 = EncryptHelper.Base64Encode(encodeUrl);

            var returnData = new { PaymentUrl = paymentUrl, Data = encodeBase64 };

            return(Json(returnData, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 12
0
        public JsonResult Create(CourierParameter parameters)
        {
            //get franchisee configuration
            var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration();
            var objFranchiseeAndLicense = new FranchisseNameAndLicenseDto
            {
                FranchiseeName = franchiseeConfiguration != null ? franchiseeConfiguration.Name : "",
                LicenseKey     = franchiseeConfiguration != null ? franchiseeConfiguration.LicenseKey : ""
            };
            var packageInfo    = _webApiConsumeUserService.GetListPackageChange(objFranchiseeAndLicense);
            var currentPackage = packageInfo.OrderByDescending(o => o.Id).Where(o => o.IsApply).FirstOrDefault();

            //Lay so luong courier dc cho phep cua franchisee
            int numberAllow = 2;

            if (currentPackage != null)
            {
                numberAllow = CaculatorHelper.GetNumberUserAllow(currentPackage.PackageId);
            }

            var numberOfUserCurrent = _userService.Count(o => o.UserRoleId == 2);

            if (numberAllow <= numberOfUserCurrent)
            {
                var mess = string.Format(SystemMessageLookup.GetMessage("NumberUserAllow"));
                MasterFileService.ThrowCustomValidation(mess);
            }
            //Bat dau Add
            var viewModel = MapFromClientParameters(parameters);
            var entity    = viewModel.MapTo <Courier>();

            entity.Status = (int)StatusCourier.Offline;
            // Generate password
            const string randomPassword = "******";

            if (entity.User.UserName != null)
            {
                entity.User.Password = PasswordHelper.HashString(randomPassword, entity.User.UserName);
            }

            var sharViewModel = viewModel.SharedViewModel as DashboardCourierShareViewModel;//
            var logoFilePath  = "";

            if (sharViewModel != null)
            {
                if (!String.IsNullOrEmpty(sharViewModel.UserShareViewModel.Avatar))
                {
                    if (!sharViewModel.UserShareViewModel.Avatar.Contains("data:image/jpg;base64"))
                    {
                        logoFilePath       = Server.MapPath(sharViewModel.UserShareViewModel.Avatar);
                        entity.User.Avatar = _resizeImage.ResizeImageByHeightAndWidth(logoFilePath, 450, 450);
                    }
                }
            }



            var savedEntity = MasterFileService.Add(entity);

            if (savedEntity.Id > 0)
            {
                var webLink       = AppSettingsReader.GetValue("Url", typeof(String)) as string;
                var imgSrc        = webLink + "/Content/quickspatch/img/logo-o.svg";
                var urlChangePass = webLink + "/Authentication/ChangePasswordCourier?code=" + PasswordHelper.HashString(savedEntity.Id.ToString(), entity.User.UserName);
                var fromEmail     = AppSettingsReader.GetValue("EmailFrom", typeof(String)) as string;
                var webapi        = AppSettingsReader.GetValue("WebApiUrlFranchisee", typeof(String)) as string;
                var displayName   = AppSettingsReader.GetValue("EmailFromDisplayName", typeof(String)) as string;
                //var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration();
                var franchiseeName = franchiseeConfiguration != null ? franchiseeConfiguration.Name : "";
                var emailContent   = Framework.Utility.TemplateHelpper.FormatTemplateWithContentTemplate(
                    TemplateHelpper.ReadContentFromFile(TemplateConfigFile.CreateCourierEmailTemplate, true),
                    new
                {
                    img_src         = imgSrc,
                    full_name       = Framework.Utility.CaculatorHelper.GetFullName(savedEntity.User.FirstName, savedEntity.User.MiddleName, savedEntity.User.LastName),
                    web_link        = webLink,
                    user_name       = entity.User.UserName,
                    password        = randomPassword,
                    url_change_pass = urlChangePass,
                    franchisee_Name = franchiseeName,
                    web_api         = webapi
                });
                // send email
                var logo = franchiseeConfiguration != null ? franchiseeConfiguration.Logo : new byte[0];
                _emailHandler.SendEmailSsl(fromEmail, new[] { savedEntity.User.Email }, SystemMessageLookup.GetMessage("SubjectToSendEmailForCreateUser"),
                                           emailContent, logo, true, displayName);
            }
            return
                (Json(new
            {
                id = savedEntity.Id,
                name =
                    Framework.Utility.CaculatorHelper.GetFullName(savedEntity.User.FirstName,
                                                                  savedEntity.User.MiddleName, savedEntity.User.LastName)
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 13
0
 public double GetTotalFreeShip(double shipByWeight, double shipByDimension)
 {
     return(CaculatorHelper.GetMaxValue(shipByWeight, shipByDimension));
 }
Ejemplo n.º 14
0
        public List <MessageErrorVo> CheckInValidDisclosureForm(DisclosureFormVo disclosureFormVm)
        {
            var listError        = new List <MessageErrorVo>();
            var disclosureFormVo = disclosureFormVm;

            #region Member
            var member = disclosureFormVo.Member;

            if (string.IsNullOrEmpty(member.Name))
            {
                listError.Add(new MessageErrorVo
                {
                    MessageError = "Full Name is required.(Disclosure Form)"
                });
            }

            if (string.IsNullOrEmpty(member.Address))
            {
                listError.Add(new MessageErrorVo
                {
                    MessageError = "Full Address is required.(Disclosure Form)"
                });
            }
            if (string.IsNullOrEmpty(member.Mid))
            {
                listError.Add(new MessageErrorVo
                {
                    MessageError = "ForwardHealth ID # is required.(Disclosure Form)"
                });
            }
            if (string.IsNullOrEmpty(member.DobStr))
            {
                listError.Add(new MessageErrorVo
                {
                    MessageError = "DOB is required.(Disclosure Form)"
                });
            }
            else
            {
                try
                {
                    //var valDate = DateTime.ParseExact(valStr, "MM/dd/yyyy", provider);
                    DateTime dt = DateTime.Parse(member.DobStr, new CultureInfo("en-US"));
                    if (CaculatorHelper.CompareDateTime(DateTime.Now, dt, "MM/dd/yyyy") == -1)
                    {
                        listError.Add(new MessageErrorVo
                        {
                            MessageError = "DOB should not be greater than the current date.(Disclosure Form)"
                        });
                    }
                }
                catch (FormatException)
                {
                }
            }

            #endregion
            #region Physician
            var physician = disclosureFormVo.Physician;
            if (physician != null && physician.IsHasPhysician)
            {
                if (string.IsNullOrEmpty(physician.FullName))
                {
                    listError.Add(new MessageErrorVo
                    {
                        MessageError = "Physician's Name is required.(Disclosure Form)"
                    });
                }

                if (string.IsNullOrEmpty(physician.ClinicName))
                {
                    listError.Add(new MessageErrorVo
                    {
                        MessageError = "Physician's Clinic Name is required.(Disclosure Form)"
                    });
                }

                if (string.IsNullOrEmpty(physician.Phone.RemoveFormatPhone()))
                {
                    listError.Add(new MessageErrorVo
                    {
                        MessageError = "Physician's Phone is required.(Disclosure Form)"
                    });
                }

                if (string.IsNullOrEmpty(physician.Fax.RemoveFormatPhone()))
                {
                    listError.Add(new MessageErrorVo
                    {
                        MessageError = "Physician's Fax is required.(Disclosure Form)"
                    });
                }
            }
            #endregion
            #region Other Healthcare Professtional
            var ohp = disclosureFormVo.OtherHealthcareProfessional;
            if (ohp != null && ohp.IsHasOtherHealthcareProfessional)
            {
                if (string.IsNullOrEmpty(ohp.FullName))
                {
                    listError.Add(new MessageErrorVo
                    {
                        MessageError = "Other Healthcare Professional's Name is required.(Disclosure Form)"
                    });
                }

                if (string.IsNullOrEmpty(ohp.ClinicName))
                {
                    listError.Add(new MessageErrorVo
                    {
                        MessageError = "Other Healthcare Professional's Clinic Name is required.(Disclosure Form)"
                    });
                }

                if (string.IsNullOrEmpty(ohp.Phone.RemoveFormatPhone()))
                {
                    listError.Add(new MessageErrorVo
                    {
                        MessageError = "Other Healthcare Professional's Phone is required.(Disclosure Form)"
                    });
                }

                if (string.IsNullOrEmpty(ohp.Fax.RemoveFormatPhone()))
                {
                    listError.Add(new MessageErrorVo
                    {
                        MessageError = "Other Healthcare Professional's Fax is required.(Disclosure Form)"
                    });
                }
            }
            #endregion
            #region Other As Listed
            var oal = disclosureFormVo.OtherAsListed;
            if (oal != null && oal.IsHasOtherAsListed)
            {
                foreach (var item in oal.OtherDisclosureForms)
                {
                    if (string.IsNullOrEmpty(item.Name) || string.IsNullOrEmpty(item.Relationship))
                    {
                        listError.Add(new MessageErrorVo
                        {
                            MessageError = "All fields in Other as listed are required.(Disclosure Form)"
                        });
                        break;
                    }
                }
            }
            #endregion
            #region Providers
            if (disclosureFormVo.IsHasProviderAgency)
            {
                var isHasFirstProvider = disclosureFormVo.Providers.Any(o => o.Order == 1);
                if (!isHasFirstProvider)
                {
                    listError.Add(new MessageErrorVo
                    {
                        MessageError = "Provider #1 is required.(Disclosure Form)"
                    });
                }
            }
            #endregion
            #region Other
            if (string.IsNullOrEmpty(disclosureFormVo.NotBeReleased))
            {
                listError.Add(new MessageErrorVo
                {
                    MessageError = "The following information should not be released is required.(Disclosure Form)"
                });
            }

            if (disclosureFormVo.IsOnTheFollowingDate)
            {
                if (string.IsNullOrEmpty(disclosureFormVo.TheFollowingDateStr))
                {
                    listError.Add(new MessageErrorVo
                    {
                        MessageError = "On the following date is required.(Disclosure Form)"
                    });
                }
            }


            #endregion
            #region Guardian
            var guardian = disclosureFormVo.Guardian;
            if (guardian != null)
            {
                if (!string.IsNullOrEmpty(guardian.Name) || !string.IsNullOrEmpty(guardian.Relationship) ||
                    (guardian.Signature != "_blank" && guardian.Signature != null))
                {
                    if (string.IsNullOrEmpty(guardian.Name))
                    {
                        listError.Add(new MessageErrorVo
                        {
                            MessageError = "Print Name is required.(Disclosure Form)"
                        });
                    }

                    if (string.IsNullOrEmpty(guardian.Relationship))
                    {
                        listError.Add(new MessageErrorVo
                        {
                            MessageError = "Relationship To Member is required.(Disclosure Form)"
                        });
                    }


                    if (guardian.Signature == "_blank")
                    {
                        listError.Add(new MessageErrorVo
                        {
                            MessageError = "Legal Guardian Signature is required.(Disclosure Form)"
                        });
                    }
                }

                if (string.IsNullOrEmpty(disclosureFormVo.DateSignedStr))
                {
                    listError.Add(new MessageErrorVo
                    {
                        MessageError = "Date Signed is required.(Disclosure Form)"
                    });
                }

                if (member.Signature == "_blank" || member.Signature == null)
                {
                    listError.Add(new MessageErrorVo
                    {
                        MessageError = "Member Signature is required.(Disclosure Form)"
                    });
                }
            }
            #endregion
            return(listError);
        }
Ejemplo n.º 15
0
        private void btnExport_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtLocation.Text.Trim()))
            {
                MessageBox.Show("Save to is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (!Directory.Exists(txtLocation.Text))
            {
                MessageBox.Show("Save to not found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (string.IsNullOrEmpty(txtFileName.Text.Trim()))
            {
                MessageBox.Show("File name is required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (!CaculatorHelper.CheckFileNameValid(txtFileName.Text))
            {
                MessageBox.Show("File name is invalid.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                string encyptKey = ConfigurationManager.AppSettings["EncyptKey"];
                if (string.IsNullOrEmpty(encyptKey))
                {
                    MessageBox.Show("EncyptKey not found in App.config.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    var export = true;

                    string path = Path.Combine(txtLocation.Text, txtFileName.Text + ".backup");
                    var    data = new ExportData
                    {
                        AssessmentData     = _assessment.AssessmentData,
                        DisclosureFormData = _assessment.DisclosureFormData,
                        MemberNumber       = _assessment.Mid
                    };
                    var json        = JsonConvert.SerializeObject(data);
                    var decryptData = EncryptHelper.Encrypt(json, encyptKey);

                    if (File.Exists(path))
                    {
                        DialogResult dialogResult = MessageBox.Show(
                            "File exists in this folder. Do you want to replace it?", "Information",
                            MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                        if (dialogResult == DialogResult.Yes)
                        {
                            if (File.Exists(path))
                            {
                                File.Delete(path);
                            }
                            export = true;
                        }
                        else if (dialogResult == DialogResult.No)
                        {
                            export = false;
                        }
                    }
                    if (export)
                    {
                        using (var fs = File.Open(path, FileMode.OpenOrCreate))
                        {
                            using (StreamWriter s = new StreamWriter(fs))
                                s.WriteLine(decryptData);
                        }
                        MessageBox.Show("Export to file successfully!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.Close();
                    }
                }
            }
        }
Ejemplo n.º 16
0
        public dynamic Save(string parameters)
        {
            string encyptKey = ConfigurationManager.AppSettings["EncyptKey"];

            if (string.IsNullOrEmpty(encyptKey))
            {
                throw new Exception("EncyptKey not found in App.config");
            }

            var dataJson  = EncryptHelper.Base64Decode(parameters);
            var jSettings = new JsonSerializerSettings
            {
                Formatting           = Formatting.Indented,
                DateTimeZoneHandling = DateTimeZoneHandling.Utc
            };

            jSettings.Converters.Add(new DefaultWrongFormatDeserialize());
            var viewModel = JsonConvert.DeserializeObject <RequestAssessmentPcsVo>(dataJson, jSettings);

            TrackingCompleteInformation(viewModel);

            var listDisclodureError      = new List <MessageErrorVo>();
            var IsDisclosureFormComplete = true;
            var listError = new List <MessageErrorVo>();

            if (viewModel.IsSaveAll == true)
            {
                var checkDisclosureForm = CheckInValidDisclosureForm(viewModel.DisclosureFormVo);
                if (checkDisclosureForm.Count > 0)
                {
                    if (viewModel.MessageErrorTotal == null)
                    {
                        viewModel.MessageErrorTotal = new List <MessageErrorVo>();
                        viewModel.MessageErrorTotal.AddRange(checkDisclosureForm);
                    }
                    else
                    {
                        viewModel.MessageErrorTotal.AddRange(checkDisclosureForm);
                    }
                    listDisclodureError      = checkDisclosureForm;
                    IsDisclosureFormComplete = false;
                }
                var checkMid = CheckMidDisclosureFormAndPcstForm(viewModel);
                if (checkMid.Count > 0)
                {
                    if (viewModel.MessageErrorTotal == null)
                    {
                        viewModel.MessageErrorTotal = new List <MessageErrorVo>();
                        viewModel.MessageErrorTotal.AddRange(checkMid);
                    }
                    else
                    {
                        viewModel.MessageErrorTotal.AddRange(checkMid);
                    }
                }

                if (viewModel.MessageErrorTotal != null && viewModel.MessageErrorTotal.Count > 0)
                {
                    var index = 0;
                    foreach (var item in viewModel.MessageErrorTotal)
                    {
                        index++;
                        item.Index = index;
                    }
                    //var result = new ObjectReturnVo();
                    //result.Error = viewModel.MessageErrorTotal;
                    //result.Id = viewModel.AssessmentPcsId;
                    //return result;
                    listError = viewModel.MessageErrorTotal;
                }
            }

            var assessmentData = new AssessmentDataVo
            {
                Sections = viewModel.Sections,
                AssessmentSectionQuestions = viewModel.AssessmentSectionQuestions,
            };
            //GetContentHtml(viewModel, assessmentData);

            var encryptAssessmentData =
                EncryptHelper.Encrypt(JsonConvert.SerializeObject(assessmentData), encyptKey);

            //parse string to DateTime
            if (viewModel.DisclosureFormVo.Member != null)
            {
                viewModel.DisclosureFormVo.Member.Dob =
                    CaculatorHelper.TryParseDatTimeFromStr(viewModel.DisclosureFormVo.Member.DobStr);//.GetValueOrDefault();
                if (viewModel.DisclosureFormVo.Member.Signature == "_blank")
                {
                    viewModel.DisclosureFormVo.Member.Signature = null;
                }
            }
            viewModel.DisclosureFormVo.DateSigned =
                CaculatorHelper.TryParseDatTimeFromStr(viewModel.DisclosureFormVo.DateSignedStr);       //.GetValueOrDefault();
            viewModel.DisclosureFormVo.TheFollowingDate =
                CaculatorHelper.TryParseDatTimeFromStr(viewModel.DisclosureFormVo.TheFollowingDateStr); //.GetValueOrDefault();
            if (viewModel.DisclosureFormVo.Guardian != null && viewModel.DisclosureFormVo.Guardian.Signature == "_blank")
            {
                viewModel.DisclosureFormVo.Guardian.Signature = null;
            }
            if (viewModel.DisclosureFormVo.IsHasProviderAgency)
            {
                //set MPI == id
                if (viewModel.DisclosureFormVo.Providers != null && viewModel.DisclosureFormVo.Providers.Count > 0)
                {
                    foreach (var dt in viewModel.DisclosureFormVo.Providers)
                    {
                        if (dt.Id != null && dt.Id.GetValueOrDefault() > 0)
                        {
                            dt.Mpi = dt.Id.ToString();
                        }
                    }
                }
            }
            else
            {
                viewModel.DisclosureFormVo.Providers = new List <ProviderDisclosureFormViewModel>();
            }
            var encryptDisclosureFormData =
                EncryptHelper.Encrypt(JsonConvert.SerializeObject(viewModel.DisclosureFormVo), encyptKey);

            var encryptMid = EncryptHelper.Encrypt(JsonConvert.SerializeObject(GetMid(viewModel)), encyptKey);

            var extensionVm = new ExtensionAssessment
            {
                DisclosureFormIsComplete = IsDisclosureFormComplete,
                ErrorDisclosureForm      = listDisclodureError
            };

            var extensionStr = JsonConvert.SerializeObject(extensionVm);

            using (var context = new AssessmentContext())
            {
                //Update
                if (viewModel.AssessmentPcsId > 0)
                {
                    var assessment = context.Assessments.FirstOrDefault(o => o.Id == viewModel.AssessmentPcsId);
                    if (assessment != null)
                    {
                        assessment.FileName           = viewModel.AssessmentName;
                        assessment.ModifiedOn         = DateTime.Now;
                        assessment.AssessmentData     = encryptAssessmentData;
                        assessment.DisclosureFormData = encryptDisclosureFormData;
                        assessment.Mid       = encryptMid;
                        assessment.Extension = extensionStr;

                        context.Entry(assessment).State = EntityState.Modified;
                        context.SaveChanges();

                        var result = new ObjectReturnVo();
                        result.Id    = assessment.Id;
                        result.Error = listError.Count > 0 ? listError : null;
                        return(result);
                    }
                    else
                    {
                        var result = new ObjectReturnVo();
                        result.Error = new List <MessageErrorVo>
                        {
                            new MessageErrorVo
                            {
                                MessageError = "This record was delete."
                            }
                        };
                        result.Id = 0;

                        return(result);
                    }
                }
                //Add
                else
                {
                    var entity = new Assessment
                    {
                        FileName           = viewModel.AssessmentName,
                        FilePath           = "",
                        CreatedOn          = DateTime.Now,
                        ModifiedOn         = DateTime.Now,
                        AssessmentData     = encryptAssessmentData,
                        DisclosureFormData = encryptDisclosureFormData,
                        Mid       = encryptMid,
                        Extension = extensionStr
                    };
                    context.Entry(entity).State = EntityState.Added;
                    context.SaveChanges();

                    var result = new ObjectReturnVo();
                    result.Id    = entity.Id;
                    result.Error = listError;
                    return(result);
                }
            }
        }
Ejemplo n.º 17
0
 double GetFreeShipByType(double shipByWeight, double shipByDimension, double shipByType)
 {
     return(CaculatorHelper.GetMaxValue(shipByWeight, shipByDimension, shipByType));
 }
Ejemplo n.º 18
0
        private RequestAssessmentPcsVo GetUpdateAssessment(int id)
        {
            var result = new RequestAssessmentPcsVo();

            //var SectionVos = new List<SectionVo>();
            using (var context = new AssessmentContext())
            {
                var assessment = context.Assessments.FirstOrDefault(o => o.Id == id);
                if (assessment != null)
                {
                    //Case for the new assessment
                    if (string.IsNullOrEmpty(assessment.AssessmentData) &&
                        string.IsNullOrEmpty(assessment.DisclosureFormData))
                    {
                        return(GetNewAssessment(assessment.FileName, id));
                    }



                    string encyptKey = ConfigurationManager.AppSettings["EncyptKey"];
                    if (string.IsNullOrEmpty(encyptKey))
                    {
                        throw new Exception("EncyptKey not found in App.config");
                    }

                    var dataJsonAssessmentData = new AssessmentDataVo();
                    if (!string.IsNullOrEmpty(assessment.AssessmentData))
                    {
                        var decryptAssessmentData = EncryptHelper.Decrypt(assessment.AssessmentData, encyptKey);
                        dataJsonAssessmentData = JsonConvert.DeserializeObject <AssessmentDataVo>(decryptAssessmentData);
                    }

                    var dataJsonDiscloseData = new DisclosureFormVo();
                    if (!string.IsNullOrEmpty(assessment.DisclosureFormData))
                    {
                        var decryptDiscloseData = EncryptHelper.Decrypt(assessment.DisclosureFormData, encyptKey);
                        dataJsonDiscloseData = JsonConvert.DeserializeObject <DisclosureFormVo>(decryptDiscloseData);
                    }

                    //always get content new
                    result.Sections = GetHtmlToDisplay();//dataJsonAssessmentData.Sections;



                    result.AssessmentSectionQuestions = dataJsonAssessmentData.AssessmentSectionQuestions;
                    result.AssessmentPcsId            = assessment.Id;
                    result.AssessmentName             = assessment.FileName;

                    if (dataJsonDiscloseData != null && dataJsonDiscloseData.Providers != null && dataJsonDiscloseData.Providers.Count > 0)
                    {
                        foreach (var dt in dataJsonDiscloseData.Providers)
                        {
                            dt.Id = CaculatorHelper.TryParseIntFromStr(dt.Mpi);
                        }
                    }
                    result.DisclosureFormVo = dataJsonDiscloseData;
                    //parse string to DateTime
                    if (result.DisclosureFormVo != null)
                    {
                        if (result.DisclosureFormVo.Member != null)
                        {
                            result.DisclosureFormVo.Member.DobStr = result.DisclosureFormVo.Member.Dob != null?
                                                                    result.DisclosureFormVo.Member.Dob.GetValueOrDefault().ToShortDateString() : "";
                        }
                        result.DisclosureFormVo.DateSignedStr = result.DisclosureFormVo.DateSigned != null?
                                                                result.DisclosureFormVo.DateSigned.GetValueOrDefault().ToShortDateString() : "";

                        result.DisclosureFormVo.TheFollowingDateStr = result.DisclosureFormVo.TheFollowingDate != null
                            ? result.DisclosureFormVo.TheFollowingDate.GetValueOrDefault().ToShortDateString()
                            : "";
                    }
                    return(result);
                }
                return(GetNewAssessment());
            }
            return(result);
        }
Ejemplo n.º 19
0
        public JsonResult GetLocationDefault()
        {
            //var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration();
            var from =
                _systemConfigurationService.FirstOrDefault(
                    o => o.SystemConfigType == SystemConfigType.DefaultLocationFrom);

            var to =
                _systemConfigurationService.FirstOrDefault(
                    o => o.SystemConfigType == SystemConfigType.DefaultLocationTo);

            var fromId      = 0;
            var toId        = 0;
            var fromAddress = "";
            var toAddress   = "";
            var fromName    = "N/A";
            var toName      = "N/A";

            if (from != null)
            {
                var frId = Convert.ToInt32(from.Value);
                if (frId > 0)
                {
                    var locationFrom = _locationService.GetById(frId);
                    if (locationFrom != null)
                    {
                        fromId      = frId;
                        fromName    = locationFrom.Name;
                        fromAddress = CaculatorHelper.GetFullAddressCountry(locationFrom.Address1, locationFrom.Address2, locationFrom.City,
                                                                            locationFrom.StateOrProvinceOrRegion, locationFrom.Zip, locationFrom.CountryOrRegion.Name);
                    }
                    else
                    {
                        fromId = 0;
                    }
                }
            }

            if (to != null)
            {
                var tId = Convert.ToInt32(to.Value);
                if (tId > 0)
                {
                    var locationFrom = _locationService.GetById(tId);
                    if (locationFrom != null)
                    {
                        toId        = tId;
                        fromName    = locationFrom.Name;
                        fromAddress = CaculatorHelper.GetFullAddressCountry(locationFrom.Address1, locationFrom.Address2, locationFrom.City,
                                                                            locationFrom.StateOrProvinceOrRegion, locationFrom.Zip, locationFrom.CountryOrRegion.Name);
                    }
                    else
                    {
                        toId = 0;
                    }
                }
            }

            var clientsJson = Json(new
            {
                LocationFromId      = fromId,
                LocationToId        = toId,
                LocationFromAddress = fromAddress,
                LocationToAddress   = toAddress,
                LocationFromName    = fromName,
                LocationToName      = toName,
            }, JsonRequestBehavior.AllowGet);

            return(clientsJson);
        }
Ejemplo n.º 20
0
        public string GetContentRequestReport(int courierId, DateTime fromDate, DateTime toDate, string displayName)
        {
            var data        = _requestRepository.GetListRequestForReport(courierId, fromDate, toDate);
            var listContent = "";

            double totalDistance = 0;

            if (data.Count > 0)
            {
                listContent +=
                    "<table width='100%' border-collapse: collapse; border: 1px solid #ddd;' cellspacing='0' cellpadding='0'>";
                listContent +=
                    " <tr ><th style='padding: 10px; border: 1px solid #ddd;background: #ccc;'>Request #</th>";
                if (courierId == 0)
                {
                    listContent +=
                        " <th style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;border-top: 1px solid #ddd;background: #ccc;'>Name</th>";
                }
                listContent +=
                    " <th style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;border-top: 1px solid #ddd;background: #ccc;'>From</th>";
                listContent +=
                    " <th style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;border-top: 1px solid #ddd;background: #ccc;'>To</th>";
                listContent +=
                    " <th style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;border-top: 1px solid #ddd;background: #ccc;'>Request Date</th>";
                listContent +=
                    " <th style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;border-top: 1px solid #ddd;background: #ccc;'>Estimate Time (hours)</th>";
                listContent +=
                    " <th style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;border-top: 1px solid #ddd;background: #ccc;'>Real Time (hours)</th>";
                listContent +=
                    " <th style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;border-top: 1px solid #ddd;background: #ccc;'>Estimate Distance (miles)</th>";
                listContent +=
                    " <th style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;border-top: 1px solid #ddd;background: #ccc;'>Real Distance (miles)</th>";
                listContent += "</tr>";

                if (data.Count > 0)
                {
                    foreach (var item in data)
                    {
                        totalDistance = totalDistance + item.ActualDistance.MetersToMiles(2);
                        listContent  +=
                            " <tr ><td style='padding: 10px;border-left: 1px solid #ddd; border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;'>" +
                            item.RequestNo + "</td>";
                        if (courierId == 0)
                        {
                            listContent +=
                                "<td style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;'>" +
                                item.FullName + "</td>";
                        }

                        listContent +=
                            "<td style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;'>" +
                            item.LocationFrom + "</td>";
                        listContent +=
                            "<td style='padding: 10px;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;'>" +
                            item.LocationTo + "</td>";
                        listContent +=
                            "<td style='padding: 10px;text-align:right;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;' >" +
                            item.RequestDateFormat + "</td>";
                        listContent +=
                            "<td style='padding: 10px;text-align:right;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;'>" +
                            item.EstimateTime + "</td>";
                        listContent +=
                            "<td style='padding: 10px;text-align:right;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;'>" +
                            item.RealTime + "</td>";
                        listContent +=
                            "<td style='padding: 10px;text-align:right;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;'>" +
                            item.TextEstimateDistance + "</td>";
                        listContent +=
                            "<td style='padding: 10px;text-align:right;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;'>" +
                            item.TextActualDistance + "</td>";
                        listContent += "</tr>";
                    }
                }

                if (courierId == 0)
                {
                    listContent +=
                        "<tr ><th style='padding: 10px;text-align: right;border-left: 1px solid #ddd; border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;' colspan='8'>Total: </th>";
                }
                else
                {
                    listContent +=
                        "<tr ><th style='padding: 10px;text-align: right;border-left: 1px solid #ddd; border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;' colspan='7'>Total: </th>";
                }
                listContent +=
                    "<th style='padding: 10px; text-align:right;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd;'>" +
                    String.Format("{0:0.00}", totalDistance) + " miles</th>";
                listContent += " </tr>";

                listContent += " </table>";
            }
            else
            {
                listContent += "There isn't request in list.";
            }
            //tao file logo temp from byte[]
            var pathDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "FileUpload");

            if (!Directory.Exists(pathDir))
            {
                Directory.CreateDirectory(pathDir);
            }
            pathDir = Path.Combine(pathDir, "Temps");
            if (!Directory.Exists(pathDir))
            {
                Directory.CreateDirectory(pathDir);
            }

            var franchisee = _franchiseeConfigurationRepository.GetFranchiseeConfiguration();
            //var logoFranchisee = new FileContentResult(franchisee.Logo, "image/jpeg");
            var fileName = Guid.NewGuid().ToString("N") + ".jpg";

            _pathTempFile = Path.Combine(pathDir, fileName);
            File.WriteAllBytes(_pathTempFile, franchisee.Logo);

            if (courierId == 0)
            {
                var reportTemplate1 = _templateRepository.FirstOrDefault(o => o.TemplateType == (int)TemplateType.ReportOfAllDriver);
                var html1           = TemplateHelpper.FormatTemplateWithContentTemplate(WebUtility.HtmlDecode(reportTemplate1.Content), new
                {
                    nameDisplay = displayName,
                    logo        = fileName,
                    reportDate  = DateTime.Now.ToShortDateString(),
                    fromDate    = fromDate.ToShortDateString(),
                    toDate      = toDate.ToShortDateString(),

                    listData = listContent
                });

                return(html1);
            }

            //var displayNameCourier =
            var courierInfo    = _courierRepository.GetById(courierId);
            var reportTemplate = _templateRepository.FirstOrDefault(o => o.TemplateType == (int)TemplateType.ReportOfDriver);
            var html           = TemplateHelpper.FormatTemplateWithContentTemplate(WebUtility.HtmlDecode(reportTemplate.Content), new
            {
                nameDisplay = displayName,
                logo        = fileName,
                reportDate  = DateTime.Now.ToShortDateString(),
                fromDate    = fromDate.ToShortDateString(),
                toDate      = toDate.ToShortDateString(),

                name        = CaculatorHelper.GetFullName(courierInfo.User.FirstName, courierInfo.User.MiddleName, courierInfo.User.LastName),
                email       = courierInfo.User.Email,
                homePhone   = courierInfo.User.HomePhone.ApplyFormatPhone(),
                mobliePhone = courierInfo.User.MobilePhone.ApplyFormatPhone(),
                listData    = listContent
            });

            return(html);

            //return "NO DATA";
        }
Ejemplo n.º 21
0
        public ActionResult PaySuccess(string data)
        {
            var passPhrase = ConfigurationManager.AppSettings["PassPhrase"];

            if (string.IsNullOrEmpty(passPhrase))
            {
                throw new Exception("Missing configuration PassPhrase");
            }
            var base64EncodedBytes = Convert.FromBase64String(data);
            var decode             = System.Text.Encoding.UTF8.GetString(base64EncodedBytes);

            decode = HttpUtility.UrlDecode(decode);
            var decrypt = EncryptHelper.Decrypt(decode, passPhrase);
            var model   = JsonConvert.DeserializeObject <PaymentViewModel>(decrypt);


            if (ModelState.IsValid)
            {
                if (!string.IsNullOrEmpty(model.AdditionInfo))
                {
                    // additionInfo is info of packingeId
                    var additionInfo = JsonConvert.DeserializeObject <dynamic>(model.AdditionInfo);
                    if (CaculatorHelper.IsPropertyExist(additionInfo, "PackageId"))
                    {
                        model.PackageId = (int?)additionInfo.PackageId;
                    }
                }
                var franchiseeConfiguration = _franchiseeConfigurationService.GetFranchiseeConfiguration();
                var objFranchiseeAndLicense = new FranchisseNameAndLicenseDto
                {
                    FranchiseeName = franchiseeConfiguration != null ? franchiseeConfiguration.Name : "",
                    LicenseKey     = franchiseeConfiguration != null ? franchiseeConfiguration.LicenseKey : ""
                };

                var packageInfo = _webApiUserService.GetPackageCurrentNoToken(objFranchiseeAndLicense);
                var info        = _webApiUserService.GetInfoFranchiseeNoToken(objFranchiseeAndLicense);
                if (packageInfo != null && info != null)
                {
                    var packageHistory = new PackageHistoryDto();
                    packageHistory.StartDate = DateTime.UtcNow;
                    if (model.PackageId % 2 == 0)
                    {
                        packageHistory.EndDate = DateTime.UtcNow.AddMonths(1);
                    }
                    else
                    {
                        packageHistory.EndDate = DateTime.UtcNow.AddMonths(12);
                    }

                    packageHistory.OldPackageId       = packageInfo.PackageId;
                    packageHistory.PackageId          = model.PackageId != null ? (int)model.PackageId : 0;
                    packageHistory.FranchiseeTenantId = info.Id;
                    packageHistory.RequestId          = model.RequestId != null ? (int)model.RequestId : 0;
                    packageHistory.IsApply            = true;
                    var  isSuccessAddPackage       = _webApiUserService.AddPackageHistoryNoToken(packageHistory);
                    bool isSuccessUpdateFranchisee = _webApiUserService.UpdateFranchiseeTenantLicenceExtentsion(objFranchiseeAndLicense);
                    if (isSuccessUpdateFranchisee && isSuccessAddPackage)
                    {
                        return(RedirectToAction("Success", "LicenceExtension"));
                    }
                }
            }
            return(RedirectToAction("Error", "LicenceExtension"));
        }