示例#1
0
        public JsonResult JEditEvent(EventViewModel oEventViewModel)
        {
            oEventViewModel.EVENT_DESCRIPTION = oEventViewModel.EVENT_DESCRIPTION.Replace(Environment.NewLine, "</br>");
            Response           oResponseResult   = null;
            string             sRealFileName     = string.Empty;
            string             sModifiedFileName = string.Empty;
            HttpPostedFileBase filebase          = null;
            var oFile = System.Web.HttpContext.Current.Request.Files["EventImage"];

            if (oFile != null)
            {
                filebase = new HttpPostedFileWrapper(oFile);
                if (filebase.ContentLength > 0)
                {
                    sRealFileName     = filebase.FileName;
                    sModifiedFileName = CommonHelper.AppendTimeStamp(filebase.FileName);
                    oEventViewModel.EVENT_IMG_FILE_PATH = Path.Combine(this.CurrentApplicationID.ToString(), "Events", sModifiedFileName).Replace('\\', '/');
                }
            }

            oEventViewModel.EVENT_DATE     = DateTime.ParseExact(string.Format("{0} {1}", oEventViewModel.FORMATTED_EVENT_DATE, oEventViewModel.EVENT_TIME), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);
            oEventViewModel.CREATED_BY     = Convert.ToInt32(CurrentUser.nUserID);
            oEventViewModel.APPLICATION_ID = CurrentApplicationID;

            oResponseResult      = this.oIEventService.oUpdateEvent(oEventViewModel);
            this.OperationResult = oResponseResult.OperationResult;

            switch (this.OperationResult)
            {
            case enumOperationResult.Success:
                if (oFile != null)
                {
                    FileAccessService oFileAccessService = new FileAccessService(CommonHelper.sGetConfigKeyValue(ConstantNames.FileAccessURL));

                    //DirectoryPath = Saved Application ID + Evemts Folder
                    string sDirectoryPath = Path.Combine(this.CurrentApplicationID.ToString(), "Events");
                    string sFullFilePath  = Path.Combine(sDirectoryPath, sModifiedFileName);
                    oFileAccessService.CreateDirectory(sDirectoryPath);

                    MagickImage oMagickImage = new MagickImage(filebase.InputStream);
                    oMagickImage.Format = MagickFormat.Png;
                    oMagickImage.Resize(Convert.ToInt32(CommonHelper.sGetConfigKeyValue(ConstantNames.ImageWidth)), Convert.ToInt32(CommonHelper.sGetConfigKeyValue(ConstantNames.ImageHeight)));

                    oFileAccessService.WirteFileByte(sFullFilePath, oMagickImage.ToByteArray());
                }
                this.OperationResultMessages = CommonResx.MessageAddSuccess;
                break;

            case enumOperationResult.Faild:
                this.OperationResultMessages = CommonResx.MessageAddFailed;
                break;
            }
            return(Json(
                       new
            {
                nResult = this.OperationResult,
                sResultMessages = this.OperationResultMessages
            },
                       JsonRequestBehavior.AllowGet));
        }
        public JsonResult JSaveApplication(ApplicationViewModel oApplicationViewModel)
        {
            Response oResponseResult = null;

            var oFile = System.Web.HttpContext.Current.Request.Files["ApplicationLogoFile"];
            HttpPostedFileBase filebase = new HttpPostedFileWrapper(oFile);

            string sRealFileName     = filebase.FileName;
            string sModifiedFileName = CommonHelper.AppendTimeStamp(filebase.FileName);

            oApplicationViewModel.APPLICATION_EXPIRY_DATE = DateTime.ParseExact(oApplicationViewModel.FORMATTED_EXPIRY_DATE, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            oApplicationViewModel.APPLICATION_LOGO_PATH   = sModifiedFileName;
            oApplicationViewModel.CREATED_BY = Convert.ToInt32(CurrentUser.nUserID);

            oResponseResult      = this.oIApplicationService.oInsertApplication(oApplicationViewModel);
            this.OperationResult = oResponseResult.OperationResult;

            switch (this.OperationResult)
            {
            case enumOperationResult.Success:
            {
                this.OperationResultMessages = CommonResx.MessageAddSuccess;
                FileAccessService oFileAccessService = new FileAccessService(CommonHelper.sGetConfigKeyValue(ConstantNames.FileAccessURL));

                //DirectoryPath = Saved Application ID
                string sDirectoryPath = oResponseResult.ResponseID;
                string sFullFilePath  = Path.Combine(sDirectoryPath, sModifiedFileName);
                oFileAccessService.CreateDirectory(sDirectoryPath);
                byte[] fileData = null;
                using (var binaryReader = new BinaryReader(filebase.InputStream))
                {
                    fileData = binaryReader.ReadBytes(filebase.ContentLength);
                }
                oFileAccessService.WirteFileByte(sFullFilePath, fileData);
                this.OperationResult = enumOperationResult.Success;
            }
            break;

            case enumOperationResult.Faild:
                this.OperationResultMessages = CommonResx.MessageAddFailed;
                break;
            }
            return(Json(
                       new
            {
                nResult = this.OperationResult,
                sResultMessages = this.OperationResultMessages
            },
                       JsonRequestBehavior.AllowGet));
        }
示例#3
0
        public JsonResult JSaveEvent(EventViewModel oEventViewModel)
        {
            oEventViewModel.EVENT_DESCRIPTION = oEventViewModel.EVENT_DESCRIPTION.Replace(Environment.NewLine, "</br>");
            Response           oResponseResult   = null;
            string             sRealFileName     = string.Empty;
            string             sModifiedFileName = string.Empty;
            HttpPostedFileBase filebase          = null;
            var oFile = System.Web.HttpContext.Current.Request.Files["EventImage"];

            if (oFile != null)
            {
                filebase = new HttpPostedFileWrapper(oFile);
                if (filebase.ContentLength > 0)
                {
                    sRealFileName     = filebase.FileName;
                    sModifiedFileName = CommonHelper.AppendTimeStamp(filebase.FileName);
                    oEventViewModel.EVENT_IMG_FILE_PATH = Path.Combine(this.CurrentApplicationID.ToString(), "Events", sModifiedFileName).Replace('\\', '/');
                }
            }
            oEventViewModel.EVENT_DATE     = DateTime.ParseExact(string.Format("{0} {1}", oEventViewModel.FORMATTED_EVENT_DATE, oEventViewModel.EVENT_TIME), "dd/MM/yyyy HH:mm", CultureInfo.InvariantCulture);
            oEventViewModel.CREATED_BY     = Convert.ToInt32(CurrentUser.nUserID);
            oEventViewModel.APPLICATION_ID = CurrentApplicationID;
            oEventViewModel.LANGUAGE_ID    = Convert.ToInt32(this.CurrentApplicationLanguage);

            oResponseResult      = this.oIEventService.oInsertEvent(oEventViewModel);
            this.OperationResult = oResponseResult.OperationResult;

            switch (this.OperationResult)
            {
            case enumOperationResult.Success:

                if (oFile != null)
                {
                    FileAccessService oFileAccessService = new FileAccessService(CommonHelper.sGetConfigKeyValue(ConstantNames.FileAccessURL));

                    try
                    {
                        //DirectoryPath = Saved Application ID + Evemts Folder
                        string sDirectoryPath = Path.Combine(this.CurrentApplicationID.ToString(), "Events");
                        string sFullFilePath  = Path.Combine(sDirectoryPath, sModifiedFileName);
                        oFileAccessService.CreateDirectory(sDirectoryPath);

                        MagickImage oMagickImage = new MagickImage(filebase.InputStream);
                        oMagickImage.Format = MagickFormat.Png;
                        oMagickImage.Resize(Convert.ToInt32(CommonHelper.sGetConfigKeyValue(ConstantNames.ImageWidth)), Convert.ToInt32(CommonHelper.sGetConfigKeyValue(ConstantNames.ImageHeight)));

                        oFileAccessService.WirteFileByte(sFullFilePath, oMagickImage.ToByteArray());
                    }
                    catch (Exception ex)
                    {
                        Elmah.ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(new Elmah.Error(ex));
                    }
                }

                if (oEventViewModel.IS_NOTIFY_USER && oEventViewModel.IS_ACTIVE)
                {
                    string sEventName = oEventViewModel.EVENT_NAME;
                    string sEventDesc = oEventViewModel.EVENT_DESCRIPTION.Substring(0, Math.Min(oEventViewModel.EVENT_DESCRIPTION.Length, 150)) + "...";

                    #region Send Push Notification

                    var lstApplicationUsers = this.oIUserServices.lGetApplicationUsers(this.CurrentApplicationID, Convert.ToInt32(enumUserType.MobileUser).ToString());
                    if (lstApplicationUsers.Count > 0)
                    {
                        string sDeviceIDS = string.Join(",", lstApplicationUsers.Where(o => Convert.ToInt32(o.PREFERED_LANGUAGE_ID) == (int)this.CurrentApplicationLanguage)
                                                        .Where(o => o.DEVICE_ID != null)
                                                        .Where(o => o.DEVICE_ID != string.Empty)
                                                        .Where(o => o.IS_ACTIVE == true)
                                                        .Where(o => o.IS_BLOCKED == false)
                                                        .Select(o => o.DEVICE_ID.ToString()));

                        string sMobileNumbers = string.Join(",", lstApplicationUsers.Where(o => Convert.ToInt32(o.PREFERED_LANGUAGE_ID) == (int)this.CurrentApplicationLanguage)
                                                            .Where(o => o.DEVICE_ID != null)
                                                            .Where(o => o.DEVICE_ID != string.Empty)
                                                            .Where(o => o.IS_ACTIVE == true)
                                                            .Where(o => o.IS_BLOCKED == false)
                                                            .Select(o => o.PHONE_NUMBER.ToString()));


                        PushNotification oPushNotification = new PushNotification();
                        oPushNotification.NotificationType  = enmNotificationType.Events;
                        oPushNotification.sHeadings         = sEventName;
                        oPushNotification.sContent          = sEventDesc;
                        oPushNotification.sDeviceID         = sDeviceIDS;
                        oPushNotification.enmLanguage       = this.CurrentApplicationLanguage;
                        oPushNotification.sRecordID         = oResponseResult.ResponseCode;
                        oPushNotification.sOneSignalAppID   = this.CurrentApplicationOneSignalID;
                        oPushNotification.sOneSignalAuthKey = this.CurrentApplicationOneSignalAuthKey;
                        oPushNotification.SendPushNotification();
                        NotificationLogViewModel oNotificationLogViewModel = new NotificationLogViewModel();
                        oNotificationLogViewModel.APPLICATION_ID       = this.CurrentApplicationID;
                        oNotificationLogViewModel.NOTIFICATION_TYPE    = "events";
                        oNotificationLogViewModel.REQUEST_JSON         = oPushNotification.sRequestJSON;
                        oNotificationLogViewModel.RESPONSE_MESSAGE     = oPushNotification.sResponseResult;
                        oNotificationLogViewModel.MOBILE_NUMBERS       = sMobileNumbers;
                        oNotificationLogViewModel.IS_SENT_NOTIFICATION = oPushNotification.bIsSentNotification;
                        oICommonServices.oInsertNotificationLog(oNotificationLogViewModel);
                        #endregion
                    }
                }
                this.OperationResultMessages = CommonResx.MessageAddSuccess;
                break;

            case enumOperationResult.Faild:
                this.OperationResultMessages = CommonResx.MessageAddFailed;
                break;
            }
            return(Json(
                       new
            {
                nResult = this.OperationResult,
                sResultMessages = this.OperationResultMessages
            },
                       JsonRequestBehavior.AllowGet));
        }
        public JsonResult JSaveApplicationLogoToTemp()
        {
            Response oResponseResult   = new Response();
            string   sRealFileName     = string.Empty;
            string   sModifiedFileName = string.Empty;
            string   sFullFilePath     = string.Empty;

            if (System.Web.HttpContext.Current.Request.Files.AllKeys.Any())
            {
                var oFile = System.Web.HttpContext.Current.Request.Files["ApplicationLogoFile"];
                HttpPostedFileBase filebase = new HttpPostedFileWrapper(oFile);

                sRealFileName     = filebase.FileName;
                sModifiedFileName = CommonHelper.AppendTimeStamp(filebase.FileName);
                FileAccessHandler oFileAccessHandler = new FileAccessHandler();

                //DirectoryPath = TempUploadFolder from web.config
                string sDirectoryPath = string.Concat(CommonHelper.sGetConfigKeyValue(ConstantNames.TempUploadFolder));
                sFullFilePath = Path.Combine(sDirectoryPath, sModifiedFileName);
                oFileAccessHandler.CreateDirectory(sDirectoryPath);
                if (oFileAccessHandler.OperationResult == 1)
                {
                    oFileAccessHandler.WirteFile(sFullFilePath, filebase.InputStream);
                    if (oFileAccessHandler.OperationResult == 1)
                    {
                        this.OperationResult = enumOperationResult.Success;
                    }
                    else
                    {
                        this.OperationResult = enumOperationResult.Faild;
                    }
                }
                else
                {
                    this.OperationResult = enumOperationResult.Faild;
                }
            }

            switch (this.OperationResult)
            {
            case enumOperationResult.Success:
                this.OperationResultMessages = CommonResx.MessageAddSuccess;
                break;

            case enumOperationResult.Faild:
                this.OperationResultMessages = CommonResx.MessageAddFailed;
                break;

            case enumOperationResult.AlreadyExistRecordFaild:
                this.OperationResultMessages = CommonResx.AlreadyExistRecordFaild;
                break;
            }
            return(Json(
                       new
            {
                nResult = this.OperationResult,
                sResultMessages = this.OperationResultMessages,
                sFileName = (this.OperationResult == enumOperationResult.Success) ? sModifiedFileName : string.Empty,
                sFullFilePath = (this.OperationResult == enumOperationResult.Success) ? sFullFilePath.Replace('\\', '/') : string.Empty
            },
                       JsonRequestBehavior.AllowGet));
        }
        public HttpResponseMessage PostTicketChat(TakamulTicketChat oTakamulTicketChat, int nLanguageID)
        {
            ApiResponse oApiResponse   = new ApiResponse();
            string      sResultMessage = string.Empty;

            if (ModelState.IsValid)
            {
                try
                {
                    string sReplyImagePath      = string.Empty;
                    string sReplyImageDirectory = string.Empty;
                    string sFullFilePath        = string.Empty;
                    if (!string.IsNullOrEmpty(oTakamulTicketChat.Base64ReplyImage))
                    {
                        sReplyImageDirectory = Path.Combine(oTakamulTicketChat.ApplicationID.ToString(), oTakamulTicketChat.TicketID.ToString());
                        enumFileTypes oEnumFileTypes = (enumFileTypes)Enum.Parse(typeof(enumFileTypes), oTakamulTicketChat.TicketChatTypeID.ToString());
                        switch (oEnumFileTypes)
                        {
                        case enumFileTypes.png:
                            sReplyImagePath = CommonHelper.AppendTimeStamp("fake.png");
                            break;

                        case enumFileTypes.jpg:
                            sReplyImagePath = CommonHelper.AppendTimeStamp("fake.jpg");
                            break;

                        case enumFileTypes.jpeg:
                            sReplyImagePath = CommonHelper.AppendTimeStamp("fake.jpeg");
                            break;

                        case enumFileTypes.doc:
                            sReplyImagePath = CommonHelper.AppendTimeStamp("fake.doc");
                            break;

                        case enumFileTypes.docx:
                            sReplyImagePath = CommonHelper.AppendTimeStamp("fake.docx");
                            break;

                        case enumFileTypes.pdf:
                            sReplyImagePath = CommonHelper.AppendTimeStamp("fake.pdf");
                            break;
                        }
                        sFullFilePath = Path.Combine(sReplyImageDirectory, sReplyImagePath);
                    }

                    TicketChatViewModel oTicketChatViewModel = new TicketChatViewModel()
                    {
                        TICKET_ID             = oTakamulTicketChat.TicketID,
                        REPLY_MESSAGE         = oTakamulTicketChat.ReplyMessage,
                        REPLY_FILE_PATH       = sFullFilePath.Replace('\\', '/'),
                        TICKET_CHAT_TYPE_ID   = oTakamulTicketChat.TicketChatTypeID,
                        TICKET_PARTICIPANT_ID = oTakamulTicketChat.UserID
                    };

                    Response oResponse = this.oITicketServices.oInsertTicketChat(oTicketChatViewModel);
                    if (oResponse.nOperationResult == 1)
                    {
                        if (!string.IsNullOrEmpty(sFullFilePath) && !string.IsNullOrEmpty(oTakamulTicketChat.Base64ReplyImage))
                        {
                            FileAccessService oFileAccessService = new FileAccessService(CommonHelper.sGetConfigKeyValue(ConstantNames.FileAccessURL));
                            Byte[]            oArrImage          = Convert.FromBase64String(oTakamulTicketChat.Base64ReplyImage);
                            oFileAccessService.CreateDirectory(sReplyImageDirectory);

                            enumFileTypes oEnumFileTypes = (enumFileTypes)Enum.Parse(typeof(enumFileTypes), oTakamulTicketChat.TicketChatTypeID.ToString());
                            if (oEnumFileTypes == enumFileTypes.jpeg || oEnumFileTypes == enumFileTypes.jpg ||
                                oEnumFileTypes == enumFileTypes.png)
                            {
                                MagickImage oMagickImage = new MagickImage(oArrImage);
                                oMagickImage.Format = MagickFormat.Jpeg;
                                oMagickImage.Resize(Convert.ToInt32(CommonHelper.sGetConfigKeyValue(ConstantNames.ImageWidth)), Convert.ToInt32(CommonHelper.sGetConfigKeyValue(ConstantNames.ImageHeight)));
                                oFileAccessService.WirteFileByte(Path.Combine(sReplyImageDirectory, sReplyImagePath), oMagickImage.ToByteArray());
                            }
                            else
                            {
                                oFileAccessService.WirteFileByte(Path.Combine(sReplyImageDirectory, sReplyImagePath), oArrImage);
                            }
                        }
                        oApiResponse.OperationResult        = 1;
                        oApiResponse.OperationResultMessage = "Success.";
                    }
                    else
                    {
                        switch (oResponse.nOperationResult)
                        {
                        case -5:
                            oApiResponse.OperationResult = -5;
                            sResultMessage = nLanguageID == 2 ? "The Application is expired." : "انتهت صلاحية التطبيق.";
                            oApiResponse.OperationResultMessage = sResultMessage;
                            break;

                        case -6:
                            oApiResponse.OperationResult = -6;
                            sResultMessage = nLanguageID == 2 ? "OTP is not verified." : "لم يتم التحقق من رمز التفعيل.";
                            oApiResponse.OperationResultMessage = sResultMessage;
                            break;

                        case -7:
                            oApiResponse.OperationResult = -7;
                            sResultMessage = nLanguageID == 2 ? "User is blocked." : "المستخدم محضور.";
                            oApiResponse.OperationResultMessage = sResultMessage;
                            break;

                        case -8:
                            oApiResponse.OperationResult = -8;
                            sResultMessage = nLanguageID == 2 ? "Ticket submission is restricted." : "المواضيع الجديدة مقيدة.";
                            oApiResponse.OperationResultMessage = sResultMessage;
                            break;

                        case -9:
                            oApiResponse.OperationResult = -9;
                            sResultMessage = nLanguageID == 2 ? "Ticket Submission Interval Days reached." : "وصلت للفترة الزمنية لتقديم للمواضيع.";
                            oApiResponse.OperationResultMessage = sResultMessage;
                            break;

                        default:
                            oApiResponse.OperationResult = 0;
                            sResultMessage = nLanguageID == 2 ? "An error occurred during the operation. Please try again later." : "حدث خطأ  يرجى المحاولة لاحقا مرة أخرى.";
                            oApiResponse.OperationResultMessage = sResultMessage;
                            break;
                        }
                    }
                    return(Request.CreateResponse(HttpStatusCode.OK, oApiResponse));
                }
                catch (Exception ex)
                {
                    Elmah.ErrorLog.GetDefault(HttpContext.Current).Log(new Elmah.Error(ex));
                    oApiResponse.OperationResult = 0;
                    sResultMessage = nLanguageID == 2 ? "An error occurred during the operation. Please try again later." : "حدث خطأ  يرجى المحاولة لاحقا مرة أخرى.";
                    oApiResponse.OperationResultMessage = sResultMessage;
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError, oApiResponse));
                }
            }
            oApiResponse.OperationResult = 0;
            sResultMessage = nLanguageID == 2 ? "An error occurred during the operation. Please try again later." : "حدث خطأ  يرجى المحاولة لاحقا مرة أخرى.";
            oApiResponse.OperationResultMessage = sResultMessage;
            return(Request.CreateResponse(HttpStatusCode.BadRequest, oApiResponse));
        }
        public HttpResponseMessage CreateTicket(TakamulTicket oTakamulTicket, int nUserID, int nLanguageID)
        {
            ApiResponse oApiResponse   = new ApiResponse();
            string      sResultMessage = string.Empty;

            if (ModelState.IsValid)
            {
                try
                {
                    string sDefaultImagePath = string.Empty;
                    if (!string.IsNullOrEmpty(oTakamulTicket.Base64DefaultImage))
                    {
                        enumFileTypes oEnumFileTypes = (enumFileTypes)Enum.Parse(typeof(enumFileTypes), oTakamulTicket.DefaultImageType.ToString());
                        switch (oEnumFileTypes)
                        {
                        case enumFileTypes.png:
                            sDefaultImagePath = CommonHelper.AppendTimeStamp("fake.png");
                            break;

                        case enumFileTypes.jpg:
                            sDefaultImagePath = CommonHelper.AppendTimeStamp("fake.jpg");
                            break;

                        case enumFileTypes.jpeg:
                            sDefaultImagePath = CommonHelper.AppendTimeStamp("fake.jpeg");
                            break;
                        }
                    }

                    TicketViewModel oTicketViewModel = new TicketViewModel()
                    {
                        APPLICATION_ID          = oTakamulTicket.ApplicationID,
                        TICKET_NAME             = oTakamulTicket.TicketName,
                        TICKET_DESCRIPTION      = oTakamulTicket.TicketDescription,
                        DEFAULT_IMAGE           = sDefaultImagePath,
                        TICKET_CREATED_PLATFORM = (int)Infrastructure.Core.enmTicketPlatForm.Mobile,
                        CREATED_BY = nUserID
                    };

                    Response oResponse = this.oITicketServices.oInsertTicket(oTicketViewModel, nUserID);
                    if (oResponse.nOperationResult == 1)
                    {
                        if (!string.IsNullOrEmpty(sDefaultImagePath) && !string.IsNullOrEmpty(oTakamulTicket.Base64DefaultImage))
                        {
                            FileAccessService oFileAccessService = new FileAccessService(CommonHelper.sGetConfigKeyValue(ConstantNames.FileAccessURL));
                            if (!oResponse.ResponseID.Equals("-99"))
                            {
                                Byte[] oArrImage = Convert.FromBase64String(oTakamulTicket.Base64DefaultImage);

                                MagickImage oMagickImage = new MagickImage(oArrImage);
                                oMagickImage.Format = MagickFormat.Png;
                                oMagickImage.Resize(Convert.ToInt32(CommonHelper.sGetConfigKeyValue(ConstantNames.ImageWidth)), Convert.ToInt32(CommonHelper.sGetConfigKeyValue(ConstantNames.ImageHeight)));


                                string sDirectoyPath = Path.Combine(oTakamulTicket.ApplicationID.ToString(), oResponse.ResponseID);
                                oFileAccessService.CreateDirectory(sDirectoyPath);
                                //oFileAccessService.WirteFileByte(Path.Combine(sDirectoyPath, sDefaultImagePath), oArrImage);
                                oFileAccessService.WirteFileByte(Path.Combine(sDirectoyPath, sDefaultImagePath), oMagickImage.ToByteArray());
                            }
                        }
                        oApiResponse.OperationResult = 1;
                        oApiResponse.ResponseID      = Convert.ToInt32(oResponse.ResponseID);
                        sResultMessage = nLanguageID == 2 ? "Ticket has been successfully created." : "تم إنشاء الموضوع بنجاح.";
                        oApiResponse.OperationResultMessage = sResultMessage;
                    }
                    else
                    {
                        switch (oResponse.nOperationResult)
                        {
                        case -5:
                            oApiResponse.OperationResult = -5;
                            sResultMessage = nLanguageID == 2 ? "The Application is expired." : "انتهت صلاحية التطبيق.";
                            oApiResponse.OperationResultMessage = sResultMessage;
                            break;

                        case -6:
                            oApiResponse.OperationResult = -6;
                            sResultMessage = nLanguageID == 2 ? "OTP is not verified." : "لم يتم التحقق من رمز التفعيل.";
                            oApiResponse.OperationResultMessage = sResultMessage;
                            break;

                        case -7:
                            oApiResponse.OperationResult = -7;
                            sResultMessage = nLanguageID == 2 ? "User is blocked." : "المستخدم محضور.";
                            oApiResponse.OperationResultMessage = sResultMessage;
                            break;

                        case -8:
                            oApiResponse.OperationResult = -8;
                            sResultMessage = nLanguageID == 2 ? "Ticket submission is restricted." : "المواضيع الجديدة مقيدة.";
                            oApiResponse.OperationResultMessage = sResultMessage;
                            break;

                        case -9:
                            oApiResponse.OperationResult = -9;
                            sResultMessage = nLanguageID == 2 ? "Ticket Submission Interval Days reached." : "وصلت للفترة الزمنية لتقديم للمواضيع.";
                            oApiResponse.OperationResultMessage = sResultMessage;
                            break;

                        default:
                            oApiResponse.OperationResult = 0;
                            sResultMessage = nLanguageID == 2 ? "An error occurred during the operation. Please try again later." : "حدث خطأ  يرجى المحاولة لاحقا مرة أخرى.";
                            oApiResponse.OperationResultMessage = sResultMessage;
                            break;
                        }
                    }
                    return(Request.CreateResponse(HttpStatusCode.OK, oApiResponse));
                }
                catch (Exception ex)
                {
                    Elmah.ErrorLog.GetDefault(HttpContext.Current).Log(new Elmah.Error(ex));
                    oApiResponse.OperationResult        = 0;
                    oApiResponse.OperationResultMessage = nLanguageID == 2 ? "An error occurred during the operation. Please try again later." : "حدث خطأ  يرجى المحاولة لاحقا مرة أخرى.";
                    return(Request.CreateResponse(HttpStatusCode.InternalServerError, oApiResponse));
                }
            }
            oApiResponse.OperationResult        = 0;
            oApiResponse.OperationResultMessage = nLanguageID == 2 ? "validation failed": "خطاء في التحقق";
            return(Request.CreateResponse(HttpStatusCode.BadRequest, oApiResponse));
        }
