Пример #1
0
        protected void gvAttachFiles_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row = gvAttachFiles.Rows[e.RowIndex];
            //Only 0-1 Element
            //AttachFile attachFile = ActiveAttachFiles.Single(a => a.ID == ((Label)row.FindControl("lblAttachFileId")).Text);
            //Only one more Element
            AttachFile attachFile    = ActiveAttachFiles.FirstOrDefault(a => a.ID == ((Label)row.FindControl("lblAttachFileId")).Text);
            TextBox    rowTextRemark = (TextBox)row.FindControl("txtDetailGv");

            AttachFile editAttachFile = attachFile.ConvertToAttachFileView();

            editAttachFile.REMARK      = (rowTextRemark == null) ? "" : rowTextRemark.Text;
            editAttachFile.FILE_STATUS = AttachFileStatus.Edit.Value();


            if (TempAttachFiles.Where(t => t.ATTACH_FILE_TYPE == editAttachFile.ATTACH_FILE_TYPE).Count() > 0)
            {
                AlertMessageShow(SysMessage.AttachFileDupicate);
            }
            else
            {
                _attachFiles.Add(editAttachFile);
            }

            gvAttachFiles.EditIndex = -1;

            ((DataControlField)gvAttachFiles.Columns
             .Cast <DataControlField>()
             .Where(fld => fld.HeaderText == "ดำเนินการ")
             .SingleOrDefault()).Visible = true;

            BindAttachFile();
        }
Пример #2
0
        protected void gvAttachFiles_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate) {

                String attachFileId = ((Label)e.Row.FindControl("lblAttachFileId")).Text;
                String fileStatus   = ((Label)e.Row.FindControl("lblFileStatus")).Text;
                //Only For 0-1 Element
                //AttachFile attachFile = AttachFiles.Single(a => a.ID == attachFileId && a.FILE_STATUS==fileStatus);
                //Only For one more Element
                AttachFile attachFile = AttachFiles.FirstOrDefault(a => a.ID == attachFileId && a.FILE_STATUS == fileStatus);
                if (attachFile != null)
                {
                    LinkButton lbnEditGv = (LinkButton)e.Row.FindControl("lbnEditGv");
                    LinkButton hplView   = (LinkButton)e.Row.FindControl("hplView");
                    LinkButton hplDelete = (LinkButton)e.Row.FindControl("hplDelete");
                    LinkButton hplCancel = (LinkButton)e.Row.FindControl("hplCancel");

                    Label lblDocumentName = (Label)e.Row.FindControl("lblDocumentName");
                    lblDocumentName.Text = ddlDocumentType.Items.FindByValue(attachFile.ATTACH_FILE_TYPE).Text;

                    //if (hplView != null) hplView.OnClientClick = LinkPopUp(attachFile.ATTACH_FILE_PATH);
                    if (_modeForm == DTO.DataActionMode.View)
                    {
                        BindingRowModeView(attachFile, lbnEditGv, hplView, hplDelete, hplCancel, e);
                    }
                    else
                    {
                        BindingRowMode(attachFile, lbnEditGv, hplView, hplDelete, hplCancel, e);
                    }
                }
                //}
            }
        }
Пример #3
0
        protected override string GetFileFullName(Guid attId)
        {
            string fileFullName              = "";
            string attRootDir                = Server.MapPath(string.Format("~/{0}", ConfigurationManager.AppSettings["AttRootDir"]));
            ArticlePublisherLogic artPub     = new ArticlePublisherLogic(null);
            AttachFile            attachFile = artPub.GetAttachFileDataForBackend(attId);

            if (attachFile == null)
            {
                logger.ErrorFormat("can't get data of attId[{0}]", attId);
                return("");
            }

            string filePath      = attachFile.FilePath;
            string fileSavedName = attachFile.FileSavedName;

            // update readCount
            if (!isInBackend)
            {
                artPub.IncreaseAttachFileMultiLangReadCount(attId, qsCultureNameOfLangNo);
            }

            fileFullName = string.Format("{0}{1}/{2}", attRootDir, filePath, fileSavedName);

            return(fileFullName);
        }
        public void SaveUserPhoto(string UserName, string fileName, string strExt, string strSaveFileName)
        {
            var guid = Guid.NewGuid();

            AttachFile files = new AttachFile();

            files.FileId         = guid.ToString();
            files.FileType       = "USER_PROFILE";
            files.OriginFileName = fileName;
            files.FileExtension  = strExt;
            files.SaveAsFileName = strSaveFileName;
            files.FilePath       = "/Files/Userpic/";
            files.IsDelete       = 0;
            files.CreateId       = System.Web.HttpContext.Current.User.Identity.GetUserId();
            files.CreateDt       = DateTime.Now;

            context.AttachFiles.Add(files);

            var users = context.UserProfiles.Find(UserName);

            var userpro = context.UserProfiles.Where(x => x.UserId == UserName);

            foreach (var item in userpro)
            {
                item.UserPic = guid.ToString();
            }

            context.SaveChanges();
        }
Пример #5
0
        public void SaveCustomerPhoto(string custId, string fileName, string strExt, string strSaveFileName)
        {
            var guid = Guid.NewGuid();

            AttachFile files = new AttachFile();

            files.FileId         = guid.ToString();
            files.FileType       = "CUSTOMER_LOGO";
            files.OriginFileName = fileName;
            files.FileExtension  = strExt;
            files.SaveAsFileName = strSaveFileName;
            files.FilePath       = "/Files/Customerpic/";
            files.IsDelete       = 0;
            files.CreateId       = System.Web.HttpContext.Current.User.Identity.GetUserId();
            files.CreateDt       = DateTime.Now;

            context.AttachFiles.Add(files);

            //var results = context.Customers.Find(custName);

            var results = context.Customers.Where(x => x.CustomerId == custId);

            foreach (var item in results)
            {
                item.CustomerPic = guid.ToString();
            }

            context.SaveChanges();
        }
Пример #6
0
        public IHttpActionResult Post(AttachFile baseRequest)
        {
            baseRequest.OrgId = SecurityHelper.CurrentPrincipal.OrgId;

            var response = service.SaveAttachFile(baseRequest);

            return(Ok(response));
        }
Пример #7
0
        private void SwitchControler(AttachFile attachFile, AttachFileStatus status, LinkButton lbnEditGv, LinkButton hplView, LinkButton hplDelete, LinkButton hplCancel)
        {
            switch (status)
            {
            case AttachFileStatus.Active:
                if (lbnEditGv != null)
                {
                    lbnEditGv.Visible = true;
                }
                if (hplDelete != null)
                {
                    lbnEditGv.Visible = true;
                }
                if (hplCancel != null)
                {
                    lbnEditGv.Visible = true;
                }
                if (hplView != null)
                {
                    hplView.Visible       = true;
                    hplView.OnClientClick = LinkPopUp(attachFile.ATTACH_FILE_PATH);
                }
                break;

            case AttachFileStatus.Edit:
                if (lbnEditGv != null)
                {
                    lbnEditGv.Visible = true;
                }
                if (hplDelete != null)
                {
                    lbnEditGv.Visible = true;
                }
                if (hplCancel != null)
                {
                    lbnEditGv.Visible = true;
                }
                if (hplView != null)
                {
                    hplView.Visible       = true;
                    hplView.OnClientClick = LinkPopUp(attachFile.ATTACH_FILE_PATH);
                }
                break;

            case AttachFileStatus.Wait:
                break;

            case AttachFileStatus.Delete:
                break;

            default:
                break;
            }
        }
