Exemplo n.º 1
0
        public static bool GetSharedFilePermission(string fileName, string processName, string userName, string tagStr, ref string iv, ref string key, ref uint accessFlags, ref string lastError)
        {
            bool retVal = false;

            try
            {
                lastError = string.Empty;
                ServiceReference1.ServiceSoapClient client = GetServiceClient(ref lastError);

                if (null == client)
                {
                    return(false);
                }

                string ivStr         = tagStr;
                string serverAccount = GlobalConfig.AccountName;
                int    index         = tagStr.IndexOf(";");
                if (index > 0)
                {
                    serverAccount = tagStr.Substring(0, index);
                    ivStr         = tagStr.Substring(index + 1);
                }

                UserInfo userInfo = new UserInfo();
                string   keyStr   = string.Empty;

                userInfo.FileName     = fileName;
                userInfo.AccountName  = serverAccount;
                userInfo.ProcessName  = processName;
                userInfo.UserName     = userName;
                userInfo.UserPassword = password;
                userInfo.CreationTime = DateTime.Now.ToFileTime();;
                userInfo.EncryptionIV = ivStr;

                string userInfoStr = DigitalRightControl.EncryptObjectToStr <UserInfo>(userInfo);

                retVal = client.GetSharedFilePermission(userInfoStr, ref key, ref iv, ref accessFlags, ref lastError);
            }
            catch (Exception ex)
            {
                lastError = "Get file key failed with error:" + ex.Message;
                retVal    = false;
            }

            return(retVal);
        }
Exemplo n.º 2
0
        public async Task <bool> ComprobanteConstatar(string CbteModo, long CuitEmisor, int PtoVta,
                                                      int CbteTipo, long CbteNro, string CbteFch, double ImpTotal,
                                                      string CodAutorizacion, string DocTipoReceptor, string DocNroReceptor)
        {
            mErrorCode = 0;
            mErrorDesc = "";

            CmpDatos CmpReq = new CmpDatos();

            CmpReq.CbteModo        = CbteModo;
            CmpReq.CuitEmisor      = CuitEmisor;
            CmpReq.PtoVta          = PtoVta;
            CmpReq.CbteTipo        = CbteTipo;
            CmpReq.CbteNro         = CbteNro;
            CmpReq.CbteFch         = CbteFch;
            CmpReq.ImpTotal        = ImpTotal;
            CmpReq.CodAutorizacion = CodAutorizacion;
            CmpReq.DocTipoReceptor = DocTipoReceptor;
            CmpReq.DocNroReceptor  = DocNroReceptor;
            ServiceReference1.ServiceSoapClient wscdc = getClient();
            var Resultado = await wscdc.ComprobanteConstatarAsync(mAuthRequest, CmpReq);

            if (Resultado.Body.ComprobanteConstatarResult.Errors != null && (Resultado.Body.ComprobanteConstatarResult.Errors.Length > 0))
            {
                mErrorCode = Resultado.Body.ComprobanteConstatarResult.Errors[0].Code;
                mErrorDesc = Resultado.Body.ComprobanteConstatarResult.Errors[0].Msg;
            }
            else
            {
                if (Resultado.Body.ComprobanteConstatarResult.Resultado == "A")
                {
                    return(true);
                }
                else if ((Resultado.Body.ComprobanteConstatarResult.Observaciones != null) && (Resultado.Body.ComprobanteConstatarResult.Observaciones.Length > 0))
                {
                    mErrorCode = Resultado.Body.ComprobanteConstatarResult.Observaciones[0].Code;
                    mErrorDesc = Resultado.Body.ComprobanteConstatarResult.Observaciones[0].Msg;
                }
                else
                {
                    mErrorCode = -1;
                    mErrorDesc = "Error Desconocido";
                }
            }
            return(false);
        }
Exemplo n.º 3
0
        private static ServiceReference1.ServiceSoapClient GetServiceClient(ref string lastError)
        {
            ServiceReference1.ServiceSoapClient client = null;

            try
            {
                BasicHttpBinding binding = new BasicHttpBinding();
                binding.OpenTimeout    = new TimeSpan(0, 0, 10);
                binding.CloseTimeout   = new TimeSpan(0, 0, 10);
                binding.SendTimeout    = new TimeSpan(0, 0, 10);
                binding.ReceiveTimeout = new TimeSpan(0, 0, 10);

                EndpointAddress endpoint = new EndpointAddress(new Uri(serverURI));

                client = new SecureShare.ServiceReference1.ServiceSoapClient(binding, endpoint);
            }
            catch (Exception ex)
            {
                lastError = "Connecting to server failed with error " + ex.Message;
            }

            return(client);
        }
Exemplo n.º 4
0
        public static bool AddShareFile(string policy, ref long creationTime, ref string key, ref string iv, ref string lastError)
        {
            bool retVal = false;

            try
            {
                lastError = string.Empty;
                ServiceReference1.ServiceSoapClient client = GetServiceClient(ref lastError);

                if (null == client)
                {
                    return(false);
                }

                retVal = client.AddShareFile(accountName, password, policy, ref creationTime, ref key, ref iv, ref lastError);
            }
            catch (Exception ex)
            {
                lastError = "Add new file to server failed with error:" + ex.Message;
                retVal    = false;
            }

            return(retVal);
        }
Exemplo n.º 5
0
        public static bool ClearAccessLog(ref string lastError)
        {
            bool retVal = false;

            try
            {
                lastError = string.Empty;
                ServiceReference1.ServiceSoapClient client = GetServiceClient(ref lastError);

                if (null == client)
                {
                    return(false);
                }

                retVal = client.ClearAccessLog(accountName, password, ref lastError);
            }
            catch (Exception ex)
            {
                lastError = "Clear access log failed with error:" + ex.Message;
                retVal    = false;
            }

            return(retVal);
        }
Exemplo n.º 6
0
        public static bool GetFileList(ref string fileListStr, ref string lastError)
        {
            bool retVal = false;

            try
            {
                lastError = string.Empty;
                ServiceReference1.ServiceSoapClient client = GetServiceClient(ref lastError);

                if (null == client)
                {
                    return(false);
                }

                retVal = client.GetFileList(accountName, password, ref fileListStr, ref lastError);
            }
            catch (Exception ex)
            {
                lastError = "Get file list failed with error:" + ex.Message;
                retVal    = false;
            }

            return(retVal);
        }
Exemplo n.º 7
0
        public static bool DeleteShareFile(string encryptionIV, ref string lastError)
        {
            bool retVal = false;

            try
            {
                lastError = string.Empty;
                ServiceReference1.ServiceSoapClient client = GetServiceClient(ref lastError);

                if (null == client)
                {
                    return(false);
                }

                retVal = client.DeleteSharedFile(accountName, password, encryptionIV, ref lastError);
            }
            catch (Exception ex)
            {
                lastError = "DeleteShareFile failed with error:" + ex.Message;
                retVal    = false;
            }

            return(retVal);
        }
Exemplo n.º 8
0
        public static bool ModifySharedFileDRInfo(string encryptedDRPolicy, ref string lastError)
        {
            bool retVal = false;

            try
            {
                lastError = string.Empty;
                ServiceReference1.ServiceSoapClient client = GetServiceClient(ref lastError);

                if (null == client)
                {
                    return(false);
                }

                retVal = client.ModifySharedFileDRInfo(accountName, password, encryptedDRPolicy, ref lastError);
            }
            catch (Exception ex)
            {
                lastError = "Set file DR info failed with error:" + ex.Message;
                retVal    = false;
            }

            return(retVal);
        }