示例#7
0
        public JsonResult JInserTicket(TicketViewModel oTicketViewModel)
        {
            Response           oResponseResult   = null;
            string             sRealFileName     = string.Empty;
            string             sModifiedFileName = string.Empty;
            HttpPostedFileBase filebase          = null;
            var oFile = System.Web.HttpContext.Current.Request.Files["TicketImage"];

            if (oFile != null)
            {
                filebase = new HttpPostedFileWrapper(oFile);
                if (filebase.ContentLength > 0)
                {
                    sRealFileName     = filebase.FileName;
                    sModifiedFileName = CommonHelper.AppendTimeStamp(filebase.FileName);
                    oTicketViewModel.DEFAULT_IMAGE = sModifiedFileName;
                }
            }

            oTicketViewModel.APPLICATION_ID          = CurrentApplicationID;
            oTicketViewModel.TICKET_CREATED_PLATFORM = (int)Infrastructure.Core.enmTicketPlatForm.Web;
            oTicketViewModel.CREATED_BY = Convert.ToInt32(CurrentUser.nUserID);

            oResponseResult = this.oITicketServices.oInsertTicket(oTicketViewModel, oTicketViewModel.MobileParticipantId);

            this.OperationResult = oResponseResult.OperationResult;

            switch (this.OperationResult)
            {
            case enumOperationResult.Success:

                if (oFile != null)
                {
                    FileAccessService oFileAccessService = new FileAccessService(CommonHelper.sGetConfigKeyValue(ConstantNames.FileAccessURL));

                    //DirectoryPath = Saved Application ID + Inserted Ticket ID
                    string sDirectoryPath = Path.Combine(this.CurrentApplicationID.ToString(), oResponseResult.ResponseID.ToString());
                    string sFullFilePath  = Path.Combine(sDirectoryPath, sModifiedFileName);
                    oFileAccessService.CreateDirectory(sDirectoryPath);
                    byte[] fileData = null;
                    using (var binaryReader = new BinaryReader(filebase.InputStream))
                    {
                        fileData = binaryReader.ReadBytes(filebase.ContentLength);
                    }
                    oFileAccessService.WirteFileByte(sFullFilePath, fileData);
                }

                #region :: Send Push Notification ::
                List <TicketMobileUserParticipantViewModel> lstTicketMobileUserParticipantViewModel = this.oITicketServices.IlGetTicketMobileUserParticipants(Convert.ToInt32(oResponseResult.ResponseID), -99);
                if (lstTicketMobileUserParticipantViewModel.Count > 0)
                {
                    foreach (var oTicketMobileUserParticipantViewModel in lstTicketMobileUserParticipantViewModel)
                    {
                        if (!oTicketMobileUserParticipantViewModel.DEVICE_ID.Equals(string.Empty))
                        {
                            PushNotification oPushNotification = new PushNotification();
                            oPushNotification.NotificationType  = enmNotificationType.Tickets;
                            oPushNotification.sHeadings         = oTicketMobileUserParticipantViewModel.TICKET_NAME;
                            oPushNotification.sContent          = string.Format("{0} {1}", CurrentUser.sUserFullNameEnglish, oTicketMobileUserParticipantViewModel.PreferedLanguage == Data.Core.Languages.English ? " has been created a ticket" : " تم إنشاء تذكرة");
                            oPushNotification.enmLanguage       = oTicketMobileUserParticipantViewModel.PreferedLanguage;
                            oPushNotification.sDeviceID         = oTicketMobileUserParticipantViewModel.DEVICE_ID;
                            oPushNotification.sOneSignalAppID   = this.CurrentApplicationOneSignalID;
                            oPushNotification.sOneSignalAuthKey = this.CurrentApplicationOneSignalAuthKey;
                            oPushNotification.SendPushNotification();
                            NotificationLogViewModel oNotificationLogViewModel = new NotificationLogViewModel();
                            oNotificationLogViewModel.APPLICATION_ID       = this.CurrentApplicationID;
                            oNotificationLogViewModel.NOTIFICATION_TYPE    = "tickets";
                            oNotificationLogViewModel.REQUEST_JSON         = oPushNotification.sRequestJSON;
                            oNotificationLogViewModel.RESPONSE_MESSAGE     = oPushNotification.sResponseResult;
                            oNotificationLogViewModel.MOBILE_NUMBERS       = oTicketMobileUserParticipantViewModel.PHONE_NUMBER;
                            oNotificationLogViewModel.IS_SENT_NOTIFICATION = oPushNotification.bIsSentNotification;
                            oICommonServices.oInsertNotificationLog(oNotificationLogViewModel);
                        }
                    }
                }
                #endregion

                this.OperationResultMessages = CommonResx.MessageAddSuccess;
                break;

            case enumOperationResult.Faild:
                this.OperationResultMessages = CommonResx.MessageAddFailed;
                break;
            }
            return(Json(
                       new
            {
                nResult = this.OperationResult,
                sResultMessages = this.OperationResultMessages
            },
                       JsonRequestBehavior.AllowGet));
        }