Пример #8
0
        public bool SendMail(string strSender, string strReceiver, string strCC, string strBcc, AttachFile[] AttachFiles, string strSubject, string strContent, bool bIsHtml, string strCreateBy, string strSysID)
        {
            Common.Util.MessageUtil message = new Common.Util.MessageUtil("smtp.163.com", "*****@*****.**", "justinle", "justinle", "052924e*fa!");
            EMailContent content = new Common.Util.EMailContent();
            content.Subject = "test";
            content.ToAddress = strReceiver.Split(';').ToList();
            content.Content = "test aaa";

            message.Send(content);
            return true;
        }
Пример #9
0
        private string ProcessUploadFiles()
        {
            string UploadsFolder =
                Path.Combine(WebHostEnvironment.WebRootPath, "AttachFiles");
            string UniqeFileName = Guid.NewGuid().ToString() + "_" + Path.GetFileName(AttachFile.FileName);
            string FilePath      = Path.Combine(UploadsFolder, UniqeFileName);

            using (var FileStream = new FileStream(FilePath, FileMode.Create))
            {
                AttachFile.CopyTo(FileStream);
            }

            return(FilePath);
        }
Пример #10
0
        protected void hplDelete_Click(object sender, EventArgs e)
        {
            try
            {
                var gr = (GridViewRow)((LinkButton)sender).NamingContainer;

                String attachFileId    = ((Label)gr.FindControl("lblAttachFileId")).Text;
                String lblDocumentCode = ((Label)gr.FindControl("lblDocumentCode")).Text;
                String fileStatus      = ((Label)gr.FindControl("lblFileStatus")).Text;

                AttachFile attachFile = _attachFiles.Single(a => a.ATTACH_FILE_TYPE == lblDocumentCode && a.FILE_STATUS == fileStatus);

                if (attachFile.FILE_STATUS == AttachFileStatus.Active.Value())
                {
                    AttachFile tempAtachFile = TempAttachFiles.SingleOrDefault(p => p.ATTACH_FILE_TYPE == attachFile.ATTACH_FILE_TYPE);

                    if (tempAtachFile == null)
                    {
                        DateTime   dateNow      = DateTime.Now;
                        AttachFile deleteAttach = new AttachFile();
                        deleteAttach              = attachFile.ConvertToAttachFileView();
                        deleteAttach.FILE_STATUS  = AttachFileStatus.Delete.Value();
                        deleteAttach.CREATED_DATE = dateNow;
                        deleteAttach.UPDATED_DATE = dateNow;
                        _attachFiles.Add(deleteAttach);
                        BindAttachFile();
                        return;
                    }
                    else if (tempAtachFile.FILE_STATUS == AttachFileStatus.Edit.Value())
                    {
                        _attachFiles.Remove(tempAtachFile);
                        DateTime   dateNow      = DateTime.Now;
                        AttachFile deleteAttach = attachFile.ConvertToAttachFileView();
                        deleteAttach.FILE_STATUS  = AttachFileStatus.Delete.Value();
                        deleteAttach.CREATED_DATE = dateNow;
                        deleteAttach.UPDATED_DATE = dateNow;
                        _attachFiles.Add(deleteAttach);
                        BindAttachFile();
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                AlertMessageShow(ex.Message);
            }

            udpAttachFiles.Update();
        }
Пример #11
0
        public List <AttachFileView> DeleteAttachFile(AttachFileView model)
        {
            using (var ctx = new ConXContext())
            {
                using (var scope = new TransactionScope())
                {
                    AttachFile remove = ctx.AttachFiles.Where(x => x.attachFileId == model.attachFileId).SingleOrDefault();
                    ctx.AttachFiles.Remove(remove);
                    ctx.SaveChanges();

                    var result = InquiryAttachFile(ctx, model.refTransactionId, model.docCode);

                    scope.Complete();
                    return(result);
                }
            }
        }
Пример #12
0
        public override Guid GetArticleId()
        {
            if (qsAct == ConfigFormAction.add)
            {
                return(qsArtId);
            }

            ArticlePublisherLogic artPub = new ArticlePublisherLogic();
            AttachFile            att    = artPub.GetAttachFileDataForBackend(qsAttId);
            Guid articleId = Guid.Empty;

            if (att != null)
            {
                articleId = att.ArticleId.Value;
            }

            return(articleId);
        }
        public string GetAttachFileID()
        {
            AttachFile attachfile = new AttachFile();
            var        mylist     = this.ListAttachFile().ToList();

            if (mylist.Count == 0)
            {
                attachfile.AttchFileID = "0000000001";
            }
            else
            {
                string s = ((from x in mylist
                             select new { x.AttchFileID }).Last()).AttchFileID.ToString();
                int    lastint = Int32.Parse(s.Substring(0, 10)) + 1;
                string myid    = String.Format("{0:0000000000}", lastint);
                string autoid  = myid.ToString();
                attachfile.AttchFileID = autoid;
            }
            return(attachfile.AttchFileID);
        }
Пример #14
0
 private void BindingRowModeView(AttachFile attachFile, LinkButton lbnEditGv, LinkButton hplView, LinkButton hplDelete, LinkButton hplCancel, GridViewRowEventArgs e)
 {
     if (lbnEditGv != null)
     {
         lbnEditGv.Visible = false;
     }
     if (hplView != null)
     {
         hplView.Visible       = true;
         hplView.OnClientClick = LinkPopUp(attachFile.ATTACH_FILE_PATH);
     }
     if (hplDelete != null)
     {
         hplDelete.Visible = false;
     }
     if (hplCancel != null)
     {
         hplCancel.Visible = false;
     }
 }
Пример #15
0
        private AttachFile ConcreateFromControl()
        {
            //var head = this.MasterLicense.PersonLicenseH;
            //var detail = this.MasterLicense.PersonLicenseD;

            DateTime curDate = DateTime.Now;
            //AttachFile attachFile = new AttachFile()
            //{
            //    ID = IAS.BLL.Helpers.GenerateIdHelper.GetGenAutoId(),
            //    REGISTRATION_ID = RegisterationId,
            //    ATTACH_FILE_TYPE = ddlDocumentType.SelectedValue,
            //    ATTACH_FILE_PATH = fulAttachFile.FileName,
            //    REMARK = txtRemark.Text,
            //    CREATED_BY = CurrentUser,
            //    CREATED_DATE = curDate,
            //    UPDATED_BY = CurrentUser,
            //    UPDATED_DATE = curDate,
            //    FILE_STATUS = AttachFileStatus.Wait.Value(),
            //    GROUP_LICENSE_ID = this.MasterLicense.PersonLicenseH[0].UPLOAD_GROUP_NO,
            //    ID_CARD_NO = this.MasterLicense.PersonLicenseD[0].ID_CARD_NO
            //};

            AttachFile attachFile = new AttachFile()
            {
                ID = IAS.BLL.Helpers.GenerateIdHelper.GetGenAutoId(),
                REGISTRATION_ID  = RegisterationId,
                ATTACH_FILE_TYPE = ddlDocumentType.SelectedValue,
                ATTACH_FILE_PATH = fulAttachFile.FileName,
                REMARK           = txtRemark.Text,
                CREATED_BY       = CurrentUser,
                CREATED_DATE     = curDate,
                UPDATED_BY       = CurrentUser,
                UPDATED_DATE     = curDate,
                FILE_STATUS      = AttachFileStatus.Wait.Value(),
                GROUP_LICENSE_ID = this.MasterLicense.CurrentUploadGroupNO,
                ID_CARD_NO       = this.UserProfile.IdCard
            };


            return(attachFile);
        }
Пример #16
0
        public ActionResult SaveAttachment(AttachFile attachFile)
        {
            string fileName = string.Empty;

            try
            {
                string fileDir = Path.Combine(m_AttachBaseDir, attachFile.SurveyId.ToString());
                Directory.CreateDirectory(fileDir);
                //attachFile.FileName.Replace("")
                fileName = string.Format("{0}-{1:yy-MM-dd-mm-ss}-{2}", attachFile.SurveyId, DateTime.Now, attachFile.FileName);
                string filePath = Path.Combine(fileDir,
                                               fileName);

                System.IO.File.WriteAllBytes(filePath, Convert.FromBase64String(attachFile.Document));
            }
            catch (Exception e)
            {
                //Logger.LogMessage(LogInfo.Error, "could not save attach file\n" + e);
                throw;
            }
            return(Json(new { result = "OK", fileName = Path.Combine(attachFile.SurveyId.ToString(), fileName) }));
        }
Пример #17
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (AttachFile.HasFile)
        {
            string FileName     = this.AttachFile.FileName;              //获取上传文件的文件名,包括后缀
            string ExtenName    = System.IO.Path.GetExtension(FileName); //获取扩展名
            string SaveFileName = System.IO.Path.Combine(
                Request.PhysicalApplicationPath + SaveFilePath,
                DateTime.Now.ToString("yyyyMMddhhmmss") + ExtenName);                                                                             //合并两个路径为上传到服务器上的全路径
            AttachFile.MoveTo(SaveFileName, Brettle.Web.NeatUpload.MoveToOptions.Overwrite);
            string url      = Request.Url.GetLeftPart(UriPartial.Authority) + SaveFilePath + DateTime.Now.ToString("yyyyMMddhhmmss") + ExtenName; //文件保存的路径
            float  FileSize = (float)System.Math.Round((float)AttachFile.ContentLength / 1024000, 1);                                             //获取文件大小并保留小数点后一位,单位是M

            WORDERSATTACHMENTS model = new WORDERSATTACHMENTS();
            model.ModelNo       = Request["ModelNo"];
            model.Filename      = FileName;
            model.FilePath      = url;
            model.CreateDate    = DateTime.Now;
            model.BelongFactory = LoginUser.BelongFactory;
            servComm.Add(model);

            BindList();
        }
    }
Пример #18
0
        protected virtual bool LoadData()
        {
            bool result = false;

            if (attId != Guid.Empty)
            {
                ArticlePublisherLogic artPub = new ArticlePublisherLogic(null);
                AttachFile            att    = artPub.GetAttachFileDataForBackend(attId);

                if (att == null)
                {
                    errState = AttFileErrState.LoadDataFailed;
                    return(false);
                }

                contextId     = att.ArticleId;
                filePath      = att.FilePath;
                fileSavedName = att.FileSavedName;
                fileSize      = att.FileSize;
                sortNo        = att.SortNo.Value;
                fileMIME      = att.FileMIME;
                dontDelete    = att.DontDelete;
                fileFullName  = string.Format("{0}{1}/{2}", GetAttRootDirectoryFullName(), filePath, fileSavedName);
                postAccount   = att.PostAccount;
                postDate      = att.PostDate.Value;

                if (att.MdfDate.HasValue)
                {
                    mdfAccount = att.MdfAccount;
                    mdfDate    = att.MdfDate.Value;
                }

                //zh-TW
                if (LangManager.IsEnableEditLangZHTW())
                {
                    AttachFileMultiLang attZhTw = artPub.GetAttachFileMultiLangDataForBackend(attId, LangManager.CultureNameZHTW);

                    if (attZhTw == null)
                    {
                        errState = AttFileErrState.LoadMultiLangDataFailed;
                        return(false);
                    }

                    attSubjectZhTw   = attZhTw.AttSubject;
                    isShowInLangZhTw = attZhTw.IsShowInLang;
                    readCountZhTw    = attZhTw.ReadCount;

                    if (attZhTw.MdfDate.HasValue)
                    {
                        DateTime mdfDateZhTw = attZhTw.MdfDate.Value;

                        if (!mdfDate.HasValue || mdfDateZhTw > mdfDate.Value)
                        {
                            mdfAccount = attZhTw.MdfAccount;
                            mdfDate    = mdfDateZhTw;
                        }
                    }
                }

                //en
                if (LangManager.IsEnableEditLangEN())
                {
                    AttachFileMultiLang attEn = artPub.GetAttachFileMultiLangDataForBackend(attId, LangManager.CultureNameEN);

                    if (attEn == null)
                    {
                        errState = AttFileErrState.LoadMultiLangDataFailed;
                        return(false);
                    }

                    attSubjectEn   = attEn.AttSubject;
                    isShowInLangEn = attEn.IsShowInLang;
                    readCountEn    = attEn.ReadCount;

                    if (attEn.MdfDate.HasValue)
                    {
                        DateTime mdfDateEn = attEn.MdfDate.Value;

                        if (!mdfDate.HasValue || mdfDateEn > mdfDate.Value)
                        {
                            mdfAccount = attEn.MdfAccount;
                            mdfDate    = mdfDateEn;
                        }
                    }
                }

                result = true;
            }
            else if (contextId != null)
            {
                // new one
                sortNo = GetNextSortNo();

                result = true;
            }

            return(result);
        }
Пример #19
0
        public void Post([FromUri] SavefileModel Value)
        {
            if (string.IsNullOrEmpty(Value.tokenId))
            {
                result = falseresult("UnAuthorized.");
            }
            if (!IsValidateToken(Value.tokenId))
            {
                result = falseresult("UnAuthorized.");
            }
            //ComplainsMapDao ComMApDao = new ComplainsMapDao();
            //var CompTemp = ComMApDao.FindByComplain_Code_ID(Value.Complain_Code).FirstOrDefault();

            //var Obj = Value.File.fileupload(CompTemp.Keygen, Value.Description, Value.Filename, Value.TypeFile);


            //Complains_FileUploadMapDao FileMap = new Complains_FileUploadMapDao();
            //Complains_FileUpload Fileobj = new Complains_FileUpload();
            //Fileobj.ComplainID = CompTemp.ID;
            //Fileobj.TypeAtID = 11;
            //Fileobj.Description = Value.Description;
            //Fileobj.Qty = 1;
            //Fileobj.Keygen = Guid.NewGuid().ToString();
            //Fileobj.Active = true;
            //Fileobj.CreateDate = DateTime.Now;
            //FileMap.Add(Fileobj);
            //FileMap.CommitChange();
            //foreach (var items in Obj)
            //{
            //    AttachFileMapDao AttachMap = new AttachFileMapDao();
            //    AttachFile _fileObj = new AttachFile();
            //    _fileObj.GUID = Fileobj.Keygen;
            //    _fileObj.path = items.path;
            //    _fileObj.Folder = items.folder;
            //    //_fileObj.Title = File.file_name;
            //    _fileObj.FileName = items.file_name;
            //    _fileObj.FileType = items.file_Type;
            //    _fileObj.CreateDate = DateTime.Now;
            //    _fileObj.Active = true;
            //    AttachMap.Add(_fileObj);
            //    AttachMap.CommitChange();
            //}

            try
            {
                var queryString = this.Request.GetQueryNameValuePairs();
                var httpRequest = HttpContext.Current.Request;
                if (httpRequest.Files.Count > 0)
                {
                    var docfiles = new List <string>();
                    foreach (string file in httpRequest.Files)
                    {
                        HttpPostedFile             postedFile = httpRequest.Files[file];
                        ComplainsMapDao            ComMApDao  = new ComplainsMapDao();
                        var                        CompTemp   = ComMApDao.FindByComplain_Code_ID(Value.Complain_Code).FirstOrDefault();
                        var                        Obj        = postedFile.fileupload(CompTemp.Keygen, Value.Description);
                        Complains_FileUploadMapDao FileMap    = new Complains_FileUploadMapDao();
                        Complains_FileUpload       Fileobj    = new Complains_FileUpload();
                        Fileobj.ComplainID  = CompTemp.ID;
                        Fileobj.TypeAtID    = 11;
                        Fileobj.Description = Value.Description;
                        Fileobj.Qty         = 1;
                        Fileobj.Keygen      = Guid.NewGuid().ToString();
                        Fileobj.Active      = true;
                        Fileobj.CreateDate  = DateTime.Now;
                        FileMap.Add(Fileobj);
                        FileMap.CommitChange();
                        foreach (var items in Obj)
                        {
                            AttachFileMapDao AttachMap = new AttachFileMapDao();
                            AttachFile       _fileObj  = new AttachFile();
                            _fileObj.GUID   = Fileobj.Keygen;
                            _fileObj.path   = items.path;
                            _fileObj.Folder = items.folder;
                            //_fileObj.Title = File.file_name;
                            _fileObj.FileName   = items.file_name;
                            _fileObj.FileType   = items.file_Type;
                            _fileObj.CreateDate = DateTime.Now;
                            _fileObj.Active     = true;
                            AttachMap.Add(_fileObj);
                            AttachMap.CommitChange();
                        }
                    }
                }
            }
            catch (IOException)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }


            HttpResponseMessage response = new HttpResponseMessage();

            response.StatusCode = HttpStatusCode.Created;
            //return response;
            result = Trueresult(response);
            HttpContext.Current.Response.ContentType = "application/json";
            HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result));
            HttpContext.Current.Response.End();
        }
