コード例 #1
0
    IEnumerator loadCo(string effectName)
    {
        yield return(null);

        var url = PathUrl.GetUIEffectUrl(effectName);

        _effectBundle = BundleReference.Get(url, this);
        if (!_effectBundle.contains(effectName))
        {
            _fxSort.enabled = false;
            yield break;
        }
        var prefab = _effectBundle.load <GameObject>(effectName);

        if (prefab == null)
        {
            yield break;
        }
        _effectGO = Instantiate(prefab) as GameObject;
        var t = _effectGO.transform;

        t.localPosition = Vector3.zero;
        t.localRotation = Quaternion.identity;
        t.localScale    = Vector3.one;
        _fxSort.enabled = true;
        _fxSort.ResortRenderers();
    }
コード例 #2
0
        protected override void Execute(NativeActivityContext context)
        {
            try
            {
                Thread.Sleep(DelayBefore.Get(context));
                string filePath = PathUrl.Get(context);

                excelApp               = new Excel::Application();
                excelApp.Visible       = IsVisible;
                excelApp.DisplayAlerts = false;

                if (_NewDoc == true)
                {
                    excelApp.Workbooks.Add(true);
                }
                else
                {
                    if (!File.Exists(filePath))
                    {
                        // 文件不存在,请检查路径有效性
                        SharedObject.Instance.Output(SharedObject.enOutputType.Error, Localize.LocalizedResources.GetString("xFileNotExist"));
                        new CommonVariable().realaseProcessExit(excelApp);
                        return;
                    }
                    else
                    {
                        //可用Open或Add函数打开文件,但对于执行VBA,Add无保存权限
                        excelApp.Workbooks.Open(filePath);
                    }
                }

                context.ScheduleAction(Body, excelApp, OnCompleted, OnFaulted);
            }
            catch (Exception e)
            {
                // EXCEL执行过程出错
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, Localize.LocalizedResources.GetString("xExcelExecError"), e.Message);
                new CommonVariable().realaseProcessExit(excelApp);
            }
        }
コード例 #3
0
ファイル: WordCreate.cs プロジェクト: sunhawk2100/RPAStudio-1
        protected override void Execute(NativeActivityContext context)
        {
            app = new Word::Application();
            try
            {
                string filePath = PathUrl.Get(context);

                Word::Documents docs = app.Documents;
                app.Visible       = IsVisible;
                app.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone;

                if (NewDoc)
                {
                    docs.Add();
                }
                else
                {
                    if (!File.Exists(PathUrl.Get(context)))
                    {
                        // 文件不存在,请检查路径有效性
                        SharedObject.Instance.Output(SharedObject.enOutputType.Error, Localize.LocalizedResources.GetString("xFileNotExist"));
                        CommonVariable.realaseProcessExit(app);
                    }
                    else
                    {
                        docs.Open(filePath);
                    }
                }
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "Word执行过程出错", e.Message);
                CommonVariable.realaseProcessExit(app);
            }
            if (Body != null)
            {
                context.ScheduleAction(Body, app, OnCompleted, OnFaulted);
            }
        }
コード例 #4
0
ファイル: InsertFile.cs プロジェクト: wuzeqingit/RPAStudio
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            PropertyDescriptor property = context.DataContext.GetProperties()[WordCreate.GetWordAppTag];
            Application        wordApp  = property.GetValue(context.DataContext) as Application;

            try
            {
                string pathUrl = PathUrl.Get(context);
                if (!File.Exists(pathUrl))
                {
                    SharedObject.Instance.Output(SharedObject.enOutputType.Error, "文件不存在,请检查路径有效性!", pathUrl);
                    CommonVariable.realaseProcessExit(wordApp);
                }
                wordApp.Selection.InsertFile(pathUrl);
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "Word执行过程出错", e.Message);
                CommonVariable.realaseProcessExit(wordApp);
            }
            m_Delegate = new runDelegate(Run);
            return(m_Delegate.BeginInvoke(callback, state));
        }
