Exemplo n.º 1
0
        void CreateSafemateSetting(String name, String value)
        {
            CCSFB.SaveResult[] sr;
            CCSFB.QueryResult  qr = binding.query(String.Format(
                                                      "select Name, Value__c from Safemate_Setting__c where Name = '{0}' and SettingGroup__c = '{1}'",
                                                      name, safemateSettingGroupId));

            if (qr.size == 0)
            {
                CCSFB.Safemate_Setting__c s = new CCSFB.Safemate_Setting__c();

                s.Name            = name;
                s.SettingGroup__c = safemateSettingGroupId;
                s.Value__c        = value;

                sr = binding.create(new CCSFB.sObject[1] {
                    s
                });
                CheckCreationResult(sr);
                monitoredSettings.Add(name, value);
                return;
            }

            monitoredSettings.Add(
                ((CCSFB.Safemate_Setting__c)qr.records[0]).Name,
                ((CCSFB.Safemate_Setting__c)qr.records[0]).Value__c);
        }
Exemplo n.º 2
0
        bool DisableIfCustomerDoesntHavePermission()
        {
            CCSFB.QueryResult qr = binding.query(String.Format(
                                                     "select Remote_Backup__c from Account where Id = '{0}'",
                                                     menumateAccountId));

            return(((CCSFB.Account)qr.records[0]).Remote_Backup__c.Value == true);
        }
Exemplo n.º 3
0
        void RemoveSafemateDetails()
        {
            CCSFB.DeleteResult[] dr;
            List <String>        objectsToRemove = new List <String>();

            CCSFB.QueryResult qr = binding.query(String.Format(
                                                     "select Id from Safemate_SettingGroup__c where Asset__c = '{0}'",
                                                     safemateAssetId));

            if (qr.size > 0)
            {
                foreach (CCSFB.Safemate_SettingGroup__c sg in qr.records)
                {
                    objectsToRemove.Add(sg.Id);
                }
            }

            qr = binding.query(String.Format(
                                   "select Id from Safemate_Setting__c where SettingGroup__c = '{0}'",
                                   safemateSettingGroupId));

            if (qr.size > 0)
            {
                foreach (CCSFB.Safemate_Setting__c s in qr.records)
                {
                    objectsToRemove.Add(s.Id);
                }
            }

            qr = binding.query(String.Format(
                                   "select Id from Safemate_Backup_Log__c where BelongsToAsset__c = '{0}'",
                                   safemateAssetId));

            if (qr.size > 0)
            {
                foreach (CCSFB.Safemate_Backup_Log__c bl in qr.records)
                {
                    objectsToRemove.Add(bl.Id);
                }
            }

            qr = binding.query(String.Format(
                                   "select Id from Asset where Id = '{0}'",
                                   safemateAssetId));

            if (qr.size > 0)
            {
                foreach (CCSFB.Asset a in qr.records)
                {
                    objectsToRemove.Add(a.Id);
                }
            }

            if (objectsToRemove.Count > 0)
            {
                dr = binding.delete(objectsToRemove.ToArray());
            }
        }
Exemplo n.º 4
0
        public override void LogBackupOperation(String detailedStatus,
                                                String name, String status, Double backupSize)
        {
            if (allowedRemoteBackup)
            {
                CCSFB.SaveResult[] sr;

                SCLP.LogProxy.Log(SCLP.LogLevel.Info, String.Format(
                                      "Attempting to log operation {0} status to CRM...", name));
                try {
                    CCSFB.Safemate_Backup_Log__c bl;
                    CCSFB.QueryResult            _qr = binding.query(String.Format(
                                                                         "select Id, Last_transfer_result__c, Name, Result_Description__c, Time_of_backup__c, LastTransferSize__c from Safemate_Backup_Log__c where BelongsToAsset__c = '{0}' and Name = '{1}'",
                                                                         safemateAssetId, name));
                    if (_qr.size == 1)
                    {
                        bl = (CCSFB.Safemate_Backup_Log__c)_qr.records[0];
                    }
                    else
                    {
                        bl = new CCSFB.Safemate_Backup_Log__c();
                    }

                    bl.Last_transfer_result__c      = status;
                    bl.Result_Description__c        = detailedStatus;
                    bl.Time_of_backup__c            = DateTime.Now;
                    bl.Time_of_backup__cSpecified   = true;
                    bl.LastTransferSize__c          = backupSize;
                    bl.LastTransferSize__cSpecified = true;

                    if (_qr.size == 0)
                    {
                        bl.Name = name;
                        bl.BelongsToAsset__c = safemateAssetId;
                        sr = binding.create(new CCSFB.sObject[1] {
                            bl
                        });
                        if (!sr[0].success)
                        {
                            ;
                        }
                    }
                    else
                    {
                        sr = binding.update(new CCSFB.sObject[1] {
                            bl
                        });
                    }

                    SCLP.LogProxy.Log(SCLP.LogLevel.Info,
                                      "Successfully logged backup status to CRM.");
                } catch {
                    SCLP.LogProxy.Log(SCLP.LogLevel.Error, "Couldn't log to CRM.");
                }
            }
        }
Exemplo n.º 5
0
        void CreateSafemateAsset()
        {
            CCSFB.Asset        safemateAsset;
            CCSFB.SaveResult[] sr;
            CCSFB.QueryResult  qr = binding.query(String.Format(
                                                      "select Id, Name from Asset where Name = 'Safemate' and AccountId = '{0}'",
                                                      menumateAccountId));
            if (qr.size > 0)
            {
                safemateAsset   = (CCSFB.Asset)qr.records[0];
                safemateAssetId = safemateAsset.Id;
                return;
            }

            safemateAsset           = new CCSFB.Asset();
            safemateAsset.AccountId = menumateAccountId;
            safemateAsset.Name      = "Safemate";

            sr = binding.create(new CCSFB.sObject[1] {
                safemateAsset
            });
            CheckCreationResult(sr);
            safemateAssetId = sr[0].id;
        }
Exemplo n.º 6
0
        void CreateSafemateSettingsGroup()
        {
            CCSFB.Safemate_SettingGroup__c sg;
            CCSFB.SaveResult[]             sr;
            CCSFB.QueryResult qr = binding.query(String.Format(
                                                     "select Id from Safemate_SettingGroup__c where Name = 'Safemate' and Asset__c = '{0}'",
                                                     safemateAssetId));
            if (qr.size > 0)
            {
                safemateSettingGroupId =
                    (sg = (CCSFB.Safemate_SettingGroup__c)qr.records[0]).Id;
                return;
            }

            sg          = new CCSFB.Safemate_SettingGroup__c();
            sg.Asset__c = safemateAssetId;
            sg.Name     = "Safemate";

            sr = binding.create(new CCSFB.sObject[1] {
                sg
            });
            CheckCreationResult(sr);
            safemateSettingGroupId = sr[0].id;
        }