コード例 #1
0
        public ActionResult Modify(M_ServicesRequests ServicesRequests, List <M_ServicesRequestItems> RequestList)
        {
            object result = "";

            try
            {
                var request = new B_ServicesRequests().GetServicesRequests(ServicesRequests.Id);
                if (request != null)
                {
                    request.Address            = ServicesRequests.Address;
                    request.Description        = ServicesRequests.Description;
                    request.ImmediatelyRequest = ServicesRequests.ImmediatelyRequest;
                    request.PlaqueNumber       = ServicesRequests.PlaqueNumber;
                    request.UnitNumber         = ServicesRequests.UnitNumber;
                    request.UpdateDate         = DateTime.Now;
                    new B_ServicesRequests().Edit(request, false);
                }
                var bItems   = new B_ServicesRequestItems();
                var oldItems = bItems.GetItems(ServicesRequests.Id, E_PublicCategory.SYSTEM_USER_TYPE.NORMAL_USER);
                foreach (var li in oldItems)
                {
                    bItems.Delete(li.Id);
                }
                foreach (var li in RequestList)
                {
                    if (!li.CategoryId.HasValue)
                    {
                        throw F_ExeptionFactory.MakeExeption("مقادیر دسته بندی های انتخاب شده صحیح نیست لطفا مراتب را سریعتر به تیم فنی پروژه گزارش دهید", Enums.Loging.E_LogType.SYSTEM_ERROR);
                    }
                    var category = new B_ServicesCategories().GetServicesCategories(li.CategoryId.Value);
                    li.CategoryId         = category.Id;
                    li.CreateDate         = category.CreateDate;
                    li.ImageName          = category.ImageName;
                    li.IsFailed           = false;
                    li.RequestId          = ServicesRequests.Id;
                    li.ScorePerUnit       = category.ScorePerUnit;
                    li.ScorePerUnitDriver = category.ScorePerUnitDriver;
                    li.Title    = category.Title;
                    li.Unit     = category.Unit;
                    li.UserId   = request.UserId;
                    li.UserType = E_PublicCategory.SYSTEM_USER_TYPE.NORMAL_USER;
                    li.Id       = 0;
                    bItems.Add(li);
                }

                result = "Success";
            }
            catch (Exception ex)
            {
                M_SystemLog exx = new M_SystemLog(E_SystemType.SHAHRDARI_WEB_APPLICATION, E_LogType.ERROR, ex);
                result = "Error";
                if (ex.Source == E_LogType.SYSTEM_ERROR.ToString())
                {
                    exx.LogType = E_LogType.SYSTEM_ERROR;
                    result      = exx;
                }
                L_Log.SubmitLog(exx);
            }
            return(Json(result));
        }
コード例 #2
0
        /// <summary>
        /// افزودن مقدار جدید
        /// </summary>
        /// <param name="ServicesRequest">داده مورد نظر</param>
        /// <returns>نتیجه عملیات</returns>
        public M_ServicesRequests Add(M_ServicesRequests ServicesRequest)
        {
            Validate(ServicesRequest);
            DatabaseContext db = new DatabaseContext();

            ServicesRequest.CreateDate = DateTime.Now;
            if (ServicesRequest.ImmediatelyRequest)
            {
                ServicesRequest.ReferralDate = DateTime.Now;
            }
            db.ServicesRequests.Add(ServicesRequest);
            db.SaveChanges();
            return(ServicesRequest);
        }