コード例 #5
0
        protected override void Execute(CodeActivityContext context)
        {
            Encoding csvEncoding;
            string   filePath     = PathUrl.Get(context);
            string   encodingType = EncodingType.Get(context);
            string   delimiter    = ",";

            if (Delimiter == DelimiterEnums.Caret插入符号)
            {
                delimiter = "^";
            }
            else if (Delimiter == DelimiterEnums.Comma逗号)
            {
                delimiter = ",";
            }
            else if (Delimiter == DelimiterEnums.Pipe竖线)
            {
                delimiter = "|";
            }
            else if (Delimiter == DelimiterEnums.Semicolon分号)
            {
                delimiter = ";";
            }
            else if (Delimiter == DelimiterEnums.Tab制表符)
            {
                delimiter = "	";
            }

            if (!File.Exists(filePath))
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "文件不存在,请检查路径有效性", filePath);
                return;
            }

            /*取字符编码 如果为空则取文件编码 异常则取系统默认编码*/
            try
            {
                if (encodingType == null)
                {
                    csvEncoding = CSVEncoding.GetEncodingType(filePath);
                }
                else
                {
                    csvEncoding = Encoding.GetEncoding(encodingType);
                }
            }
            catch (Exception)
            {
                csvEncoding = System.Text.Encoding.Default;
            }

            /*设置DataTable*/
            try
            {
                DataTable dataTable = ReadCSVFile(filePath, csvEncoding, delimiter);
                OutDataTable.Set(context, dataTable);
                foreach (DataRow dr in dataTable.Rows)
                {
                    for (int i = 0; i < dataTable.Columns.Count; i++)
                    {
                        System.Diagnostics.Debug.WriteLine("dt : " + dr[i]);
                    }
                }
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "EXCEL执行过程出错", e.Message);
                throw e;
            }
        }
コード例 #6
0
ファイル: AppendCSV.cs プロジェクト: wuzeqingit/RPAStudio
        protected override void Execute(CodeActivityContext context)
        {
            Encoding csvEncoding;
            string   filePath     = PathUrl.Get(context);
            string   encodingType = EncodingType.Get(context);
            string   delimiter    = ",";

            if (Delimiter == DelimiterEnums.Caret插入符号)
            {
                delimiter = "^";
            }
            else if (Delimiter == DelimiterEnums.Comma逗号)
            {
                delimiter = ",";
            }
            else if (Delimiter == DelimiterEnums.Pipe竖线)
            {
                delimiter = "|";
            }
            else if (Delimiter == DelimiterEnums.Semicolon分号)
            {
                delimiter = ";";
            }
            else if (Delimiter == DelimiterEnums.Tab制表符)
            {
                delimiter = "	";
            }

            if (!File.Exists(filePath))
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "文件不存在,请检查路径有效性", filePath);
                return;
            }

            /*取字符编码 如果为空则取文件编码 异常则取系统默认编码*/
            try
            {
                if (encodingType == null)
                {
                    csvEncoding = CSVEncoding.GetEncodingType(filePath);
                }
                else
                {
                    csvEncoding = Encoding.GetEncoding(encodingType);
                }
            }
            catch (Exception)
            {
                csvEncoding = System.Text.Encoding.Default;
            }

            /*将DataTable内容写入CSV文件*/
            try
            {
                DataTable inDataTable = InDataTable.Get(context);
                WriteCSVFile(inDataTable, filePath, csvEncoding, delimiter);
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "EXCEL执行过程出错", e.Message);
                throw e;
            }
        }
コード例 #7
0
        protected override void Execute(CodeActivityContext context)
        {
            try
            {
                PdfReader pdfReader;
                string    pathUrl = PathUrl.Get(context);
                string    range   = Range.Get(context);

                if (!File.Exists(pathUrl))
                {
                    SharedObject.Instance.Output(SharedObject.enOutputType.Error, "PDF文件不存在,请检查路径有效性", pathUrl);
                    return;
                }
                if (PassWord.Expression != null)
                {
                    byte[] byteArray = System.Text.Encoding.Default.GetBytes(PassWord.Get(context));
                    pdfReader = new iTextSharp.text.pdf.PdfReader(pathUrl, byteArray);
                }
                else
                {
                    pdfReader = new iTextSharp.text.pdf.PdfReader(pathUrl);
                }

                string pdfText = null;
                if (range.Contains(","))
                {
                    string[] rangeArray1 = range.Split(',');
                    foreach (string buff in rangeArray1)
                    {
                        string pdfPara = null;
                        if (buff.Contains("-"))
                        {
                            string[] rangeArray = buff.Split('-');
                            string   range1     = rangeArray[0];
                            string   range2     = rangeArray[1];
                            pdfPara = getContent(pdfReader, range1, range2);
                        }
                        else
                        {
                            pdfPara = getContent(pdfReader, buff);
                        }
                        pdfText += pdfPara;
                    }
                }
                else if (range.Contains("-"))
                {
                    string[] rangeArray = range.Split('-');
                    string   range1     = rangeArray[0];
                    string   range2     = rangeArray[1];
                    pdfText = getContent(pdfReader, range1, range2);
                }
                else
                {
                    pdfText = getContent(pdfReader, range);
                }
                context.SetValue(PDFText, pdfText);
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "PDF读取文本失败", e);
                throw e;
            }
        }