Пример #20
0
        private void btn_newLetter_Click(object sender, EventArgs e)
        {
            if (txt_subject.Text.Trim() == "" || txt_chekideh.Text.Trim() == "" || advancedTextEditor_matn.TextEditor.Text.Trim() == "")
            {
                MessageBox.Show("Please enter the full letter information");
                return;
            }


            if (this.FormType == 1)
            {
                using (TransactionScope ts = new TransactionScope())

                {
                    try
                    {
                        Letter L = new Letter();
                        L.subject = txt_subject.Text.Trim();
                        L.abstrct = txt_chekideh.Text.Trim();
                        L.matn    = advancedTextEditor_matn.TextEditor.Text;

                        ///Make a letter number
                        {
                            /// Year + User job level + / + Last ID Letter +1
                            var Last_LetterID = (from Leter in database.Letters orderby Leter.LetterId descending select Leter).First();
                            L.letterNo = PublicVariable.TodayDate.Substring(2, 2) + PublicVariable.gDetermineJobsLevel + "/" + (Last_LetterID.LetterId + 1);
                        }

                        L.createDate = lbl_createDate.Text;
                        L.userID     = PublicVariable.gUserId;

                        if (rdb_tabaghe_adi.Checked)
                        {
                            L.SecurityType = 1;
                        }
                        else if (rdb_tabaghe_mahramane.Checked)
                        {
                            L.SecurityType = 2;
                        }
                        else if (rdb_tabaghe_seri.Checked)
                        {
                            L.SecurityType = 3;
                        }


                        if (rdb_foriyat_adi.Checked)
                        {
                            L.ForceType = 1;
                        }
                        else if (rdb_foriyat_fori.Checked)
                        {
                            L.ForceType = 2;
                        }
                        else if (rdb_foriyat_ani.Checked)
                        {
                            L.ForceType = 3;
                        }

                        L.BayganiType = 1;

                        if (rdb_peygiri_darad.Checked)
                        {
                            L.PeygiryType = 1;
                        }
                        else if (rdb_peygiri_nadarad.Checked)
                        {
                            L.PeygiryType = 2;
                        }

                        if (rdb_peyvast_darad.Checked)
                        {
                            L.AttachmentType = 1;
                        }
                        else if (rdb_peyvast_nadarad.Checked)
                        {
                            L.AttachmentType = 2;
                        }


                        //    L.ReadType = 1;
                        if (this.IsReply == 1)// reply
                        {
                            L.LetterType = 2;
                        }
                        else
                        {
                            L.LetterType = 1;
                        }


                        L.DraftType = 1;

                        if (rdb_mohlat_darad.Checked)
                        {
                            L.answerType     = 1;
                            L.answerDeadline = string.Format("{0:yyyy/MM/dd}", Convert.ToDateTime(persianDateTimePicker_mohlatPasokh.Value.Year + "/" + persianDateTimePicker_mohlatPasokh.Value.Month + "/" + persianDateTimePicker_mohlatPasokh.Value.Day));
                        }
                        else if (rdb_mohlat_nadarad.Checked)
                        {
                            L.answerType    = 2;
                            L.Reffrence     = this.Get_LetterNo;
                            L.replyLetterId = this.Get_LetterID;
                        }

                        database.Letters.Add(L);
                        database.SaveChanges();


                        ///////// Attach File

                        if (rdb_peyvast_darad.Checked == true)
                        {
                            if (lbl_path.Text != "")
                            {
                                FileStream objFileStream = new FileStream(lbl_path.Text, FileMode.Open, FileAccess.Read);
                                int        intLength     = Convert.ToInt32(objFileStream.Length);
                                byte[]     objData;
                                objData = new byte[intLength];
                                String[] strPath = lbl_path.Text.Split(Convert.ToChar(@"\"));

                                objFileStream.Read(objData, 0, intLength);
                                objFileStream.Close();

                                AttachFile AF = new AttachFile();
                                AF.FileSize = intLength / 1024; ///KB
                                AF.FileName = strPath[strPath.Length - 1];
                                AF.FileData = objData;
                                AF.LetterID = L.LetterId;

                                database.AttachFiles.Add(AF);
                                database.SaveChanges();
                            }
                        }

                        ts.Complete();

                        if (this.IsReply == 1)
                        {
                            MessageBox.Show("The reply was successfully created and moved to the drafts section.");
                        }
                        else
                        {
                            MessageBox.Show("The letter was successfully created and moved to the drafts section.");
                        }
                    }
                    catch
                    {
                        MessageBox.Show("There is a problem with the server. try again.");
                    }
                }
            }


            else if (this.FormType == 2)  //edit
            {
                using (TransactionScope ts = new TransactionScope())

                {
                    try
                    {
                        var query_update = (from L in database.Letters where L.LetterId == this.Get_LetterID where L.userID == PublicVariable.gUserId select L).SingleOrDefault();


                        query_update.subject    = txt_subject.Text.Trim();
                        query_update.abstrct    = txt_chekideh.Text.Trim();
                        query_update.matn       = advancedTextEditor_matn.TextEditor.Text;
                        query_update.createDate = lbl_createDate.Text;

                        if (rdb_tabaghe_adi.Checked)
                        {
                            query_update.SecurityType = 1;
                        }
                        else if (rdb_tabaghe_mahramane.Checked)
                        {
                            query_update.SecurityType = 2;
                        }
                        else if (rdb_tabaghe_seri.Checked)
                        {
                            query_update.SecurityType = 3;
                        }


                        if (rdb_foriyat_adi.Checked)
                        {
                            query_update.ForceType = 1;
                        }
                        else if (rdb_foriyat_fori.Checked)
                        {
                            query_update.ForceType = 2;
                        }
                        else if (rdb_foriyat_ani.Checked)
                        {
                            query_update.ForceType = 3;
                        }



                        if (rdb_peygiri_darad.Checked)
                        {
                            query_update.PeygiryType = 1;
                        }
                        else if (rdb_peygiri_nadarad.Checked)
                        {
                            query_update.PeygiryType = 2;
                        }

                        if (rdb_peyvast_darad.Checked)
                        {
                            query_update.AttachmentType = 1;
                        }
                        else if (rdb_peyvast_nadarad.Checked)
                        {
                            ///پیوست ندارد
                            query_update.AttachmentType = 2;
                        }


                        if (rdb_mohlat_darad.Checked)
                        {
                            query_update.answerType     = 1;
                            query_update.answerDeadline = string.Format("{0:yyyy/MM/dd}", Convert.ToDateTime(persianDateTimePicker_mohlatPasokh.Value.Year + "/" + persianDateTimePicker_mohlatPasokh.Value.Month + "/" + persianDateTimePicker_mohlatPasokh.Value.Day));
                        }
                        else if (rdb_mohlat_nadarad.Checked)
                        {
                            query_update.answerType     = 2;
                            query_update.answerDeadline = "";
                        }

                        database.SaveChanges();

                        ///////// attach file

                        if (rdb_peyvast_darad.Checked == true)
                        {
                            if (lbl_path.Text != "")
                            {
                                var query_checkAttachment = (from AF in database.AttachFiles where AF.LetterID == Get_LetterID select AF).ToList();

                                //The letter has not had attachment but now it has
                                if (query_checkAttachment.Count == 0)
                                {
                                    FileStream objfilestream = new FileStream(lbl_path.Text, FileMode.Open, FileAccess.Read);
                                    int        intlength     = Convert.ToInt32(objfilestream.Length);
                                    byte[]     objdata;
                                    objdata = new byte[intlength];
                                    string[] strpath = lbl_path.Text.Split(Convert.ToChar(@"\"));

                                    objfilestream.Read(objdata, 0, intlength);
                                    objfilestream.Close();
                                    AttachFile af = new AttachFile();
                                    af.FileSize = intlength / 1024; ///kb
                                    af.FileName = strpath[strpath.Length - 1];
                                    af.FileData = objdata;
                                    af.LetterID = this.Get_LetterID;

                                    database.AttachFiles.Add(af);
                                    database.SaveChanges();
                                }
                                else if (query_checkAttachment.Count == 1)                  // The letter has already had attachment and still has
                                {
                                    if (lbl_path.Text != query_checkAttachment[0].FileName) ///The letter already has an attachment, but it is the same as the previous file
                                    {
                                        FileStream objfilestream = new FileStream(lbl_path.Text, FileMode.Open, FileAccess.Read);
                                        int        intlength     = Convert.ToInt32(objfilestream.Length);
                                        byte[]     objdata;
                                        objdata = new byte[intlength];
                                        string[] strpath = lbl_path.Text.Split(Convert.ToChar(@"\"));

                                        objfilestream.Read(objdata, 0, intlength);
                                        objfilestream.Close();

                                        var query_updateAttach = (from AF in database.AttachFiles where AF.LetterID == this.Get_LetterID select AF).SingleOrDefault();

                                        query_updateAttach.FileSize = intlength / 1024; ///kb
                                        query_updateAttach.FileName = strpath[strpath.Length - 1];
                                        query_updateAttach.FileData = objdata;

                                        database.SaveChanges();
                                    }
                                }
                            }
                        }
                        else if (rdb_peyvast_nadarad.Checked = true)   ///If it already had it, but not now
                        {
                            try
                            {
                                var query_checkAttachment = (from AF in database.AttachFiles where AF.LetterID == this.Get_LetterID select AF).ToList();
                                if (query_checkAttachment.Count > 0)
                                {
                                    var query_delete = (from AF in database.AttachFiles where AF.LetterID == this.Get_LetterID select AF).SingleOrDefault();
                                    database.AttachFiles.Remove(query_delete);
                                    database.SaveChanges();
                                }
                            }
                            catch
                            {
                                MessageBox.Show("There is a problem with the server. try again");
                                return;
                            }
                        }

                        ts.Complete();


                        MessageBox.Show("The letter was successfully edited and moved to the drafts section.");
                    }
                    catch
                    {
                        MessageBox.Show("There is a problem with the server. try again.");
                        return;
                    }
                }
            }
        }
Пример #21
0
        /// <summary>
        /// Function used for Edit & review page for the single Request
        /// </summary>
        /// <param name="ReferID">ReferenceID</param>
        /// <param name="UserId">UserId for checking authentication</param>
        /// <param name="Type">Review or DraftEdit</param>
        /// SP  : K2_Review , K2_ReviewCC
        /// <returns></returns>
        public List <Review> GetRequestDetails(string ReferID, string UserId, string ProInstID, string Type)
        {
            List <RequestReview> MList        = new List <RequestReview>();
            List <CC>            CClist       = new List <CC>();
            List <Review>        FormRequests = new List <Review>();

            try
            {
                SqlParameter[] sqlp =
                {
                    new SqlParameter("ReferID",   ReferID),
                    new SqlParameter("UserId",    UserId),
                    new SqlParameter("Type",      Type),
                    new SqlParameter("ProInstID", DBNull.Value)
                };
                if (!string.IsNullOrEmpty(ProInstID))
                {
                    sqlp[3].Value = ProInstID;
                }
                MList = Db.Database.SqlQuery <RequestReview>("exec [K2_Review_new] @ReferID,@UserId,@Type,@ProInstID", sqlp).ToList();
                SqlParameter[] sqlp1 =
                {
                    new SqlParameter("ReferID", ReferID),
                    new SqlParameter("UserId",  UserId),
                    new SqlParameter("Type",    Type)
                };
                CClist = Db.Database.SqlQuery <CC>("exec [K2_ReviewCC] @ReferID,@UserId,@Type", sqlp1).ToList();

                if (MList != null)
                {
                    foreach (int FormGUID in MList.Select(P => P.FormID).Distinct())
                    {
                        Review Rev     = new Review();
                        var    request = MList.Where(P => P.FormID == FormGUID).FirstOrDefault();
                        Rev.FormID              = FormGUID;
                        Rev.ProcInstID          = request.ProcInstID;
                        Rev.ReferenceID         = request.ReferenceID;
                        Rev.FormStatus          = request.FormStatus;
                        Rev.CreatedOn           = request.CreatedOn;
                        Rev.PreparerEMP         = request.PreparerEMP;
                        Rev.PreparerUserID      = request.PreparerUserID;
                        Rev.PreparerFNAME       = request.PreparerFNAME;
                        Rev.ApplicantEMP        = request.ApplicantEMP;
                        Rev.ApplicantUserID     = request.ApplicantUserID;
                        Rev.ApplicantFNAME      = request.ApplicantFNAME;
                        Rev.DEPT                = request.DEPT;
                        Rev.Title               = request.Title;
                        Rev.Location            = request.Location;
                        Rev.ApproverEmp         = request.ApproverEMP;
                        Rev.ApproverUserID      = request.ApproverUserID;
                        Rev.ApproverFNAME       = request.ApproverFNAME;
                        Rev.Justification       = request.Justification;
                        Rev.EDeliveryDate       = request.EDeliveryDate;
                        Rev.DurationOfUse       = request.DurationOfUse;
                        Rev.EstimatedCost       = request.EstimatedCost;
                        Rev.BudgetProvided      = request.BudgetProvided;
                        Rev.BudgetSum           = request.BudgetSum;
                        Rev.Remark              = request.Remark;
                        Rev.ActionTakerUserID   = request.ActionTakerUserID;
                        Rev.ActionTakerFullName = request.ActionTakerFullName;
                        //Rev.ActionTakerStatus = request.ActionTakerStatus;
                        Rev.ITSApproverUserID   = request.ITSApproverUserID;
                        Rev.ITSApproverFullName = request.ITSApproverFullName;
                        //Rev.ITSApproverStatus = request.ITSApproverStatus;
                        //Rev.Status = request.Status;
                        Rev.DisplayStatus          = request.DisplayStatus;
                        Rev.ActionTakerServiceType = request.ActionTakerServiceType;
                        List <Employee> CC1 = new List <Employee>();
                        foreach (string mm in CClist.Where(k => k.Type == "CC").Select(k => k.UID).Distinct())
                        {
                            CC1.Add(new Employee {
                                USERID = mm, FULLNAME = CClist.Where(k => k.Type == "CC" && k.UID == mm).Select(k => k.UName).FirstOrDefault()
                            });
                        }
                        if (CC1.Count > 0)
                        {
                            Rev.RequestCC = CC1;
                        }
                        else
                        {
                            Rev.RequestCC = null;
                        }
                        AttachFile    Attach    = new AttachFile();
                        List <string> FileNames = new List <string>();
                        FileNames = CClist.Where(k => k.Type == "Attachment").Select(k => k.UID).Distinct().ToList();
                        if (FileNames.Count > 0)
                        {
                            Attach.FileName = FileNames;
                        }
                        else
                        {
                            Attach.FileName = null;
                        }
                        Rev.Attachment = Attach;
                        Rev.ProcessLog = Db.ProcessLogs.Where(P => P.FormID == Rev.FormID && (P.ProcInstID.ToString() == Rev.ProcInstID || P.ProcInstID.ToString() == ProInstID) && P.ActionResult != "Forwarded").ToList();
                        foreach (var plog in Rev.ProcessLog)
                        {
                            //ProcessActionList pa = Db.ProcessActionLists.Where(P => P.K2ActionName == plog.ActionResult).FirstOrDefault();
                            var pa = (from a in Db.ProcessStepLists
                                      join b in Db.ProcessActionLists on a.StepID equals b.StepID into ps
                                      from b in ps.DefaultIfEmpty()
                                      where a.K2StepName == plog.ActivityName && b.K2ActionName == plog.ActionResult
                                      select b.ActionDisplayName
                                      ).FirstOrDefault();
                            if (pa != null)
                            {
                                plog.ActionResult = pa;
                            }
                        }

                        Rev.Attachments = Db.RequestFormAttachments.Where(P => P.FormID == Rev.FormID).ToList();
                        List <ServiceLevel1> Level1lst = new List <ServiceLevel1>();
                        //foreach (string FirstLevelService in MList.Where(P => P.FormID == FormGUID).Select(P => P.MMenu).Distinct())
                        foreach (var FirstLevelService in MList.Where(P => P.FormID == FormGUID).Select(P => new { P.MMenu, P.MMenuGUID, P.ServiceGUID }).Distinct())
                        {
                            if (!string.IsNullOrEmpty(FirstLevelService.MMenu))
                            {
                                ServiceLevel1 Level1 = new ServiceLevel1();
                                Level1.Name        = FirstLevelService.MMenu;
                                Level1.ServiceGUID = FirstLevelService.ServiceGUID;
                                Level1.GUID        = new Guid(FirstLevelService.MMenuGUID);
                                List <ServiceLevel2> Level2lst = new List <ServiceLevel2>();
                                var s = MList.Where(P => P.FormID == FormGUID && P.MMenu == FirstLevelService.MMenu).Distinct();
                                foreach (var SecondLevelService in MList.Where(P => P.FormID == FormGUID && P.MMenu == FirstLevelService.MMenu).DistinctBy(P => P.SubMenu))
                                {
                                    ServiceLevel2 Level2 = new ServiceLevel2();
                                    Level2.Name        = SecondLevelService.SubMenu;
                                    Level2.GUID        = new Guid(SecondLevelService.SubMenuGUID);
                                    Level2.ServiceGUID = SecondLevelService.ServiceGUID;
                                    Level2.SValue      = SecondLevelService.ServiceTypeValue;
                                    List <ServiceLevel3> Level3lst = new List <ServiceLevel3>();
                                    foreach (var ThirsLevelService in MList.Where(P => P.FormID == FormGUID && P.MMenu == FirstLevelService.MMenu && P.SubMenu == SecondLevelService.SubMenu).OrderBy(P => P.ServiceGUID))
                                    {
                                        ServiceLevel3 Level3 = new ServiceLevel3();
                                        Level3.Name        = ThirsLevelService.SSubMenu;
                                        Level3.GUID        = new Guid(ThirsLevelService.ServiceTypeGUID);
                                        Level3.ServiceGUID = ThirsLevelService.ServiceGUID;
                                        if (!string.IsNullOrEmpty(ThirsLevelService.SSubMenu))
                                        {
                                            Level3.SValue      = ThirsLevelService.ServiceTypeValue;
                                            Level3.Approver    = ThirsLevelService.ApproverRuleCode;
                                            Level3.ActionTaker = ThirsLevelService.ActionTakerRuleCode;
                                            Level3.ControlFlag = ThirsLevelService.ControlFlag;
                                            Level3.Enabled     = ThirsLevelService.Enabled;
                                            Level3.Placeholder = ThirsLevelService.Placeholder;
                                        }
                                        else
                                        {
                                            Level3.SValue = null;
                                        }
                                        Level3lst.Add(Level3);
                                    }
                                    if (Level3lst.Count > 0)
                                    {
                                        Level2.Level3 = Level3lst;
                                        //Level2.GUID = Guid.Empty;   // To return Null Value.
                                        Level2.SValue = null;
                                    }
                                    else
                                    {
                                        Level2.Level3 = null;
                                    }
                                    Level2lst.Add(Level2);
                                }
                                if (Level2lst.Count > 0)
                                {
                                    Level1.Level2 = Level2lst;
                                }
                                else
                                {
                                    Level1.Level2 = null;
                                }
                                Level1lst.Add(Level1);
                            }
                        }
                        if (Level1lst.Count > 0)
                        {
                            Rev.RequestList = Level1lst;
                        }
                        else
                        {
                            Rev.RequestList = null;
                        }
                        FormRequests.Add(Rev);
                    }
                }
                else
                {
                    throw new System.ArgumentException("The user has no enough permission to open this item");
                }
            }
            catch (Exception ex)
            {
                FormRequests = null;
                throw ex;
            }
            return(FormRequests);
        }
Пример #22
0
 public abstract void Submit(AttachFile attachFile);
Пример #23
0
        public IHttpActionResult Post(AttachFile baseRequest)
        {
            var response = service.SaveAttachFile(baseRequest);

            return(Ok(response));
        }
Пример #24
0
 /// <summary>Method for set file in message, input full path to file</summary>
 public void SetAttachedFile(string pathFile)
 {
     AttachFile.SendKeys(pathFile);
 }
Пример #25
0
        protected void btnUploadFile_Click(object sender, EventArgs e)
        {
            if (!fulAttachFile.HasFile)
            {
                AlertMessageShow(SysMessage.CannotUploadFile);
                return;
            }

            var           documentCode = ddlDocumentType.SelectedValue;
            DataCenterBiz dbiz         = new DataCenterBiz();
            var           imgItem      = dbiz.GetPicByDocumentCode(documentCode);

            if (imgItem != null)
            {
                if (!FilterContentTypeImage(fulAttachFile.PostedFile.ContentType))
                {
                    AlertMessageShow(String.Format("ไม่สามารถนำเข้าไฟล์ ประเภท{0} ได้.", fulAttachFile.FileName.Substring(fulAttachFile.FileName.LastIndexOf('.'))));
                    return;
                }
            }
            else
            {
                if (!FilterContentType(fulAttachFile.PostedFile.ContentType))
                {
                    AlertMessageShow(String.Format("ไม่สามารถนำเข้าไฟล์ ประเภท{0} ได้.", fulAttachFile.FileName.Substring(fulAttachFile.FileName.LastIndexOf('.'))));
                    return;
                }
            }

            if (fulAttachFile.FileBytes.LongCount() > 1048576)
            {
                AlertMessageShow(SysMessage.AttachNotOverOneMB);
                return;
            }

            AttachFile attachFile = ConcreateFromControl();

            Stream fileStream = fulAttachFile.PostedFile.InputStream;

            try
            {
                if (ActiveAttachFiles.Where(a => a.ATTACH_FILE_TYPE == attachFile.ATTACH_FILE_TYPE).Count() > 0)
                {
                    if (TempAttachFiles.Where(t => t.ATTACH_FILE_TYPE == attachFile.ATTACH_FILE_TYPE &&
                                              t.FILE_STATUS == AttachFileStatus.Wait.Value()).Count() > 0)
                    {
                        AlertMessageShow(SysMessage.AttachFileDupicate);
                        return;
                    }
                    if (TempAttachFiles.Where(t => t.ATTACH_FILE_TYPE == attachFile.ATTACH_FILE_TYPE &&
                                              t.FILE_STATUS == AttachFileStatus.Delete.Value()).Count() > 0)
                    {
                        var biz = new BLL.UploadDataBiz();
                        UploadFileResponse response = new UploadFileResponse();
                        response = biz.UploadAttachFileToTemp(attachFile, fileStream);

                        if (response.Code != "0000")
                        {
                            AlertMessageShow(response.Message);
                            return;
                        }
                        attachFile.ATTACH_FILE_PATH = response.TargetFullName;

                        AttachFile deleteAttach = _attachFiles.Single(t => t.ATTACH_FILE_TYPE == attachFile.ATTACH_FILE_TYPE &&
                                                                      t.FILE_STATUS == AttachFileStatus.Delete.Value());

                        attachFile.MappingToEntity <AttachFile>(deleteAttach);
                        DefaultValue();
                        BindAttachFile();
                    }
                    else
                    {
                        AlertMessageShow(SysMessage.AttachFileDupicate);
                        return;
                    }
                }
                else
                {
                    if (TempAttachFiles.Where(t => t.ATTACH_FILE_TYPE == ddlDocumentType.SelectedValue &&
                                              t.FILE_STATUS == AttachFileStatus.Wait.Value()).Count() > 0)
                    {
                        AlertMessageShow(SysMessage.AttachFileDupicate);
                        return;
                    }
                    else
                    {
                        var biz = new BLL.UploadDataBiz();
                        UploadFileResponse response = new UploadFileResponse();
                        //response = biz.UploadAttachFileToTemp(attachFile, fileStream);
                        response = biz.UploadAttachFileLicenseToTemp(attachFile, fileStream);


                        if (response.Code != "0000")
                        {
                            AlertMessageShow(response.Message);
                            return;
                        }
                        attachFile.ATTACH_FILE_PATH = response.TargetFullName;

                        _attachFiles.Add(attachFile);
                        DefaultValue();
                        BindAttachFile();


                        //Add to masterLicense
                        this.MasterLicense.AttachFiles = _attachFiles;
                    }
                }
            }
            catch (Exception ex)
            {
                AlertMessageShow(ex.Message);
            }

            udpAttachFiles.Update();
        }
Пример #26
0
 public AttachFilesProxy(AttachFile f)
 {
     this.Id = f.Id;
     this.FilePath = f.FilePath;
 }
Пример #27
0
        private void BindingRowMode(AttachFile attachFile, LinkButton lbnEditGv, LinkButton hplView, LinkButton hplDelete, LinkButton hplCancel, GridViewRowEventArgs e)
        {
            if (attachFile.FILE_STATUS == AttachFileStatus.Active.Value())
            {
                if (TempAttachFiles.Where(a => a.ATTACH_FILE_TYPE == attachFile.ATTACH_FILE_TYPE &&
                                          (a.FILE_STATUS == AttachFileStatus.Edit.Value() ||
                                           a.FILE_STATUS == AttachFileStatus.Wait.Value())).Count() > 0)
                {
                    if (lbnEditGv != null)
                    {
                        lbnEditGv.Visible = false;
                    }
                    if (hplView != null)
                    {
                        hplView.Visible = false;
                    }
                    if (hplDelete != null)
                    {
                        hplDelete.Visible = false;
                    }
                    if (hplCancel != null)
                    {
                        hplCancel.Visible = false;
                    }

                    e.Row.Style.Value = "text-decoration:line-through;";
                }
                else if (TempAttachFiles.Where(a => a.ATTACH_FILE_TYPE == attachFile.ATTACH_FILE_TYPE &&
                                               a.FILE_STATUS == AttachFileStatus.Delete.Value()).Count() > 0)
                {
                    e.Row.Visible = false;
                }

                else
                {
                    if (lbnEditGv != null)
                    {
                        lbnEditGv.Visible = true;
                    }
                    if (hplView != null)
                    {
                        hplView.Visible       = true;
                        hplView.OnClientClick = LinkPopUp(attachFile.ATTACH_FILE_PATH);
                    }
                    if (hplDelete != null)
                    {
                        hplDelete.Visible = true;
                    }
                    if (hplCancel != null)
                    {
                        hplCancel.Visible = false;
                    }
                }
            }
            else if (attachFile.FILE_STATUS == AttachFileStatus.Delete.Value())
            {
                if (TempAttachFiles.Where(a => a.ATTACH_FILE_TYPE == attachFile.ATTACH_FILE_TYPE &&
                                          a.FILE_STATUS == AttachFileStatus.Wait.Value()).Count() > 0)
                {
                    if (lbnEditGv != null)
                    {
                        lbnEditGv.Visible = false;
                    }
                    if (hplView != null)
                    {
                        hplView.Visible       = true;
                        hplView.OnClientClick = LinkPopUp(attachFile.ATTACH_FILE_PATH);
                    }
                    if (hplDelete != null)
                    {
                        hplDelete.Visible = false;
                    }
                    if (hplCancel != null)
                    {
                        hplCancel.Visible = false;
                    }
                }
                else
                {
                    if (lbnEditGv != null)
                    {
                        lbnEditGv.Visible = false;
                    }
                    if (hplView != null)
                    {
                        hplView.Visible       = true;
                        hplView.OnClientClick = LinkPopUp(attachFile.ATTACH_FILE_PATH);
                    }
                    if (hplDelete != null)
                    {
                        hplDelete.Visible = false;
                    }
                    if (hplCancel != null)
                    {
                        hplCancel.Visible = true;
                    }
                }


                e.Row.Style.Value = "text-decoration:line-through;";
            }
            else if (attachFile.FILE_STATUS == AttachFileStatus.Edit.Value())
            {
                if (lbnEditGv != null)
                {
                    lbnEditGv.Visible = false;
                }
                if (hplView != null)
                {
                    hplView.Visible       = true;
                    hplView.OnClientClick = LinkPopUp(attachFile.ATTACH_FILE_PATH);
                }
                if (hplDelete != null)
                {
                    hplDelete.Visible = false;
                }
                if (hplCancel != null)
                {
                    hplCancel.Visible = true;
                }
            }
            else if (attachFile.FILE_STATUS == AttachFileStatus.Wait.Value())
            {
                if (lbnEditGv != null)
                {
                    lbnEditGv.Visible = false;
                }
                if (hplView != null)
                {
                    hplView.Visible       = true;
                    hplView.OnClientClick = LinkPopUp(attachFile.ATTACH_FILE_PATH);
                }
                if (hplDelete != null)
                {
                    hplDelete.Visible = false;
                }
                if (hplCancel != null)
                {
                    hplCancel.Visible = true;
                }
            }
        }
Пример #28
0
 public override void Submit(AttachFile attachFile)
 {
     throw new InvalidOperationException(Resources.errorDeleteAttachFileState_001);
 }
Пример #29
0
        public string[] SaveAttachFiles(HttpRequestBase requstWeb)
        {
            string OriginFileName  = "";
            string strSaveFileName = "";
            string strExt          = "";

            int arrSeq = 0;

            //var uploadIds;
            PostFileViewModels postFile = new PostFileViewModels();

            string[] uploadIds = new string[] { };

            try
            {
                foreach (string fileName in requstWeb.Files)
                {
                    uploadIds = new string[requstWeb.Files.Count];

                    HttpPostedFileBase file = requstWeb.Files[fileName];

                    OriginFileName = file.FileName;

                    if (file != null && file.ContentLength > 0)
                    {
                        var saveDir = new DirectoryInfo(string.Format("{0}Files", HostingEnvironment.MapPath(@"\")));

                        string pathString = System.IO.Path.Combine(saveDir.ToString(), "PostAttach");

                        bool isExists = System.IO.Directory.Exists(pathString);

                        if (!isExists)
                        {
                            System.IO.Directory.CreateDirectory(pathString);
                        }


                        strExt = Path.GetExtension(OriginFileName);

                        var    nowDt  = DateTime.Now;
                        string strNow = nowDt.ToString("yyyyMMddHHmm");

                        Random rnd     = new Random();
                        int    fileSeq = rnd.Next(999999);

                        strSaveFileName = strNow + "_" + fileSeq.ToString() + strExt;
                        var path = string.Format("{0}\\{1}", pathString, strSaveFileName);

                        file.SaveAs(path);

                        var guid = Guid.NewGuid();

                        postFile.FiledId = guid.ToString();
                        postFile.PostId  = 0;

                        //uploadIds.Add(guid.ToString());

                        uploadIds[arrSeq] = guid.ToString();

                        arrSeq++;

                        AttachFile files = new AttachFile();
                        files.FileId         = guid.ToString();
                        files.FileType       = "POST_ATTACH";
                        files.OriginFileName = OriginFileName;
                        files.FileExtension  = strExt.Substring(1);
                        files.SaveAsFileName = strSaveFileName;
                        files.FilePath       = "/Files/PostAttach/";
                        files.IsDelete       = 0;
                        files.CreateId       = System.Web.HttpContext.Current.User.Identity.GetUserId();
                        files.CreateDt       = DateTime.Now;

                        context.AttachFiles.Add(files);
                        context.SaveChanges();
                    }
                }

                return(uploadIds);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Пример #30
0
 public override void Submit(AttachFile attachFile)
 {
     throw new NotImplementedException();
 }
 public void Add(AttachFile attachfile)
 {
     db.AttachFiles.InsertOnSubmit(attachfile);
 }