Ejemplo n.º 1
0
    void SetMessagePlaceholderInputfield(ChangeTextData dataObj)
    {
        dataTxt   = dataObj.gameobjectContainer.GetComponent <InputField>().placeholder.GetComponent <Text>();
        dataMessg = dataObj.messageCodeId;

//		Debug.Log (dataObj.gameobjectContainer.name);

        LanguageManager.Instance.SetMessageToText(dataTxt, dataMessg);
    }
Ejemplo n.º 2
0
    void SetMessageText2D(ChangeTextData dataObj)
    {
        dataTxt   = dataObj.gameobjectContainer.GetComponent <Text>();
        dataMessg = dataObj.messageCodeId;

//		Debug.Log (dataObj.gameobjectContainer.name);

        LanguageManager.Instance.SetMessageToText(dataTxt, dataMessg);
    }
        public HttpResponseMessage ChangeText(ChangeTextData ctData)
        {
            try
            {
                WriteWordTableHandle writeWordTable = new WriteWordTableHandle();
                writeWordTable.ChangeTextInCell(ctData);
            }
            catch (Exception ex)
            {
                return(tool.MsgFormat(ResponseCode.操作失败, "修改失败", ex.ToString()));
            }

            return(tool.MsgFormat(ResponseCode.成功, "修改成功", "0"));
        }
Ejemplo n.º 4
0
        public void ChangeTextInCell(ChangeTextData ctData)
        {
            using (WordprocessingDocument doc = WordprocessingDocument.Open(ctData.DocUrl, true))
            {
                Table table = doc.MainDocumentPart.Document.Body.Elements <Table>().First();

                TableRow row = table.Elements <TableRow>().ElementAt(Convert.ToInt32(ctData.Line));

                TableCell cell = row.Elements <TableCell>().ElementAt(Convert.ToInt32(ctData.Column));

                Paragraph p = cell.Elements <Paragraph>().First();

                Run r = p.Elements <Run>().First();

                Text t = r.Elements <Text>().First();

                t.Text = ctData.Value;
            }
        }
Ejemplo n.º 5
0
        public HttpResponseMessage Download(ChangTestList data)
        {
            string docUrl = "D:\\workspace2015\\docxFile\\对经营高危险性体育项目的行政许可.docx";

            try
            {
                WriteWordTableHandle writeWordTable = new WriteWordTableHandle();
                ChangeTextData       ctData         = null;

                #region 处理json数组
                JArray info = (JArray)JsonConvert.DeserializeObject(data.CtdListString);

                if (info != null)
                {
                    for (int i = 0; i < info.Count; i++)
                    {
                        JObject joRet = (JObject)info[i];
                        if (joRet["bindingMethod"].ToString().Equals("1"))
                        {
                            //ctData = ChangeTextData.FromJson(joRet);
                            //ctData.DocUrl = docUrl;
                            ctData = new ChangeTextData()
                            {
                                DocUrl = docUrl,
                                Line   = joRet["line"].ToString() != string.Empty ? Convert.ToInt32(joRet["line"]) : -1,
                                Column = joRet["column"].ToString() != string.Empty ? Convert.ToInt32(joRet["column"]) : -1,
                                Value  = joRet["value"].ToString() != string.Empty ? joRet["column"].ToString() : "",
                            };
                            if (ctData.Line >= 0 && ctData.Column >= 0)
                            {
                                writeWordTable.ChangeTextInCell(ctData);
                            }
                        }
                    }
                }
                #endregion

                #region word 转 html
                OfficeConvertHandle officeConvertHandle = new OfficeConvertHandle();
                WordToHtmlData      wth = new WordToHtmlData()
                {
                    Sourcedocx      = docUrl,
                    TargetDirectory = "D:\\workspace2015\\docxFile"
                };
                officeConvertHandle.ConvertToHtml(wth);
                #endregion

                #region html 转 pdf
                HtmlToPdfData htp = new HtmlToPdfData()
                {
                    SourceHtml = "D:\\workspace2015\\docxFile\\对经营高危险性体育项目的行政许可.html",
                    TargetPdf  = "D:\\workspace2015\\docxFile\\对经营高危险性体育项目的行政许可.pdf"
                };
                officeConvertHandle.HtmlToPdf(htp);
                #endregion

                #region  载文档
                string fn = "对经营高危险性体育项目的行政许可.pdf";

                string fileName = fn
                ;
                if (fileName.LastIndexOf(".") == -1)
                {
                    fileName = string.Format("{0}.pdf", fn);
                }


                string filePath = "D:\\workspace2015\\docxFile\\" + fileName;//测试下载的路劲

                FileStream          stream   = new FileStream(filePath, FileMode.Open);
                HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
                response.Content = new StreamContent(stream);
                response.Content.Headers.ContentType        = new MediaTypeHeaderValue("application/octet-stream");
                response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
                {
                    FileName = HttpUtility.UrlEncode(fileName)
                };
                response.Headers.Add("Access-Control-Expose-Headers", "FileName");
                response.Headers.Add("FileName", HttpUtility.UrlEncode(fileName));
                return(response);

                #endregion
            }
            catch (Exception ex)
            {
                return(tool.MsgFormat(ResponseCode.操作失败, "操作失败", ex.ToString()));
            }

            //return tool.MsgFormat(ResponseCode.成功, "操作成功", "0");
        }