Пример #1
0
        public static int UpdateFileBinaryContentUsingEncoding(int packageId, string path, byte[] content, string encoding)
        {
            // check account
            int accountCheck = SecurityContext.CheckAccount(DemandAccount.NotDemo | DemandAccount.IsActive);

            if (accountCheck < 0)
            {
                return(accountCheck);
            }

            // check package
            int packageCheck = SecurityContext.CheckPackage(packageId, DemandPackage.IsActive);

            if (packageCheck < 0)
            {
                return(packageCheck);
            }

            // place log record
            TaskManager.StartTask("FILES", "UPDATE_BINARY_CONTENT", path, packageId);

            try
            {
                OS.OperatingSystem os       = GetOS(packageId);
                string             fullPath = GetFullPackagePath(packageId, path);

                // create file
                os.UpdateFileBinaryContentUsingEncoding(fullPath, content, encoding);

                return(0);
            }
            catch (Exception ex)
            {
                throw TaskManager.WriteError(ex);
            }
            finally
            {
                TaskManager.CompleteTask();
            }
        }