コード例 #3
0
        /// <summary>
        /// ویرایش یک درخواست
        /// </summary>
        /// <param name="ServiceRequest">درخواست مورد نظر</param>
        /// <param name="IsService">درخواست ای.پی.آی هستش ؟</param>
        public void Edit(M_ServicesRequests ServiceRequest, bool IsService)
        {
            Validate(ServiceRequest);
            DatabaseContext db = new DatabaseContext();

            db.ServicesRequests.Where(c => c.Id == ServiceRequest.Id && c.IsDeleted == false).Load();
            if (db.ServicesRequests.Local.Count == 0)
            {
                throw F_ExeptionFactory.MakeExeption("درخواستی برای ویرایش پیدا نشد",
                                                     ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "Id", Enums.Loging.E_LogType.SYSTEM_ERROR);
            }
            if (IsService && db.ServicesRequests.Local.Where(c => c.UserId == ServiceRequest.UserId).Count() == 0)
            {
                throw F_ExeptionFactory.MakeExeption("درخواست مورد نظر برای کاربر جاری نمیباشد",
                                                     ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "Id", Enums.Loging.E_LogType.SYSTEM_ERROR);
            }
            db.ServicesRequests.Local[0].Address                 = ServiceRequest.Address;
            db.ServicesRequests.Local[0].Description             = ServiceRequest.Description;
            db.ServicesRequests.Local[0].GeographicalCoordinates = ServiceRequest.GeographicalCoordinates;
            db.ServicesRequests.Local[0].ImmediatelyRequest      = ServiceRequest.ImmediatelyRequest;
            db.ServicesRequests.Local[0].PlaqueNumber            = ServiceRequest.PlaqueNumber;
            db.ServicesRequests.Local[0].ReferralDate            = ServiceRequest.ReferralDate;
            db.ServicesRequests.Local[0].UnitNumber              = ServiceRequest.UnitNumber;
            db.ServicesRequests.Local[0].UpdateDate              = DateTime.Now;
            db.ServicesRequests.Local[0].Pouriya_DateId          = ServiceRequest.Pouriya_DateId;
            db.ServicesRequests.Local[0].Pouriya_TimeId          = ServiceRequest.Pouriya_TimeId;
            db.ServicesRequests.Local[0].Pouriya_Type            = ServiceRequest.Pouriya_Type;
            if (!IsService)
            {
                db.ServicesRequests.Local[0].Status     = ServiceRequest.Status;
                db.ServicesRequests.Local[0].PersonelId = ServiceRequest.PersonelId;
                if (ServiceRequest.Status == E_PublicCategory.REQUEST_STATUS.APPROVED_AND_REFERENCED)
                {
                    db.ServicesRequests.Local[0].ToDoDate = DateTime.Now;
                }
            }
            db.SaveChanges();
        }
コード例 #4
0
        public ActionResult Add(M_ServicesRequests ServicesRequests)
        {
            object result = "";

            try
            {
                ServicesRequests.ReferralDate = DateTime.Now;
                ServicesRequests.Status       = E_PublicCategory.REQUEST_STATUS.NEW_REQUEST;
                new B_ServicesRequests().Add(ServicesRequests);
                result = "Success";
            }
            catch (Exception ex)
            {
                M_SystemLog exx = new M_SystemLog(E_SystemType.SHAHRDARI_WEB_APPLICATION, E_LogType.ERROR, ex);
                result = "Error";
                if (ex.Source == E_LogType.SYSTEM_ERROR.ToString())
                {
                    exx.LogType = E_LogType.SYSTEM_ERROR;
                    result      = exx;
                }
                L_Log.SubmitLog(exx);
            }
            return(Json(result));
        }
