Пример #1
0
        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var userInfo  = FormulaHelper.GetUserInfo();
            var sqlHelper = SQLHelper.CreateSqlHelper(ConnEnum.Engineering);

            Dictionary <string, object> operaLog = new Dictionary <string, object>();

            operaLog.SetValue("ID", FormulaHelper.CreateGuid());

            string tableIDs = GetTableFieldValue(filterContext, IDField);
            string name     = GetTableFieldValue(filterContext, NameField, tableIDs, Table);

            if (string.IsNullOrEmpty(EngineeringInfoField))
            {
                EngineeringInfoField = "EngineeringInfoID";
            }

            string engineeringInfoID = GetTableFieldValue(filterContext, EngineeringInfoField, tableIDs, Table);

            if (OperaType == EnumOperaType.None)
            {
                OperaType = GetAddorUpdateOpera(Table, tableIDs);
            }

            operaLog.SetValue("EngineeringInfoID", engineeringInfoID);
            operaLog.SetValue("OperateType", OperaType.ToString());
            operaLog.SetValue("TableIDs", tableIDs);
            operaLog.SetValue("Name", name);
            operaLog.SetValue("DBTable", Table);
            operaLog.SetValue("DBTableName", Table);
            operaLog.SetValue("Remark", Remark);

            operaLog.SetValue("CreateUser", userInfo.UserName);
            operaLog.SetValue("CreateUserID", userInfo.UserID);
            operaLog.SetValue("CompanyID", userInfo.UserOrgID);

            operaLog.InsertDB(sqlHelper, "S_A_ParticipantOperaLog");
        }
Пример #2
0
 public abstract Task <bool> Start(FileInformation source, string target, OperaType operaType);
Пример #3
0
        /// <summary>
        /// 开始下载 和 上传
        /// </summary>
        /// <param name="cloudid"></param>
        /// <param name="source"></param>
        /// <param name="target"></param>
        /// <param name="operaType"></param>
        /// <returns></returns>
        public static Task <bool> Start(Guid cloudid, FileInformation source, string target, OperaType operaType)
        {
            var cloud = GetCloud(cloudid);

            RefreshCloudToken(cloudid);

            var cancel = new CancellationTokenSource();
            var token  = cancel.Token;
            var result = Task.Factory.StartNew(() =>
            {
                token.ThrowIfCancellationRequested();
                return(cloud?.Start(source, target, operaType));
            },
                                               token);

            if (result.Result.Result)
            {
                TaskManagement.AddTask(Path.Combine(source.FilePath, source.FileName),
                                       result,
                                       cancel,
                                       target,
                                       0,
                                       cloudid);
                return(result.Result);
            }
            return(result.Result);
        }
Пример #4
0
        public override async Task <bool> Start(FileInformation source, string target, OperaType operaType)
        {
            bool isSuccess = false;

            switch (operaType)
            {
            case OperaType.UpLoad:
                try
                {
                    var o = new OneDriveFileUpload();
                    o.ProgressEvent += O_ProgressEvent;
                    isSuccess        = await o.UpLoadFile(Cloud.CloudToken, source, Guid.NewGuid().ToString());
                }
                catch (Exception e)
                {
                    OnException(new ExceptionEventHandler(CloudId.ToString(), "", e.ToString()));
                }
                break;

            case OperaType.DownLoad:
                try
                {
                    var o = new OneDriveFileLoad();
                    o.ProgressEvent += O_ProgressEvent;
                    isSuccess        = await o.DownloadFile(Cloud.CloudToken, source, target, Guid.NewGuid().ToString());
                }
                catch (Exception e)
                {
                    OnException(new ExceptionEventHandler(CloudId.ToString(), "", e.ToString()));
                }
                break;
            }
            return(isSuccess);
        }