Esempio n. 1
0
 private void ftpCheck_Tick(object sender, EventArgs e)
 {
     if (!this.ftp.IsBusy)
     {
         foreach (ListViewItem item in this.listView1.Items)
         {
             IsoEntry tag = (IsoEntry)item.Tag;
             if (tag.Status == IsoEntryStatus.UploadQueue)
             {
                 tag.Status = IsoEntryStatus.Uploading;
                 item.Tag   = tag;
                 this.ftp   = new FtpUploader();
                 this.ftp.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.ftp_RunWorkerCompleted);
                 this.ftp.ProgressChanged    += new ProgressChangedEventHandler(this.ftp_ProgressChanged);
                 string ip          = Chilano.Iso2God.Properties.Settings.Default["FtpIP"].ToString();
                 string user        = Chilano.Iso2God.Properties.Settings.Default["FtpUser"].ToString();
                 string pass        = Chilano.Iso2God.Properties.Settings.Default["FtpPass"].ToString();
                 string port        = Chilano.Iso2God.Properties.Settings.Default["FtpPort"].ToString();
                 string containerID = tag.ID.ContainerID;
                 this.ftp.RunWorkerAsync(new FtpUploaderArgs(ip, user, pass, port, tag.ID.TitleID, tag.ID.ContainerID, tag.Destination, tag.Platform));
                 this.ftpCheck.Enabled = false;
                 return;
             }
         }
         this.ftpCheck.Enabled = false;
     }
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            string configFile = string.Empty, targetDir = string.Empty;
            var    sourceDirs = new List <string>();
            bool   showHelp = false, cleanupTarget = true;
            var    threads = 0;

            var p = new OptionSet()
            {
                { "c|config=", "the configuration file to use.", c => configFile = c },
                { "t|target=", "the destination directory (target), where to store the compressed files.", t => targetDir = t },
                { "s|source=", "the source directory to compress. You can specify multiple source directories.", s => sourceDirs.Add(s) },
                { "r|cleanupTarget", "clean the destination directory before compressing.", c => cleanupTarget = c == null },
                { "threads=", "the maximum number of threads to use.", t => threads = int.Parse(t) },
                { "h|help", "show this help.", b => showHelp = b != null }
            };

            try
            {
                p.Parse(args);
            }
            catch (OptionException ex)
            {
                Console.Error.WriteLine("Could not parse command line: {0}", ex.Message);
                Environment.Exit(1);
            }

            if (showHelp)
            {
                Help(p);
                return;
            }

            if (!string.IsNullOrWhiteSpace(configFile))
            {
                JsonConfiguration.Configuration = JsonConfiguration.Load(configFile);
            }
            else
            {
                JsonConfiguration.Configuration = JsonConfiguration.Generate(targetDir, sourceDirs, cleanupTarget, threads);
            }
            var conf = JsonConfiguration.Configuration;

            Logger.Global = new Logger(
                conf.LogConfiguration.Severity,
                conf.LogConfiguration.Logfile,
                conf.LogConfiguration.Append);

            Compress();

            if (conf.FtpConfiguration != null)
            {
                var ftp = new FtpUploader(conf.FtpConfiguration);
                ftp.DeleteDirectory(conf.FtpConfiguration.Destination);
                ftp.UploadDirectory(conf.TargetDirectory, conf.FtpConfiguration.Destination);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Upload the given memory stream with the attached filename to the FTP server and return
        /// a link with the registered CopyPath prefix.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="stream"></param>
        /// <returns></returns>
        public Task <string> Upload(string name, MemoryStream stream)
        {
            try
            {
                var remote = new Uri(creds.RemotePath, name);
                var copy   = new Uri(creds.CopyPath, name);

                // This is needed, it will not work otherwise - I do not know why
                using (var newStream = new MemoryStream(stream.ToArray()))
                {
                    FtpUploader.Upload(newStream, remote, creds.Username, creds.Password);
                }

                return(Task.FromResult(copy.ToString()));
            }
            catch
            {
                return(Task.FromResult((string)null));
            }
        }
Esempio n. 4
0
    IEnumerator captureScreenshot()
    {
        yield return(new WaitForEndOfFrame());

        //string path = Application.persistentDataPath + "Screenshots" + Screen.width + "X" + Screen.height + "" + ".png";
        string path = Application.persistentDataPath + "/Input.png";

        Texture2D screenImage = new Texture2D(Screen.width, Screen.height);

        //Get Image from screen
        screenImage.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
        screenImage.Apply();
        //Convert to png
        byte[] imageBytes = screenImage.EncodeToPNG();

        //Save image to file
        System.IO.File.WriteAllBytes(path, imageBytes);

        FtpUploader uploader = new FtpUploader();

        uploader.UploadFile(imageBytes);
    }
Esempio n. 5
0
        public void Notify(params object[] args)
        {
            #region 从事件参数中取得当前业务实体

            //从事件参数中取得当前业务实体
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }
            BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            if (key == null)
            {
                return;
            }

            Contact       cc = new Contact();
            PurchaseOrder po = key.GetEntity() as PurchaseOrder;
            if (po == null)
            {
                return;
            }
            poid = po.ID.ToString();



            #region OA接口

            string oaProfileValue = Common.GetProfileValue(Common.iProfileCode, Context.LoginOrg.ID);
            if (oaProfileValue.ToLower() != "true")
            {
                return;
            }
            string docTypeCode = po.DocumentType.Code.ToString();
            if (docTypeCode == "PO31" || docTypeCode == "PO32" || docTypeCode == "PO33" || docTypeCode == "PO34" || docTypeCode == "PO35" || docTypeCode == "PO36")
            {
                if (po.OriginalData.Status == PODOCStatusEnum.Approving && po.Status == PODOCStatusEnum.Approving)
                {
                    logger.Error("不能修改::");
                    if (po.DescFlexField.PrivateDescSeg29 == "")
                    {
                        if (Context.LoginUser.ToString() != "administrator" && Context.LoginUser.ToString() != "admin" && Context.LoginUser.ToString() != "系统管理员")
                        {
                            throw new Exception("OA流程单据不允许手动修改!");
                        }
                    }
                }

                if (po.OriginalData.Status == PODOCStatusEnum.Approving && po.Status == PODOCStatusEnum.Approved)
                {
                    logger.Error("不能审核::");
                    if (po.DescFlexField.PrivateDescSeg29 == "")
                    {
                        if (Context.LoginUser.ToString() != "administrator" && Context.LoginUser.ToString() != "admin" && Context.LoginUser.ToString() != "系统管理员")
                        {
                            throw new Exception("OA流程单据:" + po.DocNo + "不允许手工审核!");
                        }
                    }
                }
            }


            string svURL = Common.GetProfileValue(Common.iProfileCode, Context.LoginOrg.ID);

            string  orgCode       = Context.LoginOrg.Code;
            string  orgName       = Context.LoginOrg.Name;
            string  docNo         = po.DocNo;
            string  operatorsName = po.PurOper != null ? po.PurOper.Name : string.Empty;
            string  title         = operatorsName + docNo;
            decimal totalMoney    = 0;
            string  docTypeName   = po.DocumentType.Name.ToString();

            if (po.ID != 0)
            {
            }
            Int64  ID            = po.ID;
            string OperatorsCode = po.PurOper != null?po.PurOper.Code.ToString() : string.Empty;

            string BusinessDate = po.BusinessDate.ToString("yyyy-MM-dd");
            string Settlement   = po.DescFlexField.PrivateDescSeg7.ToString();
            //decimal TotalMoney = po.TotalMnyAC;
            string ProjectUse      = po.DescFlexField.PubDescSeg26.ToString();
            string TradeLocation   = po.DescFlexField.PrivateDescSeg5.ToString();
            string Supplier        = po.Supplier != null ? po.Supplier.Supplier.Name : string.Empty;
            string supplierContact = po.Supplier.Supplier.DescFlexField.PrivateDescSeg3;
            string supplierPhone   = po.Supplier.Supplier.DescFlexField.PrivateDescSeg4;
            string supplierEmail   = po.Supplier.Supplier.DescFlexField.PrivateDescSeg11;//正式库和测试库不一样
            khname  = po.Supplier != null ? po.Supplier.Supplier.Name : string.Empty;
            scdocno = po.DocNo;
            //string supplierPhone = "";
            //if (cc.DefaultPhoneNum != null) { supplierPhone = cc.DefaultPhoneNum; }
            //string supplierContact = "";
            //if (supplierPhone != null) { supplierContact = cc.PersonName.DisplayName +  supplierPhone; }
            //组织编码	OrgCode
            //组织名称	OrgName
            //Title	标题	bt
            //DocTypeName	单据类型	djlx
            //ID	单据ID	djid
            //DocNo	单号	cgdh
            //OperatorsCode	申请人编码	zdrbm
            //OperatorsName	申请人	zdrmc
            //BusinessDate	日期	cjsj
            //Settlement	结算方式及期限	jsfs
            //TotalMoney	合同总金额(小写)	htzjexx
            //    合同总金额(大写)
            //ProjectUse	项目用途	xmyt
            //TradeLocation	交货地点	jhdd
            //Supplier	供应商	gys
            //SupplierContact	供应商联系人+供应商电话	gyslxr

            Hashtable ht = new Hashtable();
            ht.Add("zzbm", orgCode); //组织编码
            ht.Add("zzmc", orgName); //组织名称
            ht.Add("cgdh", docNo);
            ht.Add("zdrmc", operatorsName);
            ht.Add("bt", title);
            ht.Add("djlx", docTypeName);
            ht.Add("djlxbm", docTypeCode);
            ht.Add("djid", ID);
            ht.Add("zdrbm", OperatorsCode);
            ht.Add("cjsj", BusinessDate);
            ht.Add("jsfs", Settlement);

            ht.Add("xmyt", ProjectUse);
            ht.Add("jhdd", TradeLocation);
            ht.Add("gys", Supplier);
            if (Supplier == "中航锂电科技有限公司" || Supplier == "中航锂电(洛阳)有限公司" || Supplier == "中航锂电技术研究院有限公司")
            {
                ht.Add("nbqsdw", Supplier);
            }
            ht.Add("gyslxr", supplierContact + supplierPhone);


            ht.Add("gysyx", supplierEmail);

            List <Hashtable> htDetailList = new List <Hashtable>();
            StringBuilder    sqlBuilder   = new StringBuilder();
            foreach (POLine line in po.POLines)
            {
                //行号	DocLineNo
                //料号	ItemCode
                //品名	ItemName
                //数量	PurQtyTU
                //单位	UomName
                //单价	FinallyPriceTC
                //金额	TotalMnyTC
                //交货时间	DeliveryDate
                Int64 id        = line.ID;
                int   docLineNo = line.DocLineNo;
                //料号
                string itemCode = line.ItemInfo.ItemCode;
                //品名
                string  itemName       = line.ItemInfo.ItemName;
                string  uomName        = line.TradeUOM.Name;
                string  deliveryDate   = line.POShiplines[0].DeliveryDate.ToString("yyyy-MM-dd");//交期
                decimal purQtyTU       = line.SupplierConfirmQtyPU;
                decimal finallyPriceTC = line.FinallyPriceTC;
                decimal totalMnyTC     = line.TotalMnyTC;
                totalMoney += totalMnyTC;


                //sqlBuilder.Append("INSERT INTO Cust_PO()");
                //sqlBuilder.Append("VALUES(''); ");
                //lh
                //pm
                //sl
                //dw
                //dj
                //je
                //jhrq

                Hashtable htDetail = new Hashtable();
                htDetail.Add("xid", id);
                htDetail.Add("xh", docLineNo);
                htDetail.Add("lh", itemCode); //料号
                htDetail.Add("pm", itemName); //品名
                htDetail.Add("dw", uomName);
                htDetail.Add("jhrq", deliveryDate);
                htDetail.Add("sl", purQtyTU);
                htDetail.Add("dj", finallyPriceTC);
                htDetail.Add("je", totalMnyTC);
                htDetailList.Add(htDetail);
            }
            ht.Add("htzjexx", totalMoney);
            //if (sqlBuilder.Length > 0)
            //{
            //    //DAOHelper.ExecuteSql(sqlBuilder.ToString());
            //    //DataAccessor.RunSQL(DatabaseManager.GetConnection(), sqlBuilder.ToString(), null);
            //}


            string userid = Context.LoginUserID;
            User   uscc   = User.Finder.FindByID(userid);
            //string uid = cc.UuID;
            int userID = 0;
            if (po.OriginalData.Status == PODOCStatusEnum.Opened && po.Status == PODOCStatusEnum.Approving)
            {
                string fileurl = "";
                #region 获取当前单据的附件信息
                //通过单据找到对应的附件
                string entityFullName = po.GetType().FullName;
                string opath          = "EntityFullName='" + entityFullName + "' and EntityID=" + po.ID;
                UFIDA.U9.Base.Attachment.Attachment.EntityList attachmentList = UFIDA.U9.Base.Attachment.Attachment.Finder.FindAll(opath, null);
                if (attachmentList != null && attachmentList.Count > 0)
                {
                    logger.Error("准备执行上传附件操作……");

                    foreach (UFIDA.U9.Base.Attachment.Attachment attachment in attachmentList)
                    {
                        //附件ID
                        long attachmentID = attachment.AttachmentID;
                        //根据附件ID查文件信息
                        //UFIDA.U9.CS.Collaboration.Library.FileInfo fileInfo = UFIDA.U9.CS.Collaboration.Library.FileInfo.Finder.FindByID(attachmentID);

                        //文件内容存储ID
                        string fileHandler = attachment.FileHandler;

                        //根据文件内容存储ID找文件信息
                        UFIDA.U9.CS.Common.FileStorage.Storage storage = new UFIDA.U9.CS.Common.FileStorage.Storage();
                        //获取文件
                        UFIDA.U9.CS.Common.FileDBService.FileInfo file = storage.GetFile(fileHandler);

                        //获取文件流
                        Stream stream = storage.GetFileContent(fileHandler);
                        stream.Position = 0;
                        //文件流转换成字节
                        byte[] infbytes = new Byte[(int)stream.Length];
                        stream.Read(infbytes, 0, infbytes.Length);
                        stream.Seek(0, SeekOrigin.Begin);

                        //UploadFile("d:/0304.txt");

                        string strRet = Convert.ToBase64String(infbytes);
                        //string localpath = @"D:\0304.txt";
                        //string userName = "******";
                        //string password="******";
                        ////C:\Users\Administrator\Desktop
                        ////logger.Error("上传文件失败,失败原因;" + fileInfo.FullPath);
                        //System.Net.NetworkCredential Credentials = new System.Net.NetworkCredential(userName, password);
                        //FtpHelper.UploadFileToFTPServer(localpath, "ftp://10.20.1.54", Credentials);
                        //<a href= "ftp://*****:*****@192.168.10.7:21/fdc/fdc_pr/FDC000000000JRA9JU2A/1231.txt\"  target=\"_blank\">1231.txt</ a>
                        string filen = "";

                        fileurl += "/" + file.FileName + ",";

                        //fileurl += "<a href='" + ftpurl + "" + filen + "' target=\"_blank\">" + filen + "</a>";
                        FtpUploader fileload = new FtpUploader();
                        fileload.UploadString(strRet, "ftp://10.20.1.54/", file.FileName, stream);
                        stream.Dispose();
                    }
                }


                #endregion

                #region OA创建流程

                //域账号   DomainName
                //userID = Convert.ToInt32(uscc.UuID);
                userID = Convert.ToInt32(uscc.ShortName);
                string requestName = "采购订单" + docNo + "审批";
                string workflowId  = po.DocType.DescFlexField.PrivateDescSeg1;//237测试
                if (string.IsNullOrEmpty(workflowId))
                {
                    return;
                }
                logger.Error("准备打印模板上传……");
                if (docTypeCode == "PO31" || docTypeCode == "PO32" || docTypeCode == "PO33" || docTypeCode == "PO34" || docTypeCode == "PO36")
                {
                    ShipUpdown();
                    UploadFile(dyfileurl);
                    fjurl = "/" + fjname + ",";
                }
                else if (docTypeCode == "PO35")
                {
                    fjurl = "";
                }

                logger.Error("附件文件名1::" + fileurl);
                fileurl = fileurl.Replace(" filename=", "");

                logger.Error("附件文件名2::" + fjurl);
                ht.Add("fj", fjurl);
                ht.Add("zccllj", fileurl);
                fjurl   = "";
                fileurl = "";
                khname  = "";
                scdocno = "";
                string workflowRequestInfo = Common.CreateXmlString(requestName, userID, workflowId, ht, htDetailList);
                logger.Error("发送采购单Xml:" + workflowRequestInfo);
                logger.Error("OA用户ID::" + userID);

                logger.Error("测试采购订单:" + po.OriginalData.Status + "---" + PODOCStatusEnum.Opened + "---" + po.Status + "---" + PODOCStatusEnum.Approved);
                if (docTypeCode == "PO31" || docTypeCode == "PO32" || docTypeCode == "PO33" || docTypeCode == "PO34" || docTypeCode == "PO35" || docTypeCode == "PO36")
                {
                    //调用OA服务
                    WebReference.WorkflowServiceXml client = new WebReference.WorkflowServiceXml();
                    client.Url = Common.GetProfileValue(Common.sProfileCode, Context.LoginOrg.ID);//无效URL
                    client.Url = client.Url.Substring(0, client.Url.Length - 5);
                    string rtnMsg = string.Empty;
                    logger.Error("测试采购订单:" + po.OriginalData.Status + "---" + PODOCStatusEnum.Opened + "---" + po.Status + "---" + PODOCStatusEnum.Approved);
                    try
                    {
                        rtnMsg = client.doCreateWorkflowRequest(workflowRequestInfo, userID);
                        //po.DescFlexField.PrivateDescSeg19 = rtnMsg;
                        using (ISession session = Session.Open())
                        {
                            string sql = "update PM_PurchaseOrder   set DescFlexField_PrivateDescSeg19='" + rtnMsg + "' where id=" + po.ID;
                            DataAccessor.RunSQL(DataAccessor.GetConn(), sql, null);
                            session.Commit();
                        }
                        logger.Error("测试Xml:" + rtnMsg);
                    }
                    catch (Exception ex)
                    {
                        throw new Exception("调用OA服务出现错误:" + ex.Message);
                    }
                }
            }

            //请购单提交状态点击保存 OA执行更新操作
            //else if (pr.OriginalData.Status == PRStatusEnum.Approving && pr.Status == PRStatusEnum.Approving)
            //{
            //    rtnMsg = client.submitWorkflowRequest(workflowRequestInfo, int.Parse(oaRquestID), userID, "submit", "");
            //}
            //if (rtnMsg.StartsWith("Error", StringComparison.OrdinalIgnoreCase))
            //{
            //    logger.Error("请购单OA系统错误:" + rtnMsg);
            //    throw new Exception("【请购单】OA系统错误—>" + rtnMsg);
            //}
            //pr.DescFlexField.PrivateDescSeg29 = "True";

            #endregion


            #endregion
        }