コード例 #5
0
ファイル: Home.cs プロジェクト: mohsenfathi/Sabzbash
        public ActionResult AddRequestCar(RequestModelAddRequest Data)
        {
            object result = "";

            try
            {
                if (!isValidUserForInsertRequest("CAR"))
                {
                    throw F_ExeptionFactory.MakeExeption("کاربر گرامی تا اتمام درخواست قبلی،امکان ثبت درخواست جدید میسر نمیباشد",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "PhoneNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                if (string.IsNullOrEmpty(Data.Address))
                {
                    throw F_ExeptionFactory.MakeExeption("آدرس وارد شده صحیح نیست",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "PhoneNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                if (Data.DayId == 0)
                {
                    throw F_ExeptionFactory.MakeExeption("روز انتخاب شده صحیح نیست",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "PhoneNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                if (Data.TimeId == 0)
                {
                    throw F_ExeptionFactory.MakeExeption("ساعت انتخاب شده صحیح نیست",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "PhoneNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                //if (string.IsNullOrEmpty(Data.Description))
                //    throw F_ExeptionFactory.MakeExeption("توضیحات وارد شده صحیح نیست",
                //        ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "PhoneNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                if (Data.UnitNumber == 0)
                {
                    throw F_ExeptionFactory.MakeExeption("شماره واحد وارد شده صحیح نیست",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "PhoneNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                if (Data.PlaqueNumber == 0)
                {
                    throw F_ExeptionFactory.MakeExeption("شماره پلاک وارد شده صحیح نیست",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "PhoneNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                bool rqItems = true;
                if (Data.RequestItems.Count > 0)
                {
                    foreach (var li in Data.RequestItems)
                    {
                        if (li.Value > 0)
                        {
                            rqItems = false;
                        }
                    }
                }
                if (rqItems)
                {
                    throw F_ExeptionFactory.MakeExeption("پسماندهای خود را به دسته بندی اضافه کنید",
                                                         ((int)E_ErrorCodes.NOT_FOUND) + S_Seprators.ErrorFieldNameSeprator.ToString() + "PhoneNumber", Enums.Loging.E_LogType.SYSTEM_ERROR);
                }
                var bServicesRequests = new B_ServicesRequests();
                var request           = new M_ServicesRequests
                {
                    Address                 = Data.Address,
                    Description             = Data.Description,
                    GeographicalCoordinates = Data.Lat + "," + Data.Lng,
                    PlaqueNumber            = Data.PlaqueNumber.ToString(),
                    Pouriya_DateId          = 0,
                    Pouriya_TimeId          = 0,
                    Pouriya_Type            = "CAR",
                    Status     = E_PublicCategory.REQUEST_STATUS.NEW_REQUEST,
                    UnitNumber = Data.UnitNumber.ToString(),
                    UserId     = CurrentUser.Id,
                    PersonelId = null,
                    CreateDate = DateTime.Now,
                };
                request = bServicesRequests.Add(request);
                var bItem = new B_ServicesRequestItems();
                if (Data.RequestItems != null && Data.RequestItems.Count > 0)
                {
                    foreach (var li in Data.RequestItems)
                    {
                        if (li.Value != 0)
                        {
                            var category = new B_ServicesCategories().GetServicesCategories(li.Id);
                            if (category != null)
                            {
                                bItem.Add(new M_ServicesRequestItems
                                {
                                    CreateDate   = DateTime.Now,
                                    RequestId    = request.Id,
                                    UserType     = E_PublicCategory.SYSTEM_USER_TYPE.NORMAL_USER,
                                    Value        = li.Value,
                                    ImageName    = category.ImageName,
                                    ScorePerUnit = category.ScorePerUnit,
                                    Title        = category.Title,
                                    Unit         = category.Unit,
                                    IsFailed     = false,
                                    UserId       = CurrentUser.Id,
                                    CategoryId   = category.Id
                                });
                            }
                        }
                    }
                }

                try
                {
                    var hubConnection = new HubConnection(url: SignalRUrl);
                    var chat          = hubConnection.CreateHubProxy(hubName: "Reqeust");

                    hubConnection.Start().Wait();

                    chat.Invoke <bool>("NewRequestDriver", request);
                }
                catch { }
            }
            catch (Exception ex)
            {
                M_SystemLog exx = new M_SystemLog(E_SystemType.SHAHRDARI_USER_WEB_APPLICATION, E_LogType.ERROR, ex);
                result = "Error";
                if (ex.Source == E_LogType.SYSTEM_ERROR.ToString())
                {
                    exx.LogType = E_LogType.SYSTEM_ERROR;
                    result      = exx;
                }
                L_Log.SubmitLog(exx);
            }
            return(Json(result));
        }