public bool CloseProviderRequest(int id) { try { ServiceRequests _serviceRequests = new ServiceRequests(); _serviceRequests.CloseProviderRequest(id); //// send notification to the first provider //var request = _serviceRequests.GetRequest(id); //var client = _serviceRequests.GetRequest(id).Client; //Dictionary<string, string> keysValues = new Dictionary<string, string> //{ // {"name", client.FullName}, // {"no", id.ToString()}, // {"duration", request.CurrentDuration.ToString()}, // {"ServiceName", request.Service.LocalizedServices.First(l => l.LanguageId == 3073).Title} //}; //string replyToAddress = WebConfigurationManager.AppSettings["ContactUsEmail"]; //string adminEmail = WebConfigurationManager.AppSettings["AdminEmail"]; //string siteMasterEmail = WebConfigurationManager.AppSettings["SiteMasterEmail"]; //try //{ // //Servston.MailManager.SendMail("client/request-finished.html", keysValues, // // "تم الاستجابة على طلبكم ببوابة خدماتكم", // // UserManger.GetEmail(client.UserId.Value), adminEmail, replyToAddress, new List<string>() { siteMasterEmail }); // if (!string.IsNullOrEmpty(request.Client.MobielNumber) && // request.Client.MobielNumber.Length > 10) // { // string sms = // string.Format( // "عميلنا العزيز نفيدكم انه تم الإنتهاء من تنفيذ طلبكم رقم {0} شكرا لكم لإستخدامكم خدمات كوم.", // request.Service.LocalizedServices.First(l => l.LanguageId == 3073).Title); // Servston.SMS smsManager = new Servston.SMS(); // // smsManager.Send(request.Client.MobielNumber, sms); // } //} //catch (Exception ex) //{ //} return(true); } catch (Exception ex) { // todo:log the exception return(false); } }
protected void btnSave_OnClick(object sender, EventArgs e) { try { int requestId = int.Parse(currentId.Value); List <string> fileNames = new List <string>(); List <string> errorsList = new List <string>(); string path = Server.MapPath("~/Attachments/"); if (fupAttachment.HasFiles) { foreach (HttpPostedFile file in fupAttachment.PostedFiles) { bool fileError = false; var fileExtension = System.IO.Path.GetExtension(file.FileName).ToLower(); var fileName = string.Format("{0}_{1}{2}", Servston.Utilities.GetRandomString(5, true), System.IO.Path.GetFileNameWithoutExtension(file.FileName), fileExtension); //Is the file too big to upload? int fileSize = file.ContentLength; if (fileSize > (6 * 1024 * 1024)) { fileError = true; errorsList.Add(string.Format("هذا لملف -{0} - قد تخطى الحجم المسموح به.", file.FileName)); } List <string> acceptedFileTypes = new List <string>() { ".pdf", ".doc", ".docx", ".jpg", ".jpeg", ".gif", ".png" }; if (!acceptedFileTypes.Contains(fileExtension)) { fileError = true; errorsList.Add(string.Format("امتداد هذا لملف -{0} - غير مسموح .", file.FileName)); } if (!fileError) { file.SaveAs(path + fileName); fileNames.Add(fileName); } } } if (errorsList.Count > 0) { RedirectAndNotify(GetLocalizedUrl("providers/services-requests/inprogress-requests"), string.Join("\r\n", errorsList.ToArray()), "حدث خطأ أثناء الطلب", NotificationType.Error); //Notify(string.Join("\r\n", errorsList.ToArray()), "حدث خطأ أثناء الطلب", NotificationType.Error); } else { if (fileNames.Count > 0) { _serviceRequests.AddRequestAttchments(fileNames, requestId, true); } _serviceRequests.CloseProviderRequest(requestId); RedirectAndNotify(GetLocalizedUrl("providers/services-requests/inprogress-requests"), "تم تفيذ الخدمة"); //Server.Transfer(GetLocalizedUrl("providers/services-requests/inprogress-requests")+ "?msg=تم تفيذ الخدمة&msgtype=0"); } } catch (Exception ex) { Server.ClearError(); RedirectAndNotify(GetLocalizedUrl("providers/services-requests/inprogress-requests"), "حدث خطأ أثناء الطلب", "", NotificationType.Error); } }