示例#8
0
        public JsonResult JSaveChatFile(int nTicketID, int nChatTypeID)
        {
            if (nTicketID != 99)
            {
                string sReplyImagePath      = string.Empty;
                string sReplyImageDirectory = string.Empty;
                string sFullFilePath        = string.Empty;
                if (System.Web.HttpContext.Current.Request.Files.AllKeys.Any())
                {
                    var oFile = System.Web.HttpContext.Current.Request.Files["ChatFile"];
                    HttpPostedFileBase filebase = new HttpPostedFileWrapper(oFile);

                    sReplyImageDirectory = Path.Combine(CurrentApplicationID.ToString(), nTicketID.ToString());

                    #region Create dynamic file name based on file type
                    enumFileTypes oEnumFileTypes = (enumFileTypes)Enum.Parse(typeof(enumFileTypes), nChatTypeID.ToString());
                    switch (oEnumFileTypes)
                    {
                    case enumFileTypes.png:
                        sReplyImagePath = CommonHelper.AppendTimeStamp("fake.png");
                        break;

                    case enumFileTypes.jpg:
                        sReplyImagePath = CommonHelper.AppendTimeStamp("fake.jpg");
                        break;

                    case enumFileTypes.jpeg:
                        sReplyImagePath = CommonHelper.AppendTimeStamp("fake.jpeg");
                        break;

                    case enumFileTypes.doc:
                        sReplyImagePath = CommonHelper.AppendTimeStamp("fake.doc");
                        break;

                    case enumFileTypes.docx:
                        sReplyImagePath = CommonHelper.AppendTimeStamp("fake.docx");
                        break;

                    case enumFileTypes.pdf:
                        sReplyImagePath = CommonHelper.AppendTimeStamp("fake.pdf");
                        break;
                    }
                    #endregion

                    sFullFilePath = Path.Combine(sReplyImageDirectory, sReplyImagePath);

                    TicketChatViewModel oTicketChatViewModel = new TicketChatViewModel()
                    {
                        TICKET_ID             = nTicketID,
                        REPLY_FILE_PATH       = sFullFilePath.Replace('\\', '/'),
                        TICKET_CHAT_TYPE_ID   = nChatTypeID,
                        TICKET_PARTICIPANT_ID = CurrentUser.nUserID
                    };

                    Response oResponse = this.oITicketServices.oInsertTicketChat(oTicketChatViewModel);
                    if (oResponse.OperationResult == enumOperationResult.Success)
                    {
                        SendTicketChatPushNotification(nTicketID, string.Empty, true, oTicketChatViewModel);
                        string sUserDeviceID = oResponse.ResponseCode;

                        if (!string.IsNullOrEmpty(sFullFilePath))
                        {
                            FileAccessService oFileAccessService = new FileAccessService(CommonHelper.sGetConfigKeyValue(ConstantNames.FileAccessURL));
                            MemoryStream      target             = new MemoryStream();
                            filebase.InputStream.CopyTo(target);
                            byte[] oArrImage = target.ToArray();

                            oFileAccessService.CreateDirectory(sReplyImageDirectory);
                            oFileAccessService.WirteFileByte(Path.Combine(sReplyImageDirectory, sReplyImagePath), oArrImage);
                        }
                        this.OperationResult = enumOperationResult.Success;
                    }
                    else
                    {
                        this.OperationResult = enumOperationResult.Faild;
                    }
                }

                switch (this.OperationResult)
                {
                case enumOperationResult.Success:
                    this.OperationResultMessages = CommonResx.MessageAddSuccess;
                    break;

                case enumOperationResult.Faild:
                    this.OperationResultMessages = CommonResx.MessageAddFailed;
                    break;
                }
            }
            return(Json(
                       new
            {
                nResult = this.OperationResult,
                sResultMessages = this.OperationResultMessages
            },
                       JsonRequestBehavior.AllowGet));
        }