Esempio n. 1
0
        private void ProcessTask(object status)
        {
            IProcessingCallback callback = status as IProcessingCallback;

            callback.Begin();
            try
            {
                _task.Execute(callback);
            }
            catch (Exception ex)
            {
                if (null != callback)
                {
                    callback.Error(string.Format("{0} failed with error: {1}", _task.Title, ex.Message));
                }
            }
            // ending
            callback.End();
        }
Esempio n. 2
0
        private void ExtractZip(object status)
        {
            IProcessingCallback callback = status as IProcessingCallback;

            callback.Begin();
            string sOpName = string.Empty;

            try
            {
                switch (MergeMode)
                {
                case Mode.Mode_Overwrite:
                    sOpName = "Updating with file ";
                    BackupRestore.Overwrite(
                        LocalLibraryFile
                        , this);
                    break;

                case Mode.Mode_Merge:
                    sOpName = "Merging with file ";
                    BackupRestore.Merge(
                        LocalLibraryFile
                        , this);
                    break;

                default:
                    Debug.Assert(false);
                    break;
                }
            }
            catch (Exception ex)
            {
                if (null != callback)
                {
                    callback.Error(string.Format("{0} {1} failed with error: {2}"
                                                 , sOpName, LocalLibraryFile, ex.Message));
                }
            }
            // ending
            callback.End();
        }
Esempio n. 3
0
        public void Upload(IProcessingCallback callback)
        {
            // check that database actually exist
            if (!System.IO.File.Exists(_dbPath))
            {
                if (null != callback)
                {
                    callback.Error(string.Format("Input database path ({0}) could not be found.", _dbPath));
                }
                return;
            }
            // begin
            if (null != callback)
            {
                callback.Begin();
            }
            // connect
            PLMPackSR.PLMPackServiceClient client = new PLMPackSR.PLMPackServiceClient();
            client.ClientCredentials.UserName.UserName = UserName;
            client.ClientCredentials.UserName.Password = Password;

            PLMPackSR.DCUser user = client.Connect();
            if (user != null)
            {
                if (null != callback)
                {
                    callback.Info(string.Format("Connection successful: {0}", user.Email));
                }
            }
            else
            {
                if (null != callback)
                {
                    callback.Info(string.Format("Failed to connect with user credentials ({0} + {1})", UserName, Password));
                }
                return;
            }

            // ### upload default thumbnails
            Dictionary <string, string> defNameDict = new Dictionary <string, string>()
            {
                { "AI", "Ai.png" },
                { "ARD", "ARD.png" },
                { "CALC", "Calc.png" },
                { "CCF2", "CFF2.png" },
                { "DXF", "DXF.png" },
                { "EPS", "EPS.png" },
                { "EXCEL", "Excel.png" },
                { "FOLDER", "Folder.png" },
                { "IMAGE", "Image.png" },
                { "PDF", "pdf.png" },
                { "DES3", "Picador3D.png" },
                { "DES", "PicGEOM.png" },
                { "PPT", "Powerpoint.png" },
                { "WORD", "Word.png" },
                { "WRITER", "Writer.png" }
            };

            foreach (KeyValuePair <string, string> entry in defNameDict)
            {
                string filePath = Path.Combine(RepositoryThumbnail, entry.Value);
                Guid   fileGuid = client.UploadDefault(entry.Key, Path.GetExtension(filePath).Trim('.'));
                Upload(filePath, fileGuid, callback);
            }
            client.Close();
            // ### upload default thumbnails
            PPDataContext db = new PPDataContext(_dbPath, RepositoryPath);

            CopyCardboardFormat(db, callback);
            CopyCardboardProfiles(db, callback);
            CopyTreeNodeRecursively(db, callback);

            // end
            if (null != callback)
            {
                callback.End();
